Astro Programming Language
Work in Progress π§
What is Astro?
Astro is a fullstack multi-paradigm programming language designed for high-performance numerical-computing applications.
Astro is a
- statically-typed language that
- compiles to native code and WebAssembly,
- has no GC,
- has a syntax similar to Python,
- provides full type inference, and
- has first-class support for data-race-free concurrency.
Why create yet another programming language?
The language creator had a set of requirements (listed above) not met by any single language. Although, the project started as an educational effort, it later shaped into a language designed to meet those requirements.
SIMD, threads and direct access to Web APIs are planned for WebAssembly. These and the proposed GPU Compute standards will make the web a desirable HPC target in the near future. Astro fullstack nature makes developing high-performance apps for web and/or desktop seamless, easier and less frustrating.
Astro has no runtime Garbage Collector (GC) as it is expected to be fast enough to develop games, scientific simulations and other real-time software. This also makes it suitable for embedded software development even though it's not a goal.
In addition, Astro makes some design decisions that are intuitive for numerical computing applications. For example, it has builtin support for vectors, matrices, vectorization, unicode identifiers, etc.
In order to match up with the expressiveness and productivity of dynamic programming languages, Astro adds full type inference, and several other high-level language features that increase productivity. A typical Astro program looks very much like its Python translation.
Python
def times(a, b):
sum = a
for i in range(b):
sum += sum
return sumAstro
fun times(a, b):
var sum = a
for i in 1..b:
sum += sum
return sumFinally, seeing as CPU manufacturers are favoring multi-core design over transistor shrinkage, we believe making concurrency (and parallelism) a major aspect of the language development is beneficial to the type of applications that the language targets.
Astro has builtin facilities for writing concurrent programs, in the form of fibers, a CSP-based lightweight threading model, with the guarantee that the programs you write won't have data races.
Why not just use exactly Python syntax or try to be compatible with Python?
Python is a really dynamic programming language and there have been several attempts in the past to compile it AOT to native code. We don't want to reinvent the wheel since there are lessons to learn from old wheels. Python cannot be fully-inferred at compile-time without performance trade-offs.
More importantly Astro introduces some concepts that Python doesn't have and probably never will.
What is Astro automatic memory management like? Rust's or Swift's?
Neither. Astro uses a special Automatic Reference Counting (ARC) system that automatically breaks reference cycles, so its unlike Swift's ARC which requires some special annotations in cases like that. It's also unlike Rust current memory management model as it puts lesser restrictions on how references are moved around while still being memory safe.
Astro simply, stays out of your way, lets you write your code like you would in any other garbage-collected language.
How close is Astro to being ready for production use?
Not close. Astro is at its infancy, there are several tasks βwhich you can find belowβ to complete before it becomes usable.
For now, Astro can only compile its source code to ast format. It is not ready for even the simplest application.
How will Astro tooling be like?
Astro is meant for interactive high-productivity usage therefore a visual REPL, for visualizing and introspecting different kinds of data, is planned. It will also have a set of language tools for making editor support easier.
Incremental compilation is a goal as well since the language requires a lot of complex compile-time computations like control flow analysis and escape analysis.
Where can I read about the language?
There is no proper documentation for the language yet since the main implementation is still under active development, but you can find an up-to-date summary of language features here.
What are the important tasks to complete?
-
Improve project structure -
Add automated unit testing and coverage reports -
Redesign and remove certain inconsistencies in language syntax - Complete parser implementation
- Implement basic semantic analysis
- Create ambiguity finders for inheritance, multiple dispatch, etc.
- Implement type inference and garbage collection using program flow analysis
- Add wasm code generation
- Incorporate incremental compilation
- Build REPL
- Create specialized error handler
What are the technologies used?
- wast2wasm - a tool for translating WebAssembly s-expression format to its binary-encoded format.
Want to contribute to the project?
Please read the code of conduct and contribution guidelines. We welcome your ideas and contributions.
Do you have an unanswered question?
Please open an issue and ask questions, offer to help, point out bugs or suggest features.
Other interesting new languages that compile to WebAssembly
- Forest - a multi-syntax functional programming language.
- AssemblyScript - a new compiler targeting WebAssembly while utilizing TypeScript's syntax and node's vibrant ecosystem.
- WAlt - an alternative syntax for WebAssembly text format. It's an experiment for using JavaScript syntax to write to as 'close to the metal' as possible.
Project folder structure
.
βββ .codeclimate.yml
βββ .coveralls.yml
βββ .eslintignore
βββ .eslintrc.json
βββ .gitattributes
βββ .gitignore
βββ .hound.yml
βββ .travis.yml
βββ CHANGELOG.md
βββ CODE_OF_CONDUCT.md
βββ CONTRIBUTING.md
βββ LICENSE
βββ MVP.md
βββ README.md
βββ docs
βΒ Β βββ README.md
βΒ Β βββ compiler
βΒ Β βΒ Β βββ README.md
βΒ Β βΒ Β βββ asts-old.md
βΒ Β βΒ Β βββ compiler.md
βΒ Β βΒ Β βββ old-compiler-notes.ast
βΒ Β βΒ Β βββ parser-rewrite.ast
βΒ Β βΒ Β βββ semantic-analysis.md
βΒ Β βββ language
βΒ Β βββ README.md
βΒ Β βββ development.ast
βΒ Β βββ feature-proposals.md
βΒ Β βββ summary.ast
βββ media
βΒ Β βββ images
βΒ Β βββ astro-syntax.png
βββ package-lock.json
βββ package.json
βββ samples
βΒ Β βββ README.md
βΒ Β βββ fibonacci
βΒ Β βΒ Β βββ fibonacci.ast
βΒ Β βββ fizzbuzz
βΒ Β βΒ Β βββ fizzbuzz.ast
βΒ Β βββ hello-world
βΒ Β βΒ Β βββ hello-world.ast
βΒ Β βββ miscellaneous
βΒ Β βΒ Β βββ preview.ast
βΒ Β βββ normalize
βΒ Β βΒ Β βββ normalize.ast
βΒ Β βββ product
βΒ Β βΒ Β βββ product.ast
βΒ Β βββ rosetta
βΒ Β βΒ Β βββ 100-doors.ast
βΒ Β βΒ Β βββ 15-puzzle-game.ast
βΒ Β βΒ Β βββ 99-bottles.ast
βΒ Β βΒ Β βββ abc-problem.ast
βΒ Β βΒ Β βββ accumulator-factory.ast
βΒ Β βΒ Β βββ address-of-a-variable.ast
βΒ Β βΒ Β βββ averages-root-mean-square.ast
βΒ Β βΒ Β βββ ceasar-cipher.ast
βΒ Β βΒ Β βββ comma-quibbling.ast
βΒ Β βΒ Β βββ concurrent-computing.ast
βΒ Β βΒ Β βββ conditional-structures.ast
βΒ Β βΒ Β βββ integer-comparison.ast
βΒ Β βΒ Β βββ maximum-triangle-path-sum.ast
βΒ Β βΒ Β βββ mean.ast
βΒ Β βΒ Β βββ number-reversal.ast
βΒ Β βΒ Β βββ queue-usage.ast
βΒ Β βΒ Β βββ read-a-file-line-by-line.ast
βΒ Β βΒ Β βββ sha-1.ast
βΒ Β βΒ Β βββ sorting-algorithms-merge-sort.ast
βΒ Β βΒ Β βββ string-comparison.ast
βΒ Β βΒ Β βββ sum-of-squares.ast
βΒ Β βΒ Β βββ tokenize-a-string.ast
βΒ Β βββ sum
βΒ Β βΒ Β βββ sum.ast
βΒ Β βββ vectorized
βΒ Β βΒ Β βββ vectorized.ast
βΒ Β βββ wordcount
βΒ Β βββ wordcount.ast
βββ src
βΒ Β βββ boilerplate
βΒ Β βΒ Β βββ parser-boilerplate.js
βΒ Β βββ compiler
βΒ Β βΒ Β βββ README.md
βΒ Β βΒ Β βββ codegen
βΒ Β βΒ Β βΒ Β βββ ast2llvm.js
βΒ Β βΒ Β βΒ Β βββ ast2wast.js
βΒ Β βΒ Β βββ semantics
βΒ Β βΒ Β βΒ Β βββ scope.js
βΒ Β βΒ Β βββ syntax
βΒ Β βΒ Β βΒ Β βββ grammar-and-ast.peg
βΒ Β βΒ Β βΒ Β βββ lexer-test.js
βΒ Β βΒ Β βΒ Β βββ lexer.js
βΒ Β βΒ Β βΒ Β βββ parser-old.js
βΒ Β βΒ Β βΒ Β βββ parser-test.js
βΒ Β βΒ Β βΒ Β βββ parser.js
βΒ Β βΒ Β βΒ Β βββ test-old.js
βΒ Β βΒ Β βββ utils
βΒ Β βΒ Β βββ index.js
βΒ Β βββ stdlib
βΒ Β βΒ Β βββ README.md
βΒ Β βββ support
βΒ Β βββ README.md
βΒ Β βββ editors
βΒ Β βββ atom
βΒ Β βΒ Β βββ README.md
βΒ Β βΒ Β βββ grammars
βΒ Β βΒ Β βΒ Β βββ astro.cson
βΒ Β βΒ Β βββ package.json
βΒ Β βΒ Β βββ snippets
βΒ Β βΒ Β βββ snippets.cson
βΒ Β βββ sublime-text
βΒ Β βΒ Β βββ astro.sublime-syntax
βΒ Β βββ vscode
βΒ Β βββ CHANGELOG.md
βΒ Β βββ README.md
βΒ Β βββ language-configuration.json
βΒ Β βββ package.json
βΒ Β βββ syntaxes
βΒ Β βΒ Β βββ astro.tmLanguage.json
βΒ Β βββ tsconfig.json
βΒ Β βββ vsc-extension-quickstart.md
βββ tests
βββ README.md
βββ compiler
βΒ Β βββ syntax
βΒ Β βΒ Β βββ declarations.spec.js
βΒ Β βΒ Β βββ misc.spec.js
βΒ Β βββ utils
βΒ Β βββ utils.spec.js
βββ samples
βββ fibonacci.spec.js
