Jump to content


Java or C++


39 replies to this topic

#1 MMO

    New Member

  • Members
  • Pip
  • 5 posts

Posted 26 September 2009 - 12:39 PM

Hello, I've had lots of game programming experence with the blitz and other languages. Now I'm considering to learn C++ or Java; I know that these languages are not for a beginner programmers so thats why I'm glad to took the time with blitz! I have a few questions about these languages and which one to choose from... I know that both languages are very powerful for games. Do any of these languages have directx 10 or 9 support?(I need some directx 10 support becouse blitz only has dx7 support)

#2 Mattias Gustavsson

    Senior Member

  • Members
  • PipPipPipPip
  • 413 posts

Posted 26 September 2009 - 01:49 PM

It depends a bit on what your goal is. If you want to work in the games industry, you need to know C++, and you need to know DirectX (not OpenGL).

If you're learning just to make your own little games, then Java is as good a choice as C++. There's differences of course, but you'll be able to make games with both. If you're interested in DirectX 10 support though, I'd say C++ is the better choice, as DirectX is configured for C++ use out-of-the-box, while on Java you probably (?) need some sort of wrapper...
  • www.mattiasgustavsson.com - My blog and current projects
  • www.rivtind.com - My Fantasy world and isometric RPG engine
  • www.pixieuniversity.com - My Software 2D Game Engine

#3 MMO

    New Member

  • Members
  • Pip
  • 5 posts

Posted 26 September 2009 - 03:31 PM

Mattias Gustavsson said:

It depends a bit on what your goal is. If you want to work in the games industry, you need to know C++, and you need to know DirectX (not OpenGL).

If you're learning just to make your own little games, then Java is as good a choice as C++. There's differences of course, but you'll be able to make games with both. If you're interested in DirectX 10 support though, I'd say C++ is the better choice, as DirectX is configured for C++ use out-of-the-box, while on Java you probably (?) need some sort of wrapper...

Well I guess i should go with c++ then. Since that c++ supports directx 10 the graphics wont come out fuzzy like in the blitz3d. Also when I start learning c++ do you think I should start with 2d or 3d?(I have experience with both 2d and 3d)

#4 Mattias Gustavsson

    Senior Member

  • Members
  • PipPipPipPip
  • 413 posts

Posted 26 September 2009 - 04:11 PM

MMO said:

Since that c++ supports directx 10 the graphics wont come out fuzzy like in the blitz3d

Hmm, I don't understand what you mean here... if you use 2d-sprites and linear interpolation, things will look just as blurred in DirectX10 as in DirectX7... If you use 3D objects, it will look just as sharp in both DirectX7 as it will in DirectX10.

Perhaps it will be easier for us to advise you if you describe what type of game you're making, and what the reasons are that you feel that Blitz might be inadequate...
  • www.mattiasgustavsson.com - My blog and current projects
  • www.rivtind.com - My Fantasy world and isometric RPG engine
  • www.pixieuniversity.com - My Software 2D Game Engine

#5 fireside

    Senior Member

  • Members
  • PipPipPipPip
  • 1617 posts

Posted 27 September 2009 - 03:34 AM

If you have experience in 3d, then you can probably just stick with 3d. As far as language, the choice is really if you want to use a scripted language, and there are quite a few, or use c++. The reasons for using a scripted language are that you won't be hunting down memory errors and you can edit the game and run it rather than re-compiling every time you make changes. You were already using scripting when you were using Blitz3d. It doesn't take long to learn another scripting language if it's different. The reason for using later versions of Directx or Opengl is for better shadowing and shaders mostly, and also speed. If you are a hobbyist, it's going to be a lot faster using one of the engines and probably a scripted language to develop your game. Using c++ with an engine like Ogre or Irrlicht or something isn't bad either because most of the memory management is taken care of, you just make a few calls. There are a few complete engines written in Java which are pretty nice, but there will be a slight speed hit since it's not as fast as c++. There are also some engines using c# which eliminates memory management and has a lot of extra libraries. Personally, I would look at engines first and find one that did what you wanted and then think about the language after. When you do learn a language, however, you should study it without the engine first. On the other hand, if you want to get into the game industry, you should probably study c++ and possibly directX like Matt said. You could also look at XNA, I think they call it, after learning c++ or any of the engines that use c++. XNA can also use c# which is a lot like java but it has a very large developer community and it can be used to possibly sell your game. It's pretty tough to actually write a game in 3d by yourself without an engine or higher library than directX. When you say you have experience in 2d and 3d, hopefully this means you have written complete games with menus, levels, etc. If you haven't done that, it would probably be better to use 2d.
Currently using Blender and Unity.

#6 Mattias Gustavsson

    Senior Member

  • Members
  • PipPipPipPip
  • 413 posts

Posted 27 September 2009 - 06:56 AM

fireside said:

you can edit the game and run it rather than re-compiling every time you make changes.

There's also Edit-and-continue in visual studio: set a breakpoint, make your changes, resume execution. Works a treat most of the time. I don't think using a scripting language is useful for the lone dev/hobbyist.
  • www.mattiasgustavsson.com - My blog and current projects
  • www.rivtind.com - My Fantasy world and isometric RPG engine
  • www.pixieuniversity.com - My Software 2D Game Engine

#7 rouncer

    Senior Member

  • Members
  • PipPipPipPip
  • 2758 posts

Posted 27 September 2009 - 10:56 AM

Java kinda has advantages of its own, if you want really neat applets that can play straight out of a web page, wasnt that what java was invented for? Cause c++ cant do what java can do in that respect.

I see your name is "MMO" and maybe in the near to far future youd like to have a networked game for people to connect to :) (i am not concerned, if its just a dream of yours to have, at least you sound like you honestly want to do a bit of work yourself.), im quite sure java has in it the networking stuff you need. But of course c++ has it too.

You could write a mini mmo with both.

Java is technically a little less of a performer than c, but if you cut the game down in a few areas, im pretty sure java can impress.

If you were writing in java, youd be using their 3d library, which is not direct x, but its still quite impressive...
you used to be able to fit a game on a disk, then you used to be able to fit a game on a cd, then you used to be able to fit a game on a dvd, now you can barely fit one on your harddrive.

#8 Hertta

    Member

  • Members
  • PipPip
  • 81 posts

Posted 27 September 2009 - 01:01 PM

It does not matter which language you use. What matters is HOW you use it.

#9 fireside

    Senior Member

  • Members
  • PipPipPipPip
  • 1617 posts

Posted 27 September 2009 - 01:22 PM

Quote

I don't think using a scripting language is useful for the lone dev/hobbyist.

There isn't a big advantage. A lot of engines compile to a dll so it's very much like a scripted engine except you can go back and recompile the dll with your own changes. Still, it's easy to make memory errors with c++ and time gets wasted finding the errors which isn't necessary with a scripted language. C++ has a longer learning curve because of the memory issue and pointers so it takes more time to get started making a game, so I would argue the point. A lone developer needs to worry about art work and game design, so it's a very large agenda already. It's going to mostly boil down to personal preference. People who are more technical will choose c++ and generally have a lot more problem doing art work. People who are a little more artistic will generally choose a script language. If you take a look at the more productive engines like Unity, Torque, and many others, you can see that a lot of people are doing better with a scripted engine. It would be interesting to get XNA statistics, but I would be willing to bet that the majority of lone developers and hobbyists are using c#. Memory issues are a pain in the neck and if you aren't in that type of mind frame, it's better to avoid the issue by using a memory managed language. Most of the engines are written in c, so the speed difference is minimal for the amount of script used.
Currently using Blender and Unity.

#10 poita

    Senior Member

  • Members
  • PipPipPipPip
  • 322 posts

Posted 27 September 2009 - 01:59 PM

Honestly, I think the whole "memory errors in C++" thing is really over-exaggerated. You rarely need to use pointers in C++ and when you do, for 99% of those cases the STL auto_ptr and Boost's shared_ptr handle everything for you.

I do agree with the longer learning curve though. It takes a very, very long time before you can start using C++ well.

#11 Mattias Gustavsson

    Senior Member

  • Members
  • PipPipPipPip
  • 413 posts

Posted 27 September 2009 - 02:53 PM

also, the built-in CrtDebug stuff makes it dead easy to stay on top of memory leaks even without smartpointers
  • www.mattiasgustavsson.com - My blog and current projects
  • www.rivtind.com - My Fantasy world and isometric RPG engine
  • www.pixieuniversity.com - My Software 2D Game Engine

#12 SamuraiCrow

    Senior Member

  • Members
  • PipPipPipPip
  • 459 posts

Posted 28 September 2009 - 12:19 AM

Mattias Gustavsson said:

It depends a bit on what your goal is. If you want to work in the games industry, you need to know C++, and you need to know DirectX (not OpenGL).

The Mac users on this forum burn with wrath as they look in your general direction. :dry:

#13 Mattias Gustavsson

    Senior Member

  • Members
  • PipPipPipPip
  • 413 posts

Posted 28 September 2009 - 08:55 AM

Well, I'm not knocking Mac, or OpenGL. It's just that games companies ask for people who know DirectX, so it wouldn't make sense to tell someone who wants to get into the industry to focus on OpenGL, even though it would work just fine to make games with.
  • www.mattiasgustavsson.com - My blog and current projects
  • www.rivtind.com - My Fantasy world and isometric RPG engine
  • www.pixieuniversity.com - My Software 2D Game Engine

#14 poita

    Senior Member

  • Members
  • PipPipPipPip
  • 322 posts

Posted 28 September 2009 - 10:09 AM

Mattias Gustavsson said:

Well, I'm not knocking Mac, or OpenGL. It's just that games companies ask for people who know DirectX, so it wouldn't make sense to tell someone who wants to get into the industry to focus on OpenGL, even though it would work just fine to make games with.

Well, the PS3 and many (most?) mobile devices use OpenGL, so I don't think it's all about DirectX anymore.

In any case, it's not like someone who knows one is going to have a really hard time learning the other. I think employers would be mainly just looking for someone who can make stuff - their API of choice is really a secondary consideration.

#15 SyntaxError

    Valued Member

  • Members
  • PipPipPip
  • 139 posts

Posted 30 September 2009 - 02:34 AM

I have been building stuff with my own higher level graphics API so I can support both OpenGL and DirectX. I'm sure I'll need to update it in the future when newer versions of DirectX come out but at least I'll have a good starting point.

As for C++ vs Java, I've never been enamored with byte code/JIT languages for stuff that needs to run fast, so I tend to stick to C++. Also my personal experience with Java has been sub-optimal but I'll have to admit I haven't tried it in a few years.

Also I'm a bit confused by the entire programming language fear factor that seems to go around these days. At some point in the not so distant past you rarely heard talk of language X being too complex for someone. If you needed to program in X you got a book, took a class etc. Now I sometimes get yelled at for recommending C++ to someone because It's "too hard" for them. My opinion is if Java, C#, Visual Basic or some scripting language makes sense in a given case use them, but don't be afraid of C++ or any other language. There is no computer language that should scare anyone.

#16 Reedbeta

    DevMaster Staff

  • Administrators
  • 5340 posts
  • LocationSanta Clara, CA

Posted 30 September 2009 - 03:52 AM

I don't know...APL scares me a lot. ;)

In all seriousness, though: while C++ certainly can be learned by anyone with a modicum of programming experience, I think the general consensus is that C++ is not the best choice for a first language. We usually recommend Python or some such as a first language, because when you're just getting familiar with how computer languages work and learning to think like a programmer, it's a lot less confusing and frustrating if you don't have to worry about memory management, the funny ways C/C++ treat strings and arrays, the idiosyncrasies and gotchas of the standard library and STL, and so on. I think possibly the disapproval of C++ as a first language may be what you are encountering when people say it's too hard for someone.
reedbeta.com - developer blog, OpenGL demos, and other projects

#17 fireside

    Senior Member

  • Members
  • PipPipPipPip
  • 1617 posts

Posted 30 September 2009 - 07:41 PM

Languages keep moving to simpler models as computers get faster. I can use c++, and I have for a few almost games I've done with it, but I don't particularly like it and I wouldn't use it unless I felt it was necessary, which it really isn't for anything I plan to do anymore. It used to be you couldn't write any kind of serious game except in c++, but that is kind of changing. I think it can sometimes be a hindrance for some people because they insist on using DirectX or Opengl rather than a higher library and they end up basically re-inventing the wheel to write games. You could kind of do that in the old days but now with physics libraries, etc, everyone is dependent on using higher libraries or writing extremely simple games. As far as I'm concerned, if I don't have to bother with memory management, that's one less chore I have to do. C++ really has become a low level tool. If someone enjoys that kind of thing, that's great, but it doesn't have much to do with game design or graphics design or much of anything, really. If you want to do it professionally, it's a necessity. If you're a hobbyist or indy, it isn't. If you don't think it's harder, you probably haven't used higher languages much. Most of the exploits done for viruses, etc, are done with c or c++ code because it's easy to screw it up. Most game crashes will be because of an inexperienced c or c++ coder. I think Ogre is a cool engine, but one of the complaints about it is that the games that are written with it crash a lot. I personally doubt that has anything to do with the engine but the c++ coders that used it to write the game. Play some Unity games and you will find them to be solid and written by much less competent coders.
Currently using Blender and Unity.

#18 Hertta

    Member

  • Members
  • PipPip
  • 81 posts

Posted 30 September 2009 - 09:11 PM

Thats it. C or C++ does not hold your hand. It does not care what you try to do with it. For example, it does not stop you from trying to access data which is out of scope. It tries, and it fails. Your fault.

With great power comes the great responsibility.

#19 .oisyn

    DevMaster Staff

  • Moderators
  • 1842 posts

Posted 30 September 2009 - 10:41 PM

Mattias Gustavsson said:

Well, I'm not knocking Mac, or OpenGL. It's just that games companies ask for people who know DirectX, so it wouldn't make sense to tell someone who wants to get into the industry to focus on OpenGL, even though it would work just fine to make games with.

What serious game company asks it's applicants for DirectX knowledge? Sure, if you're interested in a graphics programmer on PC, then DirectX is a plus. But otherwise I don't think I've ever seen that as a requirement.
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#20 .oisyn

    DevMaster Staff

  • Moderators
  • 1842 posts

Posted 30 September 2009 - 10:50 PM

fireside said:

Most game crashes will be because of an inexperienced c or c++ coder.
I'm sorry, but this is just plain bullshit. Java and .Net allow you to make the exact same mistakes as C++ does. The only difference is that in C++ everything blows up (if you're lucky), while .Net and Java throw an exception. It's not that if you're using a managed language, you can no longer dereference a null pointer, access an array beyond it's bounds, or leak memory. The programming errors are exactly the same, and the result is exactly the same: a crashing game.
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users