hOp is a micro-kernel based on the RTS of GHC. It is meant to enable people to experiment with writing device drivers in Haskell. Currently, hOp is still very hackish, and IA32-specific. More info here and here.
Aside from the fact that to do any of the interesting things on a computer (i.e. any type of I/O) you have to resort to using monads, which basically means imperitive programming. Therefore Haskell, and for the most part functional languages, are a pipe dream…
Neat stuff. I’m learning ML at the moment, Haskell looks quite similar, and I’ve wondered how practical system programming is with functional languages.
No some doubt people will laugh at projects like this. Just like it seemed insane to use a high-level language like C or PL/I or whatever for a kernel back in the days when it was all done in assembly, I think people will think the same thing again 😉
That’s quite a bit of a leap in logic, heh? Using monads means that functional languages are a pipe dream? Monads aren’t “basically imperative programming”. They allow you to do imperative things, but unlike imperative programming, don’t require you to break the rule that functions can’t have side-effects. Here is a good discussion of monads that’ll hopefully make the distinction clear: http://myweb.lsbu.ac.uk/~abdallae/units/fp/iomonads.pdf
Practically, the breaking of functional purity isn’t a big deal. The fundemental idea of functional programming, from a utilitarian standpoint, is that it allows the programmer to reduce the amount of program state he has to reason about while writing the program. That means even if you don’t write all your code functionally, you can still greatly reduce the amount of program state you have to reason about. This makes a functional style useful even in languages, like Lisp, that don’t enforce functional constructs.
For those who are curious (I had to look this up): RTS is GHC’s runtime system. It contains support routines used by the C code generated by the GHC compiler.
Lisp and Scheme are really kind of different, and hard to compare directly. Scheme is cleaner than Lisp in the sense that it get’s rid of some less-used features, and has a more systematic naming convention, but it also lacks some important features like objects and generic functions. It also places more emphasis on functional programming, while Lisp is more multi-paradigm and places and emphasis on macros.
what is the best language to learn to get into functional programming? I’ve already played with languages that have some functional programming charecteristics such as Perl 5, and and generally competent in programming.
“what is the best language to learn to get into functional programming?”
I would suggest Scheme. Specifically, DrScheme is great for learning the concepts of functional programming. I would not suggest Common Lisp as it is a bit too large for someone just wanting a taste of the paradigm. Haskell is also good, but it is no where as simple as Scheme.
I don’t know if my Prof is going to cover Prolog, out Semester project is a LISP program that implements a Heuristic for Go Fish. the smarter the program is, the better your grade. it sounds fun, but I can’t seem to think that it would be easier done in another language…. but then again, I am just learning LISP, so everything is harder 🙂
out AI book does cover ProLog though (I am sure it is the same one you use, the big green one) I think I will play with it a bit. thanks for the tip
Though there still is some active thinking about hOp, not much code had been written lately, mostly because of thesis and real life issues. We are also waiting for GHC 6.4 release which will help hOp bootstrapping.
Well, “real” problems very quite greatly. For example, consider reasoning engines — programs that take a large set of rules as input, and decides how to end up with a state that satisfies those rules. Sounds like one of those college problems that Haskell would be good at (and indeed, it is), but such things are tremendously useful in certain application domains.
Haskell is nifty for another reason. You can systematically reason about Haskell programs. When you’re writing something to control a nuclear reactor, this sort of thing can come in handy.
AI is an extremely broad field, so it is easy to imagine that some languages would be really good for one branch of AI and some other languages for another branch. Prolog for instance was originally built for natural language programming (It’s also really good for compiler writing).
One of the reasons that Prolog never really caught on as much as Lisp though is that Lisp had ~10 years of a head start so its implementations were always _much_ faster. Of course now days the situation may have changed, but Lisp has long had a mindshare advantage over Prolog.
“[monads] allow you to do imperative things, but unlike imperative programming, don’t require you to break the rule that functions can’t have side-effects.”
This is not entirely true. Using monads you have a purely functional program (which you can reason about in the way you describe), but that program constructs as its result an imperative program which is then executed. I.E. you get all the hassles again, and it’s even *harder* to reason about because you have to deal with code that is hidden under data.
That is, with monads you program partially functional, partially imperative. A program will only be maintainable if you balance the two well, and that’s very much the same with traditional languages such as C.
That said, typical C programmers usually don’t find the balance at all so it might not be bad to teach them using monads
Monads are just one way to handle mutable data in a pure functional language. Another way is uniqueness typing http://en.wikipedia.org/wiki/Uniqueness_type . I think that uniqueness typing is much easier to understand for people coming from imperative languages (almost everybody).
Advocates of functional languages should stop insisting that everybody has to use monads and instead advocate uniqueness typing. This is the only way that functional languages can become mainstream.
Sorry to be offtopic but there is a language called Curry that integrates Functional and Logic Programming paradigms. Also there is Nemerle, which is a functional language that works with .Net and Mono (unfortunately it lacks many of the cool features of Haskell at this point, like lazy processing, list ranges, and list comprehensions).
Erlang is designed for concurrent and distributed programming, it is a functional language as well. It inherited its syntax from Prolog for a great deal.
Most functional languages have not managed to leave the ivory towers yet, while Erlang is used in the telecommunication industry.
I would recommend every developer to learn a bit of Prolog and some functional language just to broaden the mind to see how different programming can be done.
Haskell is one of the best languages i have ever seen.
Aside from the fact that to do any of the interesting things on a computer (i.e. any type of I/O) you have to resort to using monads, which basically means imperitive programming. Therefore Haskell, and for the most part functional languages, are a pipe dream…
given that, just like OO, it makes no difference to the CPU how you construct the code (though it does matter if you have a good compiler or not)
frankly, with my AI class, I have found LISP to be a very nice language in principle, but the parentheses are murder.
functional programming itself is a very powerful concept, and I like it…. just not with LISP 🙂
Neat stuff. I’m learning ML at the moment, Haskell looks quite similar, and I’ve wondered how practical system programming is with functional languages.
No some doubt people will laugh at projects like this. Just like it seemed insane to use a high-level language like C or PL/I or whatever for a kernel back in the days when it was all done in assembly, I think people will think the same thing again 😉
That’s quite a bit of a leap in logic, heh? Using monads means that functional languages are a pipe dream? Monads aren’t “basically imperative programming”. They allow you to do imperative things, but unlike imperative programming, don’t require you to break the rule that functions can’t have side-effects. Here is a good discussion of monads that’ll hopefully make the distinction clear: http://myweb.lsbu.ac.uk/~abdallae/units/fp/iomonads.pdf
Practically, the breaking of functional purity isn’t a big deal. The fundemental idea of functional programming, from a utilitarian standpoint, is that it allows the programmer to reduce the amount of program state he has to reason about while writing the program. That means even if you don’t write all your code functionally, you can still greatly reduce the amount of program state you have to reason about. This makes a functional style useful even in languages, like Lisp, that don’t enforce functional constructs.
For those who are curious (I had to look this up): RTS is GHC’s runtime system. It contains support routines used by the C code generated by the GHC compiler.
Eugenia, this os is kinda of unmainteined. Here is a fork for it(even has a gui =P)
http://www.cse.ogi.edu/~hallgren/House/
“””frankly, with my AI class, I have found LISP to be a very nice language in principle, but the parentheses are murder.”
Everyone seems to complain about the parenthesis until they do serious macro programming.
from what I hear from upper year students is that they don’t find Lispas clean as Scheme.
Lisp and Scheme are really kind of different, and hard to compare directly. Scheme is cleaner than Lisp in the sense that it get’s rid of some less-used features, and has a more systematic naming convention, but it also lacks some important features like objects and generic functions. It also places more emphasis on functional programming, while Lisp is more multi-paradigm and places and emphasis on macros.
Try Prolog, its perfect for AI, I did an assignment in it.
what is the best language to learn to get into functional programming? I’ve already played with languages that have some functional programming charecteristics such as Perl 5, and and generally competent in programming.
As someone with experience in Both Perl 5 and Ruby (which has even more similarities to functional languages), I would suggest O’Caml.
“what is the best language to learn to get into functional programming?”
I would suggest Scheme. Specifically, DrScheme is great for learning the concepts of functional programming. I would not suggest Common Lisp as it is a bit too large for someone just wanting a taste of the paradigm. Haskell is also good, but it is no where as simple as Scheme.
http://www.drscheme.org/
In the end, Haskell excels at solving college programming assignments designed to be….well, solved with a Haskell-type language.
Its a cool language, don’t get me wrong. I had to drop it though when trying to apply it to a “real” problem
like what?
@ Aaron
I don’t know if my Prof is going to cover Prolog, out Semester project is a LISP program that implements a Heuristic for Go Fish. the smarter the program is, the better your grade. it sounds fun, but I can’t seem to think that it would be easier done in another language…. but then again, I am just learning LISP, so everything is harder 🙂
out AI book does cover ProLog though (I am sure it is the same one you use, the big green one) I think I will play with it a bit. thanks for the tip
I should have said “I can’t seem to think that LISP would be the best language for the job”
This entry should definitely mention House [1], Thomas Hallgren, Iavor Diatchki and Andrew Tolmach made some impressive improvements to the work we did with Sébastien Carlier.
Though there still is some active thinking about hOp, not much code had been written lately, mostly because of thesis and real life issues. We are also waiting for GHC 6.4 release which will help hOp bootstrapping.
[1] http://www.cse.ogi.edu/~hallgren/House/
Well, “real” problems very quite greatly. For example, consider reasoning engines — programs that take a large set of rules as input, and decides how to end up with a state that satisfies those rules. Sounds like one of those college problems that Haskell would be good at (and indeed, it is), but such things are tremendously useful in certain application domains.
Haskell is nifty for another reason. You can systematically reason about Haskell programs. When you’re writing something to control a nuclear reactor, this sort of thing can come in handy.
Never tried LISP so I can’t compare, but here is a simple example of Prolog:
Represent three blocks on a table, block b is on block a, block c is directly on the table:
block(a).
block(b).
block(c).
table(d).
on(c,table).
on(b,a).
on(a,table).
Querying if a block ‘z’ is on the table would entail:
?- on(z,table).
Yes.
Or what blocks are on the table (note the capital):
?- on(Z, table).
c;
a;
No.
Btw: It uses depth first searching.
As you said about LISP, I can’t think of a better language for AI than Prolog. Hope this is of some interest
AI is an extremely broad field, so it is easy to imagine that some languages would be really good for one branch of AI and some other languages for another branch. Prolog for instance was originally built for natural language programming (It’s also really good for compiler writing).
One of the reasons that Prolog never really caught on as much as Lisp though is that Lisp had ~10 years of a head start so its implementations were always _much_ faster. Of course now days the situation may have changed, but Lisp has long had a mindshare advantage over Prolog.
“[monads] allow you to do imperative things, but unlike imperative programming, don’t require you to break the rule that functions can’t have side-effects.”
This is not entirely true. Using monads you have a purely functional program (which you can reason about in the way you describe), but that program constructs as its result an imperative program which is then executed. I.E. you get all the hassles again, and it’s even *harder* to reason about because you have to deal with code that is hidden under data.
That is, with monads you program partially functional, partially imperative. A program will only be maintainable if you balance the two well, and that’s very much the same with traditional languages such as C.
That said, typical C programmers usually don’t find the balance at all so it might not be bad to teach them using monads
Can we actually have some comments on hOp and House?
Monads are just one way to handle mutable data in a pure functional language. Another way is uniqueness typing http://en.wikipedia.org/wiki/Uniqueness_type . I think that uniqueness typing is much easier to understand for people coming from imperative languages (almost everybody).
Advocates of functional languages should stop insisting that everybody has to use monads and instead advocate uniqueness typing. This is the only way that functional languages can become mainstream.
What is the best for functional programming (0)Caml or Haskell ?
> What is the best for functional programming (0)Caml or
> Haskell ?
Scheme. Or did you really expect a serious answer to such a question? Read some tutorials and decide for yourself.
Btw. What is the best for editing, Vi or Emacs? *SCNR*
>> Btw. What is the best for editing, Vi or Emacs? *SCNR*
cat
Depends
Haskell is american , (O)Caml European.
By default
Haskell is largely used in US,
(O)Caml in Europe.
> Haskell is american , (O)Caml European.
Erm from the article “hOp is a micro-kernel based on the RTS of GHC.” — the G in GHC stands for Glasgow.
Sorry to be offtopic but there is a language called Curry that integrates Functional and Logic Programming paradigms. Also there is Nemerle, which is a functional language that works with .Net and Mono (unfortunately it lacks many of the cool features of Haskell at this point, like lazy processing, list ranges, and list comprehensions).
You should have posted a link. I found this: http://www.informatik.uni-kiel.de/~mh/curry/
Erlang is designed for concurrent and distributed programming, it is a functional language as well. It inherited its syntax from Prolog for a great deal.
http://www.erlang.org
Most functional languages have not managed to leave the ivory towers yet, while Erlang is used in the telecommunication industry.
I would recommend every developer to learn a bit of Prolog and some functional language just to broaden the mind to see how different programming can be done.
Regards,
Marc