
Can Java Be Saved? - fogus
http://www.sleberknight.com/blog/sleberkn/entry/can_java_be_saved
======
axod
_SIGH_ Some people are such fashion idiots. We get it. You think Java is like
wearing flares. It's unfashionable to you hip idiots.

You're having a blast hacking together your dynamic stuff without a care in
the world. You love how you can type 3 less characters and get the same work
done! Woo! High five! You have your repl setup so you can edit (and break)
your website on the fly. Static typing? who needs it. Lets write our own type
checking all over the code.

Meanwhile, people who don't care what is fashionable, are making awesome stuff
in whatever language they assess does the job best.

For anyone who hates Java, I'd recommend:

    
    
      * Ignore everyone who writes Java commercially.
        *especially* corporates doing their massive TomCat
        beans getter/setter XML over engineered crap.
      * Do NOT use an IDE. You don't need to. It makes you
        output more code, and worse code.
      * Figure out your own concise style, and figure out
        the absolute strengths of Java (There's many).
    

I know it's ridiculous that at some point programmers may figure out that
languages are largely irrelevant, but I hope it happens one day.

Talking of languages "Dying" is also quite ridiculous. Languages are 'alive'
as long as people use them. Guess what? If a new JVM is never released, it
still solves a massive class of problems.

A good programmer beats a good <language> programmer IMHO.

</rant>

~~~
Hexstream
"I know it's ridiculous that at some point programmers may figure out that
languages are largely irrelevant, but I hope it happens one day."

One can't "figure out" that which isn't true ;P

As a proponent of language-oriented programming I can only disagree strongly
with your statement. Languages are _supremely_ relevant. However it is true
that with respect to a specific problem, the expressive difference between
almost any two general-purpose languages pales in comparison to the difference
between a general-purpose language and a domain-specific language specifically
tailored to the task at hand.

In my as-of-yet-unreleased Common Lisp web framework, I have DSLs for:

\- HTML ("building", rewriting and outputting) \- CSS (building and
outputting) \- Form validation \- Error message specification and
customization \- Declarative configuration management (loading and dumping,
eventually modifying too) \- and probably others I'm forgetting at the moment,
plus a bunch of others I'm planning to do

I'm sure Java has equivalent stuff, the problem is that their solution has to
fit in a rigid mold (object-oriented, java syntax) so there's a lot of
cognitive resources wasted in translating back and forth between your mental
model of what you want to do and how you must express it in Java.

~~~
axod
Would shakespeare have been terrible if he had written everything in french?

Personally, I don't think so.

~~~
jrockway
Would he have done as well in a language that didn't have adjectives or
adverbs?

~~~
axod
That's not a good comparison. You can do anything in any turing complete
language. They're all equally expressive. If the language isn't expressive
enough, make it so.

~~~
Hexstream
Isn't that contradictory?

If all turing-complete languages are equally expressive, how does adding
another feature to a language that's already turing-complete can possibly make
it more expressive than it already is? It was turing-complete before the
addition and it's just as much turing-complete after the addition.

I'm not really impressed by turing-tarpit-style arguments. There's at least
one thing I can do in Common Lisp that I can't in Java: Implementing new
syntaxic constructs look exactly like they're part of the language. I won't
bore you with a long laundry-list of other similar things.

In fact, you know what? If by the turing-completeness criterion all languages
are equally expressive, then the important points of comparison between
languages in terms of expressiveness are _necessarily_ matters other than
turing-completeness.

Or would you argue that, say, x86 machine-language is just as expressive as
say, Java? According to your turing-completeness argument that would seem like
a yes. By the way, I do include a certain measure of "productivity" in my use
of the word "expressiveness". Do you?

~~~
jrockway
You are exactly right. Turing completeness is irrelevant when comparing
languages, because it is a property of both. Turing complete or not, good luck
programming your graphics card with Tcl or having boilerplate-free Java. It
just isn't possible.

But the way I see it is, "it's not my problem if people want to write
boilerplate all day" or that they like Java. Using Java does not take anything
away from me, except possibly contributions to the community. (But then, the
fanbois are rarely contributors to the community. This is true even for me!)

You will never convince axod that Java would benefit from new features. He is
happy to be in a minority here (a "smug Java weenie"), and that happiness is
worth more than potential increased productivity.

HN is a weird place for programming discussions. People here seem to think
that making a website that people will visit and look at ads on is somehow
correlated to code quality. It's not. It's just that you will enjoy making
that website more when you aren't manually writing your own delegation
functions, or writing "Foo foo = new Foo()".

------
ivenkys
Welcome to the bimonthly "Is Java dead ? Can it be saved ? Using Java, brain-
dead ?" ad-infinitum . The reality is quite prosaic , does Java work for you ?
This can also be re-phrased as Are you looking for a stable,robust language
with tons of libraries + tools and lots of "developers" ? If yes, then
consider Java.

If no, then look elsewhere , may be even at one of the languages running on
the JVM. End of.

~~~
jrockway
That's not what this article is.

Why bother reading when you can make a cynical comment instead, though?

~~~
ivenkys
I did read the inflammatory headline and the complete article and that was my
takeaway from it.

You of course are welcome to your opinion.

------
weavejester
I find it interesting that the article mentions the "new" operator, since this
particular language quirk has been a source of minor fascination to me.
Presumably it was added to make Java look more like C++, even though many
other parts of the language are quite different. The "new" operator is the
only language feature I can think of that has no purpose other than
appearance, and that comes at the cost of making the language just that little
bit worse.

~~~
leoc
These comments by Guy Steele

[http://people.csail.mit.edu/gregs/ll1-discuss-archive-
html/m...](http://people.csail.mit.edu/gregs/ll1-discuss-archive-
html/msg04044.html)

[http://people.csail.mit.edu/gregs/ll1-discuss-archive-
html/m...](http://people.csail.mit.edu/gregs/ll1-discuss-archive-
html/msg04030.html)

on the LL-1 list seem to shed light on why Java has a hardwired "new".

~~~
weavejester
Aha, interesting. So they were worried about having a specific operator for
heap allocation.

It doesn't sound like a particularly clever design decision, because even very
early on Java had static "newInstance" methods which rather seem to defeat the
point. But I can see the reasoning behind it now, even if that reasoning
wasn't very well thought through.

------
forinti
This is all irrelevant because most Java programmers now program in XML
anyway. Except they like to think it's not programming, but "configuration".

~~~
gaius
I don't know why you were downmodded, that's an accurate description of most
AOP shops. 10,000-line, version controlled "config files" are not unusual.

~~~
jrockway
But it's not code, so it doesn't need testing or documentation. Think of the
time savings!

~~~
gaius
Version controlled _if you're lucky_ too!

~~~
jrockway
Uh oh, the Java downmod trolls are here.

I wonder how many accounts axod has created simply to mod down every post in
"Java is not perfect" threads.

~~~
axod
And I'll do the same in a few years time when this place is overrun with "Ruby
is dead!", "Why Python is dead", "Is erlang the next COBOL" articles.

~~~
jrockway
"Why Python is dead" was posted yesterday. ("No changes for three years.")

------
rubinelli
C# and Java may look similar, but they have drastically different ecosystems.
C# can evolve much faster because Microsoft can drop their support of older
versions and make them practically inviable. MS customers are used to the
cycle and have learned to expect it. The large corporations that adopt Java,
on the other hand, don't expect and don't want the language to change. They
have hundreds of millions of dollars invested in code, and they won't let any
vendor tell them it's obsolete.

------
moron4hire
I think projects like Clojure are showing that the Java platform isn't
necessarily about the Java language anymore, that the runtime and the class
library can be used to great effect while getting passed Sun's unwillingness
to evolve the language.

When was the last time Sun updated the bytecode format? I seem to remember it
has been quite a while, like 1.3. I don't know, I haven't been steeped in Java
for the last 3 years.

~~~
moron4hire
It appears it was round about the time of JRE1.5. Actually, that was the last
major runtime update, that doesn't mean the bytecode format changed, though
obviously how the runtime reacts to the bytecode is a significant
consideration when developing a new language. Anyway, it doesn't seem like the
JRE is a largely moving target.

------
mdemare
The strange thing is that even though Java is very much backwards compatible,
big vendors behave as if every new version would break everything.

I've had to move heaven and earth for an upgrade from 1.4.1 to 1.4.2 when Java
6 was just around the corner, and I hear that there are still many teams using
Java 1.4.

------
rudd
It's funny how an article about Java the language comes up and almost every
single comment here is attacking either the article or the language. Like it
or not, Java is one of the most popular languages, so there are going to be a
lot of people who want to improve it to make it more usable.

As the article said, Microsoft has proven with C# that you can take a language
and evolve it over time for the better. If Java the language wants to be
viable and keep up with what programmers want from a language, then it's going
to have to release an update with changes like the ones outlined in the
article. I think the article hit the nail on the head with some of Java's
biggest problems (though not all). These changes would make it so that Java
could be used in the way a lot of people _want_ to use it.

------
dreish
Funny that this article praises C#'s generics over Java's type erasures, when
Rich Hickey specifically cited the latter, and the convenience it creates for
dynamic languages, as a reason for choosing the JVM over the CLR for his
implementation of Clojure.

------
nazgulnarsil
again, please don't upvote question headlines. cowardly journalism, easily
abused, insubstantial stories. just don't do it.

~~~
axod
Agree. Flag it instead.

------
jacquesm
That's an excellent article, thanks Fogus!

Not only does it level some valid criticism, it also proposes (for the most
part, omitting 'new' would break too much code) workable solutions.

~~~
silkodyssey
I think that both sides of the argument are valid but I am more inclined to
believe that keeping the language stable at least over the short term may be
the better strategy.

Java thrives in environments where stability is a prime concern and Sun's
commitment to maintaining backwards compatibility would inspire confidence.

The new languages that are being developed to run on the jvm reduces the need
for Java to evolve as rapidly as some would like. If it is proven that these
new languages solve problems better than java then it's only a matter of time
before developers make the switch.

At this point when it's obvious what features are really desired then it
Sun/Oracle may decide that adding those features to the Java language are
appropriate.

In this way the new jvm languages sort of act like a research lab to test out
new ideas to see which work better.

~~~
jacquesm
Java has some serious shortcomings that require you to write lots more code
than actually necessary, to reduce that would be really really neat.

On top of that I can see one immediate benefit in implementing some of these,
which is that to my eyes all java persistence layers are kludges, simply
because of the way the language is structured.

This could make writing such software a lot easier and more reliable.

------
vladev
"Can Java Be Saved?"

Hopefully not. :)

~~~
jacquesm
Why hopefully not ? Java has it's uses.

I'm no 'fan' of the platform, but like any other programming language you can
write anything in it, it simply has a 'niche' where it is a good tool when
properly applied.

~~~
jrockway
And what is this niche?

~~~
jacquesm
Software written for large corporations with a medium to high turnover in
their staff where quality of programmer is less a factor than long-term
maintainability of the project is.

As weird as it sounds, in that world java's lack of 'neat constructs' and
tendency to solve things using 'boilerplate' is actually an asset, for the
same reason that COBOL used to be an asset.

I've inherited a bunch of java code about 10 months ago now, so I've been more
or less forced to come to terms with it, and even if I can't get over how
tremendously kludgy it feels I would have a hard time getting this kind of
performance out of other platforms on the exact same hardware.

Call it grudging admiration, I personally would have _never_ thought that you
could do this and more with Java before being forced to get in to it.

There isn't a day though that I don't curse the language designers for making
me go the long way around on just about anything that I could do in half the
code (or less) in pretty much any other language that I have under my belt
with the exception of assembler.

At this point in time, my main gripes with java are verbosity and an
absolutely terribly kludgy feel to the interface with other parts of the
library, it feels like wearing a straightjacket.

And it is exactly for that reason why enterprise types much really love it, my
'creativity' is limited to the point where anybody else facing the same
problem would probably write more or less the same code.

Since joining this project I've basically just been busy condensing code and
removing 1000's of lines of boilerplate by replacing it with the appropriate
abstractions.

And by doing that I'm doing two things, I'm making the work marginally more
interesting, secondly the other guy working on the project is slowly starting
to see that cut&paste is not the way to go.

But that's my 'toolmakers' hat that I'm wearing, I'm pretty sure the that
people that lead this project would rather have me work on 'features' because
that is more productive in their eyes, my kind of 'productivity' will start
paying off in the longer term.

Time will tell how it is all goes, for now my conclusion is that it is
probably not the language that is 100% at fault, it is likely in large part
attributable to the people that use it and promote it. And it will be a long
time before I will be one of them, if ever.

If you've ever used UCSD-P with the dreaded P-code then you know roughly what
I feel like about this job :)

------
bediger
This is just crying over spilt milk, isn't it?

Java got to be the COBOL of the 21st Century because of the boilerplate & etc,
not despite it.

Immoral MegaCorporations like Java because they can segment large jobs and
have armies of drones work on the small segments. Immoral MegaCorporations
don't innately like productivity, they innately like Control Over Employees.

~~~
radu_floricica
Uhh... it's not immoral to want manageable code. If any piece of code would
depend on the programmer who wrote it, or require somebody in the top 10% then
I'm sorry to say, but a lot less software would be written. It's not a perfect
world, but I tend to value a workable compromise over an unworkable ideal.

~~~
bad_user
If you're going to implicitly say that Java code is more "manageable" than
alternatives, then you're going to have to provide citations, or at least
meaningful stories of your experience.

The most important purpose of higher-level programming languages is to remove
accidental complexities.

I can give you dozens of examples where Java fails to do that ... as opposed
to other languages, some of them mainstream. Some examples ... nullable
references, checked exceptions (which are a class of their own), no compile-
time code contracts (the type-system is way too weak), concurrency based on
shared state and mutexes, public/protected instance variables (with a god-
awful getters/setters convention), no real closures (an anonymous class
instantiation only captures final locals), no multi-dispatching (this could
take care of half of all possible Java-related gotchas, at least), no pattern-
matching operator (switch doesn't count). And the list can go on and on.

I've also worked on "big" code-bases written in Java. Some Java open-source
libraries are truly beautiful, but these particular projects were not. On one
of them it took one whole month to fix a bug that escaped us because of all
the layers and all the boilerplate that was executing. This particular bug
only happened like once a month, and debugging multi-threading Java code is a
nightmare (I guess it could be worse).

Sorry, but this argument doesn't fly. I work in a Perl shop and not all
programmers here are in "the top 10%" (I don't think either of us are). But
with enough training and clear code-conventions (many of them coming from our
community) ... our code base is quite manageable.

PS: I don't have anything against Java or Java programmers. I actually like it
because of the available tools, libraries and because of the JVM, which is
state-of-the-art.

