Compiled JS

# doodad-js Admin (7 years ago)

By seeing many proposals about reducing the syntax for X and Y, I just want to open the idea of a [non-native] compiled JS world. What do you think?

Because, if that's not the problem (code size), what it is ?

Claude Petit


This email has been checked for viruses by AVG. www.avg.com

# /#!/JoePea (7 years ago)

What do you mean? Like coffeescript?

# doodad-js Admin (7 years ago)

Not “compile/transpile/... X-language to Javascript “, but compile Whatever/Javascript to “operational codes”, or [non-machine level] opcodes. You perfectly know what I mean.

From: trusktr at gmail.com [mailto:trusktr at gmail.com] On Behalf Of /#!/JoePea Sent: Tuesday, October 24, 2017 5:57 PM To: doodad-js Admin <doodadjs at gmail.com>

Cc: es-discuss <es-discuss at mozilla.org>

Subject: Re: Compiled JS

What do you mean? Like coffeescript?

/#!/JoePea

On Tue, Oct 24, 2017 at 2:06 PM, doodad-js Admin <doodadjs at gmail.com <mailto:doodadjs at gmail.com> > wrote:

Hi,

By seeing many proposals about reducing the syntax for X and Y, I just want to open the idea of a [non-native] compiled JS world. What do you think?

Because, if that’s not the problem (code size), what it is ?

Claude Petit

www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient

www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient Virus-free. www.avg.com

www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient

# Karl Cheng (7 years ago)

It seems that you're referring to something like WebAssembly webassembly.org or a binary AST syg/ecmascript-binary-ast. Please check them out and

see if they're similar to what you're thinking of.

# doodad-js Admin (7 years ago)

No WASM/AST.... Don’t challenge my ignorance.... I’m basically suggesting a way to compile:


const a = {};

```

 

to opcodes, like:

 

```hex

F10B6100

```

 

From: Karl Cheng [mailto:qantas94heavy at gmail.com] 
Sent: Wednesday, October 25, 2017 12:57 AM
To: doodad-js Admin <doodadjs at gmail.com>

Cc: es-discuss <es-discuss at mozilla.org>

Subject: Re: Compiled JS

 

It seems that you're referring to something like WebAssembly <http://webassembly.org/>  or a binary AST <https://github.com/syg/ecmascript-binary-ast> . Please check them out and see if they're similar to what you're thinking of.

 

On 25 October 2017 at 08:06, doodad-js Admin <doodadjs at gmail.com <mailto:doodadjs at gmail.com> > wrote:

Hi,

 

By seeing many proposals about reducing the syntax for X and Y, I just want to open the idea of a [non-native] compiled JS world. What do you think?

 

Because, if that’s not the problem (code size), what it is ?

 

Claude Petit

 

 


 <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> 

 <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> Virus-free. www.avg.com 

 <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
# Peter Jaszkowiak (7 years ago)

Compiling JS into an intermediate representation like the JVM or LLVM isn't really possible because JavaScript is a dynamic language.

That's my understanding anyways. The binary AST is as close as we can get.

# J Decker (7 years ago)

Each javascript engine uses different opcodes internally; there is no universal bytecode like Java, C# or Vulkan. using closure compiler or some other minification is the closest you can come; short symbols are quicker to process.

Trying to learn how to do that for V8 Engine, it is possible to generate precompiled javascript chunks and link them into the compiled product; but it's not a universal solution, and, as far as I can tell, isn't even really possible to do into dynamic libraries to add dynamically.

# Isiah Meadows (7 years ago)

Yeah, and in particular, you can't even reuse snapshots across V8 patch versions.

The binary AST is pretty much the only way to go on this one, and they have in fact looked for ways to reduce common sugared operations (like method vs function calls). Their focus is more on size and parsing/compilation speed, since it makes a very real difference in load times with larger web applications.

# Allen Wirfs-Brock (7 years ago)

Of course, it is possible to write a compiler for JavaScript. It’s just a programming language. But a traditional compiler that fully supports are the dynamic characteristics of JS is probably not going to be competitive with modern JITs.

However, a closed world whole-program optimizing compiler might be a plausible approach for JS applications that meet those characteristics. For example, some embedded applications.

Allen

.

# Michał Wadas (7 years ago)

I don't think it's possible to write a compiler that can run eval/Function without either JIT or interpretation.

On 25 Oct 2017 10:27 pm, "Allen Wirfs-Brock" <allen at wirfs-brock.com> wrote:

Of course, it is possible to write a compiler for JavaScript. It’s just a programming language. But a traditional compiler that fully supports are the dynamic characteristics of JS is probably not going to be competitive with modern JITs.

However, a closed world whole-program optimizing compiler might be a plausible approach for JS applications that meet those characteristics. For example, some embedded applications.

Allen

.

# Allen Wirfs-Brock (7 years ago)

On Oct 25, 2017, at 1:56 PM, Michał Wadas <michalwadas at gmail.com> wrote:

I don't think it's possible to write a compiler that can run eval/Function without either JIT or interpretation.

Runtime code injection would, of course, requires runtime compilation. Doesn’t mean that you have to use a JIT or interpreter.

# Uncloud Group (7 years ago)

It's fine. If you need to implement eval , then use the same compiler with different settings and context, nah?