This is a delightful read, which reminds me of two other articles. The first is also a caricature of the technical interview, solving FizzBuz with Tensorflow: <a href="https://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/" rel="nofollow">https://joelgrus.com/2016/05/23/fizz-buzz-in-tensorflow/</a><p>The second is a explanatory story, or "discovery fiction" as the article classifies itself: <a href="https://paulbutler.org/2022/what-does-it-mean-to-listen-on-a-port/" rel="nofollow">https://paulbutler.org/2022/what-does-it-mean-to-listen-on-a...</a><p>I love these humorous yet pedagogic technical writings, woven with a bit of literary eloquence and down-to-earth narrative. Thank you for this.
Long ago, on Svalbard, when you were a young witch of forty-three, your mother took your unscarred wrists in her hands, and spoke:<p><pre><code> Vidrun, born of the sea-wind through the spruce
Vidrun, green-tinged offshoot of my bough, joy and burden of my life
Vidrun, fierce and clever, may our clan’s wisdom be yours:
Never read Hacker News
</code></pre>
But Hacker News has read of you, in their snicker-slithing susurrential warrens, and word has spread...<p><a href="https://aphyr.com/posts/341-hexing-the-technical-interview" rel="nofollow">https://aphyr.com/posts/341-hexing-the-technical-interview</a>
In case folks miss the link at the top of the article, this is translated from an old 2017 post by Aphyr.<p>That post was in Haskell, where it's not too surprising that you can do serious computation inside the type system.<p>This new post translates the ideas to TypeScript, which is more widely known, and which I once heard described as having "accidentally Turing-complete" types:<p><a href="https://github.com/microsoft/TypeScript/issues/14833">https://github.com/microsoft/TypeScript/issues/14833</a>
If you want to see some more legs on TypeScript type-level logic, check out this SQL database as Typescript types: <a href="https://github.com/codemix/ts-sql">https://github.com/codemix/ts-sql</a>:<p><pre><code> import { Query } from "@codemix/ts-sql";
const db = {
things: [
{ id: 1, name: "a", active: true },
{ id: 2, name: "b", active: false },
{ id: 3, name: "c", active: true },
],
} as const;
type ActiveThings = Query<
"SELECT id, name AS nom FROM things WHERE active = true",
typeof db
>;
// ActiveThings is now equal to the following type:
type Expected = [{ id: 1; nom: "a" }, { id: 3; nom: "c" }];</code></pre>
I remember reading the original version and thinking "Ah, this would be so much more grokkable if only I knew Haskell"... Delusions of grandeur are a marvelous thing!
So he wrote all that for the typescript lsp to respond with the answer, but when it compiles down it's nothing? And we're using runes as variables just because?<p>That is pretty neat, and silly.<p>I also think it highlights my natural aversion to static type checking in dynamic languages. I know that I could get sucked into writing a bunch of code for the checker, instead of using my energy for making the application work.
Pretty sad that computations on types look like C++98 in Typescript when C++ itself has moved on to have much more concise ways of performing computations on types in C++11 and 14 (see boost hana).
Well written and super funny. Reminded me a bit of Scott’s writing, particularly the descriptions of the horrified interviewer.<p>I’ve never worked in a Typescript shop, is there any truth to the satire here? The sea of confusing types to solve any problem?
Why did they only solve for 7 Queens and not 8 Queens?<p>I'm reminded of <a href="https://github.com/type-challenges/type-challenges">https://github.com/type-challenges/type-challenges</a> -- I've only looked at some of the more challenging problems, but one involves writing a JSON parser in the type system. The easy problems look reasonably useful to solve.
I’m unfamiliar with TS. Could someone explain this part?<p>> Invoke the compiler<p><pre><code> $ tsc *.ts --lib esnext --outFile /dev/stdout
var ᚾ = Symbol();
var ᛊ = Symbol();
var ᛚ = Symbol();
var ᛞ = Symbol();
</code></pre>
Why is there so little output? Is that because the compiler removed the unneeded types? And the author is implying that the task was boilerplate and pointless?
This is what I mean when I search for "How to ______ in TypeScript": types! Too many blogs and Stack Overflow questions say "TypeScript" when they mean JavaScript, making it harder to find information on actual type problems.
Next time someone asks me if I know TypeScript, I'll tell them "No, I don't even know JavaScript, in fact I don't know anything."
Richard has a whole series of these.<p>I was going to try to pick out one of my favourites from this series, but I really can't. Every last one is a treasure.<p>EDIT: Oops! This is based on Aphyr's work. My bad!
Well written. I laughed hard at "he asserts, wrongly".<p>I wish TS didn't evolve into this complexity. Library types that should be simple turn into a machine you have to understand (for no good reason).
An amazing read, and <i>almost</i> perfect!<p>There's a bug in the Solve "function" due to which you'll get the right answer only for 1x1, 5x5 and 7x7 (I checked till 8x8).<p>The base case makes a wrong assumption that there will always be a candidate available for the last row. If there are no candidates available, it should return Nil, and backtrack.<p>Basically, replace<p><pre><code> Concat<candidates, placedQueens>
</code></pre>
with<p><pre><code> candidates extends Cons<infer x, any>
? Cons<x, placedQueens>
: Nil</code></pre>
I've got a CS related degree, but I'm a mostly self-taught dev, and not understanding 90% of the code really makes me reevaluate my career choices. Where and how can I learn this stuff?
You can also play around with the code in the TypeScript playground:<p><a href="https://www.typescriptlang.org/play?#code/PTAEEkDsAsEMBsCmAaUBLSBnAxgJzQEaIB0AsAFDYD2WALqIH1ooAvKAMoCeAtgVfABQBKCtTqhAU2gt23XgOGUameoC20KZx58hIxfUB7aGpmb5FEOwCuXLjVC1oiUADcqaACbpamRPABmqWJDcCDDc0egB3UOgbO1BETE9IbHsqb1AAAwY04lAAOUREF1RIKlsMAHNIOMxUW3tvXDMlXFhaAtB4GjLymypQImouEgpaDgAHexy0eCkR8ZTGChMwNi4p7tFWyFaXeA5QFuj7QatcPfmANVcGyFQB0aRWw-aMAGs2+DQlMnJZ+wBhRQAHgAHqhgZgAHxSADaoNA4IAuotyKYACoNWyobxoXAofagTBmSDZABCVCJbgitgk31MABk0HEsQhPNAqFRCk8XIhRrZMKB5rB2rA3qTyQFQFSospvr9QOizPZWL95uJhmN7AAxFlKmwa+bKZFynIlQEEACMUNYFtiwM2Ln5CvsAH5QNr4J5QAAuPrm232-nuz2up3e0CVByIXDq8agADyuDN5tQBAATFbff7EAFHQ0XfK82G01mcwXFaAQ4WfUHEMjTOB+bVcftIHtaBjoK6AJrkglUQa0NCDflhGjc3CyjWgACCradgI+Sgzi-oiDt2YdoABWEBGG8UfhqD3B-BUNdwJLm9DlfLPtnHHnp7DNbry1osFw9AIe2zmEgH+6AAvKMqGyXQahiFxYD2a4SFAABVT0hWA3BeigvZ-DcbAP1OJ4UNAmN7AALRAmZ9VSXQjSnNhAUgDNoUgJFyEI+NKlAdjWBokjUIhFjUVHdi1EBONKl4n4p1RaBcV1Gj+KoMS5U1clcA49hAUk6SFKnTU0EjVSaKUsxcC02M2DQC99MBHTIxM+w2EQSNICEszgTEpZQAAUQARzMBBQg4VAXD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UqQeLykIrHsEmYgaZGSalzOllCV+uZFQQ0EvUoEnzDkTyjKcxAvSfmoDub+YZK0RrViOUigFqKbkYqwFEsZG1jTlUBMA4l2NchTAzDpRFJyCXQMBBAy+vSqY0xRvTQEOQvGP3RTMkFmK0FyXaFQKeNzaitwQLQQCYiSixCnnsJQDtvAxTwbgB0VCvyDxeO2fV5RUCYFGBgSAxrQCIy2LsfYHwyjQEHNTTOTx-C4IPAcE2Sgnj4AdfQKwgwtgn3YHwSMeQ7QQKpefIVwLUkZjYKGwF4blk0UFbc4VcbUCpsQTG1p0DbIhvgJGQEFygpQWeQ-aN6bY35qkK4qNYRUD8qBk6P5panlxGKUCNqcIQbQopluIEcIaUc0hnS+AIylaPPLZ2iFg6dw9q+SpU8-bGoJqLYgZNkbgFc2HRm-N4LXnjtXbdddxbwSVsbdWvN9yT2TTPZu8q26q27tzbMzFo7JpkvcpJewmB1aDhoCxHIahzLjL4LbNA1hOKJr5ZSuaXiebjr5qYJSP8aCOUZOFVA5VmjYCLjEaKmBQhQacvMbOwQ+4uAKjHG+LEoDcmBAuT4tAijLhY12hd5izFXRXdixqBMj2PVJn-W6DG1wghuWTT97EfTAknd+t20sAAMUhxNMfXZBmgqAEMsS8n6Vg6nASacAzcViiAC1eVTGpgIEmTOkdQHJSzABmGzjHjMQdM45+RFm9MABY3N2c8w5t0ylLMAFZAsaeC9pw5Nk9MADYosefgFpszLkIRAA" rel="nofollow">https://www.typescriptlang.org/play?#code/PTAEEkDsAsEMBsCmAa...</a>
I am a 6-figure front end developer, work with typescript daily for the last 3 years.<p>I didn't follow any of that shit. The fuck is an 'n-queen'? I don't think I learned that in my coding bootcamp.<p>Is that a bad sign?