mentby.com
Blog | Jobs | Help | Signup | Login

can we use direct ruby instaed of javascript ?



Hi Ninjas,

i am a ROR Developer .
I feel happy to develop in ROR over other frameworks because of the
simplicity of Ruby Language

For browser side code i am using Javascript/ActionScript .
but i would like to use Ruby in browser side also (instead of
Javascript/ActionScript)
Is there any way to do this ?
or
Is there any active development /future plan to implement Ruby VM on
browser engine (instead of javascript/actionscript engines ) ?
if yes? then i also want to join in that community/dev team .
if not? please some body initiate a plan to develop a Ruby VM for
browser engine (so i can join with you)
i know already that prototype/jquery frameworks are there but those are
not
looking like pure ruby code

Anyone have an Idea/Suggestion/Intrest ?
please let me know

by

Mokkai @ TLI

.


Sniper Abandon Wed, 06 Apr 2011 23:45:55 -0700

Hi,

I am sure there are quite a few projects out there to do what you wish to.
Quite sometime back I came across this - http://ejohn.org/blog/ruby-vm-in-javascript/

< http://ejohn.org/blog/ruby-vm-in-javascript/ >That should help you out, I
haven't used it or worked on it extensively, but it is close to what you
wish to do.

--
Thanks & Regards,
Dhruva Sagar < http://dhruvasagar.net> >
----------------------------
Technical Developer - Mentor,
Artha42 Innovations Pvt. Ltd. < http://www.artha42.com/> >

Become an expert in Rails. Join our 3 day Rails workshop and learn Ruby,
Rails 3, Cucumber and Git. http://www.railspundit.com


Dhruva Sagar Wed, 06 Apr 2011 23:53:42 -0700

thx , but i thing HotRuby is dead. There are no updates from last 3
years

.


Sniper Abandon Thu, 07 Apr 2011 00:34:33 -0700

Hmmm, I only know of that.

--
Thanks & Regards,
Dhruva Sagar < http://dhruvasagar.net> >
----------------------------
Technical Developer - Mentor,
Artha42 Innovations Pvt. Ltd. < http://www.artha42.com/> >

Become an expert in Rails. Join our 3 day Rails workshop and learn Ruby,
Rails 3, Cucumber and Git. http://www.railspundit.com


Dhruva Sagar Thu, 07 Apr 2011 01:18:10 -0700

If you have been to any large corporate's offices of late, you would
notice that pcs are so locked down it's surprising you're still allowed
to touch the keyboard.

If you tried to require such users to load Ruby, you would immediately
lose a huge target audience. Would all those employees wait until they
got home to user your site, or log on to a more friendly competitor?

If you want to code in Ruby, I suggest you need to think about a
pe-processor that turns Ruby into JavaScript prior to sending the page.

.


Mike Stephens Thu, 07 Apr 2011 05:29:56 -0700

I have a project called ColdRuby which is essentially a Ruby 1.9
bytecode
to JavaScript translator. It cannot (yet) even load mspec/RubySpec, but
is
already somewhat usable.

  http://github.com/whitequark/coldruby

--
   WBR, Peter Zotov.


Peter Zotov Thu, 07 Apr 2011 06:04:17 -0700

Another option to use might be JRuby.

Java plugin is quite standard in browsers these days.

HTH

Michal


Michal Suchanek Thu, 07 Apr 2011 06:06:25 -0700

I don't see any license listed.  Did I overlook it?

--
Chad Perrin [ original content licensed OWL:  http://owl.apotheon.org  ]


Chad Perrin Thu, 07 Apr 2011 09:50:16 -0700

The Ruby license, of course. It is implicit.
(Indeed, I just forgot to add it to git. Fixed already.)

--
   WBR, Peter Zotov.


Peter Zotov Thu, 07 Apr 2011 13:39:02 -0700

I haven't looked closely enough to know which way this goes, but one of
two sets of conditions are likely to apply here:

1. It's "implicit" because it incorporates Ruby Licensed code in a way
that requires the Ruby License to be applied to the whole project.  In
this case, you violate the terms of the license if you do not include the
license text with the code.

2. It's not "implicit", and needs license notification.

I'm not a lawyer, but I spend a lot of time trying to avoid giving
lawyers reason to contact me with bad news.

--
Chad Perrin [ original content licensed OWL:  http://owl.apotheon.org  ]


Chad Perrin Thu, 07 Apr 2011 19:02:41 -0700

"ØbžH­š(!µ·šrÛš–\ªº+^Š{^­ë-Šx¢»azŠâ‚)Ú–š,µê


Julian Leviston Thu, 07 Apr 2011 21:47:45 -0700

Please, treat all my words about implicit license as a form of bad
humor.
It does not incorporate any external code, just mine, and I always
intended
to use the Ruby license, but it somehow got not included in the git
tree.

Thanks for your efforts.

--
   WBR, Peter Zotov.


Peter Zotov Fri, 08 Apr 2011 02:48:14 -0700

That is incredibly cool! But can you really implement *any* language? What
about languages that are completely different from javascript? In Haskell,
for example, everything happens lazily, data is immutable, there is a
complex type system. Can you really map this right to javascript? (or am I
misunderstanding OMeta?)


Josh Cheek Fri, 08 Apr 2011 06:04:13 -0700

My take here is full of handwaving.  I'll admit I've never of O-Meta
before.

Comp sci point of view:
OMeta is turing complete?  If so then by universality it is possible.

Further, OMeta can run C#, it doesn't take a huge stretch of the
imagine to say it can run C. Haskell can compile to C*. Therefore it can
run Haskell.

The best way to do it though would be to port the STG-Machine** into
O-meta.  Fun!

* Check the list of GHC features  http://www.haskell.org/ghc/

** See "Implementing lazy functional languages on stock hardware: the
Spineless Tagless G-machine", Simon Peyton Jones 1992. The link on SPJ's
website is dead unforunately :(

I've been tempted to port STG into ruby before.  Or maybe just
G-Machine because it's simpler.  It just sounds like a fun little
project.

Sorry for yet another random long interjection on functional
programming.  SIGH.


Johnny Morrice Fri, 08 Apr 2011 06:21:58 -0700

Also, if you've already proved the program shouldn't crash due
to type errors, you don't need to check any types as you run.


Johnny Morrice Fri, 08 Apr 2011 06:35:45 -0700

Do we actually need to have full ruby spec implemented? Don't forget
about the 20/80 rule of the universe - there are only 20 % of features
that provide 80% of value.

It seems that it's impossible in any time soon to create a full-featured
Ruby JS. There were lots of project of this kind (HotRuby, RubyJS, Red,
.... google github) and it seems that all of them are dead by now,
although some of them got some attention in past.

But look at the success of CoffeeScript, it doesn't try to solve all
problems at once, but it eliminates the most annoying problems.

Maybe it would be better do it in the same way? Take the core part, that
can be easily implemented and leave the rest to the better time?

.


Alexey Petrushin Sat, 09 Apr 2011 21:02:38 -0700

This is incredibly cool but can you really translate any language into
machine code?
What about languages that are completely different from machine code?
In Haskell, for example, everything happens lazily, data is immutable,
there is a complex type system. Can you really map this right to
machine code? (Or am I misunderstanding your question?)

Thanks

Michal


Michal Suchanek Mon, 11 Apr 2011 02:47:15 -0700

Of course. Otherwise, the code wouldn't be executed on a CPU, after all.

The question is if you can implement every feature a language has, but
that's more about how much work and workarounds you are willing to
invest (dynamic code is a touch harder, but since there's JRuby which
started before the JVM had any sort of dynamic capabilities at all..),
rather than pure ability.

See also: "Compiler" and "bytecode" or "intermediary language". ;)

After all, a programming language is a construct, an abstraction, that
allows us to instruct computers to do Stuff(tm), without us having to
lower ourselves to the CPU's level. ;)

The question is kind of like asking if computers can represent text,
or do substraction of irrational numbers, when all they do is binary
addition. ;)

--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.


Phillip Gawlowski Mon, 11 Apr 2011 03:35:25 -0700

And since it can execute on something as limited and poorly designed
as x86 assembly I see no reason it could not run on OMeta, whatever it
is.

Creating something worse than x86 assembly for running code might be a
sort of a challenge in itself.

Thanks

Michal


Michal Suchanek Mon, 11 Apr 2011 06:00:35 -0700

Accidentally went off list for a bit.

Ruby isn't translated to Assembly, you must interpret it.

The hypothesis was that you could implement *any* language. C falls within
that set. The leak is that JavaScript does not have the properties of
assembly. There is a reason you don't write systems level code with
interpreted languages, because they have very different properties. Wouldn't
implementing a systems level language in an interpreted language cause the
systems level language to lose the attributes that make it a viable choice
for such a domain?

Hmm, seems to be because you CC'd me in your response to the ML, so when I
hit reply, gmail sent it to you instead of the list. I changed the recipient
of this one, hopefully we're back on list. You might change your client to
avoid that, it seems unlikely that I'll be the only one to do this.


Josh Cheek Mon, 11 Apr 2011 06:19:12 -0700

YARV generates byte code. The byte code is interpreted by the Ruby VM.
The Ruby VM runs on an operating system. The Operating system runs on
machine code.

Ruby *can* run on machine code, or it wouldn't run at all. The
question is how many intermediary steps are needed to get it running,
and at what costs (it's generally easier, it appears, to run a dynamic
language on some sort of interpreter, if only to make an abstraction
only once).

It doesn't need them. The compiler takes care of that.

Since IE9 was just released to the general public, here's an MSDN
article on Chakra: http://blogs.msdn.com/b/ie/archive/2010/03/18/the-new-javasc[..]

IE9 is a latecomer to the "compile JS" party, too. Google's V8 is one
of the first.

That's a question of optimization.

Even GCC has several optimization switches; some more, some less
dangerous to apply to code.

C's whole reason of existence is that it is a higher level language
than assembly with the compiler taking care of translating the
constructs of the higher level language into something that a CPU
understands.

Yup, back on list. Though, IME GMail doesn't change the reply-to
header (maybe it got borked somewhere).

--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.


Phillip Gawlowski Mon, 11 Apr 2011 07:09:06 -0700

Yes but some language features would depend on a run-time library.
The compiler-interpreter dichotomy is better thought of as a continuum.

Bill Rutiser


William Rutiser Mon, 11 Apr 2011 07:49:22 -0700

That would be the STG machine I was talking about, which definitely
could be ported.

I'd it'd be easier to first compile Haskell into a bytecode
representation, which you make OMeta interpret.  That means you could
use an existing compiler frontend.  And just port the run-time library
in OMeta.

TBH for the effort if you wanted Haskell in the browser, it'd
probably be less convoluted to write a plugin.  (In Haskell?)

Cheers
Johnny


Johnny Morrice Mon, 11 Apr 2011 09:54:25 -0700

Sorry, I'm an idiot.  Had a brainfart... really you could write a naive
STG machine interpreter in OMeta, which would constitute run-time
support

Equally you could just compile it further.


Johnny Morrice Mon, 11 Apr 2011 09:58:25 -0700



Post a Comment