Author Topic: JavaScript standalone interpreters  (Read 5720 times)

Tomaaz

  • Guest
JavaScript standalone interpreters
« on: August 03, 2016, 10:00:31 PM »
Has anyone tried JavaScript outside web browsers? There is Node.js, of course, but JSDB seems to be a very compact interpreter. The only problem I had with it was regular expressions not working properly. Apart from that (and the fact that it's a bit dated) it's a nice tool for scripting and plying with JavaScript.

wang renxin

  • Guest
Re: JavaScript standalone interpreters
« Reply #1 on: August 04, 2016, 01:17:31 AM »
Node.js has a standalone distribution in a single EXE too. I'll take a try and test among Node.js, Python, Ruby to choose one as a quick prototyping tool for web backend development.

Ed Davis

  • Guest
Re: JavaScript standalone interpreters
« Reply #2 on: August 04, 2016, 05:04:05 PM »
Has anyone tried JavaScript outside web browsers? There is Node.js, of course, but JSDB seems to be a very compact interpreter. The only problem I had with it was regular expressions not working properly. Apart from that (and the fact that it's a bit dated) it's a nice tool for scripting and plying with JavaScript.

A few that I've played with:

Duktape
http://duktape.org/

mujs
https://github.com/ccxvii/mujs

42tiny-js
https://github.com/ardi69/42tiny-js


But I keep coming back to Python.  The more I use it, the more I appreciate it.

Tomaaz

  • Guest
Re: JavaScript standalone interpreters
« Reply #3 on: August 05, 2016, 12:07:37 PM »
Node.js has a standalone distribution in a single EXE too.

Yes, but Node's been created for a slightly different things.

But I keep coming back to Python.  The more I use it, the more I appreciate it.

 ;) But for me Ruby's syntax still makes much more sense. It's a shame that Ruby doesn't exist outside the web. There are nice projects based on it (Shoes, SonicPi), but you can't really compare Ruby with Python in terms of available libraries. Thanx for the links to the JavaScript interpreters. Not exactly what I want (I would prefer fully featured distribution), but it's good to know that things like that exist. ;)

Tomaaz

  • Guest
Re: JavaScript standalone interpreters
« Reply #4 on: August 09, 2016, 02:04:37 PM »
I've just found Gjs. In the repositories. Ready to use and looks like something still in development.

Cybermonkey

  • Administrator
  • *****
  • Posts: 0
Re: JavaScript standalone interpreters
« Reply #5 on: August 10, 2016, 06:35:28 PM »
I used Node-Webkit (now known as NW.js) to build desktop applications.
Look here: http://nwjs.io/

Aurel

  • Guest
Re: JavaScript standalone interpreters
« Reply #6 on: August 10, 2016, 10:09:21 PM »
...and do you can show us your example Cyb?
this smell to me to Cromium html control( dll) connected with java script to build
so called desktop app, long time ago i see something similar but with php linked with something
i forget...

ScriptBasic

  • Guest
Re: JavaScript standalone interpreters
« Reply #7 on: August 11, 2016, 03:18:48 AM »
Quote from: Ed
But I keep coming back to Python.  The more I use it, the more I appreciate it.

Are you using Python for web development or utility work?

Curious, have you played around with Script BASIC any further?

Tomaaz

  • Guest
Re: JavaScript standalone interpreters
« Reply #8 on: August 11, 2016, 11:38:32 AM »
...and do you can show us your example Cyb?

I would like to see a piece of code, too.

this smell to me to Cromium html control( dll) connected with java script to build
so called desktop app, long time ago i see something similar but with php linked with something
i forget...

Do you mean PHP and Gtk server? Slightly different thing.
« Last Edit: August 11, 2016, 11:48:30 AM by Tomaaz »

Aurel

  • Guest
Re: JavaScript standalone interpreters
« Reply #9 on: August 11, 2016, 05:09:30 PM »
No GTK...this use bind to native win api...and I find it
it is called WinBinder ..if i remember this thing work very well on windows
i will download new version and try:
http://winbinder.org/

          
     

Key benefits

    * Large installed base of PHP programmers.
    * No compiling and linking steps necessary: just code and run.
    * Access to the vast range of existing PHP functions and extensions, including databases, graphics, web functions, XML, PDF, and much more.
    * A small set of WinBinder functions encapsulates many complex aspects of the Windows API and makes programming for Windows an easy task.
    * Provides 100% native Windows classes and controls.
    * Interfaces directly to the Window API. This means fast execution, no extra libraries and no installation required.
    * Supports both procedural and object-oriented programming models.
    * High performance, compares favorably to most scripting languages.
    * Produces standalone applications that can be easily installed and removed with no reboot.
    * Small footprint. A simple Windows application, complete with the PHP runtime and SQLite extension, is smaller than 700 kB (zipped).
    * A database-independent framework allows easy coding (no SQL knowledge is necessary) and smooth integration with the WinBinder code.
    * No database server required if using SQLite.
    * Does not need to use to the Windows registry, but may use it if necessary.
« Last Edit: August 11, 2016, 05:14:22 PM by Aurel »

Tomaaz

  • Guest
Re: JavaScript standalone interpreters
« Reply #10 on: August 11, 2016, 08:38:23 PM »
I used Node-Webkit (now known as NW.js) to build desktop applications.
Look here: http://nwjs.io/

OK. I've tried it. It's very slow on Linux. Takes ages to run simple "Hello World" example.

ScriptBasic

  • Guest
Re: JavaScript standalone interpreters
« Reply #11 on: August 11, 2016, 10:59:51 PM »
UltraEdit has done a nice job of embedding JavaScript into their editor.

My plan was after the Perl extension module for Script BASIC was to do a JavaScript extension but array sort got in the way and I never got back to it. Unfortunately real life is consuming all my free time at the moment.
« Last Edit: August 11, 2016, 11:03:29 PM by John »

Tomaaz

  • Guest
Re: JavaScript standalone interpreters
« Reply #12 on: August 12, 2016, 01:55:06 PM »
I used Node-Webkit (now known as NW.js) to build desktop applications.
Look here: http://nwjs.io/

OK. I've tried it. It's very slow on Linux. Takes ages to run simple "Hello World" example.

It seems to be a bit faster on my Win 10 machine. Yes, it takes several seconds to start, but apart from that it seems to be something I was looking for. Thanx a lot, Cybermonkey! :)

...and do you can show us your example Cyb?.

Aurel, it basically takes your HTML/CSS/JavaScript code and run it in a standalone window. Plus you get functions that can interact with your operating system. This example simply draws Mandelbrot Set in a standalone window, but it places the window in a specific position, set its width and height and checks if the directory named "mandelbrot" exists (if not, it is created):

Code: [Select]
<!DOCTYPE html>
<html>
<head>
<title>Mandelbrot</title>
<script>
var win = nw.Window.get();
win.x = 100;
win.y = 20;
win.width = 920;
win.height = 620;
fs = require('fs');
if (!(fs.existsSync('mandelbrot'))) {
var kat = fs.mkdirSync('mandelbrot');
}
var x = 0;
function aktywuj() {
plotno = document.getElementById("rysunek");
zawartosc = plotno.getContext("2d");
zawartosc.fillStyle = "#000000";
zawartosc.fillRect(0,0,900,600);
t = setTimeout("rysuj()", 1);
}
function rysuj() {
plotno = document.getElementById("rysunek");
zawartosc = plotno.getContext("2d");
przelx = 3 / 900;
przely = 2 / 600;
for (y = 0; y < 600; y++) {
c = 0;
a = 0;
b = 0;
z = 0;
x2 = (x - 450) / 150;
y2 = (y - 300) / 150;
while (c < 128 && z < 4) {
a2 = a * a - b * b;
b2 = 2 * a * b;
a = a2 + x2;
b = b2 + y2;
z = a * a + b * b;
c = c + 1;
}
p = c * 12;
if (p > 255) {
p = 0;
}
k = c * 8;
if (k > 255) {
k = 0;
}
l = c * 4;
if (l > 255) {
l = 0;
}
m = l.toString();
n = k.toString();
o = p.toString();
kol = "rgb(" + m + "," + n + "," + o + ")";
zawartosc.fillStyle=kol;
zawartosc.fillRect(x, y, 1, 1);
}
if (x < 900) {
x++;
t = setTimeout("rysuj()", 1);
}
}
</script>
</head>
<body onload = "aktywuj()">
<div>
<canvas id="rysunek" width="900" height="600"></canvas>
</div>
</body>
</html>

Aurel

  • Guest
Re: JavaScript standalone interpreters
« Reply #13 on: August 12, 2016, 02:14:19 PM »
Quote
Aurel, it basically takes your HTML/CSS/JavaScript code and run it in a standalone window
Yes i see ...nothing new or better

Tomaaz

  • Guest
Re: JavaScript standalone interpreters
« Reply #14 on: August 12, 2016, 02:41:24 PM »
Quote
Aurel, it basically takes your HTML/CSS/JavaScript code and run it in a standalone window
Yes i see ...nothing new or better

Well, it can call Node.js modules from DOM, so it is something new. And better... Better than what? If you are planning to start this "WinAPI stuff" again, I'm not gonna continue this conversation. ;)
« Last Edit: August 12, 2016, 02:45:31 PM by Tomaaz »