The Artima Developer Community
Sponsored Link

Weblogs Forum
Java is Object-Oriented COBOL

35 replies on 3 pages. Most recent reply: Jun 1, 2011 11:25 AM by Larry Jackson

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 35 replies on 3 pages [ 1 2 3 | » ]
Steve Holden

Posts: 42
Nickname: holdenweb
Registered: Apr, 2003

Java is Object-Oriented COBOL (View in Weblogs)
Posted: Apr 1, 2004 2:21 PM
Reply to this message Reply
Summary
Why is this "new" language so annoyingly verbose? Why does it take so much code to express relatively simple ideas? Why is Java drowning in the complexity of its APIs?
Advertisement

Before I start I'd like to make it clear that this modest essay is not an attempt to get anybody to change their ways. I made my decision, and others are free to make theirs. You are free to criticize my inadequate knowledge of the language and my generally ill-informed approach. You will not be the first. The rest of the world may do as it chooses. I took up Java early, and left it early, in 1996 if I remember correctly. "I used to write in Java, but I'm all right now".

The language suffers from bloat at the API level. Last time I looked, I found a closely-printed book of over a thousand pages documenting the many and varied interfaces the programmer can use to do whatever he or she needs. I don't imagine this has been simplified or streamlined in the intervening years. In terms of learning curve, of course, this makes Java a little like Everest, and I suspect some people have climbed the Java learning curve for just the same reason as Everest.

When you get right down to it, Java seems to me to be a depressing language in which to attempt to become productive. I have no idea why ithas become as popular as it undoubtedly is, unless because of the dollars the Sun marketing communications team has spent winning "mindshare". Perhaps you really can fool all of the people all of the time.

Please note that I am simply trying to explain a personal distaste for the language, one which has been niggling at me for years now. I suppose it could be a matter of usage. I just saw this example used in the discussion of someone else's blog entry:

OldClassName newThing = new OldClassName();

So much Java is written like this. Java programmers actually seem to revel in this idiom, while for some reason its deliberate redundancy seems to jar my sensitive little soul to the point that I think if I see one more line of the form:

Thing aThing = new Thing();

I will scream. Java is so type-strict, surely the type of the result of calling the Thing() constructor can be inferred, making the type at the start of the declaration unnecessary? As if it weren't obvious enough just from the naming conventions. Perhaps the language is the way it is to allow for the possibility that one day some daring soul will write:

Thing aThing = new NotThing();

and a new metaphor will be born.

There are a number of other nits. Relative import and class path management has several of the same issues that Python is struggling with right now (see, I'm not a language bigot). While I understand the need for integer and Integer (and similarly for many other primitive types and their corresponding wrapers) for efficiency reasons, it certainly doesn't make Java easier as a first programming language which, God help us, for many recent beginners it is. Do we really have to design our languages with execution efficiency as a foremost consideration in the twenty-first century? ("Yes" is an acceptable answer to this question, by the way. Please give your reasons).

In fact, I'm beginning to suspect that the title of this piece does COBOL a disservice, because if you want to put a columnar report together then COBOL is a really easy language to do it in, with PICTURE declarations that allow you to control formatting down to the exact level you need. In Java nothing seems easy, despite the swathes of support libraries using sometimes-compatible interfaces, even though everything is possible. In the old days, everyone wrote commercial code in COBOL because it was so obviously the best tool for a wide range of tasks. Nowadays Java is the predominant langauge because ... ?

I'm not intending to be personally offensive to the many excellent Java programmers, though I do find it dperessing that Java seems to encourage mediocrity in programming. I am told that some Java "programmers" recently interviewed by a colleague couldn't write a simple for loop, which supports my suspicion that there are a lot of "cut-and-paste merchants" masquerading as programmers. Be that as it may, there are undoubtedly a lot of very intelligent people writing Java, better programmers than I will ever be. I just wish I knew why.


Ian Phillips

Posts: 8
Nickname: ianp
Registered: Oct, 2002

Re: Java is Object-Oriented COBOL Posted: Apr 1, 2004 2:42 PM
Reply to this message Reply
"Do we really have to design our languages with execution efficiency as a foremost consideration in the twenty-first century?"

No. See http://www.paulgraham.com/arc.html for a language being designed awith quite the opposite in mind.

Pete Lyons

Posts: 2
Nickname: petelyons
Registered: Jul, 2003

Re: Java is Object-Oriented COBOL Posted: Apr 1, 2004 3:19 PM
Reply to this message Reply
there are undoubtedly a lot of very intelligent people writing Java, better programmers than I will ever be. I just wish I knew why

For many developers Java is a stepping stone from the world of C and C++. Compared to those languages Java isn't verbose or restrictive at all. For many of those developer Java is their first taste of a language with built in objects and a garbage collector. It makes for a smooth transition.

Steve Holden

Posts: 42
Nickname: holdenweb
Registered: Apr, 2003

Re: Java is Object-Oriented COBOL Posted: Apr 1, 2004 5:22 PM
Reply to this message Reply
For many developers Java is a stepping stone from the world of C and C++

Fair point. Would you care to estimate the proportion of java developers for whom this is true? I can see that Java would seem attractive in some ways, but I'd say C was terser. And, of course, Java explicitly prohibits many of the things that C specifically used for in a systems environment (casts are easy in C, union types allow implicit conversion, and so on).

I may not be in touch with your average C programmer, but I'd have thought many of them use C precisely to get at these aspects of the systems they program.

I haven't used C++ enough to comment.

Greg Gaughan

Posts: 3
Nickname: ggaughan
Registered: Feb, 2003

Re: Java is Object-Oriented COBOL Posted: Apr 1, 2004 6:32 PM
Reply to this message Reply
> Thing aThing = new Thing();
> ...Java is so type-strict, surely the type
> of the result of calling the Thing() constructor can be
> inferred, making the type at the start of the declaration
> unnecessary?

The type at the start of the declaration is there for cases when the constructor is for a sub-class and you want your code to use polymorphism, e.g.
Shape s = new Square();
s.draw();

Where you want to be able to use s.draw() even if you decide to create a Circle or something else descended from Shape. Declaring s as Shape keeps its generality so you can use a common set of method calls to handle all Shapes and still have compiler-time type-checking.

By the way, I agree with your point: after using Python, Java and C# seem over-elaborate and less expressive. Far too many curly brackets, type specifiers and hard-to-remember libraries.

Javid Jamae

Posts: 16
Nickname: javidjamae
Registered: Jan, 2003

Re: Java is Object-Oriented COBOL Posted: Apr 1, 2004 7:02 PM
Reply to this message Reply

Variable Name
vvvvv
Thing thing = new NotThing();
^^^^^ ^^^^^^^^^^^^^^
Type Instantiation
Declaration

Are you saying that you would only get rid of the type declaration when you are declaring the type and instantiating the object in the same statement? What about when you are instantiating an object in a separate statement?


Thing thing;
.
.
thing = new Thing();

or

Thing thing = getOneOfThoseThings();


If you are arguing that the type declaration should go away all together, then it sounds like you are arguing that Java should be weakly typed. I disagree with that, but to each his own. I don't understand how you could maintain strong typing without type declarations. Then again, there are many things that I don't understand.

If you are not arguing that the type declaration should go away all together, but just when the variable is instantiated and declared in the same statement, then I would say that the only harm/difficulty is breaking an existing idiom.

Isaac Gouy

Posts: 527
Nickname: igouy
Registered: Jul, 2003

Re: Java is Object-Oriented COBOL Posted: Apr 1, 2004 7:54 PM
Reply to this message Reply
I will scream. Java is so type-strict, surely the type of the result of calling the Thing() constructor can be inferred, making the type at the start of the declaration unnecessary?

Yes, it's nothing to do with being type-strict, this works fine in other statically checked languages that run on JVM, like Nice and Scala and ...
   var conker = new Thing();

http://nice.sourceforge.net/index.html

> While I understand the need for integer and Integer
Why do we have to deal with this int/Integer nonsense in Java 1.5?
   List<Integer> myList = new ArrayList<Integer>();
   myList.add( new Integer(4875) );

The Nice version is... Nicer
   let myList = new ArrayList(); 
   myList.add(4875); 
 
   // now myList has type ArrayList<int>


> Do we really have to design our languages
> with execution efficiency as a foremost consideration in
> the twenty-first century?

For 2 or 3 languages yes, for the rest no - and wouldn't designing languages for efficiency mean designing clean languages with few special cases, like Oberon-2.

the title of this piece does COBOL a disservice
Yes it does. OO Cobol is Object Oriented Cobol. Some are choosing to move their mainframe apps to Cobol on .Net rather than rewrite them on J2EE.

Michael Feathers

Posts: 448
Nickname: mfeathers
Registered: Jul, 2003

Re: Java is Object-Oriented COBOL Posted: Apr 1, 2004 8:20 PM
Reply to this message Reply
All I can say is that if you think that Java is OO COBOL, you mustn't have seen VB.NET yet. To make an abstract class you use the keyword 'mustinherit.' To make an abstract method you use the keyword 'mustoverride.'

Malte Finsterwalder

Posts: 20
Nickname: jufoda
Registered: Aug, 2003

Re: Java is Object-Oriented COBOL Posted: Apr 2, 2004 5:38 AM
Reply to this message Reply
Yes, Java is verbose in a lot of ways. But it is in it's own way somehow consistent, when I think about it.

Why is Java used so widespread?
- Big companies are commited to Java.
- Java was or still is hype.
- There are tons of (cheap) Java developers.
- There are a lot of standardized libraries.
- There are a lot of other libraries (Open source as well as commercial).
- There are tons of tools. A lot of them are free, incl. the basics: compiler etc., IDEs
- Everybody else does it.

It boils down to: Java is mainstream

Are these good reasons? Decide for yourself...

Greetings,
Malte Finsterwalder

Wolfhart Bauer

Posts: 1
Nickname: wolfhart
Registered: Apr, 2004

Re: Java is Object-Oriented COBOL Posted: Apr 2, 2004 6:06 AM
Reply to this message Reply
> Yes, Java is verbose in a lot of ways. But it is in it's
> own way somehow consistent, when I think about it.

Why is everyone here suggesting that verbose code is a bad thing? When there is code that I do not understand, it's not because it's too verbose, but because it does not reveal its inner working by use of structuring, variable names etc. I could show you some Perl code that is absolutely not verbose but actually quite difficult to understand.

When I'm writing code, the bottleneck is not how fast I can type (luckily quite fast), but how fast I can think of what to do. However it may be different for others.

Maybe the question of verbosity is just a question of personal taste.

Dmitry Beransky

Posts: 2
Nickname: dberansky
Registered: Apr, 2004

Re: Java is Object-Oriented COBOL Posted: Apr 2, 2004 1:15 PM
Reply to this message Reply
I've shut myself in a foot so many a time in C, Perl, PHP and the likes that Java's imposed type strictness is nirvana to me. Wouldn't have any other way for an extensive, long run and intricate project. On the other hand, yes, if I need a quick, dirty and non-lasting solution, a dynamically typed language would be my choice. It always comes down to choosing the right tool for the job.

> Relative import and class path management

Relative import sounds like something potentially interesting, but I haven't had any problems with the current way of importing classes.

As far as path management goes... This has nothing to do with either Java or JVM. It's just how the bootstrap class loader is implemented. You can always write your own bootstrap code and load the classes from a database if you really want to.

> While I understand the need for integer and Integer (and
> similarly for many other primitive types and their
> corresponding wrapers) for efficiency reasons, it
> certainly doesn't make Java easier as a first programming
> language

this is moot with JDK 1.5's auto-(un)boxing feature.

> which supports my suspicion that there are a lot of
> "cut-and-paste merchants" masquerading
> as programmers

Yeh. what's your point? :) When a language matures and development commoditizes, that's what you get. I don't think one can escape this trend. In fact, when this does happen, it is IMHO an unmistakable sign that the language is ready for prime time use in serious enterprise level projects.

> Last time I looked, I found a closely-printed book of
> over a thousand pages documenting the many and varied
> interfaces the programmer can use to do whatever he or
> she needs. I don't imagine this has been simplified or
> streamlined in the intervening years

I agree that some of those libraries can use revisioning. However, let's not confuse the language with the libraries. The language is quite compact (at least pre 1.5) and easy to learn. But hey, if you want to use Java for sophisticated projects, you better use sophisticated libraries. If not, there's an abundance of much simpler libraries thanks to Java's vibrant developer community.

Johan Lindström

Posts: 3
Nickname: jplindstro
Registered: Jun, 2003

Re: Java is Object-Oriented COBOL Posted: Apr 2, 2004 2:24 PM
Reply to this message Reply
>Why is everyone here suggesting that verbose code is a bad thing?

Choosing good names for stuff (variables, methods, stuff) means there is an element of verbosity to begin with.

Verbosity in-the-language is bad because it adds to the size of the code while not adding to the descriptiveness.

This is important because reading and understanding code has to do, in part, with what you can see on a screen.

So verbose code isn't necessarily bad, but verbose languages probably are.

/J

Andrew Waddington

Posts: 4
Nickname: snstrk
Registered: Apr, 2004

Re: Java is Object-Oriented COBOL Posted: Apr 3, 2004 4:44 AM
Reply to this message Reply
Well I went from assembler to C to C++ and I have been learning java now for quite some time. The learning curve was stupendous. I think that this was largely due to the fact that the java api and libraries are immense.

Java would benefit from a new api called say, main, or something that had real simple versions of really useful classes, like LinkedList and Formatter, and Matcher, File, and DatagramSocket. Ideally I'd be able to learn those in less than a month. I've been at it for four years now, and I still spend half my day buried in the api docs.

C++? Well, heh, I loved the language but the STL made me run. If I had been able to specialise early, then c++ would have been joyful; alas, given a choice of the Xt toolkit or Qt widgets, I chose java. TCL has a lot of great features nowadays, maybe I would jump there, who knows?

You're right there is a lot of syntax and language cruft, but it is clean, and if well written, easy enough to read. I'm glad I didn't get nailed with Perl, anything that has more than two meta-characters in a row is really pushing the edges of the human parser.

What I am waiting for is the language that is written for somebody who works all day with an IDE. I've got 578 square inches of screen estate and I'm not even close to being able to see all the down-calls, I always have to flip through fifteen class files to determine that, yes, indeed, such and such does return a null value. I get the impression that fixing this sort of stuff, just isn't possible in any other language, so I stick with Java; hoping that someday, I'll be able to write findInList( myList, getLdapName( name = "cn=Andrew" ); and the *compiler* will identify and locate, on the net, an api that can take a List and an ldapname in a method findInList and link to it, put up the api-doc, comment out my code and replace it with something sane.

Ever notice that, no matter how great CPAN is, (it is good) you hardly ever see a powerful Perl-IDE?

Syntax is still king, and, if you read the JLS, you'd find that any language that can be accurately and precisely described in 16 sections, without monthly revision and addendae, is bound to be a really good thing.

Andrew

Marc Briand

Posts: 1
Nickname: marcopolo
Registered: Apr, 2004

Re: Java is Object-Oriented COBOL Posted: Apr 3, 2004 8:24 AM
Reply to this message Reply
I'm no Java fanatic, but I'm not sure Java's API is more bloated than that of any other general purpose language. You might argue that C and C++, with their standard libraries, have relatively modest APIs, but this ignores the fact that the standard libraries are inadequate for most real-world applications -- the developer will have to write his own APIs, or go out and find a third-party API to fill in what's missing. You have to put all that functionality somewhere, either in libraries or (ugh) in the language proper. (Maybe APL junkies would favor the latter approach, but I suspect most programmers would not.)

What matters to me is not so much the size of Java's API, but how well it is implemented. I can't say much about that, except to note that many of Java's classes have a bad case of memberitis. Maybe that's what you were talking about in the first place, so now I'll shut up.

Todd Blanchard

Posts: 316
Nickname: tblanchard
Registered: May, 2003

Re: Java is Object-Oriented COBOL Posted: Apr 5, 2004 1:34 AM
Reply to this message Reply
If you are arguing that the type declaration should go away all together, then it sounds like you are arguing that Java should be weakly typed. I disagree with that, but to each his own. I don't understand how you could maintain strong typing without type declarations. Then again, there are many things that I don't understand.

Could be arguing for dynamic typing, or type inferencing as seen in Haskell and the ML languages and friends. Personally I like dynamic typing but I see the advantages in type inferencing.

As type systems go, Java's is right out of the stone ages (along with its loop constructs, static methods that are really functions, classes that aren't objects, primitive types, arrays different from collections, StringBuffers that aren't Strings, and a whole host of other poorly thought out idiocies).

Java is gratuitously complex in a lot of areas - clearly the whole thing was a low budget rush job.

Flat View: This topic has 35 replies on 3 pages [ 1  2  3 | » ]
Topic: ScalaTest 1.6.1.RC1 for Scala 2.9.0 Released Previous Topic   Next Topic Topic: Programming Summer Camp: July 25-29 2011, Crested Butte, Colorado


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us