1. 12
  1.  

  2. 6

    I can’t really relate to this post at all, I’m not sure where it is coming from. Is this a real experience people have? I’m generally having the opposite problem: people trying to do FP in languages that do not support it well at all, and you get an even more confusing mess out of it.

    1. 3

      I have genuinely had a CTO-type person send around an email saying “anyone making PRs that use functional programming will be told to redo them”. I replied asking for specifics, with a couple of example cases where the functional way was in line with generally accepted OO principles (e.g. SOLID), and got no reply.

      1. 2

        It’s satire, as with @puffnfresh’s last submission which stated that it was but the first in a series of satire pieces.

        1. 9

          I understand it’s satire, I’m just not sure what it is satiring. What is the grain of truth in this that people connect with?

        2. 2

          I can’t really relate to this post at all, I’m not sure where it is coming from. Is this a real experience people have?

          Me neither. I’ve had people on other teams at employers say that this sort of thing has happened. I’ve also heard stories on IRC. I just got another claim of this via Twitter. Sometimes in a phrasing kinda like:

          I wish I could do FP at work but my boss says no.

          We live in a strange world.

          1. 8

            I’ve heard that kind of phrasing.

            At the start of my career I was the maintenance/support dev for a service. I asked my boss for permission to add tests. He said no. Looking back I can understand that I asked a stupid question out of sheer ignorance and unconfidence, but I still have not figured out why he said no. (I was increasingly idle but they had a contractual obligation to have a dedicated dev.)

            My best guess is that a previous project involved automated testing and went poorly, so rightly or wrongly it shared some of the blame and he wanted to avoid it. Last year I saw a Ruby project fail for people reasons - rather than fix those directly, they fired the Ruby devs, officially banned Ruby for guilt by association, and started a .Net rewrite.

            I have no trouble believing that FP languages or just “style” have been banned by employers, either for being used on projects that went wrong or just for being a risk of a common stereotype like hard, confusing, can’t find devs, slow, too academic, etc.

            1. 1

              Also realize that just because one dev knows FP does not mean the whole team does. If they already have a large code base in an OO language to maintain, and all the developers are proficient at it, the decision to switch would be difficult to make.

            2. 2

              My guess is that this usually means they want to use a different language.

          2. 2

            You’re going to have to add numbers together. Without being pure. You’re going to have to think about this one.

            Challenge accepted.

            The problem is that many languages do this absolutely wasteful pass-by-value thing: you add two numbers and get a third number. You need to make sure that everything is passed by reference. Think about it in object-oriented terms: when I add 5 to 6, am I asking for a new integer with value 11? No, I want that 6 turned into 11. I mean, what else could it be? Who says I’m going to use that 6 again? Why is the language making this decision for me? If I want to reuse the 6, I’ll copy the damn thing! Assembly supports in-place addition (look up addq; it’s true)! It’s just that calling-convention nonsense that forces us into the so-called “pure” pass-by-value convention.

            If you’re using C, just add & before each function parameter name. If you’re not using C, this could be hard. In Java, always use Integer instead of int. Perhaps create a wrapper class so that all of your mathematical operations do the right thing (you know, addition in-place) instead of that wasteful pass-by-value nonsense for the quiche eaters who can’t handle mutation. If you’re in a high-level language like Python or Ruby, you may need to hack it, or you might alternately have to create a new language where everything is truly an object and 6.+(5) does the right thing and mutates the 6.

            We’ll get there. Don’t worry. Plenty of software managers are leading us in the right direction on this one.

            1. 2

              I’d like to hear about the other end of the spectrum: when developers choose functional programming out of almost complete ignorance or because it’s the thing right now. Maybe this isn’t something to be discouraged, but I sometimes wonder how many choose Scala because, at first glance, it sorta looks like their favorite scripting language. To be fair, it’s possible they begin earnestly adopting the language and its style… but you can’t help the feeling that this is driven by fashion.

              1. 3

                I found my way to functional and Scala by way of the checkers framework, initially triggered by http://www.joelonsoftware.com/articles/Wrong.html

                I think there’s a convergence of languages. Scala looks like Python because both are trying to look like pseudocode. Even modern Java is moving towards that ideal. Moving towards a readable language is a good thing, and Scala is (or rather, well-written Scala can be) possibly the most readable mainstream-ish language with decent performance[1]. (Theoretically Haskell should be better, but I always find it unreadable - some combination of the terse variable (and type) name culture, the lack of syntax that looks like syntax, the overpowered $ operator/bracket, the lack of OO…)

                I think if you take ordinary good programming practice - separation of concerns, encapsulation of state, composability - far enough, you end up with functional programming.

                [1] I’m somewhat disturbed that Python and Ruby perform so much worse than Javascript - there’s no real reason this should be the case, and I see a lot of people leaving Python for performance reasons when it’s really the best language for what they need to do. I think it’s an artifact of there being much more moneyed competition in web browsers than in other language runtimes?