my dog learned polymorphism*
The moose likes Beginning Java and the fly likes java weakness Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java weakness" Watch "java weakness" New topic
Author

java weakness

Arun Prasath
Ranch Hand

Joined: Jul 18, 2006
Posts: 60
is there any weakness of java?
what are they if so?
Rao Raghu
Ranch Hand

Joined: Jan 05, 2007
Posts: 100
Well, I could find some here:
Strengths and Weaknesses
Java Lets Hackers Attack Your Browser




RAGHU<br /> <br />"When the going gets tough, the tough get going"
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14193
    
  20

My personal comments on Rao's links:

Strengths and Weaknesses - The strengths and weaknesses mentioned on that page are very vague. That page looks like it has been written by a highschool student, or at least someone who has only very basic knowledge of Java. The explanation he gives about "what Java is" looks very "1998". He is talking about applets ("Java is a computer programming language that shifts action from the server to the client") as if Java only consists of applets. Sorry, but in my opinion his Java Vision is BS. It doesn't have anything to do with how Java is used today. I wouldn't take this website too literally.

Java Lets Hackers Attack Your Browser - This is about bugs in Netscape Communicator versions 4.05 to 4.74, which is a very old browser that (almost?) nobody uses anymore. It is not relevant anymore today.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39053
    
  23
I am not convinced about some of the advantages and disadvantages on those websites. Obviously anybody can create applications with "holes" in, so the security issue applies to any language. There was slightly related discussion about two weeks ago on another forum here.

I would suggest the advantages include:-
  • Object-oriented programming is more likely to result in good coding; if it is done badly that is not the fault of the language.
  • One doesn't have to pay for it.
  • It is quite easy to learn. But programming remains difficult whichever language one uses.
  • Great availability of library classes.
  • Regular updates from SUN and others.
  • Rapid execution (early versions were very slow however).
  • The fact that Java is an "interpreted" language reduces security risks. See below.More discussion about interpreted languages here.
  • Portability from platform to platform with only very minor changes to the code.
  • . . . and some disadvantages
  • Platform-independence means it is not suitable for operating systems etc.
  • Retention of some syntactic features of non-OO languages (eg labelled break) which should no longer be used.
  • A superficial similarity to C and C++ which misleads some people into thinking the features all mean the same thing in all three languages. Not a problem to people who use Java only.

  • [edited for minor formatting problems.]
    [ March 06, 2007: Message edited by: Campbell Ritchie ]
    Rao Raghu
    Ranch Hand

    Joined: Jan 05, 2007
    Posts: 100
    @ Jesper Young

    Like questions, Like answers.

    Jesper de Jong
    Java Cowboy
    Saloon Keeper

    Joined: Aug 16, 2005
    Posts: 14193
        
      20

    Originally posted by Rao Raghu:
    @ Jesper Young

    Like questions, Like answers.


    I believe we should help people here as best we can, however "dumb" their questions might sound to you.
    Rao Raghu
    Ranch Hand

    Joined: Jan 05, 2007
    Posts: 100

    Originally posted by: Jesper Young
    I believe we should help people here as best we can, however "dumb" their questions might sound to you.


    I agree with you, Jesper. Those links were just a result of a quick search, just to quench the curiousity of the poster.
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 39053
        
      23
    Agree with Jesper Young.

    Another potential pitfall:
  • It takes some time to learn the difference between passing by value when you are passing a primitive type and when you are passing a reference type.

  • But other languages have problems. C has pointers, which are difficult to understand, and global variables, which are a potential source of nasty logic errors.
    Eiffel has a complicated system to deal with multiple inheritance, and doesn't use operators. Any "+" or "-" signs are "aliases" for calls to the "add" and "subtract" method.
    C# has overloaded operators. It has the advantage of the "for each" loop which was later introduced into Java as, "(for String s : stringArray) . . ."

    Every language constitutes a compromise between ease of use and functionality.
    Mark K
    Greenhorn

    Joined: Jan 20, 2007
    Posts: 5
    I am a raw beginner both on this forum and in Java. As an old top/down GWBASIC programmer who is trying to learn how to program in the modern world I see one HUGE advantage to Java...

    It is object oriented from the very beginning programming levels. I've looked at some other languages and bought books to attempt to learn them. I get started just fine and then, halfway through the book, they switch gears to object oriented programming. It screws up my whole thought process.

    I'm not sure about other books, but "Head First Java" starts you out learning about objects. My understanding is that everything is an object. It helps to learn this from the beginning. I'm not quite halfway through the book, but I've learned more about objects than ever before and much easier to boot! It actually helps clear up things that I was attempting to understand in other languages.

    So I guess the learning curve is not so steep. (I know, just wait for the next half of the book!)
    marc weber
    Sheriff

    Joined: Aug 31, 2004
    Posts: 11343

    Originally posted by Jesper Young:
    ...That page looks like it has been written by a highschool student, or at least someone who has only very basic knowledge of Java. The explanation he gives about "what Java is" looks very "1998"...

    I have to agree. It borders on ridiculous.


    "We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
    sscce.org
    pete stein
    Bartender

    Joined: Feb 23, 2007
    Posts: 1561
    C# has overloaded operators. It has the advantage of the "for each" loop which was later introduced into Java as, "(for String s : stringArray) . . ."
    IMO foreach seems more syntactic sugar than a true advantage.
    Most of the c# code I've seen avoids overloading operators. It seems much more common in c++ (again, IMHO), making such code more difficult to comprehend and debug.

    Another Java Advantage: Huge community of programmers / gurus / sites
    There's so much available on the web, you almost don't even need a book to learn.
    A disadvantage: I've not seen a GUI creator that can match that of Microsquish's Visual Studio.
    [ March 08, 2007: Message edited by: pete stein ]
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 39053
        
      23
    Quoted by Pete Stein
    Most of the c# code I've seen avoids overloading operators.

    . . .

    A disadvantage: I've not seen a GUI creator that can match that of Microsquish's Visual Studio.
    That shows that most C# programmers have enough sense to avoid using overloading. It is still used however, in a C# construct likeAnd as for Visual Studio. That is more a design feature of the IDE than of the language. C# doesn't use LayoutManagers; all GUI components are aligned by size and position, rather like using a null LayoutManager and setBounds() for all Components in Java. It is much easier to learn and implement, but has the disadvantage that Components can disappear off the GUI's bounds on resizing.
    Ilja Preuss
    author
    Sheriff

    Joined: Jul 11, 2001
    Posts: 14112
    Originally posted by pete stein:
    IMO foreach seems more syntactic sugar than a true advantage.


    The advantage is that you can change the type of a variable between an array, a collection and another implementation of Iterable, without having to change the looping code.


    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
    marcos rodrigues
    Greenhorn

    Joined: Mar 08, 2007
    Posts: 7
    garbage collector is not platform independent.
    Ulf Dittmer
    Marshal

    Joined: Mar 22, 2005
    Posts: 42031
        
      64
    garbage collector is not platform independent

    Can you elaborate on what you mean by that? The JVMs on all platforms have GC, without which Java wouldn't work. The inner workings of the GC are invisible to the user, and of little consequence, as long as it works effectively.


    Ping & DNS - my free Android networking tools app
    pete stein
    Bartender

    Joined: Feb 23, 2007
    Posts: 1561
    A couple of questions:
  • What do you think about c#'s implementation of events and delegates compared to java? Here I lean towards c#.
  • Has anyone used mono? Is it quite usable? Does it have a thriving community?
  • Is the java layout manager code base open? Has anyone tried to implement it in c# (just for grins)?

  • Thanks in advance!
    [ March 09, 2007: Message edited by: pete stein ]
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 39053
        
      23
  • Don't know
  • Don't know
  • LayoutManager is an interface; it hasn't got a code base. I am pretty sure you can get the code from the Java website. As for trying it in C#
  • Pj Murray
    Ranch Hand

    Joined: Sep 24, 2004
    Posts: 194
    Originally posted by Arun Prasath:
    is there any weakness of java?
    what are they if so?


    Not so much weaknesses as random observations:

    -different JVMs have subtle inconsistencies, and although Java is cross platform, you should really test crost platforms
    -there are several good things in C++ that didn't make it into Java, like memory allocation


    PJ Murray -
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 39053
        
      23
    I am not convinced that subtle inconsistencies between JVM implementations can be regarded as a drawback of the language. There are bound to be differences when the language is used on different platforms; I have half a Windows PC and half Linux PC here and I must careful to use platform-independent coding (eg %n rather than simply \n for newline in printf, pathSeparator rather than ";" and ":"), but it is one of those things we have to get used to.
    I have more difficulty with C code; I can write a little C app which runs happily on the Windows half of my PC only to have it crash dismally on Linux and vice versa.

    As for memory allocation, that is not too mush of a drawback. With OO programming you have all the memory allocation you need whenever you say "new." But the real problem is not "malloc," it is "free." It is very difficult, if not impossible, for a programmer to predict when objects will pass out of scope and out of reference so you can call their destructor or "free." The JVM's garbage collector which sweeps memory for unused objects periodically is a much more reliable means of memory management.
    Pointers (and hence malloc and free) were omitted from the Java language because they were considered too likely to cause confusion and difficulty.

    CR
    [ March 20, 2007: Message edited by: Campbell Ritchie ]
    Gregg Bolinger
    GenRocket Founder
    Ranch Hand

    Joined: Jul 11, 2001
    Posts: 15299
        
        6

    Windows Forms, which is MS's GUI API for the .NET platform, uses Docks and Anchors for their layout management. It's not quite as sophisticated as some of Swing's layout managers but it's good enough since Windows apps don't need to worry about any other platforms besides Windows.

    And FYI, Windows Forms is not just for C#. VB.NET uses it and you can use it with C++.NET if developing C++ managed code.


    GenRocket - Experts at Building Test Data
    Jesper de Jong
    Java Cowboy
    Saloon Keeper

    Joined: Aug 16, 2005
    Posts: 14193
        
      20

    Microsoft Visual Studio is a great IDE which has a very good GUI building tool. But there are also great and free IDEs for Java, such as Eclipse and NetBeans. NetBeans has a very good GUI builder, Matisse. Another very good GUI builder is WindowBuilder Pro (a commercial product) which not only supports AWT and Swing but also alternative Java GUI kits such as SWT (Eclipse's GUI toolkit). If you look at them you can see that Matisse and WindowBuilder Pro both stole some good ideas from Visual Studio...

    Another advantage of Java is that it is open; through the Java Community Process you can get involved in developing the Java language and platform yourself if you want. A language like C# is developed by Microsoft and there's no way you can contribute to C# or the .NET platform other than applying for a job at Microsoft. Sun's JDK is now open source too: see the OpenJDK website.

    Ofcourse there are some things that can be improved in Java. I like the way you can access properties in C#, without the need for getter and setter methods like we have in Java. There are people thinking about adding support for properties in Java (see this for example) but there are also people who think it's not necessary to have explicit support for properties (Why Java Doesn't Need Properties).

    One other feature that people are thinking about adding to Java are closures.

    I recently started picking up C++ again (I was a full-time C++ programmer until about 2000, when I became a full-time Java programmer). I still like C++, but I was immediately reminded that C++ is harder to use than Java. In C++, because you have to do all the memory management yourself, it is very easy to have memory leaks in your program that are hard to track down. Another thing is that if you want to be able to override a method in a subclass, you have to make the method virtual in the superclass explicitly, otherwise it won't work. Not making a destructor in a superclass virtual is also a mistake that can cause nasty and hard to find problems. In Java, those kind of problems don't exist.

    So a major advantage that Java has over C++ is that it is easier, you don't have to be aware of a whole list of subtle issues that may cause bugs and memory leaks in your program. Write a program in Java and write it in C++ and you will find that the Java version took you only half the time and contains fewer bugs.

    One more thing I like about Java is the rules it has for source files and packages; one public class (or interface) per source file, the file has to have the same name as the public class (or interface), the directory structure has to match the package naming. This makes it very easy to find the source file for a particular class. Try looking at a large C++ project - it's much harder to make sense out of a whole bunch of source files and it's much harder to find the declaration and implementation of a class.
    [ March 21, 2007: Message edited by: Jesper Young ]
    Pj Murray
    Ranch Hand

    Joined: Sep 24, 2004
    Posts: 194
    Originally posted by Campbell Ritchie:
    I am not convinced that subtle inconsistencies between JVM implementations can be regarded as a drawback of the language.

    [ March 20, 2007: Message edited by: Campbell Ritchie ]


    Sorry, yes you are right.

    The fact that the various JVMs are different and operating systems are different does not change the fact that Java is the same.

    My real point was that if you want to take advantage of the fact that Java is multi platform - like many ISVs do - you do in fact have to still test your software on multiple JVMs and multiple operating systems (or even multiple versions of operating systems).

    An minor example of the sort of things that can have an impact you is the licensing system in my company's product relied on encryption technology in Sun's JDK. That meant it could not work on IBM's JDK, which in turn meant that it could not run on SUSE Linux.

    If your target application is running on a specified JVM and operating system, then you don't need to worry about this.

    Either way, as Campbell correctly pointed out, it is not a weakness of Java as a programming language.
    fred rosenberger
    lowercase baba
    Bartender

    Joined: Oct 02, 2003
    Posts: 11351
        
      16

    Not to belabor the point, but I hate questions like this. "What are the weakneses of a hammer?"

    Let's see...

    1) it can't turn a screw.
    2) It's really hard to cut a 2x4 with it neatly.
    3) It won't play my mp3 files.

    There are probably a few others...

    A computer language is the same thing. It is a tool. It has it's uses. It does things it is designed to do pretty gosh darn well. The things it wasn't designed to do... it probably could do them, but it wouldn't be pretty. Just like the end of that 2x4 i cut with my hammer.


    There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
    pete stein
    Bartender

    Joined: Feb 23, 2007
    Posts: 1561
    To quote Bjarne Stroustrup:
    "There are only two kinds of languages: the ones people complain about and the ones nobody uses".
    James A Anderson
    Greenhorn

    Joined: Mar 02, 2007
    Posts: 12
    I'm not one of them, but I've read and heard of many former Java developers who have fled to the dynamically typed world of Ruby (especially w/Rails) and similar platforms that would say that a weakness of Java is that it is statically typed and also that it takes too long to build complex working programs.

    As I said, I am not a member, but the community of test-driven, interpreted-language developers that claim compilers are evil and on their way out is growing.

    Personally, I'm old school and can remember not too long ago when "strong" typing was considered a strength, not a weakness.
    pete stein
    Bartender

    Joined: Feb 23, 2007
    Posts: 1561
    Originally posted by James A Anderson:
    I'm not one of them, but I've read and heard of many former Java developers who have fled to the dynamically typed world of Ruby (especially w/Rails) and similar platforms that would say that a weakness of Java is that it is statically typed and also that it takes too long to build complex working programs.
    ........
    Personally, I'm old school and can remember not too long ago when "strong" typing was considered a strength, not a weakness.

    Please correct me if I'm wrong, but I thought that Ruby, like Python is a strongly typed language. They both may be dynamically typed, but they are (I think) strongly typed too. This is as opposed to Javascript and C which are weakly typed. My reference is this.
    [ March 22, 2007: Message edited by: pete stein ]
    James A Anderson
    Greenhorn

    Joined: Mar 02, 2007
    Posts: 12
    Pete,

    That is an interesting article. I was using "strongly" typed to be synonymous with statically typed, which apparently is not technically correct, althought the article does note that "static typing almost always goes hand in hand with strong typing.".

    The article also seems to contradict itself somewhat. It explains the difference between strong and weak typing with a code example:



    explaining that, Perl is weakly typed because it will perform an implicit conversion and Ruby is strongly typed because the code will generate a TypeError.

    However, later it lists Java as a strongly typed language. But in Java, can't you write:
    ?

    That being said, I believe my original statement of Java being statically typed and Ruby being dynamically typed is still true and my point about the movement towards dynamically typed languages (good or bad) valid.

    [ March 23, 2007: Message edited by: James A Anderson ]
    [ March 23, 2007: Message edited by: James A Anderson ]
    Ricky Clarkson
    Ranch Hand

    Joined: Jul 27, 2006
    Posts: 131
    A weakness of Java is that it tries to prevent you from making mistakes. You'll still make the same mistakes, just in different, more subtle, ways, and learn more slowly.

    It's not the job of the language to constrain you. That's your job (you as a collective). You can constrain yourself; prevent yourself from making mistakes, but the language is too static to know how to do that. Best practices change.
    [ March 23, 2007: Message edited by: Ricky Clarkson ]
    marc weber
    Sheriff

    Joined: Aug 31, 2004
    Posts: 11343

    Originally posted by Fred Rosenberger:
    Not to belabor the point, but I hate questions like this. "What are the weakneses of a hammer?"...

    Not to belabor the point even further, but now that tape measures are being used, the hammer is a dead tool.
    fred rosenberger
    lowercase baba
    Bartender

    Joined: Oct 02, 2003
    Posts: 11351
        
      16

    Originally posted by marc weber:

    Not to belabor the point even further, but now that tape measures are being used, the hammer is a dead tool.


    real coders keyboard
    marc weber
    Sheriff

    Joined: Aug 31, 2004
    Posts: 11343

    Originally posted by Fred Rosenberger:
    ...real coders keyboard

    Now we're getting somewhere!
    pete stein
    Bartender

    Joined: Feb 23, 2007
    Posts: 1561
    Originally posted by James A Anderson:
    Pete,
    The article also seems to contradict itself somewhat. It explains the difference between strong and weak typing with a code example:



    However, later it lists Java as a strongly typed language. But in Java, can't you write:
    ?


    There's a difference here though. In Perl print "2" + 4 will result in the int 6. in java if you do the S.o.p("2"+4) you get the string "24". I think there is a subtle but significant difference between a string changing to an int without explicitly converting it vs an int converting to the Integer object and calling Integer.toString().
    James A Anderson
    Greenhorn

    Joined: Mar 02, 2007
    Posts: 12
    Sure, Perl works differently than Java, but in this case they both perform implicit conversions (albeit different ones) which the article claims is the definition of weak typing.
    James A Anderson
    Greenhorn

    Joined: Mar 02, 2007
    Posts: 12
    Originally posted by marc weber:

    Not to belabor the point even further, but now that tape measures are being used, the hammer is a dead tool.


    It's a legitimate beginner forum question. In order to choose the best tool for a job, you need to know the strengths and weaknesses of the tools that are available to you.

    The hammer analogy doesn't translate very well to a field as complex as software engineering. Hopefully, software development tools have more numerous potential applications than a hammer does and therefore the decision of which one to choose isn't as straightforward.
    marc weber
    Sheriff

    Joined: Aug 31, 2004
    Posts: 11343

    Originally posted by James A Anderson:
    ... It's a legitimate beginner forum question...

    Yes, I can appreciate the question. To me, it's some of the answers that usually lead these things down a dubious path.

    When advice is given along the lines of, "Now that .NET has arrived, Java is a dead language," or, "Java is no longer viable because applets are a thing of the past," well... These types of over-reaching declarations fail to acknowledge how subjective -- and contextual -- the question really is.

    So I think the discussion here about typing is quite valuable, because it illustrates the subjectivity behind some of the factors that should be considered.
    Ilja Preuss
    author
    Sheriff

    Joined: Jul 11, 2001
    Posts: 14112
    Originally posted by James A Anderson:
    the article does note that "static typing almost always goes hand in hand with strong typing.".


    Which is total nonsense. C, for example, is statically and weakly typed. (I think in modern C++ you can choose between weak and strong typing to some degree.)
    James A Anderson
    Greenhorn

    Joined: Mar 02, 2007
    Posts: 12
    Originally posted by marc weber:

    Yes, I can appreciate the question. To me, it's some of the answers that usually lead these things down a dubious path.

    When advice is given along the lines of, "Now that .NET has arrived, Java is a dead language," or, "Java is no longer viable because applets are a thing of the past," well... These types of over-reaching declarations fail to acknowledge how subjective -- and contextual -- the question really is.

    So I think the discussion here about typing is quite valuable, because it illustrates the subjectivity behind some of the factors that should be considered.


    Okay. I understand. Such broad topics can prompt a variety of irrelevant replies.
    Garrett Rowe
    Ranch Hand

    Joined: Jan 17, 2006
    Posts: 1296
    One weakness of Java IMO of course is that it doesn't support tail call optimization.


    Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
    Gavin Tranter
    Ranch Hand

    Joined: Jan 01, 2007
    Posts: 333
    Hi all,
    Well time to throw my 2pence worth in on a couple of points as I have code in both languages.

    In general I think Java has the edge, but not for any huge reasons, and most can be considered personal taste but:

    Open Community,
    Plenty of choice of tools.
    Sensible file format (i have seen people abuse the more then one public class per file in C#).
    Enforced package/physical space set up.
    Sets in the collection framework.
    No Properties.
    Distiction between interface and abstract class (I not sure if C# has this)
    appropritly more verbose, i.e extends rather then :
    Overriding of methods is automatic, no need to add : override. (not sure if i like this @override in java)
    No pass by reference. (you can pass by reference in C#)
    Primitives, I happen to think they are a good thing.
    Java Enums are better.
    No Structures.

    There seems to be less relience on visual tools in Java (maybe thats just me) which I think is good, because it gives you a better understanding. (i did initial learn how to use the C# compile from teh command line cos we didnt have access to VS), it wasnt easy, but its easy to write Java code with textpad and the JDK another advantage of Java.

    There is probably more but these are thing I like about Java and missed like hell when I went to C#, no I am back in Java i dont miss anything from C# and I am enjoying coding again. This is a sign of a good language. For some that will mean C# for me it means Java.

    I have written some aweful C# code that I would never dream of doing in Java, for example using null with "primitive" data types which requires a special "marker" to be used.

    G
    Dhineshkumar raj
    Greenhorn

    Joined: Aug 06, 2007
    Posts: 28
    Originally posted by Jesper Young:

    I believe we should help people here as best we can, however "dumb" their questions might sound to you.


    Yes i Agree with this.
     
    GeeCON Prague 2014
     
    subject: java weakness