When comparing Ruby (via Opal) vs Earl Grey, the Slant community recommends Ruby (via Opal) for most people. In the question“What are the best languages that compile to JavaScript? ” Ruby (via Opal) is ranked 16th while Earl Grey is ranked 29th. The most important reason people chose Ruby (via Opal) is:
Ruby has a very clean syntax that makes code easier to both read and write than more traditional Object Oriented languages, such as Java. For beginning programmers, this means the focus is on the meaning of the program, where it should be, rather than trying to figure out the meaning of obscure characters. presidents = ["Ford", "Carter", "Reagan", "Bush1", "Clinton", "Bush2"] for ss in 0...presidents.length print ss, ": ", presidents[presidents.length - ss - 1], "\n"; end
Ranked in these QuestionsQuestion Ranking
Pros
Pro Elegant syntax
Ruby has a very clean syntax that makes code easier to both read and write than more traditional Object Oriented languages, such as Java. For beginning programmers, this means the focus is on the meaning of the program, where it should be, rather than trying to figure out the meaning of obscure characters.
presidents = ["Ford", "Carter", "Reagan", "Bush1", "Clinton", "Bush2"]
for ss in 0...presidents.length
print ss, ": ", presidents[presidents.length - ss - 1], "\n";
end
Pro Popular
Ruby is one of the most popular languages for developing web sites. As a result, there's an abundant amount of documentation, sample code, and libraries available for learning the language and getting your project up and running. The most popular features are just 'gem install' away.
Pro Powerful hygienic macros
Earl Grey's macro system allows for creating powerful control structures that look just like builtin ones. EG also supports macro libraries which allows developers to provide their macros/DSLs for others to use.
Pro Pattern matching
Pattern matching is an incredibly powerful tool that, once you've tried, you cannot live without. This is not your average hacked-together pattern matching but a complete and integral feature to the language.
Pro ECMAScript 6 Asynchrony
Earl Grey provides Promises based on ECMAScript version 6 and as many NPM libraries already implement. Earl Grey also provides a promisify
function that converts old-fashioned callback-style asynchrony to promises.
Pro Fully compatible with Node.js ecosystem
Anything available on NPM can be used just as easily with Earl Grey. In fact, everything else can be used too! Earl Grey has interfaces to Browserify, Webpack, and even experimental support for SystemJS. Earl Grey can even be used to generate npm packages that any node-compatible language can use!
Cons
Con Meta-programming causes confusion for new developers
The ability for libraries to open classes and augment them leads to confusion for new developers since it is not clear who injected the functionality into some standard class.
In other words, if two modules decide to modify the same function on the same class can introduce a number of issues. Mainly, the order in which the modules are included matters. Since you more or less can't tell what kind of "helper" functions a module might write into any class, or for that matter, where the helper function was included from, you may sometimes wonder why class X can do Y sometimes but not at other times.
Con Not true static typing
EG gives you the tools to implement your own type-checking inside of argument lists and elsewhere but there's no analysis done at compile-time like other compile-to-js languages.
Con Unfamiliar syntax
While the language shares a lot of DNA with Python, there are still many new (and interesting) features/sugar that may take some time to get used to.