5 ms·
This is really neat, but I am very wary of building kernel modules with garbage collected languages especially ones like Haskell, which can has very difficult t
by chas 13y ago
This is really neat, but I am very wary of building kernel modules with garbage collected languages especially ones like Haskell, which can has very difficult to reason about runtime characteristics due to laziness.
One approach that I find much more promising is using Haskell (or other robust and semantically easy to reason about and easy to verify languages) to generate C code which then can be used with normal toolchains for low-level development. Galois is doing a lot of work in this area that looks very promising. One of their projects is an autopilot system called SMACCMPilot[0] that uses a Haskell eDSL called Ivory[1] to generate safe C code. I am particularly excited about its integration with FreeRTOS tasks using the Tower Language[2] (another Haskell eDSL).
This makes it possible to generate code that can be reasoned about with Haskell but has the runtime characteristics of C. This is particularly interesting because embedded systems code is notoriously non-composable and difficult to reason about due to the enormous shared state of the hardware itself and the highly concurrent nature of interrupt-driven design. Embedded C makes a good target for this sort of design and analysis though, because it has very constrained memory usage (developers typically eschew dynamic allocation), very subtle potential issues (debugging race conditions with LEDs sucks), and very serious consequences for errors[3].
[0]http://smaccmpilot.org/index.html http://smaccmpilot.org/index.html
[1]http://smaccmpilot.org/languages/ivory-introduction.html http://smaccmpilot.org/languages/ivory-introduction.html
[2]http://smaccmpilot.org/languages/tower-overview.html http://smaccmpilot.org/languages/tower-overview.html
[3]http://en.wikipedia.org/wiki/Therac-25 http://en.wikipedia.org/wiki/Therac-25
- DanWaterworth 13y agoGalois are doing lots of interesting things in this space, including HaLVM, which allows you to write Haskell programs that run without an OS [1] [1] http://corp.galois.com/halvm http://corp.galois.com/halvm
- chas 13y agoAbsolutely! I am very interested by their approach in this area because integration with existing infrastructure is essential for practical work in this area, but reasoning about existing infrastructure is a lot harder than it needs to be. This is a relatively old presentation of theirs, but it has a decent overview of what they have used Haskell for. http://www.cse.chalmers.se/edu/year/2010/course/TDA555/Material/Guest1/magnus.pdf http://www.cse.chalmers.se/edu/year/2010/course/TDA555/Mater...
- perlgeek 13y agoBut if you generate C code from Haskell, don't you have the same problem as before that it's difficult to reason about runtime characteristics due to laziness?
- chas 13y agoNot really. Haskell is basically used as a compiler from a DSL to C. Compilers running on general purpose systems are much less sensitive to timing and memory use than embedded systems and kernel drivers, so it isn't that big of a deal. The generated C code is the only thing that executes on the target device so you get the same performance that you would expect from C code.
- freyrs3 13y agoThe emitted code need not be lazy, and most often isn't. To a lesser extent the EDSL technique is also the technique that Accelerate uses to build fast array computations. [1]: https://speakerdeck.com/mchakravarty/embedded-languages-for-high-performance-computing-in-haskell https://speakerdeck.com/mchakravarty/embedded-languages-for-...
- chongli 13y agoThis is really neat, but I am very wary of building kernel modules with garbage collected languages especially ones like Haskell, which can has very difficult to reason about runtime characteristics due to laziness. This is FUD, repeated ad nauseum all over the internet as a misinterpretation of what Simon Peyton Jones said once during a talk. In case you hadn't noticed, there appears to be a tradition in programmer circles of picking SPJ quotes and turning them into memes. "Haskell is useless!" and "Avoid success at all costs!" are some others. The reality is far less extreme than most people think. It is not at all unreasonable to write low-level code such as device drivers in Haskell. This has actually been done as part of the HaLVM project.
- mestonlawest 13y agoSPJ is a fool for making those 'clever' statements like "Haskell is useless!", because most people won't stick around to hear the twist explanation.
- freyrs3 13y agoI think you have it backwards. If someone forms opinions on languages based on out of context quotations then they are the fool, not SPJ.
- phaer 13y agoThe explanation of this particular quote is like 5 minutes long on YouTube. If you don't spend that much time to listen to an argument, it's unlikely that you have a well founded opinion on programming languages anyway.
- efnx 13y agoI don't think at the time he was trying to be clever. If you watch the talk you'll see it makes a lot of sense to make this statement in its context. Also - Haskell will either be very popular or not, based on its merits in industry. I doubt the fallout from these type of statements will amount to much in the long run.
- cwzwarich 13y ago
- pjmlp 13y ago> This is really neat, but I am very wary of building kernel modules with garbage collected languages Native Oberon, Spin, Singularity, ...