o11c

joined 1 year ago
[–] o11c 1 points 1 year ago

For one thing: don't bother with fancy log destinations. Just log to stderr and let your daemon manager take care of directing that where it needs to go. (systemd made life a lot easier in the Linux world).

Structured logging is overrated since it means you can't just do the above.

Per-module (filterable) logging are quite useful, but must be automatic (use __FILE__ or __name__ whatever your language supports) or you will never actually do it. All semi-reasonable languages support some form of either macros-which-capture-the-current-module-and-location or peek-at-the-caller-module-name-and-location.


One subtle part of logging: never conditionally defer a computation that can fail. Many logging APIs ultimately support something like:

if (log_level >= INFO) // or <= depending on how levels are numbered
    do_log(INFO, message, arguments...)

This is potentially dangerous - if logging of that level is disabled, the code is never tested, and trying to enable logging later might introduce an error when evaluating the arguments or formatting them into the message. Also, if logging of that level is disabled, side-effects might not happen.

To avoid this, do one of:

  • never use the if-style deferring, internally or externally. Instead, squelch the I/O only. This can have a significant performance cost (especially at the DEBUG level), which is why the API is made in the first place.
  • ensure that your type system can statically verify that runtime errors are impossible in the conditional block. This requires that you are using a sane language and logging library.
  • run your testsuite at every log level, ensure 100% coverage of log code, and hope that the inevitable logic bug doesn't have an unexpected dynamic failure.
[–] o11c 1 points 1 year ago (1 children)

To be fair, Secure Boot is actively hostile toward dual-booting in the first place. Worst of all, it might seem to work for a while then suddenly start causing errors sometime later.

[–] o11c 3 points 1 year ago

From my experience, Cinnamon is definitely highly immature compared to KDE. Very poor support for virtual desktops is the thing that jumped out at me most. There were also some problems regarding shortcuts and/or keyboard layout I think, and probably others, but I only played with it for a couple weeks while limited to LiveCD.

[–] o11c 2 points 1 year ago

ReplaceFile exists to get everyone else's semantics though?

[–] o11c 2 points 1 year ago

As a rule, and Integrated Development Environment is less than the sum of its parts. Whether it is worth using depends on:

  • how many of the parts you actually need to use
  • to what extent you would benefit to use features of a part that are not exposed by the IDE
  • whether you find it easier to switch between different windows (involving tools with different UIs) for different tasks, or use the same window for different tasks.
  • whether the language you're using is statically or dynamically typed, and whether it's syntactically "simple" or complicated (this affects the difficulty of "manual" refactoring)
[–] o11c 1 points 1 year ago

Time-division isn't the only kind of multiplexing ... but I guess most of the others already have more specific names.

[–] o11c 1 points 1 year ago

git is, however, bad with files that don't have meaningful small binary diffs. And the page size for SQL binary files is small enough that that is in fact a problem (though this is not nearly as bad as already-compressed files).

If you disable VACUUM that can give a rough idea of what git actually has to deal with. But you really shouldn't.

[–] o11c 2 points 1 year ago

Is it even meaningful to speak of an AST interpreter at that point? What does the actually-executed code look like?

One thing to test would be to see if you get the massive slowdown when you exceed each cache size.

And of course, outside of meta-compilation contexts, the (rough!) rule of thumb remains: AST walker is 10x slower than bytecode, which is 10x slower than compiling to native code.

[–] o11c 1 points 1 year ago

Compilers are generally forbidden from optimizing floating-point arithmetic, since it can change precision.

[–] o11c 2 points 1 year ago (4 children)

Related, note that division is much slower than multiplication.

Instead of:

n / d

see if you can refactor it to:

n * (1.0/d)

where that inverse can then be hoisted out of loops.

[–] o11c 5 points 1 year ago (3 children)

This is about the one thing where SQL is a badly designed language, and you should use a frontend that forces you to write your queries in the order (table, filter, columns) for consistency.

UPDATE table_name WHERE y = $3 SET w = $1, x = $2, z = $4 RETURNING *
FROM table_name SELECT w, x, y, z
[–] o11c 0 points 1 year ago (1 children)

Obviously the actual programs are trivial. The question is, how are the tools supposed to be used?

So you say to use deno? Out of all the tutorials I found telling me what tools to use, that wasn't one of them (I really thought this "typescript" package would be the thing I was supposed to use; I just checked again on a hot cache and it was 1.7 seconds real time, 4.5 seconds cpu time, only 2.9 seconds if I pin everything to a single core). And I swear I just saw this week, people saying "seriously, don't use deno". It also doesn't seem to address the browser use case at all though.

In other languages I know, I know how to write 4 files (the fib library and 3 frontends), and compile and/or execute them separately. I know how to shove all of them into a single blob with multiple entry points selected dynamically. I know how to shove just one frontend with the library into a single executable. I know how to separately compile the library and each frontend, producing 4 separate artifacts, with the library being dynamically replaceable. I even know how to leave them as loose files and execute them directly (barring things like C). I can choose between these things all in a single codebase, since there are no hard-coded project filenames.

I learned these things because I knew I wanted the ability from previous languages I'd learned, and very quickly found how the new language's tools supported that.

I don't have that for TS (JS itself seems to be fine, since I have yet to actually need all the polyfill spam). And every time I try to find an answer, I get something that contradicts everything I read before.

That is why I say that TS is a hopelessly immature ecosystem.

view more: next ›