Live data from Hacker News

Execution in the Kingdom of Nouns (2006)

steve-yegge.blogspot.de

41–50 of 73 posts

Re: Execution in the Kingdom of Nouns (2006)

#41

OOP goes bad when you take a centralized design and nominalize the verbs, yes. It's more fun to think in terms of trained animals: "Trash, go empty yourself outside." TrashBag >> emptyInto: vessel |here| here := self place. self go: vessel place. vessel add: self spill. self go: here This seems just as reasonable as the English he wrote. (I like functional programming too.)

Trained animals is a good metaphor. Not passive objects acted upon but actors. Your example is even cleaner in Self which allows implicit 'self':

  emptyInto: vessel = (| here |
    here: place.
    go: vessel place.
    vessel add: spill.
    go: here
  )

Re: Execution in the Kingdom of Nouns (2006)

#42
post #11

Earlier quoted context omitted.

This is why the fundamental operation in the land of the verbs is composition: do this then do that. It turns out that composition is such a useful idea that we want more of it, which is where categories, monads and arrows come in. The most obvious type of composition for functions is, well, function composition. In math we define the composition of functions f and g as f(g(x)), usually written as f ∘ g. We can write…

Your explanations of Haskell concepts have been impressing me lately. Do you write elsewhere?

I keep on meaning to start a blog, but haven't gotten around to it yet :/. I even have some half-finished articles lying around.

One of these days...

Re: Execution in the Kingdom of Nouns (2006)

#43
I remember reading this. Highly recommended but the methodology dogma goes both ways.

My take on it is this. Object-oriented and imperative style is eating with a fork and a spoon. Functional technique gives you a knife. The people I'm most suspicious of are the ones who think I'd be more productive if one of my utensils were taken away.

Re: Execution in the Kingdom of Nouns (2006)

#44
post #7

The problem with verbs is that they are black boxes. With objects you can subclass and override methods - do stuff like the Universal Design Pattern - basing something on prototypes that you tweak here and there. Functions you can only apply, objects have parts that have names.

You can fake objects and subclassing with closures, in addition to making it trivial to implement the "one method interface" (aka "functor"). http://roboprogs.com/devel/2010.06.html (example using a subset of JavaScript, rather than a language likely to be unfamiliar to most) TODO: edit example someday to get rid of "useless use of local variables" (in place of original formal parameters), fix where I call the outer…

I always thought this koan summed up this concept best: http://stackoverflow.com/a/501053/580947

Re: Execution in the Kingdom of Nouns (2006)

#45
post #22
post #18

This is a real classic. As someone who had only done imperative programming before reading this it really inspired me to give FP a try and led me down the road to trying Scala and then Haskell. However a year into this adventure, I still prefer "nouns". I think the human brain really does work imperatively for most logical problems. I can't deny that for a single problem the functional solution is often more " beauti…

I think you've mistaken Yegge's point if you see it as "Declarative functional languages are better than imperative ones." It's more about how the version of OO embodied in Java warps your program designs in an awkward way. He presents functional languages as the antithesis of this because, well, they are. But it's certainly possible for an imperative language to put functions and data on the same level — Yegge's fav…

I understand it was more anti-Java than pro anything else, I just saw functional as his solution to this problem. I'm already fluent enough with Java that I see absolutely no need to switch to a different imperative language as my main workhorse, so I looked at Haskell as a sort of "go big or go home" approach to weaning myself off of mutable state, etc.

Re: Execution in the Kingdom of Nouns (2006)

#46
post #31

I like first class functions. I get hung up on the trash example in this essay though. To show the commonality of verbs in a person's general understanding Yegge says 'get the garbage bag from under the sink'. WTF (Who the fuck) 'gets' the garbage? I do. 'I' is implied. I get the garbage from under the sink. Or perhaps 'Steve' gets the garbage from under the sink. These are nouns (or pronouns, whatever). If anything,…

> If anything, verbs do nothing without a noun to do them, and nouns need verbs to do anything.

O Canada! It's raining.

Re: Execution in the Kingdom of Nouns (2006)

#47
post #31

I like first class functions. I get hung up on the trash example in this essay though. To show the commonality of verbs in a person's general understanding Yegge says 'get the garbage bag from under the sink'. WTF (Who the fuck) 'gets' the garbage? I do. 'I' is implied. I get the garbage from under the sink. Or perhaps 'Steve' gets the garbage from under the sink. These are nouns (or pronouns, whatever). If anything,…

Right, OO vs functional is not either/or. It's an ever-present duality (data and algorithms) in any language. The problem is that discussions about achieving the optimum balance for a job are too subtle and non-sensational. Bloggers and commenters prefer polemics, so instead you mostly see die-hards who enjoy combative flamewars for an acclaimed tribal superiority.

Thankfully, a while back I saw an enlightening wiki page on c2.com.[1] Recognizing the yin-yang relationship where one cannot exist without the other gives a much better understanding of both.

The venerable master Qc Na was walking with his student, Anton. Hoping to prompt the master into a discussion, Anton said "Master, I have heard that objects are a very good thing - is this true?" Qc Na looked pityingly at his student and replied, "Foolish pupil - objects are merely a poor man's closures."

Chastised, Anton took his leave from his master and returned to his cell, intent on studying closures. He carefully read the entire "Lambda: The Ultimate..." series of papers and its cousins, and implemented a small Scheme interpreter with a closure-based object system. He learned much, and looked forward to informing his master of his progress.

On his next walk with Qc Na, Anton attempted to impress his master by saying "Master, I have diligently studied the matter, and now understand that objects are truly a poor man's closures." Qc Na responded by hitting Anton with his stick, saying "When will you learn? Closures are a poor man's object." At that moment, Anton became enlightened.

1. http://c2.com/cgi/wiki?ClosuresAndObjectsAreEquivalent

Re: Execution in the Kingdom of Nouns (2006)

#48

Yeah, but you can always have static methods, which let you call a function without creating an object.

Sure, which you can use the following ways: * C: function pointer * Pascal/Delphi: procedural type * JavaScript: function/expression as r-value (weakly typed) * C#: delegate * Java: er, ah, well, I guess you're screwed, as there is no way to pass that function around to other functions. Maybe in Java version N+1! (or Scala or Groovy) -- that is, a static function is even worse than a "virtual" function, since you can…

[deleted]

Re: Execution in the Kingdom of Nouns (2006)

#49

Yeah, but you can always have static methods, which let you call a function without creating an object.

Sure, which you can use the following ways: * C: function pointer * Pascal/Delphi: procedural type * JavaScript: function/expression as r-value (weakly typed) * C#: delegate * Java: er, ah, well, I guess you're screwed, as there is no way to pass that function around to other functions. Maybe in Java version N+1! (or Scala or Groovy) -- that is, a static function is even worse than a "virtual" function, since you can…

[deleted]

Re: Execution in the Kingdom of Nouns (2006)

#50

Yeah, but you can always have static methods, which let you call a function without creating an object.

Sure, which you can use the following ways: * C: function pointer * Pascal/Delphi: procedural type * JavaScript: function/expression as r-value (weakly typed) * C#: delegate * Java: er, ah, well, I guess you're screwed, as there is no way to pass that function around to other functions. Maybe in Java version N+1! (or Scala or Groovy) -- that is, a static function is even worse than a "virtual" function, since you can…

[deleted]
Post reply on HN