3 ms·
> I generally think a programming language should incentivize you to "do the right thing" > It is easier to create a immutable struct than a mutable struct Th
by sundarurfriend 4y ago
> I generally think a programming language should incentivize you to "do the right thing"
> It is easier to create a immutable struct than a mutable struct
This is exactly an implementation of that principle - since very often one of the goals when using Julia is performance, it makes sense to incentivize the more performant option. [1]
> I'm incentivized to write `::String` instead of `::AbstractString`, `::Int` instead of `::Integer`. In Julia using `AbstractString` is almost always preferred.
I'm on the fence about this one. I used to think this way, but now I think just slapping Abstract types everywhere in code leads only to fake-genericity. It's the sort of trap that leads to the kind of problems Yuri complained about in his (in)famous blog post.
I'd rather someone type ::String and be artificially limited in what they accept (at least for now, until someone complains), rather than be incentivized to say they accept an abstract type and then end up not actually supporting all of the abstract type interface's flexibility.
[1] https://docs.julialang.org/en/v1/manual/types/#Mutable-Composite-Types-1 https://docs.julialang.org/en/v1/manual/types/#Mutable-Compo...