aspose file tools*
The moose likes Java in General and the fly likes Difficulty in Java 1.5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Difficulty in Java 1.5" Watch "Difficulty in Java 1.5" New topic
Author

Difficulty in Java 1.5

Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
hi all the ranchers
Actually, I had read some material and discussed with some professors in the past, and know that Java 1.5 may be difficult to learn as it seems to be similar to C++ in some mechanism.
Could any rancher point out how difficulty(may be easier) of Java 1.5 to be leant?
thanks for your help


Francis Siu
SCJP, MCDBA
Rick Portugal
Ranch Hand

Joined: Dec 17, 2002
Posts: 243
Java is still easier to learn than C++. C++ has pointers which are the cause of many errors. In addition to constructors, C++ also has destructors. Also, Java has garbage collection - you don't need to allocate and deallocate memory in Java.


IBM 286, SCJP, SCWCD, EIEIO
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Rick Portugal:
Java is still easier to learn than C++. C++ has pointers which are the cause of many errors. In addition to constructors, C++ also has destructors. Also, Java has garbage collection - you don't need to allocate and deallocate memory in Java.


Mmm, it's kinda personal favourite, I guess... Most of my friends, who are C++ programmers, told me that they cannot follow up the concept of Java and its OO Concept... As for me, I feel that Java is easier to learn than C++... I do agree with your comment that pointer is the most difficult topic for me as well...

But some basic I/O things like cin and cout methods are more convenient in C++ than in Java's I/O system... So we cannot say which one is easier to learn or which one is difficult...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Rick Portugal
Ranch Hand

Joined: Dec 17, 2002
Posts: 243
Most of my friends, who are C++ programmers, told me that they cannot follow up the concept of Java and its OO Concept

I'm surprised at that. C++ is also object oriented, and C++ has the additional concept of multiple inheritence.

I suppose it comes down to whatever you are used to.
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Although C++ is OO, however, unlike Java, OO is not enforced.

Thus, for programmers who wrote C before, even they change to C++, they may keep the old coding style, as OO is not enforced.

Sometimes, maybe just the issue of *NOT DOING SO*, instead of *CANNOT DO*.

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Rick Portugal:

I'm surprised at that. C++ is also object oriented, and C++ has the additional concept of multiple inheritence.

I suppose it comes down to whatever you are used to.


Like Nick said in the post above, Java and C++ got different style of OO Concepts and that's what I want to point out...

As you said, it comes down to whatever we are used to in the real world...
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
I feel Java 5 will make programmers' life easier, as the coding becomes more and more simplified.

Thus, time to start with Tiger!

Nick
Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341

Like Nick said in the post above, Java and C++ got different style of OO Concepts and that's what I want to point out...


I think of Java has OO features less than C++ provides such as private, public inheritance.
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

I think of Java has OO features less than C++ provides such as private, public inheritance.


Could you explain a bit more? :roll:

Nick
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Surasak Leenapongpanit:


I think of Java has OO features less than C++ provides such as private, public inheritance.


I even heard before that Java got more OO features than C++... But what you are saying is opposite to that...

Then I also would know in detail about it, like Nick... Could you? :roll:
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
I get the same thinking as Ko Ko.

Nick
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Ko Ko Naing:
I even heard before that Java got more OO features than C++...


Then you heard something wrong - everything that can be done in Java, can also be done in C++ - there are even garbage collectors for C++. And additionally, C++ has multiple implementation inheritance, private inheritance (that is, inheritance of implementation without inheriting the interface) etc. pp.

Of C++ guys have problems have problems understanding Java, they simply aren't using the OO concepts of C++ either...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Originally posted by Ilja Preuss:

(...) there are even garbage collectors for C++. (...)


But it's not part of the language, so whether a team you join is using one, or libraries you use uses them is an issue.

You have to use .h - files.
And c++ is slower, because of no JIT-Compiler.

And every platform has its own GUI-Library (while there are platform - independent libraries for c++ as well - but are they used on your new job?). Even on one Plattform you have different libraries from Borland and MS.
Ok - we have AWT, Swing and SWT...

In general I guess since java is enforcing OO-concepts stronger, you will get more benefits in learning java first, and use that knowledge for c++, than the other way round.


http://home.arcor.de/hirnstrom/bewerbung
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Ilja Preuss:

C++ has multiple implementation inheritance, private inheritance (that is, inheritance of implementation without inheriting the interface) etc. pp.


Thanks a lot for your info about the C++ OO Concept...

But I think implementing multiple interfaces is analogous to the multiple implementation inheritance of C++...

Could you explain more in details about several kinds of inheritance types in C++? Or good links about them might be enough...Thanks...
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Stefan Wagner:
But it's not part of the language


Yes it is

Originally posted by Stefan Wagner:
And c++ is slower, because of no JIT-Compiler.


Umm, huh? C++ compiles to binary. The JIT compiler looks at byte code and compiles it to binary on the fly.

Originally posted by Stefan Wagner:
In general I guess since java is enforcing OO-concepts stronger, you will get more benefits in learning java first, and use that knowledge for c++, than the other way round.


It is true that most academic programs are teaching OO with Java rather than C++. However, that does not mean that learning Java first will prove any benefit over learning C++ first. In face, I would say the opposit is true. If you learn C++ first, Java will be a breeze. No pointer syntax, no memory allocation or deallocation. I'm not saying Java is better. Pointers and memory management can be very important, especially in RealTime systems where memory is limited and a VM might be too much of a footprint.

Wow, I basically don't agree with anything you said here huh.
[ August 28, 2004: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Ko Ko Naing:
But I think implementing multiple interfaces is analogous to the multiple implementation inheritance of C++...


When implementing an interface, you don't inherit any implementation, do you?


Could you explain more in details about several kinds of inheritance types in C++? Or good links about them might be enough...Thanks... [/QB]


http://cpptips.hyperformix.com/cpptips/priv_inher
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Gregg: GC is part of the c++ - language?
Don't you normally have to define a destructor for your classes any more, and call it explicitly?

To JIT-Compiler: The jit-compiler knows the machine (or might know it) which shall run the code, but most compilations of c++ come to be compatible to some few-years-old processors - don't they?
And a JIT-Compiler might know, if a loop-unrolling makes sense in some context, which might be unknowable at compile-time.

The best language to learn first is mostly speculation in my case.
I started with a mixture of c/c++, and thought I knew what OO-Programming is after reading 3 books and writing two small applications.
When I started learning java, I had to see, that nearly everything might be modelled as a Class, and after learning and using it for two or three years, I knew how few I knew when starting.

What I wanted to say, is: If you start with java, where nearly everything is a class, it might be more easy to use c++ very object-oriented, while if you start with c++, the traditions of fine c-developers, which only use some c++-features, could infect you.

Of course everybody is free to write bad code in any language, even with java.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Stefan Wagner:
Of course everybody is free to write bad code in any language, even with java.


Definitely. Most importantly, making everything a class is not what makes a programm OO, in my opinion. I've seen many Java programs that I wouldn't call OO - (my first programs included).
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
I've seen many Java programs that I wouldn't call OO - (my first programs included).

Thanks for so much informative opinion, my situation is that I require to learn C++ in the fall semester, but I learn Java language two years ago. Now, I got some idea on how to learn it effective.
zmarak ahmad djan
Greenhorn

Joined: Sep 02, 2004
Posts: 20
Originally posted by Nicholas Cheung:
I feel Java 5 will make programmers' life easier, as the coding becomes more and more simplified.

Thus, time to start with Tiger!



not that simple.
when java arrived I was pleased to see a rather simple language with
very few "behind the scenes" things happening to your code.

J2SE5 breaks these assertions on many points.
many new features have bright and dark sides:
for instance generics has some interesting properties and an horrible irregular syntax that obfuscates code.
auto-boxing and unboxing is syntactic sugar: you'll love it until it starts rotting your teeths (the same applies to static import)

so-so


zmarak (publican)
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by zmarak ahmad djan:
for instance generics has some interesting properties and an horrible irregular syntax that obfuscates code.


In which way is the generics syntax "irregular"?

auto-boxing and unboxing is syntactic sugar: you'll love it until it starts rotting your teeths (the same applies to static import)


The whole Java language is syntactic sugar - after all you could write byte code instead. And near to every feature of the language can be misused - that doesn't make the language a bad one, though.
zmarak ahmad djan
Greenhorn

Joined: Sep 02, 2004
Posts: 20
question: why is generics "irregular"

many points here...

- tokens "extends" "super" "&" have a contextual meaning
that is they do not mean the same at these specific points in the program
(ok it's not exactly a syntactic problem ;-))

-type parameters are not declared at the same place
they are at a specific place when declaring a class and at another
when declaring a method ....

the results are rather confusing ... try to teach that to greenhorns
and you'll see what I mean!

zmarak

P.S. as to syntactic sugar you are carrying the analogy a bit far
again it's ok unless it let you express things that are :
- contrary to OO paradigm
- hiding "things" to the reader and maintainer of the code
(remember that's the very reason why macros were ruled out of the language)
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by zmarak ahmad djan:
- tokens "extends" "super" "&" have a contextual meaning
that is they do not mean the same at these specific points in the program
(ok it's not exactly a syntactic problem ;-))


But that's in now way specific to generics:
- "super" is already overloaded: it can mean both a call to a constructor or a reference to an inherited member (similar for "this"),
- "final" has different meanings for classes, methods and fields,
- "abstract" has different semantics for classes and methods,
- parentheses are used for method argument lists, changing evaluation order inside expressions and casting,
- ":" is used for case statements, labels (for break/continue) and in the "?:" operator (and nowadays in the enhanced for loop)

etc. pp.


-type parameters are not declared at the same place
they are at a specific place when declaring a class and at another
when declaring a method ....


Yes, that's needs to get a little bit used to. Not sure what would have been a better alternative though. I'd assume that the expert group thought a while about this, too, and came up with this style for a reason.

the results are rather confusing ... try to teach that to greenhorns
and you'll see what I mean!


"Being determines consciousness." Try to maintain complex systems...


P.S. as to syntactic sugar you are carrying the analogy a bit far


I don't think so. I think it makes perfectly clear that being "syntactic sugar" cannot possibly be a good argument against a feature of a programming language.

again it's ok unless it let you express things that are :
- contrary to OO paradigm


I don't see how generics are against the "oo paradigm" at all. Could you please elaborate?



- hiding "things" to the reader and maintainer of the code
(remember that's the very reason why macros were ruled out of the language)


I am not sure what you are getting at here. Obviously "hiding things" is not generally a bad idea - actually, hiding the right things is an important part of OO (information hiding and abstractions from implementation details).

In fact I'd think that generics make the important things more explicite (such as "what objects does this collection contain") and only hides clutter such as explicite casting from the developer.
zmarak ahmad djan
Greenhorn

Joined: Sep 02, 2004
Posts: 20
are you saying that if you write
<T extends Comparable>
the "extends" there "overloads" the base semantics
of "extends" in

MyClass extends YourClass

....?
(there I have to confess I am no native speaker of english ... so I may have a wrong perception of the term overloads )

in a hurry.... other points will be answered later

zmarak
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
With "being overloaded" I just wanted to say "meaning different things depending on the context". I might have used it wrongly, though...

I have to say, though, that I don't find the new meaning of extends to be hard to understand:

<T extends Foo>

If you look at T as a kind of variable, that actually makes a lot of sense, doesn't it? We don't know what class exactly T is, but what we know is that it extends Foo...
zmarak ahmad djan
Greenhorn

Joined: Sep 02, 2004
Posts: 20
A class that extendsan interface?

the sad fact is this:
though the semantics of constrained type variables is NOT extends or super
the devt. team prefered not to create yet another keyword
so this choice was considered the less of two evils
____________________________________

I am no OO priest and I wasn't refering to generics about that
static import of methods is *bad* (Oops turning preachy again...)

__________________________________

about syntactic sugar I repeat what I said : you're going to love it
until you'll get a big bug that will drive you mad...

this has nothing to do with "information hiding"...
let's draw an analogy:

one of the features I do not like in standard Java is the ability to mix
integer and floating point arithmetic.
for sure this was a compromise (they did not intend to create something too complicated)
for sure that's a mine for crazy questions in the SCJP exam
but when you've got a bug because you inadvertently operated with integer
division instead of floating point division you find the feature unamusing!
some languages do not let you write such code...
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by zmarak ahmad djan:
A class that extendsan interface?


Mhh, didn't think of that yet. Certainly not the most consistent thing to do, but isn't much headache-inducing to me, either... :shrug:


I am no OO priest and I wasn't refering to generics about that
static import of methods is *bad* (Oops turning preachy again...)


What's so bad about it (besides static methods being inappropriate in many circumstances, anyway)?


about syntactic sugar I repeat what I said : you're going to love it
until you'll get a big bug that will drive you mad...


Is there a specific kind of "big bug" you are thinking of?


this has nothing to do with "information hiding"...
let's draw an analogy:


I guess I don't get it. Don't generics actually *prevent* you from missing things that don't belong together? Such as putting a Foo into a List of Bars?


one of the features I do not like in standard Java is the ability to mix
integer and floating point arithmetic.


In my experience, this isn't a big issue in practice. Might depend on the type of systems you are working on, I assume.

Anyway, in my humble opinion, if you don't have a suite of tests that find this problem in a matter of minutes after you introduced it, you are in trouble, anyway.
zmarak ahmad djan
Greenhorn

Joined: Sep 02, 2004
Posts: 20
Originally posted by Ilja Preuss:

Anyway, in my humble opinion, if you don't have a suite of tests that find this problem in a matter of minutes after you introduced it, you are in trouble, anyway.


well it's like saying you do not need a typed language
why bother? you'll fix the problem at first test ...!

unfortunately in complex calculations things are not so simple ...
again that's why this is forbidden in some prudent languages

--------------------
as for static import of methods
it's not that static methods are bad
but that expressiveness of java is that you request explicitly a service
to somebody: be it an instance or a class
so if you write


it starts looking like C not java
+ you do not obviously know if you are requesting a service
to class Math or to class StrictMath ?
(sure it's written somewhere in the code ... but it's not obvious
hence it's a sin)

prosit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difficulty in Java 1.5