Why java over other languages?

I like the syntax. C++ is really ugly.
And of course the completeness of the base packages.

It was the first real programming language I properly learned, and the only real language I wrote a ‘Hello World’ for. (Javascript doesn’t count as a real language)

Most importantly: Portability.

IMO, the best languages for writing games are not the ones designed with writing games in mind.

For me:

  • I get things done
  • Java is my hammer, and all problems are nails to me
  • Develop once, deploy on Win, Mac, Linux, Android(, Ouya?)

Some sysadmin needs to have his hand slapped and given a firm “NO”.

J2ME, iOS, smart card, TV, scanner machine, etc

Have they made a JRE for my fridge yet?

Dunno, ask Oracle :confused:

But I believe they’re not interested anymore, since most of that stuff done by Sun.

You forgot microwave.

/OT:
a strange game, the only winning move is not to use C(++). How about we write in Java?

Back on topic: I chose java because I saw some awesome games written in it (minecraft, mostly, but also several 4k games) and because the portability amd ease of use was very promising.

Why Java? Because I don’t want to be dealing with such crap.

But lets not kid ourselves, we’re not here because of Java the language, but because of the JVM and the JDK libraries. The language feels like a bytecode wrapper compared to other JVM languages. Lambdas in Java 8 is admittedly a huge step forward and it’s good that the base JVM language evolves (the JVM and library changes benefit everyone), but it still won’t do enough to reduce Java’s verbosity.

Why would you want to? Good feature of Java if you ask me, and with code completion it’s almost a non-issue. I’ll take easy to comprehend over quick to write any day! :wink:

@Spasi - tools. Don’t forget the tools.

[quote=“nsigma,post:30,topic:40839”]
Verbosity is good when it helps to express developer intent. In Java’s case, there’s so much verbosity that developer intent is actually hidden from all the stuff that goes around it. Getters/setters vs properties, @NotNull/@Nullable vs null-safety at the language level, wildcards in generics vs declaration-site variance, no smart casts, no pattern matching, no automatic delegation, no infix method calls, no named or default arguments. Even more verbosity is coming with type annotations in Java 8. If easy comprehension is the goal, then why do I have to read pages of Java code to understand a few lines? Not to mention that, more often than not, those pages would be in many different source files.

[quote=“Roquen,post:31,topic:40839”]
Of course, I wouldn’t even bother with Java without the awesome IDEs we use.

You can write verbose code in a terse language. The converse is not true. If your coding standards require 20 lines of code to do a simple map and filter, go do that. I’ll do it in one line.

Well, at least I’ll know exactly what it is I’ve told the computer to do. The terseness stuff lets the computer figure out more exactly how to do things in its own way but I have on many occasions had to delve into what it thinks is best when something misbehaves.

Java is not really that verbose, compared to even C++ or C. It’s a happy medium.

Cas :slight_smile:

Compared to Pascal and Modula, Java isn’t a particularly verbose language.

I don’t know how to put it right. But there seem to be personal preferences on information desnity in source code. Some people like a lot of information is small space, others like it more spread out. If I look at old code of mine, I find that my own preferences have changed from dense to sparse code.

I don’t think it is a benfit or a problem of a language if it is more verbose or terse than another. People have different prefernces and will choose what fits them best. And while you cannot shorten “BEGIN … END” very much, you can space out “{ … }” if you want more space in your code.

I forgot to say it in my last “Why Java” posting: I like the fact that Java limits multiple inheritance to one implementation and many interfaces. This avoids a lot of problems that other languages have.

[quote=“princec,post:34,topic:40839”]

[quote=“Varkas,post:35,topic:40839”]
So if the goal is to be able to write code that clearly shows developer intent and you knew for a fact that the following pieces of code produce the same bytecode:

// Without lambdas
button.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    System.out.println("Button pressed: " + e);
  }
});

// With lambdas
button.addActionListener(e -> System.out.println("Button pressed: " + e));

Which one would you prefer*?

Note that this a feature that’s actually coming to Java real soon, but there are many other examples of Java verbosity that can be toned down without resorting to alien syntax or compromising performance.

[quote=“princec,post:34,topic:40839”]
I think the most interesting comparisons come from other JVM languages, not C/C++.

  • I know that quickly writing an ActionListener is one shortcut away in modern IDEs, but the real issue is reading code, not writing it.

Lambda is great, but I still prefer Java’s original style for that.

I prefer the original java syntax.

  • the lambda introduces a new operator “->” which must be learned
  • Also the "e -> " part of the expression is alien to Java. It seems to be sort of argument passing to a parameter which has the same name as the argument … it’s also somethign new, other parts of java don’t work this way.

I must say I think it is very good that the syntax of java doesn’t have a lot of operators (unlike C++). I’m not fond of adding a new operator, and with it, implicit arguments (or how that may be called).

The original Java code is longer (-> IDE, code completion), but uses standard java syntax, and fits seamless with the other elements of the language. Even if longer, it’s more “Java” and IMO better.

Moreover, the -> operator is redundant and people will have two ways to write code. This nowhere makes code easier to read, because people must know both styles to understand other peoples code then. Admitted it’s not that bad, but there is no reason to make things worse without need.

But if Java 1.0 were shipped supporting lambdas and this syntax you’d think differently, as you’d be used to it. Just because you have to learn new syntax doesn’t mean Java suddenly becomes bloated or confusing.

If you were learning Java post-Java 8, and your education included lambdas, would you think “this one feature is just too confusing,” or would you simply accept it and happily move on?

yeah the -> is creepy and new

but this


button.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    System.out.println("Button pressed: " + e);
  }
});

is really an unholy mess for something so simple