Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
×
Java Programming

Love and Hate For Java 8 434

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.'"
This discussion has been archived. No new comments can be posted.

Love and Hate For Java 8

Comments Filter:
  • by msobkow ( 48369 ) on Thursday July 25, 2013 @06:57PM (#44386961) Homepage Journal

    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.

  • by CastrTroy ( 595695 ) on Thursday July 25, 2013 @06:58PM (#44386971)
    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.
    • by msobkow ( 48369 )

      How would your Decimal concept be any more powerful than Number?

      The one thing I wish they'd have done with Number is added Precision and Scale to it's usage, which would be invaluable for things like financial and scientific calculations.

      • by msobkow ( 48369 )

        Sorry. I meant "BigDecimal".

      • They need to support it as a native numeric type, so it's not so difficult to use. If it was a native type with proper mathematical operators you wouldn't need questions on Stackoverflow [stackoverflow.com] about how to add two values together.
        • by msobkow ( 48369 ) on Thursday July 25, 2013 @07:20PM (#44387109) Homepage Journal

          I'd hardly call it "difficult" to use, any more than it is to use the wrappers for the native types. Still, it would be *nice* if you could use "+" instead of "add()", but really that's just syntactic sugar.

          • by Anonymous Coward on Thursday July 25, 2013 @07:31PM (#44387163)

            I'd hardly call it "difficult" to use, any more than it is to use the wrappers for the native types. Still, it would be *nice* if you could use "+" instead of "add()", but really that's just syntactic sugar.

            To some extent, anything beyond raw binary notation used by your processor is just some form or another of "syntactic sugar" transformed by some intermediate tool.

          • by petermgreen ( 876956 ) <plugwash&p10link,net> on Thursday July 25, 2013 @07:44PM (#44387237) Homepage

            People like to dismiss syntactic sugar as unimportant but IMO it's the difference between code that is pleasant to read and write and code that is a PITA to read and write.

            I wish some fork of java would happen and take off that adds back in the basic features sun left out. Stuff like properties*, user defined types without an implicit reference, unsigned numeric types, operator overloading, parameter pass by reference etc. Some of that is syntactic sugar, other parts not so much. Ideally these features would be done in a way that could somewhat work on existing VMs though some features would likely require VM enhancements to operate efficiently.

            Unfortunately MS has already taken the name J++ :(

            * No that javabeans shit doesn't count.

            • by jythie ( 914043 )
              I think in general people use the term 'syntactic sugar' when they feel that it does not increase readability. I know I tend to use it to describe features that neither add functionality nor seem to make the code easier or harder to write. Things that do one or the other I just call 'useful'.
              • by LO0G ( 606364 )

                Interesting. I've always used "syntactic sugar" to mean language features that are fundamentally implemented in the front end. For example C++ lambdas are effectively syntactic sugar - it's a clean syntax that wraps an anonymous class declaration (with the lambda capture values being class members and the lambda body being an "operator()" method).

                Another example is C++ reference parameters - under the cover most C++ compilers implement reference parameters as pointer to type parameters and the reference par

                • by EvanED ( 569694 )

                  I've always used "syntactic sugar" to mean language features that are fundamentally implemented in the front end

                  But what does that mean? Lots of stuff is implemented in the front end. Without knowing for sure, loops and conditionals are language features that are probably almost always lowered to gotos by the time it hits the back end. Classes are almost guaranteed to be syntactic sugar, even if they have virtual functions. Templates and macros are syntactic sugar.

            • by jbolden ( 176878 )

              There are lots of languages built on top of the JVM that can even use Java libraries which have totally different syntax. Clojure being a great example, and Scala another.

              • Unfortunately, it seems that JVM based languages are still limited by the lack of unsigned types. What a remarkably stupid decision to omit them.

                • Unsigned (Score:4, Informative)

                  by jbolden ( 176878 ) on Thursday July 25, 2013 @10:09PM (#44387975) Homepage

                  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.

                  • How is int_minvalue - 1 handled? In .Net without an unsafe directive, it does bounds checking on the result and raises an exception.
                    • 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 a
            • by Ksevio ( 865461 )
              Just imagine how many lines of useless java code could be removed if it had implemented properties! No more of these pointless getValue(){return value;} that everyone in the java world seems to admire. if there's a part of your code that can be auto generated, there's a problem with the language.
          • by Alomex ( 148003 ) on Thursday July 25, 2013 @07:55PM (#44387307) Homepage

            Actually it isn't. The add() method belongs to the first parameter, whereas the native '+' implementation (used to) belong to neither and if you think about it really should be that way.

            '+' is not a method or property of the first parameter. the correct interpretation of a+b is that this creates a unnamed virtual object number tuple with the method add.

          • by Alomex ( 148003 ) on Thursday July 25, 2013 @08:10PM (#44387379) Homepage

            Academic types have rejected 95% of all real advances in programming languages for nearly 4 decades as "syntactic sugar" while they carry on with their abstract type theory which has had rather limited impact in the real world in the same time span.

            Do yourself a favor and do away with the "syntactic sugar" crutch and try to judge a language proposal on it's own merits. Is it better to write 3+5 than 3.add(5) ?

            The answer is obviously YES, so who the hell cares if it is syntactic sugar, syntactic salt or syntactic coconut sprinkles.

            If it makes life better it should be adopted. End of story.
            p.s. there are potential drawbacks with operator overloading, but "syntactic sugar" ain't one of them.

            • by bzipitidoo ( 647217 ) <bzipitidoo@yahoo.com> on Thursday July 25, 2013 @11:02PM (#44388229) Journal

              What bugs me about operator overloading is how tediously verbose it can get. For example, say you define operator functions for < and ==. You still have to do <=. Even when all the <= function is is: return this < that || this == that;, you still have to write it. It's so tempting to skip writing the code for an unused operator that many programmers do so. Languages are mostly unable to automatically fill in obvious code of that sort. C++ does have a default assignment operator function, but that's all. Too much chance of the obvious being wrong, so they opt not to do anything.

              To make matters worse, the above implementation of <= is inefficient. Down at the machine level, the computer does not stupidly require 2 separate comparisons to test <=. It has instructions such as JLE. The above function will at the least result in the computer having to do JL; JE;. While JE may be executed only 50% of the time that JL is executed, depends entirely on the data and code, it's still a waste. Further, two branches takes more space in the CPU's branch prediction, and the extra instruction takes more space in cache, so JL; JE is not as good as 50% slower.

              I find your gratuitous slur against "academic types" unwarranted and unfair. Academia has produced much innovation in programming. Do you forget the proof that Structured Programming is sufficient, and GOTOs are not necessary? All the work done on Turing machines, and universal computation? Automata Theory, with the classification of grammars into such categories as "context free"? BNF? Without that academia you sneer at, we couldn't be sure of all that. What of the entire concept of OOP? Where did that come from? And functional programming and LISP? It's easy for some hack to bang out a programming language built around what he feels are a few good ideas, drawn from perhaps years of experience. But without careful examination of the problems, insightful modeling that leads to good, pertinent questions which can be proven one way or another, we would just be flailing around even more than we already do. We might all still be trying to program in ALGOL. I put more trust in academia's ability to create a good programming language than I do a modern corporation with its dismissive attitude towards fundamental research.

    • by viperidaenz ( 2515578 ) on Thursday July 25, 2013 @07:50PM (#44387273)

      New Java Date Time API for Java8: http://openjdk.java.net/jeps/150 [java.net]
      AKA JSR 310

  • by countach ( 534280 ) on Thursday July 25, 2013 @08:13PM (#44387391)

    The old adage is always applicable: Those that do not use LISP are condemned to reinvent it. Badly.

    • by Alomex ( 148003 )

      Except that no one ever said that. Santayana said that about history and Henry Spence paraphrased it with Unix, but no one said it about Lisp.

      In fact all the modern functional languages are remarkable in how much they are not like Lisp, starting from Scheme which managed to maintain the horrible parens notation but did away with almost everything else (dynamic scoping, no state, no control structures, no defun, etc.) and moving on to Python, Haskell and Scala.

  • by ChaseTec ( 447725 ) <chase@osdev.org> on Thursday July 25, 2013 @08:59PM (#44387647) Homepage

    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.

  • Still 32GB barrier (Score:3, Informative)

    by michaelmalak ( 91262 ) <michael@michaelmalak.com> on Thursday July 25, 2013 @09:06PM (#44387681) Homepage
    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.
  • Seems familar... (Score:4, Informative)

    by ndykman ( 659315 ) on Thursday July 25, 2013 @09:07PM (#44387683)

    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.

    • Re:Seems familar... (Score:5, Interesting)

      by hibiki_r ( 649814 ) on Thursday July 25, 2013 @09:51PM (#44387879)

      More than reacting to C#, they seem to be reacting to other JVM languages that are just more attractive for any shop with experienced people.

        The JVM is often used to write large amounts of business crud: Take a parameter, query a database, process a list. Make a service call, transform the result into a slightly different list, merge the results with a different service, then return. You could write that kind of computation in a functional way using Groovy or Scala in half the number of statements. And if there's one rule for programming productivity is that the less statements you need to write, the faster the job can be written, and the less bugs you get.

      When the people using your virtual machine start migrating to other languages you do not control, you are at risk of having the people building the language just porting the language away to a different one, and poof, Java becomes obsolete. Therefore, Oracle just has to improve Java.

    • by elabs ( 2539572 )
      C# was a fusion of Java, C++ and Delphi. Java 8 is just playing catch-up, sucking in all the innovation that the Microsoft guys have been doing over the past decade. I think you're right that Microsoft is innovating and blazing new trails at a much faster rate than Oracle can copy.
    • In case you weren't aware of it: http://ironscheme.codeplex.com/ [codeplex.com]
  • by greg_barton ( 5551 ) <greg_barton @ y a h o o.com> on Thursday July 25, 2013 @10:02PM (#44387933) Homepage Journal

    So if another framework or language has a certain feature Java isn't allowed to have them?

    Really?

  • by stenvar ( 2789879 ) on Thursday July 25, 2013 @11:12PM (#44388267)

    The basics still are wrong: generics still are slow and poorly implemented and Java still is bad for numerical apps.

  • by SpaghettiPattern ( 609814 ) on Friday July 26, 2013 @01:18AM (#44388679)
    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?

How many hardware guys does it take to change a light bulb? "Well the diagnostics say it's fine buddy, so it's a software problem."

Working...