Better HN
topnewbestaskshowjobs
Log inSign up

piinbinary

3,021 karma · joined Jul 16, 2010 (16y ago) · 466 submissions

Jeremy Mikkola

http://jeremymikkola.com

Email: <My first name><2^7=>@<google's mail product>.com

https://twitter.com/silenceofnight

Submissions

comment 5y ago · link · parent

Besides static (which seems likely - perhaps there is an issue with the grounding), I can think of two other explanations:

1) the computer is near a heater. The heat both attracts the cat and overwhelms the cooling enough to cause a crash.

2) The pc makes some noise (e.g. Coil whine) when it is about to crash, and the cat can hear that noise.

comment 5y ago · link · parent

And a separate copy of `append` for every possible type :)

183.

How to Write Readable Code(jeremymikkola.com ↗)

93 points · by piinbinary · 5y ago · 38 comments

comment 5y ago · link · parent

The level1techs forums seems to have a lot of people with similar interests

comment 5y ago · link · parent

The fact that the following messages shouldn't be shown publicly is useful information to convey, and I feel like conveying that avoids wasting the first message -- If it explicitly says that what follows needs to be private.

(The recipient needs more than "hi" to know that what follows is private)

comment 5y ago · link · parent

A problem with saying "hi" and then waiting is it turns an asynchronous communication medium into a synchronous one.

Say you have a question for me, but I'm in a meeting (or it's past working hours in my timezone). By the time I respond to your "hi", you might now be in a meeting (or it might be before your working hours, the next day). Finally you ask the question, and I respond the next time I'm available. This could easily cause a question that takes 30 seconds to answer to have 24 hours of latency.

Or I might be busy doing something else or talking to someone else. Waiting for me to respond to "hi" is basically demanding real-time access to my focus. I don't have the capacity to always have live conversations with everyone who wants one. Just posting a (complete, thought-out) question allows me to devote just a short window of focus, and do so only when I have that focus to spare.

comment 5y ago · link · parent

Can Prolog be used to create AI?

:- No.

comment 5y ago · link · parent

I incorrectly assumed that `-j` and `-j$(nproc)` would do the same thing. TIL!

comment 5y ago · link · parent

Don't try to compile this with `make -j` - I tried, and my system ran out of ram and swap and started OOM killing things. I have 16 threads and 32gb of ram.

Running `make -j4` seems safe thus far.

190.

Why software development is hard(jeremymikkola.com ↗)

2 points · by piinbinary · 5y ago · discuss

comment 5y ago · link · parent

1. Add comments that explain why. This might be a technical reason (like, this query is structured in this weird way to convince Postgres to optimize it correctly) or business reasons (e.g. users outside the US sometimes put the street number at the end of the first line of the address)

2. Keep each method at a single level of abstraction. Don't mix high-level business logic like send_email() with low-level logic like constructing a SQL query.

3. Break out separate functions just to give a block of logic a name. This results in more context when reading the code, shorter functions, and better stack traces.

4. Don't work too hard to avoid duplication. A little duplication when two codepaths do something similar is much better than having a weird abstraction that exists just for the sake of deduplicating a few lines. (But do work hard to make sure that there is a single source of truth for important values and decisions!)

5. Prefer many functions to a few, configurable functions. When you have a function with, say, 5 boolean options, that's 2^5 = 32 cases you need to support. In reality, the function might only be actually called 6 or 7 different ways, so you don't actually need all those combinations. Having more functions that do one thing makes it much easier to tell what a particular piece of code is actually doing.

6. Start by explaining what needs to be done as though you are telling another person, and then transform that into code. It tends to result in more readable code than starting by explaining it to a machine.

comment 5y ago · link · parent

It depends on exactly what you count as 'work', but if I count all the things I do for the sake of work that tie me to the computer (so counting e.g. the team's informal chat half-hour), then about 9 hours.

If you count just mentally intensive work (writing/reviewing code, writing/reviewing designs, making plans), then it's hard to do more than 4-5 hours per day (in terms of how long I can focus - days usually don't have that much free time for "real" work!)

comment 5y ago · link · parent

I wish something like this existed for garbage-collected languages. The closest thing I know of is the JVM (and other similar VMs), but I'm hoping for ahead-of-time compilation.

The key difficulty in adding garbage collection to code emitted with tools like this is being able to accurately tell what the root set is.

(I know LLVM has support for this in theory, but I have found nothing that tells how to actually use it)

comment 6y ago · link · parent

If the office was closed, and I needed something out of the office cabinets, I would not like to have to open up the whole thing just to get the item I needed.

comment 6y ago · link · parent

This tweet is slightly more useful: https://twitter.com/lapcatsoftware/status/132699029641299148...

Apparently the server apple uses for checking apps on startup went down, making it extremely slow or impossible to start apps.

(It appears to be back up)

comment 6y ago · link · parent

While RTX is still a selling point for Nvidia over AMD right now (it has more developmentand broader support than AMD's ray tracing), I think that a lot of gamers aren't going to be willing to pay the premium to get it (to say nothing of availability)

comment 6y ago · link · parent

I think Zoom makes this even worse because they nearly mute[0] the audio of all but the person currently speaking. (I'm not sure if this is a real feature, or just a side-effect of something else)

[0] I think the audio still plays, but at a greatly reduced volume.

comment 6y ago · link · parent

I really ought to learn OCaml (besides just the toy programs I've written). I think if I got past the messy ecosystem (is tuareg the right thing to use, or is that the old thing?) I'd really like it.

comment 6y ago · link · parent

Flask is better in the little mechanics of interacting with HTTP - parsing a parameter out of a URL (in Flask, it's a function argument; in Go, it's at least one extra line per arg), returning JSON (just return a dictionary in Flask), handling errors. Flask also is able to auto-reload the code when it changes (turn on development mode) which is really convenient.

Plus all the ways that Python is more convenient than Go.

comment 6y ago · link · parent

For large data sets, it sometimes spends all day in GC while just loading the data into memory (this is actually more of a problem in Ruby than in Python, but it still exists here).

It's also not very efficient about using memory, so it can be easier to get a dataset to fit in RAM in Go vs. Python.

Python also makes it hard enough to make use of multiple cores that it becomes easier to just use Go.

The same goes for making it fast. It can be done in Python, but I tend to be happy with the performance of my Go code out of the box.

comment 6y ago · link · parent

I find myself reaching for it over other languages when I want to build small servers with a bit of in-memory state or a bit of heavy processing. For little search-engines, Go is perfect. While writing servers in Flask + Python is much more convenient, I still prefer Go because I don't run into the limits that Python has.

The development process is fluid enough that I wish the language was suited to more usecases. When I need to handle complicated data (e.g. abstract syntax trees), I use Rust or Haskell because of their rich data types. But it tends to be much harder to get things running in those languages (borrow-checker and monads, respectively). I want to reach for Go to make those problems go away, but then realize that it would be really painful to try to express the program in Go. I understand that other people are unhappy with Go's development process, particularly if you deal with package versioning.

The language design itself may have been backed into a corner where adding generics will create an ugly mess (what will the standard library look like if it tries to maintain backwards compatibility?). Time will tell.

The tooling is mostly pretty good, but many things feel half-baked (compared to more mature ecosystems). On the spectrum of 'written in a weekend' to 'dozens of developer-years of work', the package "net/http/pprof" feels closer to the weekend side. There are bright sides, like having the production parser available as a library.

It's a language that is frustrating in different ways from other languages. Instead of fighting with Cabal/Stack, you have to write a million `if err != nil {}` statements. Part of what makes it frustrating is seeing how good it could have been.

comment 6y ago · link · parent

It should also add a few dozen GB of ram for all those chrome tabs.

I can't tell if that card would be a great thing or a terrible thing if it really existed. On the one hand, encoding decisions in hardware might slow down the pace at which the web shifts around. On the other hand, web page complexity would expand to fill the available processing power, so they would only be fast for the web devs and anyone else who has the expansion card.

comment 6y ago · link · parent

If that scaled completely linearly - I'm sure it doesn't, but it might be close enough - it would mean that it could compile a few kloc in less time than most interpreters/VMs take to boot up.

For me, "instant" compiler and test feedback would be the ideal development experience. (Plus a good debugger)

I think sadly there are some features (e.g. HM-style type inference) that I want to have but would be an order of magnitude or two slower than this. But still, I'd love to see a compiler for a modern language use something like this as a goal. Even 10kloc/thread*sec would be quite good, now that we have 16+ thread CPUs readily available.

comment 6y ago · link · parent

It sounds like "Big Navi" may roughly match RTX 2000-series performance, but not quite meet RTX 3000-series performance (which is better than I was expecting).

comment 6y ago · link · parent

Try holding your mouse* upside-down on the surface of your desk to get the same effect. The point at which the mouse meets the desk will always be the point where the tangent of the curve is horizontal.

*Assuming your mouse is curved on top.

comment 6y ago · link · parent

I'm reminded of the Monty Python sketch where a bored airline pilot says to the passengers, "you have no cause for alarm."

Similarly, if a political entity calls themselves a name containing "democratic" or "republic", you can be assured that it is not a democracy.

comment 6y ago · link · parent

Backups you've never tested are not a backup

(backups encrypted with a key no one has access to are not a backup)

comment 6y ago · link · parent

This reminds me a lot of Parse, don't Validate (by the same author, apparently): https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-va...

I think there's another reason to make invalid states inexpressible in the type. When you need to change existing code (perhaps years after it was first written) in a way that breaks key assumptions, you find that the current types don't allow expressing that change. This is a good warning sign that other code will need to be updated to take the new states into account. Without the type enforcing that invariant, it might have been much harder to tell that this particular change (out of all the changes you make over the years) is the one that breaks a key assumption. (A key assumption that might have been forgotten by now!)

Types become a message to your future self.

comment 6y ago · link · parent

> Changing the -timeout flag now invalidates cached test results. A cached result for a test run with a long timeout will no longer count as passing when go test is re-invoked with a short one.

I'm glad this is fixed! That will make life that one bit less annoying.

comment 6y ago · link · parent

It has been consistently regarded as valuable for thousands of years, and there is very little chance of the value dropping to near zero.

Edit: In response to child comment, I mean in the sense of the Lindy effect, not in the sense that age implies realness

1
678
16