Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 624 625 [626] 627 628 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 909187 times)

lethosor

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9375 on: April 18, 2016, 08:15:44 pm »

In C++ you'd want to use const in almost all cases.  #define is a relic from before C supported true constant variables, and C++ was originally derived from C.

C probably supports the const keyword these days too, but I'm not sure.

To expand on why, #define can do a lot of things you don't expect it to.  It largely behaves as a text replace in your code, so if you did this:

Code: [Select]
#define something 5

int somethingElse = 5;

You'd get a compilation error.  Why?  Because the compiler would see this:

Code: [Select]
int 5else = 5;

This example actually isn't correct (it sets somethingElse to 5 just as you'd expect), because the preprocessor replaces all occurrences of "something" surrounded by token boundaries (i.e. stuff that couldn't be part of a variable/definition name), not all occurrences of "something" without restrictions. (It also won't replace occurrences of "something" anywhere inside double quotes.)
The exact rules are a bit more nuanced than that, and I'm sure you could find similar examples that do produce unexpected behavior.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9376 on: April 19, 2016, 07:17:12 am »

Alright, can somebody explain to me why the majority of C and C++ code I see around (particularly in tutorials and examples) still uses arcane acronyms and abbreviations for variable names? I know C languages have been around since the days when a text file could be a credible threat to your storage capacity, but come on. It's space year 2016, you can spare a few bytes to type out a name that other people can read.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.

TheDarkStar

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9377 on: April 19, 2016, 07:38:48 am »

Alright, can somebody explain to me why the majority of C and C++ code I see around (particularly in tutorials and examples) still uses arcane acronyms and abbreviations for variable names? I know C languages have been around since the days when a text file could be a credible threat to your storage capacity, but come on. It's space year 2016, you can spare a few bytes to type out a name that other people can read.

It's probably habit. Also, it might not cause space issues, but it takes more time to write out something that's long.
Logged
Don't die; it's bad for your health!

it happened it happened it happen im so hyped to actually get attacked now

Rose

  • Bay Watcher
  • Resident Elf
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9378 on: April 19, 2016, 08:27:16 am »

Alright, can somebody explain to me why the majority of C and C++ code I see around (particularly in tutorials and examples) still uses arcane acronyms and abbreviations for variable names? I know C languages have been around since the days when a text file could be a credible threat to your storage capacity, but come on. It's space year 2016, you can spare a few bytes to type out a name that other people can read.

It's probably habit. Also, it might not cause space issues, but it takes more time to write out something that's long.

I see you are not familiar with any IDE ever.
Logged

Parsely

  • Bay Watcher
    • View Profile
    • My games!
Re: if self.isCoder(): post() #Programming Thread
« Reply #9379 on: April 19, 2016, 08:32:14 am »

Alright, can somebody explain to me why the majority of C and C++ code I see around (particularly in tutorials and examples) still uses arcane acronyms and abbreviations for variable names? I know C languages have been around since the days when a text file could be a credible threat to your storage capacity, but come on. It's space year 2016, you can spare a few bytes to type out a name that other people can read.

It's probably habit. Also, it might not cause space issues, but it takes more time to write out something that's long.
Even Notepad++ has tab complete.
Logged

Reelya

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9380 on: April 19, 2016, 08:34:26 am »

Maybe tutorial code tries to minimize the amount of typing for noobs?

TheDarkStar

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9381 on: April 19, 2016, 09:07:40 am »

Alright, can somebody explain to me why the majority of C and C++ code I see around (particularly in tutorials and examples) still uses arcane acronyms and abbreviations for variable names? I know C languages have been around since the days when a text file could be a credible threat to your storage capacity, but come on. It's space year 2016, you can spare a few bytes to type out a name that other people can read.

It's probably habit. Also, it might not cause space issues, but it takes more time to write out something that's long.
Even Notepad++ has tab complete.

Not the first time you type it :P
Logged
Don't die; it's bad for your health!

it happened it happened it happen im so hyped to actually get attacked now

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9382 on: April 19, 2016, 09:28:46 am »

So there's a document floating around the net that lots of you have probably seen. We mocked the guy at work yesterday but no one has posted it here yet.

Here you go. This guy runs a company, manages people, and has lots of clout with other people who also run companies and manage people.
Logged

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9383 on: April 19, 2016, 11:09:17 am »

Even Notepad++ has tab complete.
Not the first time you type it :P
That's fine... until you have two different long-named variables in the same file with similar names. If I have "distraction_runaway_bombs" and "distraction_runaway_cops" then I'm going to have to type out "distraction_runaway_c" before tab complete will properly complete it to "distraction_runaway_cops" instead of "distraction_runaway_bombs". Of course that's still no excuse for using things like "ctlrdr" as variable/function names, which is a horrible practice that colleges are doing their best to stamp out. Names should be in a happy medium length where they are long enough to be descriptive, but there's no need to, for example, prepend the program name to every single variable and make variables like "my_program_7_the_really_cool_variable_that_tracks_how_hot_the_player_is" either.
« Last Edit: April 19, 2016, 11:12:06 am by i2amroy »
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

EnigmaticHat

  • Bay Watcher
  • I vibrate, I die, I vibrate again
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9384 on: April 19, 2016, 11:13:18 am »

So there's a document floating around the net that lots of you have probably seen. We mocked the guy at work yesterday but no one has posted it here yet.

Here you go. This guy runs a company, manages people, and has lots of clout with other people who also run companies and manage people.
Overwork your employees, promise them money but don't actually pay them much, do whatever you can to keep them from leaving the company on their own terms = good employees.

Wage slaves = bad employees.

Okay then.
Logged
"T-take this non-euclidean geometry, h-humanity-baka. I m-made it, but not because I l-li-l-like you or anything! I just felt s-sorry for you, b-baka."
You misspelled seance.  Are possessing Draignean?  Are you actually a ghost in the shell? You have to tell us if you are, that's the rule

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9385 on: April 19, 2016, 11:35:39 am »

So there's a document floating around the net that lots of you have probably seen. We mocked the guy at work yesterday but no one has posted it here yet.

Here you go. This guy runs a company, manages people, and has lots of clout with other people who also run companies and manage people.
That just goes so good with yesterday's Three Panel Soul comic: :P
Spoiler (click to show/hide)
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

Willfor

  • Bay Watcher
  • The great magmaman adventurer. I do it for hugs.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9386 on: April 19, 2016, 12:18:55 pm »

Maybe tutorial code tries to minimize the amount of typing for noobs?
If it's this please stop.

I bounced off of so many C and C++ tutorials when I was starting out because the names were jibberish that I could never figure out what they were trying to be, and therefore never lock them down in my head enough to memorize them. That's why on my first exposure to C# I clung to it like a life raft, and it took many years before I would even bother to look at a piece of C code without cringing.
Logged
In the wells of livestock vans with shells and garden sands /
Iron mixed with oxygen as per the laws of chemistry and chance /
A shape was roughly human, it was only roughly human /
Apparition eyes / Apparition eyes / Knock, apparition, knock / Eyes, apparition eyes /

Telgin

  • Bay Watcher
  • Professional Programmer
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9387 on: April 19, 2016, 12:34:57 pm »

Some of the C++ tutorials and examples I've seen are almost impenetrable.  I'm pretty familiar with the language and it still took me a lot of banging my head against code examples to figure out how to use map containers correctly, largely because the code examples were just a lot of template garbage with either no comments or unhelpful comments.  Didn't help that g++ gives even more impenetrable template garbage when you get it wrong.

Well formatted C isn't too ugly or hard to parse for me, but a lot of tutorials (and programmers...) do not use well formatted C.  C++ on the other hand, feels to me like it invariably becomes ugly when a program becomes nontrivial.

So there's a document floating around the net that lots of you have probably seen. We mocked the guy at work yesterday but no one has posted it here yet.

Here you go. This guy runs a company, manages people, and has lots of clout with other people who also run companies and manage people.

Huh.  I'm not sure how to classify myself by his standards since I'm single, have no interest in a girlfriend or wife and yet I'm motivated by money and can be burnt out of my own accord.  I guess I don't fit his mold well enough to be employed by him.  I'm a maverick that might do something crazy.
Logged
Through pain, I find wisdom.

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9388 on: April 19, 2016, 12:40:07 pm »

Well formatted C isn't too ugly or hard to parse for me, but a lot of tutorials (and programmers...) do not use well formatted C.  C++ on the other hand, feels to me like it invariably becomes ugly when a program becomes nontrivial.
Well-formatted C++ looks just as good as well-formatted C, (and has the advantage of more names coming from the std library and being standardized rather than being whatever that particular coder decided to call their queue structure). The big problem is that since C++ has more tools given to the user out of the box, it means that those people who still hold onto the ancient "impenetrable named stuff" traditions can mess things up even worse than they would be able to do with out of the box C. (Though yeah, a good Clang compiler that actually gives sensible, human-readable error output on compilation is something I suggest to anyone who has the hardware/software combinations that support it).
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

itisnotlogical

  • Bay Watcher
  • might be dat boi
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #9389 on: April 19, 2016, 12:42:32 pm »

C and C++ (barring header files, #include instead of using, minor syntax differences) actually looks a lot like C#. Semicolons for line endings, function declarations have the format "type name (arguments)", code goes inside curly braces, etc.

Most unintelligible C/++ that I've seen is because the 1337 h4ck3r writing the tutorial/document/etc. wants to use fostrdr (File Output STReam DiRectory) instead of outDir, output_directory, outputDir, or any other reasonable human-readable way of writing this pretend variable name.
Logged
This game is Curtain Fire Shooting Game.
Girls do their best now and are preparing. Please watch warmly until it is ready.
Pages: 1 ... 624 625 [626] 627 628 ... 796