GithubHelp home page GithubHelp logo

abhibob / rusthon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rusthon/rusthon

0.0 0.0 0.0 9.09 MB

multi-lang transpiler, compiler frontend.

Home Page: http://rusthon.github.io/Rusthon/

License: Other

Python 73.72% Perl 12.83% HTML 8.63% C++ 4.60% Shell 0.22%

rusthon's Introduction

Build Status

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.

Installing

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

Using transpile

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.

Getting Started Javascript

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)

Extra JavaScript Frontends

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.

JavaScript Regression Test Results

C++/Rust/Go Backends

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:

C++ Backend Docs

note: this and other backends are still a work in progress.

rusthon's People

Contributors

amirouche avatar shoozza avatar texcoffier avatar techtonik avatar subvertio avatar jcrubino avatar bwiklund avatar bitdeli-chef avatar gordianknotc avatar shekhargulati avatar

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.