• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question to Cay:Language features that are ground breaking

 
Ranch Hand
Posts: 238
1
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Cay,

Advancements in language features happens for a variety of reasons ,to cater to the complex enterprise dynamics, to improve developer productivity ,to maintain the java Eco system in general
As far as platform improvement goes,what in your opinion especially after the slow phase of improvement between Java6 and Java8 is a ground breaking advancements between Java5 and Java8?

There was a good reason why java 5-Tiger came out with futures like , Annotations,Generics,Autoboxing... and made a such
a impact amongst the developer community.

With features like functional programming and Optionals,Nashorn,unasigned Integer Arithmetic,Repeating annotations,New Date and Time API
would java 8 become yet another milestone in this


Thanks
Sundar
 
author
Posts: 284
35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree that Java 5 was huge. Generics is very important because the compiler can check correctness, and programmers are freed from tedious casts. And annotations make it possible to write nifty tools, particularly in Java EE.

I think Java 8 is another huge step, and in one aspect it could be more important. Generics don't really let you express anything new that you couldn't do before. They add safety, not expressiveness. But lambda expressions let you express ideas that are very difficult to do without.

Consider a typical pipeline of processing time-consuming operations. You want to do them in a separate thread, first one, and then when it has concluded, the next, and so on. With lambdas, you can implement a library so that programmers can write something like this:

doWork(() -> firstStep).andThen(result1 -> secondStep).andThen(result2 -> thirdStep).andThen(result3 -> consume);

Now consider that each step might need an error handler. That can just be another lambda.

I've written code like that with anonymous inner classes, and it was unbelievably painful and confusing. But with lambdas it is pretty good.

So, I think that over the next several years, many people will find all sorts of interesting uses of lambdas, perhaps comparable to how people have found all sorts of interesting uses of annotations. I think that is the killer feature of Java 8.

Cheers,

Cay
 
meenakshi sundar
Ranch Hand
Posts: 238
1
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well Said Cay , But there are still are lot of skepticism around Java 8 specially with the Closure
Though this feature has come bit late ,Its like saying"better late than never" ,Do you think this was a reactive
measure to address the concern of the community that Java is lacking the functional features of Scala?

Thanks
Sundar
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

meenakshi sundar wrote:. . . With features like functional programming and Optionals,Nashorn,unasigned Integer Arithmetic,Repeating annotations,New Date and Time API . . .

I presume “unasigned” is a misspelling of unsigned not unassigned.
The Optional can be very useful; Urma Fusco and Mycroft have a whole chapter in their book about how to use Optionals to avoid nulls. Since Tony Hoare describes the invention of nulls as his 64 billion dollar mistake, getting rid of nulls is a really useful feature.
If you have suffered from that affliction the Calendar class, you will be only too pleased to see the back of it
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

meenakshi sundar wrote:Advancements in language features happens for a variety of reasons ,to cater to the complex enterprise dynamics, to improve developer productivity ,to maintain the java Eco system in general
As far as platform improvement goes,what in your opinion especially after the slow phase of improvement between Java6 and Java8 is a ground breaking advancements between Java5 and Java8?


Well, we got the diamond operator with v7. And java.nio.

I think the reason that these things tend to go in spurts is that there's a fair bit of prep-work required for major changes that's done by "backroom boys". As I recall, 1.4 (which I remember running for a couple of years) was a major release, not because it changed things dramatically for us programmers, but because Java's entire memory model was virtually re-written from the ground up, turning Java from an interesting C++-like variant to a language that could compete on almost equal terms performance-wise.

I also seem to remember that lambdas were originally supposed to be in v7, but were postponed.

Winston
 
meenakshi sundar
Ranch Hand
Posts: 238
1
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If you have suffered from that affliction the Calendar class, you will be only too pleased to see the back of it



Of course ,those were like pretty bad—probably the worst APIs in the JDK ,they were buggy, mutable, cumbersome, many bugs, and they tend not to be thread safe.

diamond operator with v7. And java.nio.



Those were really nice features that came along ,But this is after a long time, a bunch of new addition have been made in Java 8 ,may be it came as bit late ,but its a good thing for Java.









 
meenakshi sundar
Ranch Hand
Posts: 238
1
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mixin is another good feature that has been introduced with 8
But the apprehension is , it can be misused ,since with Mixin the subtle characteristic difference between an Abstract Class and Interface can be misunderstood and misused.

What is your take on that?
 
Saloon Keeper
Posts: 15489
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Java doesn't have mixins.
 
meenakshi sundar
Ranch Hand
Posts: 238
1
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I stand corrected Stephan, .Yes not directly Mixins but through default methods for interfaces....

 
Stephan van Hulst
Saloon Keeper
Posts: 15489
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The distinction between abstract classes and interfaces has indeed become a lot smaller with the introduction of default methods. You should use default methods where possible in preference to abstract classes.

Abstract classes still have a very important role, because they can provide partial implementations that require access to state. Interfaces can't have state.
 
Cay Horstmann
author
Posts: 284
35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

meenakshi sundar wrote:Mixin is another good feature that has been introduced with 8
But the apprehension is , it can be misused ,since with Mixin the subtle characteristic difference between an Abstract Class and Interface can be misunderstood and misused.

What is your take on that?



I am really bad at these abstract discussions. Could you give me an example where you see the potential of abuse? I mean, in the context of Java, where it would be a bad idea to use an interface with default methods instead of an abstract class?
 
meenakshi sundar
Ranch Hand
Posts: 238
1
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am saying there could be a chance of it if misunderstood.Please correct me ,if my contextualization of this new feature is wrong

With Abstract class you can define constructor and they are more structured and can have a state associated with them,While in contrary, default method can be implemented only in the terms of invoking other interface methods,
With no reference to a particular implementation's state.Hence, both can be used for different purposes and choosing between two really depends on the scenario and the requirement and more importantly the ability of the coder.
 
Cay Horstmann
author
Posts: 284
35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are putting the finger right on it. If you need state, use an abstract class. If you don't, use an interface. I think that's a straightforward rule that coders of all abilities can apply.

As an example, on one of my projects, I have an HTML report, a text report, and a JSON report. They are all reports. Should Report be a class or an interface?

Before Java 8, this was a painful decision. We want to prefer interfaces over abstract classes. And it would have worked since the classes share no data. But it was a "fat" interface with quite a few convenience methods. I ended up using an abstract class so that I could implement some in terms of others.

When I updated the project to Java 8, I changed to an interface with default methods.

So, actually, if anything, Java 8 has made the decision process simpler.

Cheers,

Cay
 
meenakshi sundar
Ranch Hand
Posts: 238
1
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Cay for that clarification,This is related to Java 8 being a functional language
What would be your advice for some one who are starting to think why not look into Scala instead of Java 8 ,with my limited understanding on Scala,it being a pure functional langue
With lot of rich features ,you can literally write few lines of code that you can do with java with lot of verbosity and big chunk of code.

But to my knowledge on the flip side ,it is way too difficult language to master and takes lot of time ,where as Java 8 with its elegance and relatively easy to learn ,though some time very verbose.
is learning Scala would be complementary or contradictory,i would be better off sticking with Java 8?
 
Cay Horstmann
author
Posts: 284
35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a big fan of Scala. Yes, it is more complex, but you can also do more fun and elegant things. When I have a greenfield project with a few contributors who know Scala or can pick it up quickly, I like using Scala. But that doesn't happen all the time. For example, right now I am working with some graduate students on a project for CS education. We use the Play framework, and we could be using Scala. But they also have to learn a bunch of other technology, so we are doing it in Java.

I think it is a good idea to spend some time learning basic Scala. The functional part is much more elegant than in Java, because they didn't have to find a way to make it compatible with an existing language. And the OO part is interesting as well. You can get a free copy of the first chapters of Scala for the Impatient at https://www.lightbend.com/resources/e-book/scala-for-the-impatient.

Cheers,

Cay
 
meenakshi sundar
Ranch Hand
Posts: 238
1
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will give it a try and thanks for the link
The type signatures are way too intimidating
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Cay Horstmann wrote:I think it is a good idea to spend some time learning basic Scala.


I've heard several writers extolling the virtues of Scala; and I have to admit, I'm interested in trying it myself.

However, if it's so good, it does make me wonder why it still has such a tiny market share (not even in the top 20, according to TIOBE).

So, is it simply an academic toy, or do we need a JScala, or what?

Winston

(PS: I notice there is a JScala.org, but it says it produces JavaScript from Scala code, rather than running Scala in a JVM)
 
Stephan van Hulst
Saloon Keeper
Posts: 15489
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Probably for the same reason that PHP has such a big market share. People don't want elegant languages that come with a learning curve. They want things they think they understand.
 
Marshal
Posts: 8856
637
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:However, if it's so good, it does make me wonder why it still has such a tiny market share (not even in the top 20, according to TIOBE).


TIOBE Index wrote:The ratings are based on the number of skilled engineers world-wide, courses and third party vendors.
It is important to note that the TIOBE index is not about the best programming language or the language in which most lines of code have been written.

Quote partially could explain that, having in mind courses perspective.

While Scala is only around 10 years old, universities are quite stubborn about distributing such courses in universities as it is not an easy language, however, there are already Scala taught in advanced software engineering modules, I particularly talking about UK (it happened only couple of years ago in some of universities). I think such decisions where made to pick Scala only because of Java in most cases used to be a first introductory language for programming discipline students, and since in nowadays functional programming became a very popular phrase and at the same time Scala runs on JVM as well as has many other similarities with Java, decision were easier to make. And I think the question is just about the time when Scala will appear on TIOBE's top 20 - I think that will happen soon, in the next couple of years or even sooner (currently it is in 30th place in TIOBE).

And that quote maybe could explain why Python improved his positions a lot, in the 5th place, basically it appeared from nowhere, langauge is very old, but never been that popular till non profit organisation Python Software Foundation started its support, 2 years ago was nearly impossible to find any literature in bookstore. And now, most of US and UK universities for introductory programming course switching from Java to Python. Most top US universities already did that, in UK it is happening now.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Probably for the same reason that PHP has such a big market share. People don't want elegant languages that come with a learning curve. They want things they think they understand.


Yes, but presumably somebody - especially companies - buy (or buy into) these things. The reasons given for adopting Java, back in 2001/2, were: simplicity, security, and the biggie: no pointers. If you were trying to sell Scala, what would your "pitch" be?

I've actually spent a bit of time looking at the Wiki page for Scala, and it looks really neat; however, I suspect that the "flexible syntax" could land you in hot water if you're not careful.
But I really like the fact that it runs on a JVM - a huge plus, IMO.

Winston
 
Stephan van Hulst
Saloon Keeper
Posts: 15489
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been meaning to get into Scala for quite a while now, but for me the issue is that it has to be in my spare time, since I'd only be using it for hobby projects. There are plenty of other languages that I also still want to get into. The next one for me will probably be Ruby.

I'm also not done playing with Haskell yet :P
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Liutauras Vilda wrote:Quote partially could explain that, having in mind courses perspective.


Yes, I can see that. I "grew up" in an age when becoming a programmer didn't require a university degree (I've still only got a "bit" of a Master's even now; and that was after 20 years on the job without one), so you tended to pick up languages (in my case: PL/1, C, C++, and Java) on the job, or as a need arose.

Which makes me wonder if we're not in danger of "calcification" with all these new constraints on applicants?

Of the two best programmers I've ever met: one didn't have a degree at all; the other's was in Soil Science.

Winston
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:. . . I "grew up" in an age when becoming a programmer didn't require a university degree . . .

Of course in those days Universities didn't teach computing or computer sciences, which were at best a subtype of Maths or something like that.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Of course in those days Universities didn't teach computing or computer sciences, which were at best a subtype of Maths or something like that.


True, but aren't major breakthroughs in CS still driven by mathematicians? Braniac CS grads tend to go and work for companies like Pixar (or the CIA ); but it's mathematicians that still (in general) write the languages, databases and algortihms we all take for granted.

Both my parents agreed on one thing (and they didn't agree on much): That I could choose what subjects I wanted to study, but that they should be "pure".
Which is why I ended up being the only kid in a school of over 2,000 students to do Maths, French and History at 'A' Level. And when they tried to stick me in an Economics class instead of Maths - because it was easier for the teaching schedule - my dad drove 200 miles and lit such a bonfire under the headmaster that I was treated with kid gloves for about a month ... and put on the subjects that we'd agreed on.

I didn't really understand the principles at the time, but I've never forgotten that incident - and I still regard "pure" subjects (like Maths) as superior to "applied" ones (like CS).

Winston
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pure subjects create the knowledge and applied subjects earn the money.
 
reply
    Bookmark Topic Watch Topic
  • New Topic