Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What can JavaScript learn from Ruby?

The ECMAScript working group has started working on the next edition of the language. What can they learn from Ruby?

like image 582
Yehuda Katz Avatar asked Jul 08 '09 20:07

Yehuda Katz


People also ask

Is it better to learn Ruby or JavaScript?

Ruby is also much more successful overall. It's faster, easier to learn, more popular, and its software engineers have had the highest average salaries in 2017. Java's declining popularity also makes it less attractive to prospective coders.

Is Ruby easier to learn than JavaScript?

Ruby's syntax is easier than JavaScript's. It is short, easy to visualize, and often has only one way of achieving a result.

Should you learn Ruby before JavaScript?

At the end of the day, having familiarity and a professional ability to code with one of the major programming languages is a great start to your developer career. By mastering one language, you'll have an easier time transitioning to the next.

Does Ruby use JavaScript?

Ruby is used with HTML, JavaScript, and CSS to create web applications that run on a web server. It is most commonly known as a platform for developing server-side web applications.


1 Answers

This is actually a much more challenging question than it appears at first.

The main reason for this is that it's been shown to be very difficult to force browser vendors, by way of specification, to implement the pet or favourite features of language enthusiasts, users, other vendors, or academics without very good justifications. This is how we ended up with the ES4 spec pretty much dead on the table, which yielded a much less ambitious (though still pretty awesome) ES Harmony. A language like JavaScript which has such insanely tricky political deployment and implementation issues is simply unable to be the type of awesome experimental playground that Ruby has been for much of its lifetime. Anyone who has followed es-discuss (the ECMAScript language development mailing list) has probably noticed by now that it takes many many months of debate and experimentation to merely articulate and agree upon common language features like, in recent memory, operator overloading, or short form lambda notation.

Perhaps it may be too much to ask of any working group to nail a spec that will target every device on the planet? On the surface it would appear that it's a very narrow band of lessons, even the social ones, that can be easily transferred from Ruby to the JavaScript.

To that end, and to ease the burden of Brendan Eich and his group:

One of the most urgently useful "lessons" to bring to the language from a perspective inspired by Ruby (or LISP) would be language malleability. The ability to introduce new features, syntax hacks and domain-specific languages not originating from a inner cabal of spec writers would be incredibly valuable. Allow the language to be a good place for modular extensions to the language to be made, and for those extensions to be self-hosted, so as to minimize fragmentation risks and to allow those changes to permeate and be mashed up, etc.

Such malleability would allow the community at large to apply lessons from all sorts of directions and allow the Internet to decide over time which lessons are worthwhile from which language, etc. We've already got a high rate of iteration and evolution happening at the other ends of this sandwich, i.e. in browsers themselves (eg: HTML5), and in js libraries. If that was able to happen more intimately at the language level, we could see some very interesting things happen very quickly.

[addendum/edit]:

The language has to be able to morph significantly because a small group of people is simply incapable of anticipating all the things it'll ever be used for. A theme that comes up on es-discuss often is that underlying current of designing "a language for the next 10-15 years". IMHO, this is an incredibly unrealistic goal. If you don't build it, the system will evolve an alternative long before spec's intended lifetime. With the immense speedup in javascript engine/JIT technology of late, we're already seeing the early signs of this happening in the form of new languages being written on top of JavaScript or being cross-compiled on the fly into JavaScript. Yep, even Ruby: http://hotruby.yukoba.jp/

like image 134
Maciek Avatar answered Sep 22 '22 14:09

Maciek