HNHacker News
TopNewBestAskShowJobs

rkts

277 karma · joined August 16, 2007

submissionscomments
rkts··on Why you shouldn't go to law school.
http://ycombinator.com/hackernews.html

"The focus of Hacker News is going to be anything that good hackers would find interesting. That includes a lot more than hacking and startups. If you had to reduce it to a sentence, the answer might be: anything that gratifies one's intellectual curiosity."

rkts··on Passwords are broken because they're incompatible with human behavior
Completely off topic, but can we all stop using the word "humans" to make ourselves sound objective and scientific? Unless it's part of a comparison with other species, the word is "people."
rkts··on ... because Ruby isn't terse enough yet
In ML you can get a similar terseness to that of Haskell, but with support for imperative programming. If we allow the increment function to be predefined (as the Arc example does):

 let inc a b = a := !a +/ b; !a
then foo becomes:

 let foo n = inc (ref n)
or, with the help of the composition operator:

 let (<<) f g x = f (g x)

 let foo = inc << ref
rkts··on California
Let me give you a real example from a program I worked on. I'll simplify the code.

Say you write a function that takes input given by the user, inserts it into a list, and then sends the action across the network. Every item has an ID, so when the function finishes, the current ID number needs to be incremented.

 add_item (item) {
     var item_id = current_id;
     insert_item(item, item_id);
     update_current_id();
     send_item(item, item_id);
 }
You write the function, and it works, and no one has any problems with it.

Two months later, you come back to the function and think, "That's messy. I should clean that up." So you do.

 add_item (item) {
     insert_item(item, current_id);
     send_item(item, current_id);
     update_current_id();
 }
Do you see a problem with this code? No, you don't. You even run the program and try it out, and everything seems to work fine.

What if the function header had said "throws NetworkException"? You might have been more careful, but I wouldn't count on it. If the function were longer, which it would be in real life, you probably wouldn't catch your mistake.

On the other hand, what if the code looked like this?

 add_item (item) {
     if (insert_item(item, current_id) == INSERT_ERROR) {
         return INSERT_ERROR;
     }
     if (send_item(item, current_id) == SEND_ERROR) {
         return SEND_ERROR;
     }
     update_current_id();
     return SUCCESS;
 }
Do you see the problem now? Of course. It's staring you in the face: current_id won't get updated if the network goes down. The result is that you could have two items in your list with the same ID.

This isn't "nuclear power plant" paranoia. What I'm describing is a real bug I had recently. It wasn't the first time that I've done something like this, either.

I like your idea of putting the throws clause next to the function call. I'd like to see something like that for checked exceptions, and eliminate unchecked exceptions completely.

rkts··on California
Sigh... Obviously errors should be able to propagate up the call stack. But that propagation needs to be done explicitly. Simply tacking "throws IOException" onto your function header isn't enough; it's still too easy to mess up.
rkts··on California
> They supposed to be used for exceptional results that cannot be handled locally.

The point is that there is no such thing. Exceptional situations should always be handled locally, and by locally I mean on the very next line. If they can't be, then the program should stop running.

Writing code with exceptions is very hard to get right. Not checking return values is just stupid.

rkts··on California
> exceptions suck, Hungarian notation rules and so on.

Have you actually read his article on this? I think it's very good.

http://www.joelonsoftware.com/articles/Wrong.html

Joel doesn't say that you should prefix integer variables with 'i' or use -1 as an error code (he prefers returning multiple values). He only says that every line of code should indicate as clearly as possible what it's doing so that you can still understand it six months later.

Exceptions eliminate one problem (a function can only return one value) but introduce another: it's impossible to tell by looking at a block of code where it will exit. If a series of statements might get interrupted halfway through, there needs to be an indication of this or else it's very easy to create bugs. I know this from experience.

rkts··on California
Why is there so much hostility toward Joel here? He writes interesting and popular articles and half the comments just attack him for not being substantive or serious enough.
rkts··on Bertrand Russell: The Value of Philosophy
> different forms of moralizing - utilitarian and the categorical imperative - use different brain systems.

Whenever a neuroscientist gets involved in these debates, I see a lot of claims like this. "Thinking about x uses brain system y, therefore [some outrageous claim]."

In this case, you seem to be suggesting that the brain activity proves "both types of morality are wired into us," but that doesn't follow at all. Brain activity doesn't tell us whether utilitarianism or the categorical imperative accurately model what is really happening in the brain, or whether the corresponding thoughts and behaviors are innate or learned.

rkts··on Functional Programming in Python
Higher-order functions do entail a sacrifice to readability compared with plain loops. The reason should be fairly obvious: loops use indentation and syntax to show visually the structure of what they do, but that goes away when you pack the logic into a higher-order function. A function call is a function call; they all look the same.

Fortunately, there exist solutions to this problem. The Haskell solution is to make your code so damn concise that you don't need to add any structure to it. The Lisp approach is to allow you to program the representation of your code in arbitrary ways.

Both are, I think, superior to the Python solution, which is simply to revert back to the imperative style.

rkts··on Joel explains how a new monopoly will emerge around AJAX
> His posts about "harm of exceptions"

So am I officially the only person who agrees with Joel on this?

rkts··on The Unexpected Uselessness of Philosophy, The Unexpected Usefulness of Mathematics
Awesome. A lot of people revile Steve Sailer, but I think he's one of the best essayists writing today.

This quote in particular elegantly sums up the history of philosophy:

"To this day, most philosophers suffer from Plato's disease: the assumption that reality fundamentally consists of abstract essences best described by words or geometry. (In truth, reality is largely a probabilistic affair best described by statistics.)"

It's not so much the world that's probabilistic, though, as the human mind and the thoughts and abstractions we impose on the world. Hume was the first philosopher to explicitly argue that the mind works this way, and modern research has supported him.

I think that, as Sailer briefly suggests, there is value in studying the works of skeptical philosophers like Hume: it gives you the tools to see through the kind of bullshit that philosophy is full of. Because you don't just see it in philosophy. It's there whenever people argue about politics or religion, and whenever a dreamy computer scientist rambles about "objects" and "types" and whatnot. It's useful to able to refute these arguments by recognizing their meaninglessness.

rkts··on Researchers show that liberals and conservatives approach everyday decisions differently.
Please tell me I'm not the only one who recoils at the inference from

"Liberals had more brain activity and made fewer mistakes than conservatives when they saw a W"

to

"Based on the results, he said, liberals could be expected to more readily accept new social, scientific or religious ideas."

!

As the article notes, political orientation is correlated with a lot of things: income, education, religion, race/ethnicity, etc. Even if they tried to control for any possible confounding variables (the article doesn't mention whether they did), I'm very skeptical that they've successfully isolated a causal relationship between liberalism/conservatism and some innate brain capacity that makes you good at pressing a button at the right time.

← PreviousPage 4 of 4