Easily mix multiple languages, frontends, backends, compilers, and transpilers inside markdown files. Markdown is the container format for your multi-language application that can contain: server backend logic and config files, and frontend javascript with html and css, all in a single markdown file. Rusthon compiles the markdown into tar files for release, or runs it for testing.
The integrated Python transpiler targets multiple backend languages, like: JavaScript and C++. The JavaScript backend implements most of the dynamic and some builtin functions of Python. The C++ backend is less dynamic and uses an extended static type syntax based on Go, Rust and C++. The other backends are experimental.
- Debian Package
- Fedora package comming soon
If you want to stay in sync with the git-repo, use the install-dev.sh
script instead of the Debian or Fedora package. note: install-dev.sh
just creates a symbolic link transpile
that points to the current location of rusthon.py
.
cd
git clone https://github.com/rusthon/Rusthon.git
cd Rusthon
sudo ./install-dev.sh
To see all the command line options run transpile --help
cd myproject
transpile mymarkdown.md
Above will compile everything in mymarkdown.md:
- if the markdown contains an html page, it will be opened with NW.js or your system default web browser.
- if the markdown contains a javascript file, it will be run with nodejs
- otherwise, if the markdown contains: C++, Rust, or Go code, it will be compiled, and the exe is run.
Transpile from Python to Javascript, with specialized syntax for static types, and using WebWorkers and other extensions to the Python language like mini-macros
Mini-macros help you make your code more readable, and hide ugly APIs like HTML DOM. note: you can use unicode for macro names.
with 𝕄 as "_=document.createElement(%s); _.setAttribute('id',%s); %s.appendChild(_)":
𝕄( 'div', 'someid1', document.body )
𝕄( 'img', 'someid2', document.body )
You can also use the ->
right arrow syntax as a shortcut on DOM elements for appending, setting attributes,
and creating text nodes. You can also define __right_arrow__
on your own classes to customize what ->
will do,
for more info see: here
The example above could be rewritten as:
with 𝕄 as "document.createElement(%s)":
document.body->(
𝕄('div')->(id='someid1'),
𝕄('img')->(id='someid2')
)
You can also do the same thing as above using pure python syntax.
a = document.createElement('div')
a.setAttribute('id', 'someid1')
b = document.createElement('img')
b.setAttribute('id', 'someid2')
document.body.appendChild(a)
document.body.appendChild(b)
CoffeeScript and Rapydscript are great languages to use to avoid the pains of writing JavaScript by hand. They can be directly included in the markdown files, and will get compiled to javascript.
To use these frontends install them on your system, they will be used as subprocesses to output the final javascript.
The C++11 backend is the most mature of the native compiled backends. All the backends are regression tested, and the tests results are here:
note: this and other backends are still a work in progress.