functional languages -- any recommendations?

J

Josh Cheek

[Note: parts of this message were removed to make it a legal post.]

Haskell, Scala, or Erlang? Which one is the best?
I don't know, but I did enjoy Try Haskell (http://tryhaskell.org/) It's
based off of _why's Try Ruby. It goes pretty quick, though I already had a
pretty good idea how it should work and what to expect.

Haskell will be my next language (okay, after I put some time into
JavaScript) because I'm fascinated by its laziness and its type system
(that, aside from all the stuff that comes from being functional).

I also intend to put some time into Clojure, which I've played with a few
times.
 
P

Phillip Gawlowski

Haskell, Scala, or Erlang? =A0Which one is the best?

That would depend on what you mean with "best".

AFAIK, of the three you mentioned, Erlang is in widest use, but that
doesn't mean that it is "the best", either (but it'll be easier to
find real-world examples).

And just to make a bad situation worse, let me throw out Clojure, for
when you are dealing with a JVM, F# if you are dealing with .NET (I
have no idea about Mono support), or Scheme if you are coming from a
LISPing background (pardon the pun).

--=20
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.
 
T

Tony Arcieri

[Note: parts of this message were removed to make it a legal post.]

Haskell, Scala, or Erlang? Which one is the best?


Erlang is surprisingly close to Ruby in ways you would not believe.
 
P

Peter Hickman

You could add Clojure to that list, it would probably be a better
(more marketable) skill to acquire than erlang or haskell and less of
a learning curve than scala (YMMV).

But you could probably pick up erlang pretty fast regardless.
 
B

Brian Candler

7stud -- wrote in post #990914:
Haskell, Scala, or Erlang? Which one is the best?

I'd say Erlang would be the easiest to get your head round. It lets you
create lightweight processes which can send explicit messages to each
other, and keep their own state. This is pretty similar to the concept
of "objects", except because it uses real message passing, it eliminates
many of the problems of threads. Furthermore, your processes could be on
the same machine or on different ones, and nothing changes in the code.

Calling a function in Erlang can have side effects (in particular, the
sending of a message), and hence it's not a true functional language.
 
J

Johnny Morrice

Haskell, Scala, or Erlang? Which one is the best?

What about Racket, the descendent of PLT scheme?

http://racket-lang.org/

I'd say it's just as good for learning about functional programming as
the others, but it also makes it easy to write something useful.

For instance, it has a nifty DSL for writing web-sites. Unimaginatively
of me, here is an example from their home page:

#lang web-server/insta
;; A "hello world" web server
(define (start request)
(response/xexpr)
'(html
(body "Hello World")))

The standard libraries include a web-server, and if you use that DSL,
it'll start it up for you, and just serve your site, no extra
configuration required. Which is pretty cool for learning at least.

It comes with OpenGL too, which is great if you like writing games :D

Also, it supports objects and classes, so you won't into the problems
described below.

Not so many libraries as Scala and Haskell though. And slower too.

You can tell I'm a "fan-boy". I swear I'm not a PLT plant!

But on to the others:

Haskell doesn't have the feature called inheritance in Object Oriented
Languages*.

Living without objects is okay, but it means you can't create a new
data-type that inherits members from another data-type.

It has other mechanisms for code-reuse, but sometimes things which
would be really simple with, for example, a template method, into a bit
of an exercise in formal logic. Still, that's okay because that's
pretty much how you program the whole of the system in Haskell.

Haskell has a really cool macro system called Meta-Haskell. It's
basically like an interface to a compiler front-end so you can create,
explore or transform a Haskell abstract syntax tree, or fragments
thereof. It's super-awesome :D

Erlang doesn't have inheritance either but it doesn't become an exercise
in logic the same way because it doesn't have static-typing.
IIRC their structures are just transformed into a vector or something at
compile time, there's no real notion of a member of a data-structure.

I really like erlang though, the syntax is cool. Commas.

Apologies for the long post!

* Haskellers would probably call inheritance "sub-type polymorphism",
sitting in their tweed and smoking their pipes, etc.
 
J

Johnny Morrice

Haskell doesn't have the feature called inheritance in Object Oriented
Languages*.

Living without objects is okay, but it means you can't create a new
data-type that inherits members from another data-type.

It has other mechanisms for code-reuse, but sometimes things which
would be really simple with, for example, a template method, into a
bit of an exercise in formal logic. Still, that's okay because that's
pretty much how you program the whole of the system in Haskell.

Now that I think about it, the template method is a bad example.

In Haskell you can inherit from abstract interfaces - you can't inherit
from a data structure.

So you can easily have a template method, it's just that it would have
to defined as part of the abstract interface.

So each child that implements the template would have to implement the
interface. Then since you can't inherit from the data type, the
children must be a whole new type which has the parent as a member, and
pass that to the template method.

At this point any functions which could have been run on the parent
will now have to be reclared for the child :(

Then again with the separation of code and data you start to consider if
that really is the structure of your program.

But usually by that time in Ruby, I'm already done!

In conclusion, I'm too stupid to program in Haskell. If you choose it,
good luck.

Cheers,
Johnny
 
B

Brian Candler

Johnny M. wrote in post #990966:
Erlang doesn't have inheritance either but it doesn't become an exercise
in logic the same way because it doesn't have static-typing.
IIRC their structures are just transformed into a vector or something at
compile time, there's no real notion of a member of a data-structure.

You're probably thinking of "records", which are basically just named
offsets into a tuple.

There are proper data structures too, such as "dict" which is somewhat
like a ruby Hash.

It can be a bit overwhelming at first having all the different built-in
types: tuple, list, binary (when you'd just use Array in ruby)
I really like erlang though, the syntax is cool. Commas.

It takes some grokking as to when you need a comma, when you need a
semicolon, and when you need a dot. Erlang has great semantics and
terrible syntax.
 
J

Johnny Morrice

You're probably thinking of "records", which are basically just named
offsets into a tuple.

Hey yeah I was!
There are proper data structures too, such as "dict" which is
somewhat like a ruby Hash.

I have should said I meant user defined data structures.
It can be a bit overwhelming at first having all the different
built-in types: tuple, list, binary (when you'd just use Array in
ruby)

binary is not so unusual, kinda like bytestrings in python, or
Haskell., Except in Haskell a bytestring is user defined rather than
built in.
It takes some grokking as to when you need a comma, when you need a
semicolon, and when you need a dot. Erlang has great semantics and
terrible syntax.

Okay, I concede the point. I am utterly wrong. But I still enjoy the
asthetics. It's sort of like a sentence in English.
 
B

Brian Candler

Johnny M. wrote in post #991021:
Okay, I concede the point. I am utterly wrong.

No, not at all. I made my point badly: *I* find Erlang's syntax to be
terrible, but syntax is clearly a very personal choice.
 
S

serialhex

[Note: parts of this message were removed to make it a legal post.]

If you're lookng into haskell, you could give huburis a try (I dont have a
link right now, but its on github by a guy named mark watton) it let's you
run haskel code/programs within ruby. Not what you want if you're aiming
for that "pure functional" feel, but I thought i'd mention it.
hex

an Android sent this

No, not at all. I made my point badly: *I* find Erlang's syntax to be
terrible, but syntax is clearly a very personal choice.
 
T

Tony Arcieri

[Note: parts of this message were removed to make it a legal post.]

No, not at all. I made my point badly: *I* find Erlang's syntax to be
terrible, but syntax is clearly a very personal choice.


I'm annoyed by there being 4 different types of statement endings, 3 of
which look like ant turds
 
S

serialhex

[Note: parts of this message were removed to make it a legal post.]

i think you are totally wrong about #{language_you_use} because
#{feature_i_think_sucks} makes the language unintelligible. personally i
find #{language_i_use} to be the uber be-all-end-all of languages.

though i do agree that #{current_thread} is kind of wonky :p
hex

#{hex.laughs_maniacally}
 
J

Johnny Morrice

i think you are totally wrong about #{language_you_use} because
#{feature_i_think_sucks} makes the language unintelligible.
personally i find #{language_i_use} to be the uber be-all-end-all of
languages.

though i do agree that #{current_thread} is kind of wonky :p
hex

#{hex.laughs_maniacally}

Oh dear, we're onto meta-recommendations.

(Anyway the language I use is clearly better (as long as you like
parenthesis))

Some others tried to be serious; they tried to write in a sensible way,
but were actually writing in Erlang.

And as I said my personal opinion is that haskell = hard.

/hangs self
 
7

7stud --

Johnny M. wrote in post #991283:
And as I said my personal opinion is that haskell = hard.

I made it to chapter 5 of Real World Haskell before drowning in a real
world JSON example.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top