Live data from Hacker News

Java for Everything

teamten.com

171–180 of 344 posts

Re: Java for Everything

#171

In real-world benchmarks in a real app I have tried to make Clojure slower than Java. I can't. In rare cases Java will beat it in insignificant ways in insignificant amounts, but I found that Clojure sometimes beats it in significant ways because of the runtime's tendency toward laziness. Furthermore, Clojure is a very dynamic language that can leverage every library Java has plus all its own. As a result I will not…

Its hard to explain, but I feel like Java would be a better choice for doing something like audio decoding, while Clojure is orders of magnitude more productive to prototype a webapp.

Re: Java for Everything

#172

Earlier quoted context omitted.

Keep in mind that JAX-WS with JAX-B beats other rival libraries in other languages. If your requirement is to be a client that consumes SOAP web service given wsdl, I'd take Java any given day. The wsimport and wsdl tool that JDK provides beat any libraries. Also, JAX-B annotation can serialize and deserialize to JSON given the right provider. That's JSON, XML with POJO with the price of one. Good example of Java eco…

False. If you use a language that's homoiconic (any Lisp), you don't need to serialize anything. The source code of the language is already in its serialzed form. You can't beat the speed of not having to do something in the first place. As an aside, no sane person would write a SOAP webservice today.

I wrote a SOAP webservice -- not because I'm insane, but because our business relies on data sent to us.

We could certainly tell everyone that they'll need to write code to send us the data we need to be of use to them. Or we could look at the installed systems that hold their data, and see what built-in support those systems have for external integrations. And so: we quickly added a simple SOAP endpoint.

About serializing -- I'm potentially missing your point, but "The source code of the language is already in its serialzed form" doesn't seem to make sense. Who serializes source code? Values in data structures need to be transmitted, normally (sometimes in the form of source code -- e.g., JSON) -- homoiconic languages are interesting for other reasons, but not serialization.

Re: Java for Everything

#173
post #53

Does anyone know a good starting point for learning not just Java, but how to install everything I need? I consider myself the Neo of OOP and a master devops, but every time I tried to use Java I hit a wall of unreadable manuals/guides , software impossible to install/maintain, and mixed opinions among Java devs. Like it can't be used without a dedicated sysadmin.

My opinionated viewpoint, if you want to learn this stuff for a job:

Install eclipse. Get a non-JavaEE version - probably "eclipse for java developers". It's flaky software and you will have to babysit it sometimes, but it's still the best choice.

Use maven, then you don't need a sysadmin to maintain your libraries. You just add libraries as dependencies (you can even use a search wizard in Eclipse) and it Just Works. Start by using the new maven project wizard; I would skip archetype selection entirely, but if you want to use a particular framework you can choose one of those and get a "hello world".

Add libraries one at a time. If you're writing a web application I love Wicket which is literally the best-designed library ever. Aside from that you're facing things that, like eclipse, are a bit clunky; sooner or later you will have to learn Spring and Hibernate. Everyone loves to hate them and with good reason, but people will expect you to know them, and they do have good parts.

Try to do as much as possible in pure java. Use embedded jetty and write a normal application rather than messing with war packaging. Use annotation-based Spring configuration rather than XML, and the same for Hibernate.

The whole ecosystem is old and crufty. You will have to get used to random crappy workarounds for all sorts of problems, and you will probably have to cargo-cult some things to get stuff working. This is unfortunate, but I guess it's the price of stability. There are good sides to the ecosystem too. Sorry to be such a downer.

Re: Java for Everything

#174
Committer to Apache HBase here:

I agree with the author on some level. All of HBase and Hadoop (except for a little bit of native stuff) is implemented in Java.

I found that to be + and a -.

Java is easy to understand and to follow, lends itself very well to large-team development, and performs well in most situations. The alleged verbosity I do not mind. I have tools, and well structured code is easy to follow.

Java (or the JVM really) does have limits, though. What I miss by far the most are simple pointers and access to the RAM outside of the Java heap. Then again I am working on a low-latency database. Yes there are DirectByteBuffers but they are annoying to use, just gimme a struct (some IBM folks are working on a proposal for that for Java). Everybody in this space who is using Java invents their own off-heap code to avoid heap allocations and the inevitable garbage collections. G1 will make it better, but not eliminate this.

I still user other tools: Python, Ruby, Bash (yes), JavaScript, C/C++, etc, and I disagree with the author's premise. It depends very much on what I attempt to do which language/ecosystem I will use for that.

Edit I: In the end I prefer to versatility of Java over the limits I face with it. Would I write a Kernel in Java: No. At least not with the current JVM.

Edit II: We should not conflate Java with the JVM.

Re: Java for Everything

#175
Do Java/JVM folks miss the simple deployment of Go? I haven't used Java for a while (used Jetty to deploy), but words like "application servers" are the things that make Java sound "heavy".

Re: Java for Everything

#176
I've been writing Python and Java(Android) side by side for a few months. I feel that for all the advantages of initial speed that python offers it takes a lot away. Especially in large projects. I spend a significant amount of my python time trying to understand Types, and if those areas are not covered by tests then I'm Fked, I'll have to spend hours trying simulate the exact conditions of how an error occurred.

Don't get me wrong, I love python, but writing python requires a lot of restraint and experience. Novice programmers who build a python code base just screw things up, especially those who don't yet understand the value of readability and maintainability.

I'd much prefer novice code on Java than on Python.

Re: Java for Everything

#177
Ok, now your boss asks you to write an iPhone client.

Or web client with a lot of logic in the browser.

Or even a custom, native windows client. (Ok, Swing or SWT, but, ...really?)

"Language X for Everything" is simple not possible, regardless of the value for X.

Re: Java for Everything

#178
post #89

Verbosity matters for reading and maintenance far more than it does for writing. IDEs can make the writing faster, but they can't make the code as easy to comprehend as it would be in a more expressive language. And remember that lines of code is the only proven risk factor for bugs. Most sites are not Twitter. They're not Stack Overflow. They're not even Nanowrimo. I've watched a company spend two years, dozens of d…

> Verbosity matters for reading and maintenance far more than it does for writing. I would argue that on average verbosity improves readability. Yes it may take you slightly longer to read the code, but verbosity often results in the code conveying more information or expressing it clearer (or both).

I would rewrite that as "_explicitness_ improves readability". When I read Java code, I rarely have trouble to know what the code is doing (at least at a local scale).

Not all static-typed languages are readable because they're not all explicit. In C++ for example, even the most trivial snippet of code can be obfuscated by all sorts of abuse: operator overloading, implicit calls to copy constructors, preprocessor macros, etc. Scala suffers the same problem, perhaps even worse, doing tons of stuff automatically i.e. in a way that's not obvious by just staring at a code fragment such as an individual method. Organizations that have success writing large-scale code in such languages [I can speak for Google here], typically have careful style guides that ban the bad stuff and are strongly enforced by code review process; but in that case you're not using language X anymore, you're using some "safe subset" of X.

Of course you can't have any high-level abstraction without some tradeoff of maximum explicitness; virtual calls for example make hard to know which exact code is invoked by "just staring" at an invocation. The trick is striking a healthy balance between power and readability. Java is not perfect in this criteria (it errs a bit in the side of caution), but it's certainly much better than any dynamic-typed language.

Re: Java for Everything

#179
post #163

There's the language and there's the ecosystem. A lot of negative feelings that still linger are, IMHO, directed more at some of the painful historical aspects of the ecosystem: J2EE XML configuration hell, EJBs, bloated application servers, XML for everything, JAX-WS, SOAP, ant, classloader problems, maven dependency hell, 10 different logging libraries, etc... A lot of this stuff truly sucked. But I feel things hav…

Ant has a bad reputation? I clearly didn't get the memo - I find Ant to be a great little tool.

Some of us don't care for XML as programming language syntax.

Re: Java for Everything

#180
post #157
post #153

Earlier quoted context omitted.

one line is way more readable than 7 lines taking up valuable vertical and brain space it could also be accomplished with return -1 * o1.compareTo(o2);

Why not: return o2.compareTo(o1);

because the o2 vs o1 is easy to miss, while the -1 makes it obvious i'm intentionally reversing. my .02
Post reply on HN