1,822 karma · joined Feb 3, 2019 (7y ago) · 645 submissions
comment 6y ago · link · parent
The solution for supporting < and > — or rather, continuing to support them only for built-in types — feels powerful enough without introducing full-on operator overloading.
If I read correctly, this does mean we’ll still need multiple versions of some common functions like min/max depending on whether the type is a built-in or something else that’s comparable (like bigint.Num or time.Time), but that feels ok to me. I wonder how the standard library will accommodate this — perhaps you just redefine math.Max to be generic, since such a change would be backwards-compatible for the vast majority of uses.
Like other posters, I’d also appreciate support for user-defined types in language constructs like for..range and [ ], but that’s orthogonal to generics and can be added in a later 2.x revision (just need to define a built-in constraint-interface for these).
comment 6y ago · link · parent
I've been using the Natural Keyboard Elite since 2001. I'm on my second one, not because the first one broke, but because it was so dirty that I replaced it in 2012. Really regret getting rid of the old one.
I never liked the newer Microsoft ones as much, and I can't go back to a straight keyboard, so I'll have to go down the rabbit hole when this one breaks. This discussion has been really informative.
comment 6y ago · link · parent
Wow, I never heard it articulated that way, but that’s exactly what it is. In 2015, after dodging the EM role for half a decade, my manager left, and there was no one else, so I had to step up. I was below average because I never stopped caring about the code. Luckily for my team, I left the company after eight months.
Now, having been the senior tech person in a startup for the last four years, I feel the fatigue from churning out code (I’ll sketch out a design over a few minutes, and then have to spend days building it), and it’s obvious that the only way to get a better ROI on my time is to lead and/or delegate. For the first time in my career, that feels exciting. I still care too much about tech to be a good manager, but I feel my mindset shifting.
comment 6y ago · link · parent
comment 6y ago · link · parent
So, like the sibling comment about prayers, I’m trying to build a system that collapses those insights into a small enough space that I can review them regularly. Kind of like regression tests for mind function.
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent
comment 6y ago · link · parent
make image push deploy
kubectl -f somewhere/deploy.yaml
comment 6y ago · link · parent
For storage, why not just mount host dirs into the container for stuff you want to persist? Then you’re no worse off than you were before.
comment 6y ago · link · parent
If you don’t use CI, it’s easy to get fast deploys with containers. Just build the images on your dev box, tag with the branch and commit hash, and push directly to a docker registry (docker push is smart enough to only push the layers the registry doesn’t already have). Code is running 30 seconds after compiling finishes.
(Don’t want to pay for a registry? It’s trivial to run one yourself)
These aren’t foolproof, fully reproducible builds, but practically they’re pretty close if your tools require your repo to be clean and pushed before building the image, and if your build system is sane. Besides, if you’re used to editing code as it’s running on servers, you don’t care about reproducible builds.
Also, if you’re starting containers manually on the command line, you’re doing it wrong. At least use compose so your setup is declarative and lifetime-managed.
(Edit: s/swarm/compose/)
comment 6y ago · link · parent
I mean I love the extensions and everything but I’m probably gonna use this as motivation to learn vim.
comment 6y ago · link · parent
For a game dev class in uni, I wrote air hockey. This is straightforward because you only have circles and lines, and there's no gravity so objects can't rest on each other. I wrote an event-based physics engine, which exploits the fact that the equations to find the time t of a future collision are closed-form and you can just solve for t. If t is greater than the time to the next frame, just step everything forward; if it's less, step to that collision, then find the next one. Collision response is easy too: just choose a reference frame where one of the pucks is stationary, then solve conservation of momentum and energy.
This excludes some kinds of friction models, but if you choose one where deceleration due to friction is independent of speed (perfectly valid for lowish speeds), you're fine.
Another cool thing about an event-based system is that it makes it trivial to write an AI: just have the system try N moves toward the nearest puck, and run the simulation forward a few collisions to see if any of those moves results in a puck going in the opponent's goal.
comment 6y ago · link · parent
When I started, there was kind of a website to do this already, but it was absolutely awful and I knew I could do way better.
So I did. I spent 100-150 hours working out all the math and coding up the program to reproduce that placard from terrain data. I still have all my notes. It was kinda slow — one panorama took 4-6 minutes to draw — but it worked.
And then I didn’t ship. Life got in the way, and it was always harder for me to do the second 50% than the first, even though in this case the first 50% was way harder.
Three years later, one of my friends shared an app with me, just released. It did the same thing. The author did a good job describing how I felt then too, how the app was good but I hated it anyway. I never used it, probably because I ended up moving overseas anyway to a place without free high-res terrain data.
That was my best chance to date to do something I’ve always dreamed about: make something cool that a lot of people love to use. Novel, good ideas like that don’t come along very often.
comment 6y ago · link · parent
Don’t know what you guys are seeing on the media but I’ve been in China since February and the response has been pretty reasonable and very effective, at least from where I’m sitting. Before I came back in early Feb I thought about fleeing to the US, but haven’t entertained the idea since.
comment 6y ago · link · parent
I wouldn't call China loosely-enslaved; Chinese certainly don't see themselves as working for the Party, but for themselves, or for a prosperous China as a whole. Even though the information environment here is completely controlled, life really does feel free for the most part.
Is it really a Pyrrhic victory when a Chinese middle class family can have a comfortable, genuinely happy life? How is that family's happiness different from that of a family of westerners that comes here and lives happily for many years, as many of my friends have done?
But more to your point, it's true that America has some special sauce that 1) drives innovation faster than anywhere else in the world, and 2) attracts people to settle there from all over the world. But we see that Freedom is neither sufficient to become an innovation powerhouse (look at much of Europe) nor is it necessary (see Korea and Taiwan in the 70s and early 80s, which back then were very much not Free).
If you want to point to something as the reason why China is less innovative than the US on the whole, I'd point to the emphasis of rote memorization in the school system, and to the fact that college is kind of a joke, at least for the techies I've talked to. But that will slowly change, and even now China has a vibrant startup ecosystem.
The Party knows that for its long-term survival it must align its own interests with those of the people. And right now, to quote Singaporean academic Kishore Mahbubani in a recent Sinica podcast, "the primary goal of the Chinese Communist Party is to revive Chinese civilization." Of course, the party will insist that this be done on its own terms.
Human rights issues need not be addressed here because in practice they do not factor in. The US especially emphasizes these things because it loves to have the moral high ground (and I believe it does), but that unfortunately does very little to slow the rate at which the US, with its ineffective strategy over the last two decades, is ceding the geopolitical high ground.
comment 6y ago · link · parent
> controls its people and stifles their freedoms on every possible level
This is not at all the reality in China today. China is free enough: don’t talk too much about politics on social media, and don’t protest, and you’ll (probably) be just fine.
The biggest lesson I’ve taken from my years living in China is that you don’t need Freedom for people to prosper collectively (though I’m still convinced you need a free press as a check against power). Not everyone here is happy with single party government, but the vast majority are ok with it. There’s no revolt coming.
The bottom 50% of China are having their best string of decades in two thousand years. Freedom is great, but so is eating, and so is the promise of a much better life for your kids.
China’s getting its innovation game together too, they just need some time. I don’t see soft power happening any time soon though.
comment 6y ago · link · parent
Maintaining a cluster set up like that is a ton of work. And if you don’t perform an upgrade perfectly, you’ll have downtime. Tools like kops help a lot but you’ll still spend far more time than the $70/month it costs for a managed cluster.
comment 6y ago · link · parent
Anything new needs a certain amount of sustained practice before you get the hang of it. I think I had to learn regex like four times before it stuck. I haven’t hit that point with TOML yet so I avoid it.
I’d suggest using the deeper indentation style where hyphens for arrays are also indented two spaces under the parent element. Like anything use a linter that enforces unambiguous indentation.
I prefer YAML for human-writeable config because JSON is just more typing and more finicky. The auto-typing of numbers and booleans in YAML is a pretty damn sharp edge though and I wish they’d solved that some other way.
comment 6y ago · link · parent
Switched to k8s in late 2017 and it’s been much more solid. And that’s where the world has moved, so I’m not sure why you’d choose swarm anymore.
comment 6y ago · link · parent
Difference in mine is that dates.SetNowSource returns a reset function that you can defer, like with context.WithCancel().
comment 6y ago · link · parent
Or, create the timer outside and inject its channel. Want to fire the timer? Just write to the channel.
If you do expect to get a lot of value from testing the event loop, blocking on individual messages received or not received as in the article is a reasonable way to de-flakify your tests (in that case, I'd expect the tests to inject mocks and/or use private interfaces). However, it is a code smell if any other tests are depending on the details of that event loop.
comment 6y ago · link · parent