C++ or Java for a Game Engine?

522d32996c54cf8ef40f9e04afb98d05
0
LizardGamer 101 Nov 06, 2010 at 10:41

I am an enthusiastic person when it comes to game engines, and so I am trying to create my own game engine and I’m trying to choose between some languages.

I’m sort of looking at Java and C++ to create an engine with, but I don’t know what language I should use because I’m a newbie with programming languages.

I was thinking if I was going to use C++ I would use AngelScript or Lua to script the game, and if I was going to use Java I would use Java to script because I don’t think AngelScript of Lua have been ported to Java or if I can use them at all in Java.

If you know the differences between these Languages (C++ and Java) for programming games, could you please give some helpful info, Like speed difference, ease of use etc.

And I know Java is more basic and C++ is for the more experienced person.

P.S. No need to tell me not to make an engine but a game instead, because I know the structure of a game engine already.

22 Replies

Please log in or register to post a reply.

A638aa42130293f319eda7fa4ba121f4
0
fireside 141 Nov 06, 2010 at 13:37

Java is a little slower, so that’s you’re first consideration. Take a look at some demos of the Jmonkey engine and see if it will be adequate. Java works pretty well with the web, depending on your engine, you can use applets or web apps, so it’s a convenient way to distribute games. Java doesn’t really need any scripting so it’s easy to extend engine classes to modify the engine for a certain type of game. That’s difficult, or nearly impossible with a scripted engine, without reverting back to c++ and then possibly adding new scripting.
Java is less secure in the sense that it’s easy to decompile. Java uses opengl for good or for bad, but it may mean more learning for someone who knows directx. If you are going to do a smaller, web centric engine, Java is probably a little better choice. There aren’t as many mid level libraries as c++ for it. There really aren’t a lot of java engines around, which should give you some idea of the demand of each, but then, specializing might be the better way to get noticed anymore.

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Nov 08, 2010 at 13:21

Depends on the engine’s target market: cutting-edge FPS or casual 2D side-scroller?

Anyways, if I wasn’t limited by language, I would not make a Java-based engine. I’d pick a language that is “closer to the metal” or compiles down to a lower level.

340bf64ac6abda6e40f7e860279823cb
0
_oisyn 101 Nov 08, 2010 at 18:26

If you’re considering Java, any reason why you’re not considering .Net?

6837d514b487de395be51432d9cdd078
0
TheNut 179 Nov 08, 2010 at 19:08

Java games on the desktop are practically unheard of. If you practice your Java skills, you will likely end up as a server or web developer somewhere. C++ as a language is as good as any other and will make you more marketable in the gaming industry. .NET also has a strong pressence with tools developers. LUA is a good scripting language and is my prefered choice, but also consider Python as it’s quite popular and will earn you brownie points in the game industry.

Something else to consider…

Java -> port to the ‘droid or to the crackberry
.NET -> port to M$ phone
C++ -> port to symbian

If you’re good, you’ll code your Java or C++ classes such that it would be minimal effort to migrate between the two languages if that should ever happen to you. The core of my C++ engine was ported to C# with minimal adjustments. As a result, I work with the same code base accross multiple platforms including Silverlight, Symbian, Linux, Mac, and iOs. Code is your asset, so write it once and use everywhere.

340bf64ac6abda6e40f7e860279823cb
0
_oisyn 101 Nov 08, 2010 at 19:41

@TheNut

Java games on the desktop are practically unheard of.

Indeed. I mean, who would ever hear of Minecraft… That game is destined to be a failure. :)

6837d514b487de395be51432d9cdd078
0
TheNut 179 Nov 08, 2010 at 21:07

Hardy har har :)

A638aa42130293f319eda7fa4ba121f4
0
fireside 141 Nov 08, 2010 at 23:01

Java games on the desktop are practically unheard of.

The games that do use java on the desktop tend to be web related such as Runescape and Bang Howdy. Runescape is the second most played MMO. I think it’s a great language, but I’m a hobbyist. Language really isn’t very important on the desktop. What you say about code, though, is a good idea. Not so much for an engine in my circumstances, but things like a pathfinding class, fsm, etc. I’ll let someone else write the engine, I don’t have that kind of patience. Using an extensible language is important to me, so c++ with scripting just gets in the way as far as I’m concerned, at least in most cases. If it’s highly specialized, it’s all right.

522d32996c54cf8ef40f9e04afb98d05
0
LizardGamer 101 Nov 08, 2010 at 23:08

Minecraft… That game is destined to be a failure

Well alot of people have heard of Minecraft and its not going to be destined to be a failure!

522d32996c54cf8ef40f9e04afb98d05
0
LizardGamer 101 Nov 08, 2010 at 23:13

But now I’m sort of leaning towards C++, because of the things that can be done with it

340bf64ac6abda6e40f7e860279823cb
0
_oisyn 101 Nov 09, 2010 at 08:39

@LizardGamer

Well alot of people have heard of Minecraft and its not going to be destined to be a failure!

I guess your sarcasm-o-meter is broken.

But you haven’t answered my question. Why not .Net (specifically, C#)? That way, if it just so happens no need extra performance somewhere, you can implement that in C++ and create the bindings between native C++ and managed C# using C++/CLI.

8563f7b73aeb34bb8604f1dd8f546c88
0
Mattias_Gustavsson 101 Nov 09, 2010 at 11:09

.net runtime is massive though…

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Nov 09, 2010 at 13:41

@Mattias Gustavsson

.net runtime is massive though…

Pretty much on a majority of machines now.

http://www.statowl.com/microsoft_dotnet.php

63% on v3, and 21% already up to v4…

340bf64ac6abda6e40f7e860279823cb
0
_oisyn 101 Nov 09, 2010 at 21:17

@Mattias Gustavsson

.net runtime is massive though…

35 MB for .Net 4.0. Yes, indeed, 3.5 SP1 was a whopping 231 megs. Don’t use it :)

522d32996c54cf8ef40f9e04afb98d05
0
LizardGamer 101 Nov 09, 2010 at 23:32

@The Wierd one .oisyn

Why not .Net (specifically, C#)?

Because I don’t know anything about them!!!!

5ccedf5e0f538b594eb578f003ade3eb
0
Hyper 96 Nov 09, 2010 at 23:35

@LizardGamer

Because I don’t know anything about them!!!!

You should get busy reading then! :p

8563f7b73aeb34bb8604f1dd8f546c88
0
Mattias_Gustavsson 101 Nov 10, 2010 at 07:50

@.oisyn

35 MB for .Net 4.0.

Wow, that’s a massive improvement - it’s actually starting to become interesting then :-) I’ll probably stick with C++ myself, for performance and out of habit, but it’s still good to see C# becoming more of a viable option - I know a lot of people like it.

522d32996c54cf8ef40f9e04afb98d05
0
LizardGamer 101 Nov 10, 2010 at 07:50

@Hyper

You should get busy reading then! :p

Na, I think I’m going to stick with C++ and scripting with Lua

340bf64ac6abda6e40f7e860279823cb
0
_oisyn 101 Nov 10, 2010 at 16:25

@LizardGamer

Because I don’t know anything about them!!!!

C# is basically just Java with extra features :)

8676d29610e6c98d6dd2d9c38528cd9c
0
alphadog 101 Nov 10, 2010 at 17:18

@Mattias Gustavsson

Wow, that’s a massive improvement - it’s actually starting to become interesting then :-) I’ll probably stick with C++ myself, for performance and out of habit, but it’s still good to see C# becoming more of a viable option - I know a lot of people like it.

Actually, there is a Client Profile for Net3.5 SP1, which weighs in at 28MB. And, yes, there was a massive improvement in the Client Profile, both in content and “visibility” of it. MS realized shoving the whole framework wasn’t going to work too well.

http://msdn.microsoft.com/en-us/library/cc656912.aspx

There are also lots of web installers that start out at 1MB, and download as needed.

Lastly, users don’t need to have the whole framework to run your stuff if they don’t need the whole framework to run your stuff.

72423d7a32a99ae33a2788b93ad941fe
0
Lalaporo 101 Jan 03, 2011 at 21:08

well chosing a language is more than just what would be smoother and look better, you also have to know how to write in that language :
java and c++ are a whole lot different to me, right now im learning BASIC, witch once experienced in BASIC can easily be transformed into c++ or java. It is bassicly both of them combined, it is really simple to. If you are interested i would sugest the to use a compiler called BASIC4gl, really nice 3d work space. But just because it is called BASIC doesnt mean it is going to be easy, im just saying it would be easier to learn BASIC and transform into c++ or java, then to learn c++ and find out that it isnt what you where looking for.

B7109317066ddd5327cb0674388c4974
0
Luz_Reyes 101 Jan 05, 2011 at 16:45

Go with c++. It’s better for games.

340bf64ac6abda6e40f7e860279823cb
0
_oisyn 101 Jan 05, 2011 at 20:40

Thank you for that very insightful post filled with compelling arguments that proves your statement.