5 ms·
> What’s awesome about Ruby? > Dynamically typed As someone who has experienced the joy and at least some feeling of safety from moving to typescript from jav
by azangru 4y ago
> What’s awesome about Ruby?
> Dynamically typed
As someone who has experienced the joy and at least some feeling of safety from moving to typescript from javascript, I would seriously question that dynamic typing is awesome.
- bryanrasmussen 4y agonot all dynamically typed languages are the same, Ruby is strongly typed and JavaScript is generally described as a weakly typed language.
- cies 4y agoThe word "strong" is not well defined in this context. But usually it is used for languages like Haskell, Idris, PureScript and Elm. Ruby does not do as many automatic casts as JS. In this regard it may be seen as "stronger".
- straight-shoota 4y agoRuby matches this definition: https://www.wikiwand.com/en/Strong_typing https://www.wikiwand.com/en/Strong_typing Crystal has static type checking though.
- sarchertech 4y agoStrong is frequently used incorrectly and as such the meaning has been diluted. But used the way the OP is using it, strong vs weak is different from static vs dynamic.
- Gigachad 4y agoI’d hardly call ruby strongly typed. There is basically no way to verify anything statically so almost all issues show up in run time. Updating Rails or any gems on a production system is a nightmare where the only option is to have 20,000 unit tests and then hope nothing blows up when you release it.
- matthewmacleod 4y agoYou have confused strong typing and static typing.
- mrkeen 4y agoSome of us need the latter for the former. What would you say some of the strengths of Ruby's type system are?
- atmosx 4y agoRuby 3 supports type signatures: https://github.com/ruby/rbs https://github.com/ruby/rbs
- Gigachad 4y agoThe rails creator DHH has indicated that rails would “absolutely not” be getting type support.
- gregors 4y agoThat's absolutely the correct call for rails.
- Gigachad 4y agoIt's the main reason I see Rails not lasting another decade. All the Rails apps I have been working on become almost unmanageable after 6+ years because keeping things updated on an untyped system is borderline impossible to do safely.
- atmosx 4y agoThere are solutions like sorbet[^1] and sorbet-rails[^2]. Have you tried them? [^1]: https://sorbet.org/ https://sorbet.org/ [^2]: https://github.com/chanzuckerberg/sorbet-rails https://github.com/chanzuckerberg/sorbet-rails
- chris12321 4y agoJust because Rails is untyped doesn't mean you can add type definitions to your own code within a rails application.
- Edd314159 4y agoI reject the implication that if dynamic typing is awesome, then static typing is _not_ awesome. It’s like saying pizza is awesome, therefore ice cream is not. Both are awesome! It just depends what you’re trying to achieve at that point in time. A language’s type system is not, in absolute terms, an advantage or disadvantage. It’s just a design choice, each with their own trade-offs that we must consider.
- Existenceblinks 4y agoThis is the problem when people only know one language, especially javascript. And then have quite naive opinion about programming languages. Ones should try at least all one of big categories; one of ML family, one of C-like, one of Lisp dialect.
- azangru 4y ago> This is the problem Could you state the problem more concretely? Javascript is a cross between Java and Lisp, having a Java-esque C-like syntax, and lisp-like function-as-a-first-class-citizen behavior. Typescript brings it all the way to C#; so the C-like territory is firmly covered. An ML-family language, especially something like Haskell, would only reinforce the admiration for static types. Which languages would lead to the conclusion that dynamic typing is awesome? Lisps?
- Existenceblinks 4y agoOh god you are bending some broad aspects to back it up that Javascript has all of greatness from every other style of programming. No, it doesn't. I don't think it works like that. It's like a p10 of jack of all trade.
- gregors 4y agoAs someone who was on the type train in Uni and moved to dynamic languages, my first feeling was slow and unsafe. I couldn't imagine how things wouldn't just explode. In practice I've rarely seen issues. Ruby is still the fastest way for me to get a concept working. I'd definitely consider it awesome.
- trehalose 4y agoI tend to like when languages are dynamically typed, but I suspect it's not the dynamic typing I like--I think it's that dynamically-typed languages generally have type inference. I don't like having to write things like `List<int> list = new List<int>`... I find myself thinking, "Why do I need to tell the stupid compiler in the very same line that a new List<int> is a List<int>? Wtf else would it be?!" When I write in a language such as Kotlin, that's statically typed but has type inference, I feel basically the same lack of resistance as I feel working in dynamically typed languages. Of course, even in such languages, there'll be times when the coder must specify a type, or should specify one for various reasons, but I like when the compiler at least makes an effort, haha. I like Ruby a lot (and I've tried out Crystal in some recreational programming stuff and like it a lot too), and I think I'd still like it just as much without the dynamic typing.