News for hackers. Stuff that matters.
Re:Why We Chose Typescript by gnaritas on Saturday July 01, 2017 @04:57PM (#14678989)
That's not what I mean by more code, by taking advantage of dynamic typing you can write more generic code than is even possible with generics in a statically typed language; code that works for any type, whereas a static language either forbids you or forces you to write multiple versions of the function. You can't write a single Max function in C# that works for any type supporting >=, it simply can't be done. This is typical of static languages, they forbid perfectly good code because it "might" be used inappropriately or because the type system can't guarantee it won't.
Re:Why We Chose Typescript by dragonwriter on Monday July 03, 2017 @01:43PM (#14690061)
> by taking advantage of dynamic typing you can write more generic code than is even possible with generics in a statically typed language; code that works for any type, whereas a static language either forbids you or forces you to write multiple versions of the function.

If you can write code that works for some combination of types, it's because those types present a common interface that could be specified in a sufficiently-expressive static type system, either via something like OOP interfaces or something like Haskell typeclasses.

> You can't write a single Max function in C# that works for any type supporting >=, it simply can't be done.

You can, in fact, do so for any type supporting the IComparable<T> interface. That the operators are defined independently is a C# type-system quirk, not a fundamental limitation of static type systems.

Re:Why We Chose Typescript by gnaritas on Monday July 03, 2017 @03:12PM (#14690643)
> that could be specified in a sufficiently-expressive static type system

Ah the mythical sufficiently-expressive static type system, I'm concerned with type systems that are in use in real jobs, not vaporware ones that could exist if only. Dynamic language support it now.

> You can, in fact, do so for any type supporting the IComparable<T> interface.

Which requires forethought on the designers of said library, I'd rather have duck typing which works without requiring correct future planning with interfaces.

Re:Why We Chose Typescript by sjwright on Sunday July 02, 2017 @08:39PM (#14685118)
Nothing is stopping languages from allowing both. For example, it could have some form of compound type declaration.

Meanwhile, how often is code made worse because you have to write multiple Max implementations? And I doubt that there's many instances where such repetition is necessary, or can't be mitigated with wrapper functions.

Re:Why We Chose Typescript by gnaritas on Monday July 03, 2017 @01:33PM (#14689996)
> Nothing is stopping languages from allowing both

Nothing stops pigs from flying either... hypothetically, but they don't, and languages don't, so debating what they could do is rather pointless, they don't.

> how often is code made worse because you have to write multiple Max implementations

Similar situations occur quite often.

> I doubt that there's many instances where such repetition is necessary, or can't be mitigated with wrapper functions.

That they have to be mitigated is the point, I don't have to do stuff like this at all in a dynamic language, things just work.

Re:Why We Chose Typescript by sjwright on Monday July 03, 2017 @07:21PM (#14692192)
Congratulations, you have worked out that there are no perfect languages. I don't understand what point you're trying to make, other than you prefer one set of trade-offs to another.
Re:Why We Chose Typescript by gnaritas on Thursday July 06, 2017 @05:04PM (#14713954)
> other than you prefer one set of trade-offs to another. reply

So you can understand the point being made, congratulations, it's what engineering is all about.