[Haskell-beginners] Haskell as a useful practical 'tool' for intelligent non-programmers

Michael Orlitzky michael at orlitzky.com
Sun Apr 29 09:32:48 CEST 2012


On 04/29/2012 02:35 AM, Mike Meyer wrote:
> On Sun, 29 Apr 2012 01:20:22 -0400
> Michael Orlitzky <michael at orlitzky.com> wrote:
> 
>>
>> They're wrapped in Proc objects, but those objects can be treated like
>> any other in the language. Everything else is just syntactic sugar on
>> top of Procs.
> 
> That makes *Procs* first class object, not functions.
> 

What's the difference? You're not passing around the actual function, in
any language.


>> This is not conceptually any different to me than in Haskell or C; you
>> have a name for the thing, distinct from the thing itself, and you have
>> to ask for function application via (f x), f(x), f.call(x), or whatever.
> 
> And if having the same set of concepts were all that mattered, we'd
> still PERFORMing blocks of code.  The syntax of a language makes some
> things easier to do, and some things harder - that's why there's more
> than one of them. Writing HOFs is harder in ruby than in a language
> with first-class functions, because you can't pass a function to a
> function.  You have to decide which of the workarounds you want to use
> (blocks or lambdas or Methods or Procs or ...). If you want to use a
> function from the standard library - you have to wrap it in order to
> pass it to your HOF. Since "all of the above" isn't a valid choice, if
> you're trying to use a library of HOFs (assuming such exist in Ruby -
> and if they don't, that's yet another reason Ruby isn't a good way to
> get to Haskell), you may wind up wrapping some things multiple times,
> or wrap the results of your HOFs, or ... well, you get the idea.
> 
> None of this makes Ruby any better or worse for anything other than
> writing code in a functional style. There are perfectly usable
> languages that can't do HOFs at all. That you can do it at all makes
> Ruby a better choice than them for writing functional code. But it
> requires a lot of code that's nothing more than boilerplate, which
> makes it worse than languages that don't require such.
> 
> Of course, if you don't think boilerplate makes things harder, and all
> that matters is having the same concepts, then I expect you won't
> argue if I claim that there's no reason to pick Ruby over Java for
> writing OO code. After all, they have the same concepts, just with
> different syntactic sugar and more or less boilerplate.

We were never talking about easy, only possible. I can pass around
functions just fine if I declare them with Proc.new and call them with
p[x]. Nobody actually does this in practice because classes provide
implicit state, and that combined with blocks solves almost all real use
cases.



More information about the Beginners mailing list