Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] recomendations for a functional language



On Wed, Nov 4, 2009 at 3:04 PM, Curt Sampson <cjs@example.com> wrote:
> On 2009-11-03 14:02 +0100 (Tue), Attila Kinali wrote:
>
>> Hmm.. didn't we had a discussion on STM just a few months ago?
>
> Yup. That, I believe, was before I'd learned about how STM works in C,
> and so I didn't understand that the cool thing Haskell had was not STM
> itself, but Haskell's type system that makes STM practical.
>

Could you elaborate why haskell's type system make STM practical?

For me it's haskell's purify, since the efficiency of STM largely
depends on whether you can successfully partition the data to avoid
conflicts.

> Common lisp has various looping constructs, and the standard doesn't
> require tail call optimization (though many compilers do provide it),
> so a program that uses tail recursion over large data structures
> or whatever is not guaranteed not to blow up the stack on some CL
> implementations. (Scheme requires tail call optimization.) So that was
> why I reckoned that CL encouraged looping rather than recursion, and why
> I'm a little doubtful about Stephen's correction on that. But he would
> probably know better than me.
>

Tail calls are structured gotos, if you look it that way, you might
feel loops are abstractions of tail recursions. But sometimes tail
recursions are more handy, ex. a state machine.

>> What would you say about first learning Scheme and then going Haskell?
>> Scheme has the very persuasive property of being compact which
>> promises that i get a quick start and do the tedious learning of
>> concepts as i walk along a nice path.
>
> I'd say don't bother, unless you intend to do some serious research
> into programming with macros. Haskell has marginally more syntax than
> Scheme, but for learning the basics that Haskell and Scheme have in
> common, the languages will be about equally easy to start with. Haskell
> is quite as compact as Scheme, by the way, probably more so as you get
> more sophisticated with it.

Why not both? Macros is a reason good enough. And there's first class
continuations. Actually Scheme is a very low-level language for
understanding how to program, which could be as enlightening as
Haskell.

>> And, if i understood you correctly, Haskell seems to be a superset
>> of concepts of Lispy and other functional languages?
>
> Right. Syntax differences aside, you can think of ML as being much like
> a Lisp with a different syntax, no macros, and a Hindley-Milner type
> system. Haskell adds purity, changes evaluation from strict to lazy, and
> gives you libraries full of Monads.

Wrong. Haskell is too far from Lisp.

1) Lisp is all about macrology.
2) Lisp is dynamic and all the reflexive.
3) Lisp is about incremental development.
4) Lisp is about hooking to the compiler and runtime.

which I don't think any of the Haskell implementation focuses on currently.

>> Can you elaborate that a little bit?
>> I didn't know about H-M before and cannot immediatly see what
>> makes it more powerfull than the dynamic typing i'm used from
>> dynamic languages.
>
> With dynamic typing, if you make a mistake, you have a failure at
> runtime. Static typing systems offer a computer-verified proof that
> certain types of failures cannot happen at runtime (baring something
> like hardware failure). That means you don't need to bother to test
> certain parts of your code, since you've got a proof that they cannot
> fail.

It still can fail. ex. stack overflow is a common mistake. Holding but
not releasing resources is another. And deadlocks. It depends on how
much and which aspect of my program the type system can prove.Though I
agree Haskell's type system eliminates a large proportion of errors.

We programmers can take it if the errors we didn't understand or
couldn't foresee, but for trivial errors, it's a shame. So it's more
of a psychological boost. Static type system gives you a safe belt so
you will feel you are protected, but never try driving over 180.


Cheers,
Jianshi


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links