| FourSight (23) | |
|
:[ Also, what's the difference between C++ and Java classes? It seems a little different in Java. I just started learning Java. | |
|
|
|
| L B (3327) | |
|
In Java, inner-classes can either be attached to an instance of the outer class, or they can be static. There are also no constructors. The main difference is that Java is single-inheritance (extend only one class) multiple-implementation (implement multiple interfaces). Interfaces are like pure virtual classes in C++ but you cannot have data members or concrete methods. | |
|
|
|
| ModShop (765) | |
|
Java isn't more popular than C++, especially in commercial applications. Perhaps as a beginner language in some computer science courses, but not as much in the real world. It is gaining popularity though, so its definitely good to know it. Difference between the classes... Well, the syntax mainly, and Java has lots of other specific rules regarding classes (makes sense as the whole language is classes) and n Java, everything is a class. | |
|
|
|
| Aramil of Elixia (772) | |
| grrrr..... java..... almost as evil as system() | |
|
|
|
| Duoas (6734) | |
|
I personally dislike Java, but there is really nothing horribly, macabrely wrong with it. As to answer the title question, I did a quick Google and found some nice answers. | |
|
|
|
| L B (3327) | |
| I started out disliking Java, having learned C++ first, but I eventually realized I was trying to compare and contrast it to C++ - after that I started to accept Java as a language built to support specific design patterns whereas C++ is very general. | |
|
|
|
| computerquip (1892) | |
| I don't like Java as a language. I also don't like any general implementation of a language that forces a memory model. I also seem to have gone Java, C, C++, C with hatred of Java. C++ really made me see the complications of OOP programming and how its used in many unnecessary situations. I don't like everything being represented as an Object in Java. | |
|
|
|
| pogrady (410) | |
|
The reason why its so popular is that Java doesn't compile like c++. When you compile c++ the program compiles into machine code designed to run on a specific chipset. This makes the code not very portable; you cannot compile a c++ program on a x86 machine and reasonably expect it to run on an Apple. What you would need is some kind of "bridge" that connects the code the programmer writes into a system that interprets for the machine that its running on. This is the concept of Java. You don't really compile a Java program, but instead send it to the actively running Java machine that then, at the time of use, complies the program and runs it on the machine that the user is operating. This machine is called the Java "virtual machine", and you probably have experience with it any time you load a Java program, its the program that loads in the background. This is why Java is more popular. You can write code that can reasonably run on any machine. There are limitations to this however. One of the biggest and a major reason why people don't use Java is that Java does not provide access to the memory or the chipset. There's a whole layer that you as the programmer do not have access. And this irritates people! | |
|
|
|
| computerquip (1892) | |
|
You still need a separate implementation of the standard libraries for each platform that Java supports. The same can be done for a library in C++ and is done all the time (OpenGL, SDL, SFML, OpenAL, udev, several games, the STL, almost all of the Boost libraries, so on). An application may have to be recompiled for a library update but there are ways to manage this on the library side (position independence). Also, you compile Java into bytecode, much like how you compile C++ into something the OS you're compiling for can understand. The implementation is different (and probably simplified) but the concept is very similar. The JVM in concept is actually pretty cool. I just don't see a lot of realistic use for it compared to alternatives. | |
|
Last edited on
|
|
| rapidcoder (681) | |||
|
There are lots of reasons why Java is very popular: 1. Managed memory model. No dangling pointers. No buffer overruns. Much harder to create memory leaks than in C or C++. 2. Security. You can precisely control, what code can and what can't do. Private is private, you can't e.g. set a private property of an object, if you don't have rights to. 3. Huge standard library. Lots of third-party libraries. 4. Well standardized and portable, no problems with non-standard compilers. 5. High performance, great support for multicore. 6. Simple language, much fewer caveats and sharp-edges than in C++. 7. Awesome tooling. 8. Compile times orders of magnitude faster than for C++. 9. If you can't do something with Java, you can still call native code from your program. 10. Can be used to create mobile-apps and web-apps, while with C++, although possible, it is not that easy.
Not true. I can call to OS from Java anytime I wish. I can even call malloc, wrap it into direct ByteBuffer and use it directly from Java code, without a single line of C. We use it all the time in Apache Cassandra - therefore lots of data is kept off-heap. And as far as I know, although it is pure Java, considering performance and scalability, it beats all the other big data NoSQL database engines, including those written in C++, e.g. MongoDB.
In reality it is just the other way round. People use C++ only for very specific reasons now: legacy systems, low latency systems with low memory (low latency with enough memory is not a problem for Java, though), AAA 3D games, sometimes some scientific HPC stuff, some desktop apps (but this era is over, too; e.g. Firefox frontend is already using lots of JS). For all the rest, there are better, more general purpose languages and Java is one of them. For 99% cases you don't need to fit in 10MB RAM, nor have <10 ms guaranteed latency. | |||
|
Last edited on
|
|||
| L B (3327) | |
|
2. Using reflection you can get and set private and protected data members and call private and protected methods. Though, it does require you to call setAccessible() on the Field instance. 6. Read "Java Puzzlers"? As for your response to me, I was talking about the way you write code, not the way you use code. | |
|
|
|
| JLBorges (1336) | |||
|
There are a lot of reasons why a programming language becomes popular. Luck, timing, marketing of the language - all these play a role. Given that the luck factor is right, IMHO, how easy it is to learn a programming language is the most important ingredient which makes up for the popularity of a programming language. The technical merits of the language itself has very little to do with its popularity. As long as it has no first degree technical defects, a language that is very easy to learn is likely to become more widely used. Bigots++ and JBigots have argued the relative technical merits, specific features that the languages support etc. endlessly, in endless debates; bigots tend to suffer from verbal diarrhea. Though this is a C++ site, we do have a resident JBigot, and if we so wish, we can continue the debate here too. Extracts from an interview that appeared in 'The C++ Report' and 'The Java Report' in July 2000:
| |||
|
|
|||
| rapidcoder (681) | ||
If I set up a SecurityManager you can shove your setAccessible() call up your ass. You'd have to break up from JVM sandbox by exploiting some vulnerability, but these are rare and fixed very fast. 6. You can create puzzlers for any language. I didn't say there aren't any caveats in Java, but that there are much less than in C++. The language is much, much simpler and smaller and additionally, unlike C++, Java has decidable, context-free (exactly LL(k)) grammar. | ||
|
Last edited on
|
||
| L B (3327) | |||
I agree except for this part:
| |||
|
Last edited on
|
|||
| JLBorges (1336) | ||
|
Checking syntactic correctness is context free for most programming languages. Checking semantic correctness in any programming language which is not type-less and allows creation of user defined types, is by definition, not context-free. Gosling is right when he says:
| ||
|
Last edited on
|
||
| mp3butcher (4) | |
|
Java suxxx....long compilation, heavy IDE, not instinctive too far from real hardware :) More personally i dont like object that can look himself without knowing how.. But it's an opinion cause there are a lot of usefull frameworks that can help for specific application(JavaBeans,EJB) and native library binding (like jogl for 3D) that are very efficient. All depend on what you focus to create : a heavy factory or a light weight and efficient application... | |
|
Last edited on
|
|
| boborokz (2) | |
|
For starters, Java is not more popular than C++. The only reason anyone uses it at all could be for three popular reasons: 1. They don't know that there are more efficient languages out there like C# or C++. 2. They are learning the basics of object oriented programming. 3. They are using the JVM for what it's meant for: portable (cross-platform) applications The third reason is the only reason why a logical programmer would use Java. But C/C++ applications are starting to become more portable by shipping the application in make-able source code form, so you can make it on any platform you have. In all honesty, Java isn't that good for general purpose programming. But if you're making a fun little app (e.g. Minecraft), then go ahead. | |
|
|
|
| Luc Lieber (911) | |||
I would be very curious to interview java programmers regarding security management. My guess would be that they would be as oblivious to them as they are to items in the java.lang.ref package. Also, be very careful about boasting to have direct access to native resources, as there is a significant overhead involved in most cases... P.S. What overhead is incurred by a "properly" set up SecurityManager? Has anyone ever benchmarked the approximate cost of running in a sandbox? P.P.S.
Might as well put in the rest of the story here. low latency with enough memory and slow enough garbage production I just love it how Java enthusiasts frequently only paint half of the real picture to make Java look better than it really is... | |||
|
Last edited on
|
|||
| rapidcoder (681) | ||
It is and I can prove this. Go to any big site offering programming jobs. The demand for Java programmers, as well as for .NET programmers is more than two fold higher than for C++ programmers. This means there is more code written in Java than in C++. The similar thing is if you compare the numbers of open source projects by language. Java is certainly more popular than C++ now. | ||
|
|
||
| L B (3327) | |||
| |||
|
|
|||