[cap-talk] Confessions of a C programmer
Sandro Magi
naasking at higherlogics.com
Mon Sep 21 10:36:27 PDT 2009
I would also recommend OCaml for its simplicity, but it will require
some porting effort for the core syscalls. There are web application
servers already done for you [1].
I also wish to clarify what seems to be a common misconception: OCaml
does not compile to C. It has its own native code generator, and a
C-based bytecode VM for unsupported architectures.
Perhaps an ML platform that supports embedded targets would be more
amenable, like MLKit. How easy MLKit is to retarget isn't clear from a
cursory search.
MLTon and Haskell can both output C, if C code is easier to work with.
Haskell has a very large library including web servers, and an active
community.
Mono has been ported to many architectures and operating systems, all
similar of course, so it's not clear how much effort would be required
for CapROS. However, the CLR's P/Invoke mechanism may make this easier.
You certainly open development up to a very wide audience if you get
Java or .NET support though.
There aren't too many embedded functional languages. I managed to find
Embedded ML [2], which targets Gumstix and Arduino embedded platforms by
compiling to C. This probably requires the smallest porting effort, but
it's not clear how mature this project is.
Sandro
[1] http://ocsigen.org/
[2] http://embeddedml.sourceforge.net/Site/Intro.html
Stiegler, Marc D wrote:
> Markm's recommendation of Emily, and Ben's recommendation of C#/DotNet, suggest that Ocaml is the place to start -- learn Ocaml, and you are already writing Emily (if you want to go to ocap guarantees) and F# (which has a subset so similar to Ocaml that it compiles Ocaml, with a couple of caveats).
>
> Learning Ocaml from the standard texts on the web will be painful. I did actually write a draft of Emily in a Walnut that I could dig up for you if you are serious. The difference is, traditional texts focus on functional programming and mention imperative programming in passing. I, on the other hand, focus on imperative, c-style programming, and mention functional programming in passing :-) And I can give you a short course on it at a Friday meeting :-)
>
> Ocaml is already used for soft-real-time device drivers despite having automatic garbage collection -- the collector is really fast and pause-resistant. It was even used to write an operating system, as a graduate student exercise. As markm mentioned, it compiles to C and launches as fast as C. However, there is no way with ocaml to launch true threads, which you might care about. For concurrent Ocaml, I built a promise pipelining library that used linux processes, pretty heavyweight. There is a variant, jocaml, about which I know nothing but it's designed for concurrency, one way or another. F# has other alternatives for multithreading. The benchmark for F# I saw was so good that I'm suspicious it was incorrect. F# has a properly tricked out IDE, there are plugins with both Mono on Linux and with Visual Studio.
>
> Ocaml's type checking is powerful enough so that null pointer exceptions are literally impossible, unless it bubbles up from a library package written in C. F# allows you to write programs that can only get null pointer exceptions from dotnet and c libraries, but to work smoothly with dotnet, reintroduced the ability for the programmer to create his own null pointer exceptions if he wants to ("you can write FORTRAN in any language" :-)
>
> --marcs
>
More information about the cap-talk
mailing list