jestermax![]() Member Posts: 1064 From: Ontario, Canada Registered: 06-21-2006 |
Hey now, Does anyone here actually use functional programming languages for anything useful? (These are languages such as Haskell, ML, and Lisp) ------------------ |
||||
samw3![]() Member Posts: 542 From: Toccoa, GA, USA Registered: 08-15-2006 |
I learned the syntax of lisp a long time ago. But I never really used it. Today, most scripting languages have functional language component to them if you want to use it. My biggest beef about functional languages is lack of state and mutable data. I personally think its best to add functional programming to a language as an option. Though there are many who would say keeping it pure is better. Believe it or not, you can actually program 2D games functionally. Check out Clean and the Clean Game Library. God Bless! ------------------ |
||||
AndyGeers![]() Member Posts: 45 From: London, UK Registered: 06-20-2005 |
You could argue that Javascript contains some very functional-like features, like anonymous functions (e.g. var a = function(b) { return b * 2; }) which makes it incredibly powerful in the right hands. ------------------ |
||||
jestermax![]() Member Posts: 1064 From: Ontario, Canada Registered: 06-21-2006 |
There are very few pure functional languages that are completely pure (meaning stuff like I/O isn't functional). It just seems like something you'd do for "fun", education/research purposes, or for the "joy" of programming, but that's just me. I have heard that that ML has been used to make some useful stuff, but that's because it's used like any other language and it's not pure. Ugh... i think one of my exams requires some Haskell or ML coding ![]() ------------------ |
||||
samw3![]() Member Posts: 542 From: Toccoa, GA, USA Registered: 08-15-2006 |
quote: Also there are the 'lambda' functions in python and php. And ruby is really functionally bent. ------------------ |
||||
MastaLlama![]() Member Posts: 671 From: Houston, TX USA Registered: 08-10-2005 |
ASP, VBScript and the .NET stuff I've been doing lately are all very functional. Maybe I don't understand the question though. | ||||
jestermax![]() Member Posts: 1064 From: Ontario, Canada Registered: 06-21-2006 |
those are imperative languages; different from functional. The functional paradigm is based on lambda calculus as opposed to the von neumann model (sp?). Stuff gets done by applying mathematical-style functions instead of assignments. Not that any of that makes sense, but it's a start. Functional programming languages are: ML, Haskell, Hope, Lisp, and Scheme for example... ------------------ |
||||
supercoder![]() Member Posts: 37 From: Registered: 08-20-2007 |
no, we learned scheme at school, everything had to be defined in ()s, it was ugly. ex:
....would return 7
.... would define a function called square-me that takes a number as a parameter and returns its squared value.
... thats how your execute the function, it would return 9
------------------ |
||||
jestermax![]() Member Posts: 1064 From: Ontario, Canada Registered: 06-21-2006 |
ugh, i can't stand Lisp's brackets.... (scheme is lisp) gross. as far as functional languages go, i kind of like the look of ML. I like its pattern matching function system, and the fact that you don't HAVE to use dynamic typing. As it turns out, on my last exam i'm going to have to write some code in either Haskell or ML. It shouldn't too too complex though, i think it's just defining a new data type or something like that. Thanks for the sample code though supercoder. I actually understand it now after reading a bit on Lisp and ML, but have you ever used it for anything other than school projects? ------------------ |
||||
AndyGeers![]() Member Posts: 45 From: London, UK Registered: 06-20-2005 |
I was looking into Erlang today - since it was born out of industry rather than academia it's supposed to be a bit more practical for real world applications. It's particularly good at concurrent (multi-threaded) ------------------ |
||||
jestermax![]() Member Posts: 1064 From: Ontario, Canada Registered: 06-21-2006 |
Hmmm, i think i actually remember seeing/hearing something about erlang... upon wiki-ing erlang i found out that it was developed by Ericson! That's kind of nifty. One of the things that impressed me is the fact that it can be used for hot-swopping. meaning you can swap out code that's running without screwing anything up! how cool is that! It should be noted though that all (most) functional languages are (should) excel with multi threading since that's their major selling point (generating new values instead of modifying existing ones). hmmm, also it looks like Wings 3D was written in Erlang... but i know i've seen it used somewhere else... Edit: I forgot to give kudos to andygeers for his find. and also forgot to give him an awesome nickname: Angry-Gears [This message has been edited by jestermax (edited December 10, 2007).] |
||||
AndyGeers![]() Member Posts: 45 From: London, UK Registered: 06-20-2005 |
quote: This is true, but the difference with Erlang is its powerful ability to pass messages between the different threads really easily ------------------ |
||||
jestermax![]() Member Posts: 1064 From: Ontario, Canada Registered: 06-21-2006 |
Ugh, after a bit more studying i realized that i can now write/read basic LISP (although i don't think there's even standards for it). I really hate the 'prime' notation for using lazy evaluation. *shudders* i hope that stuff isn't on my exam in large amounts. oh yeah my exam is today btw; so pray for my soul. Getting back to my rant on LISP; why on earth would they pick out keywords that have no meaning? the head and tail list functions, CAR and CDR are only used because that's how they were implemented low-level....why?? Also i think it's dumb that NULL tests for NIL...what a horrible language. ------------------ |
||||
supercoder![]() Member Posts: 37 From: Registered: 08-20-2007 |
i didnt get the logic for using car and cdr either. from my notes: the IBM 704 had some 36-bit registers -bits 6-20 were called the address register, thus an instruction called CAR (Contents of Adress Register) would access these bits -bits 21-35 were the decrement register, CDR (Contents of Decrement Register) would access these bits I have no idea what this had to do with lisps use of car and adr good luck on test, hope you do better than i did with sceme - the only thing i know lisp is used for is emacs for setting editor properiies. [This message has been edited by supercoder (edited December 12, 2007).] |
||||
jestermax![]() Member Posts: 1064 From: Ontario, Canada Registered: 06-21-2006 |
i did awesome ![]() ![]() So yeah, now i'm actually interested in ML, although i REALLY detest the idea of Haskell. It seems like something the "snobs" of computer science would use ------------------ |