3 ms·
I am so excited about this!! Ruby tooling is already pretty good, but we can do better. I will try to contribute. Now we just need types
by gurgeous 1y ago
I am so excited about this!! Ruby tooling is already pretty good, but we can do better. I will try to contribute. Now we just need types
- bingo-bongo 1y agoTake a look at Crystal for types: https://crystal-lang.org/ https://crystal-lang.org/
- dcchambers 1y agoCrystal is cool but the only thing it shares in common with Ruby is a similar syntax. If you actually want types in Ruby, you should check out Sorbet: https://sorbet.org/ https://sorbet.org/
- dismalaf 1y agoPlease no types... They're worse than pointless for a dynamically typed language.
- bmacho 1y agoAll dynamically typed Ruby competitors like Python, Javascript (via Typscript), PHP, Elixir have embraced Gradual Typing/Type Inference. You use typed variables/typed function signatures when it's convenient, they give you some compile-time contracts, easy documentation and probably even speed. Otherwise they don't exist. I don't do Ruby, but Gradual Types/Type Inference is a no-brainer for dynamic languages, practically no drawback, only benefits. (And popular statically typed languages such as C/C++, Java, Rust support Type Inference, or are going there too.)
- dismalaf 1y agoCool. People who want gradual typing can use those and leave Ruby alone. > I don't do Ruby So why have an opinion? Languages I use: Ruby, C++, Odin, R. I'm not about to to around telling Rust, Python or Typescript people they're doing their languages wrong, even if there's things I hate about those languages. I just don't use them.
- jameslk 1y agoRuby already has this with Sorbet. Nobody is forcing you to use it, are they? It seems you have a lot of opinion here without really discussing your problem with type hints though. What is it you dislike? I use Ruby regularly, have used it for more than a decade, and I wish it had something like a TypeScript equivalent (Sorbet is sorta this but not enough). Every time I work with a Ruby codebase without Sorbet, it’s a lot of guessing and praying that test coverage is good enough. It’s not fun having to find out in prod there’s dumb bugs that would have been caught by static analysis. Something I experience virtually never in TypeScript, the other language I’ve also used for a decade
- dismalaf 1y ago> It seems you have a lot of opinion here without really discussing your problem with type hints. What is it you dislike? It's runtime overhead (or you make a transpiler which then makes the language less dynamic), makes metaprogramming more annoying (other languages solve this with an "any" type which just defeats the purpose), and the "problem" it solves can be solved with tests which you should be writing anyway. I do use statically typed languages BTW, I just prefer that if I'm going to go through the rigmarole of types that I'm going to get some actual benefit, namely an order of magnitude more performance. My opinion is probably this since I don't work for a large corporation, I have my own startup, so I value my time a lot. I'm ok with trade-offs, I just think adding type hints to a dynamic language isn't a good trade off; it's almost all downside. Edit: > guessing and praying that test coverage is good enough. You can always improve your test coverage...
- GrantMoyer 1y agoPyright catches an awful lot of dumb mistakes I make in Python.
- notpushkin 1y agoSidenote, but you might also want to give basedpyright a try (basically FOSS Pylance reimplementation): https://docs.basedpyright.com/ https://docs.basedpyright.com/
- jameslk 1y agoStatic analysis through type hints brings plenty of benefits to a dynamic language, such as helping to eliminate bugs at runtime (albeit not perfectly) and making it easier to grok a codebase. It’s a trade off and Ruby is as dynamic as it gets. But there is a point to it
- phoronixrly 1y agoMy beautiful experience with sorbet: Yeah, ducktyping? We don't do that here. Depending on a library that uses ducktyping (like any sane library following the Ruby conventions)? Good luck writing a wrapper for it. Or just disable type checking. This goes so much against the Ruby vibe that I advise you to just go and use Rust instead if you hate Ruby that much that you want to butcher it with types.
- jameslk 1y agoSorbet has its flaws. I didn’t like it either. Having used TypeScript extensively, there is a way to do it right and a way to do it wrong. I’d classify TypeScript as the ideal way to introduce static types into a very dynamic language, given its extensive flexibility to handle dynamic features in a language (e.g. smart type inference, ‘is’ keyword, very flexible generics). Sorbet doesn’t have a lot of those features Ruby has a strong history and tradition of TDD/unit testing. This is partially a crutch for its lack of static type analysis. Ultimately checking for bugs before running code is very useful
- pxc 1y agoSorbet can actually make programs crash at runtime if a variable's type doesn't match its annotation, right? It's not as busted as some other gradual typing implementations.
- phoronixrly 1y agoOh exactly what I wanted - runtime overhead, on top of its lack of ability to accomodate ducktyped external dependencies in any sane way. It does welcome nil proliferation though! Just sprinkle some `nilable` around and you're set to continue the actual scourge of the language.
- Lio 1y agoI'm definitely in favour of gradual typing but runtime checking is already really easy to do if that's what you want. Just add a rightward assignment patten match to your method. e.g. def somemethod(foo, bar) foo => Integer bar => MyBarClass end Personally I think the RBS-Inine format is the way forward. Sorbet has experimental support for it too. https://sorbet.org/docs/rbs-support https://sorbet.org/docs/rbs-support
- seabrookmx 1y agoMany smart engineers (including Guido) disagree with you, and have added static types to Python, Javascript, Dart, Elixir, Hack and surely some I'm forgetting.
- dismalaf 1y agoI use statically typed languages. There's benefits. There's also benefits to dynamically typed languages, namely runtime metaprogramming. Dynamic typing + type annotations is the worst of both worlds for questionable benefit.
- seabrookmx 1y ago> the worst of both worlds Agree to disagree!
- deleted 1y ago[deleted]