Rubyscript instead of javascript

D

Damjan Rems

It is just a thought. And I wouldn't know anything about possible
problems implementing this,

but

wouldn't be nice if rubyscript could be executed inside of browser just
like javascript does.


by
TheR
 
M

Marc Heiler

wouldn't be nice if rubyscript could be executed inside of browser just
like javascript does.

Yeah. I think most people like Javascript, but I actually hate it.

Pretty all my code is in ruby, and I dont plan to add Javascript to this
at all.
 
E

Eleanor McHugh

It is just a thought. And I wouldn't know anything about possible
problems implementing this,

but

wouldn't be nice if rubyscript could be executed inside of browser
just
like javascript does.

There are several projects for getting Ruby into the browser, ranging
from Yahoo's approach of a plugin that can run Ruby in parallel with
the browser to the HotRuby bytecode interpreter which is implemented
in JavaScript. As of yet none is a good solution for general-purpose
browser-side Ruby.


Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net
 
D

Damjan Rems

There are several projects for getting Ruby into the browser, ranging
from Yahoo's approach of a plugin that can run Ruby in parallel with
the browser to the HotRuby bytecode interpreter which is implemented
in JavaScript. As of yet none is a good solution for general-purpose
browser-side Ruby.

It should probably be done like a plugin. Like Flash. Since it already
can be compiled for numerous platforms porting to browsers shouldn't be
a problem.

Of course security should be tightened and DOM must be implemented.

by
TheR
 
M

Michal Suchanek

2009/9/5 Damjan Rems said:
It should probably be done like a plugin. Like Flash. Since it already
can be compiled for numerous platforms porting to browsers shouldn't be
a problem.

The problem with yet another plugin is that everybody who visits your
site has to install it which may not be possible because they are
running a (mostly) readonly live-cd or an administratively locked-down
PC in an office (you even have to be administrator to install Explorer
plugins on WIndows). And then the plugin will be available only for
finite number of browser-platform combinations. If you are running a
different browser or a supported browser but on a different platform
you get no plugin.

That's why Flash sucks.
Of course security should be tightened and DOM must be implemented.

Bindings for DOM in each browser in the world ... or a compiler into
Javascript that already has them?

The fact DOM bindings are already present is Javascript and Javascript
(actually ECMA script) is widely supported is why there are projects
targeting this platform.

Thanks

Michal
 
M

Mario Camou

[Note: parts of this message were removed to make it a legal post.]

Well, Java is installed in most computers and there's JRuby.

The problem with yet another plugin is that everybody who visits your
site has to install it which may not be possible because they are
running a (mostly) readonly live-cd or an administratively locked-down
PC in an office (you even have to be administrator to install Explorer
plugins on WIndows). And then the plugin will be available only for
finite number of browser-platform combinations. If you are running a
different browser or a supported browser but on a different platform
you get no plugin.

That's why Flash sucks.
Bindings for DOM in each browser in the world ... or a compiler into
Javascript that already has them?

The fact DOM bindings are already present is Javascript and Javascript
(actually ECMA script) is widely supported is why there are projects
targeting this platform.

Thanks

Michal
 
M

Michal Suchanek

2009/9/5 Mario Camou said:
Well, Java is installed in most computers and there's JRuby.

Sure having Java installed does not automatically mean that it works
in your browser, too.

And it's no longer the web. AFAIK Java in browsers is just like movies
in browsers - it just runs in part of the browser window but has no
relation to the originating web page whatsoever - you could equally
well save the applet and run it in a separate window.

On the other hand, JavaScript allows for small pieces of code that
modify the HTML pages in the browser without redownloading the page
from the server.

Thanks

Michal
 
E

Eleanor McHugh

Well, Java is installed in most computers and there's JRuby.

It's arguable as to whether Java or Flash is more widely distributed,
however with IE still the dominant browser environment I continue to
anticipate IronRuby for the Silverlight 2 platform.


Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net
 
D

David Masover

Yeah. I think most people like Javascript, but I actually hate it.

Really? I tend to find the opposite.

That is, most people who know a little Javascript and a lot of some other
language hate Javascript. I actually know Javascript well enough that I...
still hate it, but no more than I hate Ruby. Which is to say, I love it,
mostly.

I'd suggest starting here, if you want to really learn Javascript:

http://crockford.com/javascript/

Now, I do agree that I'd probably rather work with Ruby in the browser. But I
don't think it's worth the hassle, at least until something like Google Gears
gets widespread.
 
D

Damjan Rems

Rome wasn't build in a day and it would be wrong to force millions users
like for example Twitter users to download some plugin to be able to
continue visiting their beloved web site.

I see Ruby and Rails perticualy as ideal tool for building company
Intranets. Where the problem is that you usualy do not have enough
employes and learning another language, which is different enough, is
not productive.

It was stated on a lot of places that Ruby and Rails is easy to learn.
New employes tend to integrate into existing projects faster. Not to
mention productivity.

I also see Ruby as a language which might finaly replace Basic as
scripting language for all kind of complex applications. Imagine Ruby
and gems embaded into OpenOffice.


by
TheR
 
E

Eleanor McHugh

Rome wasn't build in a day and it would be wrong to force millions
users
like for example Twitter users to download some plugin to be able to
continue visiting their beloved web site.

I see Ruby and Rails perticualy as ideal tool for building company
Intranets. Where the problem is that you usualy do not have enough
employes and learning another language, which is different enough, is
not productive.

It was stated on a lot of places that Ruby and Rails is easy to learn.
New employes tend to integrate into existing projects faster. Not to
mention productivity.

JavaScript is ugly (to my eyes) but I wouldn't say it was any more
difficult to learn than Ruby, and unless your team is comprised of
developers who only know Ruby and hence would be facing the learning-
my-second-language problem it's unlikely to have a major impact on
overall productivity across the lifespan of any non-trivial project.

That said, if I could do browser-side coding in Ruby it would
certainly make me much happier.
I also see Ruby as a language which might finaly replace Basic as
scripting language for all kind of complex applications. Imagine Ruby
and gems embaded into OpenOffice.

It's unlikely to happen anytime soon for the simple reason that Ruby
is still perceived as a niche language.


Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net
 
T

Tony Arcieri

[Note: parts of this message were removed to make it a legal post.]

Really? I tend to find the opposite.

That is, most people who know a little Javascript and a lot of some other
language hate Javascript.

As someone who works with JavaScript on a daily basis, programming in it
some and working with tools to support it the rest of the time, I really
loathe JavaScript.

JavaScript tries to force everything into a universal abstraction (the
object) and yet that universal abstraction doesn't even work consistently.

Take, for example:

[].prototype

*gasp* It's undefined! How can we check if something is an array? I
suppose this works, albeit painfully so:

[].constructor.toString().indexOf("Array") != -1

The typical retort I hear from those who like JavaScript is that if you ever
need to do ^^^ you're writing your program wrong, however I'd just like to
add a bit of polymorphism and it seems like it requires a huge hack.

Also rather unintuitive and nonsensical is the behavior of the coercing ==
operator. For example:

NaN == NaN

...is false! We lack basic reflexivity. Even worse:

if([]) { ... }

...is true, in a boolean context [] gets coerced into a true value,
however...

if([] == false) { ... }

...is also true! When coerced by the == comparison operator [] gets coerced
an entirely different way.

I'm not sure how JavaScript wound up being so painfully inconsistent.
 
T

Tony Arcieri

[Note: parts of this message were removed to make it a legal post.]

For example:

NaN == NaN

...is false! We lack basic reflexivity.

Although it appears Ruby behaves the same way:
=> false
 
D

David Masover

As someone who works with JavaScript on a daily basis, programming in it
some and working with tools to support it the rest of the time, I really
loathe JavaScript.

So do I, just no more than any other language I've had to work with enough to
understand it thoroughly.
JavaScript tries to force everything into a universal abstraction (the
object) and yet that universal abstraction doesn't even work consistently.

You could say the same for Ruby, certainly. Indeed, we try to use "duck
typing" for most things, yet the type of an object suddenly matters when you
want to bind an UnboundMethod.

Or, to take another example, every object can have singleton methods defined,
like so:

foo = "foo"
class << foo
def bar
:baz
end
end
foo.bar

Not that this is useful, but try doing it to an integer. That is:

foo = 5
class << foo
...

Doesn't work. I can't think of a good reason it shouldn't work. After all, you
can define instance variables on integers:

5.instance_variable_set :mad:foo, :bar
5.instance_variable_get :mad:foo

Not that this has actually bitten me in practice, of course. Other things,
like the difference between symbols and strings, seem much more likely to
confuse people.
The typical retort I hear from those who like JavaScript is that if you
ever need to do ^^^ you're writing your program wrong, however I'd just
like to add a bit of polymorphism and it seems like it requires a huge
hack.

Similarly, if you need to know with absolute certainty whether a Ruby object
will respond to a method, before sending the method -- or whether an object is
of a certain type -- you're doing it wrong.

But if you think about it, you're basically wanting to know whether
something's an Array or an object, right? Because if you were wanting any of
the other basic types, it would be something you could check with 'typeof', if
nothing else.
Also rather unintuitive and nonsensical is the behavior of the coercing ==
operator. For example:

NaN == NaN

...is false!

I'm fairly sure something similar going on here:

[] == [] is false.
[] == ![] is true.

It's sort of an A is not A problem.

These are weird little warts, but frankly, they bother me far less than when I
have issues with the design itself. For example, I can probably abstract away
those annoyances, but it's harder to abstract away something like this:

class Hello {
public static void main(String [] args) {
System.out.println("Hello, world!");
}
}

That is, I find Javascript's ugliness to be skin-deep, while Java's ugliness is
pervasive.

At the end of the day, I suppose it's a matter of taste, and we'd probably all
be much better off with a common VM in the browser (something like Java or
Flash, but more closely tied to the DOM, and standard), so that no one is
forced into one language or another.
 
E

Eleanor McHugh

At the end of the day, I suppose it's a matter of taste, and we'd
probably all
be much better off with a common VM in the browser (something like
Java or
Flash, but more closely tied to the DOM, and standard), so that no
one is
forced into one language or another.

It seems that's part of Microsoft's thinking with Silverlight and the
Mono project's Moonlight Linux/X11 implementation could make it a
credible platform.


Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net
 
A

Alex Young

Tony said:
Although it appears Ruby behaves the same way:

=> false

This particular example has nothing to do with coercion, and everything
to do with IEEE floating point implementation. It's also correct, in
both cases.
 
D

David Masover

It seems that's part of Microsoft's thinking with Silverlight and the
Mono project's Moonlight Linux/X11 implementation could make it a
credible platform.

It looks interesting, but I have several concerns:

- Mono always seems to be several steps behind .NET.
- Microsoft has helped Mono and Moonlight, because they're fighting Flash. If
Flash dies, that support may simply be dropped.
- Software patents?
- Forces users to download a third-party plugin.
- Tons of additional crap, like XAML. Do we need it? I could be convinced,
but I'd rather see it built on top of a simpler runtime, to ease third-party
implementation.
- Is this the best we could do? Microsoft built Silverlight on .NET because
they're Microsoft, and it's .NET. Is it the best VM for the job?

What I've heard suggested instead is to take Adobe's Tamarin engine, merge it
into open browsers like Firefox, and let Adobe quietly push it into IE via
Flash. This has the advantage that everyone already has Flash, and Flash
generally stays up to date somehow or other, so it would be instant,
widespread adoption -- yet the Flash would be a hack for where the standard
itself isn't supported.

That's a powerful platform -- if that's the direction Adobe is going. I have
no idea -- a quick Google doesn't show whether any other languages target
Flash, or could reasonably target Flash.

An example of where this kind of scheme might already be working well is the
HTML5 video tag -- it can be made to gracefully degrade into a Flash player,
and depending on the format you choose, it could even be the same video stream
for either.
 
J

Jörg W Mittag

We already have. It's called ECMAScript. The only thing missing to
make it a great truly great VM is GOTO, but it actually *does* have
GOTO, it's just spelled funny: E-X-C-E-P-T-I-O-N.

Here is just a small excerpt of the languages that target ECMAScript:

* CIL bytecode (meaning any CLI language, and that includes Ruby,
Python, PHP, Perl, Scheme, Prolog(!), ... can run on ECMAScript),
* JVM bytecode (meaning any JVM language, and that includes Ruby,
Python, PHP, Scheme, ... can run on ECMAScript),
* YARV bytecode (meaning any YARV language, and that *obviously*
includes Ruby can run on ECMAScript),
* any language implementation that uses PyPy (including Python,
Smalltalk, Prolog),
* Clojure,
* C,
* Flapjax,
* Caja,
* Objective-J,
* Clamato,
* haXe and
* links.
It looks interesting, but I have several concerns:
- Mono always seems to be several steps behind .NET.

This not a problem if you explicitly target Mono. Also, while Mono
does not implement the entirety of .NET, it *does* implement the
entirety of ECMA-334 aka ISO/IEC 23270 (C#) and ECMA-335 aka ISO/IEC
23271 (CLI).

It's also not entirely true: in several areas, .NET is several steps
behind Mono: modularity (developing the CoreCLR for Silverlight was a
major effort, while Mono was modular from day one),
Compiler-as-a-Service (available in Mono for over a year, planned but
not even announced yet for .NET 5 or 6), iPhone support (Mono runs on
the iPhone just fine, .NET probably never will), static native
compilation (Mono can compile a .NET application together with the
Mono runtime into a single static native executable, .NET always needs
the .NET runtime installed, even if you use NGen), 64 Bit array
indices (explicitly allowed by the specification, but only implemented
by Mono with no plans by Microsoft), SIMD support (some vague comments
by Microsoft, but nothing even remotely concrete), Continuation
support (no interest from Microsoft)-
- Microsoft has helped Mono and Moonlight, because they're fighting Flash. If
Flash dies, that support may simply be dropped.

Microsoft already helped Mono before they did Silverlight. And even
before Microsoft started helping them, Mono did just fine.

Oh, and Silverlight has already failed. The next version of Office
will be web-based, but it uses only HTML, CSS and ECMAScript. If you
can build MS Office, Google Wave and Sun Research's Lively Kernel
without any plugins, then what the heck *would* you need Silverlight
for?
- Software patents?

The ECMA specifications are covered by the Microsoft Specification
Promise. Of course, that doesn't cover the parts not part of the ECMA
specifications, which includes Silverlight.
What I've heard suggested instead is to take Adobe's Tamarin engine, merge it
into open browsers like Firefox,

This was the original goal for replacing SpiderMonkey. However, as it
turned out, Tamarin is heavily biased towards statically typed
languages like ActionScript, which is why Mozilla and Adobe decided to
drop Tamarin, only extract the tracing JIT and duct-tape that onto
SpiderMonkey, producing the current Mozilla ECMAScript engine,
TraceMonkey.

Tamarin sounded like a good idea, when ECMAScript 4 was still the
future, but that died, thank the heavens.
and let Adobe quietly push it into IE via
Flash. This has the advantage that everyone already has Flash, and Flash
generally stays up to date somehow or other, so it would be instant,
widespread adoption -- yet the Flash would be a hack for where the standard
itself isn't supported.

Actually, Flash is also only supported on a tiny fraction of
platforms. Indeed, I believe Mono is actually better in this regard.
For example, Flash 9 was released in 2006, but in 2007, the most
recent version of Flash for Linux was still Flash 7 (released 2003!),
which did not support ActionScript 3 nor Flex.

Also, to this day, Flash for Linux is only available for 32-Bit x86
processors (which is pretty much exactly 0% of computers sold in the
last 2 years, with the exception of netbooks), and only for a small
number of distributions and browsers (excluding, for example, Opera).
That's a powerful platform -- if that's the direction Adobe is going. I have
no idea -- a quick Google doesn't show whether any other languages target
Flash, or could reasonably target Flash.

Here is just a small excerpt of the languages that target Flash:

* YARV bytecode (meaning any YARV language, and that *obviously*
includes Ruby),
* C and
* haXe.

jwm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,458
Latest member
Chris#

Latest Threads

Top