4 ms·
It's a batteries-included, statically-typed language that's safer and harder to get wrong than C/C++, but faster than any dynamic language, and it has a fast, h
by kyllo 13y ago
It's a batteries-included, statically-typed language that's safer and harder to get wrong than C/C++, but faster than any dynamic language, and it has a fast, high-quality JIT compiler with well-written warnings and errors. Overall it's a very safe choice.
Unfortunately its extreme object-orientation, lack of type inference and polymorphism, lack of first-class functions and anonymous functions, and awkward error handling, make it quite painful to actually write (at least without code completion and automatic refactoring), while encouraging a number of poor design choices and serious source code bloat. It's too high-level to be useful for systems or game programming, but it's not expressive enough to be very productive for programming at a higher level of abstraction, and it's useless for scripting. So, it's mostly used for building enterprise web services. And Android apps.
- pjmlp 13y ago> Unfortunately its extreme object-orientation... Like Smalltalk, Eiffel, C#, VB.NET > It's too high-level to be useful for systems or game programming True if you are speaking about AAA games or writing kernels, for everything else lots of people seem to be quite successful using it. > So, it's mostly used for building enterprise web services. And Android apps. And in embedded environments powerful enough to run it, like windmills, electricity control meters, missile radar controls, blue ray players, J2ME mobiles, ...
- kyllo 13y agoI don't know much about the other languages you mentioned, but C# is multi-paradigm, allowing certain functional and declarative programming practices that Java does not. It's much more expressive than Java.
- pjmlp 13y agoHow do you write pure functions and procedures outside classes in C#?
- kyllo 13y agoYeah, I don't use C# and I don't know if you can do that, I think you have to create a class and declare them as methods like Java. But C# does have closures and lambdas, and lets you use functions as arguments and return values. Java doesn't have any of those yet, although they're supposed to be coming in 1.8.
- pjmlp 13y agoStill it makes it fundamentally an OO language, because C# closures and lambdas are mapped to System.Delegate class. All primitive types are actually alias for classes and structs that live in the System namespace. My point was basically from a point of view of someone with compiler development background, if one bashes Java for being OO based, there are lots of other languages to bash for the same sin, which for whatever reason people like to forget.
- kyllo 13y agoWell, Ruby is OO too, even moreso than Java because there are no primitives in Ruby. Even the "integers" in Ruby are not ints but objects with lots of methods. But Ruby has a lot of powerful, functional, expressive, declarative, and meta language features that Java lacks. Java is like an OOP straightjacket, that's why it gets so much hate.
- pjmlp 13y agoCorrect, the main issue is that many seem to mistake Java's OO model with OOP in general. Most modern languages are all OO based in some form, while being more flexible, like your example. Java 8 will probably improve the situation. At least on the enterprise level, I don't see it moving away from Java and .NET anytime soon.
- 6ren 13y agoGreat and fair summary. But what do you mean by lack of type (...) polymorphism?
- kyllo 13y agoType inference = the compiler being able to figure out what types your variables, function arguments, and return values are without you having to explicitly tell it. Polymorphism = the ability to write one function that works for multiple types. So for example, if you want to implement a sorting algorithm, you can write one function that is capable of sorting ints, floats, doubles, chars, and Strings. Java doesn't have this, so if you want to sort four different types, you have to write four functions instead of one, using overloading (you give all four functions the same name but they accept and return different types). If you're interested in these topics I recommend learning a language like Scala, SML, OCaml, or Haskell. It will open your eyes to some of the very powerful features of higher-level and functional programming languages.
- neilk 13y agoIt's not quite fair to say Java lacks polymorphism, it just doesn't extend to primitive types.
- kyllo 13y agoWell, apparently "polymorphism" in the Java world just means that subclasses can override the superclass's methods. http://docs.oracle.com/javase/tutorial/java/IandI/polymorphism.html http://docs.oracle.com/javase/tutorial/java/IandI/polymorphi... Yes, the Java 1.5+ generic data structure classes that take parameterized types allow a sort of polymorphism, but only for objects (including wrapper classes), but it's not quite as powerful as functional polymorphism. For example, in SML you can swap an ordered pair of any two datatypes with one line of code: fun swap(x: 'a, y: 'b): 'b * 'a = (y,x) And to illustrate my other point about type inference, this is also legal SML and does the same thing. You can leave the type annotations off and the compiler will figure them out for you: fun swap(x,y)= (y,x) where x and y can each be any datatype. I don't really know Scala but from reading about it I get the impression that it also allows this. Have fun doing it in Java though... you'll have to implement your own generic ordered pair class.
- skyebook 13y ago> It's too high-level to be useful for systems or game programming I plead with you to check out http://jmonkeyengine.org http://jmonkeyengine.org and see for yourself