Re: Compiled JS

2017-10-25 Thread Allen Wirfs-Brock

> On Oct 25, 2017, at 1:56 PM, Michał Wadas  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. 

___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Compiled JS

2017-10-25 Thread Michał Wadas
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"  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

.


___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Compiled JS

2017-10-25 Thread Allen Wirfs-Brock
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

.


___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Shorter syntax for arrow function assignment

2017-10-25 Thread dante federici
Sorry I was unclear -- I was referring to "If we were to add this syntax,
then seeing this code with knowing how JS interprets the current syntax, I
would expect [x] to be the outcome"

I wasn't trying to imply it would work as-is -- either way, sorry for not
being clear. If anything the confusion around the newline interacting with
the shortened syntax as well as this miscommunication should probably
indicate something about the idea.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Shorter syntax for arrow function assignment

2017-10-25 Thread T.J. Crowder
On Wed, Oct 25, 2017 at 3:11 PM, J Decker  wrote:
>
> ya this is not a syntax error.
> myFn()
> {
> }

Indeed it isn't, but that isn't what I referred to in dante's message,
nor is it what he was suggesting it would be. He quoted

```js
myFn() {
}
```

...which is indeed a syntax error because ASI doesn't kick in. This:

```js
myFn()
{
}
```

...isn't a syntax error because ASI adds a `;` after `myFn()`, making
it a function *call* followed by a standalone block, not the function
declaration/expression he suggested it was.

All of which is by-the-bye, though, as I don't think Brian was
suggesting that anyway... :-)

-- T.J. Crowder
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Shorter syntax for arrow function assignment

2017-10-25 Thread J Decker
On Wed, Oct 25, 2017 at 4:57 AM, T.J. Crowder <
tj.crow...@farsightsoftware.com> wrote:

> On Tue, Oct 24, 2017 at 6:26 PM, dante federici
>  wrote:
> >
> > So, something like:
> > ```
> > myFn() {
> > }
> > ```
> >
> > Would be considered as:
> > ```
> > var myFn = function() {
> > }
> > ```
> >
> > with what semantics exist now. Not best practices, but what is
> > currently interpreted in the language.
>
> No, it isn't. It's a `SyntaxError: Unexpected token {`. There's a big
> difference between `myFn() { }` and `myFn = function() { };` The latter is
> valid syntax for the horror of implicit globals (in loose mode; strict mode
> fixed it). The former is just a syntax error. (It would be valid method
> syntax if it were inside an object initializer or `class`.)
>

ya this is not a syntax error.
myFn()
{
}


> But AFAIK, Brian Blakely wasn't promoting that syntax anyway. His original
> post only ever uses this shorthand with `export`, so I think it was meant
> to be specific to exporting.
>
> -- T.J. Crowder
>
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Extend Object Dereferencing

2017-10-25 Thread T.J. Crowder
On Wed, Oct 25, 2017 at 1:15 PM, Sebastian Malton
 wrote:
>
> I didn't mean that part when I said multiple levels. I meant
> the following
> ```
> const abc = { { bcd, cde, efg: {qnc} } = obj};
>
> ```

I was responding to your initial assertion in your first message, which
didn't show that form. It just said

> Currently you can do the following
>
> `const {abc, xyz, qnc} = obj;`
>
> However if you want to go more than one level deep then you have to do it
again for each level.
>
> ...
>
> I therefore propose the ability to do the following
>
> `const {abc, xyz, qnc.awj} = obj;`
>
> And this would create the variables 'abc'', 'xyz', 'awj' with the
> values from obj.

I was pointing out how you can do that without having to "do it again."

Perhaps you could clarify what you're actually proposing. Your first
message talked about individual variables for the parts of `obj`;
subsequently you seemed to be talking about creating a new object
(combining object initializers with destructuring)...?

-- T.J. Crowder
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Extend Object Dereferencing

2017-10-25 Thread Sebastian Malton
  I didn't mean that part when I said multiple levels. I meant the following ```const abc = { { bcd, cde, efg: {qnc} } = obj};```This would most definitely seem strange as to why the outer {} is needed for picking from a single object From: tj.crow...@farsightsoftware.comSent: October 25, 2017 8:10 AMTo: sebast...@malton.nameCc: es-discuss@mozilla.orgSubject: Re: Extend Object Dereferencing  On Tue, Oct 24, 2017 at 7:51 PM, Sebastian Malton wrote:>> Currently you can do the following >> const {abc, xyz, qnc} = obj;>> However if you want to go more than one level deep then you have> to do it again for each level.You don't have to do it again, you can nest patterns as deeply as you like. In this case:```jsconst {abc, xyz, qnc: {awj}} = obj;```jE.g.: http://jsfiddle.net/yyud2gvg/```jsconst obj = {    abc: 1,    xyz: 2,    qnc: {        awj: 3    }};const {abc, xyz, qnc: {awj}} = obj;console.log(abc, xyz, awj); // 1, 2, 3```js-- T.J. Crowder
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Extend Object Dereferencing

2017-10-25 Thread T.J. Crowder
On Tue, Oct 24, 2017 at 7:51 PM, Sebastian Malton
 wrote:
>
> Currently you can do the following
>
> const {abc, xyz, qnc} = obj;
>
> However if you want to go more than one level deep then you have
> to do it again for each level.

You don't have to do it again, you can nest patterns as deeply as you like.
In this case:

```js
const {abc, xyz, qnc: {awj}} = obj;
```j

E.g.: http://jsfiddle.net/yyud2gvg/

```js
const obj = {
abc: 1,
xyz: 2,
qnc: {
awj: 3
}
};
const {abc, xyz, qnc: {awj}} = obj;
console.log(abc, xyz, awj); // 1, 2, 3
```js

-- T.J. Crowder
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Compiled JS

2017-10-25 Thread Isiah Meadows
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.

On Wed, Oct 25, 2017, 02:21 J Decker  wrote:

> 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.
>
>
> On Tue, Oct 24, 2017 at 10:48 PM, Peter Jaszkowiak 
> wrote:
>
>> 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.
>>
>> On Oct 24, 2017 23:43, "doodad-js Admin"  wrote:
>>
>>> No WASM/AST Don’t challenge my ignorance I’m basically
>>> suggesting a way to compile:
>>>
>>>
>>>
>>> js
>>>
>>> const a = {};
>>>
>>> ```
>>>
>>>
>>>
>>> to opcodes, like:
>>>
>>>
>>>
>>> ```hex
>>>
>>> F10B6100
>>>
>>> ```
>>>
>>>
>>>
>>> *From:* Karl Cheng [mailto:qantas94he...@gmail.com]
>>> *Sent:* Wednesday, October 25, 2017 12:57 AM
>>> *To:* doodad-js Admin 
>>> *Cc:* es-discuss 
>>> *Subject:* Re: Compiled JS
>>>
>>>
>>>
>>> It seems that you're referring to something like WebAssembly
>>>  or a 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  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
>>>
>>>
>>>
>>>
>>>
>>>
>>> 
>>>
>>> Virus-free. *www.avg.com*
>>> 
>>>
>>>
>>> ___
>>> es-discuss mailing list
>>> *es-discuss@mozilla.org*
>>> *https://mail.mozilla.org/listinfo/es-discuss*
>>> 
>>>
>>>
>>>
>>>
>>> --
>>> 
>>>
>>> - Karl Cheng (Qantas94Heavy)
>>> 
>>>
>>> ___
>>> es-discuss mailing list
>>> es-discuss@mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>>
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Shorter syntax for arrow function assignment

2017-10-25 Thread T.J. Crowder
On Tue, Oct 24, 2017 at 6:26 PM, dante federici
 wrote:
>
> So, something like:
> ```
> myFn() {
> }
> ```
>
> Would be considered as:
> ```
> var myFn = function() {
> }
> ```
>
> with what semantics exist now. Not best practices, but what is
> currently interpreted in the language.

No, it isn't. It's a `SyntaxError: Unexpected token {`. There's a big
difference between `myFn() { }` and `myFn = function() { };` The latter is
valid syntax for the horror of implicit globals (in loose mode; strict mode
fixed it). The former is just a syntax error. (It would be valid method
syntax if it were inside an object initializer or `class`.)

But AFAIK, Brian Blakely wasn't promoting that syntax anyway. His original
post only ever uses this shorthand with `export`, so I think it was meant
to be specific to exporting.

-- T.J. Crowder
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Shorter syntax for arrow function assignment

2017-10-25 Thread Isiah Meadows
I 100% agree it's a terrible idea, and this proposal's syntax sucks for
this very reason.

I'll note a few things:

1. The main proposal AFAICT is for `let foo() {}`, not `foo() {}`.
2. It does *not* syntactically conflict with object methods, because it's
only valid as a statement.
3. It conflicts with existing ASI, but only with `let` and `var`, where
this is currently unambiguously valid (it's open real estate with `const`):

```js
let
foo
(
x
)
{
}

// Parsed in both sloppy and strict as:
let foo;
(x);
{}
```

On Tue, Oct 24, 2017, 16:09 dante federici 
wrote:

> The use case fading away doesn't mean you can drop support for it, or that
> it won't still be in use.
>
> Please stop trying to push your "shorthand" syntax of:
> ```
> myFn() {
> }
> ```
>
> It's already been pointed out in multiple cases that:
> 1. The current usages are not "outmoded"
> 2. The proposed syntax has misleading `this` binding without the arrow
> 3. Blocks, ASI, and the object shorthand notation either conflict or make
> it vague how to interpret
>
> This isn't a beneficial syntax moving forward, and it doesn't seem to add
> anything other than "I don't like typing '='".
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Compiled JS

2017-10-25 Thread J Decker
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.


On Tue, Oct 24, 2017 at 10:48 PM, Peter Jaszkowiak 
wrote:

> 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.
>
> On Oct 24, 2017 23:43, "doodad-js Admin"  wrote:
>
>> No WASM/AST Don’t challenge my ignorance I’m basically suggesting
>> a way to compile:
>>
>>
>>
>> js
>>
>> const a = {};
>>
>> ```
>>
>>
>>
>> to opcodes, like:
>>
>>
>>
>> ```hex
>>
>> F10B6100
>>
>> ```
>>
>>
>>
>> *From:* Karl Cheng [mailto:qantas94he...@gmail.com]
>> *Sent:* Wednesday, October 25, 2017 12:57 AM
>> *To:* doodad-js Admin 
>> *Cc:* es-discuss 
>> *Subject:* Re: Compiled JS
>>
>>
>>
>> It seems that you're referring to something like WebAssembly
>>  or a 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  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
>>
>>
>>
>>
>>
>>
>> 
>>
>> Virus-free. *www.avg.com*
>> 
>>
>>
>> ___
>> es-discuss mailing list
>> *es-discuss@mozilla.org*
>> *https://mail.mozilla.org/listinfo/es-discuss*
>> 
>>
>>
>>
>>
>> --
>> 
>>
>> - Karl Cheng (Qantas94Heavy)
>> 
>>
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss