Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 21 Oct 2011
Online Last Active Today, 08:28 AM

Posts I've Made

In Topic: Some programmers actually hate OOP languages? WHAT?!

27 January 2015 - 09:21 AM

Problem is, I will never learn the right way to code from the wrong way if I don't share my code and no one explains it to me.

TL;DR - unless you've been telling everyone that you're the greatest software engineer who's ever lived, you should never feel like that.


. . .



To add to that:

- Egoless Programming: http://blog.codinghorror.com/egoless-programming-you-are-not-your-job/

- You Are Not Your Code: http://www.hanselman.com/blog/YouAreNotYourCode.aspx

In Topic: A Starting Point

26 October 2014 - 12:13 PM

Go with something recent -- i.e., targeting C++11/C++14; anything older is a waste of time, especially when learning.

Even if you end up unlucky enough to be confined to maintaining legacy code, it's always easier to pick up older C++ coding style along the way if you already are familiar with the foundations of the language. And getting familiar with the foundations of the language is definitely easier starting with C++11.


Here's the official getting-started list: http://isocpp.org/get-started

I think the recommendations there are 100% spot on, so I won't repeat them here. I can just say that personally I think "C++ Primer" may be the choice for you (and that's what I usually recommend to C++-is-not-my-first-programming-language programmers).


For more, see The Definitive C++ Book Guide and List: http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list


BTW, Scott Meyers is working on Effective Modern C++: http://scottmeyers.blogspot.com/2014/09/the-four-stages-of-doneness.html

From the previews so far it definitely looks a great second/third C++ book to have.


Now, that's as far as the learning is concerned (worth emphasizing: you definitely need a book, IMHO you can't really learn much from the on-line references that won't be covered in a first chapter or two of a good book).

Regarding the reference, worth bookmarking and revisiting as you learn along the way:



For instance, sooner or later you'll need most of the algorithms listed here -- http://en.cppreference.com/w/cpp/algorithm -- it may save you quite some time to at least get familiarized with their existence, in order to avoid unnecessarily reimplementing the wheel :-)


Good luck!

In Topic: Aspiring Game Developer, Fluent in C++, What Do I Learn Now?

13 September 2014 - 02:11 PM

I'd also add Lua -- it's more minimalistic than Python and is often useful for embedding as a scripting language for your game (so that the players can extend it: modify the AI behavior, add custom scenarios, etc.). In fact, Lua would be my first choice for an embedded scripting language (not just) in a gamedev context.


It's also very easy to get started: http://www.lua.org/pil/


Here's a comparison: http://lua-users.org/wiki/LuaVersusPython (even though it's hosted on lua-users it points both the upsides and the downsides of both).


OTOH, if you already know Python, picking up Perl wouldn't necessarily have the highest priority (the use-cases of these substantially overlap).

In Topic: SFML - Can't even compile tutorial code

19 February 2014 - 06:55 AM

Try simply following the official tutorials: http://www.sfml-dev.org/tutorials/2.1/

In Topic: C++ templates, are they worth it?

08 January 2014 - 04:40 PM

These are some pretty good starting points ("old-code-can-call-new-code" is a pretty succinct description):

One other thing -- they go hand in hand with "auto" and genericity:

For instance, instead of writing:

int add(int a, int b) { return a + b; }
float add(float a, float b) { return a + b; }
double add(double a, double b) { return a + b; }

int x = add(1, 2);
float y = add(1.f, 2.f);
double z = add(1., 2.);

You can simply write:

template <typename T>
T add(T a, T b) { return a + b; }

auto x = add(1, 2);
auto y = add(1.f, 2.f);
auto z = add(1., 2.);

So they help you achieve generic, reusable code that doesn't just work for a particular type, but for a bunch of types that happen to satisfy a concept: http://en.cppreference.com/w/cpp/concept

// This concept is implicit here -- operator "+" has to exist. You can make it explicit with type-traits, static_assert, and enable_if.


This is useful -- say, instead of "add" taking two numbers, think of "will_first_monster_win" taking two monsters:

template <typename FirstMonsterType, typename SecondMonsterType>
bool will_first_monster_win(const FirstMonsterType & first_monster, const SecondMonsterType & second_monster)
  return strength(first_monster) >= strength(second_monster); // super-fancy combat algorithm!

Now, if you add new monster types to your game, your "will_first_monster_win" function will keep working unmodified -- as long as the relevant (new) "strength" function exists (let's call this particular existence requirement a "has-strength" concept -- in other words, FirstMonsterType & SecondMonsterType in the "will_first_monster_win" function will successfully match any types that satisfy the "has-strength" concept). In other words, you can extend your code (and add new code) without modifying the already written ("old") code: https://en.wikipedia.org/wiki/Open/closed_principle

// Note: the linked article happens to use inheritance/inclusion-run-time-polymorphism (typical OOP technique) to illustrate this; in many ways, however, templates/compile-time-polymorphism (typical Generic Programming) as in the "will_first_monster_win" example will work just as well if not better.


Without templates, you'd have to know the types of your monsters in advance / right at the moment when you're implementing "will_first_monster_win" -- and then rewrite it / provide overloads / etc. each time you add new monster type. Or just settle for a boring game with fixed monster types :-(


With templates you can save quite some time, speed up your experiments, and keep adding increasingly cruel monsters, so you can provide more fun for the players :-)