Slashdot Mirror


Erik Meijer: The Curse of the Excluded Middle

CowboyRobot (671517) writes "Erik Meijer, known for his contributions to Haskell, C#, Visual Basic, Hack, and LINQ, has an article at the ACM in which he argues that 'Mostly functional' programming does not work. 'The idea of "mostly functional programming" is unfeasible. It is impossible to make imperative programming languages safer by only partially removing implicit side effects. Leaving one kind of effect is often enough to simulate the very effect you just tried to remove. On the other hand, allowing effects to be "forgotten" in a pure language also causes mayhem in its own way. Unfortunately, there is no golden middle, and we are faced with a classic dichotomy: the curse of the excluded middle, which presents the choice of either (a) trying to tame effects using purity annotations, yet fully embracing the fact that your code is still fundamentally effectful; or (b) fully embracing purity by making all effects explicit in the type system and being pragmatic by introducing nonfunctions such as unsafePerformIO. The examples shown here are meant to convince language designers and developers to jump through the mirror and start looking more seriously at fundamentalist functional programming.'"

237 comments

  1. Jump through the mirror? by jeffb+(2.718) · · Score: 5, Insightful

    "The examples shown here are meant to convince language designers and developers to jump through the mirror and start looking more seriously at fundamentalist functional programming."

    Or, perhaps, to acknowledge that it's very hard to do anything useful without side effects.

    You can write beautiful, elegant, purely functional code, as long as it doesn't have to touch a storage system, a network, or a user. But, hey, other than that, it's great!

    1. Re:Jump through the mirror? by jythie · · Score: 4, Insightful

      I take this as a good example of why we should not strive for universal languages to use everywhere. Functional languages are really useful in their domains, while procedural and OOP languages are really useful in their domains. Language designers, or maybe just programmers who do not want to learn more then one language and thus find the One True Language, keep trying to extend languages to handle everything.

    2. Re:Jump through the mirror? by catmistake · · Score: 5, Funny

      You can write beautiful, elegant, purely functional code, as long as it doesn't have to touch a storage system, a network, or a user. But, hey, other than that, it's great!

      Speaking as an sysadmin, sounds like Heaven.

      The other way to make code safer, of course, is to eliminate the programmers.

    3. Re:Jump through the mirror? by Kjella · · Score: 1, Interesting

      My impression of "pure" functional programming is that it's roughly like having only static classes and no static members in OOP. Basically if you can have all the information you need "in flight" with you, then it can do all sorts of neat parallelization and optimization tricks because there's no state that makes the ordering important. I guess that's great if you're running some sort of scientific simulation where all the input is set in the model and you expect a result set out at the very end. But I don't find that part hard, the hard part about OOP is when the state throws you a curve ball. You try to write to a database record but it's not there anymore or the user removed the CD from the drive or the database is full or the network connection was lost and now what? It's handling all the contingencies that is difficult. I guess if the problem is the performance of your side effect free code, functional programming may be the answer. But it's not what most developers deal with.

      --
      Live today, because you never know what tomorrow brings
    4. Re:Jump through the mirror? by PPH · · Score: 3, Funny

      Speaking as a sysadmin, you should have said, "eliminate the users."

      --
      Have gnu, will travel.
    5. Re:Jump through the mirror? by Anonymous Coward · · Score: 1

      My impression of "pure" functional programming is that it's roughly like having only static classes and no static members in OOP

      Linus was right. OO programmers are brain damaged.

    6. Re:Jump through the mirror? by Geoffrey.landis · · Score: 1

      I take this as a good example of why we should not strive for universal languages to use everywhere.

      I take it as a good example of how programmers don't know what "excluded middle" means.

      --
      http://www.geoffreylandis.com
    7. Re:Jump through the mirror? by fractoid · · Score: 2

      Or, perhaps, to acknowledge that it's very hard to do anything useful without side effects.

      Exactly. Outside of an ivory tower or some very niche applications, everything we do with computers inherently has side-effects. Trying to pretend otherwise just leads to elaborate castles in the sky.

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    8. Re:Jump through the mirror? by jeffb+(2.718) · · Score: 1

      I take it as an amusing commentary on much of the functional programming debate. "If we assume that whether to use functional programming is a binary choice, then we can't decide to use it in some places and not others, because the middle is excluded in a binary choice!"

    9. Re:Jump through the mirror? by Anonymous Coward · · Score: 0

      Unfortunately, Linus didn't realise that C programmers are brain damaged too.

    10. Re:Jump through the mirror? by Anonymous Coward · · Score: 5, Informative

      Nobody is trying to pretend that there are no side effects you idiots. The point is that there are a lot of benefits that come when you clearly separate the parts of the program that have side effects from those that are pure and referentially transparent.

      It's trivial to ask a user for input, send packets across the network, query a database in Haskell and various other purely functional programming languages.

    11. Re:Jump through the mirror? by Pseudonym · · Score: 1

      So you didn't read TFA either, then?

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    12. Re:Jump through the mirror? by fractoid · · Score: 1, Funny

      ITT: Functional language fanboys get defensive.

      --
      Rampant carbon sequestration destroyed the Dinosaurs' tropical paradise. I'm here to help repair the damage.
    13. Re:Jump through the mirror? by jc42 · · Score: 4, Funny

      ... C programmers are brain damaged too.

      From the viewpoint of the general public, we can simplify it to "Programmers are brain damaged." This conclusion is often especially obvious to management, who find programmers both incomprehensible and arrogant. After all, would a truly sane person clearly tell their bosses that something can't be done the way the bosses said it is to be done? But programmers do this all the time, so they must be mentally deranged.

      --
      Those who do study history are doomed to stand helplessly by while everyone else repeats it.
    14. Re:Jump through the mirror? by Pseudonym · · Score: 5, Informative

      My impression of "pure" functional programming is that it's roughly like having only static classes and no static members in OOP.

      If you got that impression from TFA, then I can actually understand how you got it. Meijer's article was written for people already using not-fully-pure functional languages, where "class" means something slightly different than it does in a Simula-style OO language.

      The term "class" comes from von Neumann–Bernays–Gödel set theory. Naive set theory had issues like Russell's Paradox, which relies on notions like the "set of all sets". To remove this paradox, NBG set theory distinguishes between a "set" and a "class" (i.e. a collection of sets defined by a property they have in common). Some classes are sets, and some are not. A set is a collection of values, but a "class" is a collection of sets.

      In programming language theory, a "type" can be thought of as a set of values (e.g. "boolean" might be the set {true, false}). A "class" is a collection of types.

      When you write class Foo in (say) Java, you're actually doing three separate things.

      • You are declaring a new type, called Foo.
      • You are declaring a new collection of types (also confusingly called Foo), which will turn out to be the type Foo and all its subtypes.
      • You are declaring that the type Foo is a member of the collection Foo.

      In the Haskell class system, these three things are separated. This is why Haskell classes look more restrictive than classes that you might find in Java: a Haskell class only contains the parts that make it a class, not the parts that make it a type.

      Did that help?

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    15. Re:Jump through the mirror? by rabtech · · Score: 4, Interesting

      Or, perhaps, to acknowledge that it's very hard to do anything useful without side effects.

      You can write beautiful, elegant, purely functional code, as long as it doesn't have to touch a storage system, a network, or a user. But, hey, other than that, it's great!

      This is a huge misconception about functional programming, one that I used to have myself.

      With a functional programming language, you can have side effects, you are just forced to be explicit about those side effects with specific language features in specific places.

      Basically functional programming requires you to "opt-in" to side effects only where necessary.

      Traditional imperative programming requires you to "opt-out" by taking huge steps to enforce immutability, generating mountains of code to accomplish any task because the compiler doesn't help you.

      --
      Natural != (nontoxic || beneficial)
    16. Re:Jump through the mirror? by Anonymous Coward · · Score: 0

      I thought it had something to do with the pitfalls of lazy evaluation.

    17. Re:Jump through the mirror? by Geoffrey.landis · · Score: 1

      The term "class" comes from von Neumann–Bernays–Gödel set theory. Naive set theory had issues like Russell's Paradox, which relies on notions like the "set of all sets". To remove this paradox, NBG set theory distinguishes between a "set" and a "class"

      Unfortunately, while that was a clever attempt to solve the paradox, the paradox is not solved in this matter.

      --
      http://www.geoffreylandis.com
    18. Re:Jump through the mirror? by timeOday · · Score: 1

      Well I read it, and I genuinely do not see anything new in it. "Use monads." "Functional programming didn't fail us, we failed it. It's be best thing since sliced bread and the only reason it's not used much is because people are too lazy and uninformed to use it. If only they knew." I'm sorry, but that is (still) not it.

    19. Re:Jump through the mirror? by Pseudonym · · Score: 1

      One thing I was going to mention but didn't (because it would have confused things) is that this is true but slightly misleading:

      a "type" can be thought of as a set of values

      Sets are unstructured, but programming language types have structure. This is part of the reason why modern thinking is to ground programming language semantics in the language of category theory. If nothing else, the "carrier sets" of types must be computable sets, and the mappings between them must be computable functions.

      You are not expected to understand this.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    20. Re:Jump through the mirror? by Pseudonym · · Score: 1

      Yes, I think that the main lasting contribution of NBG is the language. Today we would talk about the "category of all sets" or the "category of all locally small categories", rather than "proper classes".

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    21. Re:Jump through the mirror? by Belial6 · · Score: 2

      You can simulate the exact same effect by just quiting your job and never working in the field again.

    22. Re:Jump through the mirror? by Anonymous Coward · · Score: 0

      AS the MCP I agree that we need to eliminate the users.

    23. Re:Jump through the mirror? by Belial6 · · Score: 2

      As illustrated here: https://www.youtube.com/watch?...

    24. Re:Jump through the mirror? by ozmanjusri · · Score: 4, Funny

      Suddenly Win8, the Office ribbon, RT, and Sharepoint begin to make sense. Thanks for the epiphany.

      --
      "I've got more toys than Teruhisa Kitahara."
    25. Re:Jump through the mirror? by Cryacin · · Score: 1

      As the BOFH, I firmly advocate playing with users for amusement and sport, until they eliminate themselves.

      --
      Science advances one funeral at a time- Max Planck
    26. Re:Jump through the mirror? by phantomfive · · Score: 1

      most hilarious comment all week

      --
      "First they came for the slanderers and i said nothing."
    27. Re:Jump through the mirror? by gnupun · · Score: 4, Insightful

      Linus was right. OO programmers are brain damaged.

      If you use fopen(), fread(), fclose() etc., you're already doing object oriented programming in C.

    28. Re:Jump through the mirror? by serviscope_minor · · Score: 1

      If you use fopen(), fread(), fclose() etc., you're already doing object oriented programming in C.

      No modpoints, sadly, but I agree.

      --
      SJW n. One who posts facts.
    29. Re:Jump through the mirror? by serviscope_minor · · Score: 1

      You start off with ad-hom (Ivory Tower...) and wonder why people get defensive. Frankly, I think the claims of FP are massively overblown and Haskell isn't going to take over the world. But I can see that on it's relative de-merits, not by aking up straw-man attacks like you.

      --
      SJW n. One who posts facts.
    30. Re:Jump through the mirror? by Anonymous Coward · · Score: 0

      Um, I think Von Neumann, Bernays and Gödel knew what it bought them, and what it didn't.

    31. Re:Jump through the mirror? by rtb61 · · Score: 1

      Well, mostly functional programming does work technically it is working right between your ears. Consider many programs running simultaneously, all tackling the same problem in different and or the same way, the outcome is the average result of not only the outcomes but the strength of the outcomes. Why useful? It allows the greater investigation of methods and outcomes and it allows for the reality of bumps on the heads and other maladies that damage the hardware the programs run on, which in the digital world means the program ends but in the biological world it allows the many other version of the program to still provide solutions.

      Of course what works in the biological world, would suck in the digital world because it would be horribly inefficient, basically tens of thousands of CPUs (ram et al) running variants of the same program with varying degrees of success and then correlating the results to produce a final outcome, even for the simplest of activities. Whilst the parallel computing model expressed in the biological world for greater resilience ie working past faults without failure, it is better in the digital world to just write an accurate program that runs well once, rather than writing thousands of variants programs running simultaneously in parallel, to account for damage in hardware over decades if life, including loss and replication of processing units.

      --
      Chaos - everything, everywhere, everywhen
    32. Re:Jump through the mirror? by StripedCow · · Score: 1

      The solution is to use functional style for high-level control flow, and imperative style for low-level (optimized) functions.

      There. That wasn't so difficult.

      --
      If Pandora's box is destined to be opened, *I* want to be the one to open it.
    33. Re:Jump through the mirror? by Anonymous Coward · · Score: 0

      Accessing to storage system, a network, or a user has nothing to do with purity (no side effects), as long as the language allows you to define that there are side effects. Take for instance the Mercury programming language, which is pure. It let's you define that a predicate is doing IO.

    34. Re:Jump through the mirror? by Twinbee · · Score: 1

      With an infinitely fast CPU, would it make sense to use functional style even for low-level control flow?

      --
      Why OpalCalc is the best Windows calc
    35. Re:Jump through the mirror? by StripedCow · · Score: 1

      No. With an infinitely fast CPU, we would let the computer do the programming :)

      --
      If Pandora's box is destined to be opened, *I* want to be the one to open it.
    36. Re:Jump through the mirror? by necro81 · · Score: 1

      Good fun on a Monday. Well played.

    37. Re:Jump through the mirror? by Anonymous Coward · · Score: 0

      r, perhaps, to acknowledge that it's very hard to do anything useful without side effects.

      You can write beautiful, elegant, purely functional code, as long as it doesn't have to touch a storage system, a network, or a user. But, hey, other than that, it's great!

      Or simply make the storage system, the network and the user immutable.

    38. Re:Jump through the mirror? by Twinbee · · Score: 1

      Seriously though, without AI, I was just wondering if the benefits of not using functional programming for low level functions had anything to do with speed, or if it was an ease of code writing or some other issue.

      --
      Why OpalCalc is the best Windows calc
    39. Re:Jump through the mirror? by StripedCow · · Score: 1

      Yes. With increasing CPU speed, it makes sense to sacrifice "performance" for ease of programming.

      --
      If Pandora's box is destined to be opened, *I* want to be the one to open it.
    40. Re:Jump through the mirror? by catmistake · · Score: 1

      you should have said...

      No, I sort of meant what I said and not really as a joke. And I am kin to BOFH, in that I'll come down hard on users, but only when they fuckup, and I guess that's where we diverge, also, my skill set is much more narrow, unfortunately.

      To illustrate the point about programmers, we need to take a little walk, because I like programmers... they are my compadres.

      I really love that Superuser forum site and the others like it ("how do you do x under these circumstances on some platform?") where someone posts a question and they get a bunch of rated answers, and all the flamers and trolls gets rated to oblivion and you never see it unless you want to, so its 3 things that work right at the top of the page sometimes, and not just for solutions in the form of previously unknown commands, or known commands used in unexpected ways, but various ways to do the same complex routines or entire scripts. It makes thinking about programming as what it should really be, as simple as creating a todo list or putting together a flow chart using modules that are constantly duplicated, improved slightly, and optimized over time.

      Which suggests four things to me. Regular folk, you know, "the norms," and really I just mean anyone at all could very likely do some high-level programming or create software for themselves or for profit if they had the right interface with different common logic modules and standard operators available in graphic form with popup documentation (if activated) that they can link together visually and simulate execution or output before compiling or printing the constructed code text to the screen and into the clipboard or publishing the code to the second thing it suggests to me.

      Which is that there should be a front end interface driving a fast database that makes available the most common logic phrases redundant in various methods, for whatever reasons (such as to minimize code verbosity, or maximize speed, or minimize hits on resources) for the most common programming languages (and excluding any that couldn't work with this paradigm), such that each module could be improved independently of the rest by the most accepted advancement method for open source development, grouped in the most common ways by the people that mostly use them tend to group them (by what they're used for, or who they're mostly used by, or what they are written in, or whether interpreted or compiled, and so on, whatever the user chooses and whatever anyone suggests that's a good enough idea to get voted into downstream availability in the interface or database). This should exist already!? Where is this site!?

      Thirdly, such a site is certain to attract and promote talent, like flies to honey, as well as attract and allow the mediocre hacks (like me, if you will allow me this very generous characterization) to have better code in whatever language works best, and grow within a few short years to some new popular accepted web phenomenon, and ultimately improve the efficiency and resiliency of code running everywhere on everything.

      And finally, that the interface should be fun and easy to understand, surprisingly fast and fluid and pretty much look like Minecraft or even Tetris, or whatever, as the interface itself is just another idea promoted and/or examined for inclusion and developed based on whatever its popularity or merits are by the roundtable of those that decide to work on the project.

      So... that's a new idea that's going to sit there until someone, anyone tells me, please, how to find out how to start a for profit open source web project that gives away functionality for free to attract users with milestones defined such that it can't change beyond its established mandate (it would fork if necessary) and somehow generate perhaps at first modest revenue with it (for site expenses, and contributors, why not?) that will slowly but surely build until its effectively printing money and making us a

    41. Re:Jump through the mirror? by Twinbee · · Score: 1

      Interesting. Would you say (again assuming an infinitely fast CPU) that for maximum ease of programming, that it would be best to write code in an entirely functional style, or use a mix of functional and traditional imperative programming?

      --
      Why OpalCalc is the best Windows calc
    42. Re:Jump through the mirror? by Anonymous Coward · · Score: 0

      My boss has already proven multiple times that P=NP, using only his mind's eye. He is a genius (and the one who sings off my compensation package).

    43. Re:Jump through the mirror? by jbolden · · Score: 1

      You can write beautiful, elegant, purely functional code, as long as it doesn't have to touch a storage system, a network, or a user. But, hey, other than that, it's great!

      You write beautiful elegant functional code for the algorithms and then messy imperative code that invokes those algorithms for stateful operations. If you do it in the functional language itself Monads work well. Otherwise you just invoke the functional code as a library.

    44. Re:Jump through the mirror? by jbolden · · Score: 1

      A good example of where functional can be very useful from your examples is: writing the database engine, writing the CD-decoder, writing the network stack, etc...

    45. Re:Jump through the mirror? by jbolden · · Score: 1

      FP has already taken over the world. Have you looked at what's happening with compilers at this point. Your imperative languages are more and more interpreters running against functional engines (though running against very low level imperative code).

    46. Re:Jump through the mirror? by jbolden · · Score: 1

      I don't think so. FP is good when you need to do complex things with simple state issues. If you need to do complex things with state and simple things to the data FP are just bad imperative languages.

    47. Re:Jump through the mirror? by Anonymous Coward · · Score: 0

      Basically functional programming requires you to "opt-in" to side effects only where necessary.

      Traditional imperative programming requires you to "opt-out" by taking huge steps to enforce immutability, generating mountains of code to accomplish any task because the compiler doesn't help you.

      Would love to see an example if one could be produced.

    48. Re:Jump through the mirror? by tepples · · Score: 1

      In order to execute as the client side of a web application, an application will have to be written in JavaScript or in a language that compiles to JavaScript. And there were a few months when it was forbidden to write native iOS apps in any language other than Objective-C++. Other platforms have their own restrictions on languages, such as Windows Phone 7 and Xbox Live Indie Games (effectively C#-only due to limitations on the subset of the CLR they may use).

    49. Re:Jump through the mirror? by Anonymous Coward · · Score: 0

      Yes. There is nothing wrong with using object oriented programming, it is a great way to structure your code, even (or especially) if you code in assembly language.
      That doesn't mean that people who go for completely OO languages aren't brain damaged.

      I actually recommend reading trough what Linus has written on the subject, including the flamewars.
      While his choice of words often are more entertaining than diplomatic it is obvious that he has given the subject a lot of thought.
      It would also be silly to disregards the opinion of Linus. There are a lot of skilled CS people out there but when it comes to writing and managing code that actually is in use very few are in a position to challenge him.

    50. Re:Jump through the mirror? by jeffb+(2.718) · · Score: 1

      Well, mostly functional programming does work technically it is working right between your ears.

      This is... well, let's call it an unexpected re-interpretation of behaviorism ("it's not useful to talk about 'mental state', just stimuli and responses").

      Do you seriously propose that biological systems are stateless? Or are you just proposing that the physical universe is "stateless" or "functional"? This may be an interesting philosophical perspective, but I'm having a hard time seeing how it gets us anywhere.

    51. Re:Jump through the mirror? by B1ackDragon · · Score: 1

      In the Haskell class system, these three things are separated. This is why Haskell classes look more restrictive than classes that you might find in Java: a Haskell class only contains the parts that make it a class, not the parts that make it a type.

      Did that help?

      As someone unfamiliar with Haskell (or much in the way of purely-functional programming at all), would you mind expanding on this a bit? I've dabbled in lisp, but R (insane but it is) is the language that's introduced me to more functional concepts but it's also quite a mixed bag.

      --
      The snow doesn't give a soft white damn whom it touches. -- ee cummings
    52. Re:Jump through the mirror? by russotto · · Score: 1

      Yes, and that beautiful, elegant, purely functional code will even be efficient... as long as the compiler/interpreter designer has done all the work for your particular case.

    53. Re:Jump through the mirror? by Anonymous Coward · · Score: 0

      That's fine though - extend a language until it handles everything. The alternative is a set of disjoint languages that all implement different things with various degrees of annoyance, and none of them inter-operate cleanly or efficiently. The closest we ever got to this in the enterprise was .Net which even features F# out of the box for functional. It was glorious until Apple and mobile took over and now no-one cares about Microsoft or Visual Studio anymore.

      Which is why I'm learning Python - it's a horrible language but it's the best I've got now C# is gone.

    54. Re:Jump through the mirror? by Anonymous Coward · · Score: 0

      Remember: to the construction worker open heart surgery looks easy. ...until they try to jack-hammer your rib cage.

      The devil is in the details.

    55. Re:Jump through the mirror? by Anonymous Coward · · Score: 1

      What the kids are calling FP lately, which used to mean simply first-class/higher-order functions, recursion and the avoidance of mutable state, now seems to mean 'Whatever Haskell did'. Regardless, it hardly has the monopoly on containing stateful operations. Even dirty 'imperative' languages like Modula/Oberon family had the System/Unsafe module to import to make such things explicit. Modula also had ML-like modules (something Haskell is severely missing) and strong static typing without being completely unfamiliar to others like the typical reaction people have to reading ML, Scheme, Haskell, etc.

      I personally love the ML family and can certainly tolerate Haskell (though I consider lazy evaluation by default to be a grave mistake), but I find articles like this one ridiculous and suspect the author simply is being willfully ignorant of the past in order to push their pet language.

    56. Re:Jump through the mirror? by gstoddart · · Score: 3, Informative

      Yes. With increasing CPU speed, it makes sense to sacrifice "performance" for ease of programming.

      I worked with a guy who used to say that.

      He wrote shitty, un-maintainable code which he thought was elegant, and which in practice was garbage, full of ridiculous assumptions, and giant inefficiencies all in the name of him being able to invoke something in as few lines of code as possible, or without consideration for the cost of his framework. Half of his code went through massive setup tasks every time it was invoked or naively did something assuming it wasn't expensive. Over and over and over again.

      He said you should write first, and the optimize later. By the time we realized his code was so slow as to be unusable, he had painted himself into a corner, and there was no way to optimize his code except to get rid of it.

      Sometimes the things passed off as "ease" of programming is a thinly veiled decision to use known terrible methods in the expectation they're prettier.

      In my experience, some of these claims don't produce good code. They produce things the coder believes to be pretty, but which in practice is quite a mess.

      I've yet to be convinced you should start writing your code in a way you know is inefficient because your belief in your elegant solution, which is anything but. I've seen an O(n^2) algorithm called O(n^2) times, all because it was "cleaner" code, and the code assumed everything was a zero cost operation (or had hidden all of the aspects of that, so you don't find it until later).

      Performance is a real thing. I lament that people have now decided it's irrelevant to consider it.

      --
      Lost at C:>. Found at C.
    57. Re:Jump through the mirror? by NoOneInParticular · · Score: 1

      Have you ever looked at physics, and how it separates state from function? Where are the side-effects in math? Do you really think an OO based view of particles would have gotten us anywhere? Well, I have this particle, and then this other particle, and they update their own states independently. Now, sometimes, if they are near, one particle sends a message to the elastic collision controller, which will ask then the other particle to update its state a bit differently. With trillions of particles, this becomes a bit awkward, but hey, that's how nature works.

    58. Re:Jump through the mirror? by ultranova · · Score: 1

      The solution is to use functional style for high-level control flow, and imperative style for low-level (optimized) functions.

      Even if you write something in hand-optimized assembly, that still doesn't mean that it'll end up being faster than machine-optimized assembly unless you're good enough. How many programmers are "good enough" in this sense of the word?

      In other words, how many people are not only good enough programmers but also knowledgeable enough about the target platform to beat a C compiler? Haskell compiler? Or even the Python interpreter? How has that number evolved as the compilers and platforms both do? And could JIT beat any programmer simply because it can profile and optimize at runtime against the actual usage, rather than hypothethised usage?

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    59. Re:Jump through the mirror? by Anonymous Coward · · Score: 0

      Demonstrating that you're too stupid and ignorant to understand meaningful correction may keep others from correcting you, but it doesn't mean that you've won an argument.

    60. Re:Jump through the mirror? by jbolden · · Score: 1

      Those tools do exist. Visual Basic, Ruby on Rails, Livecode....

    61. Re:Jump through the mirror? by jbolden · · Score: 2

      Class definition of Haskell simply contains methods defined abstractly.

      For example the collections class is defined:

      class Collects e ce where
                    empty :: ce
                    insert :: e -> ce -> ce
                    member :: e -> ce -> Bool

      What this reads is there are 3 functions
      empty which tells you if a collection is empty
      insert which takes an element and a collection is arguments and then "inserts" the element into the collection
      member which takes an element and a collection is arguments which tests to see if an element is a member of a collection

      That's it for the class. If you have a collection you are guaranteed those 3 things exist. But you guaranteed nothing about implementation at all. Because of that the methods empty, insert, member are incredibly polymorphic. Which means I can continue to define new functions using these abstractions. So "insert list"

      insertList list collection = foldr insert collection list
      and I get an efficient operation involving a looping structure with no complexity at all.

    62. Re:Jump through the mirror? by jbolden · · Score: 1

      Not sure what you would want here. Just look at Haskell code. Doing a side effect inside the wrong kind of function (i.e. one not in a side effect monad like I/O) just throws a type error.

    63. Re:Jump through the mirror? by jbolden · · Score: 1

      Lazy evaluation by default is the most controversial aspect of Haskell. That's the one big design issue where Haskell hasn't proven to be a clear cut win. I think the advantage of lazy by default is really captured by "non deterministic order of evaluation by default" and that's been a huge win for parallelism.

    64. Re:Jump through the mirror? by rwa2 · · Score: 2

      Well, would you rather be faced with a false dichotomy, or would you like to have other options?

    65. Re:Jump through the mirror? by euroq · · Score: 1

      If you use fopen(), fread(), fclose() etc., you're already doing object oriented programming in C.

      Can you explain that to the unenlightened? I don't follow.

      --
      Just because the U.S. is a republic does not mean it is not a democracy. Democracy/republic are not mutually exclusive.
    66. Re:Jump through the mirror? by gnupun · · Score: 2

      OO (C++) promotes data hiding (of fields in a struct/class) and using member functions to manipulate the data in a safe manner. So the above file operations in C++ would be something like:

      f = new File("test.txt", "rb"); // create file object
      // f = fopen("test.txt", "rb"); // C code
       
      f->read(dataArr, 1024); // read 1KB array
      // File::read(f, dataArr, 1024); // compiler generated code
      // fread(dataArr, 1024, f); // C code
       
      f->write(dataArr, 1024); // write array to file
      // File::write(f, dataArr, 1024); // C++ compiler gen code
      // fwrite(dataArr, 1024, f); // C code
       
      f->close();
      // File::close(f) // C++ compiler gen code
      // fclose(f) // C code
       
      delete f;

      Note: I've skipped the "size" parameter in fread(), fwrite() for simplicity.

      The C "FILE*" type is object oriented in that
      a) The programmer has no idea what's inside the struct (same as OO data encapsulation)
      b) You have to use fxxx() functions to access anything about the file (continuation of data encapsulation)
      c) C programmers pass an "fp" variable to the fxxx() functions whereas C++ programmers pass an invisible "this" pointer to similar file member functions.

      As you can see, under the hood, the code generated by the C++ compiler is very similar to the C code you are familiar with when using fxxx file functions because C FILE objects use many of the concepts used commonly in C++.

    67. Re:Jump through the mirror? by euroq · · Score: 1

      And could JIT beat any programmer simply because it can profile and optimize at runtime against the actual usage, rather than hypothethised usage?

      Huh? You were just saying that compilers optimize better than humans, then say that Java cannot beat any human? I'm sick of all these Java haters... :/

      --
      Just because the U.S. is a republic does not mean it is not a democracy. Democracy/republic are not mutually exclusive.
    68. Re:Jump through the mirror? by phantomfive · · Score: 1

      Nice description.

      --
      "First they came for the slanderers and i said nothing."
    69. Re:Jump through the mirror? by catmistake · · Score: 1

      I think you may have missed the part about the whole being online bit, and including all permittable code and all logic modules being precoded in different ways for different optimizations, and the bit about it being stored in and accessable in a database by a Minecraft-like front end that ...

      wait a second. Who do I know you can even read?

    70. Re:Jump through the mirror? by jbolden · · Score: 1

      I was focusing on the allowing regular folks to program. Honestly I couldn't follow your description of what you wanted and there was no explanation of why those choices made sense.

    71. Re:Jump through the mirror? by catmistake · · Score: 1

      Programming, if nothing else, is moduler.

      Simply, the idea is to have pre-programmed every common codable module, optimized for diffrent purposes in multiple ways, for every language that this paradigm can work with, available in an online database, with a front end that looks like Minecraft or something, and also includes a sandbox for users to test the resulting program/application, and that the entire OSS project is built and run by volunteer programmers that are paid from advertising profits or corporate subscription fees, based on the level of their involvement.

      One never need explain why something makes sense. That would be redundant. What makes sense does so on its face.

  2. functional programming catch-22 by smoothnorman · · Score: 3, Interesting

    to interact with an imperfect world one needs monads. to have monads is to compromise functional programming. ipso-facto-quod-splut: i always did rarther fancy Fortran. (hsst: don't tell anyone, but Forth is the -only- way to go, (and by 'go' i don't mean "Go" (or "Dart")))

    1. Re:functional programming catch-22 by Anonymous Coward · · Score: 1

      Forth is always fun...
      If you want to program using functional procedures, just use a functional language. I like ocaml.
      Or try some variant of Scheme. You can use any programming paradigm you like with that...

    2. Re:functional programming catch-22 by phantomfive · · Score: 1

      IF you read the article, you'll find that his advice for doing functional programming without compromising it is to use monads.: but then I always did fancy reading the article.

      --
      "First they came for the slanderers and i said nothing."
    3. Re:functional programming catch-22 by Anonymous Coward · · Score: 0

      to interact with an imperfect world one needs monads. to have monads is to compromise functional programming. ipso-facto-quod-splut: i always did rarther fancy Fortran. (hsst: don't tell anyone, but Forth is the -only- way to go, (and by 'go' i don't mean "Go" (or "Dart")))

      I think it's Lisp you secretly crave.

    4. Re:functional programming catch-22 by Pseudonym · · Score: 2

      to have monads is to compromise functional programming.

      [citation needed]

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    5. Re: functional programming catch-22 by Anonymous Coward · · Score: 0

      Lots of silly paranethesis

      *sob*

    6. Re:functional programming catch-22 by Warbothong · · Score: 1

      to have monads is to compromise functional programming.

      How so? If anything, monads are one of the great success stories of (pure) functional programming.

      There are lots of interesting monads which are literally useless in the presence of effects. For example, side-effects can:

      Leak private references from the Single Thread monad, making its encapsulation useless.
      Perform irreversible changes, making monads like Software Transactional Memory and Backtrack/Undo useless.
      Enter infinite loops, making the Partial monad useless.
      Break referential transparency, making Memoisation useless.

    7. Re: functional programming catch-22 by rwa2 · · Score: 1

      LISP ("Lots of Insignificant Silly Parentheses")

      (FTFY)

  3. "Mostly" by defintion isn't what you wanted... by The+New+Guy+2.0 · · Score: 1

    If your goal is "functional" and you wind up at "mostly functional"... aren't you admitting you've got a bug in your program?

  4. Or just a hybrid by Anonymous Coward · · Score: 0

    With CloudI

  5. NaNL (Not a Natural Language) by Anonymous Coward · · Score: 1

    I suspect that this was written by a computer because even though it is is grammatically correct it still seems like a bunch of technical words strung together.

  6. Wow by xdor · · Score: 3, Insightful

    After programming for 16 years, I finally realize I have no idea what I'm doing. I'm so glad these people are out there to point this out.

    1. Re:Wow by Anonymous Coward · · Score: 0

      Hi Erik,

      Glad you could join the discussion!

      Best,

      Your left Gonad.

    2. Re: Wow by Anonymous Coward · · Score: 1

      Just wait until you've been doing it for 30... then you'll really not know anything anymore...

    3. Re:Wow by PPH · · Score: 3, Funny

      P.S. You still login to Slashdot so you're almost definitely an incompetent retard.

      Welcome to the club. Here's your hat.

      --
      Have gnu, will travel.
    4. Re:Wow by Anonymous Coward · · Score: 0

      The reality is none of us know what we're doing, or what we're doing is constantly changing. Like doctors _practice_ medicine, we're all really just practicing. I'm eternally saddened by college program-a-day jockeys that come in with their language du jour and start hacking away, but unfortunately that's going to keep happening. There are many ways to write code so that it will work but you also have to write code so you can _keep_ writing code and you'll be able to keep it working.

      We're transitioning into programming mainstream now. We have brogrammers and we're on the cusp of mandating programming for everyone. Even your mom can program. This was like opening the lexicon to the masses with telecommunications, and we came up with txtspk and l33t speek. Heck, even modern human languages are still evolving, the last thing we want is the masses pushing the C++ language as well.

  7. Well that summary leaves me wondering by Anonymous Coward · · Score: 5, Funny

    what does Bennett Haselton think about this topic?

  8. Sounds like my old comp-sci professor. by quietwalker · · Score: 5, Insightful

    I remember he used to lament the fact that we had to use computers to run programs, because they were always so impure. Hacked up with model-breaking input and output considerations. He loved APL. Had us write our programs as math equations and prove that they had no side effects. On paper. Step by step, like how elementary teachers used to have you write out long division. He was a computer scientist before they HAD computers, he'd point out.

    To be fair, APL was a wonderful language, and perfect so long as you didn't want to actually /do/ anything.

    Well, that's unfair. As long as you meant to do a certain type of thing, these languages work out fairly well. The issue is the old percent split issue you normally see with frameworks and libraries - by making it easy to do some percent, X, easily, you create a high barrier to performing the remaining percent, Y. The problem with adhering to pure functional languages is that Y is not only high, it's often the most common tasks. Iterating, direct input and output, multi-variable based behavior, a slew of what we'd call flow conditions - these are very hard to do in a pure functional language. The benefit you get is far outweighed by the fact that you could use C, or the non-functional aspects of OCaml, or some other so-called 'multi-paradigm' language to fix the problem in a fraction of the time, even with side-effect management.

    Then, have you ever tried to maintain a complex functional program? There's no doubt you can implement those Y-items above. The problem is that it makes your code very specific and interrelated as you're forced to present a model that captures all the intended behaviors. It's a lot of work. Work that will then need to be repeated each time you need to make additional changes. Adding a mechanism to - for example - play a sound at the end of a processing job based on the status - that's a line of code in most languages. Not so in a functional language.

    The problem here isn't the oft-cited 'Devs just have to think of things differently, and they'll see it's better.'. It's more basic. It's simple throughput. Functional languages might be a theoretical improvement, but they're a practical hindrance. That, in a nutshell, is why they're not in common use in a corporate environment, where "value" loses it's theoretical polish and is compared to hard metrics like time and cost for a given quality.

    1. Re:Sounds like my old comp-sci professor. by msobkow · · Score: 1, Interesting

      I agree completely, and have experienced this problem with Erlang. We got most of a complex system built at my last job over 2 years using Erlang for the servers and data I/O services.

      Then we came to the scheduling algorithm, which had originally been prototyped with Visual Basic. It did the job, and had for many years.

      But have you ever tried to express an n-length array and process it in a functional language?

      In the end we had to cancel the project and blame the fellow who'd made the decision to use Erlang. Maybe if he were still with the company, he'd have been able to code it (he was an Erlang "expert".) But he'd jumped ship two years before it was due, so we'll never know if even a self-proclaimed "expert" could have made it work.

      I couldn't. I'd managed to shoehorn every other piece of functionality into the system, but mapping that simple array-based algorithm to a functional language proved impossible.

      --
      I do not fail; I succeed at finding out what does not work.
    2. Re:Sounds like my old comp-sci professor. by Pseudonym · · Score: 1

      But have you ever tried to express an n-length array and process it in a functional language?

      You're going to need to expand on this. Pretty much every functional language I know (and I know a lot of them) has support for arrays, either in the language or in a library.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    3. Re:Sounds like my old comp-sci professor. by msobkow · · Score: 1

      Erlang expressed arrays as lists internally. Any obvious implementation sucked donkey balls for performance.

      --
      I do not fail; I succeed at finding out what does not work.
    4. Re:Sounds like my old comp-sci professor. by msobkow · · Score: 2

      And I am far from an Erlang expert. Therein lay the problem. The only expert at the language who recommended using the language was the first one to fuck off and run away when the going got tough and it was too late to change course to a language the whole TEAM was familiar with, like Java or C#.

      --
      I do not fail; I succeed at finding out what does not work.
    5. Re:Sounds like my old comp-sci professor. by Pseudonym · · Score: 3, Insightful

      Erlang expressed arrays as lists internally.

      Actually, it uses a 10-ary tree, which has O(log n) lookup, update, etc with a pretty low constant factor. Or, at least, that's what it does now.

      It doesn't have to be this way. Haskell has O(1) arrays, but they live in a monad (either ST or IO) if they're not read-only. Plus, of course, Haskell has lazy evaluation, so read-only arrays are not necessarily as read-only as you might think.

      Without knowing more details (and since I'm just some random guy on the Internet, you probably don't care enough to give details, so that's cool) it's difficult to say if you really needed imperative arrays for your algorithm, or you only thought you did because that's what the Visual Basic prototype used. Most people don't learn pure functional data structures in their undergrad classes, so they not always the solution which springs to mind when you have a problem to solve.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    6. Re:Sounds like my old comp-sci professor. by Anonymous Coward · · Score: 0

      Then we came to the scheduling algorithm, which had originally been prototyped with Visual Basic.

      Haha, there's the real problem, and your lack of skills, no offense.

    7. Re:Sounds like my old comp-sci professor. by Anonymous Coward · · Score: 0

      You are familiar with tuples, right?

    8. Re:Sounds like my old comp-sci professor. by msobkow · · Score: 4, Interesting

      No offense taken. I don't claim to be an Erlang expert; I hadn't even heard of the language before this project. None of the team members had worked with it. The only one who'd worked with it was the guy who architected and prototyped the system. As soon as he was done the prototype, he didn't renew the contract and buggered off.

      But we had done "too much" to switch to a language we could all agree on. Oh hell, no. We had to keep on using that crap because somebody had Made A Decision and wouldn't backtrack and Lose Money.

      In the end, they lost 4-5 times as much money when we couldn't make it go. And it serves them right -- sticking with a bad decision just because you've got an investment in it is stupid when everyone is telling you it's a bad decision and a bad investment. You need to listen to the TEAM DOING THE WORK, not an "expert" who buggered off before the real work started.

      --
      I do not fail; I succeed at finding out what does not work.
    9. Re:Sounds like my old comp-sci professor. by Anonymous Coward · · Score: 1

      http://www.erlang.org/doc/man/array.html

    10. Re:Sounds like my old comp-sci professor. by gnalre · · Score: 1

      Sounds more like a loss of faith rather than a language problem. I have sympathy, but if you are not an expert in a domain, whenever a problem arises the 1st reaction is to go back to safe ground.

      Unfortunately while all programmers know imperative languages, few are taught functional techniques when first programming. Until that happens it is unlikely that functional languages will ever be much more than a sideshow despite there obvious advantages because there are very few problem domains that can only be solved in functional languages.

      --
      Choose your allies carefully, it is highly unlikely you will be held accountable for the actions of your enemies
    11. Re:Sounds like my old comp-sci professor. by jbolden · · Score: 1

      A0 = array:new(10).
          10 = array:size(A0).

      Will give you a fixed sized array.

      ____

      If you need a mutable array datatype you just create a monad and do it in there. Which incidentally has been done for Erlang as opensource libraries.

    12. Re:Sounds like my old comp-sci professor. by jbolden · · Score: 1

      There are two issues here:

      a) Was Erlang the right choice
      b) Did management handle transitioning the team to Erlang the right way.

      (b) could be "no" and (a) could be yes. Your argument before was that Erlang wasn't a good language. No one is arguing that FP doesn't take unlearning a bunch of ways of thinking that are typical in other languages. Also some pure learning time where you see concepts on simple examples and not in the context of real life. Redoing programming 101 type stuff.

    13. Re:Sounds like my old comp-sci professor. by jbolden · · Score: 1

      I suspect the mixed paradigm languages will make functional techniques more popular. Heck they are having to introduce them into Java now they've become so popular. The .NET compiler is all functional. Javascript, Scala, Perl6, Ruby... are mixed paradigm. I think the change is happening.

    14. Re:Sounds like my old comp-sci professor. by msobkow · · Score: 1

      The answer to both questions is "no".

      When you're creating a business-critical system (i.e. the product you SHIP), you need to use languages and tools that you can get resources for, not some esoteric pie-in-the-sky theoretical bullshit.

      --
      I do not fail; I succeed at finding out what does not work.
    15. Re:Sounds like my old comp-sci professor. by msobkow · · Score: 1

      The purpose for the company's existance was to ship a product, not to train Erlang programmers.

      --
      I do not fail; I succeed at finding out what does not work.
    16. Re:Sounds like my old comp-sci professor. by jbolden · · Score: 1

      You keep arguing for (a) by arguing for (b). A company most certainly can get resources for Erlang. As for your arguments regarding efficiency there have been tests again and again for decades that higher level languages increase efficiency. Programs which in practice become too difficult in imperative languages like Java are written all the time in functional languages.

      If the developers were simply unwilling to learn to use new tools properly that certainly is a serious issue but that's a good argument for outsourcing the project away from that development team or being in a new team. It is not an argument for using the wrong tool.

    17. Re:Sounds like my old comp-sci professor. by kbahey · · Score: 1

      To be fair, APL was a wonderful language, and perfect so long as you didn't want to actually /do/ anything.

      I worked with a guy in the mid 1980s who used APL for everything. He came from the mainframe world, but had APL for MS-DOS on floppies. When he was contracted for writing an MS-DOS application in RM-COBOL, he used APL to write a full screen text editor so that he would not use edlin and such.

  9. 'Mostly functional' programming does not work by xxxJonBoyxxx · · Score: 0

    It does if you're a government contractor, apparently...
    http://www.forbes.com/sites/je...
    http://www.computerworld.com/s...
    (and thousands more...)

  10. Not really by phantomfive · · Score: 3, Insightful

    I use function techniques even when I'm using Java or C. Writing functions that have no side effects is useful and achievable, even when the language doesn't strictly enforce it.

    Furthermore it can be mixed with imperative, or even object, programming. It's a useful technique for minimizing bugs.

    --
    "First they came for the slanderers and i said nothing."
    1. Re:Not really by Anonymous Coward · · Score: 0

      I use function techniques even when I'm using Java or C. Writing functions that have no side effects is useful and achievable, even when the language doesn't strictly enforce it.

      Furthermore it can be mixed with imperative, or even object, programming. It's a useful technique for minimizing bugs.

      How DARE you use the best tool for any job!

    2. Re:Not really by Bite+The+Pillow · · Score: 0

      You are the reason the article exists. You talk about minimizing bugs, and the article talks about eliminating them. They are not the same.

      Moving to a mostly functional language to eliminate bugs does not work. Reduce, maybe. But not eliminate. No one should make the mistake of assuming that mostly functional programming reduces bugs, either. It may just relocate them.

      Mostly functional is not the same as functional, and remove is not the same as reduce. At least understand what you object to before objecting.

    3. Re:Not really by phantomfive · · Score: 2

      Well, functional programming won't eliminate bugs either, so whatever

      --
      "First they came for the slanderers and i said nothing."
    4. Re:Not really by Anonymous Coward · · Score: 0

      At the end of the day, pure functional languages are useless. So of course there are no bugs.

  11. Safer is not the reason by Anonymous Coward · · Score: 1

    Removing side effects from the equation is only one advantage of functional programming. The solutions to many problems are far more succinctly written in terms of functions. That's why the reason why I like using the paradigm. "Mostly functional programming" gives you the flexibility of imperative programming with the powerful expressiveness of functional. Who said it was trying to make it safer?

    1. Re:Safer is not the reason by Tablizer · · Score: 2

      I've heard this "expressiveness" claim multiple times, but have yet to see a realistic and practical code example. There have been examples where the code was more compact, but the readability of such code was either questionable or highly subjective.

    2. Re:Safer is not the reason by jbolden · · Score: 1

      Code that is 10-20x shorter is right off the bat quite a bit more readable.
      Code that is structurally simple is quite a bit more readable.
      Code that uses powerful abstractions can be much less readable till you get used to thinking that way.

    3. Re:Safer is not the reason by Tablizer · · Score: 1

      I disagree that brevity and readable are the same thing. Further, "structurally simple" is in the eye of the beholder. And, if one cannot find staff that can grok lots of heavy abstraction, then the organization gets stuck. Lower abstraction may cost more (less efficient), but is less likely to create outright "stuckage".

      More on this kind of debate:

      http://c2.com/cgi/wiki?GreatLi...

    4. Re:Safer is not the reason by jbolden · · Score: 1

      I would agree that Haskell, LISP... can unquestionable provide outright "stuckage". No question. I'll grant that one. In an FP if the programmer who wrote the code is moderately more advanced than the person maintaining it than the maintainer will often have to do some serious learning to get the new code.

      If you exclude that issue though shorter is easier. For example take parallelism. In pure FPs the parallel strategy is often a single operator located in a few key places in the code. You can just skip it, as a compiler directive. In imperative languages it is scattered all over the code and there is no way to skip.

    5. Re:Safer is not the reason by Tablizer · · Score: 1

      In imperative languages [parallelism] is scattered all over the code and there is no way to skip.

      I haven't found much of a need for direct parallelism coding in the typical "custom business applications" I encounter. The web server model or client/server, and the databases generally provide such already for most "parallel" needs without explicit coding. But other niches may indeed need more of such. The issue is "FP everywhere" versus "FP only where helpful".

    6. Re:Safer is not the reason by jbolden · · Score: 1

      I'm not a fan of FP everywhere. I'm a fan of FP for complex algorithms. If you have simple algorithms that just need to be structured into a sequence with lots of I/O all FP gets you is a bad imperative language.

    7. Re:Safer is not the reason by Tablizer · · Score: 1

      "Complex" is difficult to objectively define, unless you use some form of code size. But generally code size and grokkability by humans are only roughly related.

  12. Unversity course from hell... by Anonymous Coward · · Score: 1

    This subject had us working in groups to code a structured editor in a functional language - we called this the "specification" but it was essentially a functional implementation of an editor with a few concessions to do the actual IO. We then "implemented" in Java. I learnt exactly 4 things from that course.

    1) NEVER EVER try to build an editor in a structured language. Functional languages are a poor fit for procedural tasks.
    2) Having built something in a functional language do not then try to translate directly to an object oriented language. Plenty will be lost in the translation (It's like trying to translate a book of jokes from one language to another, only worse) and you'll wind yourself up in a knot trying to define a subset of a functional language in an object oriented one. What you'll end up in the object oriented language will be an ugly inelegant unreadable mess!!!
    3) The idea that you can build a provable system using a functional language is bat crap insane. In terms of proof it'll give you nothing that good unit tests wouldn't give you.
    4) Spend a lot of time ensuring you work in groups where for the most part everyone pulls their own weight.

    1. Re:Unversity course from hell... by Pseudonym · · Score: 1

      NEVER EVER try to build an editor in a structured language. Functional languages are a poor fit for procedural tasks.

      This is good advice, right up to the point where you need to implement "undo". At that moment, you learn why non-destructive data structure manipulation is an excellent idea.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    2. Re:Unversity course from hell... by Anonymous Coward · · Score: 0

      NEVER EVER try to build an editor in a structured language. Functional languages are a poor fit for procedural tasks.

      This is good advice, right up to the point where you need to implement "undo". At that moment, you learn why non-destructive data structure manipulation is an excellent idea.

      (Of course I meant to say functional language and I'm assuming you picked that up)

      You can build your non-destructive data structure in the procedural language - it's way easier.

      In fact your undo has to be a two way function in order to be able to get back. Which is not always so easy.

      Suffice to say you can build a bad editor in a procedural language as well.

    3. Re:Unversity course from hell... by Twinbee · · Score: 1

      If you had infinite memory/CPU (or at least a small enough file), you could implement multiple undo/redo simply by storing the whole string in the file for every character change, easing code writing immensely.

      --
      Why OpalCalc is the best Windows calc
    4. Re:Unversity course from hell... by Rhymoid · · Score: 1

      1) NEVER EVER try to build an editor in a structured language. Functional languages are a poor fit for procedural tasks.

      Concrete examples, please. I've been using Haskell for a few years now, and I can't see the problem with "procedural" tasks. Especially when you don't define what that means.

      3) The idea that you can build a provable system using a functional language is bat crap insane. In terms of proof it'll give you nothing that good unit tests wouldn't give you.

      I suspect you (or your lecturer) encountered something like QuickCheck, which is indeed not more thorough than unit tests (but properties are much easier to write).

      There are definitely techniques to truly prove correctness of software, which are based on dependently-typed functional languages like Coq, Agda and Idris. In these languages, the type system is so expressive that you can express theorems in it, and values of those types are proofs.

  13. The only true functional program... by Anonymous Coward · · Score: 0

    Since input and output are side effects, and externals like running time, or even whether a program is running could be used to signal output, the only Pure Functional program is such that it is undecidable whether or not the program is even running, or can be run. But maybe reality is is a simulation run by a functional program, and the only observers are inside the system, and there's no way to tell if reality is a simulation from inside the system. So studying Pure Functional programming is just cheesy metaphysics by another name.

    1. Re:The only true functional program... by jbolden · · Score: 3, Informative

      Pure functional programming means state is isolated not that it doesn't exist.

  14. Good aspiration, bad in (some) practice by RedMage · · Score: 2

    I'm not an expect in functional programming, but I am an expert in other (object, etc) styles. While I appreciate the functional toolbox in languages such as Scala (which I use every day), I don't really see a way to do my day to day job in a purely functional way. Others have mentioned the I/O dilemma, but I think it goes deeper than that. Functional != Efficient for many of the tasks I perform, which are rather iterative. For many of my tasks, the overhead of the functional structures required are either much more memory intensive, or impose a run-time overhead that isn't acceptable. In the end, when what I have to do is move 300 fields from one data structure to another with edits, COBOL would be sufficient...

    --
    }#q NO CARRIER
    1. Re:Good aspiration, bad in (some) practice by lgw · · Score: 1

      Function programming optimizes well in a functional language. That was the point of Guy L Steele's dissertation, lo these many years ago: a tail call is just a branch. Tail recursion is just a different way to spell iteration, and a compiler should understand that.

      I enjoy blending both styles, each where it's useful, in C# with its linq extensions. All the proper list processing constructs (albeit with ridiculous names: "select"? really?), all quite efficient and lazy.

      OTOH passing lambdas around everywhere just because that's the music you listened to in college isn't helping either performance or clarity.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    2. Re:Good aspiration, bad in (some) practice by Anonymous Coward · · Score: 1

      Functional programming doesn't work very well on the JVM because of the lack of proper tail call optimization. Scala also doesn't track effects in its type system so there are a ton of optimizations that can't be done (fusion being the most obvious and probably the biggest).

      It also doesn't help that the primary Scala implementation is a fucking mess.

  15. Bad Summary. by thestuckmud · · Score: 4, Interesting

    The synopsis completely misses the qualification, made in the first sentence, that TFA is discussing "concurrency, parallelism (manycore), and, of course, Big Data". Purely functional programming eliminates some significant issues in this type of programming (while introducing its own set of limitations). Meijer's point is that mostly functional programming is not really better than imperative here

    For other types of programming, mostly functional style (using multi-paradigm languages) can be very nice. At least that's my position.

  16. I like hybrids myself by GoodNewsJimDotCom · · Score: 1

    I like to use a combination of procedural, functional, and OO. I find some things are better for different things. Restricting yourself from options doesn't necessarily make you a better programmer.

    If you want to hear a good one that will make you cringe on side effects: When I write personal code for myself that no one else will touch, I use a globally mutable systems and I have no issues. Globally mutable systems are bad in teams if you're trying to track down who's code is causing the problem because side effects could happen anywhere! But when your a solo guy, you know right away.

    1. Re:I like hybrids myself by Warbothong · · Score: 1

      Restricting yourself from options doesn't necessarily make you a better programmer.

      The point is not that we should restrict our choice of technology as programmers; in fact, the more technologies we play with the better programmers we will become. However, the point is that sometimes a specific choice of technology in a project *must* restrict the other technologies we can use in that project.

      For example, if our project requires that we always call some cleanup procedure after using some resource, we may choose to ban GOTO, exceptions and call/cc *in that project* since they break the logical flow of procedure calls. TFA is saying that massively-parallel functional code can be completely ruined if we allow even the *possibility* of side-effects, so we may choose to ban side-effects *in that project*.

  17. Re:I am looking for a word ... by Anonymous Coward · · Score: 2, Informative

    I'll break it down into Retardese for you.

    Side effects are things that change the state of the program. We don't want to store the state of the program because it gives it a memory. If it is not memoryless, then it is difficult to reason about. For instance, the equation f(x)=2x+1 is memoryless, because it does not matter what was observed the last time you observed f(x). As such, we can reason very easily with this function, and as long as we always supply the same input, we always get the same output.

    Now think what would happen if we have g(x)=h(x)*x+1, where h(x) returns the previous value that it was supplied with (assume that it returns 0 on the first call if you like). That complicates things greatly, because we now have to consider everything that has been called before. You evaluate g(10) then g(5) to get 51, then reset the environment and evaluate g(5) then g(5) to get 26. That means it's no longer a function and cannot be reasoned like it is one. This means that you cannot formally prove the code correct, but you have to use a debugger to hunt down things like some sort of code monkey. It's intolerable!

  18. It's Not Just A Good Idea, It's The Law by mbstone · · Score: 2

    If Republicans are elected, expect fundamentalist programming to become mandatory.

    1. Re:It's Not Just A Good Idea, It's The Law by Anonymous Coward · · Score: 0

      No, they've been working on outlawing programming. Just look at the way those hateful people are shutting down computer science classes. Our mayor recently gleefully smashed a couple of LCD monitors in the school where I used to teach. He is a diehard Republican, and is trying to get all Democrats fired from teaching here. That is their way. They are horrible people.

    2. Re:It's Not Just A Good Idea, It's The Law by DahGhostfacedFiddlah · · Score: 2

      Yeah, it seems they're always trying to reduce the power of the state.

  19. State machine programming by Mr.CRC · · Score: 1

    I write lots of state machines that control external world gadgets, which input new results to my program to use to compute the next state. Consequently I can only wonder about this idea of removing side effects as: "WTF?"

    That said, I tend to write modules so that they only write to globals within that module.

    Writing an IIR filter without memory is a pretty funny idea.

    1. Re:State machine programming by ultranova · · Score: 2

      I write lots of state machines that control external world gadgets, which input new results to my program to use to compute the next state. Consequently I can only wonder about this idea of removing side effects as: "WTF?"

      newState = deriveNewStateFromDeviceMessage (oldState, message)

      (bitsToSendToDevice, newState) = getHardwareCommandForSomeAction(oldState, action)

      That said, I tend to write modules so that they only write to globals within that module.

      So, basically, if someone plugs two gadgets into the same control machine, Bad Things happen?

      Writing an IIR filter without memory is a pretty funny idea.

      The idea of functional programming is to pass all information in function parameters and return values, rather than through globals.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

    2. Re:State machine programming by Anonymous Coward · · Score: 0

      It all can be done functionally, you just need to use monads. It's basically a clever way of chaining computations so that you can treat anything in a functional manner, and preserve the neatness and predictability of the type system.

    3. Re:State machine programming by tepples · · Score: 1

      When you're generating a new multi-megabyte state 60 times a second, you had better have a lot of memory bandwidth for all the copies of parts of the state that didn't change and a best-of-breed real-time garbage collector to plow through the no-longer-referenced old states. Good luck making a sufficiently smart compiler that makes such a purely functional approach execute as fast as a mutable approach on the same hardware.

    4. Re:State machine programming by Anonymous Coward · · Score: 0

      Or you structure your state so that creating "copies" is cheap (some sort of tree or graph -- you only need to copy the path to the modified portions). Something like this.

    5. Re:State machine programming by tepples · · Score: 1

      Unfortunately, Haskell is like Greek to me. Perhaps that's the problem: colleges currently tend not to teach the skills needed to help students get their respective minds around Haskell.

    6. Re:State machine programming by jbolden · · Score: 1

      Learning to think in Haskell isn't undoable there there is a learning curve. You have to learn different ways of thinking about problems and different techniques.
      I'd say get a very basic easy Haskell book and do some very simple projects in it.

  20. Don't worry by Anonymous Coward · · Score: 0

    My new one language to rule them all, Ruperelix, will solve all that, for 1 week only, until it's taken apart. As you rightly stated, computers are not paper.

  21. Gobbledigook by Topwiz · · Score: 0

    This just a bunch of academic rambling that has nothing to do with the real world. Real world business software developers just don't talk that way. They could care less if the language they use is functional or not and probably don't know. They just want to know how to implement a business requirement. If something doesn't work it is a bug, not an effect.

    1. Re:Gobbledigook by Pseudonym · · Score: 4, Informative

      Real world business software developers just don't talk that way.

      "Real world business software developers" are those whose code ends up on The Daily WTF.

      But seriously, welcome to the future. In the 1960s, "real world business software developers" thought that all this "object" stuff was a bunch of academic gobbeldygook at worst, or niche tool for people doing scientific simulations at best, rather than anything that would be useful with their hard-nosed COBOL. And in a sense, they were right. How would it help you speed up the overnight bank transaction updates? It probably wouldn't.

      This "academic rambling" probably won't help you write your business software today, but it just might help you avoid becoming obsolete tomorrow. Thankfully, you probably won't need to learn it until tomorrow.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    2. Re:Gobbledigook by Anonymous Coward · · Score: 0

      You are correct, but you're also missing the point. If you work long enough in the software industry you come to the realization that the benefits of rigor, be it functionality or otherwise, are near universally viewed with suspicion. Rather, ignorance is promoted as intellectual honesty, and "correctness" is always just a fix away. Good luck to the language designer if they take TFA to heart. They'll neither be understood, nor adopted.

    3. Re:Gobbledigook by Anonymous Coward · · Score: 0

      Rather, ignorance is promoted as intellectual honesty, and "correctness" is always just a fix away. Good luck to the language designer if they take TFA to heart. They'll neither be understood, nor adopted.

      There are small niches where you can still find really smart developers/mathematicians (finance and a lot of DoD projects for instance). You'll probably be working for some "evil" people but who really cares.

    4. Re:Gobbledigook by bytesex · · Score: 2

      But you have to agree that 'functional programming is the next big thing' has been said for so long now - it's the flying car of computer science. When people say 'any day now' for so long, some scepsis *is* in order.

      --
      Religion is what happens when nature strikes and groupthink goes wrong.
    5. Re:Gobbledigook by Pseudonym · · Score: 1

      But you have to agree that 'functional programming is the next big thing' has been said for so long now [...]

      Well... I kind of have to agree, in that it's true that it has been said. However, it's not true that this means anything either way.

      I remember when transputers were the next big thing. People older than I probably remember when perceptrons were the next big thing. People talk crap, and functional programming has been around for a while, so it's inevitable that some subculture has considered it "the next big thing" for a while, along with everyone else who thinks that something else is "the next big thing".

      I don't know who those people are, because I don't listen to them, but Erik Meijer is not one of them. Actually he's making a sort-of opposite point, namely, that in the world of many-core and big-data, "almost" pure functional programming (which is almost all functional programming) is useless.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    6. Re:Gobbledigook by JaredOfEuropa · · Score: 1

      In my environment (business software), projects rarely fail because of bugs, but because of poorly understood business processes, business requirements that are poorly formulated or interpreted, and a poor sense of priorities which results in dropping the wrong 20% in an 80-20 situation, skipping acceptance tests, etc. Poorly understood IT requirements are also factors, especially when it comes to integration with other systems (which is often added as an afterthought).

      --
      If construction was anything like programming, an incorrectly fitted lock would bring down the entire building...
    7. Re:Gobbledigook by LWATCDR · · Score: 1

      Of course at the same time the academics where also pushing LIsp as the end all and be all of computer programing. It got so far as hardware Lisp machines.
      OOP worked out Lisp is still around but not really mainstream.

      --
      See my blog http://ilovecookes.blogspot.com/ for light hearted technical information.
    8. Re:Gobbledigook by jeffb+(2.718) · · Score: 1

      It actually shows the lack of mathematical background.

      Computers are mathematical devices, the only thing they can do is mathematics.

      The more mathematics the programmer knows the easier the problems become.

      Unfortunately, training for the "language of the day/month/year" is that none of the necessary background is provided, and that lack causes the problems/bugs/errors/catastrophes and project failures...

      it is also why programs cannot be validated...

      LOL. Computers are at the core mechanisms, and they are no more "mathematical" than any other physical device.

      Sure, more math can help make you a more effective programmer. But if you rely entirely on mathematical purity, you will in general not be an effective programmer. It's like pointing to the beauty of the closed-form mathematical solution for the two-body problem, and saying "now why don't you do it this way for your n-body problem?"

    9. Re:Gobbledigook by Anonymous Coward · · Score: 0

      Out of a zillion things that were touted as "the next big thing", only a handful, like OOP, actually made it to the mainstream. So, by any reasonable reckoning "real world business software developers" were right 99.9% of the time and the academics weren't.

    10. Re:Gobbledigook by Pseudonym · · Score: 1

      Out of a zillion things that were touted as "the next big thing", only a handful, like OOP, actually made it to the mainstream. So, by any reasonable reckoning "real world business software developers" were right 99.9% of the time and the academics weren't.

      First off, you're assuming that it's academics who make the unsubstantiated bold claims about the "next big thing". In my experience, a few academics are like that, but most aren't. Academics generally know their own limitations, especially when it comes to predicting the future.

      But more crucially, when it does come to predicting the future, academics are wrong at about the same rate as entrepreneurs are. This is the nature of innovation: You must try a lot of things, knowing that most of them will fail.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    11. Re:Gobbledigook by Pseudonym · · Score: 1

      Of course at the same time the academics where also pushing LIsp as the end all and be all of computer programming.

      Name three, with actual quotations please.

      What I think you'll actually find is that a number of academics were pushing symbolic computing as an important future trend, and at the time, Lisp was the only game in town.

      OOP worked out Lisp is still around but not really mainstream.

      ...and yet Greenspun's tenth rule and Morris's corollary are as true as they've always been.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    12. Re:Gobbledigook by Bob9113 · · Score: 1

      But seriously, welcome to the future. In the 1960s, "real world business software developers" thought that all this "object" stuff was a bunch of academic gobbeldygook

      You do know functional programming is older than OO, by a lot, right? See Lisp.

    13. Re:Gobbledigook by Pseudonym · · Score: 1

      Uhm... where did you get that I didn't know this?

      For the record, Simula appeared in 1967, so "the 1960s" is accurate.

      OOP became mainstream in 1991. We know it to the year, because that was when OOAD by Booch was published. Between 1967 and 1991, there was a steady trickle of new programming languages with Simula-style objects. After 1991, they almost all did, or had support for emulating them. We're talking 25 years of lead time between initial research and adoption.

      Functional programming, in a sense, predates computers, but as far as programming languages go, it does go back to Lisp in 1958. There has been a steady trickle of functional programming languages since then, but the time in history when almost all languages are getting language support is right about now. C# got lambdas in 2007, C++ in 2011, and Java in 2014.

      Of course, these aren't fundamentalist functional languages, but they're not fundamentalist OO languages either.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    14. Re:Gobbledigook by Bob9113 · · Score: 1

      Uhm... where did you get that I didn't know this?

      Ahh, sorry, I misinterpreted what you were saying. I read it as, "OOP was once considered new and silly, just like functional is now." I've been talking to a few too many programmers lately who are jumping on the new hotness bandwagon without realizing it has a long history.

  22. Re:I am looking for a word ... by Anonymous Coward · · Score: 0

    Are you gay?

  23. Excluded middle, eh? by Pseudonym · · Score: 2

    Am I the only person whose first thought on reading the headline was that Erik Meijer (of all people) should know that the law of the excluded middle is not a theorem in the type theories that he advocates?

    --
    sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  24. Re:I am looking for a word ... by Anonymous Coward · · Score: 0

    Sorry, I'm taken.

  25. Hello by Anonymous Coward · · Score: 0

    I support this topic,

    Bennett.

  26. Through the looking glass indeed by Alomex · · Score: 2

    So Erik Meijer is arguing that mostly functional programming which is widely used in industry "does not work" and suggest instead purely functional programs which have been around for decades and gone nowhere?

    Through the looking glass indeed.

  27. Mostly functional works quite alright by Alomex · · Score: 4, Insightful

    From TFA:

    mostly secure does not work

    Spoken like a true academic. Mostly secure does work in practice. My house is mostly secure, my car is mostly secure, my bank is mostly secure. None of them are perfectly secure, as all of them would fail to a sufficiently strong attack, but generally they do fine.

    So does mostly functional programming. It works great in practice even though it is not 100% safe but neither is functional programming once you allow monads which are needed to make FP Turing complete.

    1. Re:Mostly functional works quite alright by Pseudonym · · Score: 1

      Mostly secure does work in practice.

      But it doesn't scale to the truly big, which is kind of Meijer's point. Those responsible for the NSA mass surveillance system have been reassuring you of its "mostly secure" nature for almost a year now, but I think we know that doesn't work in practice.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    2. Re:Mostly functional works quite alright by Alomex · · Score: 1

      It does scale. I've got news for you but there are no 100% completely secure systems out there. They are all mostly secure but if I really want in I can send the Army, NSA, FBI and CIA and compel you to break the system open for me. I don't know if you follow the news, but we have several recent examples where this took place.

    3. Re:Mostly functional works quite alright by Anonymous Coward · · Score: 0

      I'm sorry, truly big like.. what? The linux kernel? clang? gcc? firefox? The Unreal Engine 4? The complete Windows Operating System?

      What successful pure-functional projects operate at this scale (pick your metric: lines of codes, number of users*time, ...)?

    4. Re:Mostly functional works quite alright by Myu · · Score: 1

      I think the issue is more that a 99.9% secure system with a million accesses every day still has maybe a thousand security vulnerabilities a day, whereas a 99.9% secure system being used a hundred times is reasonably likely to not have any. Scaling things up makes what looks like reasonable endemic risk into something that, while still not proportionally significant, is also quite likely to nonetheless happen.

      --
      Myu: ... The map's upside down...
    5. Re:Mostly functional works quite alright by Anonymous Coward · · Score: 0

      ... but neither is functional programming once you allow monads which are needed to make FP Turing complete.

      You've just undercut every argument you could possibly make on the subject of functional programming.

    6. Re:Mostly functional works quite alright by Pseudonym · · Score: 1

      I'm sorry, truly big like.. what? [...] What successful pure-functional projects operate at this scale (pick your metric: lines of codes, number of users*time, ...)?

      Like map/reduce at Google.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
    7. Re:Mostly functional works quite alright by Anonymous Coward · · Score: 0

      monads which are needed to make FP Turing complete.

      Um .. no.

      The lambda calculus is TC .. no monads. Etc.

    8. Re:Mostly functional works quite alright by Anonymous Coward · · Score: 0

      Which is exactly why industry grade systems are built to six and seven nines (i.e. 99.9999-99.99999%) of security and reliability.

      And no one promises 100% security and reliability. Only an out of touch academic could promise that.

    9. Re:Mostly functional works quite alright by Alomex · · Score: 1

      Map reduce ain't pure functional programming. Map-reduce as implemented in practice today uses storage which breaks the purely functional paradigm. It is a good example of mostly functional though.

    10. Re:Mostly functional works quite alright by smallfries · · Score: 1

      once you allow monads which are needed to make FP Turing complete.

      Artful troll, no?

      --
      Slashdot: where don knuth is an idiot because he cant grasp the awesome power of php
    11. Re:Mostly functional works quite alright by Anonymous Coward · · Score: 0

      +1

      And I will go further: mostly secure is the best there is. Anyone who tells you they are perfectly secure is lying to you, or totally uninformed.

    12. Re:Mostly functional works quite alright by Pseudonym · · Score: 1

      Map-reduce as implemented in practice today uses storage which breaks the purely functional paradigm.

      I think you're using a different sense of "uses storage" than I am. The map and reduce phases of map-reduce transform abstract data into abstract data, and it is the framework which turns this into a process which transforms storage into storage. The whole point of map-reduce is that it's cheaper to move code around cluster than to move data. As soon as the map and reduce tasks share data, performance is lost.

      --
      sub f{($f)=@_;print"$f(q{$f});";}f(q{sub f{($f)=@_;print"$f(q{$f});";}f});
  28. Concurrency is still badly understood by Animats · · Score: 4, Interesting

    It's frustrating. Functional programming is painful when you actually have to do something, not just compute some result. But the real problem is older. We never got concurrency right in imperative languages.

    Classic pthread-type concurrency suffers from the problem that the language has no idea what's locked by a lock. This problem is in C, wasn't fixed in C++, and isn't even fixed properly in Go. It was addressed more seriously in Modula and Ada, where the language knew which variables where shared and which were not. The Ada rendezvous approach was too limiting for anything otther than hard real-time, but it was on the right track.

    Java addressed this with synchronized objects. This was a step in the right direction. The basic concept of a synchronized object is that, when executing a method of the object, nothing else can affect the state of the object. Java's synchronized objects don't quite get that right - you can call out of an object, then back into it, from within the same thread. This can break the object's invariant, in that the callback function is entered while the object is not in its stable, nobody-inside state. This is a classic cause of trouble in GUI systems, which involve lots of objects calling each other through dynamically changing collections. (If some unusual order of clicks crashes a program, there's a good chance the bug is of this type.)

    The inside/outside issue for state protected by locks is a big one. This also comes up when a thread blocks. Many programs have sections where a thread unlocks a lock, blocks, then relocks the lock. This constitutes control leaving the block, but the compiler doesn't understand this. There's no syntax that says "I am now leaving this object to wait", with the language checks to insure that no internal object state gets passed to the code outside the object. The Spec# group at Microsoft (Spec# is a proof of correctness project using a form of C#) attacked this problem, and came up with a solution of sorts, but it never went mainstream. It's hard to fix this with a language bolt-on.

    Objects ought to be either immutable, synchronized, or part of something that's synchronized. Then you're safe from low level race conditions. (You can still deadlock. However, deadlock bugs tend to be detectable and repeatable, unlike race condition bugs. So they get caught and fixed.) if this is built into the language, the compiler can check and optimize. Compilers are good at catching things like a local variable being passed to something that might save a reference to it and mess with it concurrently. Humans suck at that. Machines are good at global analysis of big data.

    I had great hopes that the Go crowd would have a solution. They claim to, but there's a lot of hand-waving. They claim "share by communicating, not by sharing memory", but the examples in "Effective Go" all share memory. It's also really easy to share memory between goroutines in Go inadvertantly, because slices and dicts are reference objects. Pass them through a pipe and you've shared data and can have race conditions. The problem is bad enough that Google AppEngine limits Go programs to one thread.

    Mixed functional/imperative programming has all these problems, plus the illusion that the problem has been solved. It hasn't.

    1. Re:Concurrency is still badly understood by bytesex · · Score: 1

      Agreed on main points. A few remarks:

      - In C's pthreads library, you *can* tell the 'system' 'I'm leaving this object to wait' of sorts (pthread_condition_wait requires you to pass a mutex).

      - Overall, there are many, *many* programs out there that, justifiably, do not use threads at all. To require these programs to incur the overhead associated with threading even though they don't use it, seems a bit much.

      --
      Religion is what happens when nature strikes and groupthink goes wrong.
    2. Re:Concurrency is still badly understood by Animats · · Score: 1

      - Overall, there are many, *many* programs out there that, justifiably, do not use threads at all. To require these programs to incur the overhead associated with threading even though they don't use it, seems a bit much.

      That's why threading needs language support. The compiler can identify many objects that are not being shared across thread boundaries, and optimize out locking. Libraries can't do that; they can't do global analysis.

      This is also true of subscript checking. Most subscript checks can be optimized out, if the compiler knows they're subscript checks. This is especially true of inner loops, where most subscript checks can be hoisted to the top of the loop, and often optimized out entirely. But compilers have to be allowed to report subscript out of range conditions "early" for this to work. That is, if a FOR loop is going to overflow an array, the compiler has to be allowed to report it at the start of the loop, instead of being required to execute all the iterations up to the buffer overflow and then report it.

      One of the Go compilers does that subscript checking optimization.

    3. Re:Concurrency is still badly understood by phantomfive · · Score: 1

      That's an interesting post. I'm not sure solving the 'inside outside' problem will really fix all threading issues though, because sometimes you want to go outside while maintaining the lock.

      --
      "First they came for the slanderers and i said nothing."
    4. Re:Concurrency is still badly understood by Animats · · Score: 1

      sometimes you want to go outside while maintaining the lock.

      That's OK. What's not OK is coming back in.

      This is difficult to get right, which is why pthreads offer "recursive locks". Go doesn't.

    5. Re:Concurrency is still badly understood by Anonymous Coward · · Score: 0

      I know you write about imperative languages, but I want to point out that this really *is* solved in haskell, fundamentally, and in many different ways.

      First, there is Software Transactional Memory (STM) which is built in.

      http://www.haskell.org/haskellwiki/Software_transactional_memory

      Secondly, something called IVars are syncronous "one-shot" communication channels between threads which, combined with the Par monad lets you create communication graphs which the type system guarantees are dead-lock free.

      http://research.microsoft.com/en-us/um/people/simonpj/papers/parallel/monad-par.pdf

      There are probably other solutions that I've forgotten.

      It is actually solved in multiple ways. First, as you mention, objects are typically immutable in Haskell

    6. Re:Concurrency is still badly understood by ultranova · · Score: 1

      Java addressed this with synchronized objects.

      Java doesn't have synchronized objects. Java has synchronized code blocks, typically whole methods, which synchronize on a particular object, typically the one the function call is associated with.

      Objects ought to be either immutable, synchronized, or part of something that's synchronized. Then you're safe from low level race conditions.

      No, you aren't. Individual objects may be safe from corruption, but the overall system can and will enter invalid states since the state is split across multiple objects. Even if it doesn't, the system will end up taking different code paths and produce different results from run to run due to random timing differences

      What's needed is a language where every operation can only access the results of operations in its causal past, and these results are immutable (because the operations that produced them have finished). Causal past and causal future need to be defined in terms of program logic, independently of runtime timing. Some kind of combination of functional and dataflow language could be a good fit.

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

  29. Sounds like somebody "catching on" by Anonymous Coward · · Score: 0

    Functional programming has gotten so much buzz the past few years, despite the fact that it's as old as math. It didn't take me too long to realize that any real computer is going to have memory, which is to say... it's going to have STATE. Furthermore, much of the world is stateful. If you don't model state directly in the language, you just model it in some klutzy way. Yeah, let's tie the brains of new users in knots making the comprehend monads so we can do... what any old imperetive language does.

  30. Terrible paper by manu0601 · · Score: 1

    I am a low level programmer, and found this paper quite hard to grasp. In my opinion it terribly fails on the vulgarization front.

    I gave up after I understood the problem to fight was that there were state in objects. I understand removing state makes the program simpler (and easier to mathematically prove), but I suspect this brings false assumptions, since the underlying environment (OS, computer, network) is full of hidden states. For instance a memory allocator may succeed or fail regardless of the parameter it was called with.

  31. Still waiting by quax · · Score: 1

    Twenty years ago a CS grad student and fellow at the research center that I worked at, told me that he was certain that after object orientation the next big thing would turn out to be functional programming.

    I thought that made perfect sense and bought into the notion. So I am still waiting.

  32. No safer by SuperKendall · · Score: 4, Funny

    The other way to make code safer, of course, is to eliminate the programmers.

    You would think so, but as a programmer I can assure you that over time code changes itself.

    No way *I* wrote that...

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
    1. Re:No safer by catmistake · · Score: 1

      The other way to make code safer, of course, is to eliminate the programmers.

      You would think so, but as a programmer I can assure you that over time code changes itself.

      No way *I* wrote that...

      Of that I have no doubt. And I know it couldn't be your fault. (And the set up goes like:) Its more likely due to cosmic ray's, man, and eddy's in the space-time continuum!

    2. Re:No safer by omfgnosis · · Score: 1

      And this is his sofa, is it?

  33. Ironic by Anonymous Coward · · Score: 0

    There is no programming language that is both useful and can ensure there are no bugs, so you'll have to excuse those of us who think it looks rather like fighting windmills.

    This might be the first time ever I have seen someone use 'excluded middle' in a true to the definition ironic sense.

  34. Misleading Summary... by ndykman · · Score: 1

    The article just notes that the hybrid approach doesn't magically address the problems in concurrent and parallel programming that other have claimed that they do. No where in the article does the author say that these approaches aren't useful. And I agree, you do need that purity to get those advantages for concurrent programming.

    But, purity comes at a cost. Monads add a order of magnitude of complexity compared to imperative models of I/O. The author notes that other approaches to the problem of side effects are complex that "one shouldn't need a PhD in computer science to code", but I think he fails to notice that monadic I/O is also incredibly complicated to the average programmer as well. It does end becoming a domain specific language very quickly, and that can be a big hammer for a very small problem.

    But, the fundamental argument is sound. If you really want those gains that pure functional languages can bring to concurrency, you have to embrace that model completely.

    However, I don't buy the argument that other approaches won't have merit. I found this paper (http://research.microsoft.com/apps/pubs/default.aspx?id=170528/) to show that type extensions really may have some promise in augmenting imperative OO languages for concurrency.

    1. Re:Misleading Summary... by MadAndy · · Score: 1

      Agreed. I've been working in this industry for 25 years, even actively like functional programming, but monads still blow my fragile little mind.

      A few years back I came across an plain-english explanation of them that made perfect sense, and boy am I annoyed that I didn't bookmark it. I might try to beat my head against the issue again at some point. If anyone thinks they might know where a good description is please post a link :-)

    2. Re:Misleading Summary... by Anonymous Coward · · Score: 0

      But, purity comes at a cost. Monads add a order of magnitude of complexity compared to imperative models of I/O. The author notes that other approaches to the problem of side effects are complex that "one shouldn't need a PhD in computer science to code", but I think he fails to notice that monadic I/O is also incredibly complicated to the average programmer as well.

      I've fucking GOT a PhD in computer science, and I bounced off monads at least twice. It's not so easy now to devote a quarter of my time for four months (the equivalent of taking a grad-level class) to master an incredibly abstruse technique while continuing to use conventional techniques as a full-time job.

      You want the world to use FP (and monads)? Do the work to make them usable and comprehensible to average programmers, instead of just going "tsk-tsk it's a shame mere programmers like you aren't smart enough to keep up". News flash: if your work is incomprehensible to most readers, it's not a sign that you're smarter, it's a sign that you suck at communicating.

    3. Re:Misleading Summary... by ChunderDownunder · · Score: 1

      Mainstream adoption of functional principles? Target developers on mainstream runtimes (JVM, CLR) with languages such as clojure and F#.

      In Meijer's case he explores Monads within Scala in the following course:

      https://www.coursera.org/cours...

      He gives as simple a layman's definition of Monads as possible, in fact deliberately sidestepping the mathematics behind it.

    4. Re:Misleading Summary... by jbolden · · Score: 1
  35. Letting the perfect be the enemy of the good by Bryan+Ischo · · Score: 1

    Haven't these guys ever heard this saying? I have never seen a more comprehensive and obvious example of letting the perfect be the enemy of the good.

  36. Another fad? by Tablizer · · Score: 1

    I remember the "OOP everywhere" fad. Turned out OOP works well in some parts of applications but not others. Functional Programming probably has a similar profile in that it's a nice tool to have for certain applications or parts of applications, but that doesn't mean it should be everywhere. The skill is in knowing when to use it and when not to.

  37. Mao would be proud by Anonymous Coward · · Score: 0

    I am happy this absolutist is talking computer languages and not means of production - else a bunch of us would be facing a purge.

  38. TL by pr0nbot · · Score: 1

    I'm too lazy to evaluate the arguments.

  39. ugh... by SuperDre · · Score: 1

    Well, in the end even the languages itself have to be created using lowlevel languages which don't have all the lazy crap languages have been bloated with these days..
    So it all depends on which level you write your application.
    And there are many ways to do stuff, there is no one right way, and 'good' code is all in the eye of the beholder..

  40. The weakness of statelessness as a principle... by MouseTheLuckyDog · · Score: 1

    for programming, is that it solves nothing.

    Let us imagine for example web servers. Any http daemon should be easy for a single C/C++ programmer to implement.Yes the more all the bells and whistles will take a lot more work, but something functional. --no problem. These things run massively parallel yet have no problems? Why. There is no need for the threads to communicate.

    Where do web servers have conncurency problems?
    Answer, when the execute processes that access shared data For example order processing programs that access the same database. Then all the concurrency problems come back.

    Generally shared data causes enough problems that a fairly intelligent programmer avoids sharing data unless absolutely necessary, like the order processing system. So that any shared data in a concurrent system written by intelligent people is necessary. What's more the machinery required by functional programming requires that the programmer be of average intelligence. So functional programming most likely solves a problem that isn't there.

    To top it off, the part of coding where functional programming is best used, is precisely the easier part of any programming problem. So all the extra effort in functional programming is spent solving the easiest part of the problem which is the part that doesn't need it.

  41. Defensive? by Anonymous Coward · · Score: 0

    Just out of interest: have you seen the wages for good FP programmers recently? (Disclaimer: I am one.) If not, you might want to take a look. The only reason for FP fanboys to "get defensive" these days is when all you rabble start using the word "monad" correctly! :-)

  42. Rubbish by Anonymous Coward · · Score: 0

    This is just wrong. Care to explain how you think a monad "compromises" a functional program?

    I'd suggest that anyone who believes you on this needs to spend a lot more time on simple monads like Maybe / Option, before tackling things like IO and ST. You've obviously got the wrong end of the (non-)burrito. :-)

  43. Lack of knowledge? by Anonymous Coward · · Score: 1

    Well, to be frank, a lack of knowledge and experience sounds like the problem. Imagine hiring a bunch of graphic designers to write C code. To me, that's only slightly more insane than hiring people who only have experience with imperative, mutable languages to write code in a functional language. It's really a different skill set. There are obviously some overlaps, but shifting over to FP often requires substantially more effort than moving between the various imperative languages. Acknowledging the extra work required to "pick up" true FP thinking is part of the problem it faces in the broader industry.

  44. Other people... by Anonymous Coward · · Score: 0

    How about when you pass your code to someone else, or they pass theirs to you? Sure, YOU know which functions are pure, but how could anyone else possibly know that without reading either all the code or trusting the comments?

    What you say is true, of course, and it's a key theme in many books like "Effective Java". However, it's no substitute for a pure, functional language.

  45. You have been listening to Paul Phillips by Anonymous Coward · · Score: 0

    Paul Phillips has lots of good points, but after watching his recent presentations, I worry far more about the health of Paul Phillips than about the health of the Scala ecosystem.

    Seriously, I invite you actually to take a look at the Scala compiler next to something like gcc or clang and tell me, with a straight face, that it's a "fucking mess". The reality is that it's a thing of refined beauty by comparison, and improving all the time. Really, look for yourself!

    1. Re:You have been listening to Paul Phillips by Anonymous Coward · · Score: 0

      Really, look for yourself!

      I have. The clang and GHC code bases are far, far better than the Scala compiler.

  46. But there is an Elixir for FP by Forget4it · · Score: 1

    Functional programming for mere mortals coming soon. Erlang tamed for the new century: http://elixir-lang.org/ Listen here http://programming.oreilly.com... and here elixir computer language

    --
    Artificial intelligence is the study of how to make real computers act like the ones in the movies.
  47. IIR filter by Anonymous Coward · · Score: 0

    An IIR filter is easy, using the Direct Form II Transposed Structure. You just maintain the current state space (z vector) as part of your evaluation:
    (y, z') = iir(x, z)
    What's difficult and / or funny about that? It's a direct transcription of the equations!

    You can wrap it in an ST monad if you want to evaluate the filter over a signal without having to allocate a new z vector for each sample. I ran a benchmark a few years ago and found that an ST version in Haskell was faster than Matlab's shipping implementation... MUCH more readable too!

  48. link not working by Anonymous Coward · · Score: 0

    That link is giving me a blank page :( What's the name of the paper?

    1. Re:link not working by ndykman · · Score: 1

      Well, that's just annoying. My apologies. If you take off the trailing slash, it works fine. The name of the paper is Uniqueness and Reference Immutability for Safe Parallelism.

  49. Captain Obvious strikes again! by Qbertino · · Score: 1

    So "Mostly functional programming is unfeasable"? Oh, really? No shit.

    There's a name for 'mostly funcitonal programming' - it's called 'I-just-started-with-programming-and-Basic imperative spagetti code'.

    There is one situation were functional programming makes sense, and that is when you're not sure which segment of which procedure will come first, either because you can't wrap your head around it due to the complexity of the domain you're just programming your way into or because you really can't know. UI state and workflow procedure is one of those things. It's basically information hiding when building and tying up complex interdependant procedures, and functional programming is the intelligent hack to deal with that. Well-built Spreadsheets of course being *the* classic example of that sort of thing.

    Doing functional programming outside of its domain, like, for instance, modelling a business process or a gameworld, is not only counter-productive, it's flat out stupid/bad software development.

    So, yeah, doing everything functional is unfeasable. Thanks for the news pal.

    That being said, every programmer should look into functional programming and know when to apply it. Switching your mind to functional mode at the right time is a skill that can save a programmer lots of headaches. Quite litteraly actually.

    My 2 cents.

    --
    We suffer more in our imagination than in reality. - Seneca
  50. Pure functional programming is awful by Anonymous Coward · · Score: 0

    The problem with pure functional programming is you get abominations like Erlang (the only language besides Intercal to have a COME FROM statement - code mysteriously starts executing in some other place for no obvious reason), and hacks to work around the limitations of functional programming. Pure functional programming is so mind-bending that it's hard for humans to do. A little functional programming here and there with a closure or anonymous class helps make programs cleaner, but really most programming is easier and more straightforward in a sequential way. Same with asynchronous programming - sometimes you need to do one thing before something else, and if you can't, the result is a huge mess of hacks and pages of checks to see if objects are null because they may not be available. Forcing one style doesn't work. Purists can say what they want, but programmers have voted for hybrid languages like Java to get work done.

    1. Re:Pure functional programming is awful by jbolden · · Score: 1

      Functional programming languages have do structures when you need statements to execute in sequence. But again the idea is that state should be isolated, so the incidental sequential stuff isn't present and only the mandatory sequential stuff is.

      And BTW Excel is a mostly pure functional programming language where order of execution (which cell gets computed when) is not up to the programmer. Lots of pretty average programmers write stuff in Excel all the time.

  51. Tomorrow is here! by Anonymous Coward · · Score: 0

    Why are you talking about tomorrow? There are many FP jobs available today (disclaimer: I work in FP), and they pay VERY well. "Flying cars" suggests that we're still waiting on a demand for FP to materialise, which is a bit nuts if you ask me. If you've got good FP skills, you're in demand RIGHT NOW!

  52. Dude... by Dareth · · Score: 1

    Dude did you smoke the mushrooms then drink the Kool-aid?

    --

    I only look human.
    My mother is a halfling and my dad is an ogre, so that makes me an Ogreling
  53. Nonexclusivism by Anonymous Coward · · Score: 0

    Mostly functional. Side-effect tracing. This is the border where the imperative and the functional styles meet. And on the border, everything lies in the details of the tools and the problems.

    Programs in languages like OCaml are predominantly of a functional style. This gives some of the benefits of functoinal code for that part of the program that can be clearly expressed so. But OCaml does have time-varying variables, and if you use them you can be exposed to the problems therewith. If you go concurrent, you may have race conditions.

    The everyday solution to this is careful coding. When that fails, you'll have bugs.

    There are less common ways of dealing with these bugs. The main one is formal analysis of the critical section structure of the code. Modula 3, (an imperative-style language) had a sophisticated analysis tool for this once upon a time, but that tool is lost to the ages. There are comments in the Modula 3 code of the Trestle user-interface system that serve as archaeological rellics of this analysis.

    And there are starting to be languages with elaborate side-effect declaration systems that mitigate the problem. I've been pointed to the language Idris as an example. It remains to be seen to what extend this mitigates the issue, but it is plainly a next step in formal ways of dealing with these issues.

    But it remains the case that the majority of code today is written in technically obsolete languages. And it looks like the situation will continue for a long, long time, because knowledge of the better ways to do things spreads more slowly than the knowledge how to do things at all. The extremist fundamentalist functionalists are only frightening ordinary folks from even trying functional techniques when those are appropriate. It may seem like an all-or-nothing excluded-middle question if you are trying to reach perfection, but perfection is probably not reachable with practical means anyway.

    There's nothing wrong with following a middle way in the real world. There's everything wrong with sticking with purely imperative code in the real world. Or for imposing purely functional code on all real-world problems,

    Maybe the situation will change with improved real-world technology in the future, but it's lot helpful to take the attitude if "If you're not with us, you're against us".

  54. Call stack as an implicit argument to a function by tepples · · Score: 1

    Tail recursion is just a different way to spell iteration, and a compiler should understand that.

    Unless the language provides security semantics built around inspecting the call stack to see what I/O capabilities are available to a method. For example, a particular function might be allowed to open network connections only to the hostname and port that the caller (or the caller's caller, etc.) has authorized. When I last looked into why Java didn't support O(1)-memory tail calls, ability to check whether or not to throw a SecurityException for I/O was a large part of the reason. Each tail call thus potentially adds another element to the list of security contexts that must be checked.

  55. Linear bounded automaton, not a Turing machine by tepples · · Score: 1

    And there's the rub: no computer is Turing complete. Physical computers have limited memory, making them equivalent to linear bounded automata. Storing every brush stroke in a paint program adds up.

    1. Re:Linear bounded automaton, not a Turing machine by Twinbee · · Score: 1

      The good news though is that as memory increases, it becomes practical to do just as I said. My own OpalCalc program (shown in my sig) does that, restricting the number of undo/redos to say 500 (though I'm sure 5000 would be fine too). The class is less than around 25-40 lines of code. As (text) files inside OpalCalc tend to be on the small/tiny side, no harm is done, and it makes the chances for programmer error much smaller.

      I'm guessing it's easy to code such a system in functional programming ...

      --
      Why OpalCalc is the best Windows calc
  56. Manycore is becoming more important by tepples · · Score: 1

    The synopsis completely misses the qualification, made in the first sentence, that TFA is discussing "concurrency, parallelism (manycore), and, of course, Big Data".

    Apart from "Big Data", that isn't much of a "qualification" anymore. Since CPU clock speeds reached 2 GHz years ago, speed as expressed in operations per second per thread has more or less stagnated in favor of packing multiple cores onto a die. Another trend has been to use slower cores in a device so that the CPU draws less current from the battery, letting the computation complete without having to recharge the battery halfway through. This is why "concurrency [and] parallelism (manycore)" will become even more important.

  57. You now and you in six months by tepples · · Score: 1

    When I write personal code for myself that no one else will touch, I use a globally mutable systems and I have no issues. Globally mutable systems are bad in teams if you're trying to track down who's code is causing the problem because side effects could happen anywhere! But when your a solo guy, you know right away.

    Not necessarily. Practically, you now and you in six months behave almost as if separate people. So if you're going to maintain your program longer than a few weeks, you're going to need to comment what can modify what and make sure to keep the comments updated.

    1. Re:You now and you in six months by GoodNewsJimDotCom · · Score: 1

      I've been working on the same code base for 5 years now... No problems at all. I don't even have a bug that's causing me any problems. Its about 200-400k lines of code too :)

  58. Re:Call stack as an implicit argument to a functio by lgw · · Score: 1

    The Tao gave birth to machine language. Machine language gave birth to the assembler.

    The assembler gave birth to the compiler. Now there are ten thousand languages.

    Each language has its purpose, however humble. Each language expresses the Yin and Yang of software. Each language has its place within the Tao.

    But do not program in Java if you can avoid it.

    --
    Socialism: a lie told by totalitarians and believed by fools.
  59. Re:Call stack as an implicit argument to a functio by jbolden · · Score: 1

    That's why isolating state and lazy is so awesome in FP. Algorithms that open network connections are isolated from algorithms that want to act on a network connection. So if you have a loop of 10,000 elements that need to open 50 network connections the 50 connections calls get grouped:

    List of stuff to send to A
    List of stuff to send to B
    List of stuff to send to C

    the actual opening to A, B and C end up in another module which would have security and which doesn't have the looping structure.

  60. Most languages can be written without side effects by rhalstead · · Score: 1

    That is, IF the programmers and administration are willing to spend the money and take the time to bulletproof the code. to do so, would take at least a second team to do nothing but debug the code as in FDA validation. Every step had to be proven and probably cost as much or more than the original programming. This is far from what hey required for the ACA, Had we tried to pass off that kind of code, the fines and jail sentences would have been huge. The Govt violated their own FDA requirements for rolling out that code,