@@ -502,7 +502,7 @@ <h1><a href="https://github.com/bloomberg/bucklescript">BuckleScript</a> User Ma
502502< ul class ="sectlevel2 ">
503503< li > < a href ="#_install_from_npm_registries "> Install from NPM registries</ a > </ li >
504504< li > < a href ="#_install_from_source_with_npm_package_manager "> Install from source with npm package manager</ a > </ li >
505- < li > < a href ="#_install_with_minimal_dependencies "> Install with minimal dependencies</ a > </ li >
505+ < li > < a href ="#_install_with_em_minimal_em_dependencies "> Install with < em > minimal</ em > dependencies</ a > </ li >
506506< li > < a href ="#_introduction_to_ocaml_ecosystem_opam "> Introduction to OCaml ecosystem: OPAM</ a > </ li >
507507</ ul >
508508</ li >
@@ -571,7 +571,7 @@ <h1><a href="https://github.com/bloomberg/bucklescript">BuckleScript</a> User Ma
571571< li > < a href ="#_debugger_support "> Debugger support</ a > </ li >
572572< li > < a href ="#_regex_support "> Regex support</ a > </ li >
573573< li > < a href ="#_examples_2 "> Examples</ a >
574- < ul class ="sectlevel4 ">
574+ < ul class ="sectlevel3 ">
575575< li > < a href ="#_a_simple_example_binding_to_mocha_unit_test_library "> A simple example: binding to mocha unit test library</ a > </ li >
576576</ ul >
577577</ li >
@@ -669,7 +669,7 @@ <h2 id="_why_bucklescript"><a class="anchor" href="#_why_bucklescript"></a>Why B
669669< div class ="sect2 ">
670670< h3 id ="_benefits_of_javascript_platform "> < a class ="anchor " href ="#_benefits_of_javascript_platform "> </ a > Benefits of JavaScript platform</ h3 >
671671< div class ="paragraph ">
672- < p > JavaScript is not just < strong > the</ strong > browser language, it’s also the < strong > only</ strong >
672+ < p > JavaScript is not just < em > the</ em > browser language, it’s also the < em > only</ em >
673673existing cross platform language. It is truly everywhere: users don’t
674674need to install binaries or use package managers to access software,
675675just a link will work.</ p >
@@ -683,32 +683,34 @@ <h3 id="_benefits_of_javascript_platform"><a class="anchor" href="#_benefits_of_
683683< div class ="sect2 ">
684684< h3 id ="_problems_of_javascript_how_bucklescript_solves_it "> < a class ="anchor " href ="#_problems_of_javascript_how_bucklescript_solves_it "> </ a > Problems of JavaScript && how BuckleScript solves it</ h3 >
685685< div class ="paragraph ">
686- < p > BuckleScript is mainly designed to solve the problems of < strong > large scale JavaScript programming</ strong > :</ p >
686+ < p > BuckleScript is mainly designed to solve the problems of < em > large scale</ em > JavaScript programming:</ p >
687687</ div >
688- < div class ="olist arabic ">
689- < ol class =" arabic " >
690- < li >
691- < p > Lack of type-safety:
692- < a href =" https://ocaml.org/ " > OCaml</ a > offers an industrial-strength
693- state-of-the-art type system and provides type inference (i.e. No
694- verbose type annotation required), which proves
688+ < div class ="dlist ">
689+ < dl >
690+ < dt class =" hdlist1 " > Type-safety </ dt >
691+ < dd >
692+ < p > OCaml offers an industrial-strength
693+ state-of-the-art type system and provides very strong type inference (i.e. No
694+ verbose type annotation required compared with typescript ), which proves
695695< a href ="http://programmers.stackexchange.com/questions/215482/what-are-the-safety-benefits-of-a-type-system "> invaluable</ a >
696- in managing large projects.</ p >
697- </ li >
698- < li >
699- < p > Dead code: A large amount of web-development relies on inclusion of
700- code dependencies by copying or referencing CDNs (the very thing
701- that makes JavaScript highly accessible), but this also introduces
702- a lot of < a href ="https://en.wikipedia.org/wiki/Dead_code "> dead code</ a > . This
703- impacts performance adversely when the JavaScript VM has to
704- interpret code that will never be invoked. BuckleScript provides
705- powerful dead-code elimination at all levels:</ p >
696+ in managing large projects. OCaml’s type system is not just for tooling,
697+ it is a < em > sound</ em > type system which means it is guaranteed that there will
698+ be no runtime type errors after type checking.</ p >
699+ </ dd >
700+ < dt class ="hdlist1 "> High quality dead code elimination</ dt >
701+ < dd >
702+ < p > A large amount of web-development relies on inclusion of
703+ code dependencies by copying or referencing CDNs (the very thing
704+ that makes JavaScript highly accessible), but this also introduces
705+ a lot of < a href ="https://en.wikipedia.org/wiki/Dead_code "> dead code</ a > . This
706+ impacts performance adversely when the JavaScript VM has to
707+ interpret code that will never be invoked. BuckleScript provides
708+ powerful dead-code elimination at all levels:</ p >
706709< div class ="ulist ">
707710< ul >
708711< li >
709712< p > Function and module level elimination is facilitated by the
710- sophistication of the type-system of OCaml and
711- purity analysis.</ p >
713+ sophistication of the type-system of OCaml and < em > purity analysis</ em > .</ p >
712714</ li >
713715< li >
714716< p > At the global level BuckleScript generates code ready for
@@ -717,9 +719,10 @@ <h3 id="_problems_of_javascript_how_bucklescript_solves_it"><a class="anchor" hr
717719</ li >
718720</ ul >
719721</ div >
720- </ li >
721- < li >
722- < p > Lack of offline optimizations: JavaScript is a dynamic language, it
722+ </ dd >
723+ < dt class ="hdlist1 "> Offline optimizations</ dt >
724+ < dd >
725+ < p > JavaScript is a dynamic language, it
723726takes a performance-hit for the VM to optimize code at runtime.
724727While some JS engines circumvent the problem to some extent by
725728< a href ="http://v8project.blogspot.com/2015/07/code-caching.html "> caching</ a > ,
@@ -728,52 +731,63 @@ <h3 id="_problems_of_javascript_how_bucklescript_solves_it"><a class="anchor" hr
728731BuckleScript, using features of the OCaml type-system and compiler
729732implementation is able to provide many optimizations during offline
730733compilation, allowing the runtime code to be extremely fast.</ p >
731- </ li >
732- < li >
733- < p > Run your programs on all platforms, but run your system < strong > faster</ strong >
734+ </ dd >
735+ < dt class ="hdlist1 "> JS platform and Native platform</ dt >
736+ < dd >
737+ < p > Run your programs on all platforms, but run your system < em > faster</ em >
734738under specific platforms. Javascript is everywhere but it does not
735739mean we have to run all apps in JS, under several platforms, for
736740example, server side or iOS/Android native apps, when programs are
737- written in OCaml, it can also be compiled to native code for < strong > best
738- performance</ strong > .</ p >
739- </ li >
740- </ ol >
741+ written in OCaml, it can also be compiled to native code for < em > better
742+ and reliable performance</ em > .</ p >
743+ </ dd >
744+ </ dl >
741745</ div >
742746< div class ="paragraph ">
743747< p > While a strong type-system helps in countering these problems, at the
744748same time we hope to avoid some of the problems faced in using other
745749offline < a href ="https://github.com/jashkenas/coffeescript/wiki/list-of-languages-that-compile-to-js "> transpilation systems</ a > :</ p >
746750</ div >
747- < div class ="ulist ">
748- < ul >
749- < li >
750- < p > Slow compilation: OCaml byte-code compilation is known to be fast
751+ < div class ="dlist ">
752+ < dl >
753+ < dt class ="hdlist1 "> Slow compilation</ dt >
754+ < dd >
755+ < p > OCaml byte-code compilation is known to be fast
751756 (one or two orders of magnitude faster than other similar languages:
752757< a href ="http://www.scala-lang.org/ "> Scala</ a > or
753758 < a href ="https://www.haskell.org/ "> Haskell</ a > ),
754759 BuckleScript shares the same property and compiles even faster
755760 since it saves the link time. See the speeds at work in the
756761 < a href ="http://bloomberg.github.io/bucklescript/js-demo/ "> playground</ a > , the native backend is one
757762 order faster than the JS backend.</ p >
758- </ li >
759- < li >
760- < p > Un-readable JS Code and hard to integrate with existing JS
761- libraries: When compiling to JavaScript, many systems
762- generate code, that while syntactically and semantically correct is
763- not human-readable and very difficult to debug and profile.
764- Our BuckleScript implementation and the multi-pass compilation strategy of OCaml,
765- allows us to avoid < a href ="https://en.wikipedia.org/wiki/Name_mangling "> name-mangling</ a > ,
766- and produce JavaScript code that is human-readable and easier to debug and
767- maintain. More importantly, this makes integration with existing JS
768- libraries much easier.</ p >
769- </ li >
770- < li >
771- < p > Loss of code-structure: Many systems generate JavaScript code that is essentially a
772- < a href ="https://en.wikipedia.org/wiki/Big_ball_of_mud "> big ball of mud</ a > . We try
773- to keep the original structure of the code by mapping one OCaml module
774- to one JS module.</ p >
775- </ li >
776- </ ul >
763+ </ dd >
764+ < dt class ="hdlist1 "> Un-readable JS Code and hard to integrate with existing JS libraries</ dt >
765+ < dd >
766+ < p > When compiling to JavaScript, many systems
767+ generate code, that while syntactically and semantically correct is
768+ not human-readable and very difficult to debug and profile.
769+ Our BuckleScript implementation and the multi-pass compilation strategy of OCaml,
770+ allows us to avoid < a href ="https://en.wikipedia.org/wiki/Name_mangling "> name-mangling</ a > ,
771+ and produce JavaScript code that is human-readable and easier to debug and
772+ maintain. More importantly, this makes integration with existing JS
773+ libraries < em > much easier</ em > .</ p >
774+ </ dd >
775+ < dt class ="hdlist1 "> Large JS output even for a simple program</ dt >
776+ < dd >
777+ < p > In BuckleScript, a < code > Hello world</ code > program generates < em > 20 bytes</ em > JS code
778+ instead of < em > 50K bytes</ em > . This is due to that BuckleScript has an excellent
779+ integration with JS libs that unlike most JS compilers,
780+ all BuckleScript’s runtime is written in OCaml itself so that these
781+ runtime libraries are only needed when user actually call it.</ p >
782+ </ dd >
783+ < dt class ="hdlist1 "> Loss of code-structure</ dt >
784+ < dd >
785+ < p > Many systems generate JavaScript code that is essentially a
786+ < a href ="https://en.wikipedia.org/wiki/Big_ball_of_mud "> big ball of mud</ a > . We try
787+ to keep the original structure of the code by mapping one OCaml module
788+ to one JS module.</ p >
789+ </ dd >
790+ </ dl >
777791</ div >
778792</ div >
779793</ div >
@@ -783,6 +797,17 @@ <h2 id="_installation"><a class="anchor" href="#_installation"></a>Installation<
783797< div class ="sectionbody ">
784798< div class ="sect2 ">
785799< h3 id ="_install_from_npm_registries "> < a class ="anchor " href ="#_install_from_npm_registries "> </ a > Install from NPM registries</ h3 >
800+ < div class ="ulist ">
801+ < div class ="title "> Prerequisites</ div >
802+ < ul >
803+ < li >
804+ < p > Standard C toolchain</ p >
805+ </ li >
806+ < li >
807+ < p > < code > npm</ code > (should be installed with Node)</ p >
808+ </ li >
809+ </ ul >
810+ </ div >
786811< div class ="paragraph ">
787812< p > The standard < code > npm</ code > package management tool can be used to install
788813BuckleScript. If you don’t already have < code > npm</ code > installed, follow the
@@ -827,7 +852,7 @@ <h3 id="_install_from_source_with_npm_package_manager"><a class="anchor" href="#
827852</ div >
828853</ div >
829854< div class ="sect2 ">
830- < h3 id ="_install_with_minimal_dependencies "> < a class ="anchor " href ="#_install_with_minimal_dependencies "> </ a > Install with minimal dependencies</ h3 >
855+ < h3 id ="_install_with_em_minimal_em_dependencies "> < a class ="anchor " href ="#_install_with_em_minimal_em_dependencies "> </ a > Install with < em > minimal</ em > dependencies</ h3 >
831856< div class ="olist arabic ">
832857< div class ="title "> Prerequisites:</ div >
833858< ol class ="arabic ">
@@ -844,7 +869,7 @@ <h3 id="_install_with_minimal_dependencies"><a class="anchor" href="#_install_wi
844869< div class ="title "> Build OCaml compiler</ div >
845870< div class ="content ">
846871< pre class ="pygments highlight "> < code data-lang ="sh "> git clone --recursive https://github.com/bloomberg/bucklescript
847- < span class ="tok-nb "> cd </ span > ocaml
872+ < span class ="tok-nb "> cd </ span > bucklescript/ ocaml
848873./configure -prefix < span class ="tok-sb "> `</ span > < span class ="tok-nb "> pwd</ span > < span class ="tok-sb "> `</ span > < span class ="tok-c "> # put your preferred directory</ span >
849874make world.opt
850875make install</ code > </ pre >
@@ -2621,7 +2646,7 @@ <h3 id="_regex_support"><a class="anchor" href="#_regex_support"></a>Regex suppo
26212646</ div >
26222647</ div >
26232648< div class ="paragraph ">
2624- < p > The compiler will infer < code > f</ code > has type < code > Js_re .t</ code > and generate code as
2649+ < p > The compiler will infer < code > f</ code > has type < code > Js.Re .t</ code > and generate code as
26252650below</ p >
26262651</ div >
26272652< div class ="listingblock ">
@@ -2636,7 +2661,7 @@ <h3 id="_regex_support"><a class="anchor" href="#_regex_support"></a>Regex suppo
26362661< div class ="title "> Note</ div >
26372662</ td >
26382663< td class ="content ">
2639- < code > Js_re .t</ code > is an abstract type, we are working on providing
2664+ < code > Js.Re .t</ code > is an abstract type, we are working on providing
26402665bindings for it.
26412666</ td >
26422667</ tr >
@@ -2650,8 +2675,8 @@ <h3 id="_examples_2"><a class="anchor" href="#_examples_2"></a>Examples</h3>
26502675more examples, please visit
26512676< a href ="https://github.com/bloomberg/bucklescript-addons " class ="bare "> https://github.com/bloomberg/bucklescript-addons</ a > </ p >
26522677</ div >
2653- < div class ="sect4 ">
2654- < h5 id ="_a_simple_example_binding_to_mocha_unit_test_library "> < a class ="anchor " href ="#_a_simple_example_binding_to_mocha_unit_test_library "> </ a > A simple example: binding to mocha unit test library</ h5 >
2678+ < div class ="sect3 ">
2679+ < h4 id ="_a_simple_example_binding_to_mocha_unit_test_library "> < a class ="anchor " href ="#_a_simple_example_binding_to_mocha_unit_test_library "> </ a > A simple example: binding to mocha unit test library</ h4 >
26552680< div class ="paragraph ">
26562681< p > This is an example showing how too provide bindings to the
26572682< a href ="https://mochajs.org/ "> mochajs</ a > unit test framework.</ p >
0 commit comments