Enforcing strict separation of JS code and Smalltalk code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Enforcing strict separation of JS code and Smalltalk code

Nicolas Petton
Hey guys,

I'm thinking about enforcing strict separation of inlined JS code. The
reason is that most of the JS code (in Amber codebase too) relies on the
Compiler output, and it shouldn't.

As soon as we open the door and allow developers to access temps vars,
etc. from the method context, the compiler output becomes more or less
part of Amber's API, and it all becomes very brittle.

To avoid such situations, I'm thinking about something quite radical:
only allow JS code in JS-only methods.

A method would contain either Smalltalk code of JavaScript code.

It would look like the following:

jsBodyMethod: aString
    <return aString>

stBodyMethod: aString
    ^ aString

In other words, inlined JS would be forbidden from smalltalk methods,
and smalltalk code would be forbidden from JavaScript methods.

Any thought/complain about that?

Cheers,
Nico

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: Enforcing strict separation of JS code and Smalltalk code

Bernat Romagosa
No complaints from my part, I think it'd make things much cleaner...


2013/2/7 Nicolas Petton <[hidden email]>
Hey guys,

I'm thinking about enforcing strict separation of inlined JS code. The
reason is that most of the JS code (in Amber codebase too) relies on the
Compiler output, and it shouldn't.

As soon as we open the door and allow developers to access temps vars,
etc. from the method context, the compiler output becomes more or less
part of Amber's API, and it all becomes very brittle.

To avoid such situations, I'm thinking about something quite radical:
only allow JS code in JS-only methods.

A method would contain either Smalltalk code of JavaScript code.

It would look like the following:

jsBodyMethod: aString
    <return aString>

stBodyMethod: aString
    ^ aString

In other words, inlined JS would be forbidden from smalltalk methods,
and smalltalk code would be forbidden from JavaScript methods.

Any thought/complain about that?

Cheers,
Nico

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.





--
Bernat Romagosa.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Enforcing strict separation of JS code and Smalltalk code

Herby Vojčík
In reply to this post by Nicolas Petton


Nicolas Petton wrote:

> Hey guys,
>
> I'm thinking about enforcing strict separation of inlined JS code. The
> reason is that most of the JS code (in Amber codebase too) relies on the
> Compiler output, and it shouldn't.
>
> As soon as we open the door and allow developers to access temps vars,
> etc. from the method context, the compiler output becomes more or less
> part of Amber's API, and it all becomes very brittle.
>
> To avoid such situations, I'm thinking about something quite radical:
> only allow JS code in JS-only methods.
>
> A method would contain either Smalltalk code of JavaScript code.
>
> It would look like the following:
>
> jsBodyMethod: aString
>      <return aString>
>
> stBodyMethod: aString
>      ^ aString
>
> In other words, inlined JS would be forbidden from smalltalk methods,
> and smalltalk code would be forbidden from JavaScript methods.
>
> Any thought/complain about that?

This is the simplest solution, but one will have hard time to optimize
some shortcuts, since every one must be put into method of its own. But
the core of the idea is fine.

I would propose to allow JS-only blocks as well:

[ :x :y | <jsUsing(x).asWellAs(y)> ]

This way, one can include well-placed pieces of JS-code into ST-method,
but they will still be separated.

> Cheers,
> Nico

Herby

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: Enforcing strict separation of JS code and Smalltalk code

Nicolas Petton

I did it and pushed to the ast-interpreter branch on github. There's no
js-only block for now, but we can think about it :)

Nico

Herby Vojčík <[hidden email]> writes:

> Nicolas Petton wrote:
>> Hey guys,
>>
>> I'm thinking about enforcing strict separation of inlined JS code. The
>> reason is that most of the JS code (in Amber codebase too) relies on the
>> Compiler output, and it shouldn't.
>>
>> As soon as we open the door and allow developers to access temps vars,
>> etc. from the method context, the compiler output becomes more or less
>> part of Amber's API, and it all becomes very brittle.
>>
>> To avoid such situations, I'm thinking about something quite radical:
>> only allow JS code in JS-only methods.
>>
>> A method would contain either Smalltalk code of JavaScript code.
>>
>> It would look like the following:
>>
>> jsBodyMethod: aString
>>      <return aString>
>>
>> stBodyMethod: aString
>>      ^ aString
>>
>> In other words, inlined JS would be forbidden from smalltalk methods,
>> and smalltalk code would be forbidden from JavaScript methods.
>>
>> Any thought/complain about that?
>
> This is the simplest solution, but one will have hard time to optimize
> some shortcuts, since every one must be put into method of its own. But
> the core of the idea is fine.
>
> I would propose to allow JS-only blocks as well:
>
> [ :x :y | <jsUsing(x).asWellAs(y)> ]
>
> This way, one can include well-placed pieces of JS-code into ST-method,
> but they will still be separated.
>
>> Cheers,
>> Nico
>
> Herby
>
> --
> You received this message because you are subscribed to the Google Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Nicolas Petton
http://nicolas-petton.fr

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: Enforcing strict separation of JS code and Smalltalk code

laci
My opinion on this issue is that since amber is running on top of JavaScript it has to integrate as much as possible seemlessly with the hosting environment. There are plenty of JavaScript libraries around and amber should embrace them. Integrating easily with third-party libraries is an important selling point for amber.

I am definately in love with amber/smalltalk but I am approaching the environment how it helps me increase my efficiency, better organize my projects and have lot of fun in the mean time.

I think what Nico is after will not contradict these remarks.
I am curious though how it will effect my current codes.
Some of them I shared with you - see Knockout sample codes.
I'd love to hear from you how to make this code better amber/smalltalk "citizen".

Regards,
 laci