With the latest commit the Gambit universal library can be used in the browser… it is as simple as:
% make _gambit.js % gsc/gsc -:= -target js -exe -o webapp.js webapp.scm % open webapp.html
webapp.scm:
(declare (extended-bindings))
(define (document.write html) (##inline-host-statement "document.write(g_scm2host(@1@));" html))
(document.write "<h1>Hello world!</h1>")
webapp.html:
<!doctype html> <html>
<head> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>webapp</title> </head>
<body> <script type="text/javascript" src="webapp.js"></script> </body>
</html>
Afficher les réponses par date
Thank you very much for putting the finishing touches on JavaScript! Looking forward to using it.
On Wed, Mar 25, 2020 at 9:49 AM Marc Feeley feeley@iro.umontreal.ca wrote:
With the latest commit the Gambit universal library can be used in the browser… it is as simple as:
% make _gambit.js % gsc/gsc -:= -target js -exe -o webapp.js webapp.scm % open webapp.html
I just had to try, this is so cool. And gladly report back it worked as expected.
A smarter linker next? A 31MB js file seems too much, even for a real application, not just "hello world".
On Mar 25, 2020, at 5:47 AM, Duy Nguyen pclouds@gmail.com wrote:
On Wed, Mar 25, 2020 at 9:49 AM Marc Feeley feeley@iro.umontreal.ca wrote:
With the latest commit the Gambit universal library can be used in the browser… it is as simple as:
% make _gambit.js % gsc/gsc -:= -target js -exe -o webapp.js webapp.scm % open webapp.html
I just had to try, this is so cool. And gladly report back it worked as expected.
A smarter linker next? A 31MB js file seems too much, even for a real application, not just "hello world". — Duy
Yes the smart linker will definitely be useful here. It is an important milestone on my TODO as it will help all of the backends and integrate with the module system.
Although 31 MB is quite big, it is still usable for local development. The compilation and linking with gsc for the small example takes 1/10 of a second and the browser starts the app from the local file in a fraction of a second, so the development loop is quite pleasant.
For use on the web the generated JavaScript code could be compressed with various methods. Marc-André Bélanger has experimented with a code compressor (post-processing of the .js code) that reduces the size by a factor of 3. And when gzip compression is also enabled in the web server the final network transfer is about 5% of the original size. So this would represent a decent 1.5 MB network transfer *without* the smart linker.
If you are interested in working on minimizing the generated JavaScript code please let me know and I can guide you through the relevant parts of the universal backend.
Marc
On Wed, Mar 25, 2020 at 6:25 PM Marc Feeley feeley@iro.umontreal.ca wrote:
Although 31 MB is quite big, it is still usable for local development. The compilation and linking with gsc for the small example takes 1/10 of a second and the browser starts the app from the local file in a fraction of a second, so the development loop is quite pleasant.
For use on the web the generated JavaScript code could be compressed with various methods. Marc-André Bélanger has experimented with a code compressor (post-processing of the .js code) that reduces the size by a factor of 3. And when gzip compression is also enabled in the web server the final network transfer is about 5% of the original size. So this would represent a decent 1.5 MB network transfer *without* the smart linker.
Ah right. I forgot about compression. 1.5 MB is a very reasonable number.
If you are interested in working on minimizing the generated JavaScript code please let me know and I can guide you through the relevant parts of the universal backend.
I'm afraid I'm not that capable. I used to use Gambit maybe ten years ago but stopped for some reason, now I don't remember a thing. Gambit looks quite attractive again :) I'll start using it more and hopefully will be able to contribute something back soon.
For use on the web the generated JavaScript code could be compressed with various methods. Marc-André Bélanger has experimented with a code compressor (post-processing of the .js code) that reduces the size by a factor of 3. And when gzip compression is also enabled in the web server the final network transfer is about 5% of the original size. So this would represent a decent 1.5 MB network transfer *without* the smart linker.
AFAIK the de facto standard framework is still React. It's 40K. Elm, a purely functional language with a built-in React-like framework, gets down to 30K. The biggest popular frameworks are 100-150K. All of these sizes are gzipped + minified (i.e. all identifiers compressed to the shortest possible obfuscated ones, and all whitespace removed).
Are there known tricks to get Gambit down to that 100-150K range?
Sources: - https://elm-lang.org - https://gist.github.com/Restuta/cda69e50a853aa64912d
On Mar 25, 2020, at 2:51 PM, Lassi Kortela lassi@lassi.io wrote:
Are there known tricks to get Gambit down to that 100-150K range?
Yes… time! (smart linker…)
Marc