@@ -669,7 +669,7 @@ <h2 id="_why_bucklescript"><a class="anchor" href="#_why_bucklescript"></a>Why B
669
669
< div class ="sect2 ">
670
670
< h3 id ="_benefits_of_javascript_platform "> < a class ="anchor " href ="#_benefits_of_javascript_platform "> </ a > Benefits of JavaScript platform</ h3 >
671
671
< 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 >
673
673
existing cross platform language. It is truly everywhere: users don’t
674
674
need to install binaries or use package managers to access software,
675
675
just a link will work.</ p >
@@ -683,32 +683,34 @@ <h3 id="_benefits_of_javascript_platform"><a class="anchor" href="#_benefits_of_
683
683
< div class ="sect2 ">
684
684
< 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 >
685
685
< 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 >
687
687
</ 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
695
695
< 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 >
706
709
< div class ="ulist ">
707
710
< ul >
708
711
< li >
709
712
< 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 >
712
714
</ li >
713
715
< li >
714
716
< 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
717
719
</ li >
718
720
</ ul >
719
721
</ 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
723
726
takes a performance-hit for the VM to optimize code at runtime.
724
727
While some JS engines circumvent the problem to some extent by
725
728
< 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
728
731
BuckleScript, using features of the OCaml type-system and compiler
729
732
implementation is able to provide many optimizations during offline
730
733
compilation, 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 >
734
738
under specific platforms. Javascript is everywhere but it does not
735
739
mean we have to run all apps in JS, under several platforms, for
736
740
example, 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 >
741
745
</ div >
742
746
< div class ="paragraph ">
743
747
< p > While a strong type-system helps in countering these problems, at the
744
748
same time we hope to avoid some of the problems faced in using other
745
749
offline < a href ="https://github.com/jashkenas/coffeescript/wiki/list-of-languages-that-compile-to-js "> transpilation systems</ a > :</ p >
746
750
</ 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
751
756
(one or two orders of magnitude faster than other similar languages:
752
757
< a href ="http://www.scala-lang.org/ "> Scala</ a > or
753
758
< a href ="https://www.haskell.org/ "> Haskell</ a > ),
754
759
BuckleScript shares the same property and compiles even faster
755
760
since it saves the link time. See the speeds at work in the
756
761
< a href ="http://bloomberg.github.io/bucklescript/js-demo/ "> playground</ a > , the native backend is one
757
762
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 >
777
791
</ div >
778
792
</ div >
779
793
</ div >
0 commit comments