   [java] benefits of Java question
  I've been wondering about the main benefits of Java over other languages.I'm a C# developer for the most part but I've been finding Java somewhat intriguing for a while.  So, I've been wondering what Java is best used for nowadays.  What are its strongest benefits?  I'm just curious and hopeful that some of the comments here will help me understand more about the Java culture and enlighten me.  Afterwards, I want to perhaps make some useful Java applications so if you have some pet projects that you want to share ideas about, then I would be glad to hear about them for some inspiration.Thanks much!   
  advantages:-platform independent.  write once (nearly always) run most anywhere.  It's not perfect but it beats the pants off c/c++ portability.-garbage collection works well *most* of the time.  there are small gotcha's but you couldn't pay me enough to go back to managing memory in c/c++.  There's a performance penalty for sure, but it's well worth the cost imo.-array bounds checking.  yes there's a performance penalty to have java check array bounds everytime you access an array and yes for me it's well worth the price.  Billions of ops per second I can afford to spend a few to get rid of hard-to-track bugs.-many other nice features: typesafe enums, method chaining, etc.  -multithreaded support is very nice.disadvantages:-horrible reputation when it comes to performance.  Much of it was rightly earned.  In 1996 spending 30mb to fire up and interpret code on a 486/pentium computer with 8/16/32 mb of ram was going to be slow.  The JIT and hotspot technologies have helped a bunch over the years.  The biggest improvement to java performance is because computers have becomes so much faster.  GBs of RAM and ghz processors with multiple cores have largly diminished the performance issues.-C# is newer and learned from many of java's mistakes. My gut feeling is MS dumps far more man hours into C# than Sun dumps into Java.  That's just my opinion.-some people hate the lack of destructors, no 'explicit' pointers, lack of method pointers, no multiple inheritance, etc.  If you are coming from C# you'll find much the same in Java.  There are a few WTF things in Java that C# fixed.  You do open up a greater number of platforms though with java which is nice.  Then again MS still controls about 85% of the OS market, but I remember when it used to be 95% though 5 years ago.  If google makes an OS i'm sure java will be quick to the party and C# will not.  If everyone likes windows 7 and MS regains 90%+ market share C# becomes a better choice and java less so.  The future is impossible to predict.The fanbois will tell you that Java is as fast as c/c++ and the haters will tell you java is as slow as dirt.  Unfortunately they are looking at the wrong metric.  There *is* a cost for the nice features in Java.  the GC eats CPU cycles and there's no way around that.  The runtime array bounds checking eats CPU cycles and there's no way around that.  In compiled languages the "price" of compilation is paid by the dev at compile time, in Java that "price" is paid by the end user when the program starts up.  The question isn't whether it's slower -- because it is -- (how much is another issue) but whether sacrificing some speed for the GC+runtime checking is a good tradoff.  In economics we call it a cost/benefit analysis.  Of course end users don't really care if you wrote the game in C#, Java, C/C++, or assembly.  They only care that it runs bugfree and at an acceptable speed.  Even the users get the benefits of CG/runtime checks because it will help coders right code faster and with fewer bugs.  Even though the user is paying a performance penalty for using java, they still get the benefits of getting a game with fewer bugs and a faster development lifecycle.On balance if you are already familiar with C# then it's probably the way to go.  Unless you have some horrible beef with MS or think that the iphone is going to supplant windows then there's not much of a reason to jump ship.  Personally I like java, but it's very possible that Java missed its opportunity to ge a good gaming platform.  I could be wrong.  Time will tell.I will say this though.  C/C++ are old.  Very old. C dates back to the late 60s and C++ the late 70s.  The stroustrup C++ book sitting on my shelf is probably older than most people who use these forums.  Sure there are people even today who will expouse how great Fortran and Cobol are but they are living in the past.  We had to use Fortran in college i'd rather poke my eyes out then go back to that.  The same holds true for C/C++.  Sure they might be the pre eminent languages for game programming -- today.  Eventually that will change.  It won't change today.  Not next week, or even next year, but eventually it will.  I'm sure someone out there is still using his 386 and will tell anyone who will listen as to why it's so much better than a new quadcore machine, but i'll stick with modern hardware thanks.I worked at a windows programmer years ago.  I used to work at MS, and there's no way you can convince me to go "back" to c/c++ programming.  If you want to get a job at a game company then you will need to know your c/c++, but if you are doing it as a hobby or running your own company then I would certainly use a more modern language.~don   ;  Advantage:Java:s strongest benefit is that it is portable to like any platform and it scales really well.(think supercomputers and servers) Also the extremely large standard library that has alot of things. There are a lot of java programmers out there also so it is easy to get help.Disadvantage:I feel it is a lot of code I need to write in order to get something done and most of the time I feel the standard library to be overly designed and complicated. I also miss a lot of things from C++ like destructors/templates(not the crippled generics)/const/delete. Yes you heard it right I miss delete because most of the time I get problems with the garbage collection under my rendering of the scene.;  If you're explicitly comparing C# to Java then the obvious advantage is the sheer number of mature, stable libraries available - C# is getting there (especially as lots of major open source Java libraries are being ported over to C#) but Java having existed for a good deal longer means there's lots of libraries for almost everything under the sun.   ;  Thanks very much for the replies!  They were very informative and helpful!   ;  Just had to add, my main reason for going to Java from Visual Basic, Dark Basic, Blitz3d was 100% due to deployment. I love Java Applets!   ;Quote:There *is* a cost for the nice features in Java. the GC eats CPU cycles and there's no way around that.I agree, but also consider that reference counting - a very common practice in C++ - eats up cycles.I'm a big fan of Java simply because it's head and shoulders above anything I used before it, but if you're accustomed to C# you're going to feel a bit naked with less language features and less than ideal generics. One of the design philosophies behind C# is that a language with more features allows you to do more with less lines of code. The line has to be drawn somewhere, though, and I don't have enough experience with C# to know how far either side of that line it is. I'd say Java is a bit short of it, but it may be closer (ie. better balanced) than C#.Quote:Yes you heard it right I miss delete because most of the time I get problems with the garbage collection under my rendering of the scene.If you're referring to jittery rendering, see if there's a regular pattern to the jitter (eg. 1.5 Hz). It could be a beat caused by the game timer not matching the screen refresh rate.   ;  There are actually many threads in these forums comparing Java with various other languages. It comes up every so often, so search around and you'll find more info. With C# you get the nice advantage of using DirectX. If all you care about is making games for Windows, that's all you need. Java games with OpenGL can be made to run with minimal effort on Linux and Mac, as well. About the whole "is Java slower" thing: Sun likes to present it as a philosophical issue. Java code gets compiled at run time based on analyzing how the code performs and optimizing it. Since this information is not available at compile time for C/C++ programs, compiled Java code could therefore _theoretically_ be faster due to various optimizations. I haven't looked at any benchmarks so I'm not sure if this holds true in practice or not. What is true is that you pay a small but significant memory overhead for the VM, which also takes some time to load and get warmed up. Development time is also an issue. Java applications can be written much faster and are easier to debug. It's not as concise as Python and such but still presents a nice trade-off between being fast to develop and being close to the metal. It shouldn't be much different from C# in this aspect though.Applets are a nice feature, but I find that it can be difficult to get them to perform reliably when reloading without quitting the browser. Java is also dominant in mobile games, so if you ever want to write a game for your phone you will likely want to pick up Java.Other common uses include enterprise applications as well as web applications (JSP / Servlets). I actually prefer Servlets over PHP as they help me separate the MVC parts better.   ;  While we're talking about applets, I think they're a great idea gone horribly wrong. There's one simple reason why Adobe Flash content is far more prevalent: It doesn't popup in your system tray advertising itself. Applets also advertise Java while loading, which has been enough to put off many developers, but the animation can be overridden, which isn't widely known.   ;  Totally agree with what Xyle said. Applets to me are one of the best things about Java and the main reason I am doing more Java games now.   