3,021 karma · joined Jul 16, 2010 (16y ago) · 466 submissions
http://jeremymikkola.com
Email: <My first name><2^7=>@<google's mail product>.com
https://twitter.com/silenceofnight
comment 5y ago · link · parent
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.
183.
How to Write Readable Code(jeremymikkola.com ↗)
93 points · by piinbinary · 5y ago · 38 comments
comment 5y ago · link · parent
(The recipient needs more than "hi" to know that what follows is private)
comment 5y ago · link · parent
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.
190.
Why software development is hard(jeremymikkola.com ↗)
2 points · by piinbinary · 5y ago · discuss
comment 5y ago · link · parent
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
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
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
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
Plus all the ways that Python is more convenient than Go.
comment 6y ago · link · parent
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
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
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
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
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.