Sign in to follow this  

I'm looking to learn a new language - something "different"

This topic is 3666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I come from a background that started with some BASIC languages, and has been predominantly C, C++ and C# for the past 3 years. Recently I've been dabbling in Python and really like this language and it's dynamism, and it's made me think that I really need to start looking in to other programming languages and paradigms. At the moment SmallTalk is really taking me, but I haven't started any work with it yet. I did a reasonable amount of work with Objective-C (4-5 months; enough to get a nice feel for the language) and really liked it. However, Objective-C seems based on SmallTalk - so I'm not sure I'll get much from learning SmallTalk as well. I've seen a lot of interest around Erlang and Haskell recently, and haven't touched either of these languages. Does anyone have any suggestions? Look forward to hearing what you suggest!

Share this post


Link to post
Share on other sites
Interesting to see Ruby there, I thought of it as just another python-copy language. How wrong am I it seems :) I will look into Ruby more (more than just that poignent guide, that is).

Thanks for the feedback about Haskell too - I've heard about the pains of monads... learning them is going to be fun :P

Share this post


Link to post
Share on other sites
Monads are no harder to understand than pointers, or recursive functions, or any other programming concept. They are just "different" - exactly what you are looking for!

I tried learning haskell several times, each time giving up, before finally actually getting that "aha" moment that people talk about, the moment where something switches in your mind and changes the way you think about programming. I had been programming in various languages for several years, but in that moment I was hit with the understanding that programming can be so different! That there is this huge world of programming ideas that 99% of programmers aren't even aware of. I felt the same kind of excitement that I felt the first time I programmed in qbasic and made a pixel animate across the screen.

Haskell is the most powerful language there is [*]. It is also one of the simplest, with only a handfull of keywords, and no builtin types. It's syntax is elegant and readable. It's my favorite language.

By the way, you can do lots of interesting things in haskell, without using monads!

[*] Apart from the more extreme academic languages, which aren't yet "practical"

Share this post


Link to post
Share on other sites
I'll throw in a vote for Erlang, especially if you're working on applications which require a lot of concurrency or network stuff. For these types of applications I'd not consider using anything else anymore - Erlang is just too awesome.

Share this post


Link to post
Share on other sites
APL, J, or K. J is probably easiest for you to get your hands on.

Loopless programming is going to blow your mind much, much more than 'monads'. And tacit programming? Yikes.

Example:

quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)

Exactly.

But if not, then I would go with Erlang or Ruby. I have always enjoyed Ruby's meta programming abilities, though it truly is horribly slow. Erlang is nice, if you don't already know another functional language. If you do, then just learn Erlang's message passing structure. Learning the actual syntax probably isn't as important, IMHO.

Share this post


Link to post
Share on other sites
I vote for a functional programming language too. I only used Standard ML and OCaml (wich are very similar) so perhaps there are better/nicer alternatives out there. I add that I didn't liked them much (I wouldn't like a job that asked me to use them, nor I would use them for my personal projects, unless they really were the better choice) but being forced to use recursion everywhere is a good training. I suppose that they improved my programming a lot.

Share this post


Link to post
Share on other sites
Quote:
Original post by visage
APL, J, or K. J is probably easiest for you to get your hands on.

Loopless programming is going to blow your mind much, much more than 'monads'. And tacit programming? Yikes.

Example:

quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)

Exactly.
Bugger that! Talk about cruel and unusual punishment!

Well if you want to broaden your paradigms experience then you almost certainly have to jump into using Prolog, or even Mercury.

Share this post


Link to post
Share on other sites
Ruby is very similar to Python. Smalltalk is similar too, but it usually runs in an "image" environment.

If you want to go all the way into functional programming then I'd recommend Haskell. Erlang or OCaml would be good choices too.

Quote:
Original post by johnfarris
Monads are no harder to understand than pointers, or recursive functions, or any other programming concept.

I agree. I think all the nuclear waste metaphors and stuff people put in their tutorials just confuse people. If you learn algebraic data types, type classes and higher order functions then monads should be straightforward. A monad is just an instance of the Monad type class satisfying 3 rules.

And until you learn those things and so can understand monads properly, there is The IO Monad for People who Simply Don't Care (you need to use the IO monad for any IO your program does).

Share this post


Link to post
Share on other sites
If you want a language which is different, and might just possibly have some practical use (maybe), and is well-known, I'd vote for Haskell.

If you want a language which is different, and a bit novel, I'd vote for this

Share this post


Link to post
Share on other sites
Allllriiiight! Thanks for the feedback guys :) I'm going to pop a Haskell book on my christmas list - any ideas? LOok forward to twisting my brain soon, hehe.

Thanks for all the feedback, very helpful.

Share this post


Link to post
Share on other sites
Quote:
Original post by TheUnbeliever
Haskell is gorgeous (although monads mess with my mind, at least, and the information on them is spread fairly thin).

I think it's improved my programming considerably.


I'm teaching myself Haskell for exactly the same reason: To learn something different. I chose Haskell because of this thread on Gamedev and seem to like it so far.

Next to that I'm also trying to teach myself Python, which is also a very nice language to know imho.

Share this post


Link to post
Share on other sites
I agree, Haskell is something which will mess with your mind, and probably for the better. I'm just finishing my CS class at Dartmouth on Haskell, and I'm finally starting to get it, and I definitely feel it's improved my programming in other languages.

I'd recommend Paul Hudak's The Haskell School of Expression, which is the book we used for my course. It gives a pretty good overview, I felt, and covered some cool applications that demonstrated the power of Haskell.

Share this post


Link to post
Share on other sites
Quote:
Original post by johnfarris
Monads are no harder to understand than pointers, or recursive functions, or any other programming concept.

I tried learning haskell several times, each time giving up, before finally actually getting that "aha" moment that people talk about


I can't remember having had that kind of difficulty with pointers or recursive functions, myself. Maybe I'm just special? :) I've never really been able to understand monads from an English description, though.

Quote:
By the way, you can do lots of interesting things in haskell, without using monads!


Can you do I/O?

Quote:
Apart from the more extreme academic languages, which aren't yet "practical"


A lot of people think Lisp (and its many, many offspring) is (are) quite practical.

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
Quote:
By the way, you can do lots of interesting things in haskell, without using monads!


Can you do I/O?


No, you can't do I/O without using the IO monad. But you can still write interesting programs and run then from the haskell prompt. An example would be a raytracer that renders using ascii art. I actually did this as one of my first haskell programs :)

Also, you can do I/O using monads, without really understanding them. Just like you can learn C++ and write [cout << "Hello"] without yet understanding classes or operator overloading.

Quote:

Quote:
Apart from the more extreme academic languages, which aren't yet "practical"


A lot of people think Lisp (and its many, many offspring) is (are) quite practical.


I agree that lisp is very practical and an excellent language. But haskell is more powerful than lisp.

Share this post


Link to post
Share on other sites
Quote:
Haskell is the most powerful language there is [*].


Finally, someone has found the One True Metric for gauging programming language power across the board.

We can all stop having language wars now, scrap all other languages and start using Haskell. It is, after all, the Most Powerful Language, without qualification.

Quote:
It is also one of the simplest, with only a handfull of keywords, and no builtin types.
That is just unmitigated bollocks. Haskell is very complex, with special syntax for everything under the sun.

You have syntax for monadic bind and return.

You have syntax for making monads look imperative (do notation).

You have two different syntactic constructs for binding (where and let clauses).

You have syntax for list comprehensions.

You have the seq operator and its twenty best friends, which subtly mess up parametricity.

You have at patterns.

You have 9 (or is it 10) arbitrary levels to specify operator precedence...

Nobody calls Haskell simple: don't take my word for it, read

"A history of haskell: being lazy with class" by Simon Peyton Jones and the other Haskell guys. Even they call the language complex.

This isn't a bad thing necessarily, but saying Haskell is one of the simplest languages is like saying elephants are one of the smallest mammals.

Quote:
I agree that lisp is very practical and an excellent language. But haskell is more powerful than lisp.
Does it shoot laser beams from its eyes? Could it beat up lisp if lisp fought dirty?

Share this post


Link to post
Share on other sites
Quote:
Original post by Anonymous P
Quote:
Haskell is the most powerful language there is [*].


Finally, someone has found the One True Metric for gauging programming language power across the board.

We can all stop having language wars now, scrap all other languages and start using Haskell. It is, after all, the Most Powerful Language, without qualification.


I didn't say that haskell is the *best* language. Other languages have better libraries, better debuggers, faster compilers and larger communities. "Power" is an ambigious word, but haskell has a property that allows you to write programs that are shorter and simpler than they would be in other languages. People can have different opinions about programming languages, and some people may hate haskell because they don't like for example its syntax. But at it's core, haskell's features simply offer more then what you get in other languages.

Quote:

Quote:
It is also one of the simplest, with only a handfull of keywords, and no builtin types.
That is just unmitigated bollocks. Haskell is very complex, with special syntax for everything under the sun.

You have syntax for monadic bind and return.


This is false. bind and return are regular haskell functions implemented in it's standard library.

Quote:

You have syntax for making monads look imperative (do notation).


do notation is syntax sugar.

Quote:

You have two different syntactic constructs for binding (where and let clauses).


where is syntax sugar that transforms into a let clause.

Quote:

You have syntax for list comprehensions.


syntax sugar that transforms into application of map and fold functions.

Quote:

You have the seq operator and its twenty best friends, which subtly mess up parametricity.


I agree that `seq` is complex, but it's an advanced feature of the language, at the same level as c++ template meta programming.

Quote:

You have at patterns.


Pattern matching is part of the core language and is truly simple.

Quote:

You have 9 (or is it 10) arbitrary levels to specify operator precedence...


Do you have any better ideas?

Quote:

Nobody calls Haskell simple: don't take my word for it, read

"A history of haskell: being lazy with class" by Simon Peyton Jones and the other Haskell guys. Even they call the language complex.


Yes, haskell has grown lots of warts over the years, but overall I think that it has managed to maintain its simplicity.

Quote:

This isn't a bad thing necessarily, but saying Haskell is one of the simplest languages is like saying elephants are one of the smallest mammals.


The list of arguments you gave are mostly syntax sugar features, which are trivial to understand once you understand the underlying concepts. Here is a quote from an article that I link to when I address your final point:

"If you've got a class full of first year computer scientists, you can teach them to read and understand the full formal semantics of Haskell. You can make it completely non-mysterious. Everything can be explained by the standard lambda calculus alpha, beta, and eta rules, with no hidden complexities. It's all remarkably straightforward."

Now think of C++ or Java, where no formal semantics exist. A stripped down version of java called feather weight java has formal semantics that are more complex than those of haskell, and you are left with a language at the level of basic.

Quote:

Quote:
I agree that lisp is very practical and an excellent language. But haskell is more powerful than lisp.
Does it shoot laser beams from its eyes? Could it beat up lisp if lisp fought dirty?


Here is a good article that compares Haskell and Scheme, a cousin of lisp:

http://scienceblogs.com/goodmath/2006/10/haskell_and_scheme_which_one_a.php

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
Can you do I/O?

No. But if you only want to do IO, you don't need to know much about monads at all, as johnfarris says. The IO Monad for People who Simply Don't Care should provide enough guidance to do IO until you have learnt enough to know what a monad is.

Quote:
I've never really been able to understand monads from an English description, though.

Once you know what a type class is, what a higher order function is and what an algebraic data type is it shouldn't be hard.

A monad is a type which implements this type class:

class Monad m where
(>>=) :: m a -> (a -> m b) -> m b
return :: a -> m a

return takes a value and "puts it into" the monad. >>=, "bind" applies a function to the value "in" the monad, and usually does something else too depending on the particular monad.

There are some rules for monads that should hold (you mostly only need to worry about these when writing a monad, not using one:

(return x) >>= f == f x
m >>= return == m
(m >>= f) >>= g == m >>= (\x -> f x >>= g)


This is similar to the rule that for anything that supports multiplication, the Associativity rule should hold:

(a*b)*c = a*(b*c)


Some monads are Identity, which is the trivial monad - >>= just does regular function application; Maybe, which adds a check for Nothing in >>= so you don't have to; State, which chains some state along in >>= so you don't have to.


Quote:
Original post by Anonymous P
Haskell is very complex, with special syntax for everything under the sun.

I don't agree. Most of the complexity you mention is only syntactic complexity. The semantics of Haskell is really quite simple - it's roughly call-by-name lambda calculus.

Some of the stuff in the IO monad is more hairy, because of the stuff it deals with - mutable state, IO, etc; but that's the same for any language. I agree with you about seq, but it is mostly used for low level optimisation so it's not a big deal.

Where and let and comprehensions are all just sugar. They are trivial to understand. The purpose of macros in Lisp is precisely to create your own sugar and syntactic transformations, so I don't think you can argue it is simpler in that area.

In the "A history of haskell: being lazy with class" article you mention, they say syntactic complexity is only "superficial". Haskell's type system has some semantic complexity because of type classes, which is the real complexity they talk about.

On Lisp vs. Haskell: they are obviously both great languages. We don't need to get into that argument, although I have my own preference.

Share this post


Link to post
Share on other sites
Quote:
Original post by johnfarris
Monads are no harder to understand than pointers, or recursive functions, or any other programming concept. They are just "different" - exactly what you are looking for!


Sure, and I'm starting to get a grip of them. However, I'm trying to see the connections between the abstract theory and the real world (ie monads in Category Theory vs monads in Haskell) and finding information that isn't trivial or far beyond my ken (at the moment) is pretty tricky. There seems to be something of a dearth of in-between information (or maybe I just need to stop being a cheapskate and buy a book!). In terms of actually just using them, though, it's not too bad (do notation, <-, >>, >>= seem to comprise all the tools you need).

I can't speak for others (such as the OP), obviously. This is just my experience (I find both pointers and recursion—as well as most of the functional paradigm idioms—easy to understand intuitively; perhaps it is simply the fact that it is different, as you say). Certainly I've enjoyed that experience thus far, which might also commend it to the OP if that's something he's looking for.

I've watched Lambda-the-Ultimate, for example, but a lot of it is heavy going. FWIW, I also find a lot of Rebooted's posts quite enlightening. :-)

Share this post


Link to post
Share on other sites
Quote:
Original post by Rebooted
Quote:
I've never really been able to understand monads from an English description, though.

Once you know what a type class is, what a higher order function is and what an algebraic data type is it shouldn't be hard.

A monad is a type which implements this type class:

class Monad m where
(>>=) :: m a -> (a -> m b) -> m b
return :: a -> m a


return takes a value and "puts it into" the monad. >>=, "bind" applies a function to the value "in" the monad, and usually does something else too depending on the particular monad.


So something like this?


template <typename a>
class Monad {
a value;
public:
// 'return'
Monad(const a& value) : value(value) {}
template <typename func, typename b>
// C++'s type system does not describe the exact type of 'func' where Haskell does
Monad<b> bind(func f) {
// possible side effect here
// Identity does nothing
// Maybe bails out if value is Nothing
// (which is a bottom type, yes? How does that work (get implemented) in a static typing system?)
// State... stores state somewhere? Er?
return f(value);
}
};

// 'return' needs to be a free function so that we can talk sanely about the
// rule "m >>= return == m". Of course, 'return' is a C++ keyword...
template <typename a>
Monad<a> ret(const a& value) { return Monad<a>(value); }

Share this post


Link to post
Share on other sites
Monads are a specific case of a generalization of algebra.

The other day I stumbled on this video when looking for some info on F sharp: Brian Beckman: Don't fear the Monads. The guy Brian Beckman is legendary and overflowing with knowledge. He ranges across group theory, lambda calculus and category theory without even once giving away that he is going over some abstract maths.

There is also the youtube series by the casters monads. Warning: Requires Category theory knowledge

Share this post


Link to post
Share on other sites

This topic is 3666 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this