Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

8/16/12

Curious look into code evaluation

If you have been programming for a while, you already should know about operator precedence. If you for some reason don't, now is a good time to read about it on from Wikipedia or the documentation of your language of choice.

Before proceeding, remember that this may contain some erroneous information, and if you notice any, please inform me so that article can be fixed.

Let's take a rather simple set of expressions:

int i = 5; 
i = ++i + ++i;

This seems rather simple, doesn't it? So did I think, but the results (which we'll see a bit late) left me thinking wtf was actually going on. If we look at the Wikipedia-article, we can see that unary operators such as prefix and suffix increment and decrement come before the addition and substraction, at least in C-family of languages. Now, what do you think the answer will be? Write your guess down somewhere, we'll take a small plunge in to the world of compilers soon.

So, you got your answer? Good. If you did a quick test with a short code of piece, shame on you. Now, let me guess what you got.

If you used Python or Ruby, you got 10.
If you used JS, Java or C#, you got 13.
If you used C, C++ or Perl, you got 14.

Wait, what? How does this even happen?


9/12/10

Starting developing games

This year I will start developing some games. The first one is a game made with C# using XNA 3.0 (I yet don't have any idea what it will be like!) and the second one, a larger and more ambitious one, will be made using C++.

But first something little about me. I am 20 year old student in University of Oulu, majoring in Information Processing Science and also taking courses in mathematics. I have pretty much very little experience in programming, thus far I've programmed with Java for about a year and C/C++ for three months. I've great ambition in making games, although I understand that right now these projects will most likely be more than I can chew, but what I've learned about programming in this short time is that one must learn from one's mistakes. And what would be a better way to make mistakes than creating a game?