newLISP Fan Club

Forum => newLISP newS => Topic started by: Lutz on January 02, 2014, 01:43:18 PM

Title: newLISP in a browser
Post by: Lutz on January 02, 2014, 01:43:18 PM
newLISP can now be compiled to JavaScript using the Emscripten SDK (1) and it runs fastest in a Chrome browser but also runs in the Firefox browser (turns out Firefox is faster edited: 2014-1-4)



The default newlisp-js.html generated has different windows for input and output with the input popup-box only about 25 characters wide. So a better front end would have to be written in JavaScript and HTML to either simulate a console REPL or make the input box bigger and integrated into the page (2). The newlisp-js.js has a size of about 2.3 MB and is loaded by newlisp-js.html of 4K size.



For bandwidth reasons and because it's not yet a finished product, I don't want to install the file on the newlisp.org website. But if some JavaScript expert here on the board wants to take this up as a project, I can send the files to that person by email.



A 'makefile_emscripten_utf8' with more info in the header section can be found in the source distribution here:



http://www.newlisp.org/downloads/development/inprogress/



(1) https://github.com/kripken/emscripten/wiki/Tutorial

(2) I wonder if there is JS code from other applications, which could be used.
Title: Re: newLISP in a browser
Post by: bairui on January 02, 2014, 02:38:16 PM
You're tireless, Lutz! Awesome.

newLISP deserves a lot more attention; perhaps this move to the browser will help?



One thought I just had for this is to convert the newLISP manual example code segments into embedded, runable, modifiable, interactive learning tools.
Title: Re: newLISP in a browser
Post by: Lutz on January 02, 2014, 04:31:14 PM
newlisp-js.js, newlisp-js.html and newlisp-js.html.map are zipped together here:



http://www.newlisp.org/downloads/development/inprogress/newlisp-js.zip



See README.txt inside
Title: Re: newLISP in a browser
Post by: HPW on January 02, 2014, 11:15:15 PM
Hello Lutz,



Thanks for creating this interesting new option.



I wonder why the Emscripten-generator/auhor decided to make a popup-promt as the input-element.

Not easy to understand the HTML and js logik and interaction.

I wonder that there are reference to a imageplugin and webgl in the javascript code.

It would be nice if more browsers would be supported. (IE etc.)



Regards
Title: Re: newLISP in a browser
Post by: HPW on January 02, 2014, 11:36:17 PM
Hello,



Interesting read about emscripten:



https://github.com/kripken/emscripten/wiki/FAQ



Also the list of demo is quite impressive:



https://github.com/kripken/emscripten/wiki



Seems other programming languages are also ported to emscripten.



Regards
Title: Re: newLISP in a browser
Post by: HPW on January 02, 2014, 11:42:27 PM
Hello,



In a second step it would be nice to get a clean and easy javascript integration.

Something like this:

<input type="button" name="eval" value="Evaluate" onclick="newLispEvalString(this.form.inputbox.value);

And callback's into javascript.





Regards
Title: Re: newLISP in a browser
Post by: hartrock on January 03, 2014, 12:48:57 AM
Quote from: "HPW"
I wonder why the Emscripten-generator/auhor decided to make a popup-promt as the input-element.

To have synchronous input behavior should be the reason; see:

  https://github.com/replit/jsrepl#standard-input-hacks

(reached from https://github.com/replit/repl.it#replit).
Title: Re: newLISP in a browser
Post by: hartrock on January 03, 2014, 02:03:06 AM
Just a few thoughts:
Quote from: "Lutz"
(2) I wonder if there is JS code from other applications, which could be used.

I can say something about experiences I've made with development of

  http://www.evolgo.de/RYT/

some time ago.

For user interaction this heavily uses jQuery and jQueryUI as tools for reaching browser compatibility (and many other libs for e.g. SVG stuff). It runs in almost all browsers (Firefox, Safari, Chrome; but probably not IE (due to SVG stuff)).

From my experiences (some time ago) I can recommend using jQuery stuff for reaching browser compatibility (instead of trying to build such a thing yourself).



For a newLISP repl a light-weight editor is needed.

Question is, how to proceed: to implement such a thing by using browser side newLISP - enriched by some Javascript interface - or choosing some free Javascript one? As more will be used from the Javascript world, as more dependencies have to be managed...

Possibly first using a free one and then going a newLISP way?



Another question is how to proceed organizationally: browser side newLISP outside the newLISP core could well be a community project; e.g. for:

  • Javascript/DOM bindings,
    • accessing browser storage,
    • UI widgets;

    to name a few.

    Why? Because this could be too much for a single person doing much other stuff ;-)
  • Title: Re: newLISP in a browser
    Post by: Lutz on January 03, 2014, 07:31:07 AM
    Initially, the goal would be a simple learning, tutoring and development environment for newLISP. We should go by little steps and start with the minimum possible:



    - Implement a simple HTML editable text field for input and another HTML text field for output. Both fields stacked on top of each other or side by side. The default newlisp-js.html is only 95 lines long and 80% of it isn't even needed and could be thrown out, for this first phase.



    - Make a facility to display manual or tutoring text for a specific topic or function



    - Improve the editor using JavaScript from other projects which do editor syntax highlighting like http://jsfiddle.net/ , http://ace.c9.io/#nav=about (comes with embedding instructions!) and many others. JavaScript is the only language builtin to the browser and with Document Object Model integration. So using jQuery, Bootstrap, etc. would be a natural thing.





    Ps: http://www.evolgo.de/RYT/ this is incredible, wow! There is tons of stuff here, which could be used in a more advanced complex browser-based newLISP IDE.
    Title: Re: newLISP in a browser
    Post by: Lutz on January 03, 2014, 12:27:56 PM
    a much faster, optimized version, now best on Firefox with almost native speed:



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js.zip



    load index.html ino the browser which is a streamlined newlisp-js.html - but still with popup window input.
    Title: Re: newLISP in a browser
    Post by: Lutz on January 03, 2014, 03:36:14 PM
    Now with two windows, one for input and one for output:



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js.zip



    unzipping newlisp-js.zip creates a newlisp-js directory with the necessary files. See the README.txt file in the package.



    Ps: now also works on Safari on OSX and IOS
    Title: Re: newLISP in a browser
    Post by: HPW on January 03, 2014, 11:54:35 PM
    Great, getting better and better. Exactly like my wish.

    (Maybe you sould exchange the Position of Input and Output)



    >>In this sandboxed JavaScript environment, File and network I/O functions

    will not work.



    Does any function for web access work? Like javascrpt Ajax etc.?

    (Maybe (load "url") can internally use XMLHttpRequest in js to load the string from thr url and then evalstring in newlisp)



    It seems also to work on IE 11 (Tested on my Win 7 tablet)!!



    Is it possible to Gzip the js-lib?

    I tried it but I am struggling with the gzip-support-configuration on my test-Server.

    When it would work the lib would get under 500kb.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on January 04, 2014, 12:22:33 AM
    I changes the layout to:



       <p>Input&nbsp;&nbsp;
        <textarea class="emscripten" id="input" rows="15">(println "Hello World")</textarea></p>
        <input type="button" value="eval"
               onclick="newlispEvalStr(document.getElementById('input').value.trim())">
        <p>Output
        <textarea class="emscripten" id="output" rows="15"></textarea></p>


    So the flow is: input=>eval=>output



    Test on WIN Xp IE 8 does not work. Keeps endless downloading.

    WIN XP with current chrome does work.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on January 04, 2014, 01:48:33 AM
    Is it possible to add a newlisp function to call javascript 'eval?



    (jsEvalString "A valid javascript call")



    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval



    Then we could build the javascript-call dynamicly in newlisp and do a callback to whatever is needed.



    PS: Just tested the demo-html successfully on my daughters Samsung Galaxy S3 Android Handy!!



    Seems that 'newlisp everyware' comes true! So great!



    I had a projekt to build another xlisp-interpreter in javascript. Seems that it is no more needed. ;-)



    Regards
    Title: Re: newLISP in a browser
    Post by: hilti on January 04, 2014, 06:01:22 AM
    Quote from: "Lutz"
    - Improve the editor using JavaScript from other projects which do editor syntax highlighting like http://jsfiddle.net/ , http://ace.c9.io/#nav=about (comes with embedding instructions!) and many others. JavaScript is the only language builtin to the browser and with Document Object Model integration. So using jQuery, Bootstrap, etc. would be a natural thing.




    OK...this result was one hour of work :-) -> http://newlisp.neocortex.io/

    If my kids would let me do some more hacking, this IDE could be very nice.



    I just combined Bootstrap, some custom CSS and CodeMirror.



    Cheers

    Marc
    Title: Re: newLISP in a browser
    Post by: HPW on January 04, 2014, 06:41:28 AM
    Hello Marc,



    Nice Editor, maybe you should link the indexed doc:



    http://www.newlisp.org/downloads/manual_frame.html



    You may also choose better Colors. It is difficult to see selected text and the Output area.



    Edit: Also tested on the Android Handy of my kids. Works fine



    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on January 04, 2014, 09:41:01 AM
    Marc's editor looks great! When all is done, I will try to deliver a compressed version of newlisp-js-lib.js which loads faster and decompresses client-side. It should be around 500K.



    newlisp-js now has a eval-string-js function. Enter any JavaScript call or statement to evaluate in the parent browser:


    (eval-string-js "window.prompt('Enter some text:')")

    (eval-string-js "6 * 7") => "42


    The statement would pop up a dialog and return the string entered.



    http://www.newlisp.org/downloads/development/inprogress/



    So now with  eval-string-js anything is possible in a browser for newLISP :)
    Title: Re: newLISP in a browser
    Post by: HPW on January 04, 2014, 09:59:52 AM
    Hello Lutz,



    Thanks again for the improvements!



    You may change the sample to avoid the 'undefined' in the promp-window:

    (eval-string-js "window.prompt('Enter some text:','')")


    Is there a max length for the return of the js-call?

    If so, it would be difficult to use it for loading Lisp-sources from the web-Server.

    (As long it is not supported directly in newlisp-js)



    Regards
    Title: Re: newLISP in a browser
    Post by: hilti on January 04, 2014, 10:32:10 AM
    (eval-string-js) is very cool!



    Just played around with it:



    (setq number (eval-string-js "window.prompt('Enter a number to divide by 2:','')"))
    (setq result (div (int number) 2))
    (setq alert (append "alert(" (string result) ")"))
    (eval-string-js alert)


    Getting the browser window height or width is easy now.



    (eval-string-js "$(window).height();")
    (eval-string-js "$(window).width();")


    I do my best in making the Browser-IDE more advanced.
    Title: Re: newLISP in a browser
    Post by: Lutz on January 04, 2014, 10:44:36 AM
    What browser and version are you using? I don't get any "undefined" messages when using only one parameter for the window.prompt call. I am using:



    Firefox 26.0

    Chrome 31.0

    Safari 7.01



    Also, all the code from Emscripten uses windows.prompt() with only one string argument.



    Regarding the the size of the returned string from eval-string-js:

    It seems that JavaScript is allocating the memory for the returned string and then is also managing it for GC. newLISP makes a copy of it and manages that copy. I tested for memory leaks when invoking eval-string-js and it seems that memory is managed well by JavaScript and newLISP for this call. I haven't tested for the max memory allowed as return value but believe, there will be no problems loading code source.



    Talking about memory in general:

    At this moment newlis-js-lib.js is limited to about 16MB of heap memory, which is the default Emscripten allocates and probably a sensible (conservative) choice for browser based applications. This value can be changed in a configuration file and perhaps I will bump it up to 32MB or even more. There are many other limits which can be configured before compilation and as things move along, I will experiment. At the moment I go with the defaults until we know more.



    Ps: thanks for the great examples Marc. Do you also get this "undefined" message HPW is talking about? And what browser version do you run?



    Ps2: I am getting a "undefined" as return value from (eval-string-js "alert(6)"), but believe this is Ok, "undefined" is simply the return value from the JavaScript alert() function in this case, perhaps in JavaScript alert is "void alert()".



    Ps3: Note, that using $(window).width(); also would need jQuery installed.
    Title: Re: newLISP in a browser
    Post by: HPW on January 04, 2014, 11:33:30 AM
    QuoteWhat browser and version are you using? I don't get any "undefined" messages when using only one parameter for the window.prompt call.


    Ok, it is only on IE 11.

    Chrome 31 is also Ok for me without the second parameter.

    But when you use it it does not hurt and you can set a default-text into the promt-window.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on January 04, 2014, 12:02:15 PM
    Hello,



    sys-info on newlisp-js shows 203 for me.

    Does it mean UTF-8 and what else?



    Regards
    Title: Re: newLISP in a browser
    Post by: hilti on January 04, 2014, 12:14:07 PM
    QuotePs: thanks for the great examples Marc. Do you also get this "undefined" message HPW is talking about? And what browser version do you run?


    Yes, I do.



    I'm running on OSX Mavericks



    1. Safari 7.01

    2. Chrome 31.0.1650.63





    P.S. Reddit seems to be interested, because I get some load on my server ...

    //http://www.reddit.com/r/lisp
    Title: Re: newLISP in a browser
    Post by: Lutz on January 04, 2014, 03:19:16 PM
    The second argument is now included in the example together with some other cleanup in index.html and some more instructions in README.txt:



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js-10.5.7.zip



    I am very excited about Marc's editor, which looks better each time I load it. Fortunately once the same newlisp-js-lib.js is loaded it goes pretty quick as it is cached by the browser, but there seems to be some load on your site at times.
    Title: Re: newLISP in a browser
    Post by: Lutz on January 04, 2014, 04:26:36 PM
    Here is a quick way to compress newlisp-js-lib.js for faster deliever, but this is only usable for delivery on HTTP 1.1 compliant web servers like Apache. It will not work when loading locally from a file or with newLISP in server mode, which only implements HTTP 1.1 partially.



    On Unix compress doing:
    gzip newlisp-js-lib.js # this produces a newlisp-js-lib.js.gz
    Now edit index.html replacing instances of newlisp-js-lib.js with newlisp-js-lib.js.gz:

    // replace
    <script async type="text/javascript" src="newlisp-js-lib.js"></script>
    // with
    <script async type="text/javascript" src="newlisp-js-lib.js.gz"></script>
    Title: Re: newLISP in a browser
    Post by: HPW on January 04, 2014, 11:50:41 PM
    Slightly modified html with disabled Gui until downloading is finished:



    <!doctype html>
    <html lang="en-us">
      <head>
        <meta charset="utf-8">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>newLISP 10.5.7 compiled to JavaScript</title>
        <style type="text/css" media="screen">
        .emscripten {
            padding-right: 0; margin-left: auto; margin-right: auto; display: block;
            }
        .button {
            color: #AA0000;
            font-size: 110%;
            }
        textarea {
            font-family: Andale Mono, "Bitstream Vera Sans Mono", Monaco, Courier;
            font-size: 15px;
            width: 100%;
            }
        body, p {
            font-family: Lucida Sans, Helvetica, sans-serif;
            }
        </style>
      </head>

      <body>
        <div class="emscripten" id="status">Downloading...</div>
        <div class="emscripten">
          <progress value="0" max="100" id="progress" hidden=1></progress>  
        </div>

        <p>Input&nbsp;&nbsp;<input type="button" value="eval" class="button" id="evalinput"
           onclick="newlispEvalStr(document.getElementById('input').value.trim())" disabled>
           &nbsp;<input type="button" value="clear" id="clearinput" class="button"
           onclick="document.getElementById('input').value = '';" disabled><br><br>
         <textarea class="emscripten" id="input" rows="14" disabled>;
    ; wait for "Downloading ..." to finish, then click eval
    ;
    (println "Hello World")
    ;; up to 1023 characters can be passed to string in eval-string-js
    ;; no limit on size of returned string
    (eval-string-js "window.prompt('Enter some text:','')")
         </textarea></p>
        <p>Output&nbsp;&nbsp;<input type="button" value="clear" class="button" id="clearoutput"
           onclick="document.getElementById('output').value = '';" disabled><br><br>
        <textarea class="emscripten" id="output" rows="12" disabled></textarea></p>

        <script type='text/javascript'>
          // download newlisp-js-lib.js and show progress of downloading
          var Module = {
            preRun: [],
            postRun: [(function() {
              newlispEvalStr = Module.cwrap('newlispEvalStr', 'number', ['string']); })],
            print: (function() {
              var element = document.getElementById('output');
              element.value = ''; // clear browser cache
              return function(text) {
                text = Array.prototype.slice.call(arguments).join(' ');
                element.value += text + "n";
                element.scrollTop = 99999; // focus on bottom
              };
            })(),
            printErr: function(text) {
              text = Array.prototype.slice.call(arguments).join(' ');
              if (0) { // XXX disabled for safety typeof dump == 'function') {
                dump(text + 'n'); // fast, straight to the real console
              } else {
                console.log(text);
              }
            },
            setStatus: function(text) {
              if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
              if (text === Module.setStatus.text) return;
              var m = text.match(/([^(]+)((d+(.d+)?)/(d+))/);
              var now = Date.now();
              if (m && now - Date.now() < 30) return; // if progress update, skip it if too soon
              var statusElement = document.getElementById('status');
              var progressElement = document.getElementById('progress');
              if (m) {
                text = m[1];
                progressElement.value = parseInt(m[2])*100;
                progressElement.max = parseInt(m[4])*100;
                progressElement.hidden = false;
              } else {
                progressElement.value = null;
                progressElement.max = null;
                progressElement.hidden = true;
                document.getElementById('evalinput').disabled = false;
                document.getElementById('clearinput').disabled = false;
                document.getElementById('clearoutput').disabled = false;
                document.getElementById('input').disabled = false;
                document.getElementById('output').disabled = false;
              }
              statusElement.innerHTML = text;
            },
            totalDependencies: 0,
            monitorRunDependencies: function(left) {
              this.totalDependencies = Math.max(this.totalDependencies, left);
              Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) +
                            '/' + this.totalDependencies + ')' : 'All downloads complete.');
            }
          };
          Module.setStatus('Downloading...');
        </script>

        <script async type="text/javascript" src="newlisp-js-lib.js"></script>

        <center>
        <font size="-1">Copyright &copy; 2014, <a href="http://newlisp.org">newlisp.org</a></font>
        </center>
      </body>
    </html>

    <!-- eof -->
    Title: Re: newLISP in a browser
    Post by: Lutz on January 05, 2014, 04:35:09 PM
    The latest update adds automatic row-sizing of input and output windows on load and a button to switch layout from horizontal two-column to a vertical one-column layout.



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js-10.5.7.zip







    Ps: This also has HPW's addition of disabling the GUI while downloading.
    Title: Re: newLISP in a browser
    Post by: Lutz on January 06, 2014, 11:06:42 AM
    Now files can be loaded from the local file system into the edit box. Also JavaScript code can be evaluated directly without using the (eval-string-js ...) expression but using the JS button.



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js-10.5.7.zip
    Title: Re: newLISP in a browser
    Post by: Lutz on January 06, 2014, 05:11:10 PM
    A better layout on mobile devices and an info button for a help page:



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js-10.5.7.zip
    Title: Re: newLISP in a browser
    Post by: HPW on January 06, 2014, 10:59:13 PM
    Modified html with additional doc button with keyword-input.

    (Selection of a keyword in one of the textareas put it into the keyword-input)

    Opens either the indexed doc or context-sensitive doc for the keyword.



    <!doctype html>
    <html lang="en-us">
      <head>
        <meta charset="utf-8"/>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>newLISP in a browser</title>
        <style type="text/css" media="screen">
        .emscripten {
            padding-right: 0; margin-left: auto; margin-right: auto; display: block;
            }
        .button {
            color: #000000;
            font-size: 1.0em;
            right: 0px;
            margin-bottom: 3px;
            margin-top: 3px;
            }
        .red-button {
            color: #AA0000;
            font-size: 1.0em;
            margin-bottom: 3px;
            margin-top: 3px;
            }
        .two-column {
            position: relative;
            margin: 1%;
            float: left;
            width: 48%;
            }
        .one-column {
            position: relative;
            margin: 1%;
            width: 98%;
            }
        textarea {
            font-family: Andale Mono, Monaco, Courier;
            font-size: 1.00em;
            width: 100%;
            resize: none;
            }
        body, p {
            font-family: Lucida Sans, Helvetica, sans-serif;
            }
        body {
            background-color: #EEEEEE;
            margin: 0;
            padding: 0;
            }
        </style>
      </head>

      <body>
        <output id="list"></output>
        <body onmouseup="GetSelectedText ()">

        <div class="emscripten" id="status">Downloading...</div>
        <div class="emscripten">
          <progress value="0" max="100" id="progress" hidden=1></progress>
        </div>

        <div class="two-column" id="editor">
        Editor&nbsp;<input type="button" value="eval" class="red-button" id="evalinput"
          onclick="newlispEvalStr(document.getElementById('input').value.trim())" disabled />

        <input type="button" value="JS" id="evalinputjs" class="red-button"
          onclick="newlispEvalStr('(eval-string-js {' + document.getElementById('input').value.trim() + '})' )" disabled />

        <input type="button" value="clear" id="clearinput" class="button"
          onclick="document.getElementById('input').value = '';" disabled /><br/>

        <textarea id="input" disabled>;
    ; wait for "Downloading ..." to finish
    ; then click eval
    ;

    (println "Hello World")
    (eval-string-js
        "window.prompt('Enter some text:','')")
         </textarea><br/>
         <input type="file" class="button" id="files" name="load" disabled /><br/>
        </div>

        <div class="two-column" id="eval-out">
        Console&nbsp;<input type="button" value="clear" class="button" id="clearoutput"
          onclick="document.getElementById('output').value = '';" disabled />
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" value="layout" class="button" onclick="switchLayout();" />
        <input type="button" value="info" id="info" class="button"
          onclick="window.open('README.html','MsgWindow');" disabled />
        <input type="button" value="doc" id="doc" class="button"
          onclick="OpenDoc();"/>
        <input type="text" id="keywordtext">
        <textarea  id="output" disabled></textarea><br/>
        <center><font size="-1">Copyright &copy; 2014, <a href="http://newlisp.org">newlisp.org</a>
        </font></center>
        </div>

        <script type='text/javascript'>
    <!--
          function resizeTextarea(mode) {
                var nrows;
                if(mode == "two-column") {
                    nrows = ((window.innerHeight || document.body.clientHeight)  - 130)  / 18;
                    } else {
                    nrows = ((window.innerHeight || document.body.clientHeight)  - 180)  / 36;
                    }
                document.getElementById('input').rows = nrows;
                document.getElementById('output').rows = nrows;
                }

          function switchLayout() {
                if(document.getElementById('editor').className == "two-column") {
                    document.getElementById('editor').className = "one-column";
                    document.getElementById('eval-out').className = "one-column";
                    resizeTextarea("one-column");
                    } else {
                    document.getElementById('editor').className = "two-column";
                    document.getElementById('eval-out').className = "two-column";
                    resizeTextarea("two-column");
                    }
                }

          function handleFileSelect(evt) {
                var files = evt.target.files; // FileList object
                var textFile = files[0]

                // file info:
                // textFile.name
                // textFile.type
                // textFile.size
                // textFile.lastModifiedDate[.toLocaleDateString()]

                //Only process text files.
                if (textFile.type.match('image.*')) {
                    alert(textFile.type + 'is an invalid file type');
                    return;
                    }

                var reader = new FileReader();

                // read file asynchronous and fill editor box
                reader.onload = (function(theFile) {
                    return function(e) {
                        var editBox = document.getElementById('input');
                        editBox.value = ''; // clear editbox
                        editBox.value = e.target.result;
                        };
                    })(textFile);

                // Read in the text file
                reader.readAsText(textFile);
                Module.print('loading: ' + textFile.name + ' - size:', textFile.size + ' bytes');
                }

            function GetSelectedText () {
                var selText = "";
                if (window.getSelection) {  // all browsers, except IE before version 9
                    if (document.activeElement &&
                            document.activeElement.tagName.toLowerCase () == "textarea")
                    {
                        var text = document.activeElement.value;
                        selText = text.substring (document.activeElement.selectionStart,
                                                  document.activeElement.selectionEnd);
                    }
                    else {
                        var selRange = window.getSelection ();
                        selText = selRange.toString ();
                    }
                }
                else {
                    if (document.selection.createRange) {       // Internet Explorer
                        var range = document.selection.createRange ();
                        selText = range.text;
                    }
                }
                if (selText !== "") {
                    document.getElementById('keywordtext').value = selText;
    //                alert(selText);
                }
            }

            function OpenDoc () {
               if (document.getElementById('keywordtext').value.trim() !== "") {
                window.open('http://www.newlisp.org/downloads/newlisp_manual.html#'+document.getElementById('keywordtext').value.trim(),'MsgWindow');
               }
               else {
                window.open('http://www.newlisp.org/downloads/manual_frame.html','MsgWindow');
               }
            }

          document.getElementById('files').addEventListener('change', handleFileSelect, false);

          // EMSCRIPTEN loading newlisp-js-lib.js showing progress of downloading
          // importing newlispEvaklStr and output to the console
          var Module = {
            preRun: [],
            postRun: [(function() {
              newlispEvalStr = Module.cwrap('newlispEvalStr', 'number', ['string']); })],
            print: (function() {
              var element = document.getElementById('output');
              element.value = ''; // clear browser cache
              return function(text) {
                text = Array.prototype.slice.call(arguments).join(' ');
                element.value += text + "n";
                element.scrollTop = 99999; // focus on bottom
              };
            })(),
            printErr: function(text) {
              text = Array.prototype.slice.call(arguments).join(' ');
              console.log(text);
            },
            setStatus: function(text) {
              if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
              if (text === Module.setStatus.text) return;
              var m = text.match(/([^(]+)((d+(.d+)?)/(d+))/);
              var now = Date.now();
              if (m && now - Date.now() < 30) return; // if progress update, skip it if too soon
              var statusElement = document.getElementById('status');
              var progressElement = document.getElementById('progress');
              if (m) {
                text = m[1];
                progressElement.value = parseInt(m[2])*100;
                progressElement.max = parseInt(m[4])*100;
                progressElement.hidden = false;
              } else {
                progressElement.value = null;
                progressElement.max = null;
                progressElement.hidden = true;
                document.getElementById('evalinput').disabled = false;
                document.getElementById('evalinputjs').disabled = false;
                document.getElementById('clearinput').disabled = false;
                document.getElementById('clearoutput').disabled = false;
                document.getElementById('input').disabled = false;
                document.getElementById('output').disabled = false;
                document.getElementById('files').disabled = false;
                document.getElementById('info').disabled = false;
                resizeTextarea("two-column");
              }
              statusElement.innerHTML = text;
            },
            totalDependencies: 0,
            monitorRunDependencies: function(left) {
              this.totalDependencies = Math.max(this.totalDependencies, left);
              Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) +
                            '/' + this.totalDependencies + ')' : 'All downloads complete.');
            }
          };
          Module.setStatus('Downloading...');
    -->
        </script>

        <script async type="text/javascript" src="newlisp-js-lib.js"></script>
      </body>
    </html>

    <!-- eof -->
    Title: Re: newLISP in a browser
    Post by: HPW on January 07, 2014, 08:55:08 AM
    Hello,



    When I eval this code nothing appear in the Output pane

    (silent(print "Hello World"))


    When I add a n then all pevious print Outputs appear including the last eval:

    (silent(print "Hello Worldn"))


    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on January 07, 2014, 10:24:21 AM
    This happens on all browsers. They - the Emscripten folks - seem not to flush the output buffer until they find a line feed. Nothing we can do about it, adding a line feed to silent would undo it's purpose.



    I added your keyword manual search, great that it also works on selections!



    Also added replacing trailing "?" with "p" e.g.: protectedp instead of protected? in search keywords to make it work for the manual when searching property functions. Made the text box a bit smaller to not overflow to the next line when working on the iPad.



    Also added more mobile specific stuff to get max possible rows on iPad, the browse button will stay disabled on most mobile devices.



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js-10.5.7.zip



    ps: to your licensing question: yes, it's the same as for the DLL



    ps: enter key now also works for the keyword search



    ps: keyboard shortcuts for buttons: Ctrl-L for <clear>, Ctrl-X for <eval>, Ctrl-J for <JS>



    ps: Ctrl-O to open the file browser
    Title: Re: newLISP in a browser
    Post by: HPW on January 08, 2014, 04:44:09 AM
    Quote
    ps: keyboard shortcuts for buttons: Ctrl-L for <clear>, Ctrl-X for <eval>, Ctrl-J for <JS>

    ps: Ctrl-O to open the file browser


    In IE 11 (win 7) the hotkeys Ctrl-X and Ctrl-J and Ctrl-O appear as letters in the textarea after executing.

    Chrome works fine.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on January 08, 2014, 07:57:15 AM
    Hello,



    CTRL-X is not so good since it is yet the cut to clipboard command for the textarea.

    So whne I hit CTRL-X in chrome when a word is selected, it starts first the eval and then cutout the word.



    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on January 08, 2014, 02:24:47 PM
    Meanwhile I could test on a Windows 8 machine. The result is, all but two keyboard shortcuts have been thrown  out. But the most important ones stayed with a different key for eval:



    Ctrl-enter - eval button - evaluate newLISP source

    Ctrl-L - clear button - clear editor box



    These two keyboard shortcuts seem to work on Windows and Mac OSX platforms and browsers including IE-11 on Windows 8. Have not tested any older IE's.



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js-10.5.7.zip



    Also added +,- buttons to make the editor box bigger or smaller. The console box will then change accordingly.
    Title: Re: newLISP in a browser
    Post by: Lutz on January 09, 2014, 11:39:05 AM
    More tweaking to accomodate an additional button and still make everything fit into 1024x768 pixels on a standard iPad or iPad mini.



    A new button to replace the current page with an HTML page, contents of the editbox. All three components of a an app: newLISP, JavaScript and HTML or any mix of it can now be developed in this IDE clientside.



    A second function - specific to newLISP compiled to a JavaScript lib - has been added display-html. This function does a similar thing as the HTML button. It replaces the current page with a new page from the HTML string parameter in  display-html.



    As an example of how to make an application for 'newLISP in a web browser' the file app.html has been added to the package. There is also a link to it on README.html page.



    http://www.newlisp.org/downloads/development/inprogress/



    There are still minor issues when using single ' in JavaScript in some situation. Use double quotes instead. The file app.html has some comments about it.
    Title: Re: newLISP in a browser
    Post by: HPW on January 09, 2014, 12:15:32 PM
    Quotedisplay-html


    Cool, interesting and powerfull.
    Title: Re: newLISP in a browser
    Post by: Lutz on January 09, 2014, 12:33:05 PM
    Just solved the single quote ' problem. It is now safe to use single quotes with strings in JavaScript also with JavaScript inside HTML. It was already safe when using JavaScript with eval-string-js



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js-10.5.7.zip



    both functions eval-string-js and display-html are also documented in the reference.
    Title: Re: newLISP in a browser
    Post by: HPW on January 10, 2014, 12:59:25 AM
    Just downloaded the latest zip from development.



    The output-area gets placed below the open-file button outside the screen (Chrome 31 on WIN XP)

    Colors are a matter of taste, but I do not like the dark background.

    The colors before did better fit to the doc.



    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on January 10, 2014, 05:27:27 AM
    I cannot test on Windows until next week. When the log window snaps below the edit window, widen the browser window a little bit and it will snap back. Or make the font size smaller with Ctrl- , then click the layout button twice.
    Title: Re: newLISP in a browser
    Post by: Lutz on January 10, 2014, 05:52:33 PM
    More tweaks and a new button c to switch the colors between a light and a dark theme.



    Tested on:

    Windows 8.0 with IE, Firefox, Chrome

    Mac OSX with Safari, Firefox, Chrome

    iOS iPad mini (1024x768) Safari



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js-10.5.7.zip



    ps: the HTML button now will open a new browser tab
    Title: Re: newLISP in a browser
    Post by: HPW on January 11, 2014, 02:44:02 AM
    Hello,



    Looks good now and works perfectly.



    Tested on:

    Windows 7.0 with IE, Chrome

    Windows XP with Chrome (IE 8 does not work)

    Android Handy Samsung Galaxy S3 mini



    One little problem on the Android: When select code in the input area the selected text gets not placed into the keyword-input. (texted with native browser and chrome)



    Edit: Here is a link with some code for the Android select problem. Maybe usable.

    http://stackoverflow.com/questions/11427403/how-to-get-touchend-to-behave-just-like-mouseup



    Does it work on IOS?



    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on January 11, 2014, 08:42:58 PM
    Thanks for doing all the testing on different devices and browsers.



    What you are seeing on Android is the same on iOS. But the fact that you have to copy-paste the keyword selection for the doc search into the text input, instead of it happening on mouse-up, is not a problem. On a touch device it may be even faster to input the keyword with the keyboard.



    The JavaScript newlispEvalStr(...) function now returns a string, just like the original newlisp.dylib/so/dll would do.



    Now you can write applications where client-side newLISP code, HTML and JavaScript are all integrated into one HTML page. This is the new demo app demonstrating this (1):



    http://www.newlisp.org/newlisp-js/app.html



    and the whole package:



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js-10.5.7.zip



    (1) do 'view source' on your browser to see how it is done in a small page plus newlisp-js-lib.js



    ps: there are no length restrictions of JavaScript anymore in eval-string-js
    Title: Re: newLISP in a browser
    Post by: Lutz on January 15, 2014, 09:57:04 AM
    Some UI changes to accommodate the new save button. It does save the current editor content to the browser local storage. This is a storage area on your local device offered by all mayor browsers. After save, you can shut down the browser. When you load the editor again it automatically retrieves the last editor content.



    The size of newlisp-js-lib.js and it's compressed version have also been reduced and there are some changes to the README page accessible with info button and app.html accessible from the README page.



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js-10.5.7.zip



    You can now develop in all three languages: newLISP, JavaScript and HTML and any mixture of the three on the desktop/laptop or a mobile device (currently optimized for iOS with 1024x768 pixels). Have not tried on an retina iPad which has more pixels but the same screen proportions.
    Title: Re: newLISP in a browser
    Post by: Lutz on January 16, 2014, 04:41:17 PM
    Eliminated errant behavior when using cleaned out browser or using a browser for the first time with the editor/IDE.

     

    The eval button now only prints the return values of the last expression, more working like the newLISP 'load' function or the JS button when evaluating JavaScript.



    The TAB key now works inside the  editor area inserting 4 spaces. Before, it would leave the editor text box jumping to the next HTML control on the page.



    A better visible cursor when the editor area has a dark background.



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js-10.5.7.zip
    Title: Re: newLISP in a browser
    Post by: Lutz on January 17, 2014, 08:51:52 AM
    A fix for the save button on non-mobile platforms in the last version.



    The + and - button now hit limits to avoid flipping to the bottom by the log column.



    http://www.newlisp.org/downloads/development/inprogress/newlisp-js-10.5.7.zip





    Ps: If any layout problems persists, it is because of saved layout settings. Worst case clear browsing data in 'Privacy Settings'
    Title: Re: newLISP in a browser
    Post by: HPW on January 17, 2014, 09:32:51 AM
    Hello,



    Not sure which Version did work, but the last 2 Versions does not work for me on IE11 on Win 7.

    But it is only index.html which does not return from downloading.

    Layout stays small.

    app.html does work.

    On Chrome both work.



    Edit: Just test a online Version and there it works with IE11. So it does not work on local file-System and answering the security question to allow blocked Content.



    Regards



    Hans-Peter
    Title: Re: newLISP in a browser
    Post by: Lutz on January 17, 2014, 03:14:44 PM
    I see the same with IE on windows local filesystem, it refuses to load the newlisp-js-lib.js and stays in "Downloading..". Chrome and Firefox do fine on Windows and local file system. I wonder if there are some settings inside IE which can be changed by the user. It seems not to be some inherent capability of IE, because it works on web installations.



    At the moment, I am not putting too much work into making IE work under all circumstances, but will guarantee for Chrome and Firefox always to work on Windows local and web and for OSX Safari, Chrome and Firefox local filesystem and web.



    When the the boxes appear stacked or else wrong, the font is either to big (do a Ctrl minus) or switch layout a couple of times, then do save to remember the new settings. For really big fonts you need certain minimum browser window size, which may not be available due to screen size restrictions. It should work for bigger fonts often used by older people.



    Also, my online installation changes frequently, as it is the only way for me to test the iPad. So sometimes I am editing the files or imnstall a new newlisp-jz-10.5.7.zip. Then things may not work for a few minutes.
    Title: Re: newLISP in a browser
    Post by: HPW on January 17, 2014, 10:09:28 PM
    I only wonder that it works before and that app.html still works.

    Of cource not a real problem as Long we have alternatives. ;-)



    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on January 17, 2014, 10:38:24 PM
    app.html doesn't access the local file-system or local browser storage.
    Title: Re: newLISP in a browser
    Post by: Lutz on January 20, 2014, 10:56:50 AM
    The editor IDE is now in pretty good shape, but running a lot of stuff in JavaScript compiled newLISP over the weekend, too often optimization problems and exception handling problems occur which are problems of the Emscripten compilation.



    When new versions of the LLVM-Clang-Emscripten toolchain come out, I will try again. At least the LLVM and Clang parts seems to be stable. Since a few versions now, newLISP is compiled using LLVM and Clang for the OSX 9.1 (Maverick) for all OSX binary distributions. Emscripten works by taking LLVM, Clang generated low level bit code and translating it to a subset of JavaScript called asm.js, which then gets fed to the JavaScript runtime VM.



    The current newlisp-js-10.5.7.zip is Ok for demo purposes but not for production work.
    Title: Re: newLISP in a browser
    Post by: HPW on January 20, 2014, 11:42:46 AM
    Hello Lutz,


    Quote
    When new versions of the LLVM-Clang-Emscripten toolchain come out, I will try again.

    The current newlisp-js-10.5.7.zip is Ok for demo purposes but not for production work.


    Not so good news. I hope the Emscripten-team is aware of the problems and get them fixed.

    A stable engine is a must-have to move serious projects to that engine.



    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on January 21, 2014, 08:38:51 PM
    Occasional problems with exceptions persist but can be defined more precisely now. See the CHANGES notes for more about this. I believe it is still possible to build stable applications with newLISP compiled to JavaScript.



    It was possible to cut the size of the library in half doing more compiler optimizations. This did not make the exception problems worse. The compressed newlisp-js-lib.js.gz is now only 250K.



    http://www.newlisp.org/downloads/development/inprogress/
    Title: Re: newLISP in a browser
    Post by: HPW on January 22, 2014, 12:11:54 PM
    Typo in changes: to work


    QuoteFor this to wordk emsdk-portable.tar.gz must be installed ....
    Title: Re: newLISP in a browser
    Post by: Lutz on February 17, 2014, 11:43:34 AM
    Since the last 'newLISP in a browser' announcement many things have been added to the editor. I use it now frequently for trying out and developing smaller code portions.



    The execption handling problems (setjmp(), longjmp()) only occur rarely and I hope they will go away completely with newer versions of the Emscripten tool set.



    - Syntax highlighting now with CodeMirror editor. This is the same editor, Marc is using at the http://newlisp.neocortex.io/ demo. He could take the syntax highlighting file from here:

    newlisp-js-x.x.x/codemirror/mode/newlisp/newlisp.js



    - Several dark and brigth color schemes.



    - Keyboard short cuts for most buttons (click [info]).



    - Automatic vertical and horizontal resizing when browser window changes and sensing of mobile device rotation.



    - Tool tips for all buttons.



    - line numbers can be toggled on/off.



    Access it here: http://www.newlisp.org/newlisp-js/



    The info page has a link to the source package. At least for me, a bluetooth keyboard connected to the iPad did not work with the CodeMirror editor. I hope this is something getting fixed soon by the Emscripten team.
    Title: Re: newLISP in a browser
    Post by: johu on February 18, 2014, 02:30:05 AM
    Hello, Lutz.



    For Stable Release or Development version,



    in newlisp_manual.html

    line 1430
    QuotenewLISP code and JavaScript code together. Bot languages can call

                         ↓

    newLISP code and JavaScript code together. But languages can call

    line 7309
    Quote<table border="0" cellpadding="1" width="95%" align="center" summary="Reflection and customization">

                                     ↓

    <table border="0" cellpadding="1" width="95%" align="center" summary="API for newLISP in a web browser">

    line 12401



    might be added

    Because there is between display-html and div.





    in README.html

    line 309
    Quote        (eval-string-js (string "GetUrl('" url "')"))

                      ↓

            (eval-string-js (string "GetUrl('" url "')")) )

    line 322
    Quotenew webpage. When evaluating the following snipped in the editor box,

                         ↓

    new webpage. When evaluating the following snippet in the editor box,


    Thanks,
    Title: Re: newLISP in a browser
    Post by: Lutz on February 18, 2014, 06:52:14 AM
    Thank you very much for all the corrections Johu.



    Everything is online here: http://www.newlisp.org/newlisp-js/
    Title: Re: newLISP in a browser
    Post by: HPW on October 11, 2014, 11:11:23 AM
    Quote....and I hope they will go away completely with newer versions of the Emscripten tool set.


    Since some time/versions have passed, is there any Progress in newer versions of the Emscripten tool set for more stable newlisp-implementations?



    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on October 11, 2014, 11:41:29 PM
    The current version at http://newlisp.org/newlisp-js was installed on September 16th and based on the latest version of Emscripten. All exception handling problems fortunately have disappeared :) On all platforms it runs best on Firefox.
    Title: Re: newLISP in a browser
    Post by: HPW on October 12, 2014, 05:36:36 AM
    Hello Lutz,



    Good News, It would be interesting to try newlisp in a browser combined with one of the popular JavaScript-GUI-frameworks for example: http://www.jqwidgets.com/jquery-ui-widgets-toolkit/



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on November 28, 2014, 09:33:24 AM
    Hello,



    In http://www.newlisp.org/newlisp-js/README.html we can read:


    QuoteFor a tutorial in to the basics of newLISP type (load "newlisp-js/tutorial.lsp") in to the editor ....


    But when I try it I get:


    QuoteERR: problem accessing file in function load : "newlisp-js/tutorial.lsp"


    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on November 28, 2014, 02:03:15 PM
    Thanks Hans-Peter, the link has been taken out. It is not completed yet but perhaps it will appear in a future version.
    Title: Re: newLISP in a browser
    Post by: HPW on March 01, 2015, 08:06:39 AM
    Hello,



    A observation for IE11 on Win7 tablet and the provided links here:



    http://www.newlisp.org/newlisp-js/ does not finish loading.The word 'Downloading...' stays visible and Buttons do not work.



    http://newlisp.nfshost.com/newlisp-js/ works as expected on IE11.



    Both links work on Chrome as expected.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on March 01, 2015, 08:23:28 AM
    Hello,
    Quote..... and based on the latest version of Emscripten.


    Just curios:



    http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html



    shows 1.29 as download-Version. The newlisp-js Shows 1.22 as the version number.



    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on March 01, 2015, 09:55:18 AM
    During the coming week, I will try to update the Emscripten.



    Also: the best browser for using Emscripten is - by far - Firefox. It is more than double the speed of Chrome. To check the speed: clear the windows using the x-edit and x-log buttons, then execute:

    (module "qa-bench")

    this will give you the relative speed to a MacOSX 10.9, 2.3GHz Intel Core i5. Firefox comes in with 1.89 and Chrome with 5.01. On my iPhone 5s and iPad Mini (version 1) it will crash, because of the lack of memory required by the bench mark routines - you must then hit the red reload button. Haven't tried on a iPhone 6 or newer iPad, which all have more memory.



    Firefox is also the only browser, which allows you to run locally on a laptop or desktop without going through a web server.
    Title: Re: newLISP in a browser
    Post by: HPW on March 01, 2015, 12:29:25 PM
    Hello Lutz,



    I will try also Firefox.

    But why does the first link not work on IE11.

    What can be the difference between the both server setups.

    Just to make sure that it work on all target-platforms.



    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on March 02, 2015, 08:17:42 AM
    see here: https://github.com/kripken/emscripten/issues/3180
    Title: Re: newLISP in a browser
    Post by: Lutz on March 03, 2015, 11:58:25 AM
    Updated here to Emscripten v1.29 and current in progress newLISP v10.6.3. http://www.newlisp.org/newlisp-js/ . Performance on Firefox has slightly improved, now 1.68 compared to native 1.0 performance.



    For IE11 issues see here: https://github.com/kripken/emscripten/issues/3180
    Title: Re: newLISP in a browser
    Post by: HPW on March 03, 2015, 12:33:27 PM
    Hello,



    Thanks for the update.

    Now it loads again from the link on IE11 on my Win7 tablet (I5 470UM / 1.33GHz).



    Qa-bench on IE11:

    >>>>> total time: 50358

    >>>>> Performance ratio:82.10 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Qa-bench on Chrome 40:

    >>>>> total time: 15157

    >>>>> Performance ratio:24.86 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Not installed Firefox yet, have to upgrade my 64Gb SSD first.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on March 03, 2015, 02:05:15 PM
    Hello,



    After upgrading Chrome to 41:



    >>>>> total time: 2844

    >>>>> Performance ratio: 4.83 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on March 03, 2015, 10:39:40 PM
    Hello,



    Another bench from my CAD-Workstation (WIN 7 64bit Xeon E5-1620 3.7 Ghz)



    IE 11:

    >>>>> total time: 4806

    >>>>> Performance ratio: 8.02 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-

    Chrome 41:

    >>>>> total time: 1097

    >>>>> Performance ratio: 1.99 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)

    Firefox 36:

    >>>>> total time: 818

    >>>>> Performance ratio: 1.54 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on March 04, 2015, 09:52:43 AM
    QuoteFirefox is also the only browser, which allows you to run locally on a laptop or desktop without going through a web server.


    Just tried it out. Nice tip. Will be usefull for further testing.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on March 07, 2015, 06:14:25 AM
    Hello,



    Upgraded my tablet SSD today from Sandisk 64Gb to Samsung evo 470Gb.

    Installed firefox 36 and here is the benchmark result:


    Quote
    >>>>> total time: 1945

    >>>>> Performance ratio: 3.37 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)


    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on October 15, 2015, 09:01:23 AM
    Hello,



    Today I could test on a aged intel core 2 duo P8400 with 4GB

    Windows 10 Pro 32 bit



    Chrome 46

    >>>>> total time: 3792

    >>>>> Performance ratio: 6.37 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Firefox 41.0.1

    >>>>> total time: 1605

    >>>>> Performance ratio: 2.82 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Edge

    >>>>> total time: 5214

    >>>>> Performance ratio: 8.68 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    IE11

    >>>>> total time: 11433

    >>>>> Performance ratio:18.80 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on October 16, 2015, 09:05:15 AM
    Hello,



    By the way emscripten is now at 1.34.1



    http://kripken.github.io/emscripten-site/docs/getting_started/downloads.html



    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on October 16, 2015, 09:50:40 AM
    There will be an update based on the latest Emscripten later this year and based on newLISP v10.6.4/5.
    Title: Re: newLISP in a browser
    Post by: HPW on October 24, 2015, 12:57:59 AM
    Hello,



    when you do the update please add this line below the sample code in the editor:


    ;(module "qa-bench") ;This call let you benchmark your pc and browser

    Then a user could outcomment the line when needed.



    Thanks as always for the ongoing development.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on December 31, 2015, 01:17:44 AM
    Hello,



    I am expermenting with newlisp in a browser from a different web-enviroment.

    (neoappbuilder from neosoft http://www.neosoftware.com/neoappbuilder.html )

    I noticed a load-error from the lib.

    I noticed that it makes a difference when the file newlisp-js-lib.html.mem is missing in the main path.

    So what is that file for and must it be redistributed with the lib?



    Edit: When the file is not present or renamed this error is shown in Firefox:

    NS_ERROR_DOM_BAD_URI: Access to restricted URI denied newlisp-js-lib.js:866:0



    Can you add a more simple sample Html than app.html reduced to the steps to load only the lib?



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on December 31, 2015, 07:48:37 AM
    Hello,



    A smaller Version of app.html.



    <!doctype html>
    <html lang="en-us">
      <head>
        <meta charset="utf-8"/>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>newLISP in a browser example app.</title>
        <style type="text/css" media="screen">
        .emscripten {padding-right: 0; margin-left: auto; margin-right: auto; display: block;}
        .content { margin: 0 5%; max-width: 800px; padding: 6px; background-color: #EEF; border-radius: 5px;}
        .button { color: #000000; background-color: #A0A0D0; border: 0px; border-radius: 5px; }
        </style>
        <script language="Javascript">
          // put your applications java script functions in this area
          // this function executes newLISP code, triggered by a button
          function evallisp() {
                var source = document.getElementById('lispinput').value;
                var result = newlispEvalStr(source);
                var fieldName = document.getElementById('content');
                fieldName.innerHTML = result;
                }
        </script>
      </head>

       <body style="font-family: Helvetica; background-color: #FFF;">
       <div class="content">
        <div class="emscripten" id="status">Downloading...</div>
        <div class="emscripten">
          <progress value="0" max="100" id="progress" hidden=1></progress>
        </div>
        <!-- Put your newLISP function definitions in this textarea. Code
        gets preloaded from here when the page loads. Just for this app it
        also gets loaded from here for display purpose in id='content'. -->

        Lisp code: &nbsp;
        <input type="text" id="lispinput" value="(sys-info)" size="80" style="font-size: 1em; border-radius: 5px;"/>
        <input type="button" class="button" value="eval lisp" style="font-size: 1em;"
                onclick="evallisp();"/>
        &nbsp;
        Result: &nbsp;
        <span id="content"></span> <!-- code is copied from id='code' area into this -->

        <script type='text/javascript'>
    <!--
          // ================== careful changing anything below ===================
          // EMSCRIPTEN loading newlisp-js-lib.js showing progress of downloading
          // importing newlispEvaklStr and defining preRun and postRun functions
          var Module = {
            preRun: [],
            postRun: [(function() {
              // import newlispEvalStr from newlisp-js-lib.js library
              newlispEvalStr = Module.cwrap('newlispEvalStr', 'string', ['string']);
              // preload newLISP functions from code textarea id='code'
    //          newlispEvalStr(document.getElementById('code').value);
              // preload memoizing table
    //          newlispEvalStr('(fibo 150)(fibo 300)(fibo 450)');
            })],
            print: (function() { return function(text) { }; })(),
            printErr: function(text) { },
            setStatus: function(text) {
              if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
              if (text === Module.setStatus.text) return;
              var m = text.match(/([^(]+)((d+(.d+)?)/(d+))/);
              var now = Date.now();
              if (m && now - Date.now() < 30) return; // if progress update, skip if too soon
              var statusElement = document.getElementById('status');
              var progressElement = document.getElementById('progress');
              if (m) {
                text = m[1];
                progressElement.value = parseInt(m[2])*100;
                progressElement.max = parseInt(m[4])*100;
                progressElement.hidden = false;
              } else {
                progressElement.value = null;
                progressElement.max = null;
                progressElement.hidden = true;
              }
              statusElement.innerHTML = text;
            },
            totalDependencies: 0,
            monitorRunDependencies: function(left) {
              this.totalDependencies = Math.max(this.totalDependencies, left);
              Module.setStatus(left ?'Preparing... (' + (this.totalDependencies-left) +
                            '/' + this.totalDependencies + ')' : 'All downloads complete.');
            }
          };
          Module.setStatus('Downloading...');
        // ========================================================================
    -->
        </script>
        <script async type="text/javascript" src="newlisp-js-lib.js"></script>
      </div></body>
    </html>
    <!-- eof -->

    Title: Re: newLISP in a browser
    Post by: Lutz on December 31, 2015, 01:14:48 PM
    From http://www.newlisp.org/newlisp-js/newlisp-js-10.6.3.zip you need the whole codemirror/ sub-directory and the files newlisp-js-lib.js (this is newLISP compiled to JavaScript) and newlisp-js-lib.html.mem (some kind of configuration file).



    A Happy 2016 to everybody!!!



    Ps: code mirror stuff is only necessary for the editor
    Title: Re: newLISP in a browser
    Post by: HPW on December 31, 2015, 11:43:26 PM
    Hello Lutz,



    Also a happy new year for you and the newlisp community.



    Thanks for the Infos.



    For now you have to know that the mem-file has to be in the main-path of the Html which has the include-code. In my tests all js-stuff was in a sub-Directory /js and the load fails when mem file is there.



    By the way emscripten is now at 1.35.0

    http://kripken.github.io/emscripten-site/index.html



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on January 02, 2016, 12:55:20 AM
    Found an Explanation for the mem-file:

    https://github.com/kripken/emscripten/issues/2537


    Quote
    .....This is by design, .mem files are created in optimized builds to reduce size and improve startup speed. You can disable them  --memory-init-file 0  if you want, but it is not recommended. When they are emitted, they must be alongside the .js file so it can find it.


    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on March 10, 2017, 11:00:10 PM
    Hello,



    Currently there are News about WebAsembly and Emsripten.



    WebAssembly was build into new Firefox 52.



    Emsripten has released 1.37.3 (February 21, 2017).



    Talk about both:

    https://brendaneich.com/2015/06/from-asm-js-to-webassembly/


    Quote
    How: If you use Emscripten, then wasm support via a command-line flag will at first include and target the prototype polyfill. But as native wasm decoders appear in top engines (see the V8 native prototype decoder), Emscripten will auto-configure for best results. Another prototype: a JS AST compressor (encoder).



    These prototypes will evolve and track draft specification changes as WebAssembly matures and receives progressively more developer testing. Other compilers than Emscripten, and other compiler frameworks than LLVM, will join the mix. I expect all engines will support fast native decoders. All these parts are means to the end of a common WebAssembly standard.


    Not sure if this can be used for a new version of newlisp in a browser.



    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on March 12, 2017, 10:31:45 AM
    Probably a newlisp-js-lib.wasm will be substantially bigger than a newlisp-js-lib.js, which might be a problem on devices with less memory. Speedwise we don't know, the current JavaScript machine in FireFox is already pretty good.



    For me, the main thing on this topic is, that the interest in 'newLISP in a browser' has been very poor and the getting the development environment right was pretty time consuming, even on Mac OS.



    There are also a few things to be done in newlisp.c for the Emscripten interface.



    At least at the moment, there are no plans to update to a newer version or to try the WebAsm way. Of course anybody trying to do that themselves is welcome.
    Title: Re: newLISP in a browser
    Post by: Lutz on March 15, 2017, 07:35:48 PM
    After reading this: https://hacks.mozilla.org/2017/03/why-webassembly-is-faster-than-asm-js/

    I may change my mind. Perhaps WebAssembly is worth a try. Also does 64bit integers.
    Title: Re: newLISP in a browser
    Post by: HPW on March 16, 2017, 05:33:59 AM
    Hello Lutz,



    Interesting read. Keep us up to date when you have changed your mind.

    When it would get widely supported on various platforms, the poor interest may change.

    I could imagine to integrate the newlisp-engine for business-rules and data with other web-Standards for GUI and 3D.

    Just my 2 Cents. ;-)



    Regards
    Title: Re: newLISP in a browser
    Post by: xytroxon on March 19, 2017, 02:55:15 PM
    Found this. Might be as simple as setting a flag!



    //http://webassembly.org/docs/faq/


    QuoteWhat's the story for Emscripten users?



    Existing Emscripten users will get the option to build their projects to WebAssembly, by flipping a flag. Initially, Emscripten's asm.js output would be converted to WebAssembly, but eventually Emscripten would use WebAssembly throughout the pipeline. This painless transition is enabled by the high-level goal that WebAssembly integrate well with the Web platform (including allowing synchronous calls into and out of JavaScript) which makes WebAssembly compatible with Emscripten's current asm.js compilation model.


    -- xytroxon
    Title: Re: newLISP in a browser, importing from a file (get-url)
    Post by: fdb on June 19, 2017, 11:28:55 AM
    Hi,i'm experimenting a bit with new lisp in a browser and while trying to write a dedicated javascript function to import a textile i ran into the following. I was first trying this with jQuery.Get(Url) which returned "undefined". Eventually I found out that to make it work you'll have to make the request synchronous.So my javascript function now looks like this (i'm not passing the url a parameter):

    function getwoordenlijst() {
    var xmlHttp = new XMLHttpRequest();
                xmlHttp.open( "GET", "/newlisp/woordenlijst.txt", false ); // false for synchronous request
               xmlHttp.send( null );
               return xmlHttp.responseText;
    }

    This works ,but of course blocks the browser while importing, and in firefox you get a warning that synchronues requests are depreciated. Anybody knows if there is a way to do this asynchronously ?
    Title: Re: newLISP in a browser -too many setjmps
    Post by: fdb on June 19, 2017, 11:43:35 AM
    When trying to run/eval a new lisp program in the browser i got below error message:



    too many setjmps in a function call, build with a higher value for MAX_SETJMPS



    apparently due to the Emscripten toolkit, but what can be done about this? Program works fine in 'normal' new lisp.
    Title: Re: newLISP in a browser too many setjmps
    Post by: fdb on June 21, 2017, 12:48:51 AM
    In answer to my own question above, i found out that the latest emscripten doesn't have the limitation on setjmps anymore. So i installed latest emscripten(1.37.14) and compiled new lisp (10.7.3) with it (using makefile_emscripten_lib_utf8) and it works!



    Got a warning because there is the -s MAX_SETJMPS=100 setting in the makefile which isn't used/supported anymore with latest emscripten, so better to remove it in future versions.
    Title: Re: newLISP in a browser
    Post by: HPW on June 21, 2017, 03:59:56 AM
    Hello fdb,



    Good to hear that get it working with latest newlisp version.

    Could you upload the resulting js somewhere so others can also test with it. (Until Lutz offer a new one)



    (I hope Lutz is thinking about the WebAssembly option)



    Regards



    Hans-Peter
    Title: Re: newLISP in a browser
    Post by: fdb on June 21, 2017, 03:32:24 PM
    Hi Hans-Peter,



    Made the js  (and .mem file)  available to download from here: www.ferrydb.nl/newlisp/download



    BR

    Ferry
    Title: Re: newLISP in a browser
    Post by: Lutz on June 21, 2017, 04:47:01 PM
    Thanks for doing this work Ferry:



    http://www.ferrydb.nl/newlisp/



    I also updated the 'info' file to newlisp-js-10.7.3.zip reference here:



    http://www.newlisp.org/newlisp-js/



    The zip file contains the whole newlisp-js directory including the codemirror editor files.



    The -s MAX_SETJMPS=100 setting in the makefile was done originally to save memory on mobile devices. This doesn't seem to be an issue anymore. Your compile runs fine on my iPhone 6s.
    Title: Re: newLISP in a browser
    Post by: HPW on June 21, 2017, 11:22:56 PM
    Hello Ferry and Lutz,



    Thanks for providing the new release.

    Works fine on all my firefox/chrome versions and IE11.

    On Edge I will test later.



    Lutz any new thoughts about the WebAssembly option?



    Edit: Latest edge also works fine.



    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on June 22, 2017, 08:05:50 AM
    When I have more time, may be. There is very little interest in the browser version at all. Perhaps somebody else wants to do it: http://webassembly.org/docs/faq/
    Title: Re: newLISP in a browser
    Post by: fdb on June 24, 2017, 12:35:05 PM
    Ok, i've managed to compile it to web assembly. - 'Just a switch...'  ;-)



    I eventually found out where to put the switch in the build file and it works in Firefox and Chrome (not in Safari), haven't tested Explorer/Edge.



    You can download newlisp-js-lib.js.wa and newlisp-js-lib.js.wasm from //ferrydb/newlisp/download, Lutz i've also added the make file i used. (makefile_emscripten_lib_utf8)



    You have to rename newlisp-js-lib.js.wa to newlisp-js-lib.js and put in together with new lisp-js-lib.wasm in the document directory of your web server.



    I've also done some performance tests with a small Scrabble program i wrote and it is really remarkable how fast JS/WA is compared to  native Newlisp (on iMac,  3.2Ghz Intel Core I3, 12 GB Ram). See below some results how long it takes to find the best solution in my little (naive/unoptimised/educational!) Scrabble program , (choosing from 35,000 words, having 5 letter and 2 jokers, 3 words already on the board).  



    All examples run on  iMac OSX 10.12.5 (Sierra),  3.2Ghz Intel Core I3, 12 GB Ram (in minutes CPU time)



    Native

    5.5



    Javascript

    Firefox : 5

    Chrome: 8

    Safari Nightly: 8

    Safari: 10



    WebAssembly

    Firefox: 4.5

    Chrome:5.5
    Title: Re: newLISP in a browser
    Post by: Lutz on June 24, 2017, 01:09:20 PM
    Great! will try it later.



    You can check performance evaluating this:



    (load "newlisp-js/qa-bench")



    The file is loaded from the internal directory.



    >>>>> total time: 821
    >>>>> Performance ratio: 1.54 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)


    Its 1.54 times slower in JavaScript on Firefox than natively. Currently running on a 2016 Macbook / macOS Sierra with very similar results. Chrome and Safari are much slower. It checks all non IO functions.
    Title: Re: newLISP in a browser
    Post by: fdb on June 24, 2017, 01:55:53 PM
    You can try it at //ferrydb.nl/newlisp-wa/ results below, so only marginally faster(as you suspected).



    >>>>> total time: 807
    >>>>> Performance ratio: 1.52 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)
    Title: Re: newLISP in a browser
    Post by: fdb on June 24, 2017, 02:25:38 PM
    Results on my 2017 macbook pro (I7 ,2.7 ghz)



    Firefox JS

    >>>>> total time: 535

    >>>>> Performance ratio: 1.08 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Chrome JS

    >>>>> total time: 1397

    >>>>> Performance ratio: 2.48 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Firefox Web Assembly

    >>>>> total time: 511

    >>>>> Performance ratio: 1.04 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Chrome Web Assembly

    >>>>> total time: 594

    >>>>> Performance ratio: 1.17 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)
    Title: Re: newLISP in a browser
    Post by: HPW on June 25, 2017, 12:43:36 AM
    Hello,



    Thanks Ferry for providing the WebAssembly Option.



    From my Win7 tablet (The middle of 3 measurements)



    http://ferrydb.nl/newlisp/



    http://ferrydb.nl/newlisp-wa/



    Asus Eee Slate

    i5 U470 1.33 Ghz 4 Gb

    Windows performance Index 3.1





    (module "qa-bench")



    IE 11.0.9600 JS



    >>>>> total time: 41174

    >>>>> Performance ratio:67.17 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    IE 11.0.9600 WA



    Not compatibel





    Chrome 59.0.3071.109 JS



    >>>>> total time: 13724

    >>>>> Performance ratio:22.52 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Chrome 59.0.3071.109 WA



    >>>>> total time: 4920

    >>>>> Performance ratio: 8.21 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)





    Firefox 54.0 32bit JS



    >>>>> total time: 6168

    >>>>> Performance ratio:10.24 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Firefox 54.0 32bit WA



    >>>>> total time: 5862

    >>>>> Performance ratio: 9.74 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on June 25, 2017, 01:02:21 AM
    Hello,



    Another test on an aged WIN 1o Laptop



    Core 2 duo P8400 2.26 Ghz 4GB

    Windows 10 Pro 1703 32bit



    Edga 40 JS



    >>>>> total time: 3759

    >>>>> Performance ratio: 6.32 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Edge 40 WA with enabled experimental javascript



    ERR: regular expression in function find-all : "error -4 when executing"

    called from user function QA:(qa)

    called from user function (module "qa-bench")



    So we see that WebAssembly is not yet everywhere. Best performance boost on chrome.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on June 25, 2017, 09:58:46 PM
    Hello,



    Another note for WIN XP:



    Neither Chrome 49 or Firefox ESR 52.2.0 work with WebAssembly.

    But the JS-flavour works.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on June 25, 2017, 10:32:26 PM
    Hello,



    CAD-Workstation:

    Dell Precision T3610

    CPU E5-1620 v2 3.7 GHZ 16GB

    Windows performance index 7.7

    WIndows 7 PRO SP1



    http://www.ferrydb.nl/newlisp/

    http://www.ferrydb.nl/newlisp-wa/



    (module "qa-bench")





    Chrome 59 JS



    >>>>> total time: 1832

    >>>>> Performance ratio: 3.18 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Chrome 59 WA



    >>>>> total time: 796

    >>>>> Performance ratio: 1.50 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)





    Firefox 54 JS



    >>>>> total time: 1032

    >>>>> Performance ratio: 1.88 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Firefox 54 WA



    >>>>> total time: 990

    >>>>> Performance ratio: 1.81 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Regards
    Title: Re: newLISP in a browser
    Post by: fdb on June 26, 2017, 03:09:08 PM
    Hi,



    i've now als run some test on my iPad Pro, running beta of IOS 11 and also Safari 11 which should be able to run web assembly, results below:



    With javascript:

    >>>> total time: 3139

    >>>>> Performance ratio: 5.31 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    With web-assembly:

    >>>>> total time: 1633

    >>>>> Performance ratio: 2.86 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    So almost twice as fast with web assembly.
    Title: Re: newLISP in a browser
    Post by: HPW on January 03, 2018, 12:38:03 PM
    Hello,



    Latest emscripten: Emscripten 1.37.27 (December 29, 2017)



    Firefox Quantum 57.0.3 64 bit with new impressive Performance on my tablet

    Asus Eee Slate

    i5 U470 1.33 Ghz 4 Gb

    Windows performance Index 3.1

    Tested on Ferry's pages with 1.37.14



    With javascript:

    http://ferrydb.nl/newlisp/



    >>>>> total time: 1891

    >>>>> Performance ratio: 3.28 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    With web-assembly:

    http://ferrydb.nl/newlisp-wa/



    >>>>> total time: 1539

    >>>>> Performance ratio: 2.71 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Much faster than the last test with Firefox 54 on that Hardware.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on January 03, 2018, 12:59:51 PM
    Hello,



    Also news on Edge compatibility:



    On the WIN 10 laptop with latest updates and Edge 41



    (module "qa-bench")



    With javascript:

    http://ferrydb.nl/newlisp/



    >>>>> total time: 3550

    >>>>> Performance ratio: 5.98 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    With web-assembly:

    http://ferrydb.nl/newlisp-wa/



    >>>>> total time: 3968

    >>>>> Performance ratio: 6.66 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Note: the only browser where web-assembly is slower than javascript.

    But it works now with wa. A little faster in javascript than the last test.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on January 27, 2018, 05:32:28 AM
    Hello,



    Firefox Quantum 58.0 getting even better:

    Asus Eee Slate

    i5 U470 1.33 Ghz 4 Gb



    With javascript:

    http://ferrydb.nl/newlisp/

    >>>>> total time: 1591

    >>>>> Performance ratio: 2.79 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    With web-assembly:

    http://ferrydb.nl/newlisp-wa/

    >>>>> total time: 1405

    >>>>> Performance ratio: 2.49 (1.0 on MacOSX 10.9, 2.3GHz Intel Core i5, newLISP v10.6.0-64-bit)



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on June 03, 2018, 01:34:04 AM
    Hello,



    In last test with Google Chrome 67 I noticed that WA is now about 8x slower than JS.

    In current Firefox WA is still faster than JS.



    I also test a chromium based broser which shows similar Performance like Chrome. Also slow WA.



    I wonder if it could be a problem with the used emscripten version.



    Latest emscripten: Emscripten: 1.38.4 (June 02, 2018)



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on June 03, 2018, 07:46:35 AM
    Hello,



    Did a bug report about chromes webassembly speed:



    https://bugs.chromium.org/p/chromium/issues/detail?id=849098



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on June 08, 2018, 03:40:50 AM
    Hello,



    Seems that they found the bug. Waiting for the fix.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on July 25, 2018, 06:46:51 AM
    Hello,



    Chrome Version 68.0.3440.75 (Offizieller Build) (64-Bit) is back on full speed with  webassembly.



    Firefox 61.0.1 (64-Bit) still a bit faster.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on August 25, 2018, 11:19:23 PM
    Hello Lutz,



    In the index.html is some code to Show a progressbar for downloading.

    I was wondering that it never Show up. Only the Status text changed.



          if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
              if (text === Module.setStatus.text) return;
              var m = text.match(/([^(]+)((d+(.d+)?)/(d+))/);
                alert (text);
                alert (m);

    The m variable keeps always null so the later if gets never true.



    Regards
    Title: Re: newLISP in a browser
    Post by: Lutz on August 26, 2018, 12:02:34 PM
    The original index.html was taken from some other application dealing with compiled JavaScript. This is probably some left-over unused or only partly used code.
    Title: Re: newLISP in a browser
    Post by: HPW on September 07, 2018, 03:31:26 AM
    Hello,

    After browser updates on major browsers



    CAD-Workstation:

    Dell Precision T3610

    CPU E5-1620 v2 3.7 GHZ 16GB

    Windows performance index 7.7

    WIndows 7 PRO SP1



    http://www.ferrydb.nl/newlisp/

    http://www.ferrydb.nl/newlisp-wa/



    (module "qa-bench")





    Chrome 69 JS



    >>>>> total time: 1099



    Chrome 69 WA



    >>>>> total time: 860





    Firefox 62 JS



    >>>>> total time: 822



    Firefox 62 WA



    >>>>> total time: 679



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on February 02, 2019, 09:31:26 PM
    Hello,



    Latest obserations with chrome 72:



    http://www.ferrydb.nl/newlisp/

    http://www.ferrydb.nl/newlisp-wa/



    For both url's chrome 72 shows a warning sign in front of the url "Nicht sicher" (german for not secure)

    Performance seems slower on both than older versions.

    Not nice.



    Regards
    Title: Re: newLISP in a browser
    Post by: HPW on February 04, 2019, 09:51:36 AM
    Hello,



    Oops, nothing special with Chrome and newlisp in the browser.

    The "Not secure" Display is for every Non-https site.



    Regards