Jave = C++

Nostradamus

Newbie
Joined
May 17, 2003
Messages
980
Reaction score
0
Well, i have this book about Java(went to it for half a year but was kinda boring) and well thought about reading it since well couldnt hurt, and it said on the back that it is almost like C++..and im just wondering...if i read a really conclusive book on Java..would i be able to understand, lets say the SDK? ;)
many thx, and peace
 
The syntax is similar but many languages share a C like Syntax.

The primary difference is this. C++ is compiled into instructions for your processor, and java is compiled into special java instructions. To run a java application you must have a virtual machine installed as it translates java instructions to processor instructions essentially.
 
Did anyone remember the 'revolution' that was supposed to come with Java... somthing about OpenDOC... mix and match programs and applets... hmmm, Fallout2man is right :)
 
Java's main problem is it's just slow. Microsoft, while its JVM conformed mainly with propriatary implimentations, was much faster. Sun's is just clunky and slow as hell.

A hardware JVM would make java more worthwhile.
 
there are some more differences, java can be ported, while windoze specific programs in c++ (winapi) can't be ported that easy. but java lacks several things like you if you make 2 or 3 classes out of the last class it's variables and methods won't be implented into the new classes. in c++ every class made outta an existing one gets the things in it's "parent" class, too
 
Originally posted by mrBadger
Did anyone remember the 'revolution' that was supposed to come with Java... somthing about OpenDOC... mix and match programs and applets... hmmm, Fallout2man is right :)

Remember how evryone was to become a millionaire and reality would be absolete? Haaaa! There's a failed .commer who has a small coffee
shop near me, he personally admits that everyone in silicon valley was so off their rocker during the 90's.

Java isn't C++ is it?:eek: :cheers: :bounce:
 
Re: Re: Jave = C++

Originally posted by nietzsche
Since the Java language was intentionally designed as a C++-like language, you'll be able to understand various concepts.

Since this is an uber-nerd area of the forum, I don't mind pointing out really geeky stuff, such as Java was actually based on Smalltalk, not C++. Smalltalk was not only the syntactical predecessor to Java, but the basis for most modern software platforms, i.e. J2EE, MS.NET, and IBM WebShere. Furthermore, Smalltalk influenced object-oriented programming greatly by intruducing concepts such as single sub-class inheritence and the fundemental idea of (modern) design patterns.

-Mr. Bildo
 
Originally posted by nietzsche
Most programming languages featuring object-oriented concepts borrowed them from the pioneering ideas of Smalltalk, C++ inclusively. However, that doesn't make Smalltalk the direct predecessor of Java,

Why not? Was not C more or less the direct decendent of FORTRAN? When you look at the core features of Java the language (and I'll concede the grammer is obviously more C-like) it reads a laundry list of Smalltalk concepts. JIT, GC, object-based type system, all selling points in Java that have an undeniable origin.

Ya know, I had this exact same conversation with a fellow consultant on a contract I had about a year ago. As soon as I brought up Smalltalk and Java, the guy got all defensive. What is up with that? It's like telling a Southern Baptist that Jesus was Jewish. So what? I mean, it's o.k. to run around and say how much Microsoft and Apple ripped off Xerox, but the moment you say Sun did, everybody gets all militant.

Experienced programmers will be even more convinced about it.

Oh, I see... I didn't realize this was a pissing contest. :rolleyes:

Disagreement is a good thing, "my skillz is betta' din yuz skillz" is just lame...

-Mr. Bildo
 
heh well to get technical, we have to go back to ALGOL (block structured programming language) then follow up to BCPL, and of course B before we reach C, of course ANSI(now ISO) C is an evolution of the orignal C, and is what we recognise nowadays as C. It wasn't FORTRAN and then C, there was a steady progression towards it.

uh yeah anyway, bit of trivia for you there.
 
Originally posted by nietzsche
Mr. Bildo, going by your logic, machine language is the predecessor of all existing higher-level programming languages.

That logic isn't nessecarily flawed. It's no more ubsurd than say, evolution. In which modern mammals are predecessors to single-celled organisms. Yet, evolution is widly held as fact.

Cunbelin made a valid point. There's a steady progression in the field of programming language development. Just because Smalltalk pioneered the concepts of object-oriented programming doesn't make it the direct predecessor of Java.

Neither could you say that C++ is, in which case you default to who hits closer to the mark. My argument remains for Smalltalk's influence. Look, the Wright Brothers didn't invent the combustion engine, the process of milling lumber, or even pioneer physics. However, when they put it all together and flew an airplane, we duly credited them with the achievment. Would you argue then that the progression of combustion engines to jet engines had a more direct influence on modern aircraft? Smalltalk put it all together and when you look at Java, you may see the combustion engine that is C++, but I personally see the airplane that is Smalltalk.

I'm going to leave it at that, because I think we're both bored with this and the coding forum is one of the few that intelligent conversations actually take place, so I don't want acts of digression (that I guess I essentially started) to ruin it.

BTW - Are you in school or out in the wild?

-Mr. Bildo
 
hey Nostradamus (btw i didn't read the other posts here, sorry!), I've taken a few semesters of java, and I can say this. If you're looking to mod, knowing java helps a lot when you're the main coder's assistant. For example, my mod's main coder is great in c++, but I can still help him find specific things, so as an assistant knowing java is just fine.

But hell if I could make my own c++ class. Learn c++ if you can, but knowing java is esspecially good for helping out someone who already knows c++.
 
(also skipping the history lessons)

Nostradamus, java is in many ways "C++ lite" and is a decent learning language for both C-type syntax and object-oriented concepts (and useful for many things that don't involve GUI). However, if your goal is to get to C++ and the SDK, there are severl big things java won't teach you. So you could learn java first (hey, programming is programming), but you'll eventually have to learn (off the top of my head):

1) memory management. this is the big one. java is one of those languages that hides pointers and memory allocation and such; C/C++ don't. as a side note, hiding it is a good thing in many ways, but if you don't understand how memory is being used you will write poor code, even in java, lisp, vb, etc...

2) operator overloading. java has very simple constructor/destructor methods in each class. C++ brings in chaining, assignment operators, copy constructors, and arbitrary operator overloading.

3) templates. you don't necessarily have to make templates, but lots of library classes do so you have to know how to use them.

4) libraries. a lot of java programming is about knowing what built in classes to use. compared to the simple java SDK libraries, C++ libraries like the STL will be very intimidating (see point 3). really they're about the same, but you'll miss nice user friendly classes like java.lang.String.

5) syntax. people are right to tell you that C/C++ code and java code look a lot alike. the actual code, that is (if, for, {}, etc). however, all the "extra" stuff like header files, declarations, preprocessor directives, macros and global functions will look like a huge mess coming from java where everything is in it's own neat little class and uses the same declarative syntax.

6) win32. java runs in it's own clean environment, which is part of the reason it makes a good learning language. the win32 API is just another library, but a particularly convoluted one due to it's evolutionary nature.

7) multiple inheritance. as mentioned before, java doesn't support this. many people feel that you never have to use this feature, and that in fact you're better off designing around it. other people feel differently. the bottom line though is that if valve uses it in their code, you've got to know how it works.

i'm sure there are more. i'm not sure what your experience is at the moment, but the thing to remember is that a good programmer can write in any language. learn the principles and they transfer well. java is great for learning basic programming like loops and conditionals as well as for object-oriented concepts. moving to C++ will involve lots more learning though.

hope that's helpful,
etomai
 
etomai, thanks for heading me off at the pass.

When I talk to new hires at my company, they tell me how they learned Java first, but having worked with it for a few years, I imagine that learning Java before moving on to C++ would be a lot like when we had to learn Pascal as a prereq for C. Pascal taught me one thing : How to write code without line numbers. I promptly forgot everything else about it and had to relearn C from scratch.

You might want to take a CS course at your local university for C++, or perhaps pick up the text for said course and work through it. I learned a lot of invaluable lessons from my Data Structures book that I use to this day...

Yes, certain concepts would help you, but you must unlearn a lot of things you will learn ;)

K
 
What if u have a background with C and Java? Then learning C++ will be a snap right?
 
it's never quite a snap, but if you have a good background in programming, you should be confident moving to any language. when someone tells me they know C, i hope that means they think in terms of memory, pointers and data structures, and that's most of the battle in any language. if that's the position you're in, knowing or not knowing java isn't going to make a huge difference one way or the other.

what vulcan3d says about data structures is spot on; i still use my book too.

coming from C to C++, i really liked the o'reilly nutshell book "C++: The Core Language", primarily because it is very short and to the point (read: not a definitive reference by far). got me right up to the point where i could mess with other people's code, and from there you can buy books as you need them.
 
Originally posted by Fallout2man
The syntax is similar but many languages share a C like Syntax.

The primary difference is this. C++ is compiled into instructions for your processor, and java is compiled into special java instructions. To run a java application you must have a virtual machine installed as it translates java instructions to processor instructions essentially.

Listen to this guy :>
 
Java compiles down to Java intructions which are then compiled on the fly by the JVM and turned into machine code for the native machine. C++ is C with the class structure added, it compiles down to native machine code and will usualy not run on the platform other than the one it was compiled for. Microsoft has recently created C# which is similar to java in syntax but compiles down to machine code like C++.

I will also say that C++ has a very bad implementation of classes. The newer languages have much better implementations of Classes and they often have much cleaner code, for instance all objects are derived from a generic objects class. This is not the case in C++. I personaly think C# will replace C++ in the next few years because its about 10x easiers to program and understand the classes and it has a 1-5% performance decrease which is acceptable and will only get smaller with time as better compilers are made.

The truth is it doesnt really matter what language you program in, the quality of the code is a much bigger factor for performance and in some cases a well written java program can run as fast as a C++ program. Feel comfortable in what you program in, I prefer C# over C++ because I learned Java first and C# makes more sense, I have done some C++ though. Once you know a language like C migrating to others is a snap.
 
C++ is more then C with classes. Dynamic Memory allocation (using the new and delete operators versus standard library or third party malloc/calloc/realloc/free implimentations) and the template language construct are just two examples of other changes made.
 
I'm not one for penis waving on forums, but I hate when the disinformed post things that just aren't true. MadMech, check your facts :

Originally posted by MadMechwarrior
Java compiles down to Java intructions which are then compiled on the fly by the JVM and turned into machine code for the native machine. C++ is C with the class structure added, it compiles down to native machine code and will usualy not run on the platform other than the one it was compiled for. Microsoft has recently created C# which is similar to java in syntax but compiles down to machine code like C++.

Nope, not really. Yes, C++ does, with most compilers, compile to machine code. Java compiles to Java Byte code. The first time you run a Java app, it uses a JIT(Just In Time) compiler to compile down to machine code. If no binary changes are made, the second and n times you run the app, it runs the precompiled machine code. This was Sun's answer to all this people complaining that Java was "slow". This is also why the first time you run a servlet or a JSP, it is much slower to respond than the second or n times. C# also compiles down to its own version of bytecode, called CLR, I believe. It also uses a JIT compiler like Java. Syntactically, the two are similar. C# is targeted at Java programmers making "the big switch". Oh, and by using managed code, you could write an application in C++ that actually compiles to CLR. Microsoft's angle is that you can use any language you want to get to CLR...


I personaly think C# will replace C++ in the next few years because its about 10x easiers to program and understand the classes and it has a 1-5% performance decrease which is acceptable and will only get smaller with time as better compilers are made.

Perhaps not. That depends on vendors providing 3d libraries for use with C#. Java has, for example, Java3D, which maps to OGL1.1. New iterations will have support pixel shaders, but I'm not holding my breath. And MS has shown no inclination towards creating or supporting a 3d api for the .Net framework. Sure, there are drawing functions, but thats not really the same, is it? I suppose we could make native calls, but why would you? As for C# replacing C++ period? Never in its current incarnation. The Framework has too much overhead for realtime apps.


The truth is it doesnt really matter what language you program in, the quality of the code is a much bigger factor for performance and in some cases a well written java program can run as fast as a C++ program. Feel comfortable in what you program in, I prefer C# over C++ because I learned Java first and C# makes more sense, I have done some C++ though. Once you know a language like C migrating to others is a snap.

Generally speaking in Zen sense, sure, the language you use doesn't dictate whether you are a programmer or not. And a smart person writing in an interpreted scripting language like PERL can beat out a C++ programmer, but if you are talking about programming for HL2, you have to work with C++. Migrating is never "a snap" even when syntax is similar. You should know that syntax is only a small part of the equation. Every language has its quirks. Every platform has its own quirks. Sure, I "learned" C# overnight. But I had to relearn a lot more about platform quirks and minor differences...

K
 
Well first off Vulcan3D I can view the entirety of your post as a flame. I wasnt trying to get all technical, just the basics anyways..


Perhaps not. That depends on vendors providing 3d libraries for use with C#. Java has, for example, Java3D, which maps to OGL1.1. New iterations will have support pixel shaders, but I'm not holding my breath. And MS has shown no inclination towards creating or supporting a 3d api for the .Net framework. Sure, there are drawing functions, but thats not really the same, is it? I suppose we could make native calls, but why would you? As for C# replacing C++ period? Never in its current incarnation. The Framework has too much overhead for realtime apps

Before you start waving your penis around you could prolly look into what your talking about a little. DirectX 9 is fully compatible with the .Net framework and it has lots of nifty DX classes. At this point there is nothing you used to be able to do in C++ that you cant do in C# except use OpenGL, but if you wanted to you could write a wraper for it.

Im not a super experienced programmer (I wouldnt be modding if I was). Im here to make mistakes, learn and progress that way. We anwsered the guys question that java isnt C++ so lets not turn this into a flame war.
 
Madmech, my intent was not to flame, but to set straight a few facts. Flaming would probably be something more purile, don't you think? I apologize if I offended you... Looking back at my email, it was rather mean spirited...

As for looking into it, I can tell you off the top of my head... The .Net framework does have a System.Drawing namespace which lets you use something called GDI+. No 3d functions. If you do know of a hidden namespace that contains Direct3d calls, I'd love to hear about it...

Right, right, the point is moot. Signing off.

K
 
if you have DirectX 9 SDK installed Microsoft.DirectX and Microsoft.DirectX.Direct3D are created. They allow you to create rendering devices and everything from vertex buffers to pixel shaders. DirectPlay, directInput and DirectSound are also in there
 
Back
Top