miniblog.

TIL that C++03 considered a file without a trailing newline to be undefined behaviour! https://stackoverflow.com/a/72377 This was fixed in C++11, but the problem was that #include was a textual operation that could produce invalid syntax if no newline was present.
If I were coming up with a new syntax today, I'd be tempted to put a deliberate marker in it. "In funkylang, you declare functions with `funk foo() {}`."
Choosing a syntax for a new programming language is hard. You want to be similar enough to an established language to avoid scaring off users. You still want to be sufficiently novel to be recognisable. Which languages do this well?
The Rust docs include a surprisingly readable example of how `for` loops desugar into essentially a while loop with a pattern match:
An excellent review of the V language and the features it promotes: https://mawfig.github.io/2022/06/18/v-lang-in-2022.html The code samples are a great example of how you do PL work: you learn about the intended semantics and try to write programs that are broken in interesting ways.
Programming is a team activity: the vast majority of projects have multiple contributors. Yet all the films I've seen show a solo programmer at a keyboard. Have any movies got this right?
Proper tail calls were added to the JS standard, but most implementations don't provide it. V8 even built it then removed it! The concern is worse developer experience. An opt-in syntax has been proposed (cf loop/recur in Clojure) but no consensus. https://www.mgmarlow.com/words/2021-03-27-proper-tail-calls-js/
I find myself writing .iter().map(|x| ...).collect() really often in Rust. I'm wondering if I should write a helper method on Vec, but it seems less idiomatic. Iterators compose, but they're less versatile (no indexing) and awkward to return from functions.
Many languages use docstrings rather than doc comments: it certainly makes extracting them easier. You just parse the code. Could you go further and require all comments to be string literals? I'm struggling to think of many downsides.
Today I learnt that Rust has an API guidelines book, with a ton of helpful advice on idiomatic style. For example, naming: https://rust-lang.github.io/api-guidelines/naming.html Readers expect `to_foo()` to do more work than `as_foo()`, which was new to me.
A charming text editor UI where you can doodle line drawings alongside text: https://akkartik.name/lines.html This shows the effectiveness of doing a small number of things in the interface.
I've released difftastic 0.29.1: https://github.com/Wilfred/difftastic/releases/tag/0.29.1 Minor release, just fixing a nasty performance issue that cropped up in 0.29.0 on large textual diffs.
Encountered a type of bug I've never seen before: upgrading the malloc implementation had a catastrophic effect on performance! I suspect one of my libraries is allocating large arrays and not writing to them.
Difftastic 0.29 is out! * A ton of optimisation (30% shorter runtime) from smaller data structures * Improved cases where the outer delimiter is preferred (lisps, JSON) * Better detection of binary files (thanks @OnlyXuanwo) * Improved Perl, added Elvish
Photo
When I first learnt VCS, I focused on history. It was only later I realised that it's wonderful for temporary notes too. I write a lot of `// here` and `// here?` comments now, as I can easily discard them once I've committed the interesting bit.
Showing 196-210 of 384 posts