The Artima Developer Community
Sponsored Link

Weblogs Forum
The Positive Legacy of C++ and Java

210 replies on 15 pages. Most recent reply: May 9, 2009 2:50 AM by Daesung Park

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 210 replies on 15 pages [ « | 1 2 3 4 5 6 7 ... 15  | » ]
Krisztian Sinka

Posts: 30
Nickname: skrisz
Registered: Mar, 2009

Re: The Positive Legacy of C++ and Java Posted: Mar 16, 2009 12:50 PM
Reply to this message Reply
Advertisement
“Operator overloading is too complicated”.

From language design point of view it may be an important question (do not know, I am not a language designer).

However as an full time C++ developer I can live with it happily. Moreover I pretty like how the objects can work with the streams using shift operator overloading (“<<” or “>>”). At certain points this can make the code more reliable, and for me, more readable: compared to “printf”s and others.

James Iry

Posts: 85
Nickname: jiry
Registered: Nov, 2007

Operator Overloading Ad Absurdum Posted: Mar 16, 2009 12:50 PM
Reply to this message Reply
http://www.reddit.com/r/programming/comments/852i4/operator_overloading_ad_absurdum/

Jeff Salter

Posts: 3
Nickname: jeffs09
Registered: Mar, 2009

Re: The Positive Legacy of C++ and Java Posted: Mar 16, 2009 1:13 PM
Reply to this message Reply
Java strengths:

Team development
Maintainability
Extensibility
Cross platform
Hot Spot
Huge standard library
JVM
Commerical and open source implementations
selection of frameworks
huge ecosystem
huge developer base
fairly easy to learn (after understanding OOD)
garbage collection

All of these things came because of, not in spite of, the design decisions in Java.

Stuff like Java's heavy, almost overly forceful, object orientation, where encapsulation, inheritiance, polymorphism, and design by contract, are heavily enabled have caused Java to be great for team development, maintainability, and extensibility.

Things like not having operator overloading, mulitple inheritance, or closures/FP, have helped make Java more maintainable, especially in team development.

And all of those things are extremely important, indeed required, for any large project that has to be written/maintained/extended by many people and that lasts over time.

The other stuff (operator overloading, closures, multiple inheritance, etc), is great for theory, individual programmer desires, and small development. But can make code incomprehensible, of not used with great care, for other programmers.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: The Positive Legacy of C++ and Java Posted: Mar 16, 2009 1:34 PM
Reply to this message Reply
> I think Java code can be easy to follow in the sense of
> all the details of how the code works, while at the same
> time harder to follow in the sense of what the programmers
> higher level intent was for that code. This may be the
> right tradeoff for enterprises, but I see it as a
> tradeoff. Because Java's syntax is more rigid, when you
> look at Java code you can figure out what's a method call
> and what's a field access, etc. But you also get a lot of
> boilerplate and verbosity that can hide the intent of the
> programmer.

Please understand that I don't think Java is perfect. Not by a long shot. What I am trying to say is there was an effort to address team development. In some ways it succeeded but in others it has failed miserably.

In some areas, I would have gone even further. I would enforce formatting rules as part of the language. I know a lot of people will scoff at that but the reality is that formatting is either really bad or roughly as good as any other non-horrible formatting. There's no obvious correct choice because it doesn't really matter.

On the other hand, I think some people who got involved with the path of Java thought about these restrictions as protecting people from themselves instead of protecting them from each other. That is, people started thinking java was popular because the developers using it are stupid. So features that would be perfectly clear and not create team development problems are excluded because there's this idea the Java developers can't be bothered from eating ants off of a stick long enough to understand something like closures.

> I suspect the readability of Java's rigid syntax was
> indeed part of its success, but the verbosity that goes
> along with that syntax predictability is now one of the
> main complaints people have about it compared to other
> languages.

But that's not new. It was always the main complaints about Java. In fact, when I first was introduced to Java I was extremely annoyed by the lack of my favorite C++ features. For example, I was appalled that there was no way to create default values for method parameters. But this is really what I am getting at. As I learned more, I realized that I could still accomplish what I needed with a little more code without having to try to keep an encyclopedia worth of language rules in my head.

I've even found that the limited syntax of Java led me to superior solutions (long-term) to problems I would have solved using built-in syntax in C++ but that's a different discussion.

Noel Grandin

Posts: 3
Nickname: grandinj
Registered: Sep, 2005

Re: The Positive Legacy of C++ and Java Posted: Mar 16, 2009 2:27 PM
Reply to this message Reply
(1) Operator overloading is one of those features that is hardly ever useful. For some math processing, it's kindof nice, but how much of the world's code using anything more sophisticated that a float.

(2) primitives were the right choice - getting optimisations and your type system correct in the presence of value objects (i.e. they don't have reference identity) is something we only started to get a handle on recently

(3) generics is hard. C# programmers whinge just as much about the choices that Microsoft made. Scala makes a lot of noise but what they forget is that their language is only possible because Java went out there and tried it, and they got to learn from all the mistakes.

(4) C++ templates are nothing more than glorified macros. They're a disaster to use and incredibly complicated to program. They only started adding real typing to them last year.

(5) Most of the other "hot" languages like Ruby, Scala are never going to hit mainstream, because they're all biased to heavily in favour of writing code, instead of reading code.
Java got this balance correct - Java might be verbose and lack lots of "cool" features, but it's really easy to figure out what some random code is doing.

Dan Sickles

Posts: 9
Nickname: dsickles
Registered: Mar, 2007

Re: The Positive Legacy of C++ and Java Posted: Mar 16, 2009 2:46 PM
Reply to this message Reply
"Scala makes a lot of noise but what they forget is that their language is only possible because Java went out there and tried it, and they got to learn from all the mistakes"

If Java were more able to learn from it's own mistakes, I might not be using Scala. Love the JVM. Java, not so much.

Bruce's point about the JVM being the most valuable part of the Java ecosystem rings true for me. The langauge and all the frameworks will live on but every day the percentage of new bytecode generated by javac will diminish, whether any of the other JVM languages "hit the mainstream" or not.

Nemanja Trifunovic

Posts: 172
Nickname: ntrif
Registered: Jun, 2004

Re: The Positive Legacy of C++ and Java Posted: Mar 16, 2009 3:11 PM
Reply to this message Reply
I am not going to comment on anybody's opinions, but this:

> (4) C++ templates are nothing more than glorified macros.

is simply wrong. C++ templates are a compile-time feature that have nothing to do with macros which are a pre-processor feature.

Jeff Salter

Posts: 3
Nickname: jeffs09
Registered: Mar, 2009

Re: The Positive Legacy of C++ and Java Posted: Mar 16, 2009 5:12 PM
Reply to this message Reply
"Java might be verbose and lack lots of "cool" features, but it's really easy to figure out what some random code is doing."

Bingo.

Such a huge part of professional software development is reading, understanding, maintaining, and extending, someone else's code. Java really helps with that.

I hate to say it, but in some ways code verbosity is good. Verbose code is rarely hard to understand.

Compact, concise code, that so called modern or "hot" languages (like Ruby, Python, Scala, Haskell, et al), with their modern "hot", or "cool" features (like closures/FP, operator overloading, etc) are supposedly good at, can be, while sometimes easy to write and can cause programmers to cream their pants because of all the oozing coolness and power, can be a real bitch to read and understand and maintain.

When I see code examples of so called modern hot languages showing some hot language feature (like closures), it can sometimes take a while before I can tell precisely what the code is doing.

I know there is a learning curve, and that once you get used to doing something, it becomes easier. But one good thing about Java is that the curve was always short, as was the "getting used to it" time.

The only real difficulty I've had with Java (the language - don't get me started with frameworks and EE development) was good object oriented design. I picked up Java originally when I had only rudimentary understanding of object oriented programming and design. But now all that is pretty much second nature, and Java is mostly pretty easy.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: The Positive Legacy of C++ and Java Posted: Mar 16, 2009 5:39 PM
Reply to this message Reply
> I know there is a learning curve, and that once you get
> used to doing something, it becomes easier. But one good
> thing about Java is that the curve was always short, as
> was the "getting used to it" time.

It's funny that you use 'was always short' instead of 'is always short'. I say that because I think Java lost a lot of it's main benefit when generics were added.

I recently saw compile error posted on the Java forums where it looked like it was a compiler bug but no one was really sure. Everyone basically threw up their hands and gave up. It used to be that you'd have people passionately arguing about whether the compiler was right and trying to prove it based on the spec. Now no one even cares to try to explain.

So I actually think Java is dying and generics is what did it in. But it has nothing to do with the lack of operator overloading or verbosity. It has to do with unwarranted complexity.

Jeff Salter

Posts: 3
Nickname: jeffs09
Registered: Mar, 2009

Re: The Positive Legacy of C++ and Java Posted: Mar 16, 2009 7:34 PM
Reply to this message Reply
"So I actually think Java is dying and generics is what did it in. But it has nothing to do with the lack of operator overloading or verbosity. It has to do with unwarranted complexity."

I wouldn't say it's dying, per say, but you make a good point: Adding language features can have negative consequences.

paulo faria

Posts: 14
Nickname: i30817
Registered: Jun, 2007

Re: The Positive Legacy of C++ and Java Posted: Mar 16, 2009 7:58 PM
Reply to this message Reply
I would trust operator overloading applied to selected STANDARD LANGUAGE classes, and that it just works, and doesn't throw funky runtime exceptions.

http://cafe.elharo.com/blogroll/operator-overloading/

Bill Venners

Posts: 2248
Nickname: bv
Registered: Jan, 2002

Re: The Positive Legacy of C++ and Java Posted: Mar 16, 2009 8:50 PM
Reply to this message Reply
> (5) Most of the other "hot" languages like Ruby, Scala are
> never going to hit mainstream, because they're all biased
> to heavily in favour of writing code, instead of reading
> code.
> Java got this balance correct - Java might be verbose and
> lack lots of "cool" features, but it's really easy to
> figure out what some random code is doing.
>
I don't think this is the best conclusion to make about this. Ruby and Scala's more flexible syntax basically gives more power to the library designer to decide what the client code will look like compared to Java. When I design a library I care very much about the readability of client code. I also care about writability, but I think readability is more important than writability, so sometimes if I can't figure out a way around it I'll favor readability at the expense of writability.

What can happen, though, is a library designer can favor conciseness to an extent that to some programmers comes at the expense of readability. I've seen people use operators more in Scala libraries than I might have used, which is an example of this. But it is subjective. So that's why I think the conclusion to make is not that Ruby and Scala's flexible syntax favors writability over readability. The conclusion I make is that the flexible syntax gives libraries designers more power, and sometimes that power will be used well and other times not as well. The difference with Java is that designers have less flexibility to do a bad job, but at the same time less flexibility to do a good job.

Kay Schluehr

Posts: 302
Nickname: schluehk
Registered: Jan, 2005

Re: The Positive Legacy of C++ and Java Posted: Mar 17, 2009 12:30 AM
Reply to this message Reply
The idea of creating idiot friendly languages has fortunately been garbage collected and replaced by that of being IDE friendly. This means that code shall provide enough hints to enable reliable analysis. Those hints can become fewer and fewer over time as demonstrated lately by C# 3 which brought local type inference into the mainstream ( or shall I say "enterprise" instead? )

I don't want to comment on C++ because each time I try an inner Dijkstra comes up and is right on that matter.

Cedric Beust

Posts: 140
Nickname: cbeust
Registered: Feb, 2004

Re: The Positive Legacy of C++ and Java Posted: Mar 17, 2009 2:29 AM
Reply to this message Reply
> Seeing "d = ( a + b ) / c;" could mean an arbitrarily
> complex and deep code path in any language with operator
> overloading. In Java you know "there's nothing funny
> going on on this line", just normal arithmetic.

I don't really buy into this fear.

When you see code like this:

void foo(Person p) {
p.lookUp();
}

You know that it's not necessarily the method lookUp() on the Person class that gets invoked. It's pretty easy to extend this line of thinking to operator overloading.

Despite this, I still think that not including operator overloading in Java was a good idea, but for different reasons.

--
Cedric

Kirk Pepperdine

Posts: 5
Nickname: kcpeppe
Registered: Jun, 2003

Re: The Positive Legacy of C++ and Java Posted: Mar 17, 2009 4:12 AM
Reply to this message Reply
> So I actually think Java is dying and generics is what did
> it in. But it has nothing to do with the lack of operator
> overloading or verbosity. It has to do with unwarranted
> complexity.

I was with you up until the statement. Java isn't dying as much as we are continuing to search for better ways of getting things done. The recent explosion in languages reflects a maturity in Java. People are trying to get an edge by introducing languages that fit their niche. But at the end of the day they stand on the shoulders of Java.

The powerful abstraction is the virtual machine. A huge win with the VM is that it provided a standard deployment environment that allowed people to develop large standard components that they could then mass market. JEE is also a standard deployment environment that not matter what you think of it, offers huge advances in a number of different ways. I would almost argue that off-shore and distributed development teams are possible because of the JEE (the argument is to simplistic and requires more words than I have time for at the moment). C++ had none of that. More over, these standard deployment environments reduced the number of mistakes that off-shore teams could make. The most serious problem that would take down a system is a Java memory leak. Those are easy to find especially when you compare this to tracking down a C++ pointer problem that doesn't SEGV on you.

Point is, there is still a lot of life in Java, it's just not so exciting as it was.

Flat View: This topic has 210 replies on 15 pages [ « | 1  2  3  4  5  6  7 | » ]
Topic: Should I use a netbook as my main development platform? Previous Topic   Next Topic Topic: Social Newsfeeds: The Next Big Thing


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us