Earlier quoted context omitted.
Wow, I sure have the opposite reaction to you. Makes me wonder what kind of code you wrote. Some specific points: "One is code reuse: yes FP code is definitely more reusable. The problem is that the kind of code it enables reuse of more than OO is very small, simple loops." Combinator libraries sure are pretty useful, and they're more than small simple loops. "Writing the same 4 line method -- that could have been ab…
> Combinator libraries sure are pretty useful, and they're more than small simple loops. Useful -- yes. Useful enough to pay the price -- IMO, no. OO is decent at code reuse, and the most effective, most important code reuse, is that of big libraries with rich functionality, which is done rather well in many programming paradigms (i.e. pure, statically typed FP has little to no advantage here). > Very puzzled how you…
A Year of Functional Programming
61–70 of 172 posts
Re: A Year of Functional Programming
#62Earlier quoted context omitted.
To be honest, I'd be happy with a 1 level interactive demo (with sound) of a Mario Brothers style platform game.
That is sort of the worst case scenario for a FP program (though I'm sure you could write it in FP). It is almost entirely side-effects. I agree with the sentiment that for a paradigm that has been advocated for 60 years it is really odd how little non-academia code is written in it. In my experience you find functional code shines (and is therefore common) in places where prove-ability is of the utmost importance or…
Re: A Year of Functional Programming
#63I used to like functional programming. Now I think that it's -- more often than not -- a solution in search of a problem. I can understand some of the things FP gets you (although those come at a cost, which I'll get to later); I'm just not so sure these are the things we need, or that FP is the best solution for them. One is code reuse: yes FP code is definitely more reusable. The problem is that the kind of code it…
> One is code reuse: yes FP code is definitely more reusable. The problem is that the kind of code it enables reuse of more than OO is very small, simple loops. It sounds like you just haven't used Haskell enough to have the full extent of the reusability become apparent. I agree that on the surface it seems like you're right. But that particular example of reuse is just the tip of the iceberg. It's actually a very p…
If we're talking real world -- as we should -- then this should be contrasted with the tradeoffs and alternatives. The most important kind of code reuse, IMO, actually happens at a larger scale, and in the past few years has worked remarkably well, since the advent of open-source. I'm talking about reusing projects like ZooKeeper, Hadoop, etc. Being able to use such a project might save you millions of LOC, regardless of the level of internal code reuse. The lack of Haskell libraries and bindings relative to other languages reduces this most important kind of reuse. In fact, using ZooKeeper also reduces a large number of bugs.
> But don't worry, we're working on it.
Excellent. I'd love to get a full picture, tradeoffs and all, of a big, important software project in Haskell (which isn't a compiler).
> The other day our newest hire made the comment that at our company each individual developer is responsible for roughly the equivalent of an entire team at all his previous jobs.
I can say the same for my current job, even though we're mostly doing Java (and some Clojure), and at our previous jobs we also used Java. This mostly has to do with the quality of developers, company structure and size, and less with the choice of programming language.
Re: A Year of Functional Programming
#64Ask HN: As somewhat of an old timer, I have a couple of questions about FP, not really worthy of creating their own thread: 1. I learned a rule (in my Pascal textbook), "avoid globals." Is FP just an embodiment of that principle? 2. I do a lot of programming involving hardware, often homemade. Hardware has state, such as whether a lamp is turned on or off. Does this just mean FP is inappropriate, or are there techniq…
That said, I agree with others here that there might not be an FP language that is a good fit, mostly because they have some trouble giving good guarantees about memory usage (particularly true of Haskell, with its lazy evaluation, but gets to be the case whenever you're passing a lot of closures around).
Re: A Year of Functional Programming
#65Earlier quoted context omitted.
I'm starting to think that different programming styles are more suited to different levels of abstraction - maybe you can program in an OO style at a high level, use functional style code for the low level implementation.
"maybe you can program in an OO style at a high level, use functional style code for the low level implementation." That's sort of the Erlang approach, right?
Which is generally considered an extremely pragmatic language.
I guess it all goes back to the Actor model and the origins of OO in Simula.
Re: A Year of Functional Programming
#66Ask HN: As somewhat of an old timer, I have a couple of questions about FP, not really worthy of creating their own thread: 1. I learned a rule (in my Pascal textbook), "avoid globals." Is FP just an embodiment of that principle? 2. I do a lot of programming involving hardware, often homemade. Hardware has state, such as whether a lamp is turned on or off. Does this just mean FP is inappropriate, or are there techniq…
FP hides state behind the concept of monads. This tends to make state-heavy systems harder. Often small embedded systems follow the "state machine" design pattern.
Re: A Year of Functional Programming
#67 If you use language 'x', then using
mutation is wrong.
and recently, I've been thinking about the practically important but socially awkward question: What language is best for implementing
mutable state?
By which I don't mean: What language makes avoiding mutable
state impossible?
because given my skill set on some absolute scale that encompasses Knuth, I've got big fish to fry. Trying to maintain ideological purity is a distraction at best and an impediment at worst, if I am ever to see an [m42] and have a solid intuition about its solution.Even the most rousing chorus of 'Onward Christian Soldiers' isn't going to help me implement Hoare's Quicksort in Clojure. Consing and filtering are great, but they miss the idea of working in-place. Racket's built in O(log n)priority queue isn't a substitute for a traditional O(1) queue implementation:
+-------+
| | o-|------------------+
+-|-----+ |
| |
v v
+-------+ +-------+ +--------+
| | o-|--->| |o-|--->| | nil|
+-|-----+ +-|-----+ +-|------+
| | |
v v v
'a 'b 'c
The built in priority queue is mutable anyway.The illustration of queues in Racket isn't rendered from whole cloth. If one searches the Racket documentation (depth first is implied?) the only hit for 'queue is the priority queue which lives in the 'data library [and again, it's still mutable and not thread safe]. But the real problem is that providing Racket implementations on Rosetta code is one of those ways Racketeers are encouraged to give back, and the implementation of LIFO on Rosetta Code shows the priority queue, rather than an actual queue, in part because using 'mcons is considered taboo under functional programming mores. It's a socially acceptable answer, rather than a correct one.
Some things just have to be to be mutable in order to get built in a way that will be useful when dealing with large tables when the first test of usability is getting built in the first place. It's not that playing with dangerous objects ought to be encouraged, it's that it there's nothing wrong with a little dynamite now and then for removing stumps when the alternative is lifting the grinder to the top of the cliff with a crane. All that really matters is acting in accord with the fact that, yes, we're using dynamite.
There's a continuum between Coq and MMIX. A good functional programming language allows refactoring a solution from right to left. It doesn't pretend as if there isn't a right wing or that it doesn't matter politically.
Re: A Year of Functional Programming
#68Nice article! I have been using Clojure for years, initially because a repetitive customer mandated its use, later for my own projects because it reduced my development time and is fun to code in. I tried Scala (really liked Martin Odersky's Coursera class!) but it did not stick. That said, Haskell has started to win my mind share. At least for my own projects I have been mostly using Haskell this year, with some bit…
That's a bit of an off-topic but may I ask, why Haskell over Clojure. What are the differences? You partly asked that in the 2nd part, but I would like to know more. I never did any serious FP so would love to know where to start: Scala? Clojure(Script)? Haskell? F#?
Re: A Year of Functional Programming
#69Earlier quoted context omitted.
The lack of magically bug-free, FP OSs, drivers, control software, and large applications, shows that even the biggest supposed benefits of languages like Haskell, are yet to be demonstrated in the real world. I've been reading religious advocacy of FP for almost 15 years now and yet there still don't seem to be many non-trivial apps written in any of these languages. Certainly many individual features of FP have bee…
> and yet there still don't seem to be many non-trivial apps written in any of these languages Perhaps you are not looking hard enough? Sure, if your problem space is CRUD web apps, then you won't find many implementations. Try looking into more difficult problem spaces, such as high-frequency trading, and you'll suddenly find more FP examples. Also, there's Erlang, which was developed by Ericsson to solve a very spe…
I doubt any of these languages are significantly more popular in "more difficult problem spaces."
Re: A Year of Functional Programming
#70It's not that I don't think that programming in a functional style isn't a good idea , it's just that the discussions about functional programming and the languages people use to implement its style so often suggest: If you use language 'x', then using mutation is wrong. and recently, I've been thinking about the practically important but socially awkward question: What language is best for implementing mutable state…
The beauty of how Dancing Links works is rather remarkable. Similarly, finally understanding how to read some of the algorithms as specified has helped to see just how "imperative" algorithms can be analyzed rather comprehensively.
Also, as a major aside, I would encourage more folks to try the Knuth works. Definitely feel free to skim the math, as that is some pretty hairy stuff. At the same time, keep trying to go back to it later. Most of it isn't undoable, so much as it is just completely foreign to what you probably do day to day. Seeing the connection between it and many typical programming tasks can be tough. (Indeed, I don't think I've done so, yet.)