I agree, better tools are often very quick to write. I'll plug what I think is a lovely piece of code now ;) Here is a tiny toy Ruby framework inspired by Arc https://github.com/julesjacobs/Raamwerk (29 loc, if you don't count blank and end lines). In the examples you can see that even though the framework is a toy you can write interesting applications much more concisely and logically than with e.g. Rails. For example a page that displays a counter, and a link to increase the counter and a link to decrease the counter:
def counter(i)
puts "the counter is #{i}"
link("increase") { counter(i+1) }
link("decrease") { counter(i-1) }
end
The quality of the code you're reusing is much more important than the quantity.Edit. Another example: a stack based calculator.
def calc(stack)
tag(:p){ puts stack }
%w{+ - * /}.each do |op|
link(op){ calc([stack[0].send(op, stack[1])] + stack[2..-1]) }
end
10.times{|n| link(n){ calc([n] + stack) } }
end
Video demonstration: http://dl.dropbox.com/u/388822/calculator.aviI think you are really just picking an easy target with JavaScript. I hope that kind of analysis doesn't hold for other languages.
I am in complete agreement that the code re-use needs to be efficient, and that sometimes I spend more time looking for re-usable code then it would take to implement it myself. I was using Rails as an example. Sure, I have my problems with the libraries I use, but overall they help me get 10x the work done that I would if I didn't have them at my disposal.
I think the future of programming languages is: those that enable the easiest code re-use will gain a huge advantage. There will be cross-language tools like github that all languages can use, but if I were to design a language that 1 principle would always be favored.
I used to think this was true, and then after I became a bit experienced with web development, I realized that the bulk of code (JavaScript, in particular) released for public use ("reusable") is garbage. Complete, utter garbage. Poor APIs, terrible abstractions, namespace contamination, a lot of assumptions that those packages are the only ones in use.
Yes, you can slap something together quickly with the bits of turds available online, but when it comes to customization and fine-tuning, you will either spend a lot of time undoing half of what some other developer did with their package or writing one of your own. For writing my own widgets, tools, and frameworks, I want a great language. And when I build tools with a great language AND with a good language design approach (it takes both), I have things I can reuse.
More available reusable code is not an advantage. I am coming to think that the more accessible a language is for just anyone to use, we get lesser quality shared code.
There are gems, for sure -- I will happily name jQuery as an excellent, extensible framework. A lot of the community's jQuery plugins, on the other hand...