Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/ffi.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Interaction with Javascript/Typescript

Note this section is still in design space, it's subject to change in
the future, we need further document how it works in general.
the future, we need to further document how it works in general.

## Call OCaml functions from Javascript/Typescript

Expand Down Expand Up @@ -48,7 +48,7 @@ For example, if we want to provide bindings to the
external describe : string -> (unit -> unit) -> unit = "" [@@js.call "describe"]
external it : string -> (unit -> unit) -> unit = "" [@@js.call "it"]
```
Since, `mochajs` is a test framework, we also need some assertion
Since `mochajs` is a test framework, we also need some assertion
test, we can also describe the bindings to `assert.deepEqual` from
nodejs `assert` library:

Expand Down
30 changes: 15 additions & 15 deletions docs/intro.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
# Why JavaScript Platform
# Why the JavaScript Platform

Javascript is not just the *only* langauge in the browser, but also
the *only* cross platform langauge in town, it is truly
Javascript is not just the *only* langauge in the browser, it is also
the *only* cross platform langauge in town. It is truly
everywhere: users don't even need install any binaries to access your
software, just a simple link.

Another important factor is that the Javascript VM is quite fast and
will become enven faster, so that it is possible to deliver quite
large applications purly in Javascript platform.
Another important factor is that modern Javascript VM's are quite fast and
will become enven faster, so it is possible to deliver large applications
purely running on the Javascript platform.

# Why OCamlScript

OCamlScript is mainly designed to solve the problem of large scale
Javascript programming:

1. Industrial strength type system while not verbose typing required
1. Industrial strength type system, while not verbose typing required
(thanks to OCaml's strong type system).

2. Dead code eliminatoin in different levels (inside functons, outside
2. Dead code elimination in different levels (inside functions, outside
functions and across modules).

3. Offline optimizations. Javascript is a dynamic language, it takes
time to optimize it during runtime, it's better to optimize it at
time to optimize it during runtime, so it's better to optimize it at
compile time if we can.

At the same time we try to avoid the cost of compiling a langague to
At the same time we try to avoid the cost of compiling a language to
Javascript as much as we can:

1. Very fast compilation, OCaml bytecode compilation is
famous for fast compilation, in general one or two order faster
than other similar langauges: [Scala](http://www.scala-lang.org/)
famous for fast compilation, in general one or two orders faster
than other similiar languages: [Scala](http://www.scala-lang.org/)
or [Haskell](https://www.haskell.org/), our compiler shares the same
property with OCaml's bytecode compiler

2. Easy interaction, no name mangling.

3. Separate compilatio. We map one OCaml module into one JS module
3. Separate compilation. We map one OCaml module into one JS module



# Resources for Learning OCaml

The offical [ocaml](https://ocaml.org/) website has a comprehensive
list of tutorials about
The official [OCaml](https://ocaml.org/) website has a comprehensive
list of tutorials.
12 changes: 6 additions & 6 deletions docs/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Hello world

Currently, `ocamlscript` shares the same command line options as `ocamlc`
Currently, `ocamlscript` shares the same command line options as the `ocamlc`
bytecode compiler.

Create a file called `hello.ml` as below
Expand All @@ -21,13 +21,13 @@ If everything goes well, you should have
console.log('hello world')
```

## Compilaton model
## Compilation model

However, the compilation/link model is like ocaml native compiler
instead of bytecode compiler, suppose you
have module `A`, `B`, `C`, module `C` depends on module `B`,
However, the compilation/link model is like the OCaml native compiler
instead of bytecode compiler, suppose you have modules `A`, `B`, `C`,
module `C` depends on module `B`.

Then you need compile `B` first before compiling `C`
Then you need to compile `B` first before compiling `C`

```sh
OCAML_RAW_JS=1 ocamlscript -c a.ml b.ml
Expand Down