Better HN
topnewbestaskshowjobs
Log inSign up

physicles

1,822 karma · joined Feb 3, 2019 (7y ago) · 645 submissions

Submissions

comment 6y ago · link · parent

I’m so glad they dispensed with the “constraint” language construct from earlier drafts, and just folded it into “interface”.

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

Me too, partly because of the reduced short-term memory (which coding relies on heavily). But more than that, my motivation drops through the floor because I can’t shake the thought that life is too short to fight with computers all day.

comment 6y ago · link · parent

I also feel like we hit peak input around 2000 with the Natural Keyboard Elite and IntelliMouse Explorer 3.0 (thankfully, Razer makes mice that are nearly identical).

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

> the cost of shifting the things you care most about entirely

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

Another way to hack around this is to use notes. Before I leave for the day, and especially for the weekend, I write 4-5 sentences about what I want to work on next. Makes it easy to put things down after work and easy to pick them up again. Also, I think it was GTD that said part of the point of having a next actions list is that it’s on paper and not in your brain.

comment 6y ago · link · parent

I wonder if this means the problem is under-determined (too many degrees of freedom) and that leads to numerical instability. Certainly one set of equations is enough, as 3Blue1Brown’s Fourier transform video shows.

comment 6y ago · link · parent

It’s like Scott G says, better to be a mediocre company in a great market, than a superbly-managed company in a bad market.

comment 6y ago · link · parent

If only they cared. It’s pretty clear they’re not optimizing for user experience.

comment 6y ago · link · parent

Yeah I have the same thoughts about go, which I've been using every day for the last four years. It's super rare for an upgrade to break anything (has happened though). When it comes to running stuff in prod, boring is good.

comment 6y ago · link · parent

We do forget! Recently there have been too many times where I “realized” something important or profound, only to go back and see it in my writing from years ago.

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

Wow, great article. This completely explains why travel (not the tourist kind, the serious kind) tends to make one more tolerant: you encounter people who clearly have very different values and beliefs, but who are nevertheless amazing human beings. It’s a powerful force for developing a more complete theory of mind.

comment 6y ago · link · parent

The mishandled Python 3 transition sure created a lot of pain (I experienced some of it, even though I only started with Python in 2016), but I never realized how much it hurt the language’s momentum. This must be one of the reasons why JavaScript is so popular today. JS benefits here from being run in browsers, which the author points out are fantastic at back compat, even as the dev culture surrounding the language doesn’t value it at all.

comment 6y ago · link · parent

I went googling for some Raymond Chen examples of the great and terrible things Windows does in the name of back compat, and came up with this old thread: https://news.ycombinator.com/item?id=13450160

comment 6y ago · link · parent

Yeah this is exactly what I do too, works just fine. You probably already have something like this, but I hacked a bash+yq script that automatically updates all relevant yaml files with the latest image tag. So getting new code running is two lines:

make image push deploy

kubectl -f somewhere/deploy.yaml

comment 6y ago · link · parent

If you only have a few VMs, consider ditching swarm and just using docker (with compose) with host mode networking. I’m not sure swarm ever got stable enough to use in prod; I migrated our stuff from swarm to k8s a couple years ago due to similar issues. K8s has been solid but it’s a beast.

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

You’re comparing cowboy sysadmin (mutable servers, ssh in and live-edit stuff) to process-heavy devops with CI. These are orthogonal to containers/not-containers.

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

Another related aphorism, I believe from Joel Spolsky:

“Users don’t want to use your software, they want to _have used_ your software.”

Users come in with a task they want to perform, not so they can bask in the glory of your wonderful UI.

comment 6y ago · link · parent

Is VS Code lean anymore? I switched to it long ago when Atom got too slow, but I’m using VS under Ubuntu for Go development on a brand new X1 Carbon and it’s laggy as hell — probably 200ms average between keypress and response, and sometimes up to a second between clicking to open a file and getting focus in the window.

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

It's a roll of the dice though. Of those who attempt to do something first class and pin their hopes on it, how many can succeed? You can at least say that the Stoic path is a more reliable path to satisfaction.

comment 6y ago · link · parent

If you restrict yourself to certain types of objects and environments, you can use totally different techniques.

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

This happened to me in 2010. I love hiking, and when you get to the top of a mountain one of the things you do is look at all the other mountains and figure out which ones they are. It’s called name-that-peak. Sometimes at scenic overlooks there’s a nice hand-drawn placard with all the peaks labeled, so I wanted to make an app to do that.

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

> Would you like to live like the Chinese? No.

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

Thanks for being open-minded and having a dialog.

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

Your perception of China is 10-20 years out of date.

> 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

Setting up your own k8s from scratch is kind of like writing your own string class in C++: it’s a good exercise (if it’s valuable for your learning path) but you probably don’t want to use it for actual work.

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

> when I edit them once in a while

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

This happened to me too when I was using swarm in 2017. Had to debug swarm networks where nodes could send packets one way but not the other. Similar problems as #2 where stuff just breaks and resetting the node is the quickest way I found to fix it.

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

I've done this too, because passing a mockable time everywhere would just clutter the code, and this is an instance where a package-level global isn't going to bite you in the ass -- in prod anyway (in tests you might get your wires crossed, but seen another way, a global ensures all parts of your program think it's the same time).

Difference in mine is that dates.SetNowSource returns a reset function that you can defer, like with context.WithCancel().

comment 6y ago · link · parent

In my experience so far, everything beyond mocking the current time is out on the long tail of tests that are expensive to write and provide little value. When I've run into a class with a time-based event loop, I isolate the timing code as well as is reasonable and just test everything else.

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

Yeah life is nearly back to normal in Beijing and Shanghai. Restaurants are still below capacity, theaters and clubs aren’t open yet, and home visitors often still have to sign in at the gate, but that’s pretty much it. Local health authorities have even announced that it’s no longer necessary to wear a mask outside, but most people still do.
1
1819202122