Justify that with actual math, please? I don't think you know how computers (processors, bus, memory access, etc) work. How exactly do you think an RDBMS can query an index at a hundred billion rows per second?
The parent said a query of a hundred million rows, i.e.: `select * from users where id = ?` when there are a hundred million users. That's obviously not scanning a hundred million rows, since the index will be a b-tree which by the power of logarithms is not so many levels deep.
Like Illniyar, that's also what I interpreted GP to mean when they said:
> "surprised that some NoSQL DB could do a query on hundred million rows in a few seconds"
which is not fast at all. However, if it actually did something on a hundred million rows that would be impressive. Not sure exactly sure which they meant, though.
Illniyar is right, a b-tree with a branching factor of 100 can index 100M rows in 4 levels. Even with the index on a spinning disk, should have no trouble coming in well under 100ms.
Indexes like this are also typically in memory to begin with, making it even faster, since you only have to find the actual record on disk.
Even better, if you only need one field from the record, and it's part of a compound index, you can frequently return the data from just the indexes; no disk seeks required. Small tip with InnoDB on MySQL - any non-primary key index is automatically a compound index with the primary key.
I'm the article's author. I don't think the headline HN chose is great but I don't mind if people have different interpretations of what I write. Hopefully all the commenters here are actually reading the original article and judging it on its merits (and flaws), right? right?
This is an excellent point. The distribution of the measurements are the distribution of the sample, not of the population. In my experience very few non-statisticians understand the difference. Statistics is hard.
This is true. I almost mentioned the difficulties of estimating the kernel density bandwidth in my original post, but thought that would be getting too far on a tangent.
I've been crossfitting for years at kylered's gym. I've also judged at the competition series he mentioned, and traveled and worked out at crossfit gyms all around the country.
I've seen some bad coaches, but I've seen a lot more people who are uncoachable and are going to injure themselves in any gym with any workout and any coach. I've never seen anyone vomit, injure themselves, get Rhabdo, pass out, or any of the other things people think are so common in Crossfit. Predictably, Crossfit haters sensationalize, and people who push themselves too hard and regret it tend to angrily blame Crossfit in public instead of themselves.
CrossFit changed my body, my self-image, and a lot of my attitude, but any other gym that's based on fun, positive encouragement from other members doing the same workout at the same time, variety, intensity, and a community of friends would do the same thing.
For the record I rarely "Rx" a workout and I almost always come away from workouts thinking I sandbagged it a little. And yet I'm very happy with my results. Why would I want to push harder and risk injury? I wouldn't. I insist on doing every movement perfectly, pausing or lowering weights or reps if I'm getting tired or winded to the point that my form might be at risk, taking it easy if I've had too little sleep or I'm dehydrated or whatever. I know a lot of people who have a similar philosophy and I admire their sense, not their hard-core-ness.
I don't buy the OP's claim that he got sick from a not-overly-strenuous workout. A Crossfit workout is no different than any other, except that if you overdo it in another style of fitness and get critically ill you don't get attention on Hacker News.
TL;DR - you can lead a horse to water but you can't make him drink. You can show a guy good form and coach him to be safe but you can't make him be safe if he wants to get hurt.
I agree -- I dislike when important technical concepts are redefined for marketing purposes. It's a bit like lightweight marital fidelity, where your spouse is faithful to you in specific circumstances.
I'm a sometimes-coder at VividCortex. Yeah, there are endless potential issues with this that make it a non-general solution. I mean, it works for us -- so far -- but it's easy to find cases where it won't. What if package X wants version 1.0 of package Y, and package Z wants a different version? Oops.
IMO Moleskine is the Starbucks of notebooks. It's a crowded category, but for me, the Leuchtturm is the clear standout for quality and fit-and-finish, head and shoulders above the Moleskine.
Yes, the Whitelines notebook is a little bit self-promotional. It makes sure you don't forget that you're holding a Swedish, patented, revolutionary notebook.
go func(){
for {
select {
case <-time.After(time.Second):
log.Println("timeout")
case <-stop:
return
case val, channelOpen := <-inputs:
if !channelOpen {
return
}
outputs <- process(val)
}
}
}()
Nice. I still haven't given Go much time, but I really like this form, where you can switch on multiple blocking calls.
I've definitely wanted this in other languages where I'm using thread safe queues for communication, and had to do manual multiplexing into a new queue whenever I wanted to do a blocking get on multiple queues.
Does anyone know of a convenient way to do this when handling multiple instances of python's Queue or similar with Haskell's Chan?
Thanks for posting this. I found something similar but on first blush didn't think it was quite right as I was mistakenly thinking that you could only do this for TChans with the same type. Looks like it might be just what I'm after! When I think about it, STM seems like it makes sense here, since you probably want the ability to cancel/rollback the blocking gets that didn't return.
EDIT: Actually, this isn't right. The example linked does "if get from channel 1 fails, get from channel 2". I'm looking for "select" on multiple channels, where the result is based on the first channel to return.
EDIT again: Apparently I can't read, and this does achieve what I'm looking for, I just have no basic experience with STM. Awesome, will try this later!
njs12345 answered for Haskell, I don't remember seeing a way to do this in Python though depending on the situation you could just use a single queue for everything of course.
FWIW there's no primitive letting you wait on multiple conditions in threading, and Queue is implemented in terms of a pair of conditions.
I got that through TinEye, and then through comments left on various places. I think with a bit more noodling I would have got a name, but HN user Wooster got there 15 minutes ago.
This is the kind of thing that can be hard to get an answer to using web search engines.
Perhaps the Google search a day could be expanded to include "tricky" and "hard" levels?
It's tough to give examples of this in Perl without a lot of narrative (and sometimes a lot of code), but the technique I'm referring to is currying: programs that write programs, via functions that write functions. This, of course, is what you do all the time in LISP. It takes half the (Higher-Order Perl) book to illustrate the technique and its power. Which is kind of the point: shouldn't it be a commonplace thing that doesn't take so much work to get around to explaining and using?
> shouldn't it be a commonplace thing that doesn't take so much work to get around to explaining and using?
Why? It's a reality of the world that more complex things take more time and more effort to learn. However, often that is because these more complex things allow you to do a lot of very useful things much more efficiently. I would prefer to drive over a bridge built by an engineer who learned all those difficult equations, material properties, and buildings codes as opposed to a high school kid with a few physics courses under his belt.
Programming is similar in some effects. As you get better and better you acquire more and more tools to do what needs to be done. Now granted, if you are working on an interface that needs to be easily accessible to the widest range of people it makes sense to simplify. However, cleverness has it's place in code that is expected to be read by specialists.
In the end, even if you avoid all the clever tricks and shortcuts you know, a large enough project will still be utterly inaccessible to a novice. The real challenge of projects that complex becomes less about the specific detail of how a piece works, but more about how all the pieces work together. If you're skilled enough to follow the design of a project like that, I don't think it's too much to ask that you either know these "clever" techniques, or you should be willing to learn.
Looking at your code you linked in the article, I think part of the problem is the fact that there are entire pages of code without a single inline comment. When you're doing these clever things you really need to document every logical step in order to understand and verify your through process later on. You also have to be ready to accept that sometimes you will mess up in your cleverness. In fact, If you are getting a lot edge cases that's a good signal to go back, re-read your comments/design notes, and find where you could improve your approach.
Ironically, I would argue that go channels are actually an example of doing something "clever" the correct way. These channels are very effective at separating a single concept from a whole pile of abstractions, and doing a lot of clever interactions beneath the hood in order to ensure it's all effectively synchronized. In other words, using go channels is using the same type of "clever" techniques once they've been abstracted away.
" I would prefer
to drive over a bridge built by an engineer who
learned all those difficult equations, material
properties, and buildings codes as opposed to a
high school kid with a few physics courses under
his belt."
I think this kind of analogy is misleading. Those things are more like the equivalent of understanding data structures and algorithms, performance estimation, being able to use a profiler effectively etc. Civil eng is very conservative in terms of the kinds of language and graphics that can be used to express a design. Anyone doing the equivalent of currying or macros (making up ones own language) would be thrown out. I would think its probable that when programming is as old as engineering its modes of expression will be similarly limited/standardised.
> Civil eng is very conservative in terms of the kinds of language and graphics that can be used to express a design.
I would argue that programming is far more specific in terms of the kind of language can be used too. In fact each such language tends to be described in exhaustive specs.
> Anyone doing the equivalent of currying or macros (making up ones own language) would be thrown out. I would think its probable that when programming is as old as engineering its modes of expression will be similarly limited/standardised.
Both things are very broad when it comes to what can be made using those languages. A civil engineer may use his language to build a house, a sky-rise, and a nuclear power plant. Each of those will have different complexities, and a different requirements of knowledge and qualifications. In fact I imagine the Engineer working on the latter will know how to do a lot of things that the Engineer who works on the former would consider to be akin in complexity to currying and macros.
The situation is the same in programming. Some people may be working on projects currying, macros, and other techniques are a major benefit. These are after all extremely powerful tools. Just like with the Civil Engineer, the challenge is knowing how to use them properly.