News for hackers. Stuff that matters.
Re:I love building a startup in Rust. I wouldn't pick it again by jdlshore on Friday February 17, 2023 @08:52PM (#34843057)
Map’s second and third parameters are optional. Your functions aren’t required to implement them, which is good, because most of the time you don’t need them.

Again, this isn’t a type system issue. It’s both an API design issue and a poor programming hygiene issue. (Don’t pass bare functions if you don’t know what the parameters are.)

Re:I love building a startup in Rust. I wouldn't pick it again by jjnoakes on Friday February 17, 2023 @09:06PM (#34843118)
> Map’s second and third parameters are optional.

I mean, map always passes them in, so in that sense they aren't optional. Mixing that with functions that take in optional parameters, but aren't usually called with them, gives you a ticking time bomb, IMO. And double that danger when the language's type system allows you to call a function with more parameters than it could ever take.

> Don’t pass bare functions if you don’t know what the parameters are.

This is exactly the kind of thing I want my programming language's type system to catch for me, if I'm working in a language with a static type system like TS.

And even in dynamic languages, this is exactly the kind of thing I want my programming language to catch for me at runtime. Python does, for example.

Stuff like this - while it might fit JS and TS and make sense to some - makes absolutely no sense to me, and is why I simply look to other languages to fit my needs.

Re:I love building a startup in Rust. I wouldn't pick it again by Mapsmithy on Friday February 17, 2023 @11:09PM (#34843805)
How would you change the Type System to fix this particular issue?

>> Don’t pass bare functions if you don’t know what the parameters are.

> This is exactly the kind of thing I want my programming language's type system to catch for me, if I'm working in a language with a static type system like TS.

Hows your compiler supposed to know you don't know what the parameters are?

Re:I love building a startup in Rust. I wouldn't pick it again by jjnoakes on Saturday February 18, 2023 @12:04AM (#34844075)
> How would you change the Type System to fix this particular issue?

In TS you really can't (that's my point and why I prefer to avoid the language) because of JS and API baggage. But just about every other static language that I've worked in can complain for this kind of thing.

> Hows your compiler supposed to know you don't know what the parameters are?

Why does the compiler care about what I know? The compiler itself knows what the function's parameters are and it can tell me that something seems wrong because I'm asking it to call a function that maxes out at 2 parameters with 3 parameters.

TS does catch this kind of thing in a lot of places. It just intentionally decides not to do it for these kinds of callbacks because of the same JS and API baggage.