Live data from Hacker News

An Opinionated Guide to Modern Java Development, Part 1

blog.paralleluniverse.co

71–80 of 402 posts

Re: An Opinionated Guide to Modern Java Development, Part 1

#71

Ironically the Java ecosystem could stand to use some garbage collection of its own: there's a ton of old, outdated info out there that both colors people's impressions of the language and teaches new players a whole manner of bad habits. I appreciate what this article's going for and hope there'll be follow-ups. I use Java daily and though there's undoubtedly room for improvement (I'm looking forward to when tooling…

> old, outdated info out there

I'd love it if the JDK had a "learner mode" that disabled interned string literals. Then newbies experimenting with `assert(str1 == str2)` wouldn't leap to false conclusions.

Re: An Opinionated Guide to Modern Java Development, Part 1

#73
post #68

Earlier quoted context omitted.

There is a good reason that Sun didn't want this to happen and tried to stop it in court — successful against Microsoft, failed against Google. If I remember right, most everyone on here was rooting for Google to win and continue to fragment the language.

The question is what Oracle would lose by licensing real Java to Google at reasonable conditions. Mobile non-Android Java is deader than dead.

> Mobile non-Android Java is deader than dead.

Lots of embedded devices make use of J2ME, e.g. cars, manufacturing, electricity monitoring...

Re: An Opinionated Guide to Modern Java Development, Part 1

#74
post #48

I like the changes in Java 8, but I'm concerned about Java fragmentation between Oracle/OpenJDK and Android. It seems Android is stuck on Java 1.6 (since Dalvik is not "true Java" and is more like a VM that happens to implement a language very similar to Java 1.6). There's now a huge gap between 1.6 and 1.8. It's not just syntax like lambda and default methods. It's also the supporting API changes in collections (str…

Android already supports most of Java 7 http://tools.android.com/tech-docs/new-build-system/user-gui... I'm not aware of any plans to support Java 8 yet, but I haven't been looking.

If you target only KitKat and don't mind missing some of the Java 7 new APIs.

Re: An Opinionated Guide to Modern Java Development, Part 1

#75
post #19
post #9

Earlier quoted context omitted.

Genuinely curious : i've been playing with dependency injection, and really never got to understand the true use of it. I mean, what's the point of being able to replace an implementation outside the source code itself ? You'd still have to extensively test the thing and recompile it... Is there more to it than just being able to replace a class by its mock up, for unit testing ?

Not to sound snarky, but you should read any introduction to dependency injection. The benefits are generally covered very thoroughly, and what you said is not usually considered a benefit.

Wikipedia article on dependency injection, section titled "Advantages", _first_ bullet: "The result is more independent clients that are easier to unit test in isolation using stubs or mock objects that simulate other objects not under test."

Would you like to try again?

Re: An Opinionated Guide to Modern Java Development, Part 1

#76

A lot of people love to hate on Java, but it's a surprisingly dynamic language and there is a ton of great testing, networking, and many other libraries available. One of the things I appreciate about Java is the ability to take large teams and just have their stuff work together, without having unhuman discipline around super subtle rules (eg: C++) Also, IntelliJ is a must have!

In what way is Java a "dynamic language" ?

Re: An Opinionated Guide to Modern Java Development, Part 1

#77
post #39

Not a single mention of Guice or even dependency injection? Seems like a gaping omission in a guide that claims to be about "modern" Java.

Dependency injection and any othee type of code indirection is evil imo. Anything that breaks the ability to find your way in a codebase with something other than grep brings more pain in the long run than it saves.

> the ability to find your way in a codebase

It's a tradeoff between two different kinds of clarity. Yes, it's harder to see the "whole wiring" without better tools...

But it makes small, encapsulated classes much easier to reason about and develop! You can focus on assuring: "My `Foo` can interact with a supplied `Bar`" rather than dealing with all sorts of crap about what implementation of `Bar` it gets or how that `Bar` instance is configured.

Re: An Opinionated Guide to Modern Java Development, Part 1

#78

I'm using Java for the first time because of Android. I had played with Java when it first came out but have stayed with C/C++/C# for almost everything. I have to say that my Java experience isn't as unpleasant as I thought it would be. I always thought C# is what Java should have been but after learning a little idiomatic Java the reality is quite okay, really.

In a lot of ways C# is still a much superior language than Java, but the JVM (I'm thinking HotSpot) is tremendously better than the CLR.

I follow Grail and now Truffle development since the days of the Maxime VM.

Looking forward to the day the reference JVM becomes a meta-circular one.

Re: An Opinionated Guide to Modern Java Development, Part 1

#79
post #9

Earlier quoted context omitted.

Genuinely curious : i've been playing with dependency injection, and really never got to understand the true use of it. I mean, what's the point of being able to replace an implementation outside the source code itself ? You'd still have to extensively test the thing and recompile it... Is there more to it than just being able to replace a class by its mock up, for unit testing ?

It depends. One thing that I thought is an interesting feature of Spring, is that it allows the framework to inject code between your dependencies like decorators. This allows them to do aspect-oriented-programming transparently. And I think there's some interesting ideas here. For example, you can mark the interface of a class as @Transactional, and all your implementations will get the behavior.

I think that's the interception way of AOP? Unity IoC in c# also does this.

The IoC container will return transparent proxy(Not the original object), which then calls the underlying method(after doing the AOP behaviour).

Re: An Opinionated Guide to Modern Java Development, Part 1

#80
post #70

Earlier quoted context omitted.

There is a good reason that Sun didn't want this to happen and tried to stop it in court — successful against Microsoft, failed against Google. If I remember right, most everyone on here was rooting for Google to win and continue to fragment the language.

I have since repent myself. Google did indeed managed to pull a Microsoft and now we have a forked Java implementation getting steady behind the standard Java implementations. Even J2ME is more compatible with its big brother than Android. KitKat has now partial support for Java 7, with libraries still missing some pieces. Dalvik and ART still don't support invokedynamic bytecode. And since almost no one has KitKat,…

I wrote a lot of J2ME stuff a few years ago and you're spot on. I spent two weeks doing Java 8 bits with NetBeans which was really nice and spent the last two evenings writing my first Android app and what a complete mess it is. Plus the Android tooling is horrible to get working reliably - most problems being solved by "restart eclipse".

Late edit: perhaps Oracle should make a phone ;)

Post reply on HN