Live data from Hacker News

Java Pain

tbray.org

41–50 of 151 posts

Re: Java Pain

#41
post #38

Yup, he's right. Most of these problems have been solved with tools, not by the JDK. If I have arbitrary Java that I want to execute quickly I write a unit test, not a test program for precisely this reason. I guess it doesn't slow me down, because I know the unit test 'trick', in the same way as I know how to get Light Table to execute arbitrary s-expressions to get around Clojures load times has meant that I'm far…

If I have arbitrary Java that I want to execute quickly I write a unit test, not a test program for precisely this reason.

Exactly. JUnit is your "command line" (and your REPL) for Java.

Re: Java Pain

#42

This is what I hear: "I am java newb and it doesn't work!" . Its true that other languages are simpler but he is missing the point why in java you have explicitly set classpath. Java allows not only for having multiple versions of libraries on the system with no installation whatsoever, but allows running components requiring those different versions of same lib in the same process (OSGi).

JavaScript with Node.js has those same features, but you can just type "node mycode.js".

Re: Java Pain

#43

Without the code and error message, this is just a rant from some (famous) guy who can't/won't figure out his tools. First of al­l, it took me for­ev­er to fig­ure out the ja­va command-line in­can­ta­tions to tell it that it need­ed my project’s class files and the json.org li­brary (which I’d al­ready down­load­ed so I could com­pile the suck­er). Yeah, I used to know that stuff ten years ago, but there re­al­ly sh…

I'm no fan of Java, but in this case I have to say I don't have much sympathy for Bray. Yes, running Java from the command line is a huge pain, especially if you haven't done it in ten years. Yes, it should be possible. But it can't be intuitive to everybody because people have conflicting ideas of what the intuitive thing would be. Yes, you will have to run "java -help" to figure it out, or package everything in a .…

Every programming environment needs to know where to find it's libraries but it's not exactly rocket science - CLASSPATH, GEM_PATH, LOAD_PATH, GO_PATH etc. Just takes a few minutes to figure it out each time.

Re: Java Pain

#45
post #34
post #31

Earlier quoted context omitted.

Referring to things like unusual command line options as "incantations" has been reasonably common across the history of computer usage at least from the 1970s or so, if not earlier. See: http://www.catb.org/jargon/html/I/incantation.html

what's so unusual about -cp (or "-classpath")

Especially since the guy writing this literally wrote the XML spec. You'd think he's be good at deciphering "incantations".

Re: Java Pain

#46

The confusing series of shell scripts most Java services (Cassandra, Kafka, Elasticearch) come wrapped in are a constant annoyance. Not only do they rarely if ever follow common shell command idioms, but trying to configure production services turns into tracing environment variables through a series of shell scripts sprinkled across my system. It's nothing wrong with Java the language, but the platform just seems to…

Java just has a slow to adapt ecosystem, and that slowness seeps into everything Java touches. The fact that it's 2014 and there is no Java Repl highlights this.

Java is FINALLY adding Lambda functions (a lackluster implementation at that), but guess what? There already exist billions of lines of code written in "noun based" Java.

Our shop has a client that refuses to upgrade from Java 5. There's no chance in hell this project sees a Lambda.

Re: Java Pain

#47

The confusing series of shell scripts most Java services (Cassandra, Kafka, Elasticearch) come wrapped in are a constant annoyance. Not only do they rarely if ever follow common shell command idioms, but trying to configure production services turns into tracing environment variables through a series of shell scripts sprinkled across my system. It's nothing wrong with Java the language, but the platform just seems to…

I was about to say "omg yes" -- as someone who writes piles of java code, this is a constant pain. However, look at the other tools: I run python out of a virtualenv. I use rvm to run multiple rubys, and that shit breaks all the time for me. (Or rather, I use it infrequently enough that I never learn it well enough; I use it for the first time again every 2-3 months).

That said, java is a special bit of shit. Those shell scripts are really complex. Most java shops have had problems with classpaths exceeding the 32k limit in shells! And java is yet another language where the morons who run it refuse to sand off some of the really sharp edges most likely because their heads are in their asses. To give two really simple examples:

1 - why the fuck can't I import a directory full of jars? eg

   --classpath ./lib/jars/*
or better yet, recursively descend

   --classpath ./lib/jars/**
For personal projects I often use ant just to manage the classpath.

2 - a nullsafe repeated dereference operator, like groovy. If I'm pulling out a.b.c.d out of a nested object, in real code, I have to say if

   String address = null;
   if (a != null)
     if (a.b != null)
       if(a.b.c != null)
          if(a.b.c.d != null)
            address = a.b.c.d.address;
   
   return address;
   
   // vs groovy
   String address = a?.b?.c?.d?.address;
this is the sort of minor irritant that you have to deal with all day long with deep class hierarchies, and there's some really low hanging fruit to instantly make my life better. sigh.

And for java, the combination of ant, maven, ivy, etc, are a special set of hell.

Re: Java Pain

#48
post #4

$CLASSPATH pain is one of the first things a new Java developer encounters — maybe the last, in many cases. The only reason it's not quite as bad in .NET is that it can usually reference at least the framework in a well-known location. But generally, whatever you call the problem that $CLASSPATH is designed to solve (assembly binding, reference resolution), it's an unsolved problem.

That's a feature, not a bug. It's part and parcel of dynamic linking and dependency management. You certainly can generate a monolithic executable jar file if you want.

Re: Java Pain

#49
post #40

By far, the most uninteresting post of the day on HN. Some random guy ranting on trivial stuff.

He's not really random, at least I remembered his name. He may have invested enough into the XML, and since Java is pretty strongly into XML, perhaps also the Java world to feel justified venting about it.

https://en.wikipedia.org/wiki/Tim_Bray

Re: Java Pain

#50
As a java dev myself, I'd just like to say that I agree. If I want all of those extra features, I will just move to scala though.

The command line is a bit quirky, but I think like anything else in java, we typically solve it with libraries like args4j. It's not the best situation, and there's lots of ways to do things.

That being said, whether you consider this stockholm syndrome or not, I'm used to the quirkiness and it doesn't really affect my day to day. Could I be as productive had java had better features/support? yes. Is it that much of a non starter? I think it's just like any situation, use what makes sense for the job.

Post reply on HN