• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Java 8: What are the good features you will advise to use?

Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java 8 seems a big deal. What features do you think are most useful in our daily work?

I also see a chapter about Scala. What's this chapter about. It seems Java 8 borrows something from Scala, for example the Option object.
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Qunfeng,

Java 8 is a major deal. It is the largest update to the language in 10years :-)

To answer your first question:

Why is Java 8 changing again? Because of two trends that could not be ignored:

1) The increasing need to exploit the power of multi-core processors in a programmer-friendly way
2) The increasing demand of processing collections of data with database-like operations (e.g. filter, map, grouping)

Neither of these trends is effectively supported by the traditional object-oriented imperative approach centred around mutating objects, and applying iterators. However, they are easily supported using ideas from functional programming, which Java 8 has taken inspiration from.

This new version of Java incorporate features popular in many other programming languages to respond to these two trends: the ability to represent a piece of behaviour in a concise form (called lambda expressions) and database-like operations on collections (called the new Streams API). In addition, it brings other popular ideas that will impact how you write code on a day to day: default methods (implementation code inside interfaces), the class Optional (an alternative to the null reference), the class CompletableFuture (composable asynchronous programming) and a new Date and Time API designed with immutability in mind.

To answer your second question:

Java 8's design is inspired from Scala in many ways. However, Scala provides a richer set of features around the new features introduced in Java 8. For example, anonymous functions in Scala (the equivalent of lambdas in Java 8) don't have write restrictions on local variables. Traits in Scala (the equivalent of interfaces with default methods in Java 8) can also be composed at object-instantiation time.

We believe you may find interesting to compare the approach taken by Java 8 and see its limitations. This is what this chapter aims to shed light on. It doesn't aim to teach you Scala.
It will give me the powers of the gods. Not bad for a tiny ad:
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic