Parhelion69
Member
Java is slow (it's not native code, but interpreted), its garbage collection is... garbage(pardon the pun) its memory management doesn't work for games.
You know, writing compilers is my job. Trust me when I say that having a JIT compiler does not, in and of itself, "solve most overhead problems". Crucially, JIT compilation does nothing for garbage collection, which is one of the most significant hurdles to consistent realtime performance. Concurrent garbage collection with limited overhead and predictable performance is still an ongoing research topic.Java's JIT solved most of the overhead problems.
I very strongly disagree with this one. Java teaches people all the wrong things, and it's not particularly good for learning anything.It's good for learning
Oh, come on, guys. Java isn't that bad. It's just not made for games.
Yes, it's garbage collection you can't control, it has no memory management. For some things, this is great. It's not for games.
C# is like a middle ground between C and Java. It's starting to get a lot of use in game development, and I'm happy about it.
Note, JavaScript is one of the two supported languages used by Unity (which is used by a lot of indie developers).
Oh, come on, guys. Java isn't that bad. It's just not made for games.
Yes, it's garbage collection you can't control, it has no memory management. For some things, this is great. It's not for games.
C# is like a middle ground between C and Java. It's starting to get a lot of use in game development, and I'm happy about it.
Java is a terrible language. For one.
Though that's probably not the reason. One important reason is likely that garbage-collected languages were historically garbage (pardon the pun) for anything which requires consistent realtime performance.
Java is a terrible language. For one.
Oh, come on, guys. Java isn't that bad. It's just not made for games.
Yes, it's garbage collection you can't control, it has no memory management. For some things, this is great. It's not for games.
C# is like a middle ground between C and Java. It's starting to get a lot of use in game development, and I'm happy about it.
C/C++ is mostly in AAA games because of middleware and yes, massive flexibility with memory and when you are dealing with importance of performance, Very technical games will opt for C/C++.
C# however is very popular when games aren't pushing limits, it's also very popular with indies. The entire XNA project by Microsoft spawned a huge amount of indie games, many of them big hit indie games, today Monogame is keeping it alive.
C# is the most adopted language of choice with Unity and games such as Shadowrun, Wasteland, Hearthstone, Kerbal Space Program, Gone Home, Ori and the Blind Forest, Might & Magic X Legacy, RUST, FRACT, Among the Sleep, Pillars of Eternity, the list goes on and on. None of these are pushing the limits of technology, but all use C#.
Unreal Engine at the moment also has unofficial C# support because C# is such a widely used language nowadays, people want to and love using it. It has good adoption rates.
C# doesn't have manual memory control, it uses a garbage collector, it's miles and miles ahead of Java's but still not ideal when you actually need to control that memory so you won't see C# being used to push very technical games. It's more than capable though and a perfectly suited language for games depending on what you are trying to do.
When you really get technical and the game becomes a huge performance burden you will see C# struggle with its garbage collector, experiencing "hooks"/stutter every now and then in gameplay with a very technical game is because of the garbage collector doing its work when dealing with what you want to hold in memory in the game as well as when putting something in and destroying something else.
Code I wrote few years ago was in C# and it dealt with pretty crazy explosions, dealing with that when it would occur would cause a "hitch" for a frame or so when the garbage collector did its work when things were destroyed in the game from the explosion such as destructibles. No amount of perf passes would solve it, it was solely due to the garbage collector not being efficient enough to deal with it. Nothing a programmer could have control over unless they were using a language like C/C++ that required the programmer to do all the memory management that could make this go away.
C/C++ has always been the industry defacto language due to flexibility + middleware that was natively for C/C++ (although you could prob write binds for other languages, nobody wants to do that if they can just go the native way), C# is pretty much the language that is widely commonly used after C/C++.
This is on my opinion/experience, been programming for 10+ years now every day with C/C++ and C# (I do love C# for what it does, dearly). C# is definitely the most adopted language and useful one other than C/C++ when it comes to games at the moment.
You can't manually manage memory but you have some decent control over the garbage collection protocols if you're trying to optimize your code.
It's pretty bad as far as programming languages go. I wonder whose kool-aid you decided to drink to come to that conclusion.
No it's not?
Java portability is a myth. You are going to build your game for each individual platform anyways, and with good libraries/SDK C++ code is as portable as Java.
Javascript != Java
Same company though.
I very strongly disagree with this one. Java teaches people all the wrong things, and it's not particularly good for learning anything.
- Low-level programming, operating systems, and basic algorithm and memory management knowledge is best taught in C.
- High-level concepts, advanced algorithms, composition, type systems, and language concepts are best taught in some high-level functional language such as Haskell or OCaml.
- General programming for larger user-facing programs can be taught in Java if you really have to, but e.g. Python or Ruby are also good choices for this and round out the set of languages much better (e.g. having one statically but not strictly typed, eagerly evaluated compiled language in C, a strictly statically typed lazily evaluated language in Haskell and a dynamically typed, interpreted/JITed language in Ruby).
You know, writing compilers is my job. Trust me when I say that having a JIT compiler does not, in and of itself, "solve most overhead problems". Crucially, JIT compilation does nothing for garbage collection, which is one of the most significant hurdles to consistent realtime performance. Concurrent garbage collection with limited overhead and predictable performance is still an ongoing research topic.
Even if you were going for a garbage-collected dynamic language (perhaps for some parts of your game where performance is not very relevant or can be easily controlled), then why would you chose Java? C# is almost the same thing but with some of the major language-level issues (e.g. stack/heap allocation, boxing/unboxing, operator overloading inconsistencies, etc.) resolved, and other dynamic languages (Lua, Python, Ruby) offer even greater productivity advantages for non-performance-sensitive gameplay code.
Basically, Java is like a highly limited C++ in productivity and features, while being potentially much slower and crucially far less predictable in execution.
I very strongly disagree with this one. Java teaches people all the wrong things, and it's not particularly good for learning anything.
- Low-level programming, operating systems, and basic algorithm and memory management knowledge is best taught in C.
- High-level concepts, advanced algorithms, composition, type systems, and language concepts are best taught in some high-level functional language such as Haskell or OCaml.
- General programming for larger user-facing programs can be taught in Java if you really have to, but e.g. Python or Ruby are also good choices for this and round out the set of languages much better (e.g. having one statically but not strictly typed, eagerly evaluated compiled language in C, a strictly statically typed lazily evaluated language in Haskell and a dynamically typed, interpreted/JITed language in Ruby).
You can opt out of both garbage collection and memory managed pointers in C# using the fixed and unsafe keywords. It's easier not to, and the performance is pretty good any way! Bad C++ can easily be slower than good C#.
Java suffers from supporting legacy code and doing silly things like type erasure...
JITing is pretty good in both languages, and you can do things like pre-JIT using NGEN as well in .Net). Also you can write pure IL in C# using Reflection.Emit. I've written games using C# for both the 360 and PC (actually the same game on both, you could play each other which is why .NET is great) and it was pretty fast!
Do they still teach Java as the primary programming language at high schools and universities? I'd wager the only reason most schools even touch Java is because of its unfortunate ubiquity in industry.I don't even know how bad it is because it's the only language I use. ¯_(ツ_/¯
- Lack of memory management
- Uncontrollable garbage collection that takes a shitload of resources to run
- Inability to code for performance
- Can't access template types in runtime
- No inherent unsigned datatypes
- No inherent compound datatypes
- No Const keyword
- Can't have arrays larger than the size of an int (which also means it can't memory map files larger than 2GB)
- Considerably less secure and more exploitable by the end-user
- Bad at catching and throwing exceptions
- Can't typecast certain types to other types (int to long, for example)
- Functions of the same name, but different parameters, will destroy each other
- Doesn't handle static class members properly
- You generally end up with tons of unnecessary (except in Java) code duplication
- Constructors can't call other constructors
- You can't create lists literally (1,2,3,4) you have to create them manually (1) (2) (3).
I haven't used it in probably 6 years, so some newer versions may have addressed some of the above.
C++ is too hard.
C# FTW.
Could you point me to some information on this because everything I have read says Java programs run just as fast as comparable C# programs
Do they still teach Java as the primary programming language at high schools and universities? I'd wager the only reason most schools even touch Java is because of its unfortunate ubiquity in industry.
Could you point me to some information on this because everything I have read says Java programs run just as fast as comparable C# programs
In very limited not real world examples it might. When it comes to managed resources? Not a hope in hell!
I'm sorry to inform you but that simply won't do, using System.gc() will just signal the VM it's ready to collect. That operation runs asynchronously, you may be loading a texture as it's doing that and performance will shatter.
The main reason C++ is the king of video game programming languages is the full control and assurance it gives over memory.
Even Minecraft had performance issues that plagued it for years. It simple isn't a good enough language for critical processing tasks, but for any other task it will do the work just fine.
Did you read the link?
Explicit Garbage Collection
Another way applications can interact with garbage collection is by invoking full garbage collections explicitly by calling System.gc(). This can force a major collection to be done when it may not be necessary (i.e., when a minor collection would suffice), and so in general should be avoided. The performance impact of explicit garbage collections can be measured by disabling them using the flag -XX:+DisableExplicitGC, which causes the VM to ignore calls to System.gc().
One of the most commonly encountered uses of explicit garbage collection occurs with RMI's distributed garbage collection (DGC). Applications using RMI refer to objects in other virtual machines. Garbage cannot be collected in these distributed applications without occasionally collection the local heap, so RMI forces full collections periodically. The frequency of these collections can be controlled with properties. For example,
java -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 ...
specifies explicit collection once per hour instead of the default rate of once per minute. However, this may also cause some objects to take much longer to be reclaimed. These properties can be set as high as Long.MAX_VALUE to make the time between explicit collections effectively infinite, if there is no desire for an upper bound on the timeliness of DGC activity.
Isn't Java vulnerable?
The question is : did you read the link ?
This shows that negligible speed issues when developing on small systems may become principal bottlenecks when scaling up to large systems. However, small improvements in reducing such a bottleneck can produce large gains in performance. For a sufficiently large system it becomes well worthwhile to select the right garbage collector and to tune it if necessary.
5. Available Collectors
The discussion to this point has been about the serial collector. The Java HotSpot VM includes three different collectors, each with different performance characteristics.
Selecting a Collector
Unless your application has rather strict pause time requirements, first run your application and allow the VM to select a collector. If necessary, adjust the heap size to improve performance. If the performance still does not meet your goals, then use the following guidelines as a starting point for selecting a collector.
I have a teacher who preaches it. He's has a doctorate in computer science and has written several papers on it. I think he is part of the reason it's one of the major languages taught here.
Isn't Windows vulerable?
Who the hell programs in Java by choice when they don't have to?
No operator overloading. Except the String object is overloaded because the language designers didn't even follow their own rules.
I am not going to call your teacher out for being an idiot. But does he have actual real world experience in large IT infrastructures?
I deal in data warehousing. Hadoop is a damn nightmare to deal with every time there are Java updates. Not only is it a nightmare. Having it play nicely with any of my older systems is borderline dark sorcery.
I can't be the only one here who prefers C over C++. I write all my games in it. OOP is the devil
Do they still teach Java as the primary programming language at high schools and universities? I'd wager the only reason most schools even touch Java is because of its unfortunate ubiquity in industry.