Live data from Hacker News

Java for Everything

teamten.com

131–140 of 344 posts

Re: Java for Everything

#131
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 program in Java willingly. There's just no reason to do it. Not with at least one language that's far better in real, quantifiable ways. There are other languages that run on the JVM that could tell a similar story. Unfortunately those are not Jython or JRuby.

Re: Java for Everything

#132
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.

That...sounds surprising. Basically you need:

1. An IDE (I highly recommend IntelliJ IDEA)

2. A build and dependency management tool (I prefer Gradle, but Maven is a reasonable choice - though way more verbose)

Beyond that point, a lot depends on what you want to do. Some of my preferences (YMMV):

* logging: slf4j over logback

* json serialization/deserialization: jackson

* db access (if you don't need or want ORM): jdbi

* db migrations: flyway

* REST services: jersey

* networking: netty

* embeddable http server: jersey

* http client: apache-commons http client

* metrics: codahale's metrics

If you're building a backend webservice I highly recommend looking at Dropwizard, which handles a lot of the boiler plate for you.

Re: Java for Everything

#133
post #74

I completely buy the idea "write everything in one language", even if I do it with a different language for completely different reasons. In general I think "use the best tool/language for the job" and anyway any tool/language will have pros and cons, nothing is perfect. My context is I was a big ECMAScript fan, then I moved to use something called ActionScript 3.0 and there I just found the "right balance" between v…

interesting,I need to check it out,you should add a link to the project. I definetly like AS3,it's a good compromise between javascript and java.

Re: Java for Everything

#134

How do you even parse JSON in Java? I remember in the days of XML, there was a kind of specification standard for the xml (a specification for how to specify a specification?). From that you could generate Java classes that would correspond to the elements of the XML. But for JSON there is no such meta description, so you are stuck with manually parsing the JSON and hoping you catch all nuances?

Typically you create your class manually and map to-and-from json-strings. In a web-context you'd usually let the container handle the serialization/de-serialization (jax-rs), in other contexts I tend to use Google's GSON-library.

Re: Java for Everything

#135

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…

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.

Re: Java for Everything

#136
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.

You need a compiler and an editor. That's it.

Your package manager will get you the compiler (probably as part of a package for the whole JDK).

You can use whatever editor you already like. It'll help if it has some support for Java's syntax, like highlighting or whatever.

If you want to add one non-essential tool, it should probably be a build tool that knows how to download libraries and compile your code against them. Gradle is the only sensible choice right now - it's far from perfect, but it should be tolerable. Again, your package manager will probably have Gradle. You only need it on the development (and CI) machine, not on the target.

At some point, you should probably give an IDE a go, to see how useful automatic refactoring is. Eclipse and IntelliJ are both free and pretty good (IntelliJ has free and paid versions, but the free version has everything you'll need to begin with). People love to argue over which is better, but the truth is that there's not a massive gap between them. Any IDE takes some getting used to, so it's probably better to start with a straightforward editor rather than an IDE.

If you want to use IntelliJ on the Mac, you might need to edit its Info.plist file to allow it to use a current version of Java. For some reason it's pinned to 1.6 by default. Gets me every time.

I can't think of anything you need to do to use Java that is remotely sysadminish, unless you count installing packages.

It's been years since i've read a Java book. Back when i did, by far the best was Just Java. Thinking In Java was also great. However, those were last revised 10 and 8 years ago respectively, so possibly not worth picking up today. They certainly won't tell you anything about the rather crucial new stuff in Java 8.

Re: Java for Everything

#137
post #127

Earlier quoted context omitted.

Welcome to the Java world! Like some of the comments so far I think the Java world is actually a pretty cool place to be right now, the language and approaches are becoming a lot less verbose. I blogged about some of the best Java books, hope it'll help you out! http://scalabilitysolved.com/dont-hold-back-your-java/

Thanks for that. Question though. The first book you listed (which got excellent amazon reviews as well) was published in 2008. Typically I've been biased into thinking that a book had to be somewhat recent. Obviously this isn't the case here though. (Do you agree with that in some situations btw?). I would have never purchased this book if you hadn't pointed it out so thanks it's in my cart.

Effective Java is a solid choice, and a lot of the advice is still relevant six years later :) Also, JCIP is a go-to if you want to get more than a passing handle on concurrency in Java.

Re: Java for Everything

#138
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…

Care to share more details of these companies including how the Ruby ones become profitable after a month with 4 guys on payroll? No offense but I've got to check the facts these days.. :). Also, don't forget Fred Brooks article about the Second System. I betcha smart engineers on tight budget can hack in Java just as quick as those 4 guys and achieve the same result. My apology, Java today is as productive as Ruby o…

> Care to share more details of these companies including how the Ruby ones become profitable after a month with 4 guys on payroll? No offense but I've got to check the facts these days.. :).

It was small industry, those were basically the only two companies in it, I don't feel I can. (I've already changed some small details e.g. it wasn't actually Ruby). In any case it's just one person's anecdote - but I bet it's happened a lot.

> My apology, Java today is as productive as Ruby on Rails.

Citation needed. In the programming language shootout Ruby still comes out much shorter than Java, and like I said, the only proven risk factor for bugs is number of lines of code.

> One can slowly move from old Java architecture to the newer one but it'll be trickier from Rails to something else...

When I worked at last.fm this was literally my entire job (well, from PHP). You're rearchitecting anyway, creating stable interfaces and putting load balancers in there because those are also things you need to do as you're scaling up. Changing languages is no harder.

> don't forget the accumulated Ops experience managing jvm based app server, the devil in details for those experienced engineers who have been there and done that...

You can hire the experience - Java is literally the easiest language to hire for (I mean, hiring is still hard, and there are a lot of crap java programmers around, but there is a bigger pool of experienced programmers out there than any other language). And you're going to need to hire anyway; your ops team will have to grow, your engineering team will have to grow more, and you absolutely cannot rely on the engineers who bought the first version still being around when the time comes to rewrite; the half-life of an engineer in a startup is not large.

Twitter was the article's choice of example, not mine - and from a business point of view Rails worked really well there.

Re: Java for Everything

#139

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…

I suspect readability isn't a big priority for you. Here's how I'd write this, lambdas or not: public static List sortDescending(List ints) { ints.sort(new Comparator () { @Override public int compare(Integer o1, Integer o2) { if (o1.equals(o2)) { return 0; } else if (o1 My personal perspective is that your use is a typical abuse which turns simple code into something unreadable and overly complex. This makes code ha…

I'll meet you halfway:

      ints.sort((o1, o2) -> {
          if (o1.equals(o2)) {
            return 0;
          } else if (o1 
Or may i suggest a version with a guard clause and a simple ternary:

      ints.sort((o1, o2) -> {
          if (o1.equals(o2)) return 0;
          return (o1 
There's definitely no need for the 'new Comparator' boilerplate any more. That's not the kind of verbosity that adds clarity; it's just ceremony.

Re: Java for Everything

#140
post #93

This whole "expressive vs. performance" is a false dichotomy. Languages like Scala and Haskell are performant like Java and expressive like Python. Not to mention the work being done on JIT compilers by V8/HHVM/PyPy that are helping to close the performance gap for dynamic languages.

Clojure too. Very fast. Very readable. Very expressive.
Post reply on HN