Most active commenters

    ←back to thread

    511 points mootrichard | 12 comments | | HN request time: 0.251s | source | bottom
    1. freedomben ◴[] No.23990680[source]
    I'm not thrilled about the separate files with the type information but I completely understand why they did it, and if it were my choice I might make the same one.

    I don't like the comparison with TypeScript `.d.ts` files however, because TS still lets you do types inline in the code. I haven't seen it mentioned anywhere that this won't be supported by Ruby 3.

    Does anybody know if Ruby 3 will also support inline type information or will the header RBS files be required?

    replies(3): >>23990915 #>>23991508 #>>23992127 #
    2. amw-zero ◴[] No.23990915[source]
    I much prefer separate files for type declarations. Or at least the ability to define them separately. Type annotation takes away from readability. I like keeping the types and code separate.
    replies(4): >>23990990 #>>23991109 #>>23991234 #>>23991625 #
    3. hombre_fatal ◴[] No.23990990[source]
    The upside of external files is pure incremental implementation that touches no other tooling and requires no buy-in.

    I don't see how having to switch files to know that `input` is a `User` increases readability, though. It seems like straight-forward impl-simplicity trade-off, not one of user ergonomics.

    replies(2): >>23991228 #>>23991261 #
    4. untog ◴[] No.23991109[source]
    > Type annotation takes away from readability.

    I don't disagree, but I think it's a very minor issue given that it's trivial to use color to highlight code these days. By comparison having to switch between two files (and keep them in sync!) when making changes is a far bigger usability concern.

    5. strogonoff ◴[] No.23991228{3}[source]
    Separating type definitions from code can be considered as contributing to readability of idiomatic Ruby on one hand, and type definitions on the other, taken separately on their own—by not imposing constraints on either syntax.

    IDEs will likely be able to seamlessly peek/go to RBS type definition on any Ruby identifier in any case.

    6. benrbray ◴[] No.23991234[source]
    > Type annotation takes away from readability.

    Do you mean for Ruby specifically or in general? I've found that it's much easier to (safely, accurately) read, use, and extend e.g. a TypeScript file than its JavaScript counterpart, even when provided with a .d.ts file.

    7. mekster ◴[] No.23991261{3}[source]
    That can be covered by the editor to give the user some hint by referencing the external file but for the user, having have to keep adding it on a separate file seems pretty annoying as you need to keep declarations synched in 2 files.

    Also how do you type something in an inline function?

    8. rattray ◴[] No.23991508[source]
    I don't think Ruby 3 itself will provide a typechecker, just a standard for type definition file formats. You have to use a third-party tool, like Steep or Sorbet, to do the type-checking – and Sorbet at least does support inline type information. See more at my comment here: https://news.ycombinator.com/item?id=23991258

    You won't need to use the header RBS files at all (types are optional in any case) but you'll likely want to use Sorbet or Steep to generate them if you're sharing your code more widely, since community tooling like YARD will probably use those for code navigation.

    replies(1): >>23991553 #
    9. baweaver ◴[] No.23991553[source]
    The intention right now is for the StdLib to provide known types to build off of written in RBS. There's no requirement to use them necessarily.

    Steep and Sorbet are second-level, they build off of RBS. Matz has mentioned offhandedly in conversations I'd had with him in the past that there's a ton more in store with RBS beyond just type checking, so we'll see where they go with it.

    As far as YARDoc I've been eyeing that one for a while now since I first heard about Steep at a Braintree Ruby meetup before Soutaro was at Square. We're still talking about what and how as far as that one.

    10. wolfadex ◴[] No.23991625[source]
    Type annotations aren't inline in all languages. If you're writing Haskell or Elm, as a few examples, then you get static types without having to write them out and if you do write them out they sit above the function that uses them.
    replies(1): >>23992289 #
    11. jrochkind1 ◴[] No.23992127[source]
    If you completely understand why they did it, can you explain it to me?

    > Does anybody know if Ruby 3 will also support inline type information or will the header RBS files be required?

    Wait, what are we talking about? I thought this was the decision you said you completely understood, that the type information is in separate .rbs files. Isn't ruby 3 what we're talking about?

    12. ric2b ◴[] No.23992289{3}[source]
    I don't think anyone is disappointed that it isn't literally inline, the problem is that it's in separate files.