The Artima Developer Community
Sponsored Link

Weblogs Forum
The departure of the hyper-enthusiasts

262 replies on 3 pages. Most recent reply: Dec 20, 2006 11:11 AM by Carlos Neves

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 262 replies on 3 pages [ « | 1 2 3 ]
Bruce Eckel

Posts: 875
Nickname: beckel
Registered: Jun, 2003

Re: The departure of the hyper-enthusiasts Posted: Dec 30, 2005 11:17 AM
Reply to this message Reply
Advertisement
Well, I'm sorry that because I effectively said "Ruby and Rails are making valuable contributions to the programming community" rather than "Ruby/Rails are the way and the light and only through them shall you achieve salvation" that this whole thing has devolved as much as it has. But as I said before, I think that the vitriol from the Ruby hyper-enthusiasts proves my point -- I'm not seeing that kind of aggression so much in the Java community anymore, so I'm theorizing that those folks have moved on from Java, and as far as I can tell (and from the flames appearing on this discussion) they have moved to Ruby. I never cared for that attitude in the Java community, and it doesn't attract me to the Ruby community. And I've personally seen very little of it in the Python community.

And attacking Alex -- especially without paying any attention to his deep understanding of programming languages in general and Python in particular, and his contribution of two of the best books on Python (when I travel light and I need Python books, "Nutshell" and "Cookbook" go in first) -- and then claiming he behaves badly after you piss him off (although, Alex, you have to admit that it's like throwing gasoline on a fire; it almost looks like you're enjoying the process of cranking these people up) is juvenile.

I certainly don't think everyone in the Ruby community is a hyper-enthusiast who migrated there from Java. And I don't think Ruby is "bad," but I want to try to understand it more deeply than I'm getting from "If it's in Ruby, then it is by definition good" (for example, saying that because having two different methods that do exactly the same thing is in Ruby's list class, it must by definition be brilliant, rather than observing that it was probably an early mistake -- after all, it violates Dave & Andy's DRY principle). For example, the fact that Ruby might make metaclass programming easier than it is in Python is quite interesting to me.

I'll also point out that I know Dave and Andy and respect their (ordinary, not hyper) enthusiasm about the language; their interest (and Martin Fowler's) is what made me become interested in the language in the first place.

I do want to know more about it, but I want to know the REAL stuff, not the religious dogma. For example, THIS is the kind of useful gem that it's been worth having this discussion for:

> Yep. Essentially, a statement such as "x = y" in Python
> always parses to "bind name 'x' to the same object to
> which 'y'" is now bound. In Ruby, it can parse to that OR
> to "call method y without arguments and bind name 'x' to
> the object that is the result of that call"; you cannot
> tell without looking more widely beyond that statement, in
> order to learn whether y is a method or a variable.
> Similarly, in Ruby you cannot know, without looking more
> e widely, if 'x=y' or 'x=y()' mean the same thing or not;
> if y is both a local variable and the name of a method,
> then both syntax forms are correct, and mean different
> things -- if y is just a variable, the second form is
> incorrect -- if y is just a method, both forms are correct
> and mean the same thing.

This points out something essential about the language, and gives me a sense of the fundamental philosophy. And I think it could be something that will cause problems in code as things scale up (don't bother replying with an argument if all it amounts to is "no it won't."). This is the kind of thing that I'd like to see in a fundamental analysis of Ruby, ideally in a comparison with Python.

PS: My apologies to your employers at Google, Alex, if this whole thing has impacted your productivity.

Dave Mason

Posts: 1
Nickname: dmason
Registered: Jan, 2006

Re: The departure of the hyper-enthusiasts Posted: Jan 2, 2006 7:06 AM
Reply to this message Reply
Sigh.

This has been an interesting series of comments, despite the vitriol, flaming and ad-hominem attacks. I've learned a lot. I probably would have learned even more if I hadn't started ignoring the most rabid of the writers.

As to the putative subject, I'll say more in a moment, but first a few comments about typing and syntax.

I'm a programming languages researcher who has programmed
20K+ lines of code in each of a handful of languages, including C, Scheme, ML, Java and a few assembly languages, and at least a few thousand lines in each of a dozen other languages (including Ruby and Smalltalk). I like some aspects of statically-typed languages and I like some aspects of dynamically-typed languages. Unfortunately, because of the covariance/contravariance problem, all OO languages are ultimately dynamically typed (although generics/parametric-polymorphism can help). While in a powerful static-typed language like ML (SML, CaML) you can't get type errors, you can still get subscript (and other) range errors. So because even the best type systems can't give me absolute guarantees about run-time errors, I've become a huge fan of unit tests - and then static typing can become pretty irrelevant.

What's generally called syntax is essentially what can be recognized by a context-free-grammar in a compiler. Syntax differences are, in some sense irrelevant (syntactic sugar) but one of the areas that programming language people focus on is cognitive-load - how much crap you need to keep in your head to implement the algorithm that's in your head. From this perspective, Ruby has one of the lowest cognitive loads that I've come across. Even the @ for instance variables and @@ for class variables that I would normally complain about actually seem to have the right level of assistance with that mental load. The only thing I have a problem with is the interaction between implicit variable definition and scopes, although it sounds like Python gets it much more wrong.

I don't know Python, although I've learned quite a lot about it and gotten a lot of the flavour of it through this discussion. I've been using Ruby since the summer, and I quite like it. Despite (or perhaps because of) my 30 years of programming experience and plethora of languages, I found the learning curve for Ruby+Rails to be surprisingly steep (but then, I like to understand a language before I start using it, rather than a just-in-time acquisition).

As for the hyper-enthusiasts: who cares??? They're mostly what I'd call the yammering classes... book authors, magazine columnists, and consultants; all of whom, by definition, need to be on to the New And Improved in order to sell books or magazines or be seen as having valuable knowledge.

But I think that most of the people that got caught by Bruce's wide net are just enthusiasts who have found a productive new way to get their jobs done. The Ruby fans probably don't know Python and vice versa. That's a shame. It sounds like there's a few good ideas in each language that may or may not be easily added to the other. Perhaps we do need a new language that captures the best of all of these languages, but in the meantime, let's enjoy programming with the best tools we can find.

Marcelo Barbero

Posts: 5
Nickname: mbarbero
Registered: Dec, 2005

Re: The departure of the hyper-enthusiasts Posted: Jan 3, 2006 9:10 AM
Reply to this message Reply
> Syntax or not, the difference between Python and Ruby are
> more than trivial. You could argue that English and
> Spanish are equivalent because it's possible to translate
> an expression from one into the other. But that's hardly
> the end of the story. For example, to say, "I dropped my
> watch" in Spanish, you might say, "se me cayo el reloj".
> You won't appreciate the nuance of that phrase without
> understanding Spanish. And that nuance may or may not be
> important in context.
>

If the translation is well done, "se me cayo el reloj" means that it's un-intentional. If it was intentionally done, it would be "tire el reloj".

Brian Ford

Posts: 153
Nickname: brixen
Registered: Dec, 2005

Re: The departure of the hyper-enthusiasts Posted: Jan 3, 2006 10:02 AM
Reply to this message Reply
> If the translation is well done, "se me cayo el reloj"
> means that it's un-intentional. If it was intentionally
> done, it would be "tire el reloj".

Exactly. ;) And Spanish seems to capture more simply than English, in this construction that is used in many contexts, the intentionality.

An interesting comparison between Python and Ruby is how the languages look at objects. It's been said that "everything's an object in Ruby", and of course, Pythonistas respond, "yeah, same as in Python". Here's the difference that I see: in Ruby, the object is, arguably, primary above control structures; not so in Python. Let me illustrate.

In Ruby, iteration is very commonly performed by:
obj.each { |arg| do_something }
and there are other ways of iterating like
10.times { |arg| do_something }
or
1.upto(10) { |arg| do_something }

We know that in a sentence, there are two places of natural emphasis, the beginning and the end. In Ruby, by placing the object in a natural place of emphasis, I think it encourages the programmer to think of the object first, and think of interacting with objects and how objects interact. Iteration is no longer a special control structure, but just another way of interacting with an object or collections of objects.

Remember when Python got generators? The way to interact with those was the for loop construct. In this way, to me, Python seems to emphasize the control structure over the object.

As a previous poster has pointed out, there is the concept of congnitive load. In the way that, to me, Ruby emphasizes objects and harmonizes the way of viewing them conceptually, it reduces the cognitive load vis-a-vis Python or Java or C, etc.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: The departure of the hyper-enthusiasts Posted: Jan 3, 2006 11:10 PM
Reply to this message Reply
> We know that in a sentence, there are two places of natural emphasis, the beginning and the end.

Natural? Languages (spoken and computer) are completely artificial. There is nothing natural about them. However, that isn't really relevant, since your analogy falls apart completely. None of the three examples you gave even close to how such a thing would be verbalized. "Ach! The air is low in my bike tire. I guess I should 10.times { |the_pump (or the tire?)| } pump }." Well, gosh, yes, I suppose you are right after all.

Anyway, the whole "my language is more object-oriented than yours" is a silly computer-nerd kind of argument. In some cases (like native types in Java), there is a some very annoying friction caused by the fact that you have to treat types differently, but this argument is a non-starter between two languages like Ruby and Python (or were you talking about Python 1.5.2?).

Your whole argument here is 100% subjectivity. For example, maybe it seems to me that a more natural way of thinking of things is as processes, not objects. A lot of really clunky stuff you see in OOD is around trying to encapsulate processes in objects. (These are usually the cases where you get really strange and ill-fitting object names, too.) Getting too fixated on making everything an object versus making good software is going down the wrong path.

Kay Schluehr

Posts: 302
Nickname: schluehk
Registered: Jan, 2005

Re: The departure of the hyper-enthusiasts Posted: Jan 3, 2006 11:43 PM
Reply to this message Reply
> In some cases (like native types in Java),
> there is a some very annoying friction caused by the fact
> that you have to treat types differently, but this
> argument is a non-starter between two languages like Ruby
> and Python (or were you talking about Python 1.5.2?).

Even in Python 0.9.2 ( released 1991 ) you noticed the difference between types and classes only when you tried to inherit from "types". There was no lack of interoperability: you did not have to wrap an int by hand in order to put it into a vector ( i.e. list, tuple ) as you have to do in Java. Serialization didn't fail because only objects can be serialized but not elementary types etc. Inheritance needed a workaround that is still reflected by now legacy classes UserList, UserDict etc. in the standard library. I started using Python with v1.5.2 and at that time I did not even noticed the type/class difference to be a wart. It did not have a large impact on my programming practice.

Kris Lightsey

Posts: 1
Nickname: kalyson
Registered: Jan, 2006

Re: The departure of the hyper-enthusiasts Posted: Jan 4, 2006 2:31 AM
Reply to this message Reply
I have learned a lot from reading these posts in spite of the personal nature of some of them. Alex M.'s attacks on Brian seemed to be particularly vicious -- rather uncalled for, in fact. I'm not a Ruby programmer, but I can easily see where someone would see the "hyper-enthusiast" label and the original article as being derogatory and even incendiary.

Witness this:
"The Java hyper-enthusiasts have left the building, leaving a significant contingent of Java programmers behind, blinking in the bright lights without the constant drumbeat of boosterism. [...] Where did the hyper-enthusiasts go? To Ruby, apparently."

and this:
"...we know the hyper-enthusiasts have moved to Ruby because of the howls of protest at Harold's opinion [...] We can identify hyper-enthusiasts because the arguments have a strongly faith-based flavor to them..."

Not exactly a positive portrayal, certainly.

Still, it sparked an interesting discussion that has been useful to me.

I appreciated Brian's comments, actually, and do not see where they warranted such vituperative responses. From an objective standpoint (I know none of these people), I do not see that his posts have been as negative or injurious as some seem to think.

For someone to assert they would not want to learn a language because they disliked the posts of an individual or even several individuals on a single thread of a given bulletin board is bizarre.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: The departure of the hyper-enthusiasts Posted: Jan 4, 2006 8:45 AM
Reply to this message Reply
> For someone to assert they would not want to learn a language because they disliked the posts of an individual or even several individuals on a single thread of a given bulletin board is bizarre.

Yeah, he was a little bit tart, which is not uncommon in internet forums, but it did seem like the reaction was disproportionate.

It is kind of strange from a sociological point of view that people often seem to be more aggressive/assertive/arrogant when posting to forums than they would be in person. Kind of like how the same person who will be very courteous when on foot (holding the door for you when it isn't really necessary), will be very rude (even ruthless) when behind the wheel of a car.

Bruce Eckel

Posts: 875
Nickname: beckel
Registered: Jun, 2003

Re: The departure of the hyper-enthusiasts Posted: Jan 4, 2006 9:11 AM
Reply to this message Reply
> A lot
> of really clunky stuff you see in OOD is around trying to
> encapsulate processes in objects. (These are usually
> the cases where you get really strange and ill-fitting
> object names, too.)

This is an excellent point. Objects appear to be designed around a single-process model, and much pain has ensued when trying to combine objects and processes. Threads, for example, are a low-level C-ish construct that have been shoehorned into OO languages because some people already knew threads, so that seemed the logical step to take. But you get a sense of orthogonality about threads in, for example, Java. There's an abrupt shift between objects playing nicely with each other vs. threads tromping around and causing havoc. Most (all?) OO languages seem to have acquired processes by assimilation rather than through insight.

The only thing I've seen that shows promise as an OO process model is Active Objects/Actors. On the other hand, I haven't seen how Erlang deals with objects -- or does it support objects?

Brian Ford

Posts: 153
Nickname: brixen
Registered: Dec, 2005

Re: The departure of the hyper-enthusiasts Posted: Jan 4, 2006 12:47 PM
Reply to this message Reply
> Natural? Languages (spoken and computer) are completely
> artificial. There is nothing natural about them.
> However, that isn't really relevant, since your analogy
> ogy falls apart completely. None of the three examples
> you gave even close to how such a thing would be
> verbalized.

Well, natural language is a term used to distinguish what we usually use in communicating from something more artificial, like a computer programming language.

Perhaps "we know" was too strong. I'll restate: congnitive psychology suggests that there may be, in arrangements of things, say words forming a sentence, places where our brains perceive or remember something more clearly. In writing courses, we're taught that those places are, usually, the beginning and end of a sentence.

Now, for the big leap that completely falls apart: when I program in Ruby, writing or reading (but not necessarily verbalizing, although I've found Ruby to verbalize pretty good), I find that thinking object then method helps me focus on the objects over control structures. I find the opposite mostly, but not always, true in Python.

>
> Anyway, the whole "my language is more
> object-oriented than yours" is a silly computer-nerd kind
> of argument.

I think you missed my point. I was trying to say this wasn't an issue of 'more object oriented' but rather an issue of how you think about objects and control structures in the two languages. It's an area where I definitely perceive, however subjectively, a difference between Python and Ruby. I like exploring those differences to better understand this thing we create called languages.

> Your whole argument here is 100% subjectivity.

Yes, of course, 100%. I wouldn't claim otherwise.

> For example, maybe it seems to me that a more natural way of
> thinking of things is as processes, not objects. A lot
> of really clunky stuff you see in OOD is around trying to
> encapsulate processes in objects.

What have you found useful in addressing this in terms of languages, design processes, etc.?

Gregg Wonderly

Posts: 317
Nickname: greggwon
Registered: Apr, 2003

Re: The departure of the hyper-enthusiasts Posted: Jan 4, 2006 1:32 PM
Reply to this message Reply
> > For example, maybe it seems to me that a more natural way of
> > thinking of things is as processes, not objects. A lot
> > of really clunky stuff you see in OOD is around trying to
> > encapsulate processes in objects.
>
> What have you found useful in addressing this in terms of
> languages, design processes, etc.?

The typical thing that I see is that process control is lumped in with the objects themselves. As participants, they are interfaced with the system as controllers rather than players.

I found an instance of this in a system critical procedure associated with a telephone switch as described in my blog
http://www.artima.com/weblogs/viewpost.jsp?thread=4350. That's a very old issue, but I still see the same thing. Because a control structure doesn't exist. We tack on little bits and pieces to existing objects to do new things, instead of having a process control structure with players from the start.

I don't provide any real details in the blog about what the designed system did, but basically it provided the ability to declare sequences of steps that you would provide objects to carry out. There was no visibility between steps of any programatic linkages/references.

This really simplified the ugly control structure that was in place, and it made it a lot easier to do simple procedures.

After I left (in 1997) the control system was reused for a number of procedures related to maintainence and upgrading hardware. I still saw it in use last year when I went back to visit some old friends, so that made me feel good about doing something that really did work.

I've been thinking about creating a new process control system in Java for some human based process control that I need.

On another related note, the upcomming availability of the scripting engine in Java, will likely cause people to start using that facility for process control because of it's perceived simplicity in mutability and simplicity.

We'll see how that works out...

Mike Petry

Posts: 34
Nickname: mikepetry
Registered: Apr, 2005

Re: The departure of the hyper-enthusiasts Posted: Jan 4, 2006 1:52 PM
Reply to this message Reply
There is an interesting posting at javajunkies.org on RoR vs Java. http://www.javajunkies.org/index.pl?node_id=483&parent_node=4523.


Also for check out this blog entry for an essay on threads as objects. http://mikepetry.blogspot.com/2005/03/temporal-anamolies.html

piglet

Posts: 63
Nickname: piglet
Registered: Dec, 2005

Java / Ruby comparison Posted: Jan 4, 2006 2:29 PM
Reply to this message Reply
Thanks for the link to Andrew Glover's piece. I wrote Andrew the following:

-----
I found your Ruby-Java comparison interesting (http://www-128.ibm.com/developerworks/library/j-ruby/?ca=dgr-lnxw06RubyOffRails), however I have to point out (I’m sure I’m not the only one) that your Java example is artificially verbose and thus the comparison is not quite realistic. I do recognize that some of the verbosity is inevitable – the declaration of getters and setters instead of the attr_reader syntax (really elegant), and the lack of default parameters in Java (a step backwards from C++) which forces us to overload more often than necessary. But apart from those two nontrivial differences, the Java example needn’t be as long. Here are my suggestions:

1. import java.util.*; // instead of three imports
2. private Collection definitions = new ArrayList(); // instead of an extra line in the constructor
3. The null checks in Java are your choice, they are not mandatory. You could leave them out, just as you could add them to your Ruby code.
4. Your validateRelationship() method doesn’t validate anything. You could replace it with def.setWord(this); , just as in Ruby. The check def.getWord() != this is redundant, too (in both examples).
5. You left out the addExampleSentence() method in Ruby.
6. Most of your this references in Java are optional.

As mentioned above, the surplus code in Java is due to the getters and setters and to the overloaded constructors. The first are inevitable, except that some setters may be redundant – immutability is often sounder. However, most java coders just write all the setters without thinking (spoiled by Mr. Bean, I guess). Writing them is no pain thanks to IDEs but they do clutter the code, in my eyes.

As to the constructors, they are also a matter of choice. Sometimes you just have to code so many constructors but often, it is a better choice not to provide them. Is it probable that a word will be initialized already with a ready list of definitions? It depends on the semantics of your use cases (where you get the data from and in what order) but I suspect in this example you would rather go for the add method, which also provides control over input types (I’m leaving J5 generics aside for now).

Collections: “Ruby's collections handling is amazingly simple too -- The << syntax is overloaded to mean add. If you look back to the Definition class in Listing 2, you'll see that the corresponding code in the Java language is a much bigger mouthful.” Excuse me?

@definitions << definition (Ruby) versus
definitions.add(definition); //Java
Now that’s a big difference! That almost convinced me to go into the desert and repent my Java sins ;-)

There is really no difference, add() in Java is overloaded too, as is addAll() (instead of the + operator in Ruby). So I think, at this point you really have let yourself take away by the hype. If Ruby collections are “done right”, so are Java collections.
-----

Andrew's response: "Thanks for the feedback. You are correct, the mouthful comment was a bit of an exaggeration. Happy New Year! "

Eivind Eklund

Posts: 49
Nickname: eeklund2
Registered: Jan, 2006

Re: Java / Ruby comparison Posted: Jan 5, 2006 2:18 AM
Reply to this message Reply
WRT the last post, I find that most of the difference is from Java requiring that there's type declarations everywhere.

As for the original article: My strong impression is that there have been no core people moving from either Perl or Python to Ruby.

As for the hypers: I think they're new people for each language, though I'm much less sure of that.

Eivind.

piglet

Posts: 63
Nickname: piglet
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 7:41 AM
Reply to this message Reply
"WRT the last post, I find that most of the difference is from Java requiring that there's type declarations everywhere."

In my post, I was taking issue with the claim that Ruby syntax is more "terse". The author clearly exaggerated this by making the Java code unnecessarily verbose. Of course you are right concerning type declarations, however, this doesn't count as verbosity for me. In my feeling, code doesn't take longer to read because of type declarations. Proponents of dynamic languages tend to identify the readability/complexity issue with number of characters, which is plain stupid. What is important is the number of logical entities that you have to keep in mind in order to understand the code, not the number or lengths of words to read. Type declarations actually reduce complexity because the reader doesn't have to try to infer what the code is about. Whatever may be the benefits of dynamic typing, readability is clearly not among them. I wish that we could get at least that one straight.

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 8:08 AM
Reply to this message Reply
"In my post, I was taking issue with the claim that Ruby syntax is more "terse". The author clearly exaggerated this by making the Java code unnecessarily verbose. Of course you are right concerning type declarations, however, this doesn't count as verbosity for me. In my feeling, code doesn't take longer to read because of type declarations. Proponents of dynamic languages tend to identify the readability/complexity issue with number of characters, which is plain stupid. What is important is the number of logical entities that you have to keep in mind in order to understand the code, not the number or lengths of words to read. Type declarations actually reduce complexity because the reader doesn't have to try to infer what the code is about. Whatever may be the benefits of dynamic typing, readability is clearly not among them. I wish that we could get at least that one straight."

Even if I agreed with you that type declaration isn't an issue, the difference turns out to be much bigger because it snowballs -- what started as a very small snowball becomes a dangerously big snowball and it never stops, though people try to at least contain it with good frameworks and tools.

If you revert that, if you actually cared that the snowball never increases unless it's necessary (like when we write a big program or library), that's what is Ruby -- a little and controllable snowball. Think about the universe before the Big Bang. :-)

Actually, I think I have written much more classes and modules in Ruby than millions of Java programmers have in Java, though by using Hash and Array in Ruby I save some obvious classes that people sometimes create in Java.

Ruby is a win-win to me.

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 10:33 AM
Reply to this message Reply
As an addendum, I would like to say that even with Ruby you won't find miracles. For instance, given all the optimum conditions of temperature and pressure, I have broken my own APIs many times by deciding that they weren't good enough, but I have done that because I needed to support evolution or else I would need to live with what I had for ever. If Ruby was any miracle, I would have gotten the APIs right in the first try. But no, up till now I'm still creating new things -- some time ago I considered some of them close to impossible, but thankful to the dynamicity of Ruby and to my commitment to Ruby, I have found the strength to keep evolving my libraries till I consider them ready.

Now, take Java's evolution to study. Java itself has broken many APIs and programs through the course of its evolution. It's no wonder when people decide to couple the Java program with a specific version of a JSDK or JRE. So, type declaration is not enough to help with backwards compatibility. And backwards compatibility does not help the further evolution of APIs. Not to mention that people might not commit to creating good and easy to use APIs, because they don't want to commit to them -- they rather prefer to create very generic APIs (rings any bell?).

Gregg Wonderly

Posts: 317
Nickname: greggwon
Registered: Apr, 2003

Re: Java / Ruby comparison Posted: Jan 5, 2006 11:07 AM
Reply to this message Reply
> As an addendum, I would like to say that even with Ruby
> you won't find miracles. For instance, given all the
> optimum conditions of temperature and pressure, I have
> broken my own APIs many times by deciding that they
> weren't good enough, but I have done that because I needed
> to support evolution or else I would need to live with
> what I had for ever. If Ruby was any miracle, I would have
> gotten the APIs right in the first try.

The nice thing about static typing and a compiler is that this provides a "test" up front that will come much closer to validating your callee/caller compatibility on the first shot. I don't believe for a moment that it is cost effective to write sufficient tests, for every project, to provide 100% type compatibility testing that a compiler and types can provide over and over. Some might argue that there is a movement of cost from development time with types to testing time without types, but I don't see that being a realistic, works everytime argument. There are probably examples to cite, but not concrete repeatability.

> Now, take Java's evolution to study. Java itself has
> broken many APIs and programs through the course of its
> evolution.

This is a different issue altogether. Bugs in library routines are something all of us get to deal with. And don't get me started on java.util.GregorianCalendar.

> It's no wonder when people decide to couple the
> Java program with a specific version of a JSDK or JRE.

J2SE 1.2 was a complete and total nightmare. Anyone who tried to create something new starting with 1.2 was greeted with the worst possible experience of a lifetime. J2SE1.3 started to repair the huge array of problems 1.2 introduced. This is a common story for any platform/API. 1.2 changed many things that really needed changing, just like you talk about.

> So,
> type declaration is not enough to help with backwards
> compatibility.

There are multiple facits here, and you are lumping API signature compatibility with implementation compatibility. Those are two completely different issues which each require separate emphasis. API signature compatibilty testing is provided by the type system and compilier in Java. In typeless or untyped languages, you have to write more/new tests repeatedly to address this. That's an open ended cost to that language choice.

Implementation compatibility is a different set of tests that focus specifically on the effects and sideeffects of each piece of an API.

> And backwards compatibility does not help
> the further evolution of APIs.

It depends on the design of the API. If the API design is wrong, it can be implemented with a new name that allows the old uses/users to have compatibility and we can move on to something that actually does work as needed.

The java.util.Hashtable and java.util.Vector classes are extremely useful for people who don't understand multithreaded programming very well, and in applications where there are lots of threads accessing the same mutable data.

The java.util.Map and java.util.List interfaces provide the same functional programming capabilities, but don't stipulate synchronization as part of the implementation. What this allows is that you can have optimized mutiple structures where a single thread is used for all access. The provision of a java.util.Collections.synchronized*() methods allow a standardization of APIs to be used.
Moving beyond Vector and Hashtable is possible without breaking any APIs.

In other cases, existing APIs have been maintained and fixes to logic or stabilization of behavior provided inside of the same signatures.

It's silly to keep arguing about specific cases where human's have injected failure and to say these are the only necessary justifications we need to say something is bad.

What we need to speak to is the rather small advantages any of these languages provide to the total programming experience compared to what we had 10 or 20 years ago. The languages haven't improved things. It's the libraries and the IDEs that the languages have inspired and allowed to be created that are making the differences.

> Not to mention that people
> might not commit to creating good and easy to use APIs,
> because they don't want to commit to them -- they rather
> prefer to create very generic APIs (rings any bell?).

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 11:36 AM
Reply to this message Reply
"The nice thing about static typing and a compiler is that this provides a "test" up front that will come much closer to validating your callee/caller compatibility on the first shot. I don't believe for a moment that it is cost effective to write sufficient tests, for every project, to provide 100% type compatibility testing that a compiler and types can provide over and over. Some might argue that there is a movement of cost from development time with types to testing time without types, but I don't see that being a realistic, works everytime argument. There are probably examples to cite, but not concrete repeatability."

First of all, I agree that creating test code for everything is close to impossible, and I don't claim that "Test Driven Development" is any silver bullet. I don't support "TDD" as a "promise land". On the other hand, by creating units of code reuse (components), we ensure that we have good APIs and that they are used all the time (so, they are tested all the time), meaning that once the bugs are eliminated from the components, we have a good and stable code to reuse as much as we like. I defend components as the "promise land". And the more succinct the component is, the more that it behaves like a component, and languages like Ruby really help in creating components or libraries that behave like components, as well as the language itself is a good means for consuming (using) the components, instead of creating another layer with XML, Template Library, etc.



"What we need to speak to is the rather small advantages any of these languages provide to the total programming experience compared to what we had 10 or 20 years ago. The languages haven't improved things. It's the libraries and the IDEs that the languages have inspired and allowed to be created that are making the differences."

Here is how we can create a Thread in Ruby:

Thread.new{ sleep 1000 }

And we can access variables from the thread without needing to declare them as final. Imagine my surprise to find that Ruby had threads in an easier way than in Java, on the other hand, we still need the Native Threads, though by the tradition of Ruby, once the Native Threads arrive, I hope they will be just as easy to use.

So, in my opinion and experience, languages do influence the programmers, though we have many different kinds of programmers, varying from the hobbyist (me) to the professional (millions of Java programmers). Just like Sun created the NetBeans, IBM created the Eclipse, Borland created the JBuilder and the supporting tools, I'm creating my own development tools, the difference is that I support Ruby and I don't need to support genericity in the same way that those companies need. You may have all the genericity that you need, but sometimes people need some cozy tools like Rails, for example -- and they are the same kind of professionals to which Java is appealing in a general sense (tool users).

piglet

Posts: 63
Nickname: piglet
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 11:36 AM
Reply to this message Reply
"Even if I agreed with you that type declaration isn't an issue, the difference turns out to be much bigger because it snowballs -- what started as a very small snowball becomes a dangerously big snowball and it never stops, though people try to at least contain it with good frameworks and tools."

I'm not sure what you are trying to say, Joao. First, type declaration IS an issue, only we completely disagree on it. I regard lack of type declaration as a *huge disadvantage*, a potential time bomb for future development and maintenance. "what started as a very small snowball becomes a dangerously big snowball", I would say that for a dynamic language.

"Actually, I think I have written much more classes and modules in Ruby than millions of Java programmers have in Java, though by using Hash and Array in Ruby I save some obvious classes that people sometimes create in Java."
Were all those classes justified or did you create them simply because it's so easy?

piglet

Posts: 63
Nickname: piglet
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 11:44 AM
Reply to this message Reply
1) "As an addendum, I would like to say that even with Ruby you won't find miracles. For instance, given all the optimum conditions of temperature and pressure, I have broken my own APIs many times by deciding that they weren't good enough, but I have done that because I needed to support evolution or else I would need to live with what I had for ever. If Ruby was any miracle, I would have gotten the APIs right in the first try."
2) "On the other hand, by creating units of code reuse (components), we ensure that we have good APIs and that they are used all the time (so, they are tested all the time), meaning that once the bugs are eliminated from the components, we have a good and stable code to reuse as much as we like."

1) and 2) seem contradictory to me... BTW, getting an API right or not is hardly the fault of the language. Maybe dynamic languages tempt the programmer to do quick and dirty design. Languages like Java emphasize interface stability but in the end, you can get it wrong in any language.

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 11:52 AM
Reply to this message Reply
Purposefully breaking an API isn't a problem, so it's not contradictory.

Bruce Eckel

Posts: 875
Nickname: beckel
Registered: Jun, 2003

Re: Java / Ruby comparison Posted: Jan 5, 2006 1:02 PM
Reply to this message Reply
> Thanks for the link to Andrew Glover's piece. I wrote
> Andrew the following:

Nice analysis.

> 6. Most of your this references in Java are
> optional.

When I see people use "this" when they don't have to, it always makes me wonder how well they really understand the language.

piglet

Posts: 63
Nickname: piglet
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 1:21 PM
Reply to this message Reply
"Purposefully breaking an API isn't a problem, so it's not contradictory."

It certainly is a problem if you aim for reusable components. Which you say you do.

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 2:09 PM
Reply to this message Reply
If we set everything in stone, we go back to procedural programming.

Gregg Wonderly

Posts: 317
Nickname: greggwon
Registered: Apr, 2003

Re: Java / Ruby comparison Posted: Jan 5, 2006 2:13 PM
Reply to this message Reply
> When I see people use "this" when they don't have to, it
> always makes me wonder how well they really understand the
> language.

Some people are as AR about using this as some are about importing every single class, instead of a package.

In the worst case, not importing by class causes later compilation errors when a new class by the same name is introduced into another package also imported.

In the case of not using 'this', you run into the problem that sometimes, people will declare new method parameters that have the same name as a class member and miss the fact that they might cause the scope of a reference to change to a different value/instance!

piglet

Posts: 63
Nickname: piglet
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 2:38 PM
Reply to this message Reply
"If we set everything in stone, we go back to procedural programming."

"On the other hand, by creating units of code reuse (components), we ensure that we have good APIs and that they are used all the time (so, they are tested all the time), meaning that once the bugs are eliminated from the components, we have a good and stable code to reuse as much as we like."

Which one is it? Do you want stable reusable code or not?

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 3:05 PM
Reply to this message Reply
Java is stable yet? Are all the core Java APIs and libraries stable yet? What if an interface changes? What if an abstract class changes? Is Java "final" in any sense?

When we develop APIs, we may change our minds from time to time, and it may be worth it to change an API while it's not a too big hassle. Imagine if Java was developed for 5 years before it reached the hands of developers? Would it be more improved than developing it for one years and then releasing it? How much "a priori" can a dozen geniuses think to create the perfect APIs?

Tell you what, the niggards among us set everything in stone if they can, because they don't care as much about generalities, they just want to get their jobs done as soon as possible. So it's not too hard to find many "finals" in Java code, not to mention those "immutable" pesky things.

I'm going to tell you an example of an API change. In GTK+, there is a command called "pack_start" and another one called "pack_end". I created a shortcut called "pack" with some default variables, but then I chose to make it even more easier by adding an "horizontal_pack" which I called "hpack" and another one "vertical_pack" which I called "vpack". But then I used the same terminology for reporting and other toolkits (Fox, WX, Web). Then I finally decided that "hpack" was too ugly and "pack" was enough for the new APIs. Even though I had used it in several examples, programs and libraries, I decided that it was still time to change it. Was it worth it? Definitely. I will use it for everything for the next 5 years.

So, a deliberate change, though it was much more a problem for me as a tools developer, then it would have been for a user if I had documented it.

But please, not that I'm not defensive about it. I know that a static typed language could help me make such a change, but a static typed language wouldn't help me as much to create the tools in the first hand. It's a tradeoff. I like OO more than millions of Java programmers, who barely know the design patterns by heart, because they don't find a lot of opportunities to use them in a sensible way. I'm baffled when people say that they use OO when they barely use polymorphism -- their code seeming a lot more procedural to me, even though it might use classes, interfaces, etc.

Give me Ruby a static typed system (maybe inferred), and maybe I might use it. Until then, there isn't much choice.

Gregg Wonderly

Posts: 317
Nickname: greggwon
Registered: Apr, 2003

Re: Java / Ruby comparison Posted: Jan 5, 2006 3:50 PM
Reply to this message Reply
> Java is stable yet? Are all the core Java APIs and
> libraries stable yet? What if an interface changes? What
> if an abstract class changes? Is Java "final" in any
> sense?

I not sure I understand what you asking. Is the Java "language" finished? I don't think so. Is the Java Standard Edition platform finished? I don't think so. Is the Java Micro Edition platform finished? I don't think so. Is the Java Enterprise Edition platform finished? I don't know, but I think it should be tossed in the trash, but I'm just a Jini fanatic some say.

I can't tell whether your wondering if a Java platform bug will bite you and break a program you wrote, or if you think that your java program will not run because of an API change.

Sun has continued to make sure that all APIs remain backward compatible as far as I can see. They've made statements to this effect in many forums, and my experience has been that this is the case where I would expect compatibility to be possible. Sometimes they have broken things with serialization and other places where they needed to make changes. The latest JMX-Remoting update 4 of v1.0.1 is not compatible with v1.0 without asking it to be.

Stuff changes...

Software will have bugs, plain and simple...

> When we develop APIs, we may change our minds from time to
> time, and it may be worth it to change an API while it's
> not a too big hassle. Imagine if Java was developed for 5
> years before it reached the hands of developers? Would it
> be more improved than developing it for one years and then
> releasing it? How much "a priori" can a dozen geniuses
> think to create the perfect APIs?

I don't understand this comment. Sun is releasing bug fixes every quarter for their implementation. Other people with JVM implementations can have different schedules.

Sun is not the only provided of JVM technologies. It is a non-trivial technology involving a non-trivial amount of software. So, there aren't a lot of people single handedly recreating it that I've seen... It makes sense to license it from Sun and build on their base.

It is a standards based platform with community based participation in its features. The JCP has a pretty stagnant group of participants which are fairly controlling of the focus of the development. But that is the fault of others for not participating rather than the fault of the JCP participants. They'll do whatever they agree to do. If you don't participate, you don't have a say in what happens, and you get to live with the results.

> Tell you what, the niggards among us set everything in
> stone if they can, because they don't care as much about
> generalities, they just want to get their jobs done as
> soon as possible. So it's not too hard to find many
> "finals" in Java code, not to mention those "immutable"
> pesky things.

There are some interesting issues with the use of final classes and immutable objects.

You see, Java has a security model built into the language, unlike almost all other programming languages. That security model relies on the fact that string values that you can look at to see sets of things in the configuration, can't be changed by you to subvert security. So, there is a need for some immutable objects.

On the other face of the issue is garbage collection. There are some optimizations to be made with String.intern() that help to greatly reduce the total number of bytes allocated to string data in your running JVM. Many people probably don't use String.intern(). I use it in a String intensive database intensive application that I have to make sure that I have only a single instance of some very repetative String values active.

Immutability is what makes these types of optimizations possible.

> I'm going to tell you an example of an API change. In
> GTK+, there is a command called "pack_start" and another
> one called "pack_end". I created a shortcut called "pack"

I have absolutely no idea how this relates to this discussion. If you're interested, I wrote a cover class for the java.awt.GridbagLayout class to provide a TK like pack facility because I liked that interface to layout. It's at
http://packer.dev.java.net. I did it back in 1995/1996 or so, and have used it without any version of Java breaking it since that time. This year, I made a change to it for JSE1.6 to allow it to support some new layout features added in JSE1.6.

> Give me Ruby a static typed system (maybe inferred), and
> maybe I might use it. Until then, there isn't much choice.

Based on your above comments and arguments, I'm not certain you have all of the "correct" information about Java.

Hope you can be successful with your programming.

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 4:00 PM
Reply to this message Reply
"On the other face of the issue is garbage collection. There are some optimizations to be made with String.intern() that help to greatly reduce the total number of bytes allocated to string data in your running JVM. Many people probably don't use String.intern(). I use it in a String intensive database intensive application that I have to make sure that I have only a single instance of some very repetative String values active.
Immutability is what makes these types of optimizations possible."

Have you seen Symbols in Ruby? One instance of String in the memory. Example:
"this is a string"
"this will be a symbol".to_sym



"I have absolutely no idea how this relates to this discussion. If you're interested, I wrote a cover class for the java.awt.GridbagLayout class to provide a TK like pack facility because I liked that interface to layout. It's at
http://packer.dev.java.net. I did it back in 1995/1996 or so, and have used it without any version of Java breaking it since that time. This year, I made a change to it for JSE1.6 to allow it to support some new layout features added in JSE1.6."

It is Ruby, not Java, that's why you didn't understand it. I wasn't clear enough.



"Based on your above comments and arguments, I'm not certain you have all of the "correct" information about Java."

It has been a while that I haven't programmed in Java nor read with interest anything on it, so you may be right.



"Hope you can be successful with your programming."

Thanks. You are nice and I wish you the best in this new year.

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 4:10 PM
Reply to this message Reply
"I have absolutely no idea how this relates to this discussion. If you're interested, I wrote a cover class for the java.awt.GridbagLayout class to provide a TK like pack facility because I liked that interface to layout. It's at
http://packer.dev.java.net. I did it back in 1995/1996 or so, and have used it without any version of Java breaking it since that time. This year, I made a change to it for JSE1.6 to allow it to support some new layout features added in JSE1.6."

Sorry, I see now. It was meant as an example of how to break an API may be important and achievable without breaking the idea of components for solidifying reusable code.

Brian Ford

Posts: 153
Nickname: brixen
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 4:10 PM
Reply to this message Reply
> ... Proponents of dynamic languages tend to
> identify the readability/complexity issue with number of
> characters, which is plain stupid. What is important is
> the number of logical entities that you have to keep in
> mind in order to understand the code, not the number or
> lengths of words to read. Type declarations actually
> reduce complexity because the reader doesn't have to try
> to infer what the code is about. Whatever may be the
> benefits of dynamic typing, readability is clearly not
> among them. I wish that we could get at least that one
> straight.


I strongly disagree. Readability assumes so many things. Readability necessarily impacts your ability to hold some number of things in short-term memory. And the reverse is also true: how many things you can hold in memory will impact how "readable" a passage is to you.

At a very basic level, readability assumes that you can "parse" the tokens of what you're looking at. So, at some point, we have to define a threshhold for "readability", let's say, knowledge of the language.

Given that, typing declarations may, in a limited way, disambiguate the first following block of code from the second.
int a, b, c;
c = a + b;
versus
c = a + b

But what percentage of cases does such a thing cover? What do you assume when you say that declaring the type of variables a, b enhance readability? Sure, it tells you that you're doing numerical addition versus string concatentation (assuming the language supports that meaning of +). But how much more do you really have? Very little I suggest. It doesn't tell you anything more about the meaning of those variables, how they're intended to be used, what their value boundaries are (except implicitly and I'll say why in a moment). If you have ever tried to understand some C code implementing a geographic transform, say from State Plane to UTM, you will clearly know that type declarations offer almost nothing to readability. There is a ton of context that tells you about those variables. For example, the function name, the algorithm, the use of the variables together, the operations performed on them. The declaration of the type adds so little, if anything, to all this.

In a statically typed system like C or Java there are several things with which you as the code writer and reader must continually wrangle:
1. The proper "class" for a declared variable, e.g. numerical versus string.
2. The proper size for the type, e.g. byte, int, double.
3. The proper "higher" type for the result of an operation, e.g. int + double = double.

Note that 1 and 2 usually act like a unit when you think about defining a number versus a string variable. However, it's hardly so trivial. The various sizes of numeric types hardly conveys much meaning but imposes a huge burden on the programmer to continually be considering boundary conditions that are entirely irrelevant to the algorithm but critical to the compiler given it's type system.

When you read the code, even though the types have been explicitly stated, you still have to think of all the other issues I mentioned above (or some subset of them) to understand the code. And if readability is not directly aimed at understanding, then what really is readability?

All the foregoing is mostly concerned with very rudimentary types like numbers and strings. When you start talking about objects, I think static typing even lends less understanding. If you have an object and you say obj.method, what can happen? The object may not have such a method, or you may have misunderstood what you thought method did and you don't get the result you're after. Both those can easily be tested for. All the other content is there and is just as critical, if not more so, to understanding the intention of what's being done than the type label of the object reference variable.

Again, the issue of the threshhold for readability comes up. If I use a type label for an object, say BlueWidget, but you don't know what that is, you have to go read about it. The label won't tell you anything. If there is no type label and all you have is obj.method, you still have to read something (e.g. a nearby comment, search for method in the class browser). Either way, the burden is about the same, and this assumes you haven't got a clue what you're looking at (except that you know the language) when you start reading. That, in itself, is a low percentage case, I'd say.

With dynamic typing in the situation above, your familiarity quickly grows and you have to look up less and less as you learn about the classes being used. More importantly, the emphasis switches to how objects are interacting, or being acted on, rather than on type labels.

With static typing, you are continually confronted with questions about picking the right type label for your variable and what the programmer intended in picking his. You have to worry about casting or declaring a variable as a base type of several derived types, etc. And the fact that you now have this label doesn't help you to understand much about the intent as the code starts calling methods on that object.

Reading code that has explicit type labels imposes the, often superfluous, task of putting into my short term memory that a is an int or something so I can then get on to look at what operations are performed or methods called on a. That additional effort often reduces readability for me. More importantly, when writing code I'm confronted with a number of concerns that are probably irrelevant for my problem domain; I shouldn't care how many bytes the compiler has to allocate for my numeric types so I can add a couple of numbers. And the more distracted the code writer's mind is, the more likelihood he will introduce bugs. Or so it seems reasonable to me. How many times do distracted people have accidents compared to those clearly thinking and carefully concentrating on the task at hand?

Of course, if that consideration is important, critically so, as in, it goes to the core of the algorithm itself, then I'll probably be writing C code and it will be important for me to pay attention to these points. Most of the time, my experience has been that worrying about types is more trouble than it's worth. Now, an interesting language might dispense with labeling all rudimentary types like numerics and strings and reserve the types for classes. But I don't see this gaining much over a simple comment or two. And then, when it's totally clear from context, I don't have to type a type label.

Gregg Wonderly

Posts: 317
Nickname: greggwon
Registered: Apr, 2003

Re: Java / Ruby comparison Posted: Jan 5, 2006 6:40 PM
Reply to this message Reply
> I strongly disagree. Readability assumes so many things.
> Readability necessarily impacts your ability to hold some
> number of things in short-term memory. And the reverse is
> also true: how many things you can hold in memory will
> impact how "readable" a passage is to you.

Variable names are inexact. Types can help qualify any information that the variable names might impart.

int lat, lon;

is very different from

double lat, lon;

> It doesn't tell you anything more about
> the meaning of those variables, how they're intended to be
> used, what their value boundaries are (except implicitly
> and I'll say why in a moment). If you have ever tried to
> understand some C code implementing a geographic
> transform, say from State Plane to UTM, you will clearly
> know that type declarations offer almost nothing to
> readability. There is a ton of context that tells you
> about those variables. For example, the function name, the
> algorithm, the use of the variables together, the
> operations performed on them. The declaration of the type
> adds so little, if anything, to all this.

It might seem to add little to you, but it tells me something about the types of calculations to expect to see. It also tells me how to manage injecting new code.

Whether or not you feel this adds value for you, is a matter of preference, education, or knowledge of the subject matter.

What types of math intensive applications do you have experience with? I'd be interested in know how complex these applications are to better understand how you perceive the impact types might have on your typing in math expressions. If the type names on the variables are more effort than the expressions you type, then that's a very interesting application/module/library that I'd like to know more about.

> In a statically typed system like C or Java there are
> several things with which you as the code writer
> and reader must continually wrangle:
> 1. The proper "class" for a declared variable, e.g.
> numerical versus string.
> 2. The proper size for the type, e.g. byte, int, double.
> 3. The proper "higher" type for the result of an
> operation, e.g. int + double = double.
>
> Note that 1 and 2 usually act like a unit when you think
> about defining a number versus a string variable. However,
> it's hardly so trivial. The various sizes of numeric types
> hardly conveys much meaning but imposes a huge burden on
> the programmer to continually be considering boundary
> conditions that are entirely irrelevant to the algorithm
> but critical to the compiler given it's type system.

There are distinct advantages to the programmers ability to control the complexity of the programs execution through the use of types. For example, time the execution of a FFT using double values in java vs implementing the same algorithm using BigDecimal. This would demonstrate the difference if we just dropped type designations for numeric values and implemented infinite precision math as the native implementation.

This is still an important issue in my mind. I have a Java application that does GSM VOIP compression (http://javecho.dev.java.net) to provide a realtime voice communications system. I'd be interested in see Ruby or Python implementations of this kind of mathematically complex algorithms to get an idea about how their untyped math systems would perform.

> When you read the code, even though the types have been
> explicitly stated, you still have to think of all the
> other issues I mentioned above (or some subset of them) to
> understand the code. And if readability is not directly
> aimed at understanding, then what really is readability?

One of the things about typing is that you can confine an algorithm to using only methods in a superclass. This is often an important part of OO design. This also applies to limiting the exposure of your interface implementation to just the methods in the interface. Java provides this type of control through the type system, and with a security manager active, you can control the access that the reflection API yields to foreign code as well.

> All the foregoing is mostly concerned with very
> rudimentary types like numbers and strings. When you start
> talking about objects, I think static typing even lends
> less understanding. If you have an object and you say
> obj.method, what can happen? The object may not
> have such a method, or you may have misunderstood what you
> thought method did and you don't get the result
> you're after. Both those can easily be tested for. All the
> other content is there and is just as critical, if not
> more so, to understanding the intention of what's being
> done than the type label of the object reference
> variable.

As I said above, typing helps control the visibility of parts of your implementation in Java. The fact that Ruby and Python have no security built into the language is perhaps one of the reasons why users of those languages don't understand some of the finer points of final classes and immutable implementations.

In Java, we have javadoc that is meant to detail exactly what the outcome of calling that method will be. In other languages, and IDEs supporting those languages, similar facilities are available. I don't know whether Ruby or Python has such context sensitive information available.
Does it? When you are writing Ruby code, how do you correlate your use of an API with the actual implementation details. Do you memorize all the APIs you use, or do you have some type of integrated or secondary documentation system that you access?

> Again, the issue of the threshhold for readability comes
> up. If I use a type label for an object, say BlueWidget,
> but you don't know what that is, you have to go read about
> it. The label won't tell you anything. If there is no type
> label and all you have is obj.method, you still
> have to read something (e.g. a nearby comment, search for
> method in the class browser). Either way, the burden is
> about the same, and this assumes you haven't got a clue
> what you're looking at (except that you know the language)
> when you start reading. That, in itself, is a low
> percentage case, I'd say.

In Java IDEs, type information controls, through polymorphism based analysis, which set of methods you can see in IDEs providing code completion. The names of methods with matching prefixes are displayed and it all works easily.

I don't generally use a fancy IDE, so I have a Folder in my Windows-XP taskbar that pops up a list of javadoc sources that I can select from to get the javadocs for a particular package. From there, I can find the class and look at the methods to find the one that I need.

I, in general, don't fight with the java APIs in a way that your simple confusion base examples are based.

Most of your arguments go on about how typing doesn't solve all problems. It's not meant to solve all problems. It's one of the portions of the total language system that provide the set of features particular to a language.

My experience with first C, then my own dynamic language, then Java have convinced me that the benifits of typing in Java are a good and useful part ofthe language.

> With dynamic typing in the situation above, your
> familiarity quickly grows and you have to look up less and
> less as you learn about the classes being used. More
> importantly, the emphasis switches to how objects are
> interacting, or being acted on, rather than on type
> labels.

Again, you seem to expect types to solve all types of problems summarily Types can help reduce the choices you have to consider, which can make programming faster. They can also keep you from having methods names with slight variations because you don't have polymorphism. And, they can remove ugly type checking in cases where you decided to keep the same name for a single argument method that handles multiple types of arguments.

int add(int);
double add(double);
String add(String);
Integer add(Integer);
Double add(Double);

In dynamic languages, type polymorphism for overrides like this require type checks, or method name changes. This, I think adds some of the confusion regarding locating the correct method or reading the code that you talk about above.

> With static typing, you are continually confronted with
> questions about picking the right type label for your
> variable and what the programmer intended in picking his.
> You have to worry about casting or declaring a variable as
> a base type of several derived types, etc. And the fact
> that you now have this label doesn't help you to
> understand much about the intent as the code starts
> calling methods on that object.

I disagree that the type doesn't help. The specific types that you seem to allude to are native types in Java such as int vs double. This is informative and necessary for particular types of algorithms.

Casting in Java that is aimless, or confusing, will decrease as people make more use of Generics. It typically only collections or other generic packaging classes that have this issue. It's a known quantity. I've found 2 different long standing bugs, but in dead code, by using generics in Java.

I've found some miss used collections that had duplicate uses where I had intended separation that generics revealed. The type system is a testing system that you can take advantage of without having to write tests. In the case of Generics, you are adding more information for the test system to look at.

> Reading code that has explicit type labels imposes the,
> often superfluous, task of putting into my short term
> memory that a is an int or something so I can then get on
> to look at what operations are performed or methods called
> on a. That additional effort often reduces readability for
> me.

What happens with me is that the shorter variable names and types are, the more likely I am to forget. They say that most people can put 5-7 things in their short term memory.
It takes about 30 seconds for things in your short term memory to migrate to longer term memory. So, small amounts of information that convey a large amount of information are important.

Your examples of int vs double vs no-type are really not providing much convincing force. These are in fact the least of the advantage to the type system in Java any ways. The use of types for polymorphic overrides, the use of types for subclass access and interface implementation access control are important parts of the whole package.

> More importantly, when writing code I'm confronted
> with a number of concerns that are probably irrelevant for
> my problem domain; I shouldn't care how many bytes the
> compiler has to allocate for my numeric types so I can add
> a couple of numbers. And the more distracted the code
> writer's mind is, the more likelihood he will introduce
> bugs. Or so it seems reasonable to me. How many times do
> distracted people have accidents compared to those clearly
> thinking and carefully concentrating on the task at hand?

But that is not a related argument. Distraction and confusion comes from multiple sources. If the concepts of typing are confusing to you, then you may well have problems developing in a typed language. But, there are so many other sources of confusion, including the lack of types which help you to understand the scope of the reference to a particular variable.

Without interfaces in Ruby, you wouldn't be concerned with limiting scope of access to certain parts of your object. Without typing, you wouldn't be familar with the benefits of superclass restrictions to help manage the linkage between callers and callees which is an important part of managing the ability of replacing one implementation of an API with another.

In particular, consider the JDBC api in Java. The fact that there is an interface for Connection, Statement, ResultSet, etc allows for me to write a database independent application from a software interface perspective.

Bugs in implementation might cause me to use particular logic to manage the impact of those bugs on my software, but that would happen without types.

The types provide the ability for me to easily try a different implementation, at will. You'll need a template class or some other standard definition in a non-typed/typeless language. That is a type definition.

> Of course, if that consideration is important, critically
> so, as in, it goes to the core of the algorithm itself,
> then I'll probably be writing C code and it will be
> important for me to pay attention to these points. Most of
> the time, my experience has been that worrying about types
> is more trouble than it's worth. Now, an interesting
> language might dispense with labeling all rudimentary
> types like numerics and strings and reserve the types for
> classes. But I don't see this gaining much over a simple
> comment or two. And then, when it's totally clear from
> context, I don't have to type a type label.

Again, I appreciate your sticking with a single example, but you aren't providing any convincing arguments about how the lack of numeric based typing (or other native types) would NOT impact the performance or portability of the software to different systems.

I'm just not seeing how there could not be an impact. I care about performance and I care about portability. Java's type system lets me manage those issues explicitly.

I'd really like to see a VOIP application in Ruby with the codec written using Ruby. Do you know of such a thing that I could look at and play with?

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 7:14 PM
Reply to this message Reply
Ruby Taint Mode (security in a lower scale than in Java):
http://www.rubycentral.com/book/taint.html

Of course we won't see Ruby Applets yet, although, just like Flash and activescript, maybe we could in the future. Hint. Hint. :-)

Ruby-DBI - database independent access:
http://ruby-dbi.sourceforge.net/

If you want you may create a fake database driver to test something, though maybe it does not compare to the substitution that you can get in Java.

I have created my own "DBI" in Ruby, and I support Oracle, PostgreSQL, MySQL, Firebird, SQL Server (ODBC), Access (kind of, ODBC), SQLite and KirbyBase. KirbyBase is a database in Ruby, and even though it does not support SQL, I created a custom SQL interface to it so it would work in the same way of the other databases; though maybe I should support SQL-less databases.
http://www.netpromi.com/kirbybase.html

I don't know of performance intensive applications written in Ruby, though I wouldn't be surprised if some people have created some already; although I concede that the dynamicity of Ruby has its price, though people might create the algorithms in C and access them from Ruby (it may be worth it).

Brian Ford

Posts: 153
Nickname: brixen
Registered: Dec, 2005

Re: Java / Ruby comparison Posted: Jan 5, 2006 8:25 PM
Reply to this message Reply
Gregg,

You make a lot of points and I appreciate your in-depth analysis. Let me clarify a couple of points.

I definitely understand the different types in C; I don't claim they are equivalent. I also understand the impact of the choice of type on the performance of an algorithm. I wouldn't expect to do floating point math with integers, but with a particular library implementation, one could of course. Depending on the platform, using ints could be much faster. Obviously that would be true of a CPU with no FPU or equivalent.

But even understanding types, are you saying that in C you always know which of short, int, long, long long is most appropriate? And is it signed or unsigned? Of course, if you are coding a carefully designed math algorithm, that will provide guidance, but what about the general case? How often will the general programmer doing some math have to make this choice. And how often has the value being pushed into an int wrapped while the test was for a value greater than zero? Of course that's a bug. But for tons and tons of math done in simple programs, it shouldn't matter a wit to the programmer whether they're using a int, long, unsigned, signed, etc. They just want to add, multiply, or something. That's where I see a big advantage of a dynamically typed language.

I don't propose, not expect, that a type system will solve all programming problems. I think the post I responded to overstates the importance of types in promoting "readability" and I think you should restrict yourself to that context if you are to understand what I'm saying. To extrapolate what I've said to other areas of concern, like performance, scope or access control, etc. is to stretch it beyond my intention. I'm simply saying that
Foo widget = new Foo(a, b);
widget.buzz();
widget.bark();
is not dramatically more readable than
widget = Foo.new(a,b)
widget.buzz
widget.bark
And if you have a object being passed in, the documentation for that argument provides just as much knowledge as the type label. In other words
int foo(int a, double b) { ... }
is not more helpful, vis-a-vis readability than
# a - integer, b - float
def foo(a,b) ...
Substitute more complex types for int and double, the argument doesn't change.

I'm not trying to speak for every dynamically typed language out there. In Ruby, with the concept of duck-typing, you are more concerned that the object you interact with does some particular thing you want, than with the class of the object. In general, although you can ask any object obj.class, you would more likely do obj.respond_to?("laugh") if that's what you are wanting your object to do.

I typically do not use an IDE when writing Ruby, Python, or C/C++, unless Emacs is an IDE. ;) With Ruby, I have the docs open in a web browser and look up stuff as needed, which isn't that often once I'm a little familiar with the code I'm working on. I've used visual studio and I like completion. But that doesn't change the fact that I find the extra burden of types hardly worth it for a lot of programming. Of course, I must add, the problem domain isn't high precision math libraries or something of that sort. For example, I've worked on many helper applications in the GIS field using AML, Avenue, MDL and even VB for integrating with apps like ARC/Info and Microstation. AML and Avenue are ESRI dynamically typed scripting languages and I didn't find them noticeably worse for writing the utilities than MDL or VB. In other user interface heavy applications and web applications I find static typing to be superfluous.

You're right, Ruby does not have a security manager like Java does, but I hardly think that means you can't do the same things. And I don't see how types are necessarily implicated. Proxy classes, I think, could provide restricted access to other classes in the way that you describe interfaces doing in Java (I haven't used interfaces this way in Java). Objects in Ruby can be frozen at some point in their lifetime, prohibiting further changes. The Ruby interpreter can be set to run in various safe levels.

There are, of course, various idioms one could use to program in Ruby. The idiom(s) that utilize duck-typing are just much less focused on the particular "type" of an object than on what that object does. And depending on your situation, you may want only to know that it has one particular method and obj.respond_to?(method) works, or you may want to check obj.class, or obj.is_a?(class) or obj.instance_of?(class). I fail to see why Ruby crumbles into a silly little toy language incapable of solving "real-world" problems because one doesn't put type labels on object references.

Ruby's math support is by no means perfect. Some things are nice and simple: 5**1024 (exponentiation in Ruby) spits you out a nice long number. 5.0**1024 returns the value Infinity from the Float class. Ruby doesn't have the floating point equivalent of its BigNum. Now, assuming I were to use Ruby to program a math intensive library, I'm sure it would be a mixture of Ruby and C, or probably better, I'd use http://raa.ruby-lang.org/project/libgmp-ruby/ unless that wouldn't work for some reason.

I do appreciate your questioning of Ruby's suitability to several domains. So far, you pointed out RMI, Jini, and VoIP as areas you'd like to see if Ruby can provide useful solutions. I am looking at this carefully. Sorry, I can't wave my hand and have examples for you, but hopefully I and others who are very interested in Ruby will be able to provide more information over time. Or better yet, perhaps we could collaborate to investigate Ruby's boundaries in such areas. The language is hardly "finished", but I think it's an excellent start. And try as I might to understand, I cannot find a major fault with dynamic typing.

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Java / Ruby comparison Posted: Jan 6, 2006 1:12 AM
Reply to this message Reply
> > When I see people use "this" when they don't have to,
> it
> > always makes me wonder how well they really understand
> the
> > language.
>
> Some people are as AR about using this as some are about
> importing every single class, instead of a package.
>
> In the worst case, not importing by class causes later
> compilation errors when a new class by the same name is
> introduced into another package also imported.
>
> In the case of not using 'this', you run into the problem
> that sometimes, people will declare new method parameters
> that have the same name as a class member and miss the
> fact that they might cause the scope of a reference to
> change to a different value/instance!

I totally concur; I for one am also guilty of placing "this"
in places where its not necessary (simply habitual); though
it was not due to the insight Greg has given above - though
its great to know this is actually a good habit :o) - it
was more so for the benefit my own thought process on
with regards to scoping.

Verbosity sometimes does wonders!!

Gregg Wonderly

Posts: 317
Nickname: greggwon
Registered: Apr, 2003

Re: Java / Ruby comparison Posted: Jan 6, 2006 5:54 AM
Reply to this message Reply
> I totally concur; I for one am also guilty of placing
> "this"
> in places where its not necessary (simply habitual);
> though
> it was not due to the insight Greg has given above -
> though
> its great to know this is actually a good habit :o) - it
> was more so for the benefit my own thought process on
> with regards to scoping.
>
> Verbosity sometimes does wonders!!

The microsoft C++ standard, of course, is to put the prefix "m_" on the name of a class member so that all chances of scope changes are eliminated.

In Java, with inner classes, the "m_" rule doesn't help as much because an inner class declaration can hide an outer class definition.

This is not a type related issue, but it is an important issue to come to grips with developing Java software.

piglet

Posts: 63
Nickname: piglet
Registered: Dec, 2005

this reference Posted: Jan 6, 2006 7:36 AM
Reply to this message Reply
"I totally concur; I for one am also guilty of placing "this" in places where its not necessary (simply habitual); though it was not due to the insight Greg has given above - though its great to know this is actually a good habit :o) - it was more so for the benefit my own thought process on with regards to scoping."

If you prefer making "this" explicit, that's all right with me. Iprefer not to, and I pointed out that it's optional and shouldn't be used to accuse Java of being too verbose. I know that there is a danger of name collisions but this shouldn't happen if variable names are chosen judiciously. What I absolutely can't stand are code conventions which make it mandatory under all circumstances. It feels like being treated as a moron.

piglet

Posts: 63
Nickname: piglet
Registered: Dec, 2005

Type declarations and readability Posted: Jan 6, 2006 8:21 AM
Reply to this message Reply
If only your comments were not too long, Brian and Gregg... I won't try to go through all the details, just to restate the main point.

"If you have ever tried to understand some C code implementing a geographic transform, say from State Plane to UTM, you will clearly know that type declarations offer almost nothing to readability."

C is not my domain but I think it's not a good example to discuss the topic. The primitive C types may not add much to understanding what's going on in the code. In an OO language, you create your own types. In a sense, this is what OO is all about. By designing your object model, you specify your own vocabulary. If this is well done, then OO code can be read almost like natural language (you know, objects as nowns and methods as verbs). For that to be possible, it is absolutely crucial that the reader knows what types the code is talking about. If you look at the Ruby example in Glover's article (it's the first Ruby code I've been reading so it will have to serve as my standard example ;-)) without having read the explanation, you can only guess what's going on. You have to actually read the code in order to guess, for example, that some variables are collections (and you could still be wrong, the overloaded operators may mean anything). You can't even know what the member variables word, definition and spelling mean. They are absolutely unrestricted. You cannot even tell what the class is composed of by reading its definition! You might say that you can guess from the variable names but it's always guesswork. spelling and definition are strings but word is of class Word.

How do you know there isn't an extra Spelling class? Maybe spelling was a string yesterday, but then the author decided it has to be a class of its own. Your code passes a string but somewhere down the road, it blows up without warning. I'm not stressing the security aspect here. I trust that your tests will sooner or later point you to the problem, although static compiler checks would have revealed it at once. What I'm stressing here is readability, clarity and ease of maintenance. I just can't see how you can have those without type declarations. Glover's Ruby code is short but it's not clear, the semantics are not obvious. I like Java most for its interfaces. There is no guesswork, the semantics are known to the world and that's it.

Joao Pedrosa

Posts: 114
Nickname: dewd
Registered: Dec, 2005

Re: Type declarations and readability Posted: Jan 6, 2006 8:35 AM
Reply to this message Reply
Readability, clarity and ease of maintenance aren't easy goals in any language, but I think I have reached an optimum balance now with the latest progresses in the development of my libraries. The secret was to use DSL for programs which can get kind of messy in any language. The OO in the backend works like a charm for solid code.

So, by adopting a DSL with a "framework" things improve imensely. I think the complexity in my own code becomes 3 times less complex now.

Mike O'Keefe

Posts: 16
Nickname: kupci2
Registered: Mar, 2005

Re: The departure of the hyper-enthusiasts Posted: Jan 10, 2006 8:45 AM
Reply to this message Reply
> Sam Gendler, you've certainly got a lot of experience.
> Unfortunately, just like Bruce, you tend to speak on a
> topic you apparently do not know.
>
> Does it scale? Hmm, according to this,
> http://www.oreillynet.com/pub/wlg/8274, "the second
> largest online record store in the world ( second only to
> Amazon)" is being rewritten to run on Rails.

Nice, that's what we call "vaporware". But if you try hard enough, you can scale just about anything (hardware, clustering, etc), but I think it says alot that ebay, which handles billions of transactions a day, chose Java. So that's fine, prototype in Ruby, scale to Java when you need to.

It's really rather foolish to disregard the tremendous amount of work done in optimizing the JVM, and the incredibly competitive App Server market, from Apache Geronimo, Tomcat, Weblogic, WebSphere, Oracle.

This is where the fresh-faced web designer, ready to try the new new thing, is doing the customer a disservice. This is what Eckel is talking about when he says "We can identify hyper-enthusiasts because the arguments have a strongly faith-based flavor to them. X is the true way, therefore anyting X is best by definition, and all other languages lack X's goodness."

And this is what is missed in this Ruby discussion - there is much, much more to software design than I can write a for loop easier in language X. Anaylysis, Design, Testing, standards support (unicode anyone?), commercial & open source support. I don't care if you rewrote a Java app in a quarter the time (as Rubyists claim), and you think it didn't matter that this was a rewrite. That shows a lack of knowledge on what it takes to design anything more than a mom & pop web app.

If their claim is that Java is bad because it's just "a better C++", that's a misunderstanding. It was certainly the intention of Java's designer's to make it _look_ like C++, and that suredly helped their learning curve, but underneath the covers it is quite different, and actually borrows much from Objective-C. In fact, Java's designers didn't think too much of C++, see below. That’s somewhat like thinking Windows NT is simply a better Windows ME – wrong, it looks the same, but it’s a complete rewrite. So again, I think Eckel's point that the bandwagonists don't understand the competition too well is correct, and therefore I take much of the hype Rubyist's say with a grain of salt.

"Java Was Strongly Influenced by Objective-C...and not C++"
http://cs.gmu.edu/~sean/stuff/java-objc.html

Now, one point about Eckel's interesting article. It is great for a "down-to-earth/back-to-reality" comment, I think the whole Ruby thing is a bit overblown, and wouldn’t be anywhere without Rails. In fact this is exactly why Python hasn’t taken off, somehow they weren’t able to come up with the “Killer app”. Obviously if the "early-adopters" are able to convince the brilliant developers behind all the fantastic work done in Java (Struts, Spring, Hibernate, Tomcat, JUnit, TestNG, Eclipse, NetBeans, Log4J, Castor, JibX, Xerces, Apache Commons), to move to Ruby, it will certainly take off, and the early-adopters like Tate will stand to benefit enormously since they were there first.


I disagree with Eckel that only C# has the chance of unseating Java, and that C# is too forward thinking – I think JDK 1.5 has shown that Sun is making every effort to appease the hyper-evangelists and move Java forward (generics, doclets), perhaps too fast. The question really is whether C# and .NET will ever catch up to Java. I admire Hjelsberg, but watching his presentations is a bit of a yawn. Sorry, I can’t get excited about a new and improved for loop. Or how great and easy it will be when they improve persistence, fix the impedance mismatch blah blah. With Hibernate, Castor, JAXB, JDO, EJB3, Java developers have a plethora of ways to persist data. And that’s always been the tricky part of Java – which great tool do I use? Struts? Enhydra XMLC? JSF? So C# and .NET have a long long way to go. Obviously Microsoft will always have it’s installed base, but as this article has shown, C# is not the only game in town, and I would venture to say that Ruby, especially with Rails, is more of a contender than C#. Because that has always been Microsoft’s forte – it’s easier with Microsoft.

Finally I will say that I certainly look forward to working with Ruby, just as I also do some work in perl (much less now that Java has RegEx), Python, and C++ - where they provide a benefit. Certainly Ruby has some good ideas – everything is an object (although, again, the reason why Java succeeded was it was a compromise). Ruby is simply a better perl (Eckel says that, not me). But if Sun can get a handle on the language, and keep to the original philosophy of a simple, robust language, and not make changes according to the whim, or threat, of the hyper-evangelists, it will continue to be the king.

Alex Bunardzic

Posts: 546
Nickname: alexbunard
Registered: Oct, 2005

Re: The departure of the hyper-enthusiasts Posted: Jan 11, 2006 8:11 PM
Reply to this message Reply
Mike O'Keefe wrote:

"And that’s always been the tricky part of Java – which great tool do I use? Struts? Enhydra XMLC? JSF?"

But, but, but... weren't you guys all telling us that the real strangth of Java is that there's always one, and only way way to do things? Can't you at least maintain certain minimum level of consistence and coherence in your views?

Vincent O'Sullivan

Posts: 724
Nickname: vincent
Registered: Nov, 2002

Re: The departure of the hyper-enthusiasts Posted: Jan 12, 2006 12:30 AM
Reply to this message Reply
> But, but, but... weren't you guys all telling us that the
> real strangth of Java is that there's always one, and only
> way way to do things? Can't you at least maintain certain
> minimum level of consistence and coherence in your views?

No. All guys have never said that there is always one and only way to do things in Java. By applying so many extreme interpretations into a single sentence you make your argument self defeating. It would be true to say, however, that many guys have said that there is frequently a best way to do things in Java but then that's true of any language, including Ruby et al.

In any case, you're confusing only ever having only one way to do something in Java syntax with only ever having only one application that does something. The latter does not follow from the former.

João Marcus Christ

Posts: 1
Nickname: joaomarcus
Registered: Jan, 2006

Re: The departure of the hyper-enthusiasts Posted: Jan 12, 2006 9:38 AM
Reply to this message Reply
Scaling is mostly a matter of doing the right thing with the tool you're using. Now, if we're to talk about Ruby's performance, well, it may really suck, period. However, many times performance is *not* critical, because concise and clean applications are much more important. I'm not saying it's okay to have an absurdly slow application. I'm saying that faster is not always better.
It's to have a Rails app 2x slower than a J2EE app if adding new stuff to a Rails app is more than 2x faster than adding stuff to a J2EE app.
Really, the Java hype is over. Let's face it: it has been *absurdly* overhyped, over and over and over. Now it's time to absurdly overhype Rails. It's part of the process.
"Java scales better" is nonsense. Do you guys realize how much effort it takes to build a scalable J2EE app? It's not really easy. The same applies to other frameworks and languages.

(BTW: I'm not into Rails, I've developed some things in Rails, but I decided to go for Django. It suits my needs better)

Gregg Wonderly

Posts: 317
Nickname: greggwon
Registered: Apr, 2003

Re: The departure of the hyper-enthusiasts Posted: Jan 12, 2006 9:54 AM
Reply to this message Reply
> "Java scales better" is nonsense. Do you guys realize how
> much effort it takes to build a scalable J2EE app? It's
> not really easy. The same applies to other frameworks and
> languages.

It's important to understand that Java != J2EE. J2EE is a programming platform built on the Java language. The JVM and the Java language are the performance and stability scaling point.

If you pick the wrong platform to develop your Java application on, you may find that the platform can't support your application.

There is a lot of noise and buzz about POJO for a reason...

Isaac Gouy

Posts: 527
Nickname: igouy
Registered: Jul, 2003

Re: The departure of the hyper-enthusiasts Posted: Jan 13, 2006 4:14 PM
Reply to this message Reply
Bruce Eckel wrote:
> The only thing I've seen that shows promise as an OO
> process model is Active Objects/Actors.

You may be interested in Zonnon's Active Object approach
http://www.bluebottle.ethz.ch/Zonnon/papers/The_Concepts_of_Zonnon_6_y041123.pdf


> On the other hand, I haven't seen how Erlang deals with
> objects -- or does it support objects?

They like to say that Erlang supports "Concurrency Oriented Programming"
http://www.sics.se/~joe/talks/ll2_2002.pdf

Erlang programs are structured around lightweight processes - that's fundamental to their notions of how to build reliable distributed software.
http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf

piglet

Posts: 63
Nickname: piglet
Registered: Dec, 2005

Verbose Java Code Posted: Jan 17, 2006 11:19 AM
Reply to this message Reply
This is only slightly related, but I have to make a rant about incredibly bad Java code. In the project that I am currently assigned to, I'm about to correct about 700 occurrences of code like the following:
 
public ArrayList getObjectList(String command) throws Exception {
try {
ArrayList list = new ArrayList();
list = dao.getObjectList(command);
return list;
} catch (Exception e) {
throw new Exception(e);
}
}


Of course this should be only one line of code in the method body instead of 7. While that is an outrageous example, I think it reflects some bad habits that are widespread among inexperienced, and even among some experienced Java coders and which may have contributed to Java's reputation of being such a verbose language. Sometimes I wonder whether newbies are deliberately taught that Java code has to contain as much redundancy as possible in order to be right. Book authors not striving for elegance, and often restrictive and inflexible coding guidelines make matters worse.

Exception handling is obviously one of the worst culprits. Java checked exceptions are often blamed (not least by Bruce) but in my eyes, the problem really is that too many developers don't understand the concept (as in the code snippet above) and courses and books don't give good, standard-setting examples. Java exception handling does force us to write some more code than we would otherwise have to but in my experience, the majority of catch handlers are redundant and could have been avoided if the programmer had spent a few minutes designing the appropriate flow of exception handling, rather than just mindlessly coding some handlers to please the compiler.

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Verbose Java Code Posted: Jan 18, 2006 12:17 AM
Reply to this message Reply
> This is only slightly related, but I have to make a rant
> about incredibly bad Java code. In the project that I am
> currently assigned to, I'm about to correct about 700
> occurrences of code like the following:

I concur, that is horrible code not only from a verbose
stand-point but also from the decision in what to return.
It doesn't allow for the flexibility enabled by Java to
at some later stage change the underlying implementation
by returning the interface instead of the actual object.
i.e. returning java.util.List allows for greater code
flexibility (from a maintenance stand point).


> Exception handling is obviously one of the worst culprits.
> Java checked exceptions are often blamed (not least by
> Bruce) but in my eyes, the problem really is that too many
> developers don't understand the concept (as in the code
> snippet above) and courses and books don't give good,
> standard-setting examples. Java exception handling does
> force us to write some more code than we would otherwise
> have to but in my experience, the majority of catch
> handlers are redundant and could have been avoided if the
> programmer had spent a few minutes designing the
> appropriate flow of exception handling, rather than just
> mindlessly coding some handlers to please the compiler.

The fact that only one line is needed in the try block
makes the code verbose - I agree with that. But I don't
think catching Exceptions in the code snippet makes it
verbose at all. Actually specifying the type of exception
in my opinion would make the code easier to understand -
in terms of Oh, at some point such and such an operation
occurs, e.g. interaction with hardware, or a datasource,
etc, this would only be evident by the type of exception
being thrown.

return dao.performSomeOperation();

doesn't really tell you much as to what type of operation
and what object is being returned, one may take a shot by
the variable name but I still don't think that helps much.

IMO there's a thin line between code
clarification/readability and verbosity.

piglet

Posts: 63
Nickname: piglet
Registered: Dec, 2005

Re: Verbose Java Code Posted: Jan 18, 2006 9:15 AM
Reply to this message Reply
"But I don't think catching Exceptions in the code snippet makes it verbose at all."

Verbose is not the right expression - the whole try-catch is redundant in that example. The programmer chose not to handle the exception, so he shouldn't catch it anyway. He obviously doesn't understand the concept. Creating a new exception instead of rethrowing makes matters worse, and declaring Exception instead of the specific exception is bad, but that's almost negligible in this case.

Thomas Gagne

Posts: 3
Nickname: tgagne
Registered: Aug, 2003

Re: The departure of the hyper-enthusiasts Posted: Feb 7, 2006 1:07 PM
Reply to this message Reply
Bruce, what do you mean when describing Fowler as being a Smalltalker that, ".. because the Smalltalk relationship never really worked out in the real world?"

Fred Grott

Posts: 105
Nickname: sharemefg
Registered: Nov, 2005

Re: The departure of the hyper-enthusiasts Posted: Feb 9, 2006 7:36 AM
Reply to this message Reply
Could it be the move to Ruby is meging of trends?

No one has touched on the economics..

Standard seed capital fro a new venture averages around $15,000

Obvioulsy, if one devloper can put together a product prototype that is production ready in 4 months than he has a chance to succeed with $15,000


I do not think the semantics of Ruby alone is the full set of trends in pick up of Ruby and Ruby on Rails..

Oscar Lee

Posts: 1
Nickname: xennest
Registered: Feb, 2006

Re: Ruby / Java Comparison Posted: Feb 9, 2006 8:50 PM
Reply to this message Reply
Cordially I invite you all to visit

http://210.17.173.101:8080/genandrun

GenAndRun 0.2 which is a Java on rails attempt to simplify Java development.

Now we offer a 3-min video demo which may prove that Java development can be EQUALLY elegant as RoR.

Oscar Lee
Xenium (Hong Kong)

Carlos Neves

Posts: 1
Nickname: lusosis
Registered: Dec, 2006

Re: The departure of the hyper-enthusiasts Posted: Dec 20, 2006 11:11 AM
Reply to this message Reply
Sorry, I have no experience in Ruby, Perl or Pyton, Java not more only C family (C++ and C#, C# 3.0 seems to evolve in good directions http://en.wikipedia.org/wiki/C_Sharp), but for my humble view Java syntax is “identical” to C++, I am not talking about any library of functions sets available in the different platforms, like the .Net Framework.

For mandatory indentation I worked, and I liked, OCCAM (http://frmb.org/occtutor.html and http://www.wotug.org/occam, born with the Transputer a very good parallel processor but fortuneless, good engineering is not enough to success in the market, but it as “reborn“ in the form of the CELL http://cellsupercomputer.com/transputer.php). The indentation in OCCAM (http://freespace.virgin.net/martin.mamo/dissert.html#intro) facilitates the understand of the program flow, and OCCAM is for real parallel or concurrent programming, so to see what parts of the program run in parallel OCCAM uses indentation in a very effective way. Before using OCCAM I also indent C and C++ programs for easy of understanding and today I do the same with SQL and C#, so I agree with indentation but also I understand that some Developers prefer “free text” than the mandatory indentation.

About Java and C#, some inside information at http://www.codeproject.com/dotnet/CSharpVersusVB.asp .

In the end C# is a Ecma and ISO standard (including the executable format - CLI), and Java is Sun proprietary, strange no ?

Flat View: This topic has 262 replies on 3 pages [ « | 1  2  3 ]
Topic: The departure of the hyper-enthusiasts Previous Topic   Next Topic Topic: Java Applets + Ajax = ?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use