Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
ben.txt
@bentxt
with gsi-script: (display (reverse (list 88 99)))
output: (99 88)
with js there is the error: "g_peps.reverse is not a function". So why is the 'reverse' function from the standard library not used?
amirouche
@amirouche
@bentxt are you compiling the runtime or jusst lib.scm + app.scm ?
@bentxt the runtime is somewhat big, the lib.scm + app.scm like I do in scheme fuss doesn't come with most scheme procedures
you have the implement them.
ben.txt
@bentxt

I'm not sure what you mean. Here is how I build it:

cat app_.js libjs.js app.js > linked_app.js

libjs.js are user defined functions

amirouche
@amirouche
yeah then you have to implement reverse yourself.
ben.txt
@bentxt
and how do you do it?
amirouche
@amirouche
you don't know scheme?
ben.txt
@bentxt
I've meant the compilation process. How do you integrate the standard library? I guess 'reverse' is written in scheme and therefor should be usable for the universal backend.
amirouche
@amirouche
ben.txt
@bentxt
@amirouche thanks. does this build a library _gambit.js inside gambits source tree?
Marc Feeley
@feeley
@bentxt yes it builds lib/_gambit.js which is most of the normal Gambit Scheme library
@amirouche I've looked at your JS performance experiment... what is the Scheme code that you are compiling? factorial wouldn't be my first choice of benchmark because very soon you need bignums to compute factorials of > 20 or so
I typically use fib which exercices function calls and fixnum arithmetic and it is very easy to scale to a larger time by incrementing the argument
when you say "almost as fast as JS" do you mean compared to factorial written directly in JS or through your compiler?
John Cowan
@johnwcowan
I sometimes ask candidates if they know of an O(1) way to implement factorial. Only one or two have actually come up with the answer.
amirouche
@amirouche
@feeley ok for fib, tx for the hint. As fast as iterative factorial written in JavaScript (which is the fatest factorial compared to recursive and tail recursive)
@johnwcowan using a memo?
@feeley it is a tail recursive factorial
John Cowan
@johnwcowan
Using a precomputed array of all possible factorials that can be represented as 64-bit floats.
There are really very few.
amirouche
@amirouche
amirouche
@amirouche
@johnwcowan I missed an opportunity to look smart
John Cowan
@johnwcowan
As I say, almost everyone does.
ben.txt
@bentxt
@feeley @amirouche ok that is producing a 21M large _gambit.js file, I guess I'll try other solutions then, ... thanks anyway
Marc Feeley
@feeley
@bentxt As was mentioned before, if your application is small (you need reverse and just a few other things), then you should build your own runtime library and you will get a reasonable JS code size, especially if you minify the code. See the mentioned link.
amirouche
@amirouche
I am around if you want to discuss the issue I just posted at gambit/gambit#404
Marc Feeley
@feeley
@amirouche did you see my response? call/cc is just:
(define (call/cc f)
  (##continuation-capture
   (lambda (k)
     (f (lambda (r) (##continuation-return-no-winding k r))))))
Marc Feeley
@feeley
if you wonder about the rationale for those continuation primitives they are explained here: http://www.iro.umontreal.ca/~feeley/papers/FeeleySW01.pdf
amirouche
@amirouche
tx a lot!
I think I have all i need :)
Marc-André Bélanger
@belmarca
> (##include "~~lib/_std#.scm")
*** ERROR IN "/usr/local/Gambit/v4.9.3/lib/_std#.scm"@11.2 -- Unbound variable: define-library-type-of-exception
Marc Feeley
@feeley
(##include "~~lib/_gambit#.scm")
Marc-André Bélanger
@belmarca
😣thanks
amirouche
@amirouche
use TAB + ENTER or click TODO to validate input
Marc-André Bélanger
@belmarca
13kb for everything amirite?
amirouche
@amirouche
amirite?
Marc-André Bélanger
@belmarca
"am I right" :)
amirouche
@amirouche
where do you see this number?
it is at least 1Mb if you count only JavaScript depedencies, and that is the helpers.js that contains ReactJS
Marc-André Bélanger
@belmarca
chrome says about 1.2Mb for everything
ok
amirouche
@amirouche
yeah it looks like that
I am wondering if I will not continue with the full build because not having access to string function is rather painful
until the tree shaking code lands in master...
even if it is 21M, it much less than pypyjs which IIRC is 60Mb also in local dev setup, you are not really slow down by the big size of the runtime.
amirouche
@amirouche
Actually pypyjs is 31Mb but split into many files which slows down the page a lot: https://hyperdev.fr/pypyjs-todomvc/