pat_shaughnessy

Joined 15 years ago

Karma
426
Submissions
81
Member since
Apr 4
Boston based Ruby developer: http://patshaughnessy.net and @pat_shaughnessy
View on Hacker News

Recent submissions

Comment · 11 months ago
Comment · 11 months ago
> Idiomatic Ruby uses blocks for loop bodies

Yes that's something I want to dig into and explore in this chapter... when exactly does Ruby's JIT compiler activate and optimize our code? And you're right: since Ruby will JIT blocks as if they were separate function many loops will be optimized using this simple heuristic.

Comment · 11 months ago
What a lovely comment - thank you!
Comment · 10 years ago
I tried that while researching the article, but found the call to "puts" doesn't link without the standard library code. And without a "puts" or similar call to produce output LLVM optimized the entire program away :)

I suppose this could work if, as you suggest, I manually called out to a lib_c function like printf instead.

Comment · 10 years ago
(author here) ...FYI I actually learned assembly language for the first time back in the 1970s and 80s using a 6809 inside a Radio Shack "Color Computer." I was super-fun at the time. I don't remember much of it now but I'm sure x86 isn't as clean or fun as 6809 assembly was.
Comment · 10 years ago
Thanks a lot. I'm looking forward to writing it, I think it will be interesting.
Comment · 10 years ago
Thanks! Glad to hear you made it to the bottom :) I always worry that I tend to write on and on for too long.
Comment · 10 years ago
Thank you! Knowing that people enjoy reading this sort of thing makes it worthwhile.
Comment · 10 years ago
Thanks everyone for the kind comments, and for taking the time to read this stuff :)
Comment · 12 years ago
Yes, good point. Rails has a lot of conventions like this - that "first" implies ordering by primary key (by default). I just imagine that most Rails developers don't think about sorting and its implications when they ask for the first record.
Comment · 12 years ago
Oh absolutely. I thought about saying that, and just ran out of energy before posting the article this morning.

The reason I used this particular SQL statement as an example is that ActiveRecord (a Ruby ORM) generates it from a fairly simple, common Ruby expression. I suppose ActiveRecord could be improved to drop the sort when you know there's one one possible match.

Comment · 12 years ago
By the way, I used a simple query on purpose to keep things simple for readers (and for me, the author!). By using such a simple SQL statement I was able to avoid complex optimizations and algorithms I would haven't been able to follow - and that wouldn't have helped readers much anyway. I wanted to get the basic idea across to people who have no prior knowledge of DB internals.

Plus I wasn't interested in comparing one DB vs. another, as much as I was interested in understanding how any DB works.

Comment · 12 years ago
Comment · 12 years ago
Thanks :) Yea indexes are where some of the real "magic" of database servers happens. It will be fun to write that up...
Comment · 13 years ago

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton