Live data from Hacker News

Modern Java – A Guide to Java 8

github.com

91–100 of 203 posts

Re: Modern Java – A Guide to Java 8

#91

Earlier quoted context omitted.

It may not be modern computer science, but it is modern Java. This post is about modern Java and explains the new (in v8) features very well. What's your problem?

OK, what then is Java The point was that if one has a proper old-school computer science (to realize the crucial importance of first class procedures and the power of uniformity 20 years ago) all these modern features are coming for free, to which the code above is an illustration. But who cares. There is a whole industry which praised Java for almost two decades even without these "modern features". Any PL student o…

> Any PL student of a decent school, if he is not a hypocrite, would tell you that Java is the worst thing that happened to CS since MS DOS,

That's why we don't listen to students to make this kind of uninformed claims.

Java has flaws, for sure, but calling it the "worst thing since MS DOS" can only come from someone who lacks perspective and experience.

Re: Modern Java – A Guide to Java 8

#92
My Java code has improve dramatically since I started (ab)using Optionals.

  String foo = Optional.ofNullable(paramater)
                       .filter(...)
                       .map(a -> ...)
                       .map(b -> ...)
                       .orElseGet(() -> ...)
                       .orElse(defaultValue)
Between this kind of thing, and similar playing with Streams, some of the ugliest code I work with is suddenly quite clear, coherent, understandable.

Re: Modern Java – A Guide to Java 8

#93
My company switched from 7 to 8 recently, and being able to use streams has been a colossal productivity boost.

I'm actually in the process of putting together a presentation on how to work magic with streams (because I'm one of the few people here who actually knows how to use them), and this will probably get a mention in a "further reading" slide, because it's really well written.

It's also inspired me to make a few slides focusing on the changes to Map and Comparator, which I wasn't aware of until now.

Re: Modern Java – A Guide to Java 8

#94

Earlier quoted context omitted.

I don't know how you can find even average Java code unreadable. If anything it's incredibly verbose. Only now with the most recent features is it really likely that you'll run into some one-liners and magic functions. Now, if you were talking about frameworks/app servers and not being able to figure out which levers and knobs to push to get them to behave, I would agree wholeheartedly. I'm not saying Java is good lo…

> I don't know how you can find even average Java code unreadable. If anything it's incredibly verbose. Not bad_user, obviously, but excessive verbosity can be antithetical to readability. (As can excessive conciseness.) It can make the overall structure and meaning of the code hard to discern, even though can clearly tell where what gets assigned to what variables, etc.

Completely agree. This is really the best time for comments in Java. Have 5 lines of stuff that's essentially working towards a single goal? Comment it! You should end up with the comments reading out the narrative properly, even if the code is way too wordy.

Re: Modern Java – A Guide to Java 8

#95
A really nice tutorial.

I have been writing Java code since 6 years. Although I can't say that I have programmed in many other languages (I have coded in C/C++ and Javascript), Java has been always very comfortable to use. It's easy to think of a solution in the Object Oriented paradigm, and I think refactoring (when a requirement changes) has not been much of a problem for me. It's only bad designs that make the code more verbose than it should be, and I think verbosity is actually a good way to articulate your thoughts, and see them evolve in front of you. Recently when I started learning Haskell a bit, I found that there are much faster and concise ways of writing code, but I still prefer Java because of the clarity of the way it allows me to express my logic. People would say that writing a line of code in Haskell would do what 10 lines of code in Java would do, but in the long run, I have found that expressing programming paraphernalia like interfaces and classes actually helps the coder in his job (not necessarily results in wastage of time).

Re: Modern Java – A Guide to Java 8

#96
post #86

Earlier quoted context omitted.

I have been using Java since the first beta, and have written a large pile of Java books (pun not intended), but I too prefer Clojure as a practical, simple to use and simple to read language. That said, Clojure / Java interop is really nice. I frequently find myself simply adding existing Java code to my lein project file. I would suggest just keep using Clojure and when it makes sense, mix in Java when you want or…

This might sound like a snarky comment but it is actually not. If you want a dynamic language on the Java platform; then why not use JavaScript? There is an easy-to-use engine in Java 8 and JavaScript is widespread and somehow familiar to Java-developers.

I like JavaScript for Meteor.js and general front end development but I have never thought to use embedded JavaScript. Clojure is a practical little language and suits my taste.

Re: Modern Java – A Guide to Java 8

#97
post #58

Earlier quoted context omitted.

Agree and disagree. The thing I was going for is that compscience advantages don't seem to matter for language adoption. i.e. popularity does not correlate to compsci purity.

Yes, there are different forces in a play. Let's name it as The Law of a Decent Runtime, and The Law of Attention to Details, and The Law of a Bazar of Ignorant.)) The Law Of a Decent Runtime is very simple - evolving a decent runtime is very costly and time-consuming. It is also related to the second law and to the inverse of the third - which is a the Law of Dictature of The Most Competent . A decent runtime cannot…

Your Law of a Decent Runtime reminds me exactly of the "Lisp Curse":

http://www.winestockwebdesign.com/Essays/Lisp_Curse.html

Re: Modern Java – A Guide to Java 8

#98
It wasn't touched on in this document, but I think more people should hear about Nashorn. It is the new JavaScript Engine that, I believe, supports ES 5.1. It allows you to do some pretty neat things with Java/JavaScript interacting in the same VM. Java 9 is planning on supporting ES6 .

You can see an introduction on this Oracle documentation: https://docs.oracle.com/javase/8/docs/technotes/guides/scrip...

Re: Modern Java – A Guide to Java 8

#99
post #28
post #25

Earlier quoted context omitted.

If you are using Java and have not tried Lambda Expressions, method references and default methods, do so now! After that, you'll think "How was I able to live without that?" I think instead of "How was I able to live without that?", people are more likely to exclaim "about time!"

Yep, somewhere at Xerox PARC in the early 80's coll := ((1 to: 100) select: [:x| ( x * x ) > 3]) collect: [:x | (x * 2)].

What language is this exactly? I'd love to research a bit more. Just any search terms to point me in the right direction.
Post reply on HN