Earlier quoted context omitted.
Haven't used ruby in years for the typical reasons people move away from it (performance, strong types, GVL, etc.) but syntax is #1 reason I like programming in Ruby. I did mostly ruby for about 5 years and really grew to love it! It may seem bonkers at first but quite enjoyable once you understand it. Now nearly 4 years later of mostly javascript, golang, python, haskell I still regularly stop and think to my self h…
I read parent’s “bonkers” in a positive way. Then for instance most languages get away with inline optional typing by using “:” , for instance “ping_user(name: String)“. In ruby it’s of course already taken, in no small part because there are 3 or 4 different ways to declare hash parameters. I’d imagine most decent syntax candidates had similar issues, due to ruby’s syntax versatility.
RBS, Ruby’s new type signature language
301–310 of 340 posts
Re: RBS, Ruby’s new type signature language
#302Earlier quoted context omitted.
RubyMine works great if you add yard type docs to your code.
Is it checking those types or just reporting then? I’ve seen so many instances where yard doc has the wrong return type or misses a return type that I rarely trust it.
Re: RBS, Ruby’s new type signature language
#303I'm still trying to make sense of this announcement. With a lack of type annotation in the Ruby core, I chose to build off YARD to make gradual type safety work. Now I don't know if there will be a standard that supports type safety or if I should continue down the path I'm already following. Help me, Ruby core developers. You're my only hope. (edit: I should have explained that I'm talking about the type checking fe…
I hear you. It occurred to me that Ruby could have chosen to innovate with something like a Semantic TomDoc. To choose a separate file based approach seems like a step backward. At the very least it could have been module based. But Matz is a C coder -- not a Ruby coder. So it doesn't necessarily surprise me. It's sad though. Since poor design of Refinements, C transpiling for 3x project, and now this, I am less and…
Re: RBS, Ruby’s new type signature language
#304For the time being I think this kind of type checking is only worthwhile in big projects, for smaller projects I have found Sorbet never finds an error, so it's just extra work to generate the files on a big change.
Re: RBS, Ruby’s new type signature language
#305Citation needed. In my experience this is a fallacy; types take no time at all to write and significantly reduces bugs (Typescript).
Re: RBS, Ruby’s new type signature language
#306Earlier quoted context omitted.
Clojure is strongly typed. I think you mean statically typed. They're orthogonal concerns. C is statically and weakly typed. Clojure is dynamically and strongly typed. PHP is dynamically and weakly typed. Haskell is statically and strongly typed. Java, as the most design-by-committe language ever, manages to be a mix of all four.
Strong typing generally does not mean much and everyone seems to be using a different definition. Would you consider Javascript weakly typed? What about Python?
I'd consider Python to be more strongly typed than JavaScript. It doesn't do quite so many automatic conversions. For example, in Python, `1 + "foo"` is a TypeError. In JavaScript, it's "1foo". Sadly, `1 == True` in Python, so it certainly doesn't get full marks.
Re: RBS, Ruby’s new type signature language
#307Earlier quoted context omitted.
But when you have things like "duck typing", don't you think "they check types at runtime" becomes less meaningful? The majority of functions written in Python, even the ones that have type annotations, do not effectively have "assert isinstance(...)" in the program text below their signature, which is what I'd expect after reading "check types at runtime". Also, Python now has (in its stdlib!) things like typing.Pro…
I don't really know what you're trying to say here. Why would it be less meaningful to say types are checked at runtime with ducktyping? The nature of ducktyping is that the specific class of an object does not matter relative to behaviour, but a class is not entirely equivalent to a type. If I need an object that implements method `foo`, and don't care about class, then "objects that implements foo" is in itself a t…
[0] https://learn.adacore.com/courses/intro-to-ada/chapters/stro...
Re: RBS, Ruby’s new type signature language
#308Earlier quoted context omitted.
I don't really know what you're trying to say here. Why would it be less meaningful to say types are checked at runtime with ducktyping? The nature of ducktyping is that the specific class of an object does not matter relative to behaviour, but a class is not entirely equivalent to a type. If I need an object that implements method `foo`, and don't care about class, then "objects that implements foo" is in itself a t…
Quibbles with your final paragraph: that's not what strongly typed means. It refers to when a language has strict rules restricting implicit type conversions. [0] Also, C++ has RTTI. [0] https://learn.adacore.com/courses/intro-to-ada/chapters/stro...
E.g. Liskov and Zilles [1] defined it this way for example:
"whenever an object is passed from a calling function to a called function, its type must be compatible with the type declared in the called function."
Under this definition C and C++ fails hard, since you can statically cast a pointer to an object and pass it to a function expecting a totally incompatible type.
Note that the system described relied at least partly on dynamic/runtime type checks (in case it reads as if the quote above suggests they used "strong" to refer to static typing):
"It is desirable to do compile-time type checking, since type errors are detected as early as possible. Because of the freedom with which types can be used in the language, however, it is not clear how complete the compile time type checking can be. Therefore, the design of the language is based on a runtime type checking mechanism which is augmented by as much compile-time checking as is possible. "
[1] https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.13...
Re: RBS, Ruby’s new type signature language
#309Earlier quoted context omitted.
Strong typing generally does not mean much and everyone seems to be using a different definition. Would you consider Javascript weakly typed? What about Python?
I'd consider JavaScript to be more toward the weak typing end of things, because it does lots of automatic conversions with surprising results. (see, for example, Gary Bernhardt's "Wat?" lightning talk.) I don't think I'd consider it as weak as C, which has things like unions and pointers that let you just sort of fall out of the type system entirely. I'd consider Python to be more strongly typed than JavaScript. It…
Re: RBS, Ruby’s new type signature language
#310Earlier quoted context omitted.
The current state of Crystal is basically a language for PoC during the week-end, it's far from being ready. I could go on about what's wrong with the language but: It's not stable, API change all the time, breaking change all the time, cryptic errors, lot of missing basic features, IDE integration etc ...
> The current state of Crystal is basically a language for PoC during the week-end, it's far from being ready. That is changing, earlier this year, the Crystal team are working on getting the language stable for 1.0 [0] Companies are already now using Crystal in production, most recently Nikola Motor Company [1]. Surely they wouldn't choose crystal if it was a 'half baked' language. [0] https://crystal-lang.org/2020/…