Adventures in Game Development -- Day 18

Today I took me first steps in learning Python. I didn't know much about the language before stepping in, other than it was easier than C++. Now, after having learned some of the language, I can safely say that it is much easier.

Here are some examples of how Python is easier than C++:

To declare any variable in C++, you have to precede the variable name with a type, like

Int variablename;
Or
Char variablename;

But in Python, you don't need to give a type, the language figures that out itself. So for example, this is how you declare a variable in Python

Variablename = 10

As you can see from above, Python also doesn't need anything to represent ending a line. So while you type a semi-colon is C++ to end the line, you type nothing and just move onto the next line in Python.

Outputting to the console is also much easier in Python. Here's some basic output in C++

Int variablename = 10;

cout << "The variable name equals " << variablename << endl;

The same in Python is

variablename = 10

print "The variable name equals", variablename

Finally, if/elseif/else statements are also easier in Python. An if/else statement in C++ is written like this

if(variablename > typename)
       cout << "variablename is greater than typename << endl;
else
       cout << "variable name is not greater than typename << endl;

The same exact statement in Python is

if variablename > typename:
       print "variablename is greater than typename
else:
       print "variable name is not greater than typename

This is why I really like Python. While it may be slower than C++ and other programming languages in execution, its very English-like syntax makes it quite easy to write.

14 comments:

Tomas.G said...

Good post. Keeep it up.

yourminigames.com said...

Cool Blog!

FreeMe said...

sweet post.

happyhacker said...

Doing good man. F# is cool too, and you might like LUA because you can incorporate it into games that use C++.

Ezz said...

I've only used python once, and it was a tutorial to learn it.

It is straight forward and useful, specifically for prototyping.

jblogger45 said...

great post

Brick said...

nice hope you get python down =)

FateIT said...

Good luck, python is a pain :P

Jesse Crows said...

you are making great progress!

Ivan said...

seems like python just said "fuck it, I'll do it myself" to ending lines.

Jack of Diamonds said...

good post!

Dola said...

great post =D

NovaJ31 said...

Hmm, I was thinking of learning a language, maybe Python is the way to go.

John said...

Python is a great programming language. It's easy syntax makes programming a lot more fun than with other lower level languages, and it's surprisingly fast for the type of language it is.

Post a Comment