nerdlang / nerd Goto Github PK
View Code? Open in Web Editor NEW🔱 Javascript's God Mode. No VM. No Bytecode. No GC. Just native binaries.
Home Page: https://nectarjs.com
License: MIT License
🔱 Javascript's God Mode. No VM. No Bytecode. No GC. Just native binaries.
Home Page: https://nectarjs.com
License: MIT License
nectarjs.com seems to stutter when scrolling on Chrome or Brave and to a lesser extent on Edge. It's like it's fighting me to scroll the page down.
Also the e in development and developers in some places has a glyph on top of it. This is incorrect.
Finally, you're loading a Google font with HTTP and this is making Brave complain about mixed content. Just need to use the HTTPS version.
This is a great idea and I look forward to seeing in progress. I'll need this in a couple of years when I want to compile my JavaScript game for distribution.
Keep it up!
I'm just returning "Unexpected Compilation Error". I fixed about 500 minor syntax errors/warnings, but now this is all I see without any further description. My target seems fine. The script isn't doing anything out of the ordinary: lots of arrays, some objects, and bit functions on 32-bit ints. Any ideas?
I already have the question in stack overflow here, but shortly, i want to be able to give parameters when starting the compiled version of the program. For examle:
#compile the javascrpit code with nectar
nectar file.js --single -o compiledFile
#now i want to run it with a second argument witch is an input file
./compiledFile inputFile
Is there a built-in functionality or any sort of way i can do that, or can it be possible to be done since JavaScript itself doesn't support that sort of thing.
Hi,
How feasible do you think that it would be to modify NectarJS to integrate it with React Native? If JS could be compiled to binary while making use of React to interact with the DOM one of the bottlenecks of React Native could be addressed.
Thanks!
Hello.
I receive "Compilation error" when I use let, async, await and others ES6 features.
Have some prediction to add suport for that?
Will be good specify this issue on readme?
Thanks.
For a couple days now it seems to do nothing then webcompile eventually times out with 504.
Is it or will it be possible to develop GUIs with nectarjs as opposed to using something like electron. If this question is unclear I can try to elaborate.
Compiled the following:
testObject.exe
var testObject = { testKey1: "test 1" };
testObject["testKey2"] = "test 2";
console.log(testObject);
testObject2.exe
console.log("test 0");
var testObject = { testKey1: "test 1" };
testObject["testKey2"] = "test 2";
console.log(testObject);
console.log("test 3");
testObjectKey.exe
var testObject = { testKey1: "test 1" };
testObject["testKey2"] = "test 2";
console.log(testObject["testKey1"]);
First, look at testObject2.exe. Strings "test 0" and "test 3" made it into the binary, but the others did not.
"test 0" and "test 3" are puts() by this, but code related to the object testObject is missing:
sub.test_0_540 is called here, mixed in with initialization code and exit which all NectarJS win-x86-64 targets seem to share (boilerplate? template?):
Now testObjectKey.exe. All related strings are present in the binary.
Looks like code working with the object is here:
Which is called here, with familiar boilerplate:
Lastly, testObject.exe. All of the related strings are missing.
In the spot where I should find a call to the code which works with the object, I instead find a call to some code which has another call to fcn.00401f00. I stopped here and have not put any effort into understanding what fcn.00401f00 does since it, or an equivalent, appears to be called during initialization in any case (the cases I've looked at, anyway).
Basically, it looks like I ended up with an exe with nothing but boilerplate.
Is console.log(object) not yet supported? Or, did something go wrong during the build, the problem was handled gracefully, and the exe was generated anyway? Maybe it would be better for the build to fail.
Assuming the object and its supporting strings and code were optimized out because there are no useful references to it, where did the optimization occur? Your compiler, or by MinGW?
shindin@shindin:~/myml/js2wasm$ nodejs example.js
dlrow olleH
shindin@shindin:~/myml/js2wasm$ sudo nectar --run example.js
Compilation error
shindin@shindin:~/myml/js2wasm$ cat example.js
function r(s) {
return s.split("").reverse().join("");
}
console.log(r('Hello world'));
shindin@shindin:~/myml/js2wasm$ sudo nectar --target wasm example.js
Compilation error
shindin@shindin:~/myml/js2wasm$ sudo nectar --run hello.js
Hello
shindin@shindin:~/myml/js2wasm$ sudo nectar --target wasm hello.js
shindin@shindin:~/myml/js2wasm$
This example.js does not compile.
Issue #10 was closed with:
However, win-x86-64 target executables compiled since then still appear to use Duktape.
When I compile this:
console.log(Duktape.version)
It still outputs 20299.
.rdata section still contains strings related to duktape.
Has something gone wrong with the update?
I did
necater --verbose a.js
And i run ./a-linux-x86-64.bin
Here is the result:
./a-linux-x86-64.bin: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./a-linux-x86-64.bin)
./a-linux-x86-64.bin: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by ./a-linux-x86-64.bin)
I know it's not NectarJS's problem.But I can't fix it....... help....
I am confused how to compile or run anything with NectarJS on macos 10.13.2 (17C88)…
# nectar -v
NectarJS Client v0.0.53
# nectar example.js
[!] Bad target
[*] Available targets :
-> win-x86-32
-> win-x86-64
-> linux-x86-32
-> linux-x86-64
-> linux-arm32v7
-> arduino-uno
-> arduino-mega1280
-> arduino-mega2560
-> wasm
-> wast
-> asm-js
# cat project.json
{"main": "example.js", "out": "example.asm.js", "target":"asm-js", "preset":"speed"}
# nectar --target asm-js example.js
Missing project.json
Note: I am using MacPorts, could this affect compilation?
# port select --summary
Name Selected Options
==== ======== =======
gcc mp-gcc49 none
llvm mp-llvm-3.5 none
Hi, I wonder if now or eventually Nectar could be used in the following way:
I defined a piece of JavaScript which depends on a platform API:
MessageBoxW(null, 'Hello, World!', 'Hi!', 0);
Then I somehow defined the FFI information so that Nectar knows this function I'm invoking is a part of the platform's/target's API.
And then I compile this code using Nectar and have a binary which invokes the Windows API MessageBoxW
.
Also, this might be a better fit for a separate issue, but anyway: I see you are providing people with keys to access Nectar while it's in alpha and also this repo doesn't include any source code. How are you going to provide Nectar when it makes out of alpha? Is it going to be open source? Free or paid?
ditto
I did not see unicode support listed in the roadmap, but I found this problem.
If I compile this:
var hovercraft_j = "私のホバークラフトは鰻でいっぱいです";
var hovercraft_g = "Το αερόστρωμνο μου ειναι γεμάτο χέλια";
var hovercraft_r = "Моё судно на воздушной подушке полно угрей";
console.log(hovercraft_j);
console.log(hovercraft_g);
console.log(hovercraft_r);
and run it on Windows with a terminal properly configured for unicode, I get this output:
Here is the same code executed by NodeJS:
Here I can see NectarJS is using fputs to try to output the unicode text:
If I compile this with MinGW:
#include <fcntl.h>
#include <io.h>
#include <stdio.h>
int main () {
char *hovercraft_j = "\t私のホバークラフトは鰻でいっぱいです\n";
wchar_t *hovercraftw_j = L"\t私のホバークラフトは鰻でいっぱいです\n";
char *hovercraft_g = "\tΤο αερόστρωμνο μου ειναι γεμάτο χέλια\n";
wchar_t *hovercraftw_g = L"\tΤο αερόστρωμνο μου ειναι γεμάτο χέλια\n";
char *hovercraft_r = "\tМоё судно на воздушной подушке полно угрей\n";
wchar_t *hovercraftw_r = L"\tМоё судно на воздушной подушке полно угрей\n";
fputs("\nfputs()\n", stdout);
fputs(hovercraft_j, stdout);
fputs(hovercraft_g, stdout);
fputs(hovercraft_r, stdout);
fputs("\nfputws()\n", stdout);
fputws(hovercraftw_j, stdout);
fputws(hovercraftw_g, stdout);
fputws(hovercraftw_r, stdout);
fputs("\nfputws() with _setmode()\n", stdout);
_setmode(_fileno(stdout), _O_U16TEXT);
fputws(hovercraftw_j, stdout);
fputws(hovercraftw_g, stdout);
fputws(hovercraftw_r, stdout);
return 0;
}
I get the following output:
Output consistent with NectarJS when using fputs. No output for fputws. And proper output when using fputws with _setmode.
Would it be possible to add a _setnode call and fputws or switch to WriteConsoleW (as I believe NodeJS uses) for Windows unicode output?
I am unable to compile the examples provided using the --example flag
$ nectar --verbose hello.js [!] Unexpected network error
I'm getting this error when I want to compile my javascript. It happened after I added xml2js npm package
fs.js:119
throw err;
^
Error: EISDIR: illegal operation on a directory, read
at Object.readSync (fs.js:498:3)
at tryReadSync (fs.js:337:20)
at Object.readFileSync (fs.js:374:19)```
Since NectarJS is able to compile JavaScript into WebAssembly, it may be possible to compile JavaScript into C source code using a compiler like wasmdec. Does NectarJS have this feature yet?
Can we write WebGL apps with Nectar? I guess it needs JS glue with WebAssembly. Any plans?
I have two issues when compiling this with NectarJS and running it:
var x = 2147483647;
var y = 2147483648;
console.log(x);
console.log(y);
console.log(x+1);
I get the following output and a crash:
In other javascript engines
var y = 2147483648;
console.log(y);
outputs 2147483648
NectarJS, unless I'm reading this wrong, appears to store 2147483648 in a local variable as a 32 bit int (mov dword [rsp + 0x80], 0x80000000)
then outputs it later with fprintf using %ld.
When I compile this with MinGW:
#include <stdio.h>
int main () {
int y = 2147483648;
fprintf(stdout,"%ld\n%lu\n", y, y);
return 0;
}
2147483648 is stored the same way (mov dword [local_4h], 0x80000000).
%ld has the same output as NectarJS, and %lu has the expected output.
Is this a matter of NectarJS incorrectly choosing %ld for fprintf in this case, or a big number support problem in general?
The crash is caused here (remember 2147483647 is sitting in local variable rsp + 0x60):
It looks like strlen is called on 2147483647 (0x7fffffff) and somehow results in strlen treating 0x7fffffff as an address. I don't understand why this happens yet, and I have not reproduced it in c or assembly so far. Bug?
NectarJS Client v0.0.46
Win8.1x64
node v8.9.0
nectar --example
Fails with error:
fs.js:646
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open 'D:\My\Dev\nectarjs-playground\example\arduino.js'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.writeFileSync (fs.js:1291:33)
at copyExample (C:\Users\Roman\AppData\Roaming\npm\node_modules\nectarjs\nectar.js:257:8)
at Object.<anonymous> (C:\Users\Roman\AppData\Roaming\npm\node_modules\nectarjs\nectar.js:86:5)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
It's just not working for me on Ubuntu (14.04.3 LTS). I'm getting this error when trying to run/build string.js
that is generated by nectar --example
$ nectar string.js
internal/buffer.js:35
throw new ERR_OUT_OF_RANGE('value', `>= ${min} and <= ${max}`, value);
^
RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= -2147483648 and <= 2147483647. Received 3653141014
at checkInt (internal/buffer.js:35:11)
at writeU_Int32LE (internal/buffer.js:515:3)
at Buffer.writeInt32LE (internal/buffer.js:684:10)
at Object.entryHeaderToBinary (/usr/local/lib/node_modules/nectarjs/extern/adm-zip/headers/entryHeader.js:216:18)
at Object.packHeader (/usr/local/lib/node_modules/nectarjs/extern/adm-zip/zipEntry.js:260:39)
at /usr/local/lib/node_modules/nectarjs/extern/adm-zip/zipFile.js:198:41
at Array.forEach (<anonymous>)
at Object.compressToBuffer (/usr/local/lib/node_modules/nectarjs/extern/adm-zip/zipFile.js:182:23)
at Object.toBuffer (/usr/local/lib/node_modules/nectarjs/extern/adm-zip/adm-zip.js:488:25)
at /usr/local/lib/node_modules/nectarjs/nectar.js:488:45
Is it possible to compile a C library (a .a for example)?
The idea would be to replace duktape for calling a javascript function from another language.
When I run broken JS code, I just get Compilation error
and that's it.
Good to know:
In order to avoid constant complaints about implementations not yet supported, it would be important to create a compatibility table, such as ECMAscript (link below), placed prominently in the product documentation.
When I compile something like this with target win-x86-64:
function fibonacci(n)
{
if (n < 2) return n;
return fibonacci(n - 2) + fibonacci(n - 1);
}
console.log("The number is " + fibonacci(50));
The compiler outputs an executable which appears to call msvcrt function
puts("Not implemented Yet");
and exits, without doing any work.
Would it make more sense for this to be a compiler error instead? Down the road it might be better for automated builds to fail rather than successfully produce executatables with unexpected behavior when a project pulls in code using unsupported language features. Tests could be built by developers to catch this situation, but things could get cumbersome very quickly.
NectarJS Client v0.0.46
OS: Ubuntu Gnome 16.04
Node: v7.10.1
I try use node modules and doesn't work.
Example:
var koa = require('koa')
var app = new koa()
I just receive: Compilation error
Obs: I'm not using --single
Trying to make some tests with nectar (master branch) and all I get in any combination is "[!] Network error : socket hang up"after waiting for a minute or so.
Any help?
This code will cause to run out of memory and crashes:
for (;;)
{
var obj = { "aa":"bb" };
}
Generated C++:
for (;;)
{
// FIXME: _N_42 needs to be shared_ptr
vector<shared_ptr<pair<var, var>>> *_N_42 = new vector<shared_ptr<pair<var, var>>>();
var obj = var(OBJECT, _N_42);
__NJS_Object_Set((char*)"aa", __create_String((char *)"bb"), obj);
}
BTW, Have you considered using GC instead of shared_ptr?
The short example code snippets work fine but on longer code I get [!] Unexpected network error
. Perhaps there is a maximum length you support, or maybe the code is too complex.
Out of curiosity for whether it would work I used the Opal Ruby to JavaScript transpiler to transpile a short snippet of Ruby code which ends up being much longer JS code, but still a single ES5 file. Then I tried running that through Nectar.
nectar --target mac-osx hello.js --single
Planned not planned what is the plan on following emcascript
Hi, i have a problem when trying to compile with any libraries in node_modules:
./node_moduleutil/README.md node_modules\util\README.md ./node_moduleutil/support/isBuffer.js node_modules\util\support\isBuffer.js ./node_moduleutil/support/isBufferBrowser.js node_modules\util\support\isBufferBrowser.js ./node_moduleutil/util.js node_modules\util\util.js ./node_module node_modules\ fs.js:115 throw err; ^ Error: EISDIR: illegal operation on a directory, read at Object.readSync (fs.js:494:3) at tryReadSync (fs.js:333:20) at Object.readFileSync (fs.js:370:19) at C:\Users\sergei.dudko\AppData\Roaming\npm\node_modules\nectarjs\extern\adm-zip\adm-zip.js:276:38 at Array.forEach () at Object.addLocalFolder (C:\Users\sergei.dudko\AppData\Roaming\npm\node_modules\nectarjs\extern\adm-zip\adm-zip.js:269:12) at C:\Users\sergei.dudko\AppData\Roaming\npm\node_modules\nectarjs\nectar.js:499:17 at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] build: `nectar --target win-x86-64 -o ./iRetailUpdater.exe ./index.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\sergei.dudko\AppData\Roaming\npm-cache\_logs\2019-08-13T16_06_16_216Z-debug.log
As far as I see the problem with the script nectarjs\extern\adm-zip\adm-zip.js in part:
if (filter(p)) { if (p.charAt(p.length - 1) !== "/") { console.log(zipPath + p) console.log(path) console.log() self.addFile(zipPath + p, fs.readFileSync(path), "", 0) } else { self.addFile(zipPath + p, Buffer.alloc(0), "", 0) } }
You check that p is not a directory if (p.charAt(p.length - 1) !== "/")
but use synchronous read to path fs.readFileSync(path)
. I believe that this is not true. And I tried to fix it:
if (filter(p)) { if (path.charAt(path.length - 1) !== "\\") { console.log(zipPath + p) console.log(path) console.log() self.addFile(zipPath + p, fs.readFileSync(path), "", 0) } else { self.addFile(zipPath + p, Buffer.alloc(0), "", 0) } }
Now i get another error:
./node_moduleutil/util.js node_modules\util\util.js ./package-lock.json package-lock.json ./package.json package.json ./project.json project.json [!] Signature error. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] build: `nectar --target win-x86-64 -o ./iRetailUpdater.exe ./index.js` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\sergei.dudko\AppData\Roaming\npm-cache\_logs\2019-08-13T16_14_11_071Z-debug.log
Windows 7 64bit
C:\nectar_test>node --version
v10.15.0
C:\nectar_test>npm --version
6.10.3
No dependencies in node_modules compilation succeeds
can typescript -> wasm ?
When I try to compile my project, I receive the message
Expression : >>> - Not Implemented Yet in BinaryExpression
This is necessary for basically all uses I have for this, hopefully it can be implemented soon, or if someone could present a workaround to me that would be great. Until then, I'll be looking on my own for a workaround. Thanks!
Also what's the reason for not doing an open source model like Qt? (they seem to be successful with their commercial licenses)
C:\Users\PC\Documents\dev code\Editor\sc>nectar test.js
fs.js:675
return binding.read(fd, buffer, offset, length, position);
^
Error: EISDIR: illegal operation on a directory, read
at Object.fs.readSync (fs.js:675:18)
at tryReadSync (fs.js:540:20)
at Object.fs.readFileSync (fs.js:583:19)
at C:\Users\PC\AppData\Roaming\npm\node_modules\nectarjs\extern\adm-zip\adm-zip.js:273:38
at Array.forEach ()
at Object.addLocalFolder (C:\Users\PC\AppData\Roaming\npm\node_modules\nectarjs\extern\adm-zip\adm-zip.js:269:12)
at C:\Users\PC\AppData\Roaming\npm\node_modules\nectarjs\nectar.js:499:17
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
C:\Users\PC\Documents\dev code\Editor\sc>nectar test.js
fs.js:675
return binding.read(fd, buffer, offset, length, position);
^
Error: EISDIR: illegal operation on a directory, read
at Object.fs.readSync (fs.js:675:18)
at tryReadSync (fs.js:540:20)
at Object.fs.readFileSync (fs.js:583:19)
at C:\Users\PC\AppData\Roaming\npm\node_modules\nectarjs\extern\adm-zip\adm-zip.js:273:38
at Array.forEach ()
at Object.addLocalFolder (C:\Users\PC\AppData\Roaming\npm\node_modules\nectarjs\extern\adm-zip\adm-zip.js:269:12)
at C:\Users\PC\AppData\Roaming\npm\node_modules\nectarjs\nectar.js:499:17
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
C:\Users\PC\Documents\dev code\Editor\sc>nectar test.js
fs.js:675
return binding.read(fd, buffer, offset, length, position);
^
I got this error
Error: EISDIR: illegal operation on a directory, read
at Object.fs.readSync (fs.js:675:18)
at tryReadSync (fs.js:540:20)
at Object.fs.readFileSync (fs.js:583:19)
at C:\Users\PC\AppData\Roaming\npm\node_modules\nectarjs\extern\adm-zip\adm-zip.js:273:38
at Array.forEach ()
at Object.addLocalFolder (C:\Users\PC\AppData\Roaming\npm\node_modules\nectarjs\extern\adm-zip\adm-zip.js:269:12)
at C:\Users\PC\AppData\Roaming\npm\node_modules\nectarjs\nectar.js:499:17
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
Other projects that compile JavaScript (or JavaScript-like languages such as TypeScript) require the addition of types to your code in order to allow compilation.
Does NectarJS have the same requirement?
Or do you somehow infer types through static analysis?
The command "nectar project.json" generates the error "Bad Target". I read your code and found out that this happens only in computers with arch other than the few specified in your code. For example, my pc has ARCH 'ia32' which you haven't specified in your code.
Also, if the code is not automatically able to find a target, it generates the above error (without even checking if the target in specified in project.json or not.). It should first check for target in project.json and then generate error if it is not there.
In the future will it be possible to compile either locally or on vps of some sort.
my email is [email protected]
I tried running the compiled code from https://nectar-lang.com/ on my macOS Mojave 10.14.4 , It shows this error
exec format error: ./result-mac-osx.bin
A Python file with an import statement errors out due to a compilation failure.
You should look into this.
Miraclx.
I found I can not new Date()
I have begun to play around with local compiling and want to begin constructing examples and the errors they result in if they do not succeed. Here is my first try:
The executed commands are:
cd node_modules/nectarjs
./nectarjs --compiler g++ ../../src/index.js
I tried again by removing the arrow functions and using function syntax and the error persisted in the same form.
(Different points in GIT history)
This is my JS file, which results in "Unexpected Compilation Error":
function json_parse(json)
{
return JSON.parse(json);
}
console.log(json_parse("{}"));
The only difference between this and a version that compiles is the introduction of the JSON
object. Isn't that a built-in javascript object? Should this be expected to work?
I would like to try nectarjs but I am unable to get a key.
Side question: why the key ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.