Live data from Hacker News

How A Pull Request Rocked My World

clayallsopp.com

91–100 of 158 posts

Re: How A Pull Request Rocked My World

#91

Earlier quoted context omitted.

> I also don't like how your comment tries to make fun of his efforts to learn something new. The problem is not that he's learning, he's teaching.

Why is that a problem? As I pointed out, he's just showed us a metaprogramming trick he thought was cool. That is no indication that he is an inept programmer or someone that should be allowed to teach something like RubyMotion (if he was writing a book on metaprogramming, that's another thing).

No problem at all, I was talking about the book. Even if he hasn't lied, when one reads the "author" section, it sounds like he's an expert. In the description of the book it also says it can help you even if you are a "veteran", which might be true (or not), but makes one think he is a veteran too. It's misleading.

Re: How A Pull Request Rocked My World

#92
This person found something that they didn't know they didn't know and were so happy they blogged about it. Regardless of what I may personally think about the merits of the code before or after, it makes me happy that there is another human being who is thrilled by learning something new about programming.

Re: How A Pull Request Rocked My World

#93
post #88

Earlier quoted context omitted.

Early in my career, a project manager said to me, "I've never heard one programmer praise another programmer's code. They always criticize!" I think that reinforced for me both that someone's approach might be good even if it isn't my own, and also that it's important to say when something is done well. Of course, there's also just a lot of bad code out there.... :-)

A lot of programmers are insecure. They were the nerds in school, not popular, not good at sports, etc. Programming is the one thing they can do where they feel in control, and confident. So they naturally tend to be defensive about it.

> A lot of programmers are insecure.

You mean a lot of persons? If you don't, I wonder where you got this from. Personal experience maybe?

Anecdotic: I have always been good at sports, popular, and confident, and I criticized this article because he used a kind of link-bait title (should have been "Today I learned about inheritance and it's awesome", something like that), and he also turned out to be selling programming books like he was an expert, which is scammy, and reinforces the fact that you can only find good books through recommendations from your peers.

Re: How A Pull Request Rocked My World

#95
post #17

Earlier quoted context omitted.

...I rarely trust these kinds of name-generation tricks. So you're probably not a big fan of Rails, then?

I'm actually not a huge fan of implicit name-generation tricks, but I'm also not entirely opposed to them. The trick here I think is consistency - is name-generated type dispatch the standard across the entirety of the codebase? If it is, go wild. If it's not then I'd be much more wary of it. Consistency and building correct expectations for future maintainers is pretty important. Doing a smart trick in one place but…

I so agree with you. There are few programming mistakes that consistency in use does ameliorate. On the other hand, no matter how "good" the code, if it's inconsistent, it's bad.

Re: How A Pull Request Rocked My World

#96

Reading the comments in this thread is very interesting to me, because each programmer seems certain of the superiority of his own programming style. We have some comments that disparage the change, saying that it obfuscates the code and makes it more difficult to understand. We have others saying that this change is a basic technique and it's "shocking" that the author wrote a book without this simple knowledge. Wha…

A technique can be both basic/obvious and not a course of action that everyone would agree upon.

The surprise isn't that he didn't make the choice to do it that way. The surprise is that the choice didn't occur to him. The feedback would be very different if he simply had made a different choice.

Re: How A Pull Request Rocked My World

#97

Earlier quoted context omitted.

How many books did you wrote ?

I did write about twelve books and I still consider OP's point to be very valid. The blog entry is great in that it shows how collaborating over the Internet can lead to improvement but it's indeed a bit concerning that someone who didn't know what polymorphism was had been publishing a programming book.

> very valid

Validity is a binary state. Don't modify it with an adverb.

Re: How A Pull Request Rocked My World

#98

Reading the comments in this thread is very interesting to me, because each programmer seems certain of the superiority of his own programming style. We have some comments that disparage the change, saying that it obfuscates the code and makes it more difficult to understand. We have others saying that this change is a basic technique and it's "shocking" that the author wrote a book without this simple knowledge. Wha…

I think that programming is very close to how we actually think. Programmers tend to be objective people who like distinguishing good from bad and better from worse. They're generally analyzers to the core.

But we all have some personal aspect of how we see the world. How we organize logic, view priorities, and such, is all personal and unique, no matter how much we may feel that it's objective.

Programming is an expression of that inner thought life. It's how you organize, categorize, and optimize, all laid out in bare raw form. It's an expression not just of our identity, but to an extent of how we exist. Being who we are, we usually tend to think highly of ourselves and our way of doing things, so it's only natural that we think highly our code style.

Re: How A Pull Request Rocked My World

#100
Fabio's approach does the job, but it fails at genericity - its usefulness is limited to the scope of the Formotion project. Which is unfortunate because something actually simple is going on - a mapping of keywords to functions.

What you really want is multimethods - they provide all the goodness of classic polymorphism, without forcing you to model intrincate, rigid class hierarchies/relationships.

Some pseudocode illustrating the concept:

    # declaration. the 'dispatch function' we pass can build an arbitrary value out of the args it receives.
    defmulti build_cell lambda { |args| args[1].tag }
    
    # if the value the dispach function generates equals :submit, this body is gonna be called
    defmethod build_cell :submit do
        # implementation...
    end
    
    # more defmethods for :switch, :check, :edit etc
    
    build_cell(row, cell)
    # our lambda gets invoked, which re-passes the arguments it receives to the corresponding implementation
Multimethods doesn't seem to be have been adopted at all in the Ruby community. A quick googling reveals a couple implementations though.

In the Lisp world they are first-class, even though they aren't used all the time. http://clojure.org/multimethods might be worth a read.

Post reply on HN