andrewducker: (Default)
[personal profile] andrewducker
[livejournal.com profile] robhu has a good point over here.

At the moment we write Javascript in web pages, which is then compiled down by the various JIT methods that Firefox/IE/Webkit use to make it super fast.

Seeing as what's run clearly isn't the actual JS itself, but bytecode, why not have a standardised bytecode that all browsers would support, which would then mean you could write your code in any language you liked, providing there was a compiler to convert it to the standardised bytecode?

At the moment Google uses GWT to convert Java into Javascript that then gets converted into the running code, (And MS used to have something similar) wouldn't it be handy if the intermediate step wasn't necessary?

Date: 2010-11-11 01:04 pm (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
> developers can use whatever language they want and just compile it to the opcode language used by the browser.

Compile? What is this 'compile'?

Date: 2010-11-11 02:16 pm (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
Heh if the server can handle compiling it, fine. I'm not going to fart around with an extra level of stuff every time I want to change one line in my JS!

(no subject)

From: [identity profile] momentsmusicaux.livejournal.com - Date: 2010-11-11 02:52 pm (UTC) - Expand

(no subject)

From: [identity profile] momentsmusicaux.livejournal.com - Date: 2010-11-11 03:08 pm (UTC) - Expand

(no subject)

From: [identity profile] momentsmusicaux.livejournal.com - Date: 2010-11-11 03:26 pm (UTC) - Expand

(no subject)

From: [identity profile] momentsmusicaux.livejournal.com - Date: 2010-11-11 03:52 pm (UTC) - Expand

(no subject)

From: [identity profile] figg.livejournal.com - Date: 2010-11-12 01:49 am (UTC) - Expand

Date: 2010-11-11 02:40 pm (UTC)
From: [identity profile] strawberryfrog.livejournal.com
What is compile? For languages like Java or C# that use a bytecode, there are two things that you can call "compile".

First is turning the source into platform-independent bytecode, this happens upfront.

Second is "Just in Time compilation" during execution, when the runtime needs to use a method that has not been used before, and so needs to turn the bytecode for it into something that can actually execute on whatever cpu.

I'd say that Andrew is referring to the first of these.

Date: 2010-11-11 02:46 pm (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
Yes I know - I'm being facetious and saying that web developers won't put up with the faffiness of it.

(no subject)

From: [identity profile] robhu.livejournal.com - Date: 2010-11-11 03:53 pm (UTC) - Expand

(no subject)

From: [identity profile] figg.livejournal.com - Date: 2010-11-12 01:57 am (UTC) - Expand

Date: 2010-11-11 01:11 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
How do you get there from here, though?

Date: 2010-11-11 03:15 pm (UTC)
From: [identity profile] ciphergoth.livejournal.com
But what would web developers target?

Date: 2010-11-11 01:18 pm (UTC)
From: [identity profile] khoth.livejournal.com
And once we have standardised bytecode, the next logical step would presumably be to improve performance by creating CPUs that can execute it directly. In 20 years we'll all be back where we started.

Date: 2010-11-11 02:00 pm (UTC)
From: [identity profile] robhu.livejournal.com
Hey we could do this now - just implement the VM in Javascript ;-)

Date: 2010-11-11 01:20 pm (UTC)
From: [identity profile] andlosers.livejournal.com
Google have already proposed this, and I believe it's coming in Chrome. I'll see if I can dig out a link,

(no subject)

From: [identity profile] robhu.livejournal.com - Date: 2010-11-11 03:54 pm (UTC) - Expand

(no subject)

From: [identity profile] robhu.livejournal.com - Date: 2010-11-11 03:59 pm (UTC) - Expand

(no subject)

From: [identity profile] robhu.livejournal.com - Date: 2010-11-11 04:14 pm (UTC) - Expand

Date: 2010-11-11 01:21 pm (UTC)
drplokta: (Default)
From: [personal profile] drplokta
The bytecode that each browser turns the Javascript into is obviously different for each browser, because each browser has different internals. So in your plan, each browser would still have to translate the bytecode into different bytecode in order to execute it. In which case, why not just call the existing Javascript language the bytecode, which also has the advantage of being human-readable, and make it the target for your compilers from other languages?

(The answer is because Javascript is lacking some functionality, not specified with sufficient rigour, in too many versions, with varying degrees of implementation in the browsers, and it takes too long to get changes into the spec, but I don't see how another spec for bytecode is going to be any different in this respect. You can only get round these problems by owning and implementing the spec yourself -- in which case you're re-inventing Flash or Silverlight.)
Edited Date: 2010-11-11 01:22 pm (UTC)

(no subject)

From: [personal profile] drplokta - Date: 2010-11-11 01:31 pm (UTC) - Expand

(no subject)

From: [personal profile] drplokta - Date: 2010-11-11 01:39 pm (UTC) - Expand

(no subject)

From: [identity profile] strawberryfrog.livejournal.com - Date: 2010-11-11 03:12 pm (UTC) - Expand

(no subject)

From: [identity profile] skington.livejournal.com - Date: 2010-11-11 02:32 pm (UTC) - Expand

(no subject)

From: [identity profile] call-waiting.livejournal.com - Date: 2010-11-11 01:31 pm (UTC) - Expand

(no subject)

From: [personal profile] drplokta - Date: 2010-11-11 01:34 pm (UTC) - Expand

(no subject)

From: [identity profile] call-waiting.livejournal.com - Date: 2010-11-11 01:37 pm (UTC) - Expand

(no subject)

From: [identity profile] jouni osmala - Date: 2010-11-11 02:37 pm (UTC) - Expand

Date: 2010-11-11 02:45 pm (UTC)
From: [identity profile] strawberryfrog.livejournal.com
The bytecode that each browser turns the Javascript into is obviously different for each browser

Currently yes. But there's no reason why that should be so. In fact, isn't that the proposal?

Something like how The Java and .Net bytecodes are standardised and designed to be platform-independent, which is kinda the point. They can be executed by different engines. Those engines may have different internals, but executing that standard bytecode is their entire purpose.

.Net bytecode is less obviously "platform-independent" than Java. But there are 32 and 64 bit windows runtimes that work with the same bytecode. And mono/Linux run that same bytecode.
Edited Date: 2010-11-11 02:50 pm (UTC)

Native Client

Date: 2010-11-11 02:12 pm (UTC)
From: [identity profile] http://www.google.com/profiles/albzey (from livejournal.com)
Exactly this exists already. Check out this:
http://code.google.com/p/nativeclient/

It probably will use LLVM bytecode at some point (I think it already supports that). Atm., it executes x86.

The hard part is the sandboxing. But it seems they have done well on this in the Natice Client.

Date: 2010-11-11 02:36 pm (UTC)
From: [identity profile] strawberryfrog.livejournal.com
Reminds me of this recent rant: "we can write any program we like so long as it's in Javascript".

A bytecode standard is not a bad idea.

Date: 2010-11-11 03:08 pm (UTC)
From: [identity profile] lpetrazickis.livejournal.com
I would imagine that browsers currently have no defences against malicious bytecode, since they generate it themselves and so don't expect it to be malicious. Their defences against forkbombs, buffer overflows, and the like are likely in the Javascript compiler, not the bytecode interpreter. There'd be huge security issues with giving third parties on the internet direct control of the browser internals as they are.

Date: 2010-11-11 03:18 pm (UTC)
From: [identity profile] strawberryfrog.livejournal.com
The defence against forkbombs is that that Javascipt has little-to-no threading ability. Long-running scripts get shut down within a minute.

Security in bytecode systems is a problem that has been solved more than once, so it doesn't appear to be that hard. JS has no pointers, hence no buffer overflows, and I'd expect the bytecode to be likewise. In Java or .Net bytecode, security is mainly about gating access to the system API by untrusted bytecode.
Edited Date: 2010-11-11 03:21 pm (UTC)

(no subject)

From: [identity profile] lpetrazickis.livejournal.com - Date: 2010-11-11 04:18 pm (UTC) - Expand

(no subject)

From: [identity profile] strawberryfrog.livejournal.com - Date: 2010-11-11 04:23 pm (UTC) - Expand

(no subject)

From: [identity profile] figg.livejournal.com - Date: 2010-11-12 01:56 am (UTC) - Expand

(no subject)

From: [identity profile] strawberryfrog.livejournal.com - Date: 2010-11-12 09:27 am (UTC) - Expand

Date: 2010-11-11 04:01 pm (UTC)
From: [identity profile] robhu.livejournal.com
Why give it access to browser internals? Just provide access to the things JS already has access to, like the DOM.

Date: 2010-11-11 03:51 pm (UTC)
From: [identity profile] robhu.livejournal.com
This post is the top item on Hacker News atm btw :)

Date: 2010-11-12 02:20 am (UTC)
From: [identity profile] figg.livejournal.com
the problem here is not compiling to javascript but compiling to javascript *semantics*. if your lists, strings or dictionaries work differently, you have to re-implement them (in javascript)

llvm would be a nice idea but is still relatively young and unsuitable for jit compilation or mobile devices.

anything higher up (like an object system or datatypes like a string or a list or a hash) would present the same problems as compiling to javascript.

October 2025

S M T W T F S
    1 2 3 4
5 6 7 8 9 10 11
12 13 14 15161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Oct. 15th, 2025 11:02 pm
Powered by Dreamwidth Studios