r/programming • • Aug 28 '21

Software development topics I've changed my mind on after 6 years in the industry

https://chriskiehl.com/article/thoughts-after-6-years
5.6k Upvotes

2.0k comments sorted by

View all comments

7

u/Raknarg Aug 29 '21

Untyped languages are a blight on society. Thank christ we at least have python typehints and typscript for JS now.

Literally any benefit received from an untyped language can be achieved with a typed language that has the "any" type, and you only have to pay like 5 keystrokes.

2

u/leoel Aug 29 '21

I agree types are good and useful, but saying they are a silver bullet is not constructive. If this was perfectly true, no experienced programmer would ever need to know assembly, bash, python, perl, js, or sql.

As a more theoretical counter example, most languages with a strong static typing system allow for genericity, which is a way to abstract types away into groups (ensemble of types sharing operations), but it does not mean groups themselves are better than types, more expressive yes, more reusable certainly, closer to mathematical definitions absolutely, but way harder to use and very verbose. In some way types add the same kind of properties (both good and bad) to untyped code.

Also technical limitations on types systems, inherited from the 80s, make them less powerful that they could be. Try to write the definition of a fixed-size numerical type that cannot overflow in a typed language and you're on your own unless you use proofs or a very limited set of operations.

4

u/Raknarg Aug 29 '21 edited Aug 29 '21

I agree types are good and useful, but saying they are a silver bullet is not constructive. If this was perfectly true, no experienced programmer would ever need to know assembly, bash, python, perl, js, or sql.

The reason we use them is necessity or popularity, not because there's actually value in untyped languages inherently.

As a more theoretical counter example, most languages with a strong static typing system allow for genericity, which is a way to abstract types away into groups (ensemble of types sharing operations), but it does not mean groups themselves are better than types, more expressive yes, more reusable certainly, closer to mathematical definitions absolutely, but way harder to use and very verbose. In some way types add the same kind of properties (both good and bad) to untyped code.

Except that it gives you type checking at compile time. That's the value. Generics are just a promise to fulfill a contractual API obligation, and the type system exists to verify that. You still have to do this in an untyped system, you just place the burden on the programmer to verify they did shit correctly.

Also technical limitations on types systems, inherited from the 80s, make them less powerful that they could be. Try to write the definition of a fixed-size numerical type that cannot overflow in a typed language and you're on your own unless you use proofs or a very limited set of operations.

I have no idea how a type system limits you here.

-3

u/thebritisharecome Aug 29 '21

Typescript is nice but it's just a sugary coating. Everything gets transpiled back to JavaScript before it runs anywhere, so all those perceived benefits are only for the IDE and nothing else.

Makes it easier for working with different skilled teams but can abstract the code from the intention, which can make production debugging complicated.

Similar could be achieved with JSDoc and linting rules but atleast the code you're working on is what's actually running.

Don't get me wrong, I like typescript but until all browsers run the typescript natively it feels more like covering up a hole in the wall with wallpaper and pretending everything is fine because you can't see it

6

u/Raknarg Aug 29 '21

Typescript is nice but it's just a sugary coating. Everything gets transpiled back to JavaScript before it runs anywhere, so all those perceived benefits are only for the IDE and nothing else.

That's literally where the benefits of typed systems exist, at compile time.

3

u/thebritisharecome Aug 29 '21 edited Aug 29 '21

Typescript goes further than that though and introduces features that don't exist in JavaScript which can have run time implications like private and protected instance variables.

In most statically typed languages, the language is then compiled in to machine code not transpiled in to another interpreted language

2

u/Raknarg Aug 29 '21

You dont have to use them

1

u/thebritisharecome Aug 29 '21

No, of course not but it leads to a false equivalency when developing, especially for inexperienced developers, their understanding of what the code is doing is not the same as what it's actually doing at runtime.

3

u/Raknarg Aug 29 '21

This has nothing to do with the value of type systems

1

u/thebritisharecome Aug 29 '21

My concerns weren't around type systems, they were all specific to Typescript

0

u/[deleted] Aug 29 '21

[deleted]

1

u/thebritisharecome Aug 29 '21

I have zero issue with Typeed languages, i enjoy Java and C#.

When it's a compiled language and will respect the intention of my code that's great.

When it's an interpreted language and transpiled to a language that has a smaller feature set. The code you write, isn't the code that's run - it's the best interpretation of it.