Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
Java Programming Open Source Operating Systems Software Build Technology

Slashdot Asks: What Are Your Favorite Java 8 Features? (infoworld.com) 427

New submitter liveedu shares with us a report from InfoWorld: When Java 8 was released two years ago, the community graciously accepted it, seeing it as a huge step toward making Java better. Its unique selling point is the attention paid to every aspect of the programming language, including JVM (Java Virtual Machine), the compiler, and other help-system improvements. Java is one of the most searched programming languages according to TIOBE index for July 2016, where Java ranks number one. Its popularity is also seen on LiveCoding, a social live coding platform for engineers around the world, where hundreds and thousands of Java projects are broadcasted live. InfoWorld highlights five Java 8 features for developers in their report: lambda expressions, JavaScript Nashorn, date/time APIs, Stream API and concurrent accumulators. But those features only scratch the surface. What makes Java 8 amazing in your opinion? What are your favorite Java 8 features that help you write high quality code? You can view the entire list of changes made to the programming language here.
This discussion has been archived. No new comments can be posted.

Slashdot Asks: What Are Your Favorite Java 8 Features?

Comments Filter:
  • by Anonymous Coward on Tuesday August 30, 2016 @06:56PM (#52799985)

    Seriously? This is "journalism"? It's just a gushing promotion.

    My favorite features are the brutally awful runtime performance and the incompatibility from one JVM/J2EE server to the next. Just awesome.

    Runner up "feature" is the litigous vendor behind it all. I just *looooove* Oracle. They are such nice people!

    • by RobotRunAmok ( 595286 ) on Tuesday August 30, 2016 @07:20PM (#52800113)
      No, it's not journalism. It's another in Infoworld's tedious astro-turf-by-story-submission stories. They pay Slashdot, have one of their Marketing Chippies put together a story with a link back to their trade mag, and the skids are greased for it to hit the main page here as scheduled. (snydeq is their usual flunky [slashdot.org]) The incredible -- or just-precious -- part of it is that InfoWorld believes there is enough of any critical mass of programmers or software industry decision-makers who still frequent Slashdot to make this a worthwhile media buy for them.
      • Re: (Score:3, Informative)

        by cpm99352 ( 939350 )

        The incredible -- or just-precious -- part of it is that InfoWorld believes there is enough of any critical mass of programmers or software industry decision-makers who still frequent Slashdot to make this a worthwhile media buy for them.

        Well, I'm both a programmer and a decision maker, and I really wonder about the motivation of someone who would pick Java for a new project. Oracle is beyond toxic.

        I'm a certified Java Programmer (1.4) and really don't advertise it any more. Oracle's Java is dead to m

    • Comment removed (Score:5, Interesting)

      by account_deleted ( 4530225 ) on Tuesday August 30, 2016 @08:08PM (#52800371)
      Comment removed based on user account deletion
      • by bondsbw ( 888959 )

        Heck, now that the C# compiler suite (Roslyn) is open source, Google could even fork it and do whatever it wanted with it. Not that I suggest it... that community is pretty awesome and the language has managed to remain incredibly clean and forward-thinking given its heavy evolution.

      • I don't know C#, other than it is a sort of almost C++, but not quite. Oh, and it runs in a kind of JVM, but not quite. Obviously I can't comment on the merits or otherwise of the language, but having long experience with both Microsoft and Oracle, I feel I come out in favour of Oracle - perhaps not on how nice they are (they are both businesses - ie callous, greedy and only trustworthy if it is profitable), but to an engineer what matters is not 'how gentle their smile, how sweet their countenance', but th

        • The documentation for C# (and to be honest all of Microsoft's recent offerings) is phenomenal. Easy to read, easy to search, well referenced, lots of examples. The language itself is modern, sleek, well thought out, and has incredibly useful features like LINQ that simply no one else has.

          As a linux nerd I spent two decades laughing at M$'s incompetence. But I have to give credit where credit is due. I hate the fact that C# is my current favorite high-level general purpose language.

    • My favorite Java 8 feature:

      java.net.UnknownHostException: slashdot.org: unknown error

      Because really, it's impossible to get a better message than "unknown error" from the getaddrinfo call it's making under the hood.

      Hrm, I guess that's a bug not a feature.

    • I'm using Dalvek

    • He's on the wrong Java.
    • Java is now toxic thanks to its owner. For the sake of the entire tech industry, we all should consider it a legacy technology that should be removed from everything as quickly as possible. Unfortunately that will take years... maybe even decades, but we must start the deprecation process as quickly as possible. Besides, in the 20 years since it was created we have better cross platform languages now anyway.

      Thankfully a lot of us have input in to technical decisions here. We all need to take a stand and kil

  • System.exit() (Score:2, Insightful)

    by oddware ( 1607691 )
    It's the best thing java can do
  • Promoted? (Score:5, Insightful)

    by bengoerz ( 581218 ) on Tuesday August 30, 2016 @07:01PM (#52800017)
    This user's entire submission history consists of 2 stories about Java within an hour of each other. Smells like shill.
    • After seeing how bad "Corporate Social Media Consultants" are on Reddit and nearly everywhere else I don't doubt it.

      If it's anything like the Fortune 500 companies I've worked at it's a committee of 40+ year olds* that are also 10-15 years behind the wave of everything. "Hey I heard of this company called Slashdot. It's for techny people. I's really easy to make an account. Lets make something up, they'll never notice".

      Based on how and when it was posted they're all at home right now patting themselves on t

  • by Anonymous Coward

    No more permgen!

  • The signiture feature is lamdbas for easier functional programming. Other goodies are nice but the lamdbas are the best new feature.

    Did I say it first to get the 5?

  • Decimal Numbers? (Score:4, Interesting)

    by CastrTroy ( 595695 ) on Tuesday August 30, 2016 @07:05PM (#52800043)

    Have they added support for decimal numbers yet? .Net has had support for decimal numbers for quite a few years now (At least since 2003 [microsoft.com]). It comes in really handy for doing applications dealing with money, which quite a lot of applications deal with. Floats and doubles don't work well with currency values as they can't hold exact decimal values for many commonly encountered numbers. There are work arounds like using integers to store the number of cents, and using classes like BigDecimal, but both of those have quite a few drawbacks.

    • Re:Decimal Numbers? (Score:4, Informative)

      by ADRA ( 37398 ) on Tuesday August 30, 2016 @07:14PM (#52800081)

      Looks like you're looking for "JSR 354: Money and Currency API" Its an API, not language primitive. Its not surprising given that decimal numbers are essentially strings for all tense and purposes with some convenience math features wrapped around them. Outside of said library there are probably dozens of math libs that you could work with for your fixed size precision needs.

    • Store your values as total cents instead of fractional dollars? The base unit is cents, not dollars, anyway. (In the US) If you're storing fractional numbers for anything that requires a specific value you're doing it wrong.
      • How do this work when calculating tax rates? Taxes can be at a fraction of a percent. Quebec for instance has 9.975 % sales tax. If you store your amounts as integers in total cents, what value do you multiply by to get the tax? If you have a proper decimal data type, you can store store the exact values. .Net has no problem storing 9.975, 0.09975 or any number up to 28 significant digits without worrying about weird floating point anomalies.

        • You round down the cents and transfer the fraction into your back account. I knew three guys who did that and got away with it.
        • A rate and an amount are quite distinct things.

          For your example, you'd multiply by 9975 and then divide by 10000. Or maybe 100000. Fuck it, QA will catch it.

          Yeah, I've seen old code dotted around with magic numbers like that.

      • by arth1 ( 260657 )

        The base unit is cents, not dollars, anyway. (In the US)

        No, that would be mill, which is defined by congress as the "lowest money of account, of which 1000 shall be equal to the federal dollar".
        Except for property taxes and gasoline prices, it's generally rounded to the nearest cent, though.

    • Re:Decimal Numbers? (Score:5, Informative)

      by Gerald Butler ( 3528265 ) on Tuesday August 30, 2016 @07:50PM (#52800301)

      BigDecimal is not a work-around. It is the exact solution to the problem.

      • Re:Decimal Numbers? (Score:5, Informative)

        by CastrTroy ( 595695 ) on Tuesday August 30, 2016 @08:02PM (#52800341)
        It works, but it makes your code kludgy. Without operator overloading, you have to do fun things like a = b.add(c) just to numbers together. Just hope you never have to do a complex mathematical operation. It's much harder to see what's going on when you can't use things like BigDecimal. Even a simple comparison just gets ugly.

        if ( bigDecimal1.compareTo(bigDecimal2) < 0){
        ...
        }

      • BigDecimal is not a work-around. It is the exact solution to the problem.

        All mechanical representations of numbers lead to inaccuracies.

        Computer scientists using binary-based representations realize this and design their algorithms to minimize the errors.

        Accountants just define any inaccurate decimal-based results as "correct".

        • by Dog-Cow ( 21281 )

          All mechanical representations of numbers lead to inaccuracies.

          That statement is false. While decimal number types may have limited precision, they are, in fact, accurate.

  • Comment removed (Score:5, Informative)

    by account_deleted ( 4530225 ) on Tuesday August 30, 2016 @07:05PM (#52800047)
    Comment removed based on user account deletion
    • Re: (Score:2, Interesting)

      Christ! That is modern Java? It looks like absolute shit. .orElseThrow() -> new FMLException()? WTF? Why is the return value String and you look like you are stringing together flatMap? WTF is a flatMap? Are you returning a bunch of concatenated strings? How do you get the data? You load the String into a flatMap? Jesus.
      • Re: (Score:3, Interesting)

        by Ksevio ( 865461 )
        But wait! It gets worse. You can't call these long function names directly on a data structure, you have to first get a stream which then can take map functions and then you have to convert it back to the data structure when you're done. Coming from Python it's just painful to see how long and ugly the code gets
      • by The Evil Atheist ( 2484676 ) on Tuesday August 30, 2016 @11:54PM (#52801069)
        How about... read the fucking documentation? I'm a C++ guy and always lamented the fact that Java did not have an algorithms equivalent. Java 8 streams + lambdas are almost there and you can achieve complex things without nested loops.

        Stop conflating your unfamiliarity with it being shit. It took me, a C++ guy, a day of getting used to it. If you can't wrap your head around that, you shouldn't be programming. It's easy stuff.
      • by abies ( 607076 ) on Wednesday August 31, 2016 @02:55AM (#52801319)

        Yes, it looks like garbage, this is why some people are switching to java dialects (still fully compatible with all libraries and java APIs both directions, but considerably shorter). My favorite, xtend, would have

        def getLastFour(Optional employee) {
            employee.flatMap(primaryAddress) .flatMap(zipCode) .flatMap(lastFour) .orElseThrow[new FMLException("Missing data")];
        }

        or, without Optionals and exceptions, old school, embrace nulls

        def getLastFour(Employee employee) {
            employee?.primaryAddress?.zipCode?.lastFour
        }

        You can get similarly short code in groovy, scala, koitlin and whatever else. Java strength lies in ecosystem (frameworks, interoperability, portability etc), not because of language syntax.

        Said that, there is a lot of overdesign and monstrosities in popular frameworks as well, but there you have a choice of using something more lightweight.

    • by AuMatar ( 183847 ) on Tuesday August 30, 2016 @11:28PM (#52801033)

      If you think that mess of streams is clearer than a for loop would be, you're on crack. It's incomprehensible.

      • Don't mistake unfamiliarity with incomprehensible. It's better than for loops because the method names tells you the intention and the guarantees of that operation.
        • by AuMatar ( 183847 )

          No. No it isn't. THe method names would tell me just the same used inside a forloop. You have added no value, while making it harder to debug and harder to read. If you use streams you're a shitty programmer.

  • by Anonymous Coward on Tuesday August 30, 2016 @07:18PM (#52800101)

    Java is so [Garbage Collecting] much fas [Garbage Collecting]ter then C becu [Garbage Collecting]se of its [Garbage Collecting] GC algorithms.

    If y [Garbage Collecting] o [Garbage Collecting] u want raw [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] speed, you h [Garbage Collecting] ave to prog [Garbage Collecting]ram in Java, not C or [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] ASSembler.

    With only 16Gb of [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] RAM, I can compile a simple h [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] ello W [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] orld program, and it only takes 15 [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] to run!

    Windows should be redone in [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] [Garbage Collecting] ..out of memory, stack trace, garbage here:

    • Haven't had mod points for years (no idea why) but if I did, you'd get them all. Thanks for making me truly laugh out loud.

    • That’s funny, although unless you’re bumping up against your VM memory limit, it’s not such a problem. When you DO approach your memory limit, performance drops to a crawl. In the 32-bit days, I hated the fact that my colleagues in AI developed in Java instead of C++ for programs that worked on really huge datasets just because of this issue. The programs would be frozen on GC for as much time as they did computation. That doesn’t mean I hate Java; I really like it, but this was

  • by mattyj ( 18900 ) on Tuesday August 30, 2016 @07:21PM (#52800121)

    ... is how easy it is to remove.

  • Yea, that's about it for Java.... Well that and that cool "Memory leaks are a thing of the past" idea can be nice... Yea, I know, Java still leaks memory from time to time... But they at least tried to rid us of all that malloc and free complications..

  • .... is a bit shit. It's better than the old one but not as easy to used as the Joda Time library it was based off of.

  • Marketing (Score:4, Interesting)

    by alantus ( 882150 ) on Tuesday August 30, 2016 @07:28PM (#52800161)

    The best thing Java ever had is good marketing, that's it.

  • security fixes! (Score:3, Informative)

    by schklerg ( 1130369 ) on Tuesday August 30, 2016 @07:36PM (#52800211)
    I mean, it's awesome that security fixes are now separate from feature changes and that they are so easy to install and track! I love being able to so easily manage a single runtime with no compatibility issues on my clients now too. Oracle has saved java!
  • by watermark ( 913726 ) on Tuesday August 30, 2016 @07:42PM (#52800251)

    They've finally done it! Java is now indisputably the best programming language available! They finally fixed all of the bugs! It's the most secure language available! Best of all, Oracle opened source the whole JVM under a copy-left license! Java 8 is indeed a game changer! These are exciting times indeed!

  • I love the fact when a non sanctioned language generates a lawsuit on demand when interacting with the APIs

  • The best thing about Java 8 is that you only need 73 years' experience with it to land a great job.

  • The fact that I still don't need to have Java installed anywhere to enjoy the Weird, Wild Web.
    • That's a good thing, because client side Java from the browser is basically dead. Google Chrome doesn't even support the Java plugin anymore, and neither does Microsoft Edge. Firefox and Internet Explorer still support it, but disable the plugin as a security risk if you're not updating it to the latest release on a monthly basis.

      They've basically made supporting the operation of Java applets in a browser impossible to support, which is great unless you're still stuck supporting them.

  • With better OOP Java wouldn't need stinkin' lambdas. Lambda's just give spaghetti coders more ways to write cryptic "cutesy" code. Flexible methods can usually do that same thing.

    For example, if Java blurred the distinction between instances and classes, then one could attach an OnClick() method directly to a UI button object instead of pushing it to a listener doodad, which is silly and unnatural.

    If the guts of a button object want to register the button's method(s) in a listener object via instantiantion

    • by MouseR ( 3264 )

      In Obj-C, Code Blocks are an awesome way to un-spaghetti-fy source code by doing away with protocols.

      Translate that to Java:

      In Java, Lambdas are an awesome way to un-spaghetti-fy source code by doing away with interfaces.

      In Obj-C, we've been able to clean up and streamline our code a lot using completion blocks. But as with any technique, you can be an idiot using it. It's all about proper usage. Knowing when to eat your spag and when to eat the meat balls.

      Disclaimer: I work for Oracle, using native iOS too

    • by Alomex ( 148003 )

      With better OOP Java wouldn't need stinkin' lambdas. Lambda's just give spaghetti coders more ways to write cryptic "cutesy" code. Flexible methods can usually do that same thing.

      I actually like lambdas but I think they are highly overrated. They have become trendy and furthermore it has become trending to claim you could write an awesome programs if only you had lambdas. In most cases what they mean by this is simply "if the language supports functions as first class objects" and all that lambda provide beyond that are anonymous functions.

  • "Its unique selling point is the attention paid to every aspect of the programming language". Other languages do this so hardly unique.
  • by QRDeNameland ( 873957 ) on Tuesday August 30, 2016 @08:57PM (#52800555)
    ...the Ask toolbar. Who doesn't love that?
  • by ashshy ( 40594 )

    "...the community graciously accepted it, seeing it as a huge step toward making Java better. Its unique selling point is the attention paid to every aspect of the programming language..."

    Java 8 also turns your garbage into gold, serves you pancakes in the morning, and will never give you up. This is ad copy.

  • That I don't have to install it, use it or ever have to deal with it again. That is by far it's best feature.

  • It has sucked so much lately, with so many security issues, that anything that requires Java has been replaced with something more modern. Just say no to Java!

  • by OrangeTide ( 124937 ) on Tuesday August 30, 2016 @11:40PM (#52801055) Homepage Journal

    That it is still controlled by Oracle.

  • My favorite Java 8 feature is that wonderful Ask Toolbar! You like type words into it and it finds stuff that actually has those words! It's like a personal librarian ... well, with ads glued to her ass.

  • I tend to chase the latest trending technologies...they pay more and are more fun. Also, anyone who has been following Oracle lately knows they are circling the drain. There is a huge code base written in Java, but i get the feeling it'll be the next Cobol. Whether that is a good thing or a bad thing will depend on how the market plays out.
  • Streams were the best surprise when I had to work with Java a couple of months ago after years of other languages. They are good but it's still the worst language with that kind of functionality. I could write in 5 lines what would have taken me a page of code, but it's still a one liner in Ruby or Python. Too much boilerplate, as usual for Java. The problem is that it can't be helped given the nature of the language. Faulty original design.

  • Java8 has a much more streamlined uninstall routine.

  • Some good, some bad (Score:4, Interesting)

    by bradley13 ( 1118935 ) on Wednesday August 31, 2016 @04:32AM (#52801531) Homepage

    Lambda expressions: A total brainfart. Lambda notation has no place in an imperative language; mixing paradigms is confusing for the vast majority of Java programmers. Most people just use lambdas as "magic syntax" to simplify things like declaring event handlers. The ugly syntax is a problem, but lambdas are the wrong solution.

    Date/time APIs: Yes, finally!

    JavaFX: Oddly, the best feature of Java 8 isn't even mentioned in TFA. JavaFX is immensely better than Swing, in every possible way: it looks better, it works more reliably, and it's easier to program.

    And the worst feature of Java 8 is the unnecessary complexity throughout the new features. Two examples:

    - The Optional class. Instead of checking directly for a null result, you have to unpack every result out of this idiotic wrapper.

    - Factory methods instead of constructors. Java is supposed to be an object-oriented language. In OO, you create an instance of a class with a constructor, which has the name of the class. But not in Java 8, no, instead you use a whole stable of factory methods with all sorts of weird names. Look at the new date/time classes for an example.

Every nonzero finite dimensional inner product space has an orthonormal basis. It makes sense, when you don't think about it.

Working...