News for hackers. Stuff that matters.
Re:Use Your Type System by johnfn on Thursday July 24, 2025 @11:59AM (#44672314)

    irb(main):001:0> a = 1
    => 1
    irb(main):002:0> a = '1'
    => "1"
It doesn't seem that strong to me.
Re:Use Your Type System by dgb23 on Thursday July 24, 2025 @12:05PM (#44672393)
In the dynamic world being able to redefine variables is a feature not a bug (unfortunately JS has broken this), even if they are strongly typed. The point of strong typing is that the language doesn't do implicit conversions and other shenanigans.
Re:Use Your Type System by Spivak on Thursday July 24, 2025 @02:26PM (#44674268)
Well yeah, because variables in what you consider to be a strongly typed language are allocating the storage for those variables. When you say int x you're asking the compiler to give you an int shaped box. When you say x = 1 in Ruby all you're doing is saying is that in this scope the name x now refers to the box holding a 1. You can't actually store a string in the int box, you can only say that from now on the name x refers to the string box.
Re:Use Your Type System by 9rx on Thursday July 24, 2025 @04:11PM (#44675453)
The types are strong. The variables are weak.
Re:Use Your Type System by folkrav on Thursday July 24, 2025 @04:13PM (#44675475)
It would be weak if that was actually mutating the first “a”. That second declaration creates a new variable using the existing name “a”. Rust lets you do the same[1].

[1] https://doc.rust-lang.org/book/ch03-01-variables-and-mutabil...

Re:Use Your Type System by johnfn on Thursday July 24, 2025 @06:45PM (#44677229)
Rust lets you do the same because the static typing keeps you safe. In Rust, treating the second 'a' like a number would be an error. In ruby, it would crash.
Re:Use Your Type System by folkrav on Thursday July 24, 2025 @11:09PM (#44679161)
Let’s rephrase: is naming a variable typing? As for runtime vs. compile errors - isn’t this just a trade off of interpreted languages?
Re:Use Your Type System by 0x457 on Thursday July 24, 2025 @04:33PM (#44675756)
These are two entirely different a's you're storing reference to it in the same variable. You can do the same in rust (we agree it statically and strongly typed, right?):

let a = 1;

let a = '1';

Strongly typing means I can do 1 + '1' variable names and types has nothing to do with it being strongly typed.