
RubyJS: A JavaScript standard library based on the Ruby core-lib - Kerrick
http://rubyjs.org/
======
sharkbrainguy
If you're after a standard library for Javascript, you could do worse than
including es5-shim. Which has the advantage of being a library that
(partially) implements a standard: Ecmascript 5.

    
    
        > es5-shim.js and es5-shim.min.js monkey-patch a
        > JavaScript context to contain all EcmaScript 5
        > methods that can be faithfully emulated with a
        > legacy JavaScript engine.
    

It provides Array::map, Array::filter, Array::reduce as defined in Ecmascript
5 along with String::trim and others, as well as replacing buggy
implementations.

Previous versions of es5-shim included shims for things that cannot be
correctly or completely shimmed in ES3 but those have since been separated and
I now recommend including es5-shim in basically all web projects to get closer
to a modern javascript in most browsers.

~~~
evincarofautumn
Sure. You could do worse than RubyJS as well. This project is implementing the
standard set by the reference implementation of Ruby and its standard library.
And having used Ruby a bit, I’ve come to find its standard library quite good,
as dynamic languages go. So it doesn’t much matter that ES5 features are “more
native”—here and now, it’s still a matter of preference.

~~~
arcatek
I don't really see why RubyJS would be better than PHP.js.

And I'm definitely not saying that PHP.js should be used.

[edit] To be more specific, I really don't see the point of using a third-
party library when the native methods are available. IMHO, if you choose a
language, you should stick with it.

~~~
sebilasse
RubyJS creator here. I was just missing so many (native) methods in
javascript. i liked the standard library of javascript and there is an
extensive public ruby testsuite that i could use to test my implementation
against. Plus i liked the idea of taking something that already works
elsewhere and translate it JS, instead of coming up with my own API. IMO it's
the same as using underscore/lodash, stringjs, etc, just all in the same
library with the same coding standards and interoperability between classes.

~~~
ericb
What is the license currently? It says Affero in the presentation, but github
shows MIT license?

------
bhaak
I laughed so hard about the testimonial on the page:

    
    
      If I had to code JavaScript I would use RubyJS.
      Yukihiro (Matz) Matsumoto, creator of Ruby
    

Of course, the best authority for writing ruby-like JS is Matz, who else would
be better? ;-D

------
orensol
I'm not a rubyist, and I can see how this can be nice for ruby developers, but
IMHO, if you need javascript - use javascript.

Why add another layer of complexity and error proneness? What happens when a
different js programmer needs to review your code? Or when you need to write
some Node.js code and forgot all about syntax?

"The main motive is to have a decent standard library for JavaScript" - jQuery
works just fine.

~~~
railsmax
Prototype, Underscore, jQuery, Coffescript, .... RubyJS - nobody love pure JS,
when you've got a chance to write nice code(short and descriptive) - why don't
use this ability? And about "different js programmer needs to review your
code" - if you don't know smth then you need to study it. That's a fundament
of programming world(probably not only programming))

~~~
arcatek
Untrue. The ES5 standard contains most of the features required for any
application (my main issue being the Date prototype which could easily be
improved).

jQuery, Prototype and afaik Underscore helper functions have been wrote when
the standard wasn't ready. Now that it is, developers should start using them.

------
DanielRibeiro
James Coglan did a lot of this with his excelent JS.Class[1]

[1] <http://jsclass.jcoglan.com/>

------
pzaich
How are callbacks handled in this library? I prefer js anonymous functions to
Procs & lambdas in Ruby.

~~~
bstar77
I do as we'll. After working in node for a bit I have come to appreciate how
nice the call backs work, but I hate the fact I have to use them every where.
Plus ruby has a few ways to implement callbacks which can be confusing.

~~~
gmac
Yes, as someone who really likes Ruby, this is probably my least favourite
thing about it — the messy profusion of subtly-different functiony things
(Procs, blocks, methods, ...).

------
jashkenas
For those who haven't already looked, the implementation of the standard
library (in CoffeeScript) is pretty interesting:
<https://github.com/rubyjs/core-lib/blob/master/ruby.coffee>

------
saadazzz
Is Underscore.js not good enough for you guys? Really?

~~~
nailer
I'm not a fan of RubyJS, but I dislike underscore for the same reason: it
encourages people to use implementation specific versions fo existing ES5
standard methods [1].

I use ES5 shim instead. That way when I ditch support for IE8, I don't have to
fix anything.

[1] Obviously Underscore doesn't have methods, it has utility functions
attached to punctuation.

------
damncabbage
Shades of <http://phpjs.org/functions/>?

------
brunnogomes
I think this is really awesome. I know I can use ES5 and I don't even have to
worry about old browsers because my app requires the latest to work, but I
think this is more a preference thing.

Hell, I could even use JQuery for a lot of this stuff, but I really like ruby
standard library and it's cleaness.

------
Raphael_Amiard
I did a quick check of the implementation, am I wrong in thinking every
primitive type is boxed ?

If it is the case, i expect the performance to be pretty abysmal. Do you have
some data on that ?

~~~
sebilasse
Yes. Primitives are boxed. However method arguments are only boxed when
needed, which makes it as fast as normal. In the methods internally are all
using JS primitives (there are some left-overs where that's not the case yet).
Wrapper objects are similarly fast as extending native JS types.

~~~
Raphael_Amiard
Ok thanks !

------
curlypaul924
This is just a library. There's nothing "standard" about it.

------
sebilasse
RubyJS creator here.

Here's the launch presentation at jscamp.asia:
<http://www.youtube.com/watch?v=7T0PJbJaMwA>

------
amalag
Love to see a comparison with this to SugarJS

------
homakov
why

