|
Since we appear to have a number of functional language wizards in here, I have a question: Which functional language would you use for a large project? The reason I ask is because I only know (sort of) two functional languages: Scheme and Erlang. Neither of which have even basic features like type checking or complex data structures (at least not that I was taught). The complex data structure thing is a big sticking point for me, since in a large program it's very likely that you'll build up a considerable amount of state as the program runs, and passing each and every variable on every single function call gets old quickly. I know Erlang has its key->value database thing, but its use is somewhat discouraged as it breaks the complete thread safety thing Erlang has going on. From what I saw, the only way to make a complex data structure is to make a list, and just have a magic place for every piece of state, then when you need something you just iterate down the list until you get to the right place. This could be done very elegantly in Erlang with the pattern matching and a second list that has the atoms that you use as the keywords for the list. It would probably only be like 5 lines of code. And it would be a horror because you have a O(n) access struct! It also doesn't help that the I/O routines that come with the language (both languages) are embarrassingly primitive. I guessing LISP must be better about this, but it still makes me wary about trying to build anything large in the language.
|
# ? Nov 29, 2009 20:18 |
|
|
# ? May 15, 2024 03:45 |
|
PT6A posted:Ding ding, you are a winner! It's McGill. Did you have Vybihal for it, out of curiosity? Don't want to keep this derail alive for too long but no, I got Mahes. An improvement if I base myself on the one class I took with Vybihal, but don't take that as an indication that you should take Mahes' networks class if you haven't; the workload for that is almost on the level of the 4 credit crypto class.
|
# ? Nov 29, 2009 20:31 |
|
jandrese posted:The reason I ask is because I only know (sort of) two functional languages: Scheme and Erlang. Neither of which have even basic features like type checking this is not a serious suggestion jandrese posted:or complex data structures (at least not that I was taught). Scheme even has multiple class systems if you want to do OOP in scheme for some reason.
|
# ? Nov 29, 2009 20:33 |
|
jandrese posted:From what I saw, the only way to make a complex data structure is to make a list, and just have a magic place for every piece of state, then when you need something you just iterate down the list until you get to the right place. This could be done very elegantly in Erlang with the pattern matching and a second list that has the atoms that you use as the keywords for the list. It would probably only be like 5 lines of code. And it would be a horror because you have a O(n) access struct! quote:and passing each and every variable on every single function call gets old quickly. quote:It also doesn't help that the I/O routines that come with the language (both languages) are embarrassingly primitive
|
# ? Nov 29, 2009 20:42 |
|
It's interesting to see so many McGill CS types in here - COMP 202 was the class that inspired me to drop my music degree and go into CS jandrese posted:Way to miss the point. The example there was to show off the weirdness that is running pattern matches on your function calls, the recursion bit was just there because that's how Erlang works! This, actually, proves my point - so many people on the net proselytize the flavour-of-the-week functional language and yet so few have clearly actually used it for anything beyond copying the code examples out of Joe Armstrong's book. Anyway. To give a less snotty answer, no, I didn't miss the point. Yes, the pattern matching stuff in Erlang is very cool, but every single other person in this thread saw it with Prolog in their third year of uni, so we don't feel the need to extol the virtues of a programming paradigm that isn't news to us. It's the whole "to a carpenter with a new hammer, everything looks like a nail" maxim. (additionally, most scheme implementations actually have compound datatypes, though IIRC it's not part of the language spec - in PLT Scheme, for instance, it's defined through the (make-struct ...) construct.) edit: Dijkstracula fucked around with this message at 20:55 on Nov 29, 2009 |
# ? Nov 29, 2009 20:52 |
|
Dijkstracula posted:For somebody who claims Erlang has revolutionized his life and how he codes, you sure had a difficult time coming up with the syntax for writing a factorial function, about the simplest Erlang program there is, from memory. What are you talking about? Have you confused me with someone else?
|
# ? Nov 29, 2009 21:12 |
|
jandrese posted:What are you talking about? Have you confused me with someone else? quote:In Pseudocode because I can't remember the wacky syntax:
|
# ? Nov 29, 2009 21:13 |
|
You're talking about factorials, the function was a simple iterator. I suppose iterators are a subset of factorials, but still. And I can't remember the syntax because it's been a couple of years since I used it, that is all. I certainly never said that it revolutionized my life, because it did not. I found it to be interesting but have never had a chance to use it in real life, only to build toy programs for class.
|
# ? Nov 29, 2009 21:16 |
|
Dijkstracula posted:(additionally, most scheme implementations actually have compound datatypes, though IIRC it's not part of the language spec - in PLT Scheme, for instance, it's defined through the (make-struct ...) construct.)
|
# ? Nov 29, 2009 21:38 |
|
jandrese posted:I suppose iterators are a subset of factorials, but still. Thread succesfully underailed.
|
# ? Nov 29, 2009 21:47 |
|
I'm just trying to understand Dijkstracula's comment.
jandrese fucked around with this message at 00:49 on Nov 30, 2009 |
# ? Nov 29, 2009 22:23 |
|
So I've been reading the PostgreSQL manual and discovered this gem.code:
|
# ? Nov 30, 2009 00:03 |
|
jandrese posted:Since we appear to have a number of functional language wizards in here, I have a question: Which functional language would you use for a large project? Erlang if you need to upgrade it in-place, Haskell if it needs to be fast, if neither of these restrictions apply then flip a coin. I assume there's somebody still writing in ML or CAML but everybody else has moved on.
|
# ? Nov 30, 2009 01:13 |
|
OCaml has a bit of a following although I don't know if it sees much/any production use
|
# ? Nov 30, 2009 01:44 |
|
Otto Skorzeny posted:OCaml has a bit of a following although I don't know if it sees much/any production use When I first learned Ocaml, type inferencing and pattern matching blew my mind. It was also my first introduction to functional programming. I haven't actually written anything in it since college though.
|
# ? Nov 30, 2009 02:16 |
|
It's my turn to sperg on Erlang.jandrese posted:Since we appear to have a number of functional language wizards in here, I have a question: Which functional language would you use for a large project? http://learnyousomeerlang.com/types-or-lack-thereof#for-type-junkies for more info. jandrese posted:The complex data structure thing is a big sticking point for me, since in a large program it's very likely that you'll build up a considerable amount of state as the program runs, and passing each and every variable on every single function call gets old quickly. With ets, you can also set permissions: read/write for all, write private to the owner process/actor only with read public to others, or write/read only allowed to the owner process/actor. This solves the problem with 'thread safety' if the mnesia transactions are not enough. Also, Dialyzer as mentioned above will find race conditions when using ets tables. jandrese posted:From what I saw, the only way to make a complex data structure is to make a list, and just have a magic place for every piece of state, then when you need something you just iterate down the list until you get to the right place. This could be done very elegantly in Erlang with the pattern matching and a second list that has the atoms that you use as the keywords for the list. It would probably only be like 5 lines of code. And it would be a horror because you have a O(n) access struct! You could also hack your way with binaries. I've written a little brainfuck interpreter that would use a long binary structure as a tape/array to read on with O(1) access. If that's still not enough, the R13B03 release from last week now includes NIFs, a way to write functions in C and have them interface with Erlang. Note that this is not a FFI and segfaults in your code will crash the whole Erlang VM the module has been loaded in, though. jandrese posted:It also doesn't help that the I/O routines that come with the language (both languages) are embarrassingly primitive. What are you looking for for the IO? Also for a lisp, you might want to give an eye to LFE, a lisp developed to run on the Erlang VM by Robert Virding, who knows his poo poo as no one else does. ----- Dijkstracula posted:To give a less snotty answer, no, I didn't miss the point. Yes, the pattern matching stuff in Erlang is very cool, but every single other person in this thread saw it with Prolog in their third year of uni, so we don't feel the need to extol the virtues of a programming paradigm that isn't news to us. It's the whole "to a carpenter with a new hammer, everything looks like a nail" maxim. Pattern matching is not that impressive, but I guess props have to be given to the error handling functionalities with supervision trees and whatnot, and then the OTP framework which is pretty unique. I don't know, I don't think many other languages have that (maybe Oz?). Dijkstracula posted:lol about leex and yecc MononcQc fucked around with this message at 03:31 on Nov 30, 2009 |
# ? Nov 30, 2009 03:00 |
|
If you think that:
|
# ? Nov 30, 2009 13:39 |
|
shrughes posted:That's right, PostgreSQL has two factorial operators!
|
# ? Nov 30, 2009 13:55 |
|
Dijkstracula posted:edit:
|
# ? Nov 30, 2009 14:07 |
|
Zombywuf posted:
I have never heard of anyone associating discriminated unions and Erlang. I don't know, I've always heard of the term used with languages supporting ML-like type systems. Where is this coming from?
|
# ? Nov 30, 2009 15:26 |
|
Dijkstracula posted:Yes, the pattern matching stuff in Erlang is very cool, but every single other person in this thread saw it with Prolog in their third year of uni, so we don't feel the need to extol the virtues of a programming paradigm that isn't news to us. And it is a lot more neat in prolog than it is in erlang: append([],X,X). % appending a list to an empty list is the same list. append([H|T],L,[H|O]) :- append(T,L,O). % appending a list to a list, is appending the head of a list to the output, where the output is the result of appending the tail of the list to the other list. Then you can use append to get the last element from a list: :- append(_,[X],[1,2,3,4]). X = 4?
|
# ? Nov 30, 2009 15:35 |
|
MononcQc posted:I have never heard of anyone associating discriminated unions and Erlang. I don't know, I've always heard of the term used with languages supporting ML-like type systems. Where is this coming from? Pattern matching is a generalisation of discriminated unions. Think what you get with algebraic data types and then remove static typing.
|
# ? Nov 30, 2009 16:48 |
|
tef posted:And it is a lot more neat in prolog than it is in erlang: *ahem* code:
|
# ? Nov 30, 2009 16:50 |
|
Should've known the 65 new posts weren't 65 new funny posts but instead 65 new posts arguing about functional programming.
|
# ? Nov 30, 2009 16:54 |
|
Zombywuf posted:If you think that: Also Actor/Agent/Process model is basically just asynchronous object-orientation. Message-passing actors are a really nice way of building but sometimes people act as though they're some kind of magic cure-all when they're not really all that different to how large systems were already engineered. Erlang's "big win" is nicely codifying and implementing the frameworks you need to get this sort of thing off the ground. Don't know where I'm going with this. In any case these arguments seem secondary to the stated goal of coding horrors. Edit: ColdPie posted:Should've known the 65 new posts weren't 65 new funny posts but instead 65 new posts arguing about functional programming.
|
# ? Nov 30, 2009 16:57 |
|
ColdPie posted:Should've known the 65 new posts weren't 65 new funny posts but instead 65 new posts arguing about functional programming. You mean 66. Edit: 68.
|
# ? Nov 30, 2009 16:57 |
|
ColdPie posted:Should've known the 65 new posts weren't 65 new funny posts but instead 65 new posts arguing about functional programming. And one post whinging about people arguing about functional programming.
|
# ? Nov 30, 2009 16:58 |
|
Zombywuf posted:And one post whinging about people arguing about functional programming.
|
# ? Nov 30, 2009 17:00 |
|
zootm posted:Sometimes a thread needs a good meta-whinge so it can get back on track. I hate meta-whinging.
|
# ? Nov 30, 2009 17:03 |
|
Zombywuf posted:Pattern matching is a generalisation of discriminated unions. Think what you get with algebraic data types and then remove static typing. Oh alright. That makes sense then. know of any other language that has the supervision trees, by the way? (I'm asking out of sheer curiosity) To actually contribute to this thread, I just stripped our website's code base from a bunch of php:<? if (!defined('LISTS_PHP_')) { define('LISTS_PHP_','1'); // Some class declaration here } // defined ?> As a result, the same lib would be check-outed 2-3 times on the same metal in different directories and when the sites would cross-include files, you'd get circular dependencies and class name clashes because PHP includes rely on the filename and path, not on the contents. The solution the old team found was to define constants on each file include to avoid the PHP interpreter making GBS threads itself. It was a loving nightmare. Took our team over a year to move poo poo out to different VMs, get rid of all the circular dependencies, kill the hard-coded poo poo and whatnot. There's still a lot of work to do too
|
# ? Nov 30, 2009 18:00 |
|
MononcQc posted:Oh alright. That makes sense then. know of any other language that has the supervision trees, by the way? (I'm asking out of sheer curiosity) The only places I've seen anything similar are server/daemon monitoring tools. Erlang is the only place I've seen it as part of the language, this is another area where Erlang seems to be trying to subsume the UNIX philosophy.
|
# ? Nov 30, 2009 18:13 |
|
MononcQc posted:This kind of stuff was used in every god drat library file we had because at some point in history the site would have some kind of common library directory with a bunch of other sites we had on a single server. Said websites would sometimes call files coming from each other to allow some weird interactions. Zombywuf posted:The only places I've seen anything similar are server/daemon monitoring tools. Erlang is the only place I've seen it as part of the language, this is another area where Erlang seems to be trying to subsume the UNIX philosophy.
|
# ? Nov 30, 2009 18:49 |
|
zootm posted:Is the resemblance to C headers deliberate or did they arrive at the same solution independently? That's pretty horrifying though. He was also a huge fan of one-letter variables, uncommented code, monitoring through private shell scripts on his own workstation and apparently would walk around the office with a katana. Zombywuf posted:The only places I've seen anything similar are server/daemon monitoring tools. Erlang is the only place I've seen it as part of the language, this is another area where Erlang seems to be trying to subsume the UNIX philosophy. I always liked etop as another example of following the UNIX concepts, except it can monitor remote nodes too.
|
# ? Nov 30, 2009 19:09 |
|
MononcQc posted:One of the lead devs back then (years before I got here) was a C programmer down to the bone. Never bothered to get into PHP the way he should have (not that I can blame him). The proper way to get into PHP is in a casket
|
# ? Nov 30, 2009 19:47 |
|
Mustach posted:Is this a "lol they suck?"
|
# ? Nov 30, 2009 23:41 |
|
Dijkstracula posted:But you're loving kidding yourself if you try and correlate a language's "quality" with a self-serving "you must be this smart to enter" metric. And further, you can't compare the "average quality" of code of a language that isn't used in a production setting, with one that is. If Java wasn't used by every half-assed developer and his dog to slap together some lovely business app, then you too could probably look at the average piece of Java code and say, "yes, this is beautifully written." Language generalizations are for people that don't write code. (Though gently caress VB/ASP right in the rear end, srs). PT6A posted:Getting back to the point about functional languages, I think people who've used them to some degree write better code because it's such a mindfuck when you first get started that you have to really understand what's going on, within the code, and within whatever code you're trying to write. That's bullshit. They're only a mindfuck because you're* coming from a whole lifetime of being drilled with procedural stuff. If you did not grok programming at all you'd probably find functional stuff MUCH more welcoming, logical and sensical than 'traditional' procedural programming. (* = impersonal you, we, etc.) wrok fucked around with this message at 02:10 on Dec 1, 2009 |
# ? Dec 1, 2009 02:08 |
|
wrok posted:That's bullshit. They're only a mindfuck because you're* coming from a whole lifetime of being drilled with procedural stuff. If you did not grok programming at all you'd probably find functional stuff MUCH more welcoming, logical and sensical than 'traditional' procedural programming. As someone who's first real introduction to programming was declarative and functional, I'll stand by this statement here. I still don't really understand why anyone would ever choose to use object-oriented programming unless it's all they know or they were somehow forced to, but I've learned this isn't an argument I'm likely to win.
|
# ? Dec 1, 2009 02:20 |
|
wrok posted:That's bullshit. They're only a mindfuck because you're* coming from a whole lifetime of being drilled with procedural stuff. If you did not grok programming at all you'd probably find functional stuff MUCH more welcoming, logical and sensical than 'traditional' procedural programming. That's actually very true, I never thought of it that way. Of course, if you come from functional programming, something like OO will be just as foreign when you start. Perhaps the mark of a good programmer is being able to comprehend and utilize multiple paradigms effectively, no matter where you started.
|
# ? Dec 1, 2009 06:22 |
|
PT6A posted:Perhaps the mark of a good programmer is being able to comprehend and utilize multiple paradigms effectively, no matter where you started. "Perhaps?" I thought this was an obvious truism.
|
# ? Dec 1, 2009 14:57 |
|
|
# ? May 15, 2024 03:45 |
|
I can't wait to use the 'seeking feed fwd', the 'anonymous role mixin', and the 'hyper dwim all'!
|
# ? Dec 1, 2009 15:01 |