Hi all,
It took a while - and I am not talking about how long I have worked on it (especially in calendar years), but since I first mentioned it on this list, or even since I presented it at the UK meetup - but now it's finally here: https://github.com/fmateoc/JsSqueak
If you want to try it out and are facing difficulties following the brief instructions on the project's web page, please let me know, hopefully this will lead to better instructions
Thank you and have fun!
Florin
That's quite a piece of work you have there. Congratulations!
On 2023-06-24, at 7:37 AM, Florin Mateoc florin.mateoc@gmail.com wrote:
Hi all,
It took a while - and I am not talking about how long I have worked on it (especially in calendar years), but since I first mentioned it on this list, or even since I presented it at the UK meetup - but now it's finally here: https://github.com/fmateoc/JsSqueak
If you want to try it out and are facing difficulties following the brief instructions on the project's web page, please let me know, hopefully this will lead to better instructions
Thank you and have fun!
Florin
tim -- tim Rowledge; tim@rowledge.org; http://www.rowledge.org/tim Strange OpCodes: MW: Multiply Work
Truly!
On 24. Jun 2023, at 19:41, Tim Rowledge tim@rowledge.org wrote:
That's quite a piece of work you have there. Congratulations!
On 2023-06-24, at 7:37 AM, Florin Mateoc florin.mateoc@gmail.com wrote:
Hi all,
It took a while - and I am not talking about how long I have worked on it (especially in calendar years), but since I first mentioned it on this list, or even since I presented it at the UK meetup - but now it's finally here: https://github.com/fmateoc/JsSqueak
If you want to try it out and are facing difficulties following the brief instructions on the project's web page, please let me know, hopefully this will lead to better instructions
Thank you and have fun!
Florin
tim
Hi Florin,
On Jun 24, 2023, at 7:38 AM, Florin Mateoc florin.mateoc@gmail.com wrote:
Hi all,
It took a while - and I am not talking about how long I have worked on it (especially in calendar years), but since I first mentioned it on this list, or even since I presented it at the UK meetup - but now it's finally here: https://github.com/fmateoc/JsSqueak
Bravo!! Can you say something about performance re SqueakJS and trunk Spur?
Also, can you sketch how do you deal with each of - thisContext, thisContext sender et al… - processes - non-local return and unwind-protect - exception handling ? AdvThanksance
If you want to try it out and are facing difficulties following the brief instructions on the project's web page, please let me know, hopefully this will lead to better instructions
Thank you and have fun!
Florin
Eliot, _,,,^..^,,,_ (phone)
Sounds interesting!
On 2023-06-25T12:32:04-07:00, eliot.miranda@gmail.com wrote:
Hi Florin,
On Jun 24, 2023, at 7:38 AM, Florin Mateoc <florin.mateoc(a)gmail.com> wrote:
Hi all,
It took a while - and I am not talking about how long I have worked on it (especially in calendar years), but since I first mentioned it on this list, or even since I presented it at the UK meetup - but now it's finally here: https://github.com/fmateoc/JsSqueak
Bravo!! Can you say something about performance re SqueakJS and trunk Spur?
I would be interested in that, too. Does it have practical performance in the browser? Are you having any concrete applications for JsSqueak?
Also, can you sketch how do you deal with each of
- thisContext, thisContext sender et al…
- processes
- non-local return and unwind-protect
- exception handling
?
I found something in https://github.com/fmateoc/JsSqueak/blob/master/docs/implementation-notes.tx....
AdvThanksance
If you want to try it out and are facing difficulties following the brief instructions on the project's web page, please let me know, hopefully this will lead to better instructions
Thank you and have fun!
Florin
Eliot, _,,,^..^,,,_ (phone)
Best, Christoph
Hi Eliot,
You have nothing to worry about, for now :) Just to give you an idea, in order to get reasonable results in the test runner, I have increased the timeout 10 fold and I still get some of the tests timing out. But, while I did try to be mindful about performance, I did not try to optimize for testing - I suspect there is a lot of low hanging fruit in the reflection area that could make the tests run faster. Anyway, general responsiveness is very good, so it is a perfectly usable environment. I think that, after addressing the development environment/reflection areas, further performance improvements would require type inferencing/inlining, which would come with significant complications re de-optimization if you want to preserve Smalltalk's flexible nature - but they would work well for packaged applications that do not require that level of flexibility. On the other hand, it is nice to be able to just sit back and let the cohorts of developers at Google work on improving performance for you :)
Regarding thisContext, some of the commonly used patterns, like String>>translated, Object>>deprecated or Object>>mustBeBoolean are handled at (JavaScript source) code generation time. Since we already have for free a (JavaScript) source-level debugger and profiler in the browser (or Node), there is no need for a context/stack-walking based debugger or profiler. For odd usages, thisContext translates to the instantiation of a Context object which just has its method/block and receiver populated, thus returning nil for sender. Exceptions are handled specially, see below. This seems to cover "normal" images pretty well, but other specific scenarios could be covered with similarly specialized solutions.
With processes I, I first made a half-hearted attempt to generate continuation-passing style JavaScript source code, but this looked like it was going to have horrible performance, so I tried to combine it with some type specializations (something like inline caches, but in the source JavaScript). This in turn lead to horrendous/unreadable/undebuggable code (to be fair even the straight CPS code was quite hard to read and very different from the original Smalltalk), so I dropped it. It was a fun exercise though :). Then I had the revelation that I could use JavaScript's yield* (iterating yield) for invocations, using the generators' stacks as the processes' stacks, and this turned out to work pretty well, as Chrome's optimizer seems to be dealing with it just fine (occasionally while debugging I can see that the JavaScript engine is inlining some of the calls). All the methods are defined as generator functions, and they are all invoked via yield* (other than #class and #==). The scheduler is a loop that just invokes the current processes' block (which is also a generator function) next() function, and the process/semaphore primitives use real (non-iterating) yield to pass the baton back to the scheduler loop and on to the next process.
non-local return is using a top-level try/catch in the methods needing it, where the catch identity matches the NonLocalReturn exception instantiated for the method (and thrown from the closure) to perform a normal method return or rethrow. At generation time I am also optimizing away some of them for well known patterns like at:..ifAbsent:[^...] or detect:..ifNone:[^...]
unwind protect is also using JavaScript level try/finally or try/catch constructs.
exception handling is performed by reifying (just) the handlers (instead of all the contexts chain) associated with a process. Smalltalk-level signal is not a JavaScript throw, it is a loop within the handlers, plus a try/catch to handle resume (resuming is a JavaScript throw). Unwinding is a JavaScript throw. Primitive 199 is not just a marker, but an installer for new handlers, a loop (for retries) and a try/catch to handle local exit from the handler block.
All the best, Florin
On Sun, Jun 25, 2023 at 3:32 PM Eliot Miranda eliot.miranda@gmail.com wrote:
Hi Florin,
On Jun 24, 2023, at 7:38 AM, Florin Mateoc florin.mateoc@gmail.com wrote:
Hi all,
It took a while - and I am not talking about how long I have worked on it (especially in calendar years), but since I first mentioned it on this list, or even since I presented it at the UK meetup - but now it's finally here: https://github.com/fmateoc/JsSqueak
Bravo!! Can you say something about performance re SqueakJS and trunk Spur?
Also, can you sketch how do you deal with each of
- thisContext, thisContext sender et al…
- processes
- non-local return and unwind-protect
- exception handling
? AdvThanksance
If you want to try it out and are facing difficulties following the brief instructions on the project's web page, please let me know, hopefully this will lead to better instructions
Thank you and have fun!
Florin
Eliot, _,,,^..^,,,_ (phone)
Hi Florin,
I can totally relate to this feeling of the seemingly endless work and perseverance needed just to realize one of these projects we do (as I'm sure many in this community can) and, for now, would simply like to say "congratulations". Moments like this are much more rare than moments striving, please enjoy it! I've actually been working on a port of a package from Squeak to JavaScript over the last few months. It's been the project which forced me to finally cut my teeth on JS for real, with a real challenge and not just a shallow tutorial. However, now I'm something like 90% done with the port! :-/ :) It's okay, I'm glad I got forced to understand JS 1000X better than I did before, a transpiler might have inhibited that.
Still, I don't want to write one line of JS that I don't have to, and so I'm spellbound by this concept! I'm wanting to sprint to the finish with my port, yet can hardly wait to check this out, but I don't want to start a big mess at this point. :-D
Does it really remake your entire image in JS? Do you then "run the image" in the browser? How did you handle the different models of async execution between Smalltalk and JS? It's immensely intriguing. I noticed it uses changesets. It must have to do some low-level stuff. I looked for what image version to start with in the documentation, but it wasn't explicitly clear. Hopefully it's for 6.0, but if it's been a long time, I could understand if it was for an older version.
Best, Chris
On Sat, Jun 24, 2023 at 9:38 AM Florin Mateoc florin.mateoc@gmail.com wrote:
Hi all,
It took a while - and I am not talking about how long I have worked on it (especially in calendar years), but since I first mentioned it on this list, or even since I presented it at the UK meetup - but now it's finally here: https://github.com/fmateoc/JsSqueak
If you want to try it out and are facing difficulties following the brief instructions on the project's web page, please let me know, hopefully this will lead to better instructions
Thank you and have fun!
Florin
squeak-dev@lists.squeakfoundation.org