just-js / just Goto Github PK
View Code? Open in Web Editor NEWthe only javascript runtime to hit no.1 on techempower :fire:
Home Page: https://just.billywhizz.io/
License: MIT License
the only javascript runtime to hit no.1 on techempower :fire:
Home Page: https://just.billywhizz.io/
License: MIT License
Hi @billywhizz
I've been messing with the http example to build a sort of runtime web/http server library around Just, but there's this thing happening where only the first request (since server startup) doesn't seem to make it to the onConnect handler... It's not such a huge issue since all subsequent requests seem to work fine, but it seems odd, and wanted to mention it:
In the http example we have:
function onConnect(sock) {
const self = this;
stats.conn++;
const stream = createHTTPStream(sock.buf, maxPipeline);
const { buf, size } = responses[200];
sock.onReadable = () => {
const bytes = sock.pull(stream.offset);
if (bytes <= 0)
return;
let headers = stream.getHeaders().split('\n');
let pathParts = headers[0].split(' ');
print("Method: " + pathParts[0] + ", url: " + pathParts[1]);
const err = stream.parse(bytes, count => {
qps += count;
stats.rps += bytes;
if (sock.write(buf, count * size) <= 0)
return;
stats.wps += (count * size);
})
if (err < 0) print(`error: ${err}`) // Todo: handle app error
}
sock.onWritable = () => {}
sock.onEnd = () => stats.conn--;
return this;
}
function start() {
print("Starting server...");
createServer(onConnect).listen();
return this;
}
You can see I added a print() statement in onConnect.
When I hit any url (ie. http://localhost:3000/test).. two requests are sent from the browser. One is for the favicon, and the other for the url endpoints (/test). The onConnect print statement only sees the favicon request, but not /test. Only when I try a second request (and subsequent) will it show that /test is being reached.
I'm not entirely sure why, maybe it's to do with the socket initialization on first run, or the way createServer is initialized... but it's only happening on the very first request.
If you might have any ideas, let me know, but I'll dig in a little.
This documentation is licensed under the Unlicense while parts of JustJS are other Licensed this Documentation can be seen as copyed from @stealify on github i write it here first because i will not have public useable build infrastructure soon as JustJS is so simple and well designed that i can translate this doc's later back to my Project 1:1 as both are v8 core Related.
JustJS started out as a build Framework for v8 written in c++ so something like a v8 embedder kit.
This allowed fast incremental iteration on some of the core concepts of ECMAScript and the v8 Engine it self.
the documentation is here: https://v8.dev/docs/embed
This is using the above described concepts mostly the Template Functions to expose C++ Code with js Code directly consistent compose able in v8
The raw speed of this implementation comes from the fact that it is having less roundtrips between different layers of the stack for example it uses kernel epoll as a loop implementation as the ECMAScript engine in this case v8 got no own loop by default a ECMAScript or JS gets executed Serial one pass by the engine it self without additional tooling. The ECMAScript Standard can be understood as the Definition of 2 Indipenedent parts and its Interfaces. The First part is the Engine and the Secund the Engine Embedder. JustJS Core is v8 without a embedder. JustJS is in first place not a JS Runtime (Embedder) it is a Runtime c++ API that allows it to use any C++ code to be directly fast build in via common interface methods that get normal used by Runtimes.
To build a Component for v8 or JustJS and it's smol Runtime implementation you need to understand how v8 works at the core.
v8 is a c++ written ECMAScript and WASM Runtime. It Implements buildIns (thats what you or i would call modules components)
but the name buildIn referes most best to the internal detail that it is something that is already Build and linked or at last dynamic link able inside the Engine it self. In General JustJS is a simple c++ Project Establishing some Build Conventions to keep it simple to build such BuildIns with a c++ API.
So in JustJS every Component consists of 2 files as of current time of writing this as this will maybe change with a new experimental component system soon.
.so file or dynlib or dll a so called Dynamic Lib its a C/C++ Representation of a Module it is binary to compile something for JustJS you should always do Debug builds as we plan to integrate that debug result later with v8 it helps to produces more optimized v8 builds if our source already offers us additional information.
.h file also often referenced by the name header or headers it is a text file containing c/c++ related API information
.js file containing ECMAScript Syntax Importent here at present is Script Syntax. Why is that importent? Most of you who read this do come from a browser background so your familar with some implementations already and your aware of something that is also in the ECMAScript standard tc39 it is called import() but you need to understand now the details!
Import is defined in the standard to get handled by the engine Embedder So as this is raw v8 it has no Embedder Runtime thats why it is so fast in this Implementation. It is similar to cloudflare workers. So Import is not something that exists inside v8!
In general it is even more importent to understand that JS while it looks like a Interpreted Language It is not really one it gets compiled like any other language into byte code to be more consistent a special format for bytecode the ECMAScript engine in this case v8 does so called multi pass compilation that means it tracks the state of compilation and has a so called compiler interface. This compiler interface allows it to later do LTO (Link time optiomization) and PGO (Profile Guided Optimization) This concepts are exact the same as with the Java Runtime for all Java Languages. but they transpile to Java Byte Code while v8 compiles to C Byte code.
TODO: Write a good example from the existing once.....
apt update && apt upgrade -y && apt install -y g++ curl make tar gzip libfindbin-libs-perl
# Contains everything to build just core
export JUST_HOME=~/just
# Contains everything to build just apps (v8 isolates with pre build builtins linked using the justjs c++ api)
export JUST_TARGET=$JUST_HOME
mkdir -p $JUST_HOME $JUST_TARGET
sh -c "$(curl -sSL https://raw.githubusercontent.com/just-js/just/current/install.sh)"
make -C just install
mkdir ~/app
create ~/app/app.js
const stringify = require('@stringify')
const html = require('@html')
const cache = require('@cache')
const dns = require('@dns')
const postgres = require('@pg')
const http = require('@http')
const socket = require('@socket')
// Some Common examples.
const { getIPAddress } = dns;
const { createSocket } = socket;
const { createServer, responses } = http;
const { SimpleCache } = cache;
just build --clean --cleanall --static app.js
It does have no need to enter a user interrupted event loop it is linear memory that uses directly kernel epoll as event system. So it is fast because it is not waisting time with evaluation it is AOT Compiled libuv is what nodejs uses and tokio is what deno uses as event loop es4x uses vertx as event loop and so on.
I'm going to create this issue and leave it open so i can post some updates on various documentation, demo and example work i have been doing and for any Q&A around that.
There seems to have been some interest in the project recently which I am encouraged by. I have questioned my sanity a few times on this little journey so it's nice to see that either i am not insane or at least there are some other equally insane folks who think doing this in JS is a good idea.
If anyone has any suggestions for demos, useful docs and examples please post them here. Also, if you have any suggestions for where best to discuss this that would suit everyone let me know. There are so many options these days it's hard to know the best forum. I set up a gitter community a while back which is one option. Maybe a google group would be best? It's a pity github does not have an integrated forum.
For now, I am finishing up some work on a demos repo which will hopefully be a good starting point for folks new to the platorm and the idea is to walk through various features of the platform, talk about the code and do a little benchmarking and comparison along the way. I'll have chapters 01-04 finished over next day or so.
For a few people who have been asking about a nice http api i have had some success with a little experiment here. It has a similar api to express/fastify etc. and the performance numbers are looking very good and on a par with the hideous and unmaintainable code in the techempower repo which i stopped working on once i saw the numbers i liked.
@whyCPPgofast @hiqsociety @pranaypratyush @kizerkizer @vaaas @episage @rw3iss @ChrisGitIt @hc-codersatlas @antonkatz @IvanTurgenev @MarshalOfficial @amoorahmat. apologies for pinging you but you are the folks who have been involved in various discussions so far. if that is not cool let me know.
I think your GitHub bot drank too much caffeine; no changes from v01.2 to v0.1.3, but it was released as a new version anyway.
I managed to get the makefiles working properly on MacOS 12.6, but the build process fails with the following linker errors.
/Applications/Xcode.app/Contents/Developer/usr/bin/make MODULE=vm module-static
CFLAGS="" LFLAGS="" JUST_HOME="/Users/renemuala/Documents/playground/just-js/just" /Applications/Xcode.app/Contents/Developer/usr/bin/make -C modules/vm/ FLAGS=-DSTATIC library
g++ -DSTATIC -c -fno-exceptions -ffunction-sections -fdata-sections -fPIC -std=c++17 -DV8_COMPRESS_POINTERS -I/Users/renemuala/Documents/playground/just-js/just -I/Users/renemuala/Documents/playground/just-js/just/deps/v8/include -g -O3 -march=native -mtune=native -Wall -Wextra -flto -Wno-unused-parameter vm.cc
g++ -g -shared -flto -pthread -m64 vm.o -Wl,-install_name,vm.so -Wl,-dead_strip -o vm.so
Undefined symbols for architecture x86_64:
"v8::HandleScope::CreateHandle(v8::internal::Isolate*, unsigned long)", referenced from:
just::vm::EnterContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::ExitContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::HandleScope::HandleScope(v8::Isolate*)", referenced from:
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::HandleScope::~HandleScope()", referenced from:
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::api_internal::ToLocalEmpty()", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::api_internal::DisposeGlobal(unsigned long*)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::api_internal::FromJustIsNothing()", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::api_internal::GlobalizeReference(v8::internal::Isolate*, unsigned long*)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::api_internal::CopyGlobalReference(unsigned long*)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::ObjectTemplate::SetInternalFieldCount(int)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::ObjectTemplate::New(v8::Isolate*, v8::Local<v8::FunctionTemplate>)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::Init(v8::Isolate*, v8::Local<v8::ObjectTemplate>) in lto.o
"v8::PrimitiveArray::New(v8::Isolate*, int)", referenced from:
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::PrimitiveArray::Set(v8::Isolate*, int, v8::Local<v8::Primitive>)", referenced from:
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::ScriptCompiler::CachedData::~CachedData()", referenced from:
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::ScriptCompiler::CompileModule(v8::Isolate*, v8::ScriptCompiler::Source*, v8::ScriptCompiler::CompileOptions, v8::ScriptCompiler::NoCacheReason)", referenced from:
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::ScriptCompiler::ConsumeCodeCacheTask::~ConsumeCodeCacheTask()", referenced from:
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::ScriptCompiler::CompileFunctionInContext(v8::Local<v8::Context>, v8::ScriptCompiler::Source*, unsigned long, v8::Local<v8::String>*, unsigned long, v8::Local<v8::Object>*, v8::ScriptCompiler::CompileOptions, v8::ScriptCompiler::NoCacheReason, v8::Local<v8::ScriptOrModule>*)", referenced from:
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::ScriptCompiler::Compile(v8::Local<v8::Context>, v8::ScriptCompiler::Source*, v8::ScriptCompiler::CompileOptions, v8::ScriptCompiler::NoCacheReason)", referenced from:
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Module::InstantiateModule(v8::Local<v8::Context>, v8::MaybeLocal<v8::Module> (*)(v8::Local<v8::Context>, v8::Local<v8::String>, v8::Local<v8::FixedArray>, v8::Local<v8::Module>))", referenced from:
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Module::Evaluate(v8::Local<v8::Context>)", referenced from:
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Number::New(v8::Isolate*, double)", referenced from:
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Object::SetAlignedPointerInInternalField(int, void*)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Object::SlowGetAlignedPointerFromInternalField(int)", referenced from:
just::vm::EnterContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::ExitContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Object::Get(v8::Local<v8::Context>, v8::Local<v8::Value>)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Object::Get(v8::Local<v8::Context>, unsigned int)", referenced from:
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Script::Run(v8::Local<v8::Context>)", referenced from:
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::String::NewFromUtf8Literal(v8::Isolate*, char const*, v8::NewStringType, int)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Context::AllowCodeGenerationFromStrings(bool)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Context::New(v8::Isolate*, v8::ExtensionConfiguration*, v8::MaybeLocal<v8::ObjectTemplate>, v8::MaybeLocal<v8::Value>, v8::DeserializeInternalFieldsCallback, v8::MicrotaskQueue*)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Context::Exit()", referenced from:
just::vm::ExitContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Context::Enter()", referenced from:
just::vm::EnterContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Context::Global()", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Isolate::GetCurrentContext()", referenced from:
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Isolate::SetPromiseRejectCallback(void (*)(v8::PromiseRejectMessage))", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Isolate::GetEnteredOrMicrotaskContext()", referenced from:
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Template::Set(v8::Local<v8::Name>, v8::Local<v8::Data>, v8::PropertyAttribute)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::TryCatch::ReThrow()", referenced from:
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::TryCatch::TryCatch(v8::Isolate*)", referenced from:
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::TryCatch::~TryCatch()", referenced from:
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"just::SET_METHOD(v8::Isolate*, v8::Local<v8::ObjectTemplate>, char const*, void (*)(v8::FunctionCallbackInfo<v8::Value> const&))", referenced from:
just::vm::Init(v8::Isolate*, v8::Local<v8::ObjectTemplate>) in lto.o
"just::SET_MODULE(v8::Isolate*, v8::Local<v8::ObjectTemplate>, char const*, v8::Local<v8::ObjectTemplate>)", referenced from:
just::vm::Init(v8::Isolate*, v8::Local<v8::ObjectTemplate>) in lto.o
"just::OnModuleInstantiate(v8::Local<v8::Context>, v8::Local<v8::String>, v8::Local<v8::FixedArray>, v8::Local<v8::Module>)", referenced from:
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"just::PromiseRejectCallback(v8::PromiseRejectMessage)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"just::Init(v8::Isolate*, v8::Local<v8::ObjectTemplate>)", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::ScriptOrigin::VerifyHostDefinedOptions() const", referenced from:
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Array::Length() const", referenced from:
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::Value::BooleanValue(v8::Isolate*) const", referenced from:
just::vm::CreateContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::TryCatch::HasTerminated() const", referenced from:
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
"v8::TryCatch::HasCaught() const", referenced from:
just::vm::CompileInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileAndRunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunInContext(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::CompileScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunScript(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
just::vm::RunModule(v8::FunctionCallbackInfo<v8::Value> const&) in lto.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [library] Error 1
make[1]: *** [module-static] Error 2
make: *** [module-static-vm] Error 2
i tried to replace the libv8 file in deps by a macos version, but the build stills failing.
Where can one find the information on the V8 version used? Need it to know which ES version (or features) it supports.
Hi!
I'm on ubuntu and trying to get the example in VSCode.md to run but can't. Just following the instructions i still get TypeError: Cannot read property 'fib' of undefined
. I'm I missing somthing?
Or the http server example with the following:
make runtime
sudo make install
make MODULE=http module
sudo make -C modules/http install
make examples
cd examples/http
just server.js
same there TypeError: Cannot destructure property 'http' of 'just.library(...)' as it is undefined.
in just/readme.md
export JUST_HOME=$(pwd)/just
export JUST_TARGET=$JUST_HOME
is it recommended to just stick these in a startup file?
When I run this command (from the README):
sh -c "$(curl -sSL https://raw.githubusercontent.com/just-js/just/0.1.1/install.sh)"
It returns this error after:
sh: 4: cd: can't cd to just-0.1.1
sh: 5: make: not found
The folder the script created is called just-0.1.0
I'd be keen to start contributing to this project, but apparently no PRs have been approved/merged so far. Just wondering if PRs are welcome at all?
Can you post a roadmap or create tasks so people can contribute to this project?
Thanks
Hi
I tried to work out "hello World" example using the latest techempower code and there are some parts that I am unable to understand.
My code is;
const stringify = require('@stringify')
const http = require('@http')
const process = require('process')
const { createServer, responses } = http
const { sjs, attr } = stringify
const message = 'Hello, World!'
const json = { message }
function spawn (main) {
if (just.env()['WORKER']) return main()
const { watch, launch } = process
const processes = []
const cpus = parseInt(just.env().CPUS || just.sys.cpus, 10)
for (let i = 0; i < cpus; i++) {
just.sys.setenv('WORKER', i)
//const proc = launch(just.args[0], ['--trace-gc', ...just.args.slice(1)])
const proc = launch(just.args[0], just.args.slice(1))
processes.push(proc)
proc.stats = { user: 0, system: 0 }
}
return Promise.all(processes.map(p => watch(p)))
}
class Clock {
constructor () {
this.slots = new Map()
}
unset (callback, repeat = 1000) {
const current = this.slots.get(repeat)
if (!current) return
current.callbacks = current.callbacks.filter(cb => cb !== callback)
if (!current.callbacks.length) {
just.clearTimeout(current.timer)
this.slots.delete(repeat)
}
}
set (callback, repeat = 1000) {
let current = this.slots.get(repeat)
if (current) {
current.callbacks.push(callback)
return
}
current = {
callbacks: [callback],
timer: just.setInterval(() => current.callbacks.forEach(cb => cb()), repeat)
}
this.slots.set(repeat, current)
}
}
async function main() {
const sJSON = sjs({ message: attr('string') })
const server = createServer()
.get('/plaintext', res => res.text(message))
.get('/json', res => res.utf8(sJSON(json), responses.json))
.listen('0.0.0.0', 8080)
const clock = new Clock()
clock.set(() => {
server.update()
})
}
spawn(main)
.catch(err => just.error(err.stack))
This is working for me.
But I am unable to understand the Clock class. what does it do ? What does server.update do?
Regarding spawn, I understand that each process carries the entire app (main function) in memory. every request to the server gets 1 process assigned, and every 'tick" the server processes the processes in the processes list. Is that understanding correct?
Also, I hope I don't come across as entitled, but some basic starter documentation would be great to have. The examples seem to be very out of date, and working out a simple program is quite difficult. Maybe just this Hello World sample, with good comments can be added to the main readme and act as a great starting point for new users.
Hi,
It might be a very dumb question, but as MacOS and Linux has quite a lot of similarities, I wanted to know if Just-JS was running on MacOS?
Thanks!
Wanted to test http with ab.
ab -n 1 -c 1 http://localhost:8080/plaintext
using this :
const stringify = require('@stringify')
const http = require('@http')
const process = require('process')
const { createServer, responses } = http
const { sjs, attr } = stringify
const message = 'Hello, World!'
const json = { message }
function spawn (main) {
if (just.env()['WORKER']) return main()
const { watch, launch } = process
const processes = []
const cpus = parseInt(just.env().CPUS || just.sys.cpus, 10)
for (let i = 0; i < cpus; i++) {
just.sys.setenv('WORKER', i)
//const proc = launch(just.args[0], ['--trace-gc', ...just.args.slice(1)])
const proc = launch(just.args[0], just.args.slice(1))
processes.push(proc)
proc.stats = { user: 0, system: 0 }
}
return Promise.all(processes.map(p => watch(p)))
}
class Clock {
constructor () {
this.slots = new Map()
}
unset (callback, repeat = 1000) {
const current = this.slots.get(repeat)
if (!current) return
current.callbacks = current.callbacks.filter(cb => cb !== callback)
if (!current.callbacks.length) {
just.clearTimeout(current.timer)
this.slots.delete(repeat)
}
}
set (callback, repeat = 1000) {
let current = this.slots.get(repeat)
if (current) {
current.callbacks.push(callback)
return
}
current = {
callbacks: [callback],
timer: just.setInterval(() => current.callbacks.forEach(cb => cb()), repeat)
}
this.slots.set(repeat, current)
}
}
async function main() {
const sJSON = sjs({ message: attr('string') })
const server = createServer()
.get('/plaintext', res => res.text(message))
.get('/json', res => res.utf8(sJSON(json), responses.json))
.listen('0.0.0.0', 8080)
const clock = new Clock()
clock.set(() => {
server.update()
})
}
spawn(main)
.catch(err => just.error(err.stack))
Seems like just-js has been inactively maintained since Sept 2022. Is it deprecated?
First of all, very impressive results for javascript on techempower benchmark.
Questions:
What kind of application is suitable for development on just-js? It tried to avoid allocation on heap? So how large an app can it be for performance to look "normal" for a js project?
From my limited understanding of js / v8, basically this is using the underlying v8 to achieve performance, so is there a possibility to use DPDK / NIF kind of stuff to get more performance out of this?
Can you mention the limitations of just-js? As in what function / features are not available and maybe some real world application suitability for development like a todo app or simple pwa kind of app on this?
If such performance is possible, I'm actually thinking of replacing luajit with just-js. Not sure if you think it's a good idea.
env
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 21.04
Release: 21.04
Codename: hirsute
when following the setup in just/readme.md
the cmd make -C just install
fails
make: Entering directory '/home/poop/git/foss/justjs/just/just'
mkdir -p /usr/local/bin
cp -f just /usr/local/bin/just
cp: cannot remove '/usr/local/bin/just': Permission denied
make: *** [Makefile:123: install] Error 1
make: Leaving directory '/home/poop/git/foss/justjs/just/just'
but it does work with sudo...
poop@spaceship:~/git/foss/justjs/just$ sudo !!
sudo make -C just install
make: Entering directory '/home/poop/git/foss/justjs/just/just'
mkdir -p /usr/local/bin
cp -f just /usr/local/bin/just
make: Leaving directory '/home/poop/git/foss/justjs/just/just'
related
I want to supply my new book which i am writing to boot the web 4.0 which also includes just-js build instructions and the next level of just-js on the web.
it contains the raw fundamentals of software architecture and v8 combined into a understand able topic when you come from a nodejs or browser background.
hope that it makes sense and is useful it is unlicensed and i will iterate over it with examples including a html based just-js build. So you need only linux and your browser then you can install justjs on your local linux pc and even create fresh builds via the browser ui.
that is in fact one of the main goals of the book. It expands the context behind why i do not simple make it easy to deploy just js without all that information. I do so because i want to fix the web as a whole and enable you to use the Web 4.0 which in fact exists. But no one did told you that this will teach you how to use the Web 4.0 to develop software and run that with just js concepts and builds on your workers may it be a web worker or just js on a server.
Hi, so i just want to try build (just build hello.js --clean --static
) with my linux machine (ElementaryOS Hera) and got error like this:
...
deps/v8/include/v8-platform.h
deps/v8/include/v8-value-serializer-version.h
deps/v8/include/OWNERS
deps/v8/include/js_protocol.pdl
deps/v8/include/v8-wasm-trap-handler-posix.h
rm -f v8lib-0.0.22.tar.gz
g++ -c -fno-exceptions -ffunction-sections -fdata-sections -DJUST_VERSION='"0.0.22"' -std=c++17 -DV8_COMPRESS_POINTERS -I. -I./deps/v8/include -O3 -march=native -mtune=native -Wpedantic -Wall -Wextra -flto -Wno-unused-parameter just.cc
g++ -c -fno-exceptions -ffunction-sections -fdata-sections -std=c++17 -DV8_COMPRESS_POINTERS -I. -I./deps/v8/include -O3 -march=native -mtune=native -Wpedantic -Wall -Wextra -flto -Wno-unused-parameter main.cc
g++ -s -static -flto -pthread -m64 -Wl,--start-group deps/v8/libv8_monolith.a main.o just.o builtins.o modules/sys/sys.o modules/fs/fs.o modules/net/net.o modules/vm/vm.o modules/epoll/epoll.o -Wl,--end-group -Wl,--gc-sections -ldl -lrt -o hello
g++: error: modules/sys/sys.o: No such file or directory
g++: error: modules/fs/fs.o: No such file or directory
g++: error: modules/net/net.o: No such file or directory
g++: error: modules/vm/vm.o: No such file or directory
g++: error: modules/epoll/epoll.o: No such file or directory
Makefile:85: recipe for target 'main-static' failed
make: *** [main-static] Error 1
failed in 319.41 sec
I really dont have experience with c/c++ or something related but i tought the problem is some lib/package are missing & not installed on my machine. Thanks.
First of all dude... You are fucking awesome! When I saw the the techempower benches I couldn't stop giggling 😁. Its so bizarre seeing JS up there.
I know your hands are full right now and theres no docs yet...
Anyway here is what I would like to see in the future:
I've seen people asking for npm support but I believe that isn't the way to go. Just my 2 cents.
Hey @billywhizz
Great project. I stumbled here (like many others) from the results on TechEmpower. As I look at your code, I see your genius at work. The challenge for many of us is to use Just in production. I understand you are doing this for fun, but the lack of documentation in your code (in addition to API docs) makes it hard for us to contribute. For example, to use Postgres in production, we need a solid API. We also need MariaDB, Mongo etc.
My summary is that you have created an (1) opinionated framework, that (2) gets around some of V8's notorious weaknesses (threads, garbage collection etc.), using (3) optimized C-libraries when available. What you have done is ideal for web services. We get native - like performance while being coder-friendly in JS. The weakness of NodeJS is what spurred people to look at Go, Rust, drogon etc.
This is a huge deal.
I know it's not as fun as coding, but you need to empower the community to help you, otherwise this amazing project will stay stuck in your "todos".
As a community, we need:
Once you do this, this project will fly and overnight dozens of developers will be contributing amazing modules to get this project to production-quality.
Seems good? Idk.
https://github.com/bytedance/terarkdb
Looks like they just forked rocks and made it faster. Only mentioning bc i was looking at recent commits and rocks was among them. Bytedance is tiktok btw
Screenshots
Ok good news SSL lib will be BoringSSL and we got a Rust Implementation that follows the standard and is deployed in production at cloudflare
Resources
commonjs modules, no support for ES modules
What's the reason for not supporting ES modules? Have you tried to in the past?
avoid abstraction as much as possible
Would ESM count as an abstraction?
const { http } = just.library('http')
just.print("hello")
just.print(just.memoryUsage().rss)
just.print(http)
Terminal:
hello
10129408
undefined
I have created the PKGBUILD of just for Arch Linux to install just easily.
Please add how to install with PKGBUILD to README.
The link of PKGBUILD is here
root@server:~/just-js-2# uname -ar
Linux server 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux
root@server:~/just-js-2# sh -c "$(curl -sSL https://raw.githubusercontent.com/just-js/just/0.0.21/install.sh)"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 120 100 120 0 0 959 0 --:--:-- --:--:-- --:--:-- 967
100 66967 0 66967 0 0 136k 0 --:--:-- --:--:-- --:--:-- 136k
just-0.0.21/
just-0.0.21/.devcontainer/
just-0.0.21/.devcontainer/Dockerfile
just-0.0.21/.devcontainer/base.Dockerfile
just-0.0.21/.devcontainer/devcontainer.json
just-0.0.21/.devcontainer/library-scripts/
just-0.0.21/.devcontainer/library-scripts/common-debian.sh
just-0.0.21/.github/
just-0.0.21/.github/workflows/
just-0.0.21/.github/workflows/ci.yml
just-0.0.21/.gitignore
just-0.0.21/BUILD.md
just-0.0.21/LICENSE
just-0.0.21/Makefile
just-0.0.21/README.md
just-0.0.21/VSCode.md
just-0.0.21/builtins.S
just-0.0.21/config.js
just-0.0.21/config/
just-0.0.21/config/debugger.js
just-0.0.21/install.sh
just-0.0.21/just.cc
just-0.0.21/just.h
just-0.0.21/just.js
just-0.0.21/lib/
just-0.0.21/lib/acorn.js
just-0.0.21/lib/build.js
just-0.0.21/lib/configure.js
just-0.0.21/lib/freeze.js
just-0.0.21/lib/fs.js
just-0.0.21/lib/inspector.js
just-0.0.21/lib/loop.js
just-0.0.21/lib/path.js
just-0.0.21/lib/process.js
just-0.0.21/lib/repl.js
just-0.0.21/lib/websocket.js
just-0.0.21/main.cc
just-0.0.21/main.h
just-0.0.21/make.sh
just-0.0.21/scc.sh
make MODULE=net module-static
make[1]: Entering directory '/root/just-js-2/just-0.0.21'
CFLAGS="" LFLAGS="" JUST_HOME="/root/just-js-2/just-0.0.21" make -C modules/net/ FLAGS=-DSTATIC library
make[2]: Entering directory '/root/just-js-2/just-0.0.21/modules/net'
g++ -DSTATIC -c -fno-exceptions -ffunction-sections -fdata-sections -fPIC -std=c++17 -DV8_COMPRESS_POINTERS -I/root/just-js-2/just-0.0.21 -I/root/just-js-2/just-0.0.21/deps/v8/include -O3 -march=native -mtune=native -Wall -Wextra -flto -Wno-unused-parameter net.cc
g++ -s -shared -flto -pthread -m64 -Wl,--start-group net.o -Wl,--end-group -Wl,-soname=net.so -Wl,--gc-sections -o net.so
make[2]: Leaving directory '/root/just-js-2/just-0.0.21/modules/net'
make[1]: Leaving directory '/root/just-js-2/just-0.0.21'
make MODULE=sys module-static
make[1]: Entering directory '/root/just-js-2/just-0.0.21'
CFLAGS="" LFLAGS="" JUST_HOME="/root/just-js-2/just-0.0.21" make -C modules/sys/ FLAGS=-DSTATIC library
make[2]: Entering directory '/root/just-js-2/just-0.0.21/modules/sys'
g++ -c -fno-exceptions -ffunction-sections -fdata-sections -DSTATIC -fPIC -std=c++17 -DV8_COMPRESS_POINTERS -I/root/just-js-2/just-0.0.21 -I/root/just-js-2/just-0.0.21/deps/v8/include -O3 -march=native -mtune=native -Wall -Wextra -flto -Wno-unused-parameter sys.cc
sys.cc: In function ‘void just::sys::MemFdCreate(const v8::FunctionCallbackInfo<v8::Value>&)’:
sys.cc:841:77: error: ‘memfd_create’ was not declared in this scope
args.GetReturnValue().Set(Integer::New(isolate, memfd_create(*fname, flags)));
^
sys.cc: In function ‘void just::sys::Init(v8::Isolate*, v8::Local<v8::ObjectTemplate>)’:
sys.cc:957:64: error: ‘MFD_CLOEXEC’ was not declared in this scope
SET_VALUE(isolate, sys, "MFD_CLOEXEC", Integer::New(isolate, MFD_CLOEXEC));
^~~~~~~~~~~
Makefile:14: recipe for target 'library' failed
make[2]: *** [library] Error 1
make[2]: Leaving directory '/root/just-js-2/just-0.0.21/modules/sys'
Makefile:66: recipe for target 'module-static' failed
make[1]: *** [module-static] Error 2
make[1]: Leaving directory '/root/just-js-2/just-0.0.21'
Makefile:111: recipe for target 'runtime-static' failed
make: *** [runtime-static] Error 2
I was following README.md
. I don't know C but I want to test the runtime. Any clues on how to make it compile?
While analyzing just TechEmpower app I discover many clock_gettime
syscalls.
We in mormot
have the same problem some times ago, and solves it by linking with libc to use vDSO (Linux subsytem what expose some of kernel level functions to user space) - see https://github.com/synopse/mORMot/pull/281/files
Hope it helps you to improve (already amazing) TechEmpower results
Hai,
Can you help me out, how can use with Mariadb.....
This is a Tracking issue for the JustJS Implementation of the Stealify Snapshot driven Component System implemented via the b8g tooling. A WASI & WASM drop in Replacement fully Capability based and Compose able with external References support and sharedArrayBuffers ffi and dlopen everything that you expect.
Related deno/rust integration:
Related stealify snapshot tooling written in ECMAScript
The internal snapshot format which is in general a serialized hash table is use able as wasi wasm replacement
It implements a binary format that is able to handle any type so it is a better fit for backend development while it is still able to be used in browsers.
Snapshot blob layout:
// [0] number of contexts N
// [1] rehashability
// [2] checksum
// [3] (128 bytes) version string
// [4] offset to readonly
// [5] offset to context 0
// [6] offset to context 1
// ...
// ... offset to context N - 1
// ... startup snapshot data
// ... read-only snapshot data
// ... context 0 snapshot data
// ... context 1 snapshot data
Maybe a noob question but can I run any nodejs
code on just
?
can you add thread support ? this while be killer feature....
Hi!
Just yesterday I've stumbled upon this entire project. It's very cool, I must admit it got me all excited and enthusiastic 😄
To make it easier for me to understand which properties/functions are available in the just
global variable, I created a skeleton just.d.ts
. For now I'm just keeping it in the root of my playground project so VSCode can generate intellisense info from it. Maybe it could be generated when just init
is called, together with config.json
. Or just shared with the community as an optional file. I just need some help in determining any additional parameters to the functions and correct param/return types. I guess it could at least be a good starting point if nothing else :)
The main purpose is just to have the VSCode intellisense working, so any additional function descriptions etc. can also be added.
Related to #10
declare namespace just {
interface KernelVersion {
os: string;
release: string;
version: string;
}
interface Version {
just: string;
v8: string;
kernel: KernelVersion;
}
declare namespace opts {
}
declare namespace vm {
function compile(): any;
function runScript(): any;
function runInContext(): any;
function compileInContext(): any;
function compileAndRunInContext(): any;
function createContext(): any;
function enterContext(): any;
function exitContext(): any;
}
declare namespace loop {
let EPOLL_CTL_ADD: number;
let EPOLL_CTL_MOD: number;
let EPOLL_CTL_DEL: number;
let EPOLLET: number;
let EPOLLIN: number;
let EPOLLOUT: number;
let EPOLLERR: number;
let EPOLLHUP: number;
let EPOLLEXCLUSIVE: number;
let EPOLLONESHOT: number;
let EPOLL_CLOEXEC: number;
function control(): any;
function create(): any;
function wait(): any;
}
declare namespace fs {
let O_RDONLY: number;
let O_WRONLY: number;
let O_RDWR: number;
let O_CREAT: number;
let O_EXCL: number;
let O_APPEND: number;
let O_SYNC: number;
let O_TRUNC: number;
let S_IRUSR: number;
let S_IWUSR: number;
let S_IXUSR: number;
let S_IRGRP: number;
let S_IWGRP: number;
let S_IXGRP: number;
let S_IROTH: number;
let S_IWOTH: number;
let S_IXOTH: number;
let S_IRWXO: number;
let S_IRWXG: number;
let S_IRWXU: number;
let DT_BLK: number;
let DT_CHR: number;
let DT_DIR: number;
let DT_FIFO: number;
let DT_LNK: number;
let DT_REG: number;
let DT_SOCK: number;
let DT_UNKNOWN: number;
let SEEK_SET: number;
let SEEK_CUR: number;
let SEEK_END: number;
let EPERM: number;
let ENOENT: number;
let ESRCH: number;
let EINTR: number;
let EIO: number;
let ENXIO: number;
let E2BIG: number;
let ENOEXEC: number;
let EBADF: number;
let ECHILD: number;
let EAGAIN: number;
let ENOMEM: number;
let EACCES: number;
let EFAULT: number;
let ENOTBLK: number;
let EBUSY: number;
let EEXIST: number;
let EXDEV: number;
let ENODEV: number;
let ENOTDIR: number;
let EISDIR: number;
let EINVAL: number;
let ENFILE: number;
let ENOTTY: number;
let ETXTBSY: number;
let EFBIG: number;
let ENOSPC: number;
let ESPIPE: number;
let EROFS: number;
let EMLINK: number;
let EPIPE: number;
let EDOM: number;
let ERANGE: number;
let S_IFMT: number;
let S_IFSOCK: number;
let S_IFLNK: number;
let S_IFREG: number;
let S_IFBLK: number;
let S_IFDIR: number;
let S_IFCHR: number;
let S_IFIFO: number;
let UTIME_NOW: number;
let UTIME_OMIT: number;
let MS_MGC_VAL: number;
let MS_MGC_MSK: number;
function open(): any;
function unlink(): any;
function symlink(): any;
function ioctl(): any;
function rmdir(): any;
function ftruncate(): any;
function rename(): any;
function mkdir(): any;
function fstat(): any;
function lseek(): any;
function readdir(): any;
function chdir(): any;
function mount(): any;
function umount(): any;
function mknod(): any;
function mkfifo(): any;
function realpath(): any;
function chmod(): any;
function chown(): any;
function readFile(path: any, unused: any, flags: any): any;
function readFileBytes(path: any, flags: any): any;
function writeFile(path: any, buf: any, flags: any): any;
function getStats(stat: any): any;
function getStat(path: any): any;
function fileType(type: any): any;
function checkMode(val: any, mode: any): any;
function checkFlag(val: any, flag: any): any;
function readDir(path: any): any;
function copyFile(src: any, dest: any): any;
function isFile(path: any): any;
function isDir(path: any): any;
function makeNode(target: any, stype: any, smode: any, ...args: any): any;
function getModified(fd: any): any;
}
declare namespace net {
let AF_INET: number;
let AF_UNIX: number;
let AF_INET6: number;
let AF_NETLINK: number;
let AF_PACKET: number;
let AF_RDS: number;
let AF_PPPOX: number;
let AF_BLUETOOTH: number;
let AF_ALG: number;
let AF_VSOCK: number;
let AF_LLC: number;
let AF_IB: number;
let AF_MPLS: number;
let AF_CAN: number;
let ETH_P_ALL: number;
let PACKET_BROADCAST: number;
let PACKET_MULTICAST: number;
let PACKET_OTHERHOST: number;
let PACKET_OUTGOING: number;
let PACKET_HOST: number;
let PACKET_LOOPBACK: number;
let SOCK_STREAM: number;
let SOCK_DGRAM: number;
let SOCK_RAW: number;
let SOCK_SEQPACKET: number;
let SOCK_RDM: number;
let PF_PACKET: number;
let SOCK_NONBLOCK: number;
let SOCK_CLOEXEC: number;
let SOL_SOCKET: number;
let SO_ERROR: number;
let SO_REUSEADDR: number;
let SO_REUSEPORT: number;
let SO_ATTACH_FILTER: number;
let SO_INCOMING_CPU: number;
let IPPROTO_TCP: number;
let IPPROTO_UDP: number;
let IPPROTO_ICMP: number;
let IPPROTO_IGMP: number;
let IPPROTO_IPV6: number;
let IPPROTO_AH: number;
let IPPROTO_ENCAP: number;
let IPPROTO_COMP: number;
let IPPROTO_PIM: number;
let IPPROTO_SCTP: number;
let IPPROTO_UDPLITE: number;
let IPPROTO_RAW: number;
let TCP_NODELAY: number;
let SO_KEEPALIVE: number;
let SOMAXCONN: number;
let O_NONBLOCK: number;
let O_CLOEXEC: number;
let EAGAIN: number;
let EWOULDBLOCK: number;
let EINTR: number;
let SEEK_SET: number;
let SEEK_CUR: number;
let SEEK_END: number;
let SHUT_RD: number;
let SHUT_WR: number;
let SHUT_RDWR: number;
function socket(): any;
function setsockopt(): any;
function getsockopt(): any;
function listen(): any;
function connect(): any;
function socketpair(): any;
function pipe(): any;
function bind(): any;
function bindInterface(): any;
function getMacAddress(): any;
function accept(): any;
function accept4(): any;
function read(): any;
function dup(): any;
function seek(): any;
function recv(): any;
function write(): any;
function splice(): any;
function sendfile(): any;
function writeString(): any;
function send(): any;
function sendString(): any;
function close(): any;
function shutdown(): any;
function getsockname(): any;
function getpeername(): any;
function setNonBlocking(fd: any): any;
}
declare namespace sys {
let CLOCK_MONOTONIC: number;
let TFD_NONBLOCK: number;
let TFD_CLOEXEC: number;
let FD_CLOEXEC: number;
let O_CLOEXEC: number;
let F_GETFL: number;
let F_SETFL: number;
let F_GETFD: number;
let F_SETFD: number;
let STDIN_FILENO: number;
let STDOUT_FILENO: number;
let STDERR_FILENO: number;
let PROT_READ: number;
let PROT_WRITE: number;
let MAP_SHARED: number;
let MAP_ANONYMOUS: number;
let RB_AUTOBOOT: number;
let RB_HALT_SYSTEM: number;
let RB_POWER_OFF: number;
let RB_SW_SUSPEND: number;
let TIOCNOTTY: number;
let TIOCSCTTY: number;
let WNOHANG: number;
let WUNTRACED: number;
let WCONTINUED: number;
let RUSAGE_SELF: number;
let RUSAGE_THREAD: number;
let BYTE_ORDER: number;
let LITTLE_ENDIAN: number;
let BIG_ENDIAN: number;
let cpus: number;
let physicalPages: number;
let pageSize: number;
function getuid(): any;
function setuid(): any;
function getgid(): any;
function setgid(): any;
function calloc(): any;
function setTerminalFlags(): any;
function getTerminalFlags(): any;
function shmopen(): any;
function shmunlink(): any;
function fexecve(): any;
function readString(): any;
function writeString(): any;
function writeCString(): any;
function getAddress(): any;
function fcntl(): any;
function memcpy(): any;
function sleep(): any;
function utf8Length(): any;
function readMemory(): any;
function writePointer(): any;
function bufferInfo(): any;
function timer(): any;
function heapUsage(): any;
function sharedMemoryUsage(): any;
function heapObjectStatistics(): any;
function heapCodeStatistics(): any;
function memfdCreate(): any;
function pid(): any;
function ppid(): any;
function setpgid(): any;
function getpgrp(): any;
function tid(): any;
function fork(): any;
function exec(): any;
function getsid(): any;
function setsid(): any;
function errno(): any;
function getchar(): any;
function putchar(): any;
function strerror(): any;
function cpuUsage(): any;
function getrUsage(): any;
function hrtime(): any;
function cwd(): any;
function env(): any;
function ioctl(): any;
function spawn(): any;
function waitpid(): any;
function runMicroTasks(): any;
function nextTick(): any;
function exit(): any;
function kill(): any;
function usleep(): any;
function pages(): any;
function nanosleep(): any;
function mmap(): any;
function munmap(): any;
function reboot(): any;
function getenv(): any;
function setenv(): any;
function unsetenv(): any;
}
declare namespace path {
function join(...args: any): any;
function baseName(path: any): any;
function normalize(path: any): any;
function fileName(path: any): any;
function extName(path: any): any;
}
declare namespace factory {
interface LoopEntry {
fd: number;
poll: (timeout: any, sigmask: any) => any;
add: (fd: any, callback: any, events: any) => any;
remove: (fd: any) => any;
update: (fd: any, events: any) => any;
handles: any;
count: number;
}
let loops: Array<LoopEntry>;
let paused: boolean;
function create(nevents: any): any;
function run(ms: any): any;
function stop(): any;
function shutdown(): any;
}
declare namespace process {
function launch(program: any, args: any, workDir: any): any;
function watch(p: any): any;
}
let version: Version;
let args: Array<string>;
function print(string: string): void;
function error(message: string): void;
function load(): any;
function exit(): any;
function pid(): any;
function chdir(): any;
function sleep(): any;
function builtin(): any;
function memoryUsage(): any;
function env(): any;
function SystemError(syscall: any): any;
function setTimeout(callback: any, timeout: any, repeat: any, loop: any): any;
function setInterval(callback: any, timeout: any, loop: any): any;
function clearInterval(fd: any, loop: any): any;
function clearTimeout(fd: any, loop: any): any;
function library(name: any, path: any): any;
function requireNative(path: any): any;
function require(path: any, parent: any): any;
function cpuUsage(): any;
function rUsage(): any;
function heapUsage(): any;
}
Should this be a valid JS code? I got an error:
EvalError: Code generation from strings disallowed for this context
at new Function ()
at objectConverter
// whole source code from d3/d3-dsv, i was trying to port the lib
// part of code:
while ((t = token()) !== EOF) {
var row = [];
while (t !== EOL && t !== EOF) row.push(t), t = token();
if (f && (row = f(row, n++)) == null) continue; // error here
rows.push(row);
}
/mnt/d/Just$ sh -c "$(curl -sSL https://raw.githubusercontent.com/just-js/just/0.0.22/install.sh)"
curl: (60) SSL certificate problem: self signed certificate in certificate chain
More details here: https://curl.haxx.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
sh -c "$(curl -sSL https://raw.githubusercontent.com/just-js/just/0.0.22/install.sh)"
Thanks upfront for any help on this issue.
Steps to reproduce
echo "just.print('hello')" > bench-parse.js
just build bench-parse.js --clean --static
result
clean bench-parse rm -f *.o
rm -f bench-parse
complete in 0.01 sec
build bench-parse 0.0.21 (just.js) gcc builtins.S -c -o builtins.o
builtins.S: Assembler messages:
builtins.S:81: Error: junk at end of line, first unrecognised character is `-'
builtins.S:82: Error: no such instruction: `_binary_bench-parse_js_start:'
builtins.S:84: Error: junk at end of line, first unrecognised character is `-'
builtins.S:85: Error: no such instruction: `_binary_bench-parse_js_end:'
Makefile:72: recipe for target 'builtins.o' failed
make: *** [builtins.o] Error 1
failed in 0.03 sec
TypeError: Cannot destructure property 'http' of 'just.library(...)' as it is undefined. in /root/just/examples/test.js on line 3
OS: Ubuntu 20.04.2 LTS 64-bit
My steps.
step 1:
git clone [email protected]:just-js/just.git
step 2:
make runtime-static
sudo make install
step 3:
make MODULE=http module
sudo make -C modules/http install
(/usr/local/lib/just directory has http.so)
step 4:
make examples
step 5:
cd examples
touch test.js
vi test.js
const { http } = just.library('http', 'http.so')
or
const { http } = just.library('http', '../modules/http/http.so')
or
const { http } = just.library('http', '/usr/local/lib/just/http.so')
step 6:
just test.js
Hey,
can you please make example with secured websocket ?
something like in node/ws examples
const https = require('https');
const WebSocket = require('ws');
const server = https.createServer({
cert: fs.readFileSync('/path/to/cert.pem'),
key: fs.readFileSync('/path/to/key.pem')
});
const wss = new WebSocket.Server({ server });
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
ws.send('something');
});
server.listen(8080);
just init hello
cd hello
just build
time ./hello
output: undefined
version used: 0.0.22
Your work is just immensely cool, Mr Whizz.
I am testing it myself with the intention of using it on my company in a quite critical part of our infrastructure (yeah, I like risks) and I am looking forward to even contribute myself with your project's codebase. The way you put it together fired up my passion for state-of-art coding! Please, let me know if I can also contribute financially with the project. I not only wish you to keep this project alive but also to hone it from inside out and backwards, for years to come! Count on me.
I found this C++ lib: https://github.com/rsta2/circle
But I don't know C, wondering if someone else is trying to get it working via that route?
At Present this projects offers single binary builds to executeable
how ever we could merge the abondoned runtime-js project which is a minimal c++ kernel to boot v8 this gives us just-js as unikernel
so we can directly deploy it without needing a additional OS
it is not much code and it is inside the philosophie of this project to be educational
algin with new node import require flags and also same behavior so we do not freeze the intrinsics the context. a bit like the smol runtime:
because it makes thinking more simple overall i want to make the web now more simple and not easy to use.
justjs --import @rollup/loader --import ./rollup.config.js myscript.js
--import[] --require[] and handle import sync via worker atomics keep the worker and expose that shared.
I'm diving into Just(JS) and it's getting better every day. I'm developing a pure JS database and now i'm decided to do it in Just.
Is it possible to use external C/C++ modules with Just, without much friction?
I would like to use faster libraries for my database internals (like in-memory data structures, including binary-trees).
Hi and applause for your current up & running project!
I'm also very performance minded and would like to see it running on BSD Systems (especially FreeBSD).
Unfortunately I'm not much into C/C++ and the whole "build process" in general. But for what I have seen in the makefiles, it should not be hard to make it work under BSD Systems.
So are you currently aware of any "Linux specific" stuff that would make it hard to port to a BSD System (like kevent on BSD vs epoll on Linux (not sure if a comparison is correct here ... just read that event handling is different on the systems))? Or is your licensing forbidding porting to BSD?
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.