Our great sponsors
-
libcperciva
BSD-licensed C99/POSIX library code shared between tarsnap, scrypt, kivaloo, spiped, and bsdiff.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
On the topic of compilers being hard: In my repositories I'm carrying around a 5 year old workaround (https://github.com/Tarsnap/libcperciva/commit/92e666e59503de...) for a 6 year old bug (https://bugs.llvm.org/show_bug.cgi?id=21183) in clang/LLVM.
You might think that "incorrect code gets generated" would be a maximum-priority must-fix-before-the-next-release bug in a compiler, but apparently not.
> I recently saw a PR to Scala that’s a great demonstration of exactly this. The private and sealed keywords have been in Scala forever and someone only just recently came up with the realisation that private classes are effectively sealed. Scala’s been in existence for 16 years!
Slight correction: someone came up with the realisation 8+ years ago[1] but someone else came up with a fix only recently
1: https://github.com/scala/bug/issues/6159?orig=1
You'll also find them used in CPython's ceval.c
I use them in both my C befunge implementations:
https://github.com/serprex/Befunge/blob/c97c8e63a4eb262f3a60...
https://github.com/serprex/Befunge/blob/c97c8e63a4eb262f3a60...
I've never used it, but [1] claims to be a much faster js/typescript compiler than some of its competitors and written in Rust.
1. https://github.com/swc-project/swc
But compilers are not hard but simple state machines.
If you don't believe me, look at cc_x86
https://github.com/oriansj/stage0/blob/master/stage2/High_le...
...or in other words, "they're hard only because you make them hard".
That said, I think C4 makes a better example of how simple it can be:
https://github.com/rswier/c4/blob/master/c4.c
(Previously on HN at https://news.ycombinator.com/item?id=8558822 and https://news.ycombinator.com/item?id=22353532)
Actually, both your examples are possible to solve even in Scala 2. Check my repository from 4 years ago. The Readme has the examples that will be interesting for you: https://github.com/valenterry/bamboomigrate
I'm not saying it looks very elegant though - this is certainly improved a lot in Scala 3
Actually, the match types page in Scala 3 lists some of the differences with typescripts approach: http://dotty.epfl.ch/docs/reference/new-types/match-types.ht...