Love and Hate For Java 8
snydeq writes "Java 8 brings exciting developments, but as with any new technology, you can count on the good, the bad, and the headaches, writes Andrew C. Oliver. 'Java 8 is trying to "innovate," according to the Microsoft meaning of the word. This means stealing a lot of things that have typically been handled by other frameworks and languages, then incorporating them into the language or runtime (aka standardization). Ahead of the next release, the Java community is talking about Project Lambda, streams, functional interfaces, and all sorts of other goodies. So let's dive into what's great — and what we can hate.'"
Java8 is bound to be one giant freakin drama.
Java is a brogrammer language. It's for people that find writing real programs, in real languages, too hard.
I'm disappointed. I expected Lambda functions to be closer to Erlang's implementation, where you can access the variables of the enclosing function/method safely. But perhaps the examples in the article are just too simplistic to show such behaviour.
I do not fail; I succeed at finding out what does not work.
Nooooo. Not Java. They are better than Microsoft. Right?
Proper date and time handling is one of the reasons I really prefer .Net to Java. The support for dates is just deplorable in Java. One shouldn't have to use an external dependancy, like JodaTime to handle basic date operations. If they could also add a "Decimal" data type, that is, a base-10 decimal primitive datatype, I think Java would be a much more useful language for day to day programming. Almost all the programming I do I would rather use a Decimal data type rather than a float data type, but very few languages support it as a native data type. .Net is one of the few environments where they got this right.
Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
Having grown up on Java, I know that it's always had a mindset of trying to be pretty much everything to everyone (even if sometimes half-heartedly.) That said, I'm tired of every language trying to see just how much of every possible programming model, paradigm, or feature it can tack on. It really seems like some bizarre dick-measuring contest among language designers these days.
I don't use annotations and actually any other irrelevant things ("for each", generics, most other things that were added with J2SE5.0) that have been added over time just because... for no reason but to pretend this changes anything for the better in any way and the JVM still runs the code that is written without all that syntactic sugar, etc., so no big deal, if you care you can use it, if you don't, nobody forces you.
MY OTHER COMMENTS
While the author states that he does not care about the "client" side of java (mentioning JavaFX but also Swing) i do* (mostly about Applets - the JavaFX stuff, as it's the new Applet thing in my understanding) - so... what's (new) with that folks?
* please... i know all the bullshit you haters prepare to write so don't waste our time! and yes, applets are great!!!
I despise java so hard. I'm stuck supporting someone fairly clueless who uses some java programs regularly. Theres just no way out of it for me aside from something serious. Like death.
Java seems to spawn the most craptastic, half-assed, slapped together, mostly works, good nuff... programs, communities, information, websites, support, and people. It's the
And between the updates it's ALWAYS needing. The security holes. And just general shitty running of the entire thing... I. hate. it. so. hard.
One new thing for JavaFX http://openjdk.java.net/projects/jdk8/features#153
It's pretty minor.
Deleted from all systems at least a year ago. Why bother?
The old adage is always applicable: Those that do not use LISP are condemned to reinvent it. Badly.
The old adage is always applicable: Those that do not use LISP are condemned to reinvent it. Badly.
Not that I totally disagree with you, but that's an amusing statement given that Guy Steele helped to write the implementation of Java per invitation of Bill Joy.
One must also remember the historical context when Java was created. A quotation from Steele on ll1-discuss: "We were not out to win over the Lisp programmers; we were after the C++ programmers. We managed to drag a lot of them about halfway to Lisp. Aren't you happy?"
Given how mainstream Ruby, Python, and even JavaScript are now for "real" development, back in the day "real" programmers only used native binaries for "real" applications. Java managed to pull a lot of people towards the dynamic-ish side of things. Certainly Perl (and shell) was around for use by sysadmins and the like, but those guys weren't "real" programmers.
IMHO, without Java being pushed as an alternative to C/C++, I don't think we would have gotten the renaissance of dynamic languages we have today; or, at the very least, it would have taken longer to get to the same point we are today. I say this as someone who has no great love for the language, but I have no trouble accepting its place in the evolution of languages in terms of technology and culture.
Since when is standardization stealing? Do you think the Redhat/JBoss devs that wrote Seam complained when they were asked to create the CDI spec? Or when Gavin King (creator of Hibernate) worked on JPA? Maybe in some bizarro world standardization actually happens as technologies mature. You can look at the expert list of any of the JSR and see who these *thieves* are.
My Hello World is 512 bytes. But it's also a valid Fat12 boot sector, Fat12 file reader, and Pmode routine.
thanks dude - yes, the one new JavaFX feature ("Enhance the java command-line launcher to launch JavaFX applications.") is pretty minor but that page you provided is very informative.
Java 8 is still limited to 32-bit array indexes, meaning, e.g. that arrays of doubles are limited to 32GB. Java won't get true 64-bit support until Java 9 in 2016.
I remember when C# and .Net first came out, it was noted that it was just borrowing (some said stealing) from Java. When C# first came out, I didn't see it as becoming a leader in new language features, but it is clearly is, as Java 8 addresses a lot of things that been part of C# for a while.
Streams: Similar to IEnumerable and parts of LINQ (LINQ to Objects). Of course, IEnumerables are less strict on multiple enumeration (it may work). Being a bit more strict on this as Streams isn't a bad idea. Functional Interfaces; The article was light on details, but it seems to address the use cases that extension methods in C# addresses. Interesting that the body of the method appear in the interface. The ability for a class to override this default is a new idea, it will be interesting to see how this plays out. Not a bad way to go about this at all. Lambdas:Well, it's -> versus =>. I can't imagine the discussions that occurred over which one to choose.
I'm not sure about the JavaScript in Java feature. But, I've always said being able to execute Scheme in .Net would be useful to me, so this something that MS may have to address down the road.
For me, Java still needs some catching up in terms of parallel programming versus the Task Parallel Library (and the Dataflow Extensions). This is especially true with C# 5.0. Async and await are powerful language features. Personally, I'm still prefer C#. I like having first class generics, the full LINQ library (Expressions) and libraries like Reactive Extensions and Code Contracts (plus the static verifier) are nice features. But, all this in Java 8lis a step in the right direction. I just hope it isn't a case of too little, too late.
That's the real question.
After years of saying java didn't need C# features they go and steal tons of them from C#! Whether it's properties, lambdas, function pointers or async/await, the Java community has always insisted that those features weren't necessary and that Java was no worse for omitting them. Now they go and steal them and put them into their products and everyone will declare them innovative new Java features. Last month it was Apple stealing the "Metro" UI from Windows Phone. Now this. Is Microsoft the ONLY company doing anything innovative anymore?
So if another framework or language has a certain feature Java isn't allowed to have them?
Really?
How much sh*t will break because of Java 8. My current employer of choice still has a core application which requires Java 6 and IE8..
It's not stealing from C#. Lisp had many of those features and more as early as the 1960s. Lexical closures, anonymous functions (lambdas), first class functions (i.e. function pointers), garbage collection, all of that was pioneered by Lisp. They are hardly new. John McCarthy and his colleagues invented them decades ago.
I'm not sure how that connects to the GPs request. Anyway Gosling didn't include it because the behavior aren't defined in CPU independent ways.
32-unsigned 0 minus 32-unsigned 1 = ?
where ? is CPU dependent. Some you'll 0xFFFF other 0x8001 others 0xFFFE. That's precisely the sort of thing JAVA was designed to abstract away. And if you don't want unsigned to be doing raw CPU arithmetic on primitives then you can just use a library.
Stop rhyming, and I mean it!
Anybody want a peanut?
"Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp."
http://en.wikipedia.org/wiki/Greenspun's_tenth_rule
It's a much better designed, more modern language, and as an added bonus it runs on the JVM, and integrates with a lot of the tools that Java devs are already familiar with.
In case you weren't aware of it: http://ironscheme.codeplex.com/
No sig, sorry.
The basics still are wrong: generics still are slow and poorly implemented and Java still is bad for numerical apps.
You stupid twat. Don't think for one second that C# invented any of those features. Those features existed long before MS ripped off Java.
After Oracle's suit against Google about Java, I am not going to touch Java again.
After years of saying java didn't need C# features they go and steal tons of them from C#! Whether it's properties, lambdas, function pointers or async/await, the Java community has always insisted that those features weren't necessary and that Java was no worse for omitting them. Now they go and steal them and put them into their products and everyone will declare them innovative new Java features. Last month it was Apple stealing the "Metro" UI from Windows Phone. Now this. Is Microsoft the ONLY company doing anything innovative anymore?
Right, lets pretend Microsoft invented all of those things.
I'm a good cook. I'm a fantastic eater. - Steven Brust
After the disaster known as Java 7 I see no reason to change.
Java 6 works just fine thank you very much and will use it for many more years to come!
Java 7 had so many security vulnerabilities and with 6 I do not have to worry about shit breaking like the Android SDK and malware attacks that 7 has. I cringe thinking about the changes java 8 will include.
http://saveie6.com/
What's the realistic alternative to Java? Java is good enough and the main gripe is that Oracle is loosing the trust that Sub Microsystems built up.
C# just isn't for political reasons. Financial institutions are very influential in programming languages becoming significant as they are the ones with deep pockets that hire huge amounts of -admittedly mediocre- programmers. So far all large to huge financial institutions I know bar Microsoft from entering their data centres.
So, what's the realistic alternative to Java that financial institutions will embrace?
I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
Is it better to write 3+5 than 3.add(5) ?
The thing 3.add(5) has going for it is clarity, in that I know 5 is being added to 3.
3+5 in a world where operator overloading exists could mean 3 carves 3 and 5 on a tree, or 5 posts a nice message to 3's Facebook wall.
Because "normal" humans do not have to read code, it's really not that obvious at all that 3+5 is better than 3.add(5) or other variants thereof...
"There is more worth loving than we have strength to love." - Brian Jay Stanley
Because Microsoft invented those methods? You need to get out of the basement more often, and well did Microsoft "steal" java and change the syntax a little to make c# ? Hmmmm? Quit raging, and grow up.
We need to start using the right tools for the right job, or make tools for the right job..
That is... DOMAIN SPECIFIC LANGUAGES, not General purpose language library bloat.
Right, lets pretend Microsoft invented all of those things.
If you had been following the language discussions for (for instance) lambda-J you would realize that there is a LOT more to it than simply deciding that a language must have this or that feature.
Specifically, both Java and C# are statically typed languages (although in C# a variable can be statically typed to be dynamic, but I digress) with advanced multi-generation garbage collection, structured exception handling, generics etc. Any new concepts introduced into the language must respect the concepts already there. Designing new features for Java or C# requires significant amount of innovation to solve the interference problems and maintaining the "feel" of the language.
LINQ is a real accomplishment, one that I have not seen put together like that in any other language. Yes, list comprehensions existed before. Yes, expression trees (ASTs) have been used in LIST and several other languages before. Don't know about extension methods, but I'm sure that there must be some research language. Yes, type inference had been used before. Yes, inferred classes must have been used in some language before. Certainly lifted types are well-known in certain other languages. But putting the whole package together and make it fit seamlessly with (and complement) the existing features and at the same time keep it so simple and generic that the useful parts are actually library features, that is a real accomplishment.
Reactive Extensions is real research (primarily by Erik Meijer who has regrettably now left Microsoft to return to academia). Not least because it ties to beautiful in with LINQ. It is entirely new? No, as Erik himself would say, IEnumerable is just a monad. IMHO that does not take away from the accomplishment.
Async and await are *really* cool and have inspired Scala to create something similar.
No, Microsoft didn't invent "all of those things". But fitting them in with a curly-brace, statically typed language is real innovation.
Reading slashdot one-liner: (irm http://rss.slashdot.org/Slashdot/slashdot).rdf.item | fl title,desc*
When installing Java and seeing the "3 billion devices run Java" I couldn't help but shout out "3 billion flies eat shit".
Just because something is popular doesn't mean that it's good.
I don't know. Reading the article, all I'm thinking is: how many ways can Jimmy find to fuck up his code now? At least with Groovy and Scala, these language features were pretty much limited to programmers who knew what they were doing. With Java, it's a bit like giving everybody in the world a glock and expecting everything to get better.
Nice try. Java does not steal from .NET -- they are not afraid of them. They try to play catch up with the _other_ JVM languages like Scala, Closure.
So does Java support unsigned integers (words) yet ?
Quite how anything can profess to be a "programming language" without the concept of an unsigned integer is simply beyond me.
For a quality post such as yours, you really ought to login and attach a name to it.
Of course they didn't invent lambdas and function pointers!
They did, however, invent async/await and the Metro UI. They didn't invent async programming, but they did invent the state machine rewriting mechanism that makes async/await so easy. They didn't invent the flat Metro look (the Seattle Metro did), but they did invent the UI around it. They didn't invent monads, but they did invent LINQ (a way to write DB queries natively in whatever language you're using, like C# or VB).
In this case, though, Java's not even copying the innovative features like async/await. They're adding features that have been around for decades, like lambdas. And even then, the lambda implementation doesn't include closures -- at best your lambda can access variables of the enclosing method that don't change, but they're just copying the values. Real closures actually include references to the variables so that they can change. The spec claims that it's to encourage concurrency, but really it's to address the shortcoming in the JVM that the escaping variable records are hard to create.
dom
dom
or Haskell. Scala has the advantage(?) of using the JVM. Of course, my personal preference is back to Fortran. For those still stuck in the Fortran IV/77 time warp, you might want to look at the 2003 specification (and the minor rev in 2008).
Oracle has demonstrated through their Google lawsuit and their (mis) handling of OpenOffice & MySQL that they are not to be trusted and will screw former partners if they think it's financially beneficial.
Let me know when Java enters the real world with an open specification process and the spec is managed by an independent industry group. Until then there is horrible vendor lock-in with a vendor I don't trust to not sue me if I do something they don't like.
I accidentally clicked an Infoworld link again. :-(
The is one and only one correct behaviour: 32-unsigned 0 minus 32-unsigned 1 = ArithmeticException — which is perfectly CPU independent. Obviously Gosling did not think far enough.
Of course it is cross platform. If you do it right instead of fast. Because when you do it right you raise ArithmeticException on overflows.
How about you need 0 … 255? Very common need in computing.
Java bytes go negative => mayor pain in the arse
short could be negative and 256 onwards => if (x<0 && x> 255) destroying all speed advantages. And you need twice as much memory.
BTW: The OP said unsigned bytes. As in 0 … 255. Honestly who needs a byte to go from -128 … 127 — that is the most useless data type in the known universe.
Spot on. And that is the reason I prefer Scala — which has operator overloading.
Don't believe me? Go find some articles from the mid-nineties. Java was *literally* sold with lines like "you cannot have a null pointer exception in Java". (right) And that it would make the programming backlog go away. (right) And it would be far easier to debug, and there'd be far fewer bugs. (Ever seen a tomcat trace, with 150-200 lines *every* *time*?)
No, thank you.
mark
Once again, Boost comes to the rescue! Provide a couple of operators, and it fills in the other ones you may want. Very well thought out, as most Boost libraries are -- for example, NaNs mean floating point numbers can't necessarily be given a strict ordering, so they provide "partially_ordered" if you need that.
When it comes to efficiency, compilers are remarkably capable these days. I just ran a test with GCC 3.4.5. It optimized "a < b || a == b" to the exact same as it generated with "a <= b" (at -O1). Source code available on request, but just try it yourself.
The lesson here: never make assumptions as to what is most efficient until you actually compile and see what happens. Instead, give the programmer the tools to make the code readable and maintainable, and then fix inefficiencies as you find them. "Premature optimization is the root of all evil." (Donald Knuth)
Ada gives a access to CPU unsigned types without “implementation defined”. Mind you Ada prescribes RANGE_ERROR on for overflows in signed types and modulo operations on unsigned types. Either way it is well defined.
Scala hides the difference between class Integer and primitive int behind a new type Int. The compiler decides automaticly if a class or primitive should be used. The quite old language SmallTalk does so as well. Primitives are only interesting when you JNI work. Worse case scenario: array of unsigned byte or short in to our out of a JNI call.
Also it should have been build into the compiler. A library is not good enough because Java has no operator overloading. Ada has, Scala has. Almost all other OO Languages have. But not Java.
Not good enough because Java is missing another important OO Feature: operator overloading. If I may expand the title of the Article “Love for the JVM and Hate For Java”.
Also: Arithmetic contains great potential for optimisation. But for this the compiler need to know what kind of type he is dealing with:
x + 1 + 2 should be optimized to x + 3
MAX_FOO + 4 should be evaluated at compile time
x < y || x = y should be optimized to x <= y
You can still have a library in background to be used by the compiler but the type must be part of the language. The SmallTalk approach that would be.
Anyway: For me the solution was to use Scala when ever I can.
True. CPUs do roll over.
And thinking of it (and correcting myself): Ada does for unsigned typed as well. Not for signed. There a RANGE_ERROR is raised. Strange but sometimes useful asymmetry.
But that does not invalidate my statement. All CPU I know of (there might be others, more exotic CPUs of course) set a carry and/or overflow flag on signed and unsigned roll-overs as well. One does not exclude the other here.
In 8 bit times those flags where extremely important to do 16 bit operation with only an 8 bit arithmetic logic unit. That is why it is called carry flag. And of course you can branch on the carry flag set or unset.
They don't have the same unsigned arithmetic.
That seems wrong to me. In fact it seem the wrong way around for me.
For signed binary arithmetic there are two option:
One-Complement: Where we have symmetric positive and negative ranges. Including a negative zero. Seldom used.
Two-Comlement: Where we have asymmetric positive and negative ranges. With the negative range having one extra number.
But for unsigned binary arithmetic I only know one way of doing it. 30 years of experience in the field. More then a dozen programming languages learned. Degree in computer science. I am hard pressed to even think of a different way to do unsigned binary arithmetic. Even on a purely abstract and academic level.
But one is never to old to learn something new and I a the curious type: Please enlighten me!