News for hackers. Stuff that matters.
Re:Typing Is Hard by madeofpalk on Wednesday February 17, 2021 @06:01AM (#26165048)
This is... a joke, right?
Re:Typing Is Hard by cryptica on Wednesday February 17, 2021 @06:18AM (#26165172)
If a surgeon needed the help of a computer to make sure that he/she didn't confuse your heart for your kidney, would you trust that surgeon to do an operation on you?
Re:Typing Is Hard by joks on Wednesday February 17, 2021 @08:46AM (#26166190)
How does this metaphor make literally any sense? In what way is type checking similar to making sure you do not kill a person because you can't tell the difference between two organs that look completely different and are in completely different parts of the body?

Here's a metaphor that makes exactly as much sense: "Construction workers should wear hard hats." "If surgeons needed to wear bulletproof vests to perform surgery, that would be silly!"

Re:Typing Is Hard by augustk on Wednesday February 17, 2021 @06:27AM (#26165219)
Why do you think protective equipment is required in some professions? Is it because workers don't know their job?

Anyway, explicit static typing

1. detects errors at compile time

2. provides documentation

3. makes programs run faster.

Re:Typing Is Hard by cryptica on Wednesday February 17, 2021 @06:39AM (#26165298)
Protective equipment is typically used to protect people, not products.

1. Tests detect errors at runtime. Typing is completely redundant when you have even half-decent tests.

2. Comments, good variable and function names provides documentation too.

3. Not really. TypeScript is not faster than JavaScript for example. Even in certain cases where they are faster (e.g. comparing C/C++ with JavaScript), the max speedup is typically less than 40% in the absolute best use cases.. For the average case (typical program) the speedup is typically insignificant (like 5%, 10%...). Also, static types don't stop people from writing inefficient algorithms.

On the other hand, statically typed languages with a build step slow down the develop/test iteration speed. In the case of TypeScript, transpilers add complexity to the project in many ways including compatibility issues (since now you have to worry about not just Node.js or Browser version but also TypeScript version and the different permutations)... Source mapping doesn't work right in certain environments. The output often looks mangled and is hard to debug in a constrained remote environment. Takes more time to setup. Adds many unnecessary dependencies to your project. Makes your software harder to integrate by third-parties since your schema is more rigid and might not correspond with their own type system. They encourage developers to define complex function signatures with complex interfaces and encourage passing instance references instead of simple copy-by-value primitives.. The drawbacks are significant and I could keep listing them all day.

Re:Typing Is Hard by madeofpalk on Wednesday February 17, 2021 @06:35AM (#26165264)
I mean we're not surgeons, we just make over-complicated wordpress themes.

I like static typing because sometimes those systems are complicated (for better or worse), and you want to understand the wake of a certain change. Or, it's just another form of documentation. How is it disagreeable that these are good things, or only relevent for the less experienced?

Re:Typing Is Hard by nullifidian on Wednesday February 17, 2021 @06:37AM (#26165281)
And yet medical mistakes occur pretty frequently. "We removed the wrong kidney" and the like.
Re:Typing Is Hard by augustk on Wednesday February 17, 2021 @07:03AM (#26165448)
Of course, removing the wrong heart would be even worse.
Re:Typing Is Hard by oalae5niMiel7qu on Wednesday February 17, 2021 @01:13PM (#26169552)
Off-by-one errors occur frequently in programming, and static typing does nothing to prevent them, since n and n+1 are always of the same type.
Re:Typing Is Hard by theon144 on Thursday February 18, 2021 @04:03AM (#26177574)
That's correct, but seems irrelevant?
Re:Typing Is Hard by cryptica on Thursday February 18, 2021 @10:59AM (#26181383)
It's very relevant. In fact I would argue that type systems only address the simplest possible errors and do absolutely nothing about the most complex, time-consuming errors such as those related to unpredictable state mutations caused by multiple events being processed in parallel or having different parts of the code operate on the same instances.

In fact, I would argue that static typing encourages developers to define more complex function interfaces which creates stronger coupling between components in the code and this leads to instances being passed around/shared between more different files and this is more likely to lead to unpredictable mutations of those instances' state. It makes it easier for developers to neglect good separation of concerns.

Dynamic languages make it more difficult to keep track of complex instances between different functions and files so they encourage developers to pass more primitive 'pass by value' arguments; this results in looser coupling between the components.

Dynamic languages encourage more modular, more interchangeable code. This is why the most popular package managers of all time are based on dynamic languages like JavaScript (npm) or Ruby (RubyGems) and not on statically typed languages; it's not a coincidence.

Re:Typing Is Hard by m0deran on Friday February 19, 2021 @03:24PM (#26197601)
statically typed languages with dependent types solve this problem of “static types not catching off-by-ones”, although I question the premise of these being the most common software bugs. Perhaps in a CS class these are the most prevalent?

Furthermore,

> Dynamic languages encourage more modular, more interchangeable code.

Have you ever used an ML or another typed language with an actual module system? It makes these dynamic languages look duct-taped in comparison.

Re:Typing Is Hard by dw-im-here on Friday February 19, 2021 @02:02AM (#26190490)
I wouldn't ever trust you to make an analogy