The Patriots loss in the Superbowl has gotten me so depressed and down that I need to take it out on somebody. I need to rant about something, so why not about some things that have annoyed me over the past few months about the dynmaic language community.
I recently emailed the mandelbrot benchmark to a dynamic language evangelist colleague. Although benchmark results are usually pure propaganda, poor representations of how a language or framework is used in the real world, or even just plainly out of date with the latest versions of the technology, still, the performance of dynamic languages compared to Java in the example is quite embarrassing. Ruby, for example, is 500 times slower! Yeah, its hard to take seriously a benchmark that outputs to stdout, but still, if you look at the code you’re thinking, WTF is Ruby doing that causes so much overhead?
Now, when I forwarded this benchmark to my evangelist colleague, he immediately accused me of trying to put down or stamp out any challenge to the “One True Language” (Java). Its not about putting down or stamping out. Its about testing whether or not a language is a viable application platform. The thing is, if the dynamic language crowd is going to position itself as a replacement for Java in application development then they are going to have stop giving silly rationalizations for their shortcomings and promoting myths about their language and Java. This, and this alone is what irritates me about this crowd. Let me give you some examples about the rationalizations and myths they try to pull over on us:
RATIONALIZATIONS
Dynamic Language XXXX didn’t do well against Java in XXXX benchmark
Rationalization: “Benchmarks indicate very little practical information about the overall utility and performance of a given language or runtime.”
Reality: Although benchmarks are either propaganda, out-dated, or not a good representation of real-world usages, glaring differences must be recognized. A 5%, 10%, or even 100-200% difference is probably as a result of tuning or some simple undiscovered bug. In the grand scheme of things, those kind of numbers ain’t very relevant. But a 50000% difference? For such a simple benchmark? Something is seriously wrong here.
This reminds of 2002, when I first ran JBoss against the J2EE SpecJ benchmark. We had some pretty embarrassing numbers at first way back then. Although SpecJ is clearly a silly, non-real-world benchmark, it allowed us to identify many major and minor bottlenecks and helped our project to mature. For some dynamic languages like Ruby, I think what the mandelbrot benchmark showed was that the VMs/implementations of dynamic languages like Ruby are still very immature compared to Java. I don’t believe that it shows anything seriously wrong with the language syntax of these dynamic languages themselves though. Java received similar attacks in the mid 90s when it came out. Since then, the JVM has improved dramatically and according to the mandelbrot benchmark, only 10% slower than C. I expect the same out of the Ruby guys eventually. I’ll have to see how this benchmark improves under JRuby.
Ruby VM cannot support kernel threads
Rationalization: “Green threads are good enough.” OR: “Who cares, I can just run multiple processes.”
Reality: Even the basic laptop nowadays has parallel computing power. Green threads don’t take advantage of this. Blocking I/O also creates huge problems with Green Threads. Solving the problem by running many processes is a poor solution. A process is just too heavy weight compared to a thread which is why we have threads in the first place. It is very common for server-side Java applications to service hundreds of concurrent users. Besides, running multiple single-threaded processes starts to negate some of the benefits of simple design patterns like caching.
If dynamic languages like Ruby want to position themselves as a viable alternative to Java for an application platform, they are going to have to solve these issues. Many will say, “Its probably good enough for simple apps”, but it is not uncommon for project leaders to underestimate how much traffic they will get, or how much they have to scale.
Dynamic languages like Ruby, Python, etc… are not typesafe/statically typed
Rationalization: “Type-safety makes my code too verbose and makes me less productive.”
Reality: Why can’t these people learn how to type? Modern IDEs make this point totally moot with code completion and code generation. Besides, why can’t we have a dynamic statically typed language?
Lack of type safety doesn’t scale well to large teams
Rationalization: Anybody noticing the “Any software written by a large team will ultimately fail.” articles floating around in the community? Am I paranoid, or is this yet another attempt at brainwashing us into believing dynamic languages are the next fad in software development?
Reality: There are a lot of large applications in the industry being written. This reminds me of a story my colleague Jason Greene told me. He was working on a very large python project. Lack of static typing ending up being such a coordination and maintenance problem they ended up having a coding policy where everybody had to embed type information into the variable names of method parameters. Funny, eh?
Lack of static typing does not allow for reliable refactoring in modern IDEs
Rationalization: “The productivity of dynamic language XXXX makes refactoring irrelevant. Anyways, there are IDEs for Ruby out there that support refactoring”. OR, my favorite: “I don’t use an IDE, what do I care?”
Reality: I was a VI/Emacs user up until 2002 when Intellij came out with refactoring capabilities. Up until then, I was as productive with emacs, find, grep, and sed as I could be with any IDE out there. After finally becoming familiar with Intellij and its refactoring capabilities, I found that I was 5, 10 times more productive with my IDE than I was before. Now, Ruby fanboys will argue, “Intellij and Netbeans have refactoring capabilities for Ruby!” My answer is, it is not reliable refactoring. Take this example Cedric Beust gave on a recent TSS thread:
def f1(o) o.init end def f2(o) o.init end class C def init ... end end class D def init ... end end
If you rename C.init to C.init2, how can the IDE know which o.init must be renamed in f1 and f2? The IDE could either do these refactorings automatically (dangerous) or prompt you to confirm at each replacement point (tedious). In either case, any productivity you’ve gained with the elegance of Ruby is lost 10 times over.
So, these are just some of the rationalizations the dynamic language crowd gives when confronted with criticism. Now let’s talk about some of the myths and propaganda that is being fostered.
MYTHS
Software Engineers should use the best language for the job
Reality: I don’t know about the rest of you, but throughout my career I’ve either been developing middleware or writing applications. What other job is there really out there? Or maybe they are saying, “XXX dynamic language is good enough to solve certain application requirements”? Good enough has never really been good enough for me.
Besides, its hard enough to find an expert in one language. Its a maintenance and integration nightmare to have a project written in multiple languages. This can be bridged, to a degree, with dynamic language implementations that run on the JVM: JRuby and Jython are good examples. But unless these implementations become mainstream, they can quickly become out of date, i.e. Jython.
More lines of code means more bugs, thus dynamic languages are better.
Reality: Modern IDEs fills this gap. TDD is viable in type-safe languages too! I’m probably doing my own rationalization here, yes… JBoss 5, for example, is the 3rd major refactoring of the JBoss Application Server that I’ve lived through. I just can’t imagine doing it without the reliable refactoring that modern Java IDEs provide.
I am more productive in XXX dynamic language because the syntax is cleaner, more elegant, and more powerful.
Reality: Because Modern IDEs with a statically typed language can do reliable refactoring, this productivity gain has diminishing returns as your project gets larger. Even with small, one man projects, this reliable refactoring offsets any productivity gain you get with the dynamic language. At least, that’s what I’ve experienced.
I’ve done a decent sized project in Python before. I did find I was more productive with the first implementation. The problem is, I’m not a very clean programmer, so I end up iterating and refactoring constantly. In my case, a powerful IDE has made me incredibly more productive. Something I just could not get with a dynamic language.
Am I just a Java fanboy?
Maybe, but I don’t think so. Throughout my career I’ve done projects in Pascal, assembly, C, C++, Fortran, Tcl, Perl, Python, Visual Basic, Java, and even hacked around a little bit with PHP. While I don’t believe that Java is the one langauge to RULE THEM ALL, I do believe it is vastly superior to anything out there to build applications with. I also do not believe that Java is the end all, be all of existence. It still needs elegant, typesafe closures to complement annotations as a way to implement DSL. It needs a standard, non-code generating way of adding behavior to annotations. It needs a structural syntax to make initialization easier. AOP support might be nice too, or at least JVM support to make it easier to implement AOP-like features. Better zero-turnaround development features in both the JVM and APIs like Java EE, Seam, Hibernate, Spring, and JBoss AS would help out tremendously as well. Really, I’d be fine to dump Java for a language that supports all these things but the new language must:
- Be typesafe, statically typed
- Have an IDE that supports the same features as modern Java IDEs
- Have a rich set apis and libraries to build my applications from
- Have a viable commercial ecosystem
- Have a vibrant open source community
While current dynamic languages do have some of these attributes, none contain all, so until then Java is my choice and I will remain a boy who is a Java fan.
Finally, I hope you realize that I’m not trying to stamp out dynamic languages, but rather hoping, in vain, that the dynamic language community admits their faults. I do wish that a statically typed dynamic language would come of age, but until then, I’ll stick with Java. Really, I don’t know why somebody hasn’t done it it. Is static typing really that hard to implement well? For example, why not gut Groovy and have Dynamic Java? Or do the same with Scala? Or add static typing to Python and get Jython up-to-date?
Well thats it, expect more ranting in the next few weeks/months on a variety of subjects. Its gonna take a long long time to get the Pats loss out of my system….
Edited: 2/22/08
Many people have been confused on what I meant by statically typed dynamic language.
1) Typesafe introductions/mixins to either an instance or a class
For example:
class Foo {} class Mixin implements MixinInterface {} Mixin.add(Foo.class, new Mixin(), MixinInterface.class); Foo foo = new Foo(); MixinInterface intf = (MixinInterface)foo;
Or:
Foo foo = new Foo(); Foo bar = new Foo(); Mixin.add(foo, new Mixin(), MixinInterface.class); (foo instanceof MixinInterface) == true (bar instanceof MixinInterface) == false
2) Ability to do AOP things like field/method/constructor interception without having to do bytecode magic
3) Ability to plug in at runtime annotation processing (not the Javac crap).
4) An instrument library that allows you to make schema changes to classes. (didn’t state this before)
Bill Burke wants to get rid of Java! on Dion Almaer's Blog
Feb 04, 2008 @ 14:44:28
Feb 04, 2008 @ 15:42:49
Thanks, very nice post and excellent arguments. Do you see language oriented programming coming into play at any point? I don’t know how many languages we need in order to write an application, and inventing small and easy to code languages is not an answer to fast and reliable development because those languages become almost useless as the size of a project grows. We are basically repeating the problems we solved in the past, well in a modern fashion. However, I still like the idea of capturing a domain knowledge in a small language that eventually translates into a more general language like Java, and code in that language. I have heard promising things about JetBrains MPS but I believe it is living its academic days for now.
Feb 04, 2008 @ 16:07:40
Bill,
I think you’re ranting against JRuby rather than dynamic languages for the JVM as a whole. Groovy and, to some extent, Jython position themselves as glue languages to efficiently exploit the rich Java library resources. APIs which are virtually unusable in Java (BigInteger, BigDecimal anyone?) become easy to use. No amount of refactoring support is going to help you do complex financial calculations using BigDecimal.
Dynamic languages on the JVM are for adding flexibility to a structure principally built using static languages (that’s Java today). They are for building quick and simple DSLs to help people express intentions more clearly (Groovy XML or Swing builders, for example). One of the uses you have ignored is the way they can help people who are not and who don’t want to be professional computer programmers implement their ideas directly rather having them filtered and distorted by a programmer. If you go to a Python conference you meet mathematicians, engineers, economists, chemists – people who are doing stuff not people who want to endlessly argue about the true meaning of “Closure”. It’s wonderful!
RoR notwithstanding, I don’t really think that there’s a convincing argument for implementing the sort of infrastructure code you develop in a dynamic language (In Grails you go about three method calls down before you hit Java).
Performance is a big issue. JRuby is currently one of the better performers (Note to Scala people reading this – I don’t consider Scala to be a dynamic language so I’m not considering you’re very impressive performance achievements). Groovy does very badly on performance and has no real excuse (i.e. it’s currently executing lots of unnecessary crud). I worked on Groovy for over three years and have been developing a high speed runtime system for a newer dynamic language for about 9 months. I think that it’s possible to have a runtime system for a fully dynamic language on the JVM which runs on average less than 10 time slower than Java. I think that would be acceptable given the fact that a large proportion of any substantial system written in such a language would be executing Java libraries.
Groovy has pretty much solved the problem of seamlessly interfacing a dynamic language to Java on the JVM (there are some odd corner cases but I consider them bugs in the implementation not deficiencies in the language design). What has not really been addressed is the problem of seamlessly interfacing the other way round. A few months ago I made a half serious suggestion on the jvm-language list for a programming language called NotJava. NotJava has exactly the same syntax and semantic as Java except that it looks for a certain annotation on any class it uses. This annotation tells the compiler that the class has dynamic behaviour and that a certain runtime system should be used to to method calls, property access, etc. The compiler (and any IDE) would allow any method to be called on the class and would allow any field or property to be accessed.
Finally, I don’t really think there’s a single Dynamic Language Community and more than there’s a Static Language Community. You need to narrow our focus otherwise you’re just tilting and windmills:)
Feb 04, 2008 @ 16:59:24
@Farzad: I don’t whether or not, or whether I want language oriented programming. Personally, I am just getting old and not smart enough to continually switch contexts in short periods of time. I do think that annotations and closures give us a lot of DSL capabilities. Do we need more? I don’t know the answer to that, nor do I know what the app-dev community wants in this regard.
@John: I’m not ranting against Ruby, I’m ranting against singlemindedness. I just want the playing field leveled and for everyone to admit their faults and failures without silly posturing and trying to pull one over on us. Its the religiousness of many communities, like the dynamic language crowd, that pisses me off. For these glassy-eyed individuals, any criticism is FUD or a personal attack. They either ignore or never admit that your points have any validity. For them there is no compromise, there is no greyness, everything is black or white, for or against, right or wrong. I just wanted to cut through the bullshit that’s been shoveled around so much recently with the RoR craze.
As far non-programmers programming, that is all and good, but what happens when a thirdparty uses this code or you build a business on it? The thing is, if you can code at all, you probably can learn some basic fundamentals even if you are a chemist, economist, or mathematician.
Feb 04, 2008 @ 17:34:21
You should write large amounts of code (> 5k LOC) in a dynamic language, interacting with good programmers before you engage on such criticisms. Theorizing too much doesn’t really help anyone.
I have worked *a lot* with C++ and Java, and I switched to Common Lisp, Smalltalk, Ruby and Perl. My life is better now. 🙂
BTW, I have also used BASIC, FORTRAN, COBOL, Pascal, C, Prolog (yes, I worked with *large* amounts of code in Prolog) and PHP.
Feb 04, 2008 @ 17:50:43
@W-g: I’m not theorizing. I have worked on dynamic language projects > 5K LOC. My question to you is, did you use a modern IDE with your Java projects? If not, then you have no ground to stand on… If so, and you still would rather switch to Lisp, Smalltalk, etc… then you are a much better programmer than I am… Or maybe I should say, you are a less lazy programmer than I am.
Feb 04, 2008 @ 18:34:29
Bill,
“As far non-programmers programming, that is all and good, but what happens when a thirdparty uses this code or you build a business on it? The thing is, if you can code at all, you probably can learn some basic fundamentals even if you are a chemist, economist, or mathematician.”
One of the first commercial applications of Groovy was building a financial model for pricing insurance. It was built by domain experts (Actuaries) not programmers. They could have learned Java and written all those method calls to do BigDecimal arithmetic (they are very bright). Quite rightly (in my view) they though that would produce unmaintainable code. This is business critical (it’s a pricing model if they get it wrong they lose business and money in quite large amounts) and they need to continually refine the model to stay competitive. This has happened again and again with Groovy (and, I suspect, other dynamic languages).
There are quite a large set of problems where the complexity is not in the code but in the need to communicate domain specific information to the person writing the code. If you can remove the need to explain what is to be done and allow the expert to do it directly win n terms of speed of implementation, maintainability, cost and quality.
Dynamic languages are not a panacea but they are the preferred tool to address some problems.
Java is moving even further away from being easy to use by non professional programmers (yes, Generics, I’m talking to you). At this point adding stuff to Java is not going to make it easier to use. IDE help professionals but leaning enough about Idea, Eclipse or Netbeans to become dramatically more productive requires a large investment in time and effort.
We are erecting more and more barriers to entry to programming the JVM. If we continue to do this it will die. If the only way you can get code written for the JVM is to hire expensive superstar prima-donnas then the party’s over.
If somebody has a bright idea and can knock up an implementation in Jython, or JRuby or Groovy in a couple of days and it doesn’t work then they have lost very little. If it does take off then there may well be problems. It may be too slow it may not scale it may be hard to maintain (note there are only problems you hit if the app is successful). Then you can raise the resources to fix this problem (the Twitter guys don’t seem to have figured this out yet). However if the resource you need to get the initial implementation up and running then the number of ideas that make it from head to machine will reduce dramatically.
Feb 04, 2008 @ 18:48:14
Personally, I abhor any form of fanatism and bipartisanism. The unrelenting so–called fanboys, or the “Us vs. Them” sentiments do not serve any beneficial purpose really. Sure, comparing and contrasting is beneficial to help languages grow. But the die–hard, one–sidedness is fruitless; or helps create an eventual backlash.
I’ve been a long–time static language developer (C/C++, C#, Pascal, Java). However, I’m also a big fan of dynamic languages such as Python and Ruby. These days I find myself gravitating towards more terse and adoptive languages. I find that I have little patience for verbose languages (thanks to my carpel tunnel syndrome probably). 😉
In any case, most arguments made against one camp could probably be said about the other camp (in some form) as well. I don’t really care so much for these types of pointless arguments. The point is, there is no silver bullet. Mainly I use whichever tool (language + IDE + framework) works best for my particular task at that given moment. I’m not opposed to static languages or dynamic languages; I embrace and use both. Of course, this doesn’t mean that I do not have my own preferences though.
Someday in the not too distant future, I have a feeling we won’t see these types of divides any longer. There will be a convergence, so to speak. An end to static vs. dynamic, compiled vs. interpreted etc. We’ll be using a hybrid language which takes the best from both worlds. You can already observe this trend in certain areas. C# 3.0, for example has inherited a few new features traditionally found only in dynamic languages. However, I don’t believe that C# is what we’ll ultimately be using in the future I’m imagining. It will probably be something new but slightly reminiscent of it’s predecessors.
Feb 04, 2008 @ 19:02:11
Comparing Java to Ruby doesn’t really do much to discredit Dynamic Languages. Smalltalk is dynamic and the performance is quite nice.
Also, you probably are more effective with your IDE, because it’s likely that even when you used a dynamic language you wrote it as you would if you were writing Java. If you learned to code in the Ruby way you’d need to rely a lot less on your IDE.
Please do stick with Java.
Feb 04, 2008 @ 20:09:10
So, are you Blinky, Pinky, Inky or Clyde? 😉
Global Nerdy | And the “Static vs. Dynamic” Battle Rages On…
Feb 04, 2008 @ 20:28:29
Feb 04, 2008 @ 20:59:16
@Joe Johnson: Thanks for the other myth 🙂 I had forgotten about this one: If you learned to code in the Ruby way you’d need to rely a lot less on your IDE. So, if I write in Ruby, I’m never going to have to remove a method, field or class? Rename? Move? You convinced me…Time to start coding in Ruby.
Feb 04, 2008 @ 21:04:31
I have to agree with John Wilson’s point. Smalltalk allows me to experiment with potential solutions, in the same way that Powerpoint can be a very quick way to put together screen layouts.
Once I have a clear understanding of what the users really want – and if performance is an
issue – I can hand a collection if class definitions to someone else and get the app coded in a faster language.
No matter how great the IDE is, I am always faster in Smalltalk ( the only exception for me is when there is a great Java library which does a big chunk of my work and which I can’t access via a eg URL)
However, I certainly agree with Bill’s main point that we should all agree on tv facts about performance.
Feb 04, 2008 @ 21:17:19
If performance is so important, how do you justify using Java instead of C? Rationalization: JIT-compiled Java is just as fast as C (no it’s not when you measure properly). Rationalization: GC only introduces imperceptible delays (imperceptible to you in your application but not to me in mine). Is it any wonder that people think you’re bashing when you use such a simplistic observation about performance as the cornerstone for such a screed? Yes, advocates of dynamic languages should admit their faults. So should advocates of every other language, including both Java and C. Why do “they” always have to go first?
Feb 04, 2008 @ 21:36:33
The way I see it is that nearly everything is awesome about Java…except the language itself. I understand it has neat IDEs (never used them, though), a really incredible VM, good tools, lots of available documentation and help, it’s stable, it’s cross-platform, has tons of libraries and so on. But the language itself is just terrible. After I use it for a bit, I get somewhat used to it, but it is not designed for ease of use. Rather, it is designed to make things like static typing and compiler optimizations easier.
In regards to a couple of your points:
No one denies that Ruby has performance issues. But they are all being worked on. That’s why we have Ruby 1.9, Rubinus, JRuby, etc. However, raw performance does not always matter. More and more people are talking not about execution time, but programmer’s time. I suppose you would say that IDEs take care of this, which might be true. But it seems strange to need an IDE in order to work effectively with a language. That tells me the language was made for the machine, not for programmers.
Ruby’s threads: the development version (1.9) of Ruby has native threads and 2.0 definitely will. I believe JRuby does as well. I am sure a few people have claimed that we don’t need them, but most people would agree that be able to take advantage of hyper-threaded/multicore/multiprocessor systems is a must.
Overall, I would rather have a language which allows me to do what I need quickly and clearly than have to depend on a particular IDE to provide that for me.
Feb 04, 2008 @ 22:51:12
I never said you don’t need to refactor, I said you will be more effective in Java because you don’t know Ruby well.
Also, let’s not forget the the original refactoring browser came from a dynamic language, Smalltalk, not Java.
Like I said, please do stick with Java.
Feb 05, 2008 @ 00:20:22
@Justin: I still believe you can have both both syntax elegance and static typing. Syntax preference is a very personal thing. For instance, I get squeamish looking at Ruby examples, while when looking at Python I feel refreshed. Anyways, I never really got a woody over syntax to begin with. For Java, I rarely find the syntax a problem. It is usually the libraries that are awful. As far as Ruby performance issues? Again, I think this is nothing to do with the language itself, but rather its implementation. Until then its an immature platform unready for application development.
@Joe Johnson: Smalltalk may have been first, but Intellij dudes were the ones to finally bring refactoring to a statically typed language. Thank you JetBrains. You guys rock!
@Jeff Darcy: For me, performance isn’t much of an issue (well, unless you’re 500 times slower) as long as you can scale concurrently. That’s why a simple single-threaded benchmark like mandlebrot is silly (as said as much in my blog). If Ruby can take advantage of kernel threads on JRuby and scale well in concurrent environments, then as long as its relatively close to Java, this point is moot. What’s much more important to me is productivity. I believe with Java + a modern IDE, I can be vastly more productive than Ruby. The real point of the blog was not to bash Ruby, et al, but to bash all the lame excuses.
Feb 05, 2008 @ 02:03:56
Justin: “No one denies that Ruby has performance issues. But they are all being worked on. That’s why we have Ruby 1.9, Rubinus, JRuby, etc.”.. dude, we are talking about 100 fold performance issues..
Feb 05, 2008 @ 03:56:35
@afsina: My point was that people in the Ruby community are not content with that. If you look at what Bill says in the original post, he points out that even Java was once considered slow. Some people still say that. As I understand it, the point was that people shouldn’t be trying to make excuses for the slowness, but instead try to solve the problems which are causing the poor performance. I think most languages go through this phase. They have the features people want, then it’s time to go for a good, solid implementation.
“Java received similar attacks in the mid 90s when it came out. Since then, the JVM has improved dramatically and according to the mandelbrot benchmark, only 10% slower than C. I expect the same out of the Ruby guys eventually.”
There you are. Ruby’s current implementation was not built for speed. It has very few optimizations and many things are done inefficiently.If you are doing heavy number crunching, you might want to wait a few years before trying out Ruby.
» Dynamic languages vs. statically typed languages codekite - stuff about programming
Feb 05, 2008 @ 07:51:46
Feb 05, 2008 @ 08:30:54
Great article. totally agree on your points. Although I’m a groovy fan. I like groovy is not because it’s dynamic typing, but because of it’s dynamic features and elegant syntax. static typing does have more benifits than dynamic typing in modern IDE. Unless people are still using command line to write some small script such as unix shell script, dynamic language do save them quite a lot of typing in the vi. But I don’t think they can write a large system using vi.
Java definately can be improved by learning from groovy without losing it’s static typing basic. Java do need introduce the elegant syntax from groovy to make code smaller and cleaner.
Feb 05, 2008 @ 08:49:06
I think the language is not that important. Frameworks like Rails, Django or JBoss Seam are the key to productivity. And IDEs.
Rails has proven to be very productive for many application. As has JBoss Seam or Spring. I would choose a language based on available frameworks and libraries for a given task.
Static Languages: Rationalizations and Myths :: Steve Vinoski’s Blog
Feb 05, 2008 @ 10:00:34
Feb 05, 2008 @ 13:57:21
I dont want to be harsh or anything, but are you actually using Ruby at all?
C.init wouldnt work the way you wrote it.
Also, a big problem is in thinking that on Ruby one needs an IDE to survive.
I think the single best thing an IDE does to help is provide integrated docu and helper-keys to finish writing code faster, and not by providing boilerplate code or help to make people stop about design.
The best rule of thumb in ruby is this:
if it (code) gets too long, there probably is a much shorter way
Feb 05, 2008 @ 16:03:58
Can’t we just agree that one’s preferred language, just like one’s preferred editor or one’s preferred deity, is purely a matter of personal choice, and leave the unprovable claims of superiority at the door?
Frankly, the only thing that’s ever been demonstrated to make a statistically significant difference is interactivity. Works with editors (anyone still write code in ed?), works with languages, and there are people out there who swear it works with deities too. Once you have interactivity, details like typing taxonomy, execution model or syntactic convention are really quite irrelevant (and a block of code as a first class object takes you the rest of the way).
But even then, all interactivity means is that the feedback loop – do {write; compile; test} while(buggy) – is as short as possible, and instant incremental compilation and a decent debugger can get you 90% of the way there too. It’s nice to have interactivity written into the language, of course, but there are even reasonably interactive assemblers and C and Pascal compilers out there.
And yet, non-interactivity has benefits of its own – chiefly, you get better at thinking through code before writing it, which means you write better-thought-through code; technologically, it allows the kind of global optimisation that is more difficult in an interactive setting (as Haskell neatly demonstrates).
This kind of juvenile rubbish about the uselessness of dynamic typing and those who prefer it (and the other side’s equally juvenile rubbish about static typing and those who prefer that) is just as ridiculous as declaring war on people for eating the wrong end of an egg first. Grow up, already! Learn that it’s OK to prefer different toys! Learn that the one thing guaranteed to engender uselessness, or worse, is not doing the wrong thing, but Knowing that what you’re doing is the One and Only Right thing!
Feb 05, 2008 @ 18:20:35
It’s quite interesting reading the advantages of dynamically typed languages. The Ruby/Groovy/Python lovers regularly mention not having to type their variables. As Bill asks, why can’t they type a bit more, or use their IDE to auto complete the type declaration for them? The answer is: they don’t want to read all these type declarations. The dynamic language solution is to think of everything as Object, and then do name lookup for the method. And no wonder, the implementations are slow.
However, new statically typed languages solve this problem using Type Inference Engines (TIE). A lot of the time, the inference engine can work out what the types of variables are, and this keeps the code cleaner. As the whole language is statically typed, the compiler can produce nice fast code, and the IDEs can do 100% guaranteed correct refactoring.
Just as the 90’s showed us that languages need a Garbage Collector, the “noughties” will show us that every nice language should have a TIE.
My current favourite is Scala, which also has user defined operators for nice BigDecimal arithmetic, nice closures, traits, a powerful type system, and easy DSL creation.
What I’d like to know, is how much extra power does meta-programming (ala Ruby) give you, if you can already do what Scala has?
Feb 05, 2008 @ 21:33:23
There is a better response to “Type-safety makes my code too verbose and makes me less productive”: that is an argument against explicit typing, not static typing.
A language like Scala is statically typed, yet most of the time you don’t need to declare types because the language infers them for you.
Feb 06, 2008 @ 01:50:09
Do you consider c# a viable alternative? It has an open source compiler/framework and it is taking on features of functional and dynamic languages.
Feb 06, 2008 @ 02:08:43
@Brain: I don’t know if C# is a viable alternative as I’ve pretty much been in the anti-Microsoft world the last 8 years. They sure are innovating enough for Java to copy them (annotations) so its probably worth a look. I also hear they are innovating a lot in the VM as well. Its good that JVM has some serious competition.
Feb 06, 2008 @ 03:24:25
Jonathan O’Connor, in a comment that illustrated perfectly the kind of attitude I was complaining about immediately above it, said:
“The dynamic language solution is to think of everything as Object, and then do name lookup for the method. And no wonder, the implementations are slow.”
You might want to do some research into that. Method lookup cacheing actually optimises method calls to direct call instructions some 90-odd % of the time; in contrast, the vtable approach never gets any better than an indirect call.
Guess which one of those two you pay through the nose for on any CPU with branch prediction…?
Hypothetical Labs » Doom On My Left and Doom On My Right
Feb 06, 2008 @ 15:57:02
Interesting debate on the benefits/negatives — jessenoller.com
Feb 07, 2008 @ 01:30:25
Feb 07, 2008 @ 06:54:44
> http://shootout.alioth.debian.org/gp4/benchmark.php?test=mandelbrot&lang=python&id=3
lol. it’s just stupid.
the right way:
http://www.dalkescientific.com/writings/NBN/c_extensions.html
if you still want to do it in python, at least, use numeric
Feb 07, 2008 @ 09:15:02
In think there is a growing consensus among long-time Java programmers that we need a new JVM language to follow on from Java. Scala is that language!
Feb 07, 2008 @ 09:55:47
IMHO, it all boils down to the balance between three key concepts: productivity, ease of maintenance and runtime efficiency.
I might be wrong, but dynamic languages beat java in terms of productivity, much in the same way java beats c or c beats assembler. Yo can do things pretty fast, so they’re great, for instance, for prototypes and proofs of concept.
Ease of maintenance is were Java and the likes (and that includes .NET, Scala, and any other of your favorite non-dynamic high-level languages) beat dynamic ones. Refactoring is quite straightforward with modern IDEs, and loads of bugs are detected in compile time, while in dynamic languages they would be detected only in runtime, and worst of all, only sometimes.
Runtime efficiency is on Java, but the same could be said about C or, for that matter, ASM. Why are not we all using ASM? Obiously because the other two factors (productivity and maintenance) vastly outweight the increase in performance for all but the most speed-critic algorithms.
My favourite solution would probably fall somewhere in between, provided there’s a good integration between languages. Code your critical algorithms in Java, the glue that joins them in whichever language suits you best. That should improve the performance of the application as a whole versus a pure dynamic implementation. This approach would be especially useful with Groovy given its similarities and flawless integration with Java (yes, I admit it, I haven’t work a lot with it, but it’s already my second favourite language). Again, it’s all a matter of balance.
Feb 07, 2008 @ 13:37:43
@Enrique: I think you should replace “productivity” in your comment with “prototyping”. One of the major point of my blogs here was to explain that you are more productive with a statically typed language like Java. I know people make the same argument about RoR, which I disagree with cuz these people probably never tried SeamGen or Hibernate Tools. But that’s a topic for another blog.
Feb 07, 2008 @ 16:00:25
Bill, maybe I should clarify the terminology. What I meant with ‘productivity’ is the ability to write new code quickly. Then, unless you’re a genius, you won’t probably do it right the first time. So you’ll have to notice it, find the problem, and work out the best way to solve it. That’s what I call ‘maintenance’.
For any significant ammount of code both tasks will be performed at the same time. Probably, for small, simple projects (like a prototype, for instance) there will be much more coding than refactoring or debugging, so it will be more important to code quickly. For bigger projects, it will be increasingly important to be able to maintain it easily, starting by having checks that don’t allow you to commit errors.
I guess that the key point here is that ‘productivity’, as I think that you understand it, is the ability to write quickly not just some piece of code, but the complete codebase that meets all your requirements. I agree that at the end of the day, that’s what really matters, only that is not the concept I meant. And as such, it is a mix of writing new code and maintaining it.
Even taking into account the time required to complete the whole project, the answer to which language is more productive will probably depend on the project’s complexity, including which frameworks and libraries you have available to make your life easier. So the discussion is a bit pointless, unless we use it to learn a bit more about our options.
Just to clarify, I like Groovy, and I think it has potential, but as of now, my favourite language overall still is Java, despite all its verbosity.
Feb 11, 2008 @ 04:24:16
silly billy wrote Although benchmarks are either propaganda, out-dated, or not a good representation of real-world usages, glaring differences must be recognized.
1) For which of those 33 language implementations is the benchmarks game pure propaganda silly billy?
2) The benchmarks game website shows Java version “1.6.0_04” and Ruby version 1.8.6 – so much for silly billy’s “out of date” flamebait.
3) Surprise! “Real world programs TM” are only representative of themselves – not of other “Real world programs TM”!
silly billy wrote Yeah, its hard to take seriously a benchmark that outputs to stdout…
Yeah, it’s hard to take silly billy seriously when he mouths-off without understanding that io makes up 2% of the measured time for that little mandelbrot Java program.
Feb 14, 2008 @ 15:02:10
My favorite argument, and one which I agree with, is that developers really shouldn’t use “the best tool for the job”. Best is such a debatable word anyway.
If I am more productive coding an application in Java than I am in Perl then *for me* Java is best. I think it is impossible to nail down which language is best for any given job in an objective manner. Yes, there is a higher probability that Perl is better for parsing text than Java is, but in practice if most of your developers know Java very well but are Perl novices then you know you shouldn’t use the latter.
Feb 14, 2008 @ 18:04:34
Gili, I agree with you. It is very hard for me to context switch to another language. I’ve done it before with Python/Java. If I don’t use something for a few weeks to a month, I forget it and have to go back to the manuals.
Feb 14, 2008 @ 19:40:21
Scala has really hit the middle ground for me. Where it fails, for me, is development environment. There really isn’t one, but if you’re used to the typical support for dynamic languages, then this probably won’t be an issues for you anyway. If Scala matures from a tools perspective, I think it could easily keep me on the JVM for a long time.
Feb 14, 2008 @ 22:22:40
I wonder what all the fuzz on this dynamic vs. Java is all about. I don’t see dynamic languages and Java competing against each other. I rather see them perfectly complementing each other, especially since being directly supported by the Java scripting API. I’m using Python scripted Java on the project I’m working on and it works like a charm.
Feb 15, 2008 @ 12:09:01
What is interesting with the benchmark programs is how similar they all look (except for the lisp based version :). For some reason, the Java implementation is the only one which even attempted to stay true, albeit superficially, to its language paradigm. I wonder how things would turn out if one had a maintainability shoot out with language where your only aid was the language itself and no comments allowed. I would how things would turn out then. I am sure Java would do well there. From the list of implementation, I really like the Lisp based one’s. They look distinctly different from the rest. The rest all look pretty much the same.
Feb 15, 2008 @ 14:15:35
Dynamic languages like Ruby, Python, etc… are not typesafe/statically typed
Rationalization: “Type-safety makes my code too verbose and makes me less productive.”
Reality: Why can’t these people learn how to type? Modern IDEs make this point totally moot with code completion and code generation. Besides, why can’t we have a dynamic statically typed language?
Sometime the problem you try to solve is intrinsically dynamic. Language dictates their extension capabilities through type systems.
Because of that, you can’t do a truly dynamic system in Java without feeling guilty.
Also don’t mix-up type annotations with what really frustrate people: Java type system has a huge impact on the design decisions and tends to over-complexify the overall design. Aren’t most of design patterns elegant and proven solutions to work-around type system limitation?
Feb 15, 2008 @ 14:42:28
@Michael Toula: Aren’t most of design patterns elegant and proven solutions to work-around type system limitation?
You have a point, but these design patterns are also defining a contract. With dynamic typing, this contract cannot be enforced and you end up having to run all your unit tests to make sure everybody is following your contracted behavior rather than just having your compiler or IDE tell you. For instance, consider the observer/observable pattern. How are you going to *reliably* find all classes that are observers or observable?
The Disco Blog » Blog Archive » The weekly bag– Feb 15
Feb 15, 2008 @ 16:32:24
Feb 15, 2008 @ 16:56:39
@Billburke
Well in the case of dynamic systems, you really don’t want to. You will fail as advertised in the doc/contract.
If you need those checking’s then what you need is static type checking.
You can have a dynamically typed language with optional type annotation (ECMA Script). Is that what you refer as “dynamic statically typed language” ?
I wasn’t saying static type checking was not useful, sorry for the confusion.
I was saying Java is not your friend when you need to design a ‘dynamic system’ (solve a problem which is intrinsically dynamic).
You sure can design such systems in Java, but you will often end up with something over-engineered or you will try to introduce dynamism by trying to cheat the type system or creating string mini-language. Fitting round pegs in square hole. A lot of useful Java libraries look that way.
Feb 15, 2008 @ 17:21:04
@Michael Toula:
I hear you that doing dynamic things in Java is a bitch. I have experienced the very things you talk about when doing JBoss AOP. Hence, if you read my blog you see that I want more dynamic (but safe) features and libraries in the language to make dynamic programming easier.
Feb 18, 2008 @ 15:25:36
Myth: The amount to type is what is the problem with code verbosity. This is a very common myth in Java circles.
Fact: The problem is the verbosity smearing out real complexity over a lot of screen space, with a ton of noise between the true signal.
Myth: *Reliable* refactoring is critical in dynamic languages.
Fact: This emphasis on “*reliable*” falls down in the presence of tests, at which point a heuristic is fine.
Myth: Argument by personal incredulity/personal lack of imagination (“I just can’t imagine …”) is a valid argument.
Fact: This is a form of argument generally used by those that have little else to argue with, for instance the people arguing against evolution. It is rude.
Myth: Labelling things in an area you don’t know well “Myths” is reasonable behavior.
Fact: You’re being rude.
Myth: “Being typesafe/statically typed” is a relevant attribute to require.
Fact: “Being typesafe” is about enabling stuff. What you should require is this stuff. Though I think the most common case is that it is about giving you peace of mind to be able to say “It is statically typed”, no matter what the cost.
Feb 18, 2008 @ 19:18:38
I suggest re-exploring C++ and also having a peek at Haskell (which, by the way, is a statically typed dynamic language).
Anders Norås' Blog : Save Java, Dead or Alive!
Feb 18, 2008 @ 20:12:17
Feb 19, 2008 @ 18:21:38
@Jesse
I’m with you on C++. I just got back into it. She’s like your first kiss who you left when your family moved to another town 15 years ago. Then you bumped into her on the street and now she’s all grown up and hot hot hot.
C++ killed Ruby.
Feb 19, 2008 @ 19:58:29
C++? No thanks. I’d rather not go back to debugging dangling pointers and worrying about cross-platform incompatibilities and using shit like preprocessor defs and Imake to get around crossplatform incompatibilities and finally memory fragmentation. The only thing I miss from C++ is const and static object creation. The latter of which the JVM automatically figures out for you now.
Feb 19, 2008 @ 20:17:39
What’s a “statically-typed dynamic” language? ‘Dynamic’ in this context means ‘dynamically-typed’, does it not? This would appear to be an oxymoron.
The comment above about Haskell being a statically-typed dynamic language appears to be a confusion between ‘functional’ and ‘dynamic’. Haskell is a statically-typed functional language.
Feb 19, 2008 @ 20:31:24
I am with Brian there– and, what a funny-but-so-true reply! ;-P
Anyway, if one encounters excessive issues with cross-platform incompatibility, pointers, and the preprocessor, chances are good that the situation is exactly the one I mean when I suggest that it’s worth *re*exploring C++. Practices and compilers have changed considerably in recent years, and strongly for the better.
After all, a working JVM is a good indication that the C++ compiler on your platform’s working just fine.;-P
Feb 19, 2008 @ 20:40:30
“After all, a working JVM is a good indication that the C++ compiler on your platform’s working just fine.;-P”
Each (Sun, at least) JVM is specially developed and compiled for each supported platform. This is poor evidence for a lack of cross-platform issues. Even if all JVMs were written in C++, few people are compiling their JVM from source. Most people get binaries for their platform.
Feb 19, 2008 @ 20:43:42
…one more thing. I just wanted to say to Mr. Burke that I enjoyed the article and thought he made some good points. I’m not trying to troll or flame, just expressing an opinion. Thanks! -J.
Feb 22, 2008 @ 15:56:58
I thought I stated what i meant by “staticaly-typed dynamic language”
1) Typesafe introductions/mixins to either an instance or a class
For example:
class Foo {}
class Mixin implements MixinInterface {}
Mixin.add(Foo.class, new Mixin(), MixinInterface.class);
Foo foo = new Foo();
MixinInterface intf = (MixinInterface)foo;
Or:
Foo foo = new Foo();
Foo bar = new Foo();
Mixin.add(foo, new Mixin(), MixinInterface.class);
(foo instanceof MixinInterface) == true
(bar instanceof MixinInterface) == false
2) Ability to do AOP things like field/method/constructor interception without having to do bytecode magic
3) Ability to plug in at runtime annotation processing (not the Javac crap).
4) An instrument library that allows you to make schema changes to classes. (didn’t state this before)
Jul 19, 2012 @ 20:36:54
“dynamic statically typed language?”
What? Do you know what the terms mean?
Ruby and Python are both type safe and they are strongly typed. In fact, more strongly typed then Java is. In Ruby a specific object is a specific type and during that objects life, it will only ever be that type. You can not coerce it to be any other type, but you can easily add functionality to it if you need to.
Ever gotten a ClassCastException in Java? Java has a broken type system that you argue for it show you can be ignored.
Play with JRuby for a while to get a feel for how bad the Java language is. 10 Java lines to 1 equivalent and readable Ruby line is not uncommon.
Ruby isn’t less verbose because references in Ruby aren’t typed(I bet you don’t understand the diff of reference and the actual object) it is less verbose because of the constructs that Ruby has that Java does not. Duck typing helps a lot by not requiring massive numbers of interface files that exist only to keep the java compiler happy. Want to make your classes objects sortable in a list? No need for a ton of ceromony, include define a single method: and you are done. What if you want to also have other comparisons done(,etc), include the Comparable module and you get all that functionality for free.
What mixing in modules also gives you is the need to avoid repetitious delegates. Java likes composition which almost always requires quite a few delegate methods. Mixin a module and the need for all those lines of code vanishes.
The best part about Ruby is that many of the design patterns favored in Java become pointless. That is why you don’t see any nasty verbose factories and builders in Ruby, you simply don’t need them. The few patterns that are explicitly used in Ruby require very little ceremony and boilerplate. Want a singleton? include Singleton and everything is automatically done for you. No needing to explicitly make the constructor private, no needing to writing a getInstance() method, nothing.
Need to write your own data structure but don’t want to write all that code to handle iteration, finding min/max, map or reduce it and sort? include Enumerable and your done. With Java, you would have so much boilerplate and repetition the code size would be at least 20 times larger.
Have you ever had a requirement change that required no refactoring in Java? It happens often in Ruby.That is right, no new code and no refactoring exsiting code to meet the new requirement.
If you need an IDE to smooth over the warts of your language, your language has too many warts.
Jul 20, 2012 @ 15:16:55
Ya, Ruby et. al. are great when you’re just writing code yourself. But when you have to share in a team, or jsut downloading some random library on the internet they become really problematic. For example, recently I needed to use the python crypto library. Documentation was really poor, they had something liek javadocs, but the javadocs were useless because HTF do you know the return type or method parameters? The only way to figure out how to use various objects/methods was to dive into the internals of the code…
Not to mention that with Ruby Python, et. al. it is impossible to reliably do refactoring in these languages with the point and click stuff that is available in Java IDEs.
Finally, doesn’t really hurt my productivity or cause me to write more buggy code just because something might take a few more lines in Java than it does in Ruby. But, that is besides the point. Creating an application is only a small part of the lifespan of a project. Maintaining it is the problem. Without the refactoring and introspection abilities that a statically typed language gives you, maitenance and usability are huge issues. I’ve done VB, Powerbuilder, Perl, Tcl, and Python projects over the years, python was a joy, but Java IDEs have progressed so much that they hide the warts of the language. You can’t hide the warts of a unstatic language.
Static vs Dynamic: Why not Both? « Pointers Gone Wild
Nov 10, 2012 @ 02:39:09