←back to thread

511 points mootrichard | 2 comments | | HN request time: 0.423s | source
Show context
muglug ◴[] No.23990520[source]
Can someone explain why the types cannot live in Ruby code itself (after an appropriate version bump)?

Python 3 incorporated types into the language itself, in a similar way (though non-reified) to PHP. This seems much easier to deal with than requiring two files (.rb and .rbs) to describe a single data structure.

replies(4): >>23990918 #>>23990947 #>>23991201 #>>23991455 #
burke ◴[] No.23990918[source]
Because Matz won't let people add type annotations to the ruby grammar.
replies(1): >>23991128 #
jakearmitage ◴[] No.23991128[source]
Which is great.
replies(2): >>23991239 #>>23991260 #
fimbulvetr ◴[] No.23991260[source]
I don't use ruby, I am genuinely interested - why is it great? I'm assuming if it were ever allowed, it would be a use-at-will feature and wouldn't affect anyone who didn't use it. Typescript has probably doubled if not more my speed and accuracy since I've adopted it - yet I still do plenty of things in normal javascript. These days I'm usually unhappy when something does not have typings because it can make it terribly difficult to discover things.
replies(3): >>23991436 #>>23992170 #>>23992513 #
sparker72678 ◴[] No.23991436[source]
The philosophical argument in the Ruby community is basically that Ruby is not a statically typed language, period. And a strong contingent, myself included, do not want a hybrid world where type annotations are optional, spattering redundancies all over our syntax. Mostly because I see that as a step in the direction of some kind of "strict" mode that will ultimately enforce type annotations and type-checking and destroy most of what I love about Ruby.

That's why the approaches being used keep the type annotations out of the source files themselves.

replies(2): >>23991582 #>>23992236 #
1. ric2b ◴[] No.23992236[source]
> I see that as a step in the direction of some kind of "strict" mode that will ultimately enforce type annotations and type-checking

Ruby is not the first or the second or even the third dynamic language that has added static type checking support, has this _ever_ happened?

replies(1): >>23992558 #
2. captn3m0 ◴[] No.23992558[source]
PHP has a strict typing mode: https://www.brainbell.com/php/strict-type.html