Bruce Eckel
Posts: 875
Nickname: beckel
Registered: Jun, 2003
|
|
Re: Programming with "Duh" Typing
|
Posted: Jul 23, 2007 12:16 PM
|
|
> > Bill Venners wrote "the feeling of productivity" > > > > If only we knew whether there was any correlation > between > > the feeling of productivity and actually being > more > > productive. > > I think the productivity feel of Python and Ruby has > mostly to do with how succinctly those languages allow you > to express what you want the program to do, but also to > some extent how that economy of syntax makes programs > readable. Bruce Eckel touched on that here: > > http://www.artima.com/intv/aboutme2.html > > I think those things (concise expression when writing code > and the uncluttered, easier to read code that results) do > contribute to programmer productivity, but a lot of other > factors come into play. I recently put together a new > website, a site for a contest we're helping TIBCO run: > > http://www.ajaxchallenge.com/ > > I did it in about two weeks, which maybe makes it sound > like a Rails app, but it's a Java app. I did use Scala for > the controllers, because I wanted to try Scala out. But > Scala had very little to do with my productivity. If > anything, Scala slowed me down because I don't know it > very well. What made me productive was that we used our > existing architecture. I think a lot about productivity, > because I want to hire programmers and I want to maximize > the ROI, and I think architecture is key, as I wrote in > this blog post: > > http://www.artima.com/weblogs/viewpost.jsp?thread=95622 > > Despite that, though, I do find plausible what I've heard > several people say about the number of working lines of > code a programmer can produce in a day. Eckel mentions it > in the interview I point to first in this message. > Basically the claim is that a programmer can produce X > working lines of code a day, no matter the language. So if > a programmer can express the same concept in fewer lines > of code in one language compared to another, that > programmer would be more productive in the more concise > language. > > There's a lot more to productivity than that, of course, > but I am considering using Scala more and more for our > future development, because the claim I hear there is that > you can do things in about half the volume of code in > Scala compared to doing it in Java. I want to take > advantage of that.
I visit my friend Scott Meyers whenever I go through Portland. Last time, Scott (a long-time C++ guy) pointed out that static typing buys you two things: (1) Support within IDEs (2) the compiler can generate more efficient code. Noticeably absent was any discussion of "safety," and Scott is all about programming better.
I find Scala interesting because it does a lot more for you (Actors, Functional programming, and the brilliant understanding of what a switch statement really means, for example) while being more succinct. I don't object to static type checking in general, but I object to (1) Its overuse and (2) The belief that it's a magical solution to program correctness, and that no alternative solution could possibly be better.
There is also a persistent misunderstanding of generics vs structural (duck) typing. People have begun to see how messy and convoluted the results of Java's generics mechanism have been. But it's far more fundamental than that -- the obsession with static typing, applied to a generics mechanism, has produced a straightjacket that obscures the original meaning of the term "generics," which should never have been applied to the feature in Java (which, I think, only appeared in the language because C# was adding a somewhat better version).
When you use a structurally typed language like Python or Ruby, you begin to understand what "generic" really means, and also how much effort you must go to in order to make a generic call in an overtyped language like Java. And it was a language decision -- C++ does it right; C++ templates are far more "generic" than Java's "generics" will ever be. Java's "generics" require far too much work with far too little payoff.
Many of my Artima Weblog postings discuss these topics in depth; you can also find my original analysis "Generics Aren't" here: http://mindview.net/WebLog/log-0050 And numerous other discussions of Generics: http://mindview.net/WebLog/ArticleIndex I tried to summarize all this in the Generics chapter of "Thinking in Java 4e".
|
|