Functional Language of choice?

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »

63 Replies - 7195 Views - Last Post: 26 July 2011 - 06:52 PM

#1 NickDMax   User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2255
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Functional Language of choice?

Post icon  Posted 25 July 2011 - 12:41 PM

*
POPULAR

I have been reading a lot of very "advanced" blogs on C++ recently (great detail into how Boost works, how to use boost, how stl works, the refactoring effort to being stl up to C++0x).

Much of this flies right over my head and as I play catch-up it occurs to me that the main reason is that I have not really paid all that much attention to functional languages.

Sure I have used Mathematica a great deal in a functional sense but have not really thought too much about it outside of mathematics. You know I don't even know if Mathematica really has "types" - AFAIK everything is some kind of list.

So anyway, I have committed to learning Haskell (since so many C++ blogs use it as the example language).

With C++0x introducing many functional "improvements", C#, VB and Java are both adding a lot of functional enhancements and Javascript going all JQuery-esque -- how many procedural programmers are taking the time to get to know functional programming beyond a passing familiarity?

(I have a passing familiarity with Clojure, F#, Mathematica, and Scheme but actually know very little about them beyond actual calculation).

Is This A Good Question/Topic? 5
  • +

Replies To: Functional Language of choice?

#2 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: Functional Language of choice?

Posted 25 July 2011 - 12:45 PM

For what little I do with FP, I have a basic familiarity with Erlang and an even more basic familiarity with some Lisps (Scheme, Common Lisp, Clojure). I've been meaning to sit down and pick up more Erlang and start with Clojure. Perhaps at some point, I may actually follow through and learn them!
Was This Post Helpful? 0
  • +
  • -

#3 NickDMax   User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2255
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Functional Language of choice?

Posted 25 July 2011 - 12:56 PM

Well I recommend it simply because if you look at the advances in languages you find a LOT of functional thinking even in the classically "procedural" or "oop" languages.

When I was in high school I did some LISP stuff and it was neat (natural language processing) but again it kind of stayed its own domain in my head. Its hard (at least for now) for me to think of those kinds of processes in terms of say C++.

Of course ideally one would not learn a new language to teach them something about their go to language. But the thing is that C++ is so classically procedural that there is very little information to help you. The information that is out there tends to be in the language of FP and not something easily digestible by procedural programmers. (example: I am really struggling to figure out what in the hell a monad is even though I know that it is something "easy" once you "get" it... If I follow the pattern I will have an epiphany one day and write a blog post about it... which other programmers will scratch their heads at until they have an epiphany and a sudden undeniable urge to write a blog post about)
Was This Post Helpful? 1
  • +
  • -

#4 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12800
  • View blog
  • Posts: 45,992
  • Joined: 27-December 08

Re: Functional Language of choice?

Posted 25 July 2011 - 01:02 PM

It really does look neat. Before I started with Erlang, I'd never heard about structures like anonymous functions, nor really had I done a lot passing methods like I would objects in Java. Maybe after I finish my Red-Black Tree in Java, I'll sit down and work more on Erlang!

Also, I think this would make a great featured topic! :)
Was This Post Helpful? 0
  • +
  • -

#5 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1259
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: Functional Language of choice?

Posted 25 July 2011 - 02:11 PM

I love Clojure, I just wish I had the time actually sit down for a couple of months and dedicate myself fully to it. I'm waiting on Raynes book to learn about it from the ground up in a more linear approach.
Was This Post Helpful? 0
  • +
  • -

#6 ishkabible   User is offline

  • spelling expret
  • member icon





Reputation: 1749
  • View blog
  • Posts: 5,901
  • Joined: 03-August 09

Re: Functional Language of choice?

Posted 25 July 2011 - 02:22 PM

i have been learning Haskell for about a month now, it is quite interesting. it makes me think about things in ways i never even considered. i LOVE the type system. it wasn't until i realized how pattern matching worked that i rally loved Haskell. Haskell can pattern match with any constructor. this means that lists are actually objects in Haskell that have the ':' constructor. it's so elegant and simple, the creators of Haskell devolved one of the most elegant languages i have ever seen, there brilliance confounds me. i have not done anything terribly interesting with Haskell yet. i have been working on 2 mini projects and 1 big project and none of them are in Haskell so i have put the book down for now. i plan to pick it back up when i finish the other projects.

also when i went into Haskell i thought it would be horribly staticly typed with no room for implicit type behavior. holy crap, could i have been more wrong? again i come back to the type system in Haskell...it's AMAZING. even basic types implement classes(classes in haskell are more like Java interface) that make things like polymorphism possible in Haskell with basic types and user defined types.

This post has been edited by ishkabible: 25 July 2011 - 02:34 PM

Was This Post Helpful? 1
  • +
  • -

#7 NickDMax   User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2255
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Functional Language of choice?

Posted 25 July 2011 - 02:35 PM

I hope to find it as amazing as you do! Apparently the type system in Haskell has a lot to say about C++ templatemeta programming and is one of the big reasons Haskell as attracted my attention to begin with.
Was This Post Helpful? 0
  • +
  • -

#8 Curtis Rutland   User is offline

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 5106
  • View blog
  • Posts: 9,283
  • Joined: 08-June 10

Re: Functional Language of choice?

Posted 25 July 2011 - 02:42 PM

I have a passing familiarity with F#, but some of its concepts are just over my head. I'm happy with the FP stuff that C# has co-opted (LINQ). I should look harder at FP stuff, but we're a C# shop here. If I did a project in F#, people would be upset because then I'd be the only one who could maintain it.
Was This Post Helpful? 0
  • +
  • -

#9 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2975
  • View blog
  • Posts: 11,224
  • Joined: 15-July 08

Re: Functional Language of choice?

Posted 25 July 2011 - 02:43 PM

I like Haskell and Clojure. Like many here, I have had a lot of other things get in the way that have slowed down my learning of FP. However, the little that I have learned has really helped me in other languages like Python, where I will use FP techniques in OO code.
Was This Post Helpful? 0
  • +
  • -

#10 ishkabible   User is offline

  • spelling expret
  • member icon





Reputation: 1749
  • View blog
  • Posts: 5,901
  • Joined: 03-August 09

Re: Functional Language of choice?

Posted 25 July 2011 - 02:50 PM

ya, im not sure how you could really work the Haskell type system into C++ but it sounds amazing. more type inference would be nice. the variadic template arguments reminds me of Haskell(it also reminds me of Lua) a bit.

here is an example i pulled off of Wikipedia.

printf(s, args...) this is the line im looking at. when args... is depleted, then the overload without the extra arguments is called!! that is exactly how a list is traversed in Haskell(well a major way at least)!!

void printf(const char *s)
{
    while (*s) {
        if (*s == '%' && *(++s) != '%')
            throw std::runtime_error("invalid format string: missing arguments");
        std::cout << *s++;
    }
}
 
template<typename T, typename... Args>
void printf(const char *s, T value, Args... args)
{
    while (*s) {
        if (*s == '%' && *(++s) != '%') {
            std::cout << value;
            ++s;
            printf(s, args...); // call even when *s == 0 to detect extra arguments
            return;
        }
        std::cout << *s++;
    }
    throw std::logic_error("extra arguments provided to printf");
} 

This post has been edited by ishkabible: 25 July 2011 - 02:56 PM

Was This Post Helpful? 0
  • +
  • -

#11 NickDMax   User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2255
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Functional Language of choice?

Posted 25 July 2011 - 03:20 PM

@ishkabible well start reading this blog post based upon a talk given a Boostcon 11:
Monads in C++

the article is at the moment over my head but if you start with this post and move into theMonads for the Curious Programmer it begins to make more and more sense... I am still in the process of digesting all of this though.

I'll let you know what I find when I get it all down!
Was This Post Helpful? 1
  • +
  • -

#12 ishkabible   User is offline

  • spelling expret
  • member icon





Reputation: 1749
  • View blog
  • Posts: 5,901
  • Joined: 03-August 09

Re: Functional Language of choice?

Posted 25 July 2011 - 03:37 PM

will read, thanks :)!! this topic got me to think about something in Haskell that at the monument doesn't seem possible. i attempted make a sprintf function in Haskell but i am having some issues with it. apparently you can have a list of type (Show a) => [a] not sure why though.

edit: reading some of this now. apparently my connection between varaidic template arguments and lists was right on the nail :)

edit2: i read that artical, C++ needs more support for TMP, it's just sweet like that.

This post has been edited by ishkabible: 25 July 2011 - 04:10 PM

Was This Post Helpful? 0
  • +
  • -

#13 mostyfriedman   User is offline

  • The Algorithmi
  • member icon

Reputation: 729
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Functional Language of choice?

Posted 25 July 2011 - 05:35 PM

I already know some haskell, but I started studying it more lately because I want to go real in depth in the language and the theory of FP languages. Haskell is the most elegant language I have known. Its so beautiful and so clean.
Was This Post Helpful? 0
  • +
  • -

#14 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 12350
  • View blog
  • Posts: 20,989
  • Joined: 19-March 11

Re: Functional Language of choice?

Posted 25 July 2011 - 07:37 PM

I may be in the minority, but so far I'm finding clojure to be sort of annoying. I'm going to keep hacking away at it, but it makes some weird and unhelpful departures from lisp syntax. If you're already familiar with a lisp, it'll probably cause you some heartburn, and if you're not familiar with a lisp, it'll probably make it harder to learn one. But if you want the java libraries, I guess it's the game you have to play.

I've been learning scheme and clisp in parallel, and they're close enough that I have no trouble going back and forth. And they're fun - both of them feel right. Clojure, however, is just annoying so far. (little thing: it removes a pair of parens from a cons - this is a completely pointless change to the syntax and forces you to think about the language instead of the problem at hand. slightly bigger thing: no lambdas. If you're writing lisp, you're used to lambdas. Now I have to learn a new idiom? Tiny thing: all of the documentation is SOO defensive about the language choices... quit explaining why you did it and just tell me how you've screwed up the language so I can write some code!) I'm sure I'll love being able to call Java libraries in a vaguely lisp-like language, I'm sure that'll make me happy as a clam at high tide, but so far I'm feeling no joy.

Whichever one you end up using, you can learn a lot about functional programming from the Little Schemer and sequels. You may have to modify some of the code to suit clojure, but the ideas will be the same, and they're good ones. Not easy ones, but good ones.

PS - And will someone please tell me when Weird Al Yankovic started writing a programming blog???
Was This Post Helpful? 0
  • +
  • -

#15 ishkabible   User is offline

  • spelling expret
  • member icon





Reputation: 1749
  • View blog
  • Posts: 5,901
  • Joined: 03-August 09

Re: Functional Language of choice?

Posted 25 July 2011 - 07:59 PM

i haven't tried conjure but i can't really seem to wrap my head around common lisp, the code is very hard for me to read and i have a hard time coming up with code in my head. Haskell just clicks with me, really well in fact. once i understood how constructors play into pattern matching it was like nirvana or something.

edit: what gives? those links NickDMax posted are broken...

This post has been edited by ishkabible: 25 July 2011 - 08:01 PM

Was This Post Helpful? 0
  • +
  • -

  • (5 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »