Try OCaml [In-Browser repl with interactive lessons]

44 views
Skip to first unread message

Bruno Deferrari

unread,
Dec 26, 2011, 1:31:33 PM12/26/11
to qil...@googlegroups.com
http://try.ocamlpro.com/

Very interesting, and a good way to learn the basics and get the feel
of the language. Maybe Shen can have something like this once the
Javascript target is ready.

--
BD

WILLI Riha

unread,
Dec 27, 2011, 2:50:30 AM12/27/11
to qil...@googlegroups.com
More info is needed! I don't know anything about Ocaml.
 
I type
 1
and get
1;;
 
I type
1 + 2
and get
1 + 2;;
 
I type
arse
and get
unbound variable arse
 
I type
and I am told the integer is too large.
 
I have a sip of wine
and get no response
 
I am intrigued - how does one use this language?
Thanks
 
Willi

--
You received this message because you are subscribed to the Google Groups "Qilang" group.
To post to this group, send email to qil...@googlegroups.com.
To unsubscribe from this group, send email to qilang+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/qilang?hl=en.


4DA

unread,
Dec 27, 2011, 6:59:01 AM12/27/11
to Qilang
Nice!

They've got ocaml implemented on top of JS VM?

Bruno Deferrari

unread,
Dec 27, 2011, 7:36:56 AM12/27/11
to qil...@googlegroups.com

Hey Willi. The results are on the second line, what you mentioned is
the auto-correction you get from your inputs.

# 1;;
- : int = 1
# 1 + 2;;
- : int = 3
# arse;;
Characters 0-4:
Error: Unbound value arse
# let arse = 1;;
val arse : int = 1
# arse + arse;;
- : int = 2

The reason 12345678910 doesn't work is that OCaml numbers aren't
arbitrary precision (those are part of the standard library, but
"normal" numbers are limited)

To start the with the lessons type: lesson 1.

But don't worry about OCaml!! it was the in-browser REPL that I wanted
to show. Here are more examples of the same concept:

http://tryruby.org/
http://tryhaskell.org/
http://tryclj.com/
http://tryarc.org/
http://www.tryerlang.org/
http://tryjavascript.devfu.com/
http://www.trypython.org/ (this one requires silverlight)

What is interesting about the OCaml one is that what you see there is
the same REPL you get when running OCaml locally, but this one runs
completely in-browser. It was compiled with js_of_ocaml[1], which is a
tool that compiles OCaml bytecode to Javascript, and seems to work
pretty well. Because Shen will target Javascript too, the same should
be doable.

Others just launch a REPL on the server and interact with it,
something that doesn't convince me (because of security issues, and
because it needs more resources).

[1] http://ocsigen.org/js_of_ocaml/

--
BD

Bruno Deferrari

unread,
Dec 27, 2011, 7:37:54 AM12/27/11
to qil...@googlegroups.com
On Tue, Dec 27, 2011 at 9:59 AM, 4DA <dcher...@gmail.com> wrote:
> Nice!
>
> They've got ocaml implemented on top of JS VM?
>

They use this tool: http://ocsigen.org/js_of_ocaml/

It compiles bytecode generated by the OCaml compiler (the one that
doesn't generate native code) to Javascript.

--
BD

eigenfunction

unread,
Dec 27, 2011, 7:54:26 AM12/27/11
to Qilang
works for me ;-)

# 12345678910.0;;
- : float = 12345678910.

Willi, if you do not like the semi-colons, may be you take a look at
F#. Those are the languages that Shen
will be fighting against in the first place.

Bruno Deferrari

unread,
Dec 27, 2011, 7:58:02 AM12/27/11
to qil...@googlegroups.com
On Tue, Dec 27, 2011 at 10:54 AM, eigenfunction <emeka...@yahoo.com> wrote:
> works for me ;-)
>
> # 12345678910.0;;
> - : float = 12345678910.
>

Oh, but thats a float. You can't do the same with integers unless you
are using the Num module.

http://caml.inria.fr/pub/docs/manual-ocaml/libref/Num.html

--
BD

WILLI Riha

unread,
Dec 27, 2011, 7:59:41 PM12/27/11
to qil...@googlegroups.com
Thanks for all your replies!
 
W


--
BD

Reply all
Reply to author
Forward
0 new messages