3 ms·
The RBS files seem like a weird compromise to me. I I'm not sure I see the practical benefit, but maybe someone who has used .d.ts files can explain it. Is it j
by eloisius 5y ago
The RBS files seem like a weird compromise to me. I I'm not sure I see the practical benefit, but maybe someone who has used .d.ts files can explain it. Is it just helpful if your IDE has tooling to use it? Seems like it could be helpful, but also sounds like it will become an annoying "code quality" hoop those of us that don't use VSCode will have to jump through for little benefit. When you read code outside of your IDE, like a code review, will you have to scan both files at once in order to benefit from static type information? Does it enforce types at runtime? I'm curious but it's a tough sell to me. I've used optional types in both PHP and Python and found them to be an annoyance compared to strong typing in Rust, where they basically guide you at every step.
The IO/performance improvements and concurrency improvements are exciting. Reading this makes me want to try out ractors.
- kayodelycaon 5y agoI tend to use guard statements in ruby methods to prevent invalid input. It helps people understand how the method is supposed to be used while also failing early with an obvious error, rather than late with a cryptic one. If there was a way to do a type signatures inline without making things ugly, I would use them. Optionally enforcing @param and @return comments would be good enough for me. A separate file is useless for me because I don’t use an IDE.
- eropple 5y agoYou might not use "an IDE", but you can get language server support for a ton of languages in almost any text editor worth using these days. There are Vim LSP plugins for TypeScript, even.
- kayodelycaon 5y agoI suppose. I use a number of linters with Sublime.(1) It’s just not as rich or integrated as a real IDE would be. 1: I have my reasons for using Sublime over the alternatives.
- jamesfinlayson 5y agoHaving used inline typing in PHP and Python I don't really see the benefit of putting it in a separate file either, but when I was reading about it earlier in the year it sounded like Matz wanted types relegated to a separate file, so that's what happened.
- RangerScience 5y agoMy understanding is that this is gentlest possible introduction of types, since you don't have to anything to your existing code. AFAICT the Ruby community is big on gentle iterations, and this is that: enough of type system to start playing with, and to get to the whatever the next step might be.
- kayodelycaon 5y agoSometimes. Ruby 1.8 -> 1.9 was harsh. Forced every string to have an encoding and was absolutely merciless about it; UTF-8 encoding errors everywhere. In a language where so many things are fast and loose, it seemed like an odd decision, but I agree with it.
- saghm 5y agoI think the idea is that it lets you provide type definitions for external libraries. I've never used TypeScript before, but I've heard from friends who use it that sometimes people will write type definitions for third-party libraries whose original authors might not have the time or interest to do it themselves. Basically, it lets you use an arbitrary JS library as though it's properly typed, as long as the maintainer of the type definitions keeps them up to date.
- billybones123 5y agoThis is the use case that I'm familiar with. For packages that don't bundle types, type definitions are often available through DefinitelyTyped[0]. npm install --save-dev @types/node > The types should then be automatically included by the compiler [0] https://github.com/DefinitelyTyped/DefinitelyTyped https://github.com/DefinitelyTyped/DefinitelyTyped