Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
benhoyt
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
26 ms
·
331.
▲
by
benhoyt
5y ago
Sarcasm does not become you. :-) I'm well aware of decimal types, which is what I'd use for currency values. That or "fixed point" integer cents.
332.
▲
by
benhoyt
5y ago
Interesting. Are IEEE-specified floating point operations not deterministic?
333.
▲
by
benhoyt
5y ago
I know fixed point was very important back in the days when CPUs didn't have dedicated floating point instructions. How important is it now, when most common CPUs have fast floating point operations? Is there still a performance win? D
334.
▲
How I write HTTP services [in Go] after eight years (2018)
(pace.dev)
3 points
by
benhoyt
5y ago
|
0 comments
335.
▲
Show HN: Tiny to-do list app using server-side Go and no JavaScript
(benhoyt.com)
3 points
by
benhoyt
5y ago
|
1 comments
336.
▲
Simple Lists: tiny to-do list app written the old-school way (Go, no JavaScript)
(benhoyt.com)
2 points
by
benhoyt
5y ago
|
0 comments
337.
▲
by
benhoyt
5y ago
See my other comment with some quick benchmarks: https://news.ycombinator.com/item?id=28601862 Yeah, the match is slower than if-else in that case because they're not grouped. However, the PEP points out that faster im
338.
▲
by
benhoyt
5y ago
Good call, I emailed and he merged them!
339.
▲
by
benhoyt
5y ago
Do you mean like this? x = match expr: case 'a': 1 case 'b': 2 case _: 0 I think mainly it doesn't work very well in Python due to indentation problems. Kind of
340.
▲
by
benhoyt
5y ago
No worries! Yours was getting lots of votes, mine wasn't (possibly a time-of-day thing). Side note: I re-read my comment and "dang" sounded like I was annoyed. By "dang" I mean "HN moderators". :-)
341.
▲
by
benhoyt
5y ago
I did a quick test of match vs if...elif for a basic enum switch, as well as a slightly more involved class/structural matching test. Results and code: https://gist.github.com/benhoyt/f648d6dd13ce112ba1a4422b175e..
342.
▲
by
benhoyt
5y ago
Which specific class matching example are you referring to, and how would you implement the matches as method calls?
343.
▲
by
benhoyt
5y ago
Do you mean like "f = handlers.get(args.command, error); f(args)"? It's a fine pattern (of course, it's only a tiny fraction of what pattern matching can do). However, it does mean that if the handlers aren't alread
344.
▲
by
benhoyt
5y ago
dang, could we please merge the comments from https://news.ycombinator.com/item?id=28591173 into here (or vice versa)? Thanks for resubmitting, chmaynard!
345.
▲
by
benhoyt
5y ago
I think it's a bit of a stretch to say that "anything that has to do with recursive structures" is too tedious to implement with without pattern matching. I've written my share of recursion in Python, and have written a
346.
▲
by
benhoyt
5y ago
Thanks! Yeah, that's how it seemed to me too. The AST processing examples really sell it. But the fact that Warehouse is a sizeable application (60kLoC) but didn't really have any good uses for pattern matching is telling.
347.
▲
Structural pattern matching in Python 3.10
(benhoyt.com)
13 points
by
benhoyt
5y ago
|
1 comments
348.
▲
by
benhoyt
5y ago
I use and really like GoatCounter: https://www.goatcounter.com/ -- it's free for non-commercial use, and low-cost for commercial use. It's a little less sleekly designed (and more nerdy-looking) than Plausible Ana
349.
▲
Go doc comment revisions: headings, lists, and links
(github.com)
1 points
by
benhoyt
5y ago
|
0 comments
350.
▲
by
benhoyt
5y ago
Good point. I had assumed Rows.Scan() would have just used type switches for efficiency -- it looks like it does for common cases ( https://github.com/golang/go/blob/d62866ef793872779c9011161e... ) but then fal
351.
▲
by
benhoyt
5y ago
sqlc doesn't quite work that way (though "sqlx" and other packages do). sqlc generates code at build time that avoids reflect by using database/sql's Rows.Scan() with pointers to fields (see the link above): var
352.
▲
by
benhoyt
5y ago
Are you sure? Well, it uses "reflection" in a general sense of introspecting your SQL code, but not in the Go sense of using using type information at runtime via the "reflect" package. sqlc compiles your SQL at build ti
353.
▲
by
benhoyt
5y ago
Sounds like a good habit, yeah. But the fact that an attribute access in a template (which might be quite far removed from the view code) can kick off a db query is an indication there's something a bit too magical about the design.
354.
▲
by
benhoyt
5y ago
Thanks for the thoughtful responses and the link -- Django Query Profiler looks nice!
355.
▲
by
benhoyt
5y ago
Thanks. Yeah, I think I used that years ago when I first ran into this problem, and it worked well. Whether one uses an ORM or not, one needs to know how to use one's tools. My problem (not just with Django, but with ORMs in general) i
356.
▲
by
benhoyt
5y ago
Yeah, I see this a lot. I think it's especially easy to introduce this kind of "accidentally quadratic" behaviour using magical ORMs like Django's, where an innocent-looking attribute access like user.groups can trigger
357.
▲
by
benhoyt
5y ago
I was just recently writing a somewhat complex websocket client API in both Go and Python. They were both a bit tricky, but Go's support for goroutines and channels as the concurrency primitives right in the language made the solutio
358.
▲
The Problem with Microservices [video]
(youtube.com)
1 points
by
benhoyt
5y ago
|
0 comments
359.
▲
by
benhoyt
5y ago
I sympathize (I like saying I don't do BDD, Buzzword-Driven Development), but I'm not terribly up on Fowler's work -- can you provide some concrete examples of things he recommends that were over-engineered or just plain bad
360.
▲
Ask HN: Programming Mentors in New York?
1 points
by
benhoyt
5y ago
|
0 comments
More ›