Friday, June 27, 2008

tanks, now i r confuzzled

Dear lazyweb,

I don't understand why people seriously use Java. I know that most colleges and schools teach kids to program in Java, but that doesn't mean it should be used in the real world (how much stuff do you learn in school that really is meant to be used in the real world?). It is a "gateway language" if I had to choose a name for it. If you are doing web development, use OO/PHP or Ruby (I don't recommend ASP simply because I write in it almost everyday and it isn't that great). If you are doing desktop development, use C++ and make it portable.

A) PHP and Ruby are (nearly) completely OS independent, and I have never run into problem moving from one OS to another (with PHP, I am just learning Ruby, so I have no personal experience with moving it. I have heard good stories though).
B) C++ is like a hairy Java on steroids. No, it isn't as clean, but it is much faster and more powerful.
C) You can run C++ apps on embedded devices without the bloat of a virtual machine to run the bytecode.

I would greatly enjoy someone explaining to me why Java is taken seriously. It is something that has been bugging me since high school.


  1. I wholeheartedly agree. Java should be viewed as a toy, litte more

  2. As I see it, it is popular because

    1- It's cheap / easy because:
    1a- A lot of people know it
    1b - A lot of tools have been built up to make development with it fairly rapid / easy.


    2- It is good enough.

    Most people, particularly in business situations, have a binary solution discriminator. There are two possible results, "good enough" and "not good enough". Since 2 is true in most cases, the advantages that 1 imply make it the tool of choice. As long as it produces results that on the positive side of the Good Enough threshold, even if it's somehow sub-optimal, it just doesn't matter.

  3. I program in Java every day for my job in the "real world" and I can tell you that developing in Java using Eclipse is faster than any other language I have used. Development time is short, and for normal desktop applications, there is little to no speed difference between Java and C++ using the latest JVMs. If you haven't experienced programming with Eclipse, I highly recommend checking out the Eclipse Ganymede release.

  4. Java is popular because every single one of your points was wrong.

    Java was designed for embedded systems, where you might want to save costs by switching processors; incurring software rewrite for that sucks but without a JVM is nessecary. Java mostly failed on this front, but there's interesting niches like ARM cpus that can run Java natively, and Japan's cellphones mostly run Java apps.

    On a related note, Java has language threading support and an explicit memory model, presumably to handle interrupts and event driven programming intelligently. This didn't pan out in the mobile area, but it's HUGE on servers, especially of the web variety. When C/C++ say they support multithreading, they're lying to you. They don't (yet) have anything to say about it other than it's undefined, which is compilar jargon for "free to slaughter kittens".

    Moreover, C++ can be slow. Go count up the number of times the STL uses inheritance. I'll wait. Yes, it avoids inheritance like the plague because it's unavoidably slow. It's also slow because garbage collection can be done incrementally and with greater cache effects and optimizations, while direct management gets little to none of that.

    Meanwhile, the JVM has significant startup costs, but excellent run time analysis. JIT techniques can compile Java code for the common case, while knowing exactly what the common case is. Because it's keeping track! At best, in C++ you can run a profiler and see where your hot spots are and change code at compile time to match that. JVM can do that at runtime and change it up if the situation changes.

  5. additionally to jlduggers comments the easier syntax and the one-file/one-class rule foster very good refactoring tools, like those in eclipse or netbeans. refactoring a large project is painless and this is important in a business environment.

  6. You cannot seriously say that porting a php script is easy - a single missing extension or safe_mode on/off an such things can totally blow your things. Let alone you need a special extension which needs to be compiled from source.

    Java is quite adept on the enterprise level because of application servers like JBoss and the comfort they add. Need to add a new SomeRandomClassLib.jar? Just drop it in your lib folder and be done with it.

    Need load balancing? Oh wait, done automagically. Need database caching? Oh wait, included.

    Add the "Java is easy to learn" factor and the "Just unpack the server to have a local test environment without root/Administrator privileges" to it and you get the picture.

  7. Well, I use java everyday, and that's my own choice ;-)
    Mainly because I like the language, and it can do everything I want.
    * Vs. PHP: there's simply no comparison. PHP is simple straightforward scripting, with almost exclusive focus on request-response. Compare that to the application level / session level / request level / multithreaded possibilities / autput flexibility (e.g binary output) of the servlet model.
    * Vs C++: that's just an ugly language, based on workarounds and weird syntax ;-)
    * Vs Ruby: ok, ruby looks ok (as a language. But I don't like rails (just my feeling). I really don't understand how you can, on one end, defend ruby, php, python and in the same article prefer C++ over java based on execution speed. Did you try it out?
    You might be surprised.

  8. I work for a company producing software for online poker with realtime 3D graphics with customizable characters etc.

    We use C++ for the client software, any other language would make it bloated and slow.

    We use PHP for the back office system which is web-based. PHP is an excellent choice for this.

    We use Java on the gaming server and it's absolutely the only good choice for that work. Why? Many reasons:

    1. The exception handling is rock solid. We can NOT have our server crash when something wierd happens with the sockets or DB connection.
    2. Totally sandboxed, we are by default protected from buffer overflow or other kinds of attacks.
    3. Great DB connectivity layer.
    4. Clear syntax, great APIs etc makes it faster and easier to develop production quality code.
    5. We can switch servers completely (both hardware/CPU platform and OS) without having to rewrite a single line of code.

    Trying to do the same in C++ or PHP would at least take twice the time for the bugtesting alone and still result in a less stable product. At the same time the drawbacks of Java (JVM + memory handling overhead, startup time, possibly slower performance than C++ (which is debatable and totally depending on the task and how the C++ code is written) are all moot points on the server side.

    I love Java as a language (clean and consistent design, great libraries and tools, great multithreading etc) and I love it on the server but hate it on the desktop. Some of the same design decisions that makes it an excellent choice for the server makes it a bad fit for the desktop.

    Using Java as an academic language for teaching people to program is in my mind a good decision since they learn good principles from a consistent and well designed language which also is heavily used in the real world. Python is another good choice, but C/C++ is in my mind very questionable.

  9. I see people beat me to the punch.

    I done web application work in both PHP and Java. And while PHP is nice, there a lot of different functions, etc.; I'd hate to build a complex system using PHP.

    In my job I get to build and support a web application built with Java and JSP. You just can't get the level of abstraction and platform independence (the same code can work a bunch of different servers and handhelds together without too much hassle) with PHP as with Java. If you are building something more complex than a simple website in PHP, I wish you luck doing so especially without a good IDE like Eclipse.

    It all comes down to using the right tools for the job.

  10. Well i would hit it for ya,

    Java is well known for its stability, easyness in understanding/coding it, secured app level lang. Any body coding in java need not to worry about porting it and pointers concept and even meddling with memories. Learning Java as far as i see, is most easy thing u can do among other lang such as C++. I 2 learned C,C++, Java, C# lang so far. But i find Java quit interesting + easy and fast adopt ability. No body needs 2 worry about the system internals, if they had to code for some task. Not even about porting. Yes the speed is quit lacks from C++, but Sun always tends to over look at how much good code can be produced as Byte code from java src file, instead of the speed only. Even the hotspot and other VM parts r written in C++ :D

  11. Java is appealing simply because it makes a lot of things "easy". Building a simple OO program is quick. There's a variety of different options building a complex GUI through a visual editor. And most of all, it's instantly cross-platform.

    I realize that Java has many (*many*) pitfalls, and it's certainly not a general-purpose language. But, it's appealing the same reason C# is appealing on Windows. Type-safety, garbage collection. For simple applications that aren't worried about performance, Java can be a good choice.

  12. I'm a PHP developer by trade. Java has these problems solved over PHP:

    1 - JIT
    2 - a designed, rather than evolved language and class library. See the mess of string and array function names in PHP, difficulty adding namespaces, etc.
    3 - Unicode support (this is 2008 right?)
    4 - better tooling support. Aside from editors, useful tools like debuggers and profilers are _just_ beingging to be integrated into PHP IDEs.
    5 - porting a PHP script to Windows is, in fact, not easy.

    I'm not saying Java is the perfect platform to use, but I certainly don't think it's a foolish choice.

  13. It's interesting that you bring this up because Jim Waldo from Sun just did a talk yesterday at USENIX answering this exact question: Why Java is useful for building systems.

    He brought up these points:
    1. It's fairly old and mature compared to languages that are popular now such as Python.
    2. It has a strong type system. Inheritance is done better than in C++. Among other benefits, Java's typing system makes Java code more maintainable in large systems than almost any other language.
    3. Exceptions
    4. Garbage collection
    5. Efficiency. This goes back to it being mature. For a while the VM did incur significant overhead and Java programs were slower than C++ programs. Now a lot of that has been optimized and a well written Java program is comparable in performance to a well written C++ program, and significantly faster than python/php/ruby.
    6. Documentation. javadoc is awesome. doxygen for C++ is okay but it's an addon. python docstrings suck, and I don't know if php or ruby have any similar system.
    7. Concurrency: Java has tools that work for multithreaded programming.
    8. Portability: For the same version of Java, a Java application is binary compatible across platforms, including all its libraries. Certainly not true for C++ (though some libraries such as Qt do a great job for source compatibility).

    There were a few more points too, and he also pointed out the flaws with Java. The main point being though, it has ALL these characteristics, while many other languages have some.
    You can look at his slides here, though they are VERY simple and not of much use:

    It seems really silly to consider Java a toy but to take PHP/Python/Ruby/Perl seriously. Those are scripting languages that have their uses, but can't be used to build large maintainable codebases.

  14. Java is targeted at enterprises, and that shows in several ways:

    * You can distribute the compiles class files and not the source code.
    * Its support for namespaces (packages) is very good, and that makes it excellent for reusing libraries both internal and external.
    * The security model is very powerful (beyond what the JVM provides in terms of crash-prevention), and (beyond resource starvation) it's relatively safe to execute sandboxed untrusted code.

  15. The same thing can be said about C++ favouring COBOL. COBOL is far more stable, far better documentet and runs on far more platforms than C++. Not to even mention the near cryptic riddles of C++ compared to the near english syntax of COBOL...

    So why do anyone bother about using C++? I guess it's just as with Java: Because that's the way things have turned out. Accept it or not, it can't be changed in any easy way.

  16. Everything has its place. Java, however great it was when it came out, has come into overuse. Newer systems are out to replace it---for example, Mono/.NET---which are more efficient and have applied at least some of the lessons learned from Java.

    There isn't anything wrong with interpreted bytecode, in any case. It's just a matter of how efficient the bytecode interpreter and JIT system is. The more efficient the systems are, the better it is to use a bytecode-based VM as a code target. You can then use the VM as a sandbox for the code, and if the VM is designed with that in mind, it can perform some means of restricting code that isn't trusted, for example. As long as that sort of setup is in control of the end-user (as it is now), and not controlled by a company, it's all good.

    Java is relatively easy, but it's also heavy. The VM is slow to start up and initialize, the JIT is slow to be triggered in many cases, and while it was excellent stuff at one point in time, I think that Java should fall into disuse fairly soon. Then again, I think there should probably be only one major bytecode engine, and that will probably never happen. It is the nature of software to have many choices to fulfill a single task in different niches. :)

  17. Hi Nice Blog A quality, web development services company will have experience with many web sites similar to yours. They will have cut their teeth on past projects, and found the right approach that will ensure you get what you need, and to do so in an organized manner. Ask them to explain their project development methods, and project planning methods. You need to be convinced that not only do they have the ability to deliver your web site to you with all of your requirements met, but they have a plan on how get it done. On time and on budget.

  18. This comment has been removed by the author.

  19. Its highly informative. I would be visiting your blog hereafter regularly to gather valuable information.

    Feelance Web Design Portfolio India

  20. Thanks for this creditable information, I appreciate you. I really liked this nice blog.