63 Replies - 7195 Views - Last Post: 26 July 2011 - 06:52 PM
#1
Functional Language of choice?
Posted 25 July 2011 - 12:41 PM

POPULAR
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).
Replies To: Functional Language of choice?
#2
Re: Functional Language of choice?
Posted 25 July 2011 - 12:45 PM
#3
Re: Functional Language of choice?
Posted 25 July 2011 - 12:56 PM
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)
#4
Re: Functional Language of choice?
Posted 25 July 2011 - 01:02 PM
Also, I think this would make a great featured topic!
#5
Re: Functional Language of choice?
Posted 25 July 2011 - 02:11 PM
#6
Re: Functional Language of choice?
Posted 25 July 2011 - 02:22 PM
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
#7
Re: Functional Language of choice?
Posted 25 July 2011 - 02:35 PM
#8
Re: Functional Language of choice?
Posted 25 July 2011 - 02:42 PM
#9
Re: Functional Language of choice?
Posted 25 July 2011 - 02:43 PM
#10
Re: Functional Language of choice?
Posted 25 July 2011 - 02:50 PM
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
#11
Re: Functional Language of choice?
Posted 25 July 2011 - 03:20 PM
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!
#12
Re: Functional Language of choice?
Posted 25 July 2011 - 03:37 PM
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
#13
Re: Functional Language of choice?
Posted 25 July 2011 - 05:35 PM
#14
Re: Functional Language of choice?
Posted 25 July 2011 - 07:37 PM
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???
#15
Re: Functional Language of choice?
Posted 25 July 2011 - 07:59 PM
edit: what gives? those links NickDMax posted are broken...
This post has been edited by ishkabible: 25 July 2011 - 08:01 PM

New Topic/Question
Reply



MultiQuote









|