Code Monkey home page Code Monkey logo

serl's Introduction

Project: Serl

Javascript/OTP, anyone? Here's an attempt to port Erlang/OTP (Open Telecom Protocol) semantics to browser-based ECMAScript.

Project: Demo

To eyeball a very rough demo, serve the repository directory, then click on the link to tests. Open the console to see test output. Tweak the code in tests.js and see how it reacts.

Project: Versions

v0.0.1 (master) - A documented proof-of-concept, where a single node can spawn multiple procs, and where a proc can recursively send >15,000 messages to another without blowing the stack. An implementation of Erlang-style pattern matching is also demonstrated.

v0.0.2 (develop) - Aiming to simply to go through all the @todos and update the ones which improve DX, such as turning weirdly shaped objects into classes, validating arguments, and renaming things.

Documentation

Documentation: Generation

Currently using JSDoc.

Quick start to generating documentation from JSDoc-formatted comments in source files:

$ cd path/to/serl-git-repository
$ npm install --save-dev jsdoc
$ node node_modules/jsdoc/jsdoc.js lib/serl.js -d docs -c node_modules/jsdoc/conf.json -R ./README.md

Current configuration of conf.json:

{
    "plugins": ["plugins/markdown"],
    "markdown": {
        "tags": [
            "description"
        ]
    },
    "allowUnknownTags": true
}

.vimrc line to auto-regenerate documentation (example):


autocmd BufWritePost ~/exercises/serl/* !node 
    \ ~/exercises/serl/node_modules/jsdoc/jsdoc.js
    \ ~/exercises/serl/lib/serl.js
    \ -d ~/exercises/serl/docs
    \ -c ~/exercises/serl/node_modules/jsdoc/conf.json
    \ -R ~/exercises/serl/README.md

Documentation: TODO

Get on JSDoc Slack.

Architecture

Architecture: Priorities

  • Leverage on the maturity of OTP design patterns.

    • If #itjustworks in the browser, then we're on our way to using the same framework on the server and client.

    • Future possibilities: inter-op with OTP compliant code written in any language and working on any runtime.

  • General Erlang/OTP priorities.

    • No shared memory between procs.

    • Let it crash.

    • Asynchronous coding style should allow non/minimally-blocking programs.

      • Testing protocol to ensure this for all user code should be established.
    • Users must be reminded to write JavaScript like this.

    • Recursion should not block the stack. #tailcalls

      • Utilities need to be provided to ease writing this sort of code. (See Serl.recurse/2 for example.)
  • Otherwise minimally opinionated.

  • Back to basics. The framework should encourage weak users,and also as well as to allow quick-starts on tiny projects.

    • The library should run out of the box. Building should optional.

    • The library should not require DSLs. Transpilation should be optional. Everything should work in use strict.

    • Server-side rendering should be optional. When SSR is enabled, de/hydration should be optional.

    • Performance optimisations should generally be optional.

    • Computed properties should be optional.

Motivations?

I didn't want to do this. I wanted something like this, but hit a dead-end, and fell back to the approach on this repository.

Backlog

Backlog: First items to implement:

- DONE: `Node` class, which constructs an object based on (erl),
  representing one runtime system 'node'

- DONE: `Pid` class, which constructs an object based on the Erlang 'pid'
  datatype; remember to specify its toString; maybe specify parsePid as its
  inverse

- DONE: `node.spawn/3` method, which returns the pid of a new 'lightweight
  process' started on a 'serl' node; the await ES keyword should be used in
  place of the receive Erlang keyword; use the 'arguments' object to
  implement arity=3, such that the other arities can be structurally
  implemente later

- DONE: `proc.send/2` method, for sending messages; since send/3 doesn't
  change the position of the first two parameters, we don't have to check
  for arity here...

- UNDONE: then do a test using the pingpong example in Erlang docs on
  message passing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.