Working with the federal government is daunting. You have to fill out a ton of paperwork and it must be done precisely. Any mistakes and the spit it back at you with no compromise. However, once you get all the paperwork submitted, then you have a tremendous amount of comfort because you have a big powerful machine on your side.
Let's see why this reminds me of Haskell: you have to do a tremendous amount of type-checking and you must do it precisely. One you get all of your types and values lined up, then you have a powerful optimized program ready for reliable execution.
I do my best to avoid putting the same logic in two places in an application. However, my stored procedurees will require computations to be in other stored procedures.
Should my programming language access all of it's business logic from database stored procedures? But then I lose the power of a full-fledged programming language and must do everything in a kludgy pascal-like language.
I suppose the solution is to have the business logic/calculation in both places. Perhaps the program logic could generate the stored procedure logic???
HTML::Mason (www.masonhq.com) is a Perl module that would make most Haskellers cringe. It is the most confused domain-specific-language you can see: Perl embedded in HTML.
But Mason is in wide use at amazon.com. In addition I just interviewed for a Perl poisition at the largest Oracle database installation in the world. And they are planning to move to Mason for HTML/XML/SOAP delivery... why would they do this? Because Mason can stream HTML data: instead of building up an entire XML document and then sending it, it can stream parts. When the document is _huge_ this becomes crucially important: render some of the xml, ship it off, reclaim the memory and keep on truckin'...
How could a lazy functional language achieve the design goal eagerly streaming data as opposed to lazily producing it on demand?
After tripping and stumbling through "Gentle" and "YAHT", I am worlds grateful for "Craft of Functional Programming" He is not just teaching Haskell, he is teaching you how to think about problem solving.
The reason I am so excited is he gave the following exercise:
Give a function orderTriple which puts the elements of a triple of three integers into ascending order.
Ok, so far, just an ordinary question. And in most other cases that's all you would get. In YAHT, you would have copious exercises like what you just saw. In Gentle, he would show you the solution and keeping moving. It is the next sentence in this exercise that sets Thompson apart from the crowd:
You might like to use the maxThree, middle, and minThree functions defined earlier.
Kapow! After reading the first part of the exercise, my mind immediately began to scramble over how to maintain state and iterate through the elements, deleting them as I found their place.
But then Thompson *decomposed* the problem into 3 simpler problems for me!
While googling for a Haskell average function, I came across this:
Haskell dating. Find dates at Date.com's personals for Haskell, Oklahoma. Tired of speed dating? Try speed dating online with date.com. This free Haskell online dating site contains thousands of Haskell singles. Casual Haskell dating or serious Haskell relationships, are you single and lonely? Create a FREE Haskell singles ad and start dating online. Find your Haskell singles in Oklahoma, USA.
and of course we can't forget the data constructor right there on the website:
Haskell Singles | Haskell Personals | Haskell Chat | Haskell Speed Dating | Haskell Love |Haskell Christian Dating | Haskell Catholic Dating | Haskell Muslim Dating
We think of the tree as a first class value “all at once” but it is only materialised “piecemeal”
-- Simon PJ " Composing contracts: an adventure in financial engineering"
[07:23] [metaperl] The Haskell Road To Logic, Maths And Programming has a very seductive intro and table of contents... I am starting to realize that I am going nowhere in Haskell unless I learn to thi\
nk and know functions well... humbling after 5 years as a well-paid Perl programmer
[07:23] [RemiTurk] false = \x y -> y
[07:23] [RemiTurk] if = id
[07:24] [RemiTurk] not = flip
[07:24] [shapr] metaperl: I realize I'm not learning much if I don't get humbled on a regular basis.
[07:24] [xerox] metaperl: I am reading it too!
[07:24] [metaperl] xerox, do you like it?
[07:24] [xerox] metaperl: I'm just at page 28, good so far.
[07:25] [shapr] http://lambda-the-ultimate.org/ is one good place to find humbleness. I also like to put forth my ideas in my blog and here on #haskell and ask people to poke holes. That mostly works.
[07:27] [xerox] metaperl: do you like it?
[07:27] [metaperl] I'm thinking about buying it
[07:28] [shapr] Isn't it free online?
[07:28] [metaperl] I think you are just playing with air until you lock in a rigourous command of logic and functions. And this book doesnt play around... it takes you right to the foundation and build\
s you up from there
[07:28] [metaperl] the first chapter and toc is
[07:28] [metaperl] all the other books give you a chance to fool yourself about knowing haskell --- not this one
[07:28] [metaperl] this book puts logic first and the language second
[07:28] [xerox] shapr: no it isn't :\
[07:29] [metaperl] all the others put the language first and hope you can build the logical reasoning... and it wont happen
[07:29] [shapr] Strange, I wonder where I got my ps.gz copy.
[07:29] [xerox] Its first example is a prime number test, it first prove to you some things -mathematecally- then implement it in Haskell, err, rewrites the proofs in Haskell :D
[07:30] [xerox] shapr: hm, it could be really.
[07:30] [xerox] http://homepages.cwi.nl/~jve/HR/
[06:28] [autrijus] shapr: I'm changing the Pugs evaluator into a compiler
[06:28] [vegai] metaperl: yes
[06:28] [shapr] autrijus: yay!
[06:28] [autrijus] shapr: without touching a line in Eval.hs
[06:28] [shapr] wow
[06:28] [metaperl] ooooooooooooooooooooooooooooooooooooo
[06:28] [autrijus] shapr: simply by redefining the Eval monad and some TH magic
I think Haskell is the best computer programming language. I say so for two reasons. First, the community of people is excellent. I have yet to see one arrogant hothead anywhere. I have had discussions with some of the best Haskell programmers out there with absolutely no sense of them thinking they are better than me. Having been around Perl for 5-7 years, let me tell you, it is rough in Perl world. And there are plenty of arrogant, egotistical self-centered people in that community. In fact, I suppose being around them has made me that way as well. Haskell is also the best computer programming language because of it's wonderful mix of strong typing and pure functional approach. Finally, haskell is an amazing project to be the result of a community effort. How in the world could a group of people get together and not simply fight and bicker and never agree? Perl was a 1-man language. Emacs was a 1-man language. Ditto for Tcl, Python and I guess PHP. Unix was a 2-man project.
Anyway, now that I have said how great a _language_ Haskell is, let us note its chief deficiency. No available functionality. I remember 2 weeks ago Philippa was asking in #haskell about whether another person had a CGI extension to deal with cookies... Perl has had this since the dot-com era! Perl has search.CPAN.org, which is a huge library of modular functionality for a plethora of real-world scenarios.
Now, let's move on to PHP. From a purely linguistic perspective, PHP is a worse language than Perl: http://tnx.nl/php. BUT from an application perspective, it outdoes Perl. I did not say from a modular/functionality perspective, but from the application perspective.
Applications are tools that are ready to run. Modules are pluggable units of functionality to build applications. Functions are even smaller units of pluggable functionality to build applications. Abstractly, applications, modules and functions all fill a gap. Applications fill the largest gap, modules fill the medium gap and functions fill the smallest gap. The relation between immediate ability to fill a gap and language quality is inversely proportional. Or, concretely: PHP sucks as a language, but rules in filling the biggest gap in apps. Haskell rules as a language, but sucks in filling application and modular gaps. And Perl is right in the middle. It is a decent language with great ability to fill in the middle gaps. It is not as composable as haskell and thus cannot compete in filling in small gaps. It lacks good, out-of-the-box applications like phpMyAdmin and Drupal and postNuke, and phpBB.
/me dons flame-retardant vest.
This article by Wadler is really quite astounding:
He shows how to create variations of an interpreter using monads and discusses the superiority of the monadic approach of the CPS approach.