In case folks miss the link at the top of the article, this is translated from an old 2017 post by Aphyr. That post was in Haskell, where it's not too surprising that you can do serious computation inside the type system. 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: https://github.com/microsoft/TypeScript…
All useful type systems are turning complete. The only people who don't realise are those that want to rewrite everything in rust.
TypeScripting the technical interview
101–110 of 180 posts
Re: TypeScripting the technical interview
#102I didn't follow any of that shit. The fuck is an 'n-queen'? I don't think I learned that in my coding bootcamp.
Is that a bad sign?
Re: TypeScripting the technical interview
#103So 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? That is pretty neat, and silly. 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 wor…
this is why i love ts when not working for a megacorp. when the ts gets too cray i just nope out. throw an any or as in there and get on with my day. wouldn't pass a code review but i don't care
But in a smaller shop, oncall are developers, that is, ourselves.
Re: TypeScripting the technical interview
#104Earlier quoted context omitted.
All useful type systems are turning complete. The only people who don't realise are those that want to rewrite everything in rust.
Were this true it would be terrible, because Turing-completeness necessarily includes non-termination. This would mean that a compiler would crash, or get stuck in an infinite loop.
Re: TypeScripting the technical interview
#105Earlier quoted context omitted.
> You are doing part one. Is part two occurring? Valid feedback. I even thought of adding it myself, because implied stuff isn’t obvious. I felt it worth communicating because there’s value in what’s implied that isn’t available in the type system. To the extent I have team members consuming the same code, I would definitely communicate the intent. To the extent I have reviewers who read the code, I do discuss it. To…
I think at this point we'll agree to disagree. I will offer this as a middle ground that I'm not even 100% sure will work since I'm not in front of a TypeScript interpreter. What about just defining it as object? Would work for object.Keys, but not sure how the function consumers would get along with it.
That’s pretty much the intent of the constraint. I don’t have time to sit with a type checker right now, but I don’t think we disagree as much as you might think. I arrived at this from years of trying to find the best way to express types which are as strict as possible with as much clarity as possible.
Unfortunately the object type is basically any non-null value, as is {}. They both intuitively mean what I want. They also inherently allow PropertyKey keys, which is effectively Record, which is looser than the “dictionary” type I often want to accept in these scenarios.
A better question (for me, and maybe you and maybe all of us who want type certainties) is why we even accept dictionaries in object shapes when Map is the obvious expression of that type. I’ve repeatedly wanted that and shied away from it because it requires too much change for very little gain.
Re: TypeScripting the technical interview
#106Earlier quoted context omitted.
This is a jab (insult), and I've flagged it, but I am also curious. If you could, please describe the qualities of a "bootcamp" grad by which you recognize them? Edit: especially pertaining to type inference, I guess?
If you wanted to have a conversation, you wouldn't have flagged it. So, no.
Re: TypeScripting the technical interview
#107Earlier quoted context omitted.
> You are doing part one. Is part two occurring? Valid feedback. I even thought of adding it myself, because implied stuff isn’t obvious. I felt it worth communicating because there’s value in what’s implied that isn’t available in the type system. To the extent I have team members consuming the same code, I would definitely communicate the intent. To the extent I have reviewers who read the code, I do discuss it. To…
I think at this point we'll agree to disagree. I will offer this as a middle ground that I'm not even 100% sure will work since I'm not in front of a TypeScript interpreter. What about just defining it as object? Would work for object.Keys, but not sure how the function consumers would get along with it.
Re: TypeScripting the technical interview
#108Earlier quoted context omitted.
If you wanted to have a conversation, you wouldn't have flagged it. So, no.
I didn't flag it, and I'm curious too.
People who would do things that "wouldn't pass the code review" for smaller companies are a primary reason so many smaller companies get hard-fucked when they have to scale.
Arbitrarily deciding "this is too much work for me to do, so I'm going to take a shortcut" may not be the sign of a bootcamper, but it's certainly the sign of a shitty dev.
Either way, it's not someone I'll ever work next to. Elite teams don't hire people who think like that. We hire junior devs who are like "I write idempotent commits with good titles and descriptions, and I and use strict typing everywhere." Because it's easier to be teach them "actually, nobody's ever going to read your description. You can usually leave it out. You could use 'any' here. Just ticket it to be fixed so you can replace it later."
Point is 'any' shouldn't pass a code review without someone asking "why'd you use 'any' here." If you have a great answer, it will pass the code review.
Re: TypeScripting the technical interview
#109Earlier quoted context omitted.
All useful type systems are turning complete. The only people who don't realise are those that want to rewrite everything in rust.
Were this true it would be terrible, because Turing-completeness necessarily includes non-termination. This would mean that a compiler would crash, or get stuck in an infinite loop.
Re: TypeScripting the technical interview
#110Earlier quoted context omitted.
I didn't flag it, and I'm curious too.
People who think code reviews are a thing imposed upon them by higher ups trying to make their job harder and not things designed to make their job easier don't understand how dev works at scale. People who would do things that "wouldn't pass the code review" for smaller companies are a primary reason so many smaller companies get hard-fucked when they have to scale. Arbitrarily deciding "this is too much work for me…
I also think the guts of a TS function don't matter much though. Write a test to confirm the behavior is correct, and then make the return type and argument types correct so that people can call it without hassle. If you need to use 'any' or 'as' inside the function, then go for it.