BuckeScriptは、既存のJS開発者にさらに身近に感じられるためのプロジェクトとして、 Reason を組み込みでサポートしています。
BuckleScript's type system alone offers three major benefits to make your programs more reliable:
- Sound type system. "Sound" here means that the types guarantee that they are what they are, not just 90% of the time. Once a BuckleScript project compiles, there are no runtime type errors. *
- Strong type inference. Almost the entirety of the language can be inferred. You don't have to tediously write all the types manually. Feel free to still type out some parts for readability!
- Expressive type features. With well-thought-out features like variants, modules and even an opt-in object system, the types guide you through your iteration process and don't block you from expressing what you need.
* The exceptions are some deliberate, optional interoperability hooks.
- Function and module level code elimination is facilitated by the well-engineered type system and purity analysis.
- At the global level, BuckleScript generates code that are naturally friendly to dead code elimination done by bundling tools such as Rollup and Closure Compiler, after its own sophisticated elimination pass.
- The same applies for BuckleScript's own tiny runtime (which is written in BuckleScript itself).
* In fact, it even runs on microcontrollers with only a few KBs of memory.
BuckleScript's build time is one or two orders of magnitude faster than alternatives. In its watcher mode, the build system usually finishes before you switch screen from the editor to the terminal tab (two digits of milliseconds). A fast iteration cycle reduces need of keeping one's mental state around longer; this in turns allows one to stay in the flow longer and more often.
- Hard to debug (cryptic stack trace, mangled variable names)
- Hard to learn from (non-straightforward mapping of concepts from one language to another)
- Hard to profile for performance (unclear what runtime performance cost there is)
- Hard to integrate with existing hand-written JS code
BuckleScript's JS output is very readable. This is especially important while learning, where users might want to understand how the code's compiled, and to audit for bugs.
Hello world BuckleScript program generates 20 bytes JS code. Additionally, the standard library pieces you require in are only include when needed.