Skip to content

A runtime for writing reliable asynchronous applications with C++. Provides I/O, networking, scheduling, timers, ...

License

Notifications You must be signed in to change notification settings

NodeppOfficial/nodepp-wasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Nodepp-WASM

The DOOM of Async Frameworks: Write Once, Build Everywhere, Process Everything.

Platform MIT License

Nodepp is a groundbreaking C++ framework that bridges the gap between the language's raw performance and the developer-friendly abstractions of Node.js. By providing a high-level, asynchronous API, Nodepp empowers you to write C++ with a familiar syntaxβ€”enabling seamless development across cloud servers, desktop apps, and microcontrollers.

At its core, Nodepp features a 100% asynchronous architecture powered by an internal Event Loop. This allows for massive concurrency and scalable task management with minimal code complexity, effectively bringing the "Write Once, Run Everywhere" philosophy to the world of high-performance C++.

πŸ”—: Nodepp The MOST Powerful Framework for Asynchronous Programming in C++

πŸ’‘ Featured Project: Duck Hunt VR (WASM Edition)

To showcase Nodepp for Web, we ported the classic Duck Hunt to Virtual Reality, running natively in the browser via WebAssembly. This project pushes the limits of web-based VR by combining low-level C++ performance with modern Web APIs.

ezgif-7a54260198ce48cc.mp4

Play it now: Duck Hunt VR on Itch.io

πŸ’‘ Featured Project: Cursed-Luna (WASM Remake)

Cursed-Luna is a high-performance remake of the Global Game Jam 2018 classic. Originally built around the theme of Transmission, this version has been completely rewritten in C++ using Nodepp and Raylib to bring tight gameplay mechanics to the browser via WebAssembly.

ezgif-7b0a4670cfd24b91.mp4

Play it now: Cursed-Luna on Itch.io

Dependencies & Cmake Integration

#emscripten
    πŸͺŸ: pacman -S mingw-w64-ucrt-x86_64-emscripten
    🐧: sudo apt install emscripten
include(FetchContent)

FetchContent_Declare(
	nodepp
	GIT_REPOSITORY   https://github.com/NodeppOfficial/nodepp-wasm
	GIT_TAG          origin/main
	GIT_PROGRESS     ON
)
FetchContent_MakeAvailable(nodepp)

#[...]

target_link_libraries( #[...]
	PUBLIC nodepp #[...]
)

Features

  • πŸ“Œ: Lightweight: Minimal dependencies, making it ideal for IoT and embedded systems.
  • πŸ“Œ: Cross-Platform: Write once, run on Linux, Windows, Mac, Android, WASM and Arduino/ESP32.
  • πŸ“Œ: Memory Efficient: Custom ptr_t, queue_t, array_t and string_t primitives provide SSO (Small Stack Optimization) and zero-copy slicing.
  • πŸ“Œ: Scalability: Build applications that can handle large workloads and grow with your needs.
  • πŸ“Œ: Open-source: Contribute to the project's development and customize it to your specific requirements.

Batteries Included

  • πŸ“Œ: UTF Support: Comprehensive manipulation for UTF8, UTF16, and UTF32.
  • πŸ“Œ: Built-in JSON & RegExp: Full parsing and text processing engines.
  • πŸ“Œ: I/O Multiplexing: Support for Poll, Epoll, Kqueue, and WSAPoll.
  • πŸ“Œ: Reactive Programming: Built-in Events and Observers system.

Build & Run

em++ -o www/index.html main.cpp -lembind -I ./include \
    --shell-file ./shell.html --bind  \
     -s NO_DISABLE_EXCEPTION_CATCHING \
     -s ASYNCIFY=1 -s FETCH=1 -s WASM=1

emrun ./www/index.html

Tests

em++ -o www/index.html ./test/main.cpp     \
     -I ./include -pthread --bind -lembind \
     -s NO_DISABLE_EXCEPTION_CATCHING  \
     -s PTHREAD_POOL_SIZE=8            \
     -s USE_PTHREADS=1                 \
     -s ASYNCIFY=1                     \
     -s FETCH=1                        \
     -s WASM=1

emrun ./www/index.html

Examples

Hello world

#include <nodepp/nodepp.h>

using namespace nodepp;

void onMain() {
    console::log("Hello World!");
}

HTTP Client

#include <nodepp/nodepp.h>
#include <nodepp/http.h>

using namespace nodepp;

void onMain() {

    fetch_t args;
            args.method = "GET";
            args.url    = "http://localhost:6931/";

    http::fetch( args )

    .fail([=]( except_t err ){ console::log( err ); })

    .then([=]( http_t cli ){
        console::log( stream::await( cli ) );
        console::log( "->", cli.status );
    });

}

Websocket Client

#include <nodepp/nodepp.h>
#include <nodepp/ws.h>

using namespace nodepp;

void onMain() {

    auto srv = ws::connect( "wss://localhost:8000" );

    srv.onConnect([=]( ws_t cli ){

        cli.onData([]( string_t data ){
            console::log( data );
        });

        cli.onClose([](){
            console::log( "done" );
        });

    });

}

More Examples here

Installing Nodepp-Wasm

Clone The Repository

git clone https://github.com/NodeppOfficial/nodepp-wasm ; cd nodepp

Create a main.cpp File

touch main.cpp ; mkdir ./www
#include <nodepp/nodepp.h>

using namespace nodepp;

void onMain() {
    console::log("Hello World!");
}

Build Your Code

em++ -o www/index.html main.cpp -lembind -I./include \
    --shell-file ./shell.html --bind  \
     -s NO_DISABLE_EXCEPTION_CATCHING \
     -s ASYNCIFY=1 -s FETCH=1 -s WASM=1

emrun ./www/index.html

Nodepp Supports Other Platforms Too

Contribution

If you want to contribute to Nodepp, you are welcome to do so! You can contribute in several ways:

  • β˜• Buying me a Coffee
  • πŸ“’ Reporting bugs and issues
  • πŸ“ Improving the documentation
  • πŸ“Œ Adding new features or improving existing ones
  • πŸ§ͺ Writing tests and ensuring compatibility with different platforms
  • πŸ” Before submitting a pull request, make sure to read the contribution guidelines.

ko-fi

License

Nodepp-WASM is distributed under the MIT License. See the LICENSE file for more details.

About

A runtime for writing reliable asynchronous applications with C++. Provides I/O, networking, scheduling, timers, ...

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published