Which language is better to learn? C++ or Java?

DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #76
This "trend" towards GC isn't. I'd call it more a "back to the roots" approach, similarly to the ":=". As far as GC goes, I don't see any reason against it, at least on the Desktop.
Luminary
Posts: 5,143
Joined: 2002.04
Post: #77
OOC's intention is to have the option of turning off GC and not just leaking like a sieve... currently you can turn off GC but you just leak.

The trend toward GC is because a good implementation is faster than manual memory management under heavy threading, and it's a lot easier on the programmer.
Sage
Posts: 1,482
Joined: 2002.09
Post: #78
AnotherJake Wrote:Interesting. There seem to be some parallels between ooc and Go. I have to agree ooc looks pretty good too. Funny they both include the ":=" thingy for declare/assign (or whatever you call it). I don't get the trend toward mandatory garbage collection (haven't read enough on ooc to know if it forces it, but Go apparently does).

Garbage collection is optional in OOC. You can disable it entirely if you want. It doesn't prevent you from using malloc(), but also gives you gc_malloc()

I don't get the attitude towards not wanting garbage collection to be honest. Wink It might be "easy" but it's incredibly tedious and error prone even if you know what you are doing. I'm super lazy and would rather have a 1% performance hit than write more code that takes hours to debug when it goes wrong. There are rather few times when I don't want garbage collection personally.

In Chipmunk there are a couple of places like the collision detection system that would produce a lot of unwanted garbage, and a couple of places where I've profiled and added in some alloca() calls. Overall it is much more pleasant to use from Ruby where I don't have to worry about memory management though. I wouldn't mind using something like OOC where I have no hassle garbage collection AND the ability to stack allocate or malloc when I felt it was more appropriate.

On top of that, OOC has very nice operator overloading that lets me do all my vector math in inlined functions. After playing with it for a bit, I was rather happy to see that I could write something like (vec2(5,6) + vec2(8,9))*vec2(2,2) and have it completely optimize away all the function calls in the resulting assembly output! In fact, for a constant expression like that, it was completely folded down to simply 56. My Ruby extension would have had to allocate the 3 vectors, the 2 temporary values and dynamically dispatch the operator calls. Slow slow slow, but more than fast enough for many of the games I want to make.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Moderator
Posts: 3,577
Joined: 2003.06
Post: #79
Oh, I'm not trying to imply that I think GC is a bad thing, just that I think making it *mandatory* might cripple a language a little, perhaps when it comes to its usage on things like embedded systems where GC might not be desirable. It's nice that OOC intends to have an option of turning it off. I didn't see that mentioned on the main page.
Member
Posts: 254
Joined: 2005.10
Post: #80
AnotherJake Wrote:Interesting. There seem to be some parallels between ooc and Go. I have to agree ooc looks pretty good too. Funny they both include the ":=" thingy for declare/assign (or whatever you call it)..

I think the reason we are seeing the := operator show up lately is the explosion of javascript in recent years. A lot of people have been bitten by bugs where they forgot to define a variable and it ended up in global scope being written by someone else.

I like most of what ooc is doing, but the most interesting feature of Go is the typing system. I haven't played with it much, but it seems that Go has basically formalized Duck typing into a compile-time checked operation. Generics probably won't make a whole lot of sense in Go since you could write an interface that applies to all the objects you need to work on without forcing anyone to actually declare they are implementing it. You can basically add type checking that didn't exist before simply by writing the code you need.
Sage
Posts: 1,482
Joined: 2002.09
Post: #81
Consider the following contrived example:
Code:
if(true){
  a = 5
}
a += 1

Should:
  • a be 6
  • Should a variable named 'a' be defined inside the if's block. Thus making the a += 1 a compile error as there is no 'a' defined out of the block.

Another consequence of having no way to declare variables is that you cannot define variables inside of a block named the same as an outer variable. If you have a global named 'myNeatVariable', then use a variable inside of a function named 'myNeatVariable', you will be overwriting the global by accident. Just as bad, what if you add a global variable that is the same name as a variable already used by a function? BAM!

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Member
Posts: 26
Joined: 2010.01
Post: #82
To be honest, both languages can be made "fast enough", which is really what counts for indie games, since you control your game concept as well as tech.

But when picking a language to learn, you should also think about industry standards and what you eventually want to do, alongside code performance and the speed of writing code. If you want to move into internet games or mmo server writing, or just want to do hobbyist game coding, learning Java is a good option, as its slightly easier. If you're interested in pure tech or think you might eventually want to do AAA console or PC games (or financial applications, hoho), then C/C++ is by far the better option.

Personally, I lean towards C++, mainly because the higher performance ceiling generally allows you to do more if you have expert coding skills.
Nibbie
Posts: 2
Joined: 2010.07
Post: #83
HI,

If you want to learn OOP learn Java( i reccomend C# ).

Bye.
Moderator
Posts: 916
Joined: 2002.10
Post: #84
(Sep 23, 2010 08:17 AM)direction Wrote:  HI,

If you want to learn OOP learn Java( i reccomend C# ).

Bye.

why? Explain your likes / dislikes instead of simply stating your opinion so that we may gain some insight.

I personally can't agree.
If your goal is to eventually get into the gaming industry, it's better to learn the languages used: aka C++
If your goal is just learn object orientation, C# is not bad.
If you want to focus strictly on mac / iPhoning, Objective-C's style of OOP is far better.

Notice, all of these languages teach/have OOP, but you learn something useful to apply to something else. Most people have troubles shifting from one language to another to another.

I'm not saying Java has no place, I just don't see it being useful outside of "learning"
Moderator
Posts: 435
Joined: 2002.09
Post: #85
As Skyhawk says, learn the language you'll be using, if possible. It's all very well to have a grounding in a more "ideal" language first, but you don't learn Latin first in order to learn Spanish. Most of your time will be spent not on theory, but on practice- designing, writing and debugging. And all the languages being discussed here have rich libraries that will help you minimize time on reinventing the wheel.

A secondary concern is what kind of tools (IDE, source level debugger) are available to you- are they free, are they stable? I personally think C# will be easier to learn than C++, more relevant than Java, but if you are on a Mac you might be stuck with the Mono implementation, and I've had mixed experiences there. OTOH you can script Unity with C#, which might not be a bad way to pick up some basic syntax.

Measure twice, cut once, curse three or four times.
Moderator
Posts: 1,560
Joined: 2003.10
Post: #86
It's weird how new members keep digging up this thread to post something that doesn't contribute at all. I've deleted the most recent one which was very spambot-like. (Posting this so people know Matt wasn't the one performing necromancy...)
Moderator
Posts: 435
Joined: 2002.09
Post: #87
I bet if I look back I've posted more or less the same opinion over and and over again, once a year or so, every time the thread is brought to life again. Rolleyes Boy, I get sick of myself sometimes..

Measure twice, cut once, curse three or four times.
Moderator
Posts: 452
Joined: 2008.04
Post: #88
I am leaning towards locking this thread. Anyone else?

Howling Moon Software - CrayonBall for Mac and iPhone, Contract Game Dev Work
Thread Closed 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Learn java ? icross 6 6,097 Apr 22, 2009 11:11 PM
Last Post: AnotherJake
  What to learn next? stevejohnson 3 3,177 Nov 19, 2006 04:08 PM
Last Post: unknown