The Artima Developer Community
Sponsored Link

Weblogs Forum
The Positive Legacy of C++ and Java

210 replies on 15 pages. Most recent reply: May 8, 2009 11:50 PM 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 ... 8 9 10 11 12 13 14 15 | » ]
John Wellbelove

Posts: 72
Nickname: garibaldi
Registered: Mar, 2008

Re: The Positive Legacy of C++ and Java Posted: Apr 2, 2009 1:17 AM
Reply to this message Reply
Advertisement
> Java is not dying, just some people like you can't be
> bothered to learn how to programme more effectively (e.g.
> learn patterns, design your own patterns/frameworks etc.),
> this sounds like slothful laziness, to busy professional
> developers like me! What chance do you stand with new
> langauges, if you can't be bother invest in Java wisdom.

I agree, and I think the same argument applies to C++ too.
Maybe the teaching of Java in universities is becoming as bad as C++.

I regularly contribute to a coding forum and often have to point out to some student looking for help with their C++ assignment that their code contains no C++ whatsoever.
The person setting the assignment usually seems to either have no knowledge of the Standard Template Library or bans its use altogether.
I can't imagine someone teaching Java and banning all of the standard library (or do they?).
Are Java students expected to write their own linked list and string classes?

Mark Thornton

Posts: 275
Nickname: mthornton
Registered: Oct, 2005

Re: The Positive Legacy of C++ and Java Posted: Apr 2, 2009 1:22 AM
Reply to this message Reply
> Are Java students expected to write their own linked list
> and string classes?

There is surely nothing wrong with an exercise to write an implementation of java.util.List or java.lang.CharSequence

John Wellbelove

Posts: 72
Nickname: garibaldi
Registered: Mar, 2008

Re: The Positive Legacy of C++ and Java Posted: Apr 2, 2009 2:25 AM
Reply to this message Reply
The problem I come across is that the students are being taught C++ as 'C with classes'. The result is that they churn out a whole load of C with only a nod to standard C++. The STL is usually not even mentioned until they have learned a whole load of bad 'C' habits first.
I think it would be better to introduce the standard containers, iterators & templates early on, and then when the concepts are understood, let them delve 'under the hood' and explore the code behind the interface.

I'm expect that java.util.List & java.lang.CharSequence are introduced before students are required to build their own.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: The Positive Legacy of C++ and Java Posted: Apr 2, 2009 11:15 AM
Reply to this message Reply
> WTF, these must be pretty arrogant, dim, or lazy, people
> if they can't accept and figure out Javac errors; this
> suggests poor understanding, and lack of study of the Java
> language specification, and lazziness for systematic
> trial-and-error, until understanding dawns. Amateurs!

Explain why line 4 fails to compile with the error message "cannot convert from List<capture#8-of ? extends Object> to List<? super String>" javac and eclipse. Is it a bug? If not, explain why this is not allowed based on what the JLS says. And no copying the definition of lub. I mean in plain terms.
      List<? extends String> x1 = null;
      List<? super String> x2 = null;
      x1 = true ? x1 : x1;
      x2 = true ? x2 : x2;

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: The Positive Legacy of C++ and Java Posted: Apr 2, 2009 11:52 AM
Reply to this message Reply
> The problem I come across is that the students are being
> taught C++ as 'C with classes'. The result is that they
> churn out a whole load of C with only a nod to standard
> C++. The STL is usually not even mentioned until they have
> learned a whole load of bad 'C' habits first.
> I think it would be better to introduce the standard
> containers, iterators & templates early on, and then when
> the concepts are understood, let them delve 'under the
> hood' and explore the code behind the interface.
>
> I'm expect that java.util.List & java.lang.CharSequence
> are introduced before students are required to build their
> own.

My experience is that most Java developers (and likely C++ developers) don't really understand OO concepts. Even developers that think they understand it don't really get it.

Most Java developers think Objects are a collection of properties (getters and setters) but don't access them dynamically. I've seen many interfaces that basically list the getters and setters of a single class.

One of the best things about the GoF design patterns book is that it demonstrates how to use dynamic dispatch effectively in languages like C++ and Java. Unfortunately it and other sets of 'patterns' are treated instead like a book of magic spells.

Fred Garvin

Posts: 52
Nickname: fredgarvin
Registered: Jan, 2008

Re: The Positive Legacy of C++ and Java Posted: Apr 3, 2009 12:51 AM
Reply to this message Reply
>> Explain why line 4 fails to compile with the error
>> message "cannot convert from List<capture#8-of ?
>> extends Object> to List<? super String>" javac and
>> eclipse. Is it a bug? If not, explain why this is not
>> allowed based on what the JLS says. And no copying the
>> definition of lub. I mean in plain terms.
>>
>> List<? extends String> x1 = null;
>> List<? super String> x2 = null;
>> x1 = true ? x1 : x1;
>> x2 = true ? x2 : x2;


Come on! I mean everyone knows this. Since x2 is parameterized contravariantly and the ternary takes the least upper bound, it's obvious that the type of the ternary expression will be either a straigth covariant object (? extends Object) or in your example the compound/capture type consisting of identical covariant object types. Neither is assignable to (? super String). Sheesh.

Hah. You're picking on what is probably Java's greatest blunder of all time -- use-site variance wrt type params. Yuck!

Most otherwise smart programmers don't understand the 'super' notation and contravariance wrt type params and so forth, because it is a pointy headed perversion. Why Sun went with wildcards is a complete mystery to me. They had much better options imo.

Krisztian Sinka

Posts: 30
Nickname: skrisz
Registered: Mar, 2009

Re: The Positive Legacy of C++ and Java Posted: Apr 3, 2009 1:35 AM
Reply to this message Reply
> My experience is that most Java developers (and likely C++
> developers) don't really understand OO concepts. Even
> developers that think they understand it don't really get
> it.

I had a colleague (he was not a programmer, but engineer) and told me that he did not understand the OO concepts at all. He asked what could be the OO in the following example:
Put together a screw and a nut.
I told that certainly this example is too simple to have some sense OO concept to use in it. Simple problems maybe more easy to solve in a functional way.

I think that real OO concepts and design patterns can be understood with practice. When someone creates something much bigger then a “Hello World” he could realize at some point things could be done more cleverly.

In my experience the teaching lacks this “deeper digging into” examples. Much of the students do not strive to get more knowledge as humans tend to be like electrons: the lower energy level the better.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: The Positive Legacy of C++ and Java Posted: Apr 3, 2009 6:28 AM
Reply to this message Reply
> Hah. You're picking on what is probably Java's greatest
> blunder of all time -- use-site variance wrt type params.
> Yuck!

This was taken straight from recent Java forums discussion. I don't even think it's the most horrid thing I've seen with generics. The incompatibility of array variance and generic variance is really nasty. I've even seen cases related to that where unsafe code did not generate compilation errors (that may have been changed in 1.6.)

> Most otherwise smart programmers don't understand the
> 'super' notation and contravariance wrt type params and so
> forth, because it is a pointy headed perversion. Why Sun
> went with wildcards is a complete mystery to me. They had
> much better options imo.

Right. When I say generics are killing Java, it's not that generics have no value. I being able to say this is a list of Strings. The problem is that the deeper you go, the less it makes sense.

I actually think that most developers could, given the time and effort, get their heads around most of Java generics. But having put a lot of effort into doing that, I have to say that it's not really worth it. It hasn't made me a better programmer. It might even have made me worse. It's definitely a case of diminishing returns.

Even autoboxing, which seems like a fairly harmless feature is messy. I really hate getting NPEs that point to line 1 of my source file. I'm so used to Java telling me the exact line where my exception came from that it always throws me for a loop.

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: The Positive Legacy of C++ and Java Posted: Apr 3, 2009 8:22 AM
Reply to this message Reply
> Explain why line 4 fails to compile with the error message
> "cannot convert from List<capture#8-of ? extends Object>
> to List<? super String>" javac and eclipse. Is it a bug?
> If not, explain why this is not allowed based on what the
> e JLS says. And no copying the definition of lub. I mean
> in plain terms.
>
>       List<? extends String> x1 = null;
>       List<? super String> x2 = null;
>       x1 = true ? x1 : x1;
>       x2 = true ? x2 : x2;
> 


It reminds of a C++ similar fact:


void foo(const std::vector<const char *> &f) {
}

int main() {
std::vector<char *> v;
foo(v); //error
return 0;
}

Pramod Chandersekhar

Posts: 1
Nickname: pramodkc
Registered: Apr, 2009

Re: The Positive Legacy of C++ and Java Posted: Apr 6, 2009 8:03 PM
Reply to this message Reply
Just wanted to add my 2 cents worth about operator overloading and C++/Java. When Java first came out I was thrilled that they had omitted operator overloading. I agree that operator overloading can be a good thing in the hands of the experienced programmer. In my view it is like a knife - useful but better kept out of the hands of Jr Developers. I had written a short little blog on why I think it is better left out of languages http://blog.pravaah.com/2009/03/23/renting-cars-and-operator-overloading/

John Wellbelove

Posts: 72
Nickname: garibaldi
Registered: Mar, 2008

Re: The Positive Legacy of C++ and Java Posted: Apr 7, 2009 1:36 AM
Reply to this message Reply
The downside of not having operator overloading is that you are then saddled with having to impose (and police) a standard naming convention if you are to ever create a usable generic system such as C++'s STL. The fact that I can overload the ++ and -- operators of my image class iterators vastly simplifies the writing of generic algorithms. Furthermore, it enables ANY algorithm written by a third party, with no knowledge of my classes, to create a compatible algorithm. It also allows many flavours of iterator to be created (up/down, left/right, diagonal, spiral, your name in cursive script) and have them implicitly compatible too. The major benefit of operator overloading is to make the interface to your class simple, leaving the complexity of the implementation to the author of the class. With proper design, the maintainer will normally only have to deal with the usage of the class, not its implementation. Throwing out operator overloading because 'some people don't get it' is akin to banning hardware stores from selling professional tools because some numpty DIYers may not know how to use them properly.

Mark Thornton

Posts: 275
Nickname: mthornton
Registered: Oct, 2005

Re: The Positive Legacy of C++ and Java Posted: Apr 7, 2009 1:57 AM
Reply to this message Reply
> usable generic system such as C++'s STL. The fact that I
> can overload the ++ and -- operators of my image class
> iterators vastly simplifies the writing of generic
> algorithms. Furthermore, it enables ANY algorithm written

In Java, implementing the Iterator or ListIterator interfaces works perfectly well for that type of application. In fact I think many operator overloading detractors would take your example as a poster case of what not to do.

I would like to be able to use the standard operators for the obvious purposes on classes like BigDecimal, but the threat of more widespread use of operator overloading prevents it from being added to Java.

John Wellbelove

Posts: 72
Nickname: garibaldi
Registered: Mar, 2008

Re: The Positive Legacy of C++ and Java Posted: Apr 7, 2009 3:08 AM
Reply to this message Reply
> In Java, implementing the Iterator or ListIterator
> interfaces works perfectly well for that type of
> application.

I'm afraid it wouldn't cut it for my application. I've just looked up the documentation for Java's Interface and I can say quite categorically that it does not address the functionality required by my image class iterators. It's just far too simplistic. Random access? Reverse iteration? Indexing?

John Wellbelove

Posts: 72
Nickname: garibaldi
Registered: Mar, 2008

Re: The Positive Legacy of C++ and Java Posted: Apr 7, 2009 3:17 AM
Reply to this message Reply
>, but the
> threat of more widespread use of operator overloading
> prevents it from being added to Java.

Threat!!?

I don't want to get into any sort of flame war over Java v C++, but that argument does seem to imply a language that was designed to accommodate the lowest common denominator of competence.

John Wellbelove

Posts: 72
Nickname: garibaldi
Registered: Mar, 2008

Re: The Positive Legacy of C++ and Java Posted: Apr 7, 2009 3:41 AM
Reply to this message Reply
> In fact I think many operator overloading
> detractors would take your example as a poster case of
> what not to do.

I can't figure out that argument at all???

Flat View: This topic has 210 replies on 15 pages [ « | 8  9  10  11  12  13  14  15 | » ]
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-2017 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us