Skip to content

Commit bedc195

Browse files
authored
Merge pull request #683 from bloomberg/tweak
more docs and fix a wrong error check for bs.pipe.send
2 parents c433bc3 + 724691a commit bedc195

36 files changed

+388
-389
lines changed

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ jscomp/bin/compiler.ml binary
33
jscomp/bin/reason.ml binary
44
jscomp/bin/bs_ppx.ml binary
55
docs/js-demo/exports.js binary
6-
docs/reason-demo/exports.js binary
6+
docs/reason-demo/exports.js binary
7+
docs/Manual.html binary

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ language: node_js
22
env:
33
- BS_TRAVIS_CI=1
44
node_js:
5-
- 6
65
- 4
76

7+
#
8+
# - 6
9+
# This delays notification
10+
811
# Not a very reliable service..
912
# script: npm run coveralls
1013

README.md

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,10 @@ If you need help or have a question, comment, or suggestion, please feel free to
1818
issue](https://github.com/bloomberg/bucklescript/issues).
1919

2020
## Installing BuckleScript
21-
22-
#### Prerequisites
23-
24-
* Standard C toolchain
25-
* `npm` (should be installed with Node)
26-
27-
#### Installing the Release Package
28-
2921
```
3022
npm install bs-platform
3123
```
32-
33-
#### Installing from Source
34-
35-
```
36-
git clone https://github.com/bloomberg/bucklescript
37-
cd bucklescript
38-
npm install
39-
```
24+
For more advanced settings, please visit [Installation](./site/docsource/Installation.adoc)
4025

4126
The BuckleScript installation includes the following:
4227

@@ -47,13 +32,10 @@ The BuckleScript installation includes the following:
4732
Installing BuckleScript from the npm package places binaries in `./node_modules/.bin`. Installing
4833
from the git repository places them in `./bin`.
4934

50-
## Manually Building BuckleScript
5135

52-
See [Developing BuckleScript](./site/docsource/Developing-bucklescript.md) for detailed instructions on manually building BuckleScript.
36+
## Documentation
5337

54-
## Detailed Documentation
55-
56-
See http://bloomberg.github.io/bucklescript for detailed documentation on BuckleScript. If you'd
38+
See http://bloomberg.github.io/bucklescript/Manual.html for detailed documentation on BuckleScript. If you'd
5739
like to contribute content [see here](https://github.com/bloomberg/bucklescript/blob/master/site/docsource)
5840
for the documentation source.
5941

@@ -193,10 +175,6 @@ function test() {
193175
test();
194176
```
195177

196-
## Release Status
197-
198-
BuckleScript has not reached a stable release. However, it is already quite usable and we
199-
encourage you to try it out and let us know what you think.
200178

201179
## Licensing
202180

docs/Manual.html

Lines changed: 87 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -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&#8217;s also the <strong>only</strong>
672+
<p>JavaScript is not just <em>the</em> browser language, it&#8217;s also the <em>only</em>
673673
existing cross platform language. It is truly everywhere: users don&#8217;t
674674
need to install binaries or use package managers to access software,
675675
just 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 &amp;&amp; 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&#8217;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
723726
takes a performance-hit for the VM to optimize code at runtime.
724727
While 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
728731
BuckleScript, using features of the OCaml type-system and compiler
729732
implementation is able to provide many optimizations during offline
730733
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>
734738
under specific platforms. Javascript is everywhere but it does not
735739
mean we have to run all apps in JS, under several platforms, for
736740
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>
741745
</div>
742746
<div class="paragraph">
743747
<p>While a strong type-system helps in countering these problems, at the
744748
same time we hope to avoid some of the problems faced in using other
745749
offline <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&#8217;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
788813
BuckleScript. If you don&#8217;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>
849874
make world.opt
850875
make 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
26252650
below</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
26402665
bindings for it.
26412666
</td>
26422667
</tr>
@@ -2650,8 +2675,8 @@ <h3 id="_examples_2"><a class="anchor" href="#_examples_2"></a>Examples</h3>
26502675
more 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>

docs/js-demo/examples/default.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

2-
Js.log "Hello BuckleScript!"
2+
print_endline "Hello BuckleScript!"
33

docs/js-demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ <h3>JavaScript</h2>
9292

9393
<div class = "right-border" style="width: 50%;float:left">
9494
<textarea id="ocamlcode#1">
95-
Js.log "Hello BuckleScript!"
95+
print_endline "Hello BuckleScript!"
9696
</textarea>
9797
</div>
9898
<div style="width: 50%; float:right">

jscomp/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ travis-world-test:./bin/bspack
119119
# since in npm mode, they are generated from a single file
120120
install:
121121
cp ./bin/bsc ./bin/bsppx ./bin/bspack ../bin/
122-
cp ./runtime/*.cmt* ./runtime/*.cmj* ./stdlib/*.cm* ./others/*.cm* ../lib/ocaml/
123-
cp ./runtime/js.ml ./runtime/js.cmi ./runtime/js_array.mli ./runtime/js_array.ml ./runtime/js_array.cmi ./runtime/js_string.ml ./runtime/js_string.mli ./runtime/js_string.cmi ./runtime/js_re.ml ./runtime/js_re.mli ./runtime/js_re.cmi ./runtime/js_unsafe.cmi ../lib/ocaml/
122+
cp ./runtime/*.cmt* ./runtime/*.cmj* ./stdlib/*.cm* ./others/*.ml ./others/*.mli ./others/*.cm* ../lib/ocaml/
123+
cp ./runtime/js.ml ./runtime/js.cmi ./runtime/js_unsafe.cmi ../lib/ocaml/
124124

125125

126126

jscomp/js.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ FILE=bin/reason.byte
88
ocamlbuild -lflags -no-check-prims -use-ocamlfind -I bin -no-hygiene -pkgs compiler-libs.common -no-links $FILE
99

1010
# jsoo_mkcmis stdlib
11-
js_of_ocaml -I +compiler-libs --toplevel +weak.js +toplevel.js ./polyfill.js _build/$FILE -I ./runtime/ --file js.cmi:/cmis/js.cmi --file js_unsafe.cmi:/cmis/js_unsafe.cmi --file js_re.cmi:/cmis/js_re.cmi -o _build/exports.js
11+
js_of_ocaml -I +compiler-libs --toplevel +weak.js +toplevel.js ./polyfill.js _build/$FILE -I ./others/ -I ./runtime/ --file js.cmi:/cmis/js.cmi --file js_unsafe.cmi:/cmis/js_unsafe.cmi --file js_re.cmi:/cmis/js_re.cmi -o _build/exports.js
1212

1313
DOCS_DIR=../docs/js-demo
1414

jscomp/others/.depend

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ bs_node_process.cmj :
66
bs_node_process.cmx :
77
bs_dict.cmj :
88
bs_dict.cmx :
9-
bs_node_module.cmj : bs_node.cmi bs_dict.cmj
10-
bs_node_module.cmx : bs_node.cmi bs_dict.cmx
9+
bs_node_module.cmj : bs_node.cmj bs_dict.cmj
10+
bs_node_module.cmx : bs_node.cmx bs_dict.cmx
11+
js_array.cmj :
12+
js_array.cmx :
13+
js_string.cmj : js_re.cmi
14+
js_string.cmx : js_re.cmx
15+
js_re.cmj : js_re.cmi
16+
js_re.cmx : js_re.cmi
17+
js_re.cmi :
1118
bs_node_path.cmo :
1219
bs_node_path.cmj :
1320
bs_node_fs.cmo :
@@ -16,5 +23,11 @@ bs_node_process.cmo :
1623
bs_node_process.cmj :
1724
bs_dict.cmo :
1825
bs_dict.cmj :
19-
bs_node_module.cmo : bs_node.cmi bs_dict.cmo
20-
bs_node_module.cmj : bs_node.cmi bs_dict.cmj
26+
bs_node_module.cmo : bs_node.cmo bs_dict.cmo
27+
bs_node_module.cmj : bs_node.cmj bs_dict.cmj
28+
js_array.cmo :
29+
js_array.cmj :
30+
js_string.cmo : js_re.cmi
31+
js_string.cmj : js_re.cmj
32+
js_re.cmo : js_re.cmi
33+
js_re.cmj : js_re.cmi

0 commit comments

Comments
 (0)