News for hackers. Stuff that matters.
Re:Strong typing, a hill I'm willing to die on by insanitybit on Wednesday October 04, 2023 @09:12AM (#37764574)
At this point it's beyond a hill I'm willing do die on. I'm not really interested in discussing it. If you don't get it I probably don't want to talk to you about it, I might even think less of you as a software developer. The amount of pre-existing respect for someone I'd need to have before I engage in a good-faith discussion on "are types good" is pretty high.

edit: To clarify, I am on the "types good" side of things

Re:Strong typing, a hill I'm willing to die on by KronisLV on Wednesday October 04, 2023 @09:41AM (#37765044)
> At this point it's beyond a hill I'm willing do die on. I'm not really interested in discussing it. If you don't get it I probably don't want to talk to you about it, I might even think less of you as a software developer.

That's a pretty strong take! I don't think there are many things that I feel similarly about... maybe if someone suggested that they don't need test environments and can just deploy changes to prod without testing or CI/CD and just see what happens, when it'd be my employment on the line, but even that's a pretty contrived and out there example.

> The amount of pre-existing respect for someone I'd need to have before I engage in a good-faith discussion on "are types good" is pretty high.

My problem is that not all type systems and the way you use them are equal.

When working with back end code, I really like .NET or even Java having a type system there for me. I know that people suggest that they have their own shortcomings (type erasure, NPEs, no multiple inheritance, even smaller things like C# enums not supporting methods) and that there are better options out there, but generally you can turn off the part of your brain that'd worry about the language too much and just deal with the domain problem at hand. Something like JetBrains are also excellent, because with the type system suddenly the tool also can reason about the language constructs you're using and give you all sorts of good suggestions and refactoring options.

Whereas with something like TypeScript in combination with React, there are times where you fight the type system instead. That's just the impression that I got working on a few projects for a while, in comparison to React with JS (perhaps the code was also a bit too clever), while with Angular it felt more coherent to me (despite Angular being more complex otherwise and not really my first choice). In the end, I gravitate towards Vue with JS for my personal stuff, but it's not like you can just say no to TypeScript when you need to maintain something long term.

I can't actually remember who said that they ditched TypeScript for similar reasons, but the argument was basically that a non-insignificant part of their codebase was there just to satisfy the type system. TypeScript does what it's supposed to... but it feels like it could be easier.

Re:Strong typing, a hill I'm willing to die on by insanitybit on Wednesday October 04, 2023 @09:43AM (#37765067)
> That's a pretty strong take!

Not even one of my spicier takes, just one of the few that I simply don't care to engage with further.

> My problem is that not all type systems and the way you use them are equal.

We agree. Some type systems suck so badly that I can see why people would be tempted to believe that all type systems suck.

Re:Strong typing, a hill I'm willing to die on by KronisLV on Wednesday October 04, 2023 @09:50AM (#37765162)
> Some type systems suck so badly that I can see why people would be tempted to believe that all type systems suck.

But that's my point: people say that exact thing about Java and .NET, while I find them usable. Meanwhile TypeScript has cool stuff like union types and other stuff to the point where you can get pretty clever with it (https://codegolf.stackexchange.com/questions/237784/tips-for...), which many would describe as the type system being objectively better, yet it's also more difficult for me to use.

In my mind, a good type system would let you do both basic stuff easily without too much work (to make sure that refactoring doesn't make you shoot yourself in the foot) and also encourage you to write the simplest code that you can get away with, while allowing you to get clever in the select few places where that is actually needed.

Which is funny, because adjacent to that, Java and .NET (web) frameworks can be a masterclass in incidental complexity, even though for me the type systems don't get in the way too much.

Edit: actually, I think I'll migrate a JS project to TS, this time in Vue. Perhaps Vue 3 will be a pleasant experience and if it won't, then I'll have a concrete list of things that caused me to feel this way.

Re:Strong typing, a hill I'm willing to die on by satvikpendem on Wednesday October 04, 2023 @10:17AM (#37765543)
Vue is not too great with TypeScript in my experience. That's one of the reasons why I switched from Vue to React.
Re:Strong typing, a hill I'm willing to die on by mcv on Wednesday October 04, 2023 @11:22AM (#37766496)
I thought Vue 3 was supposed to be native Typescript.
Re:Strong typing, a hill I'm willing to die on by mcv on Wednesday October 04, 2023 @11:21AM (#37766477)
I'm pretty agnostic about the whole thing. The topic has been done to death already. Types are great, but some ways of handling types can get in the way sometimes, and the excessive type declarations in older Java was just painful. Dynamic types can work fine too, but they work better in smaller projects than in bigger ones. Types do give you a lot more to hold onto, even if they're only compile-time types like Typescript. In large, complex projects where you're juggling a lot of different types, you want to know what you've got in your hands.

That's pretty much my take. I don't hate anyone for having different ideas about it. But if you're going to use Typescript, don't use 'any'. At all. Unless you really don't know and the next step is figuring out what type you've got.

Re:Strong typing, a hill I'm willing to die on by xxs on Wednesday October 04, 2023 @01:03PM (#37768193)
>maybe if someone suggested that they don't need test environments and can just deploy changes to prod without testing or CI/CD and just see what happens

That's actually not hard, you need to be able to run in dry mode, and run the same in an existing instance (in parallel), then compare the results. If you are happy you can continue with the roll up, disabling the dry mode.

Re:Strong typing, a hill I'm willing to die on by tasn on Wednesday October 04, 2023 @09:18AM (#37764675)
Author here. I ended the post with:

> I can see both side of the arguments on many topics, such as vim vs. emacs, tabs vs. spaces, and even much more controversial ones. Though in this case, the costs are so low compared to the benefits that I just don't understand why anyone would ever choose not to use types.

> I'd love to know what I'm missing, but until then: Strong typing is a hill I'm willing to die on.

I genuinely want to know what I'm missing. I also outlined in the post all of the arguments I usually see in favor of not having types and why I disagree with them.

I'm happy, willing, and excited to hear what I'm missing.

Re:Strong typing, a hill I'm willing to die on by insanitybit on Wednesday October 04, 2023 @09:24AM (#37764764)
Hey, I hear you, and I commend you for your good faith position of "I want to hear both sides". I'm just not there anymore. The arguments put forth ("the cost is worth it, it makes up for itself", etc) are arguments I've had a million times and I just no longer will engage.
Re:Strong typing, a hill I'm willing to die on by tasn on Wednesday October 04, 2023 @09:30AM (#37764859)
Oh, apologies, I misread your comment. I thought you were saying that you won't engage in this discussion because of my strong stance on the topic. I'm a big fan of "Strong beliefs, weakly held".
Re:Strong typing, a hill I'm willing to die on by junon on Wednesday October 04, 2023 @09:57AM (#37765265)
Same here. Been doing this for too long that I refuse to even bother anymore.
Re:Strong typing, a hill I'm willing to die on by a_c on Wednesday October 04, 2023 @09:20AM (#37764703)
I think you and parent are in agreement
Re:Strong typing, a hill I'm willing to die on by randomdata on Wednesday October 04, 2023 @09:43AM (#37765064)
> I just don't understand why anyone would ever choose not to use types.

Is there a language out there that gives you that choice?

I expect you mean choose not to use strong static typing as per the original piece? Compatibility is a pretty good reason. I'd like to see Javascript die in the fiery pits of hell as much as the next guy, but its positioning means it is almost inevitable that some system will make it the only reasonable choice for you to choose if you want to build for that system.

Typescript doesn't help. It adds static typing, but not strong typing.

Re:Strong typing, a hill I'm willing to die on by junon on Wednesday October 04, 2023 @09:54AM (#37765213)
Python and PHP both have type hints that are natively ignored by the language if present, but can be checked if you have enough of them, if that's what you mean.
Re:Strong typing, a hill I'm willing to die on by randomdata on Wednesday October 04, 2023 @09:58AM (#37765273)
No, I mean it lacks strong typing. C and C++ also lack strong typing even with static typing being a core feature and checked at compile time.
Re:Strong typing, a hill I'm willing to die on by junon on Wednesday October 04, 2023 @10:03AM (#37765337)
There's no agreed upon definition of "strong" vs "weak" so you'll have to elaborate a bit.
Re:Strong typing, a hill I'm willing to die on by randomdata on Wednesday October 04, 2023 @10:04AM (#37765370)
The only other use I'm familiar with where strong types are used to describe the equivalent of static types, but we've made clear distinction between the two here. What other definition is there?

Usually: A strong type system does not allow types to change after being established. A weak type system allows types to change. This is also described in the original article.

Re:Strong typing, a hill I'm willing to die on by 1-more on Wednesday October 04, 2023 @10:43AM (#37765913)
How is that different from static typing?
Re:Strong typing, a hill I'm willing to die on by AnimalMuppet on Wednesday October 04, 2023 @11:03AM (#37766211)
C++ has casts. I don't regard those as making it a "weak" type system. I regard it as "strong type system with escape hatches", which is not the same thing. A strong type system should not be a straightjacket. (Languages that try to make types bulletproof tend to get used less than languages that allow escape hatches, and rightly so. The language designer never knows what the union of all use cases will be. Good language designers know that the user may have a case the designer didn't think of, and allow some flexibility to hopefully handle it.)
Re:Strong typing, a hill I'm willing to die on by zabzonk on Wednesday October 04, 2023 @11:04AM (#37766220)
>A strong type system does not allow types to change

so... like in c++?

Re:Strong typing, a hill I'm willing to die on by neverartful on Wednesday October 04, 2023 @01:30PM (#37768652)
No. C++ does allow types to change. That's exactly what casts are for.
Re:Strong typing, a hill I'm willing to die on by zabzonk on Wednesday October 04, 2023 @02:23PM (#37769453)
no. c++ allows you to convert a value of one type into a value of another type (in a very limited number of cases) but you cannot change the type of an object.
Re:Strong typing, a hill I'm willing to die on by gpderetta on Wednesday October 04, 2023 @11:10AM (#37766315)
You can't change the type of an object in C++ so I'm not sure how your definition applies.

Generally "strong" vs "weak" typing[1] is an ill-defined an mostly useless definition.

[1] as opposed to static vs dynamic or safe vs unsafe.

Re:Strong typing, a hill I'm willing to die on by syndicatedjelly on Wednesday October 04, 2023 @11:46AM (#37766881)
Re:Strong typing, a hill I'm willing to die on by gpderetta on Wednesday October 04, 2023 @12:01PM (#37767137)
Casts don't change the type of an object. They might create a new object of another type from the first one.

edit: I guess what you want to say is that implicit casts make a type system weak. But even there there is plenty of wiggle room: I think that everybody agree that implicitly converting the string "1" to an integer is bad (which is not allowed in C++). Narrowing conversions are arguably bad (they are sometimes allowed in C++), but some other implicit conversions are hard to argue against (int to long for example, or derived to base).

Re:Strong typing, a hill I'm willing to die on by nyssos on Wednesday October 04, 2023 @12:59PM (#37768124)
> A strong type system does not allow types to change after being established. A weak type system allows types to change.

For dynamic types, sure, that's a reasonable enough definition. But it doesn't really make sense for static types: they're attached to expressions in your source code, not runtime values.

Re:Strong typing, a hill I'm willing to die on by SkyMarshal on Wednesday October 04, 2023 @01:35PM (#37768738)
My personal notion of a strong type system is one built around function type signatures.

In order to have that, you need static typing of variables and constants, like most statically typed imperative languages have. But you also need a method to specify required input types and expected output types of all functions.

In a purely functional language like Haskell where there are only functions, and functions are first class and can be both inputs to or outputs from other functions, then the entire operation of the program is encapsulated in its function type signatures.

The entire flow of data and logic through the program can be type-checked by the compiler, and function implementations checked against their type signatures.

Re:Strong typing, a hill I'm willing to die on by pavlov on Wednesday October 04, 2023 @10:03AM (#37765350)
C++ lacks strong typing? I'm curious what the type system is missing to qualify.

Or do you mean that the C-based escape hatches like casting pointers make the type system inherently weak? You don't have to use them though...

Re:Strong typing, a hill I'm willing to die on by robertlagrant on Wednesday October 04, 2023 @10:29AM (#37765737)
You don't have to make type errors either :-)
Re:Strong typing, a hill I'm willing to die on by AnimalMuppet on Wednesday October 04, 2023 @11:06AM (#37766265)
Sure. But you have to deliberately use a cast; people rarely make deliberate type errors.
Re:Strong typing, a hill I'm willing to die on by JonChesterfield on Wednesday October 04, 2023 @11:18AM (#37766437)
C++ has chosen a special place in the hellscape of language design by allowing you to silence the compiler using casts, where almost anything you do with the resulting object is undefined behaviour no diagnostic required.

Said UB is observationally indistinguishable from miscompilation under some toolchains under some optimisation controls.

It also has various bolt on weirdness like const doesn't mean the thing won't be changed by some other pointer so you can't constant propagate based on it, unless it's written on the global, at which point attempts to mutate it anyway may succeed under the usual UB challenges.

Maybe that's a "strong" type system, but you'd only define it like that if you started by taking C++ as axiomatically reasonable.

Re:Strong typing, a hill I'm willing to die on by prewett on Wednesday October 04, 2023 @12:40PM (#37767787)
Static typing is already quite a help, as it makes whole categories of errors compile-time errors.

> I'd like to see Javascript die in the fiery pits of hell as much as the next guy

Part of the problem is that some of those "next guys" don't have the experience and/or vision to realize that it needs to die. Perhaps we should emulate Cato in our subsequent HN posts:

And furthermore, I consider it necessary that Javascript be replaced with WebAssembly so that we can use well-designed languages in the browser.

Re:Strong typing, a hill I'm willing to die on by user3939382 on Wednesday October 04, 2023 @09:49AM (#37765151)
There's a specific scenario where I have more sympathy for weak typing, which is: I'm writing a small, focused utility by myself whose scope can never expand and whose code will never be collaborated on. I do have these, little shell scripts. I write them, they work, I move on and use it for 10 years. No types in there, fine whatever.

As soon as there's any complexity at all or another person involved that exception stops.

Re:Strong typing, a hill I'm willing to die on by racked on Wednesday October 04, 2023 @10:18AM (#37765569)
Indeed this. There are benefits. Less code, faster to write.
Re:Strong typing, a hill I'm willing to die on by AnimalMuppet on Wednesday October 04, 2023 @10:57AM (#37766110)
You are the other person. Come back in six months needing to make a change, and it's almost like you're new to the code.

Now, in general, I agree with you. If it's a one-off (or if it's really never going to need maintenance), and if it's small enough that you don't need types while writing it, then sure, do whatever is easiest at the time. But "never going to need maintenance" often turns out to be a lie, and when that time comes, you may be happy for some types as signposts to give a hint of what you were thinking all those months or years ago.

Re:Strong typing, a hill I'm willing to die on by BobbyJo on Wednesday October 04, 2023 @11:07AM (#37766269)
This is the trojan horse dynamic types use to get into your castle :P
Re:Strong typing, a hill I'm willing to die on by SAI_Peregrinus on Wednesday October 04, 2023 @11:19AM (#37766457)
I want a shell scripting language that allows a max line length of (for example) 128 characters and a max script length of (for example) 128 lines, with no `source` equivalent. If the script expands to not be a "small, focused" single-file script it should just fail to run at all. Just enough for small utilities, but unusable for giant monstrosities.
Re:Strong typing, a hill I'm willing to die on by KMag on Wednesday October 04, 2023 @12:07PM (#37767211)
... and unable to call external programs or communicate with external programs via pipes / sockets / etc.?

Otherwise, if you're unable to source another script, you could just have another script return a normal result in addition to a JSON blob of the environment variable changes the caller should make, which is probably worse than just allowing sourcing.

Pipes allow arbitrarily complex networks of communicating sequential processes. In some cases, networks of tiny CSPs are cleaner, but without discipline, they can rapidly become worse than huge monoliths.

Re:Strong typing, a hill I'm willing to die on by SAI_Peregrinus on Friday October 06, 2023 @09:54AM (#37790833)
I suppose I should just say "any sourced file counts against the length limits".
Re:Strong typing, a hill I'm willing to die on by KMag on Friday October 06, 2023 @11:20AM (#37791971)
That doesn't prevent the problem of length limits encouraging users to break their programs into networks of smaller programs communicating over pipes. I'm sure that sort of thing can be done well, but it certainly takes discipline.

Particularly as programs start out simple and organically grow, once they start hitting length limits, they're going to start evolving into locally-distributed computation. Maybe you get something nice like composable small unix-like utilities. However, I suspect there's a large overlap between the set of developers who would do that well and the set of developers who would still keep things nice and modular within a single process if they didn't have size limits.

Re:Strong typing, a hill I'm willing to die on by KMag on Wednesday October 04, 2023 @12:00PM (#37767105)
Note that weak typing and dynamic typing are orthogonal. I believe you're expressing sympathy for strong dynamic typing: types are checked an enforced by the runtime, but there's no static type analysis done at compile / load time. Python, JS, Ruby, etc. are strong dynamically typed languages.

The C runtime, on the other hand, will gladly (with UB nasal demon caveats) allow you to treat an int as a pointer. There are static type checks, but no hard limits on the type-confused nonsense it will attempt to execute. C is weakly statically typed.

Java, C#, etc. are strong statically typed. There are static checks at compile time, and the runtimes do their best (modulo escape hatches) to use dynamic runtime type checks to plug the gaps in the static type systems. (For any sufficiently complex sound/consistent type system, as per Godel, there will be some type-correct programs that cannot statically type-check. So, in practice, there will always be escape hatches in the type system. Hopefully most of these escape hatches are backed by dynamic runtime checks.)

Of course, these categories are a partially-ordered continuum, not clear binary distinctions. Also, type weakness is more a property of the runtime than the language, but for those languages with specifications, the language specification usually also specifies a large amount of behavior for a compliant runtime.

Re:Strong typing, a hill I'm willing to die on by user3939382 on Wednesday October 04, 2023 @03:47PM (#37770635)
I’m aware of the difference, I was contemplating bash in my comment. Some people construe it as strongly typed though it’s a little ambiguous, here’s another discussion about it https://news.ycombinator.com/item?id=12704050
Re:Strong typing, a hill I'm willing to die on by packetlost on Wednesday October 04, 2023 @09:54AM (#37765218)
I'm also a pretty die-hard type-system user, but I've been programming a lot of Lisp and FORTH lately. FORTH is just bad at safety period. Lisp, on the other hand, I can see why there really isn't a need for types. The macro system means you can create arbitrary "compile-time" safety checks which is, IMO, more powerful than just a type system. That being said, I would still love a strongly, statically typed Lisp, or at least one with a strong macro type system (before y'all mention it, I'm not a fan of typed Racket).
Re:Strong typing, a hill I'm willing to die on by qazwse_ on Wednesday October 04, 2023 @10:03AM (#37765354)
I haven't used it, but I know that Coalton adds static typing to Common Lisp, might be something you're interested in.

https://github.com/coalton-lang/coalton

Re:Strong typing, a hill I'm willing to die on by packetlost on Wednesday October 04, 2023 @10:21AM (#37765631)
I'm more into Scheme than CL, but am aware of Coalton. My current lisp is Gerbil: https://cons.io which already has a type annotation system and will be enhancing it for the next major release (v19).
Re:Strong typing, a hill I'm willing to die on by Zambyte on Wednesday October 04, 2023 @10:04AM (#37765362)
> Lisp, on the other hand, I can see why there really isn't a need for types.

What Lisp are you using that doesn't have types?

Re:Strong typing, a hill I'm willing to die on by packetlost on Wednesday October 04, 2023 @10:20AM (#37765615)
Well, every programming language must necessarily have types to some degree, but they aren't necessarily static or strong type systems. Most Lisps do not have a static type system and even fewer have a "strong" type system.
Re:Strong typing, a hill I'm willing to die on by Zambyte on Wednesday October 04, 2023 @10:36AM (#37765819)
> Well, every programming language must necessarily have types to some degree

The vast majority yes, that's why I was a bit confused :D

There some languages that have no types. The only thing I can think of though is a POSIX shell minus arrays.

> Most Lisps do not have a static type system

True

> and even fewer have a "strong" type system.

Common Lisp, Emacs Lisp, Scheme, Hylang, Clojure, and Racket all feature strong typing. I'm curious where you have found this trove of weakly typed Lisp dialects

Re:Strong typing, a hill I'm willing to die on by packetlost on Wednesday October 04, 2023 @11:03AM (#37766216)
Lisps are not statically typed typically and "strongly" typed is poorly defined. I would not consider most Lisp's type systems to be strong or particularly expressive, but they don't need to be because it would hurt the main benefit to the language: meta-programming. I don't think a "strong" vs "weak" type system argument is particularly valuable here, yes most prevent you from inadvertently changing how a particular series of bytes is interpreted, but their aggregates do not have any type identity besides their own typically. This means you cannot typically express and enforce an aggregate's covariance or contravariance properties. There may be ways to do so, but most do not provide utilities for it.
Re:Strong typing, a hill I'm willing to die on by gpderetta on Wednesday October 04, 2023 @11:14AM (#37766372)
Why dynamic typing is required for metaprogramming? D (and rust and c++ to a significantly lesser extent) for example has extremely strong metaprogramming capabilities while being statically typed.
Re:Strong typing, a hill I'm willing to die on by packetlost on Wednesday October 04, 2023 @11:21AM (#37766474)
I didn't say it was required, I said it hurts it in Lisps case. One of Lisps strongest features is extreme flexibility and homoiconicity. Strict typing would make it clunkier, though maybe it's worth it for some scenarios.
Re:Strong typing, a hill I'm willing to die on by Zambyte on Wednesday October 04, 2023 @01:25PM (#37768561)
> I don't think a "strong" vs "weak" type system argument is particularly valuable here, yes most prevent you from inadvertently changing how a particular series of bytes is interpreted [...]

I think that interpretation of the "strong" vs "weak" scale is a valuable one within the context of the blog post. The post is at least partially about how type systems can help the programmer by making them aware of certain kinds of errors (it is also about when: static vs dynamic).

My understanding of the terms covariance and contravariance are a bit shaky. Could you provide an example in another language that you think cannot be expressed using the provided utilities of most Lisp's?

You also mentioned that you don't think most Lisp's have "expressive" type systems. What do you mean by that? When I think of a type system as being expressive, I think of it as having explicit rather than implicit types, which is unrelated to the issue of strongly vs weakly typed and static vs dynamic types. Do you mean more like how you can describe / constrain the relationships between types in certain strongly typed languages?

Re:Strong typing, a hill I'm willing to die on by packetlost on Wednesday October 04, 2023 @01:53PM (#37769027)
> I think that interpretation of the "strong" vs "weak" scale is a valuable one within the context of the blog post. The post is at least partially about how type systems can help the programmer by making them aware of certain kinds of errors (it is also about when: static vs dynamic).

Sure, agree. That's also the real point: type systems primarily exist to make semantically impossible computations unrepresentable in the language (at least, without some extra song and dance). To this end, Lisps have rather lackluster type systems, but they don't try to encode much of the languages semantics into a type system.

> My understanding of the terms covariance and contravariance are a bit shaky. Could you provide an example in another language that you think cannot be expressed using the provided utilities of most Lisp's?

The wikipedia article on the topic is a great source: https://en.wikipedia.org/wiki/Covariance_and_contravariance_...

I'm actually mostly concerned with type invariants (ex. List[int]), which don't really have much for representation in Lisps from what I've seen. Further, see above about using types to make compile-time assertions/checks about the behavior at runtime.

> You also mentioned that you don't think most Lisp's have "expressive" type systems. What do you mean by that? When I think of a type system as being expressive, I think of it as having explicit rather than implicit types, which is unrelated to the issue of strongly vs weakly typed and static vs dynamic types. Do you mean more like how you can describe / constrain the relationships between types in certain strongly typed languages?

"Expressive" is a nothing word that doesn't have concrete meaning in-context, similar to "strong" type system. That being said, I would say Rust, OCaml, and TypeScript have expressive type systems: the behavior of the language is largely encoded as types. The implicit vs explicit nature of types is not super consequential IMO, it has more to do with how you primarily represent semantic meaning. In lisp, it's symbols. In Rust, it's traits, enums, and structs (+ the affine types, but that's not relevant here).

Re:Strong typing, a hill I'm willing to die on by kazinator on Monday October 09, 2023 @02:05AM (#37817359)
In Lisps, and other dynamic languages, two or more objects that are not related by inheritance can be substitutable. This is very useful.

That makes inheritance-based covariance and contravariance largely moot.

You have substitutability-based covariance and contravariance (you can't get away from those) but they cannot be subdued declaratively.

E.g. if you're passing a callback function somewhere, which you know will pass widget objects to the callback, it's okay to use a function that was written to handle gadget objects, if widget objects are designed to substitute for gadget objects.

That's contravariance of substitutability.

Substitutability is the only thing that matters in the end. Declared inheritance doesn't ipso facto guarantee substitutability, and therefore declared covariance or contravariance, which are inheritance based, do not guarantee actual substitutability-based covariance or contravariance.

Re:Strong typing, a hill I'm willing to die on by gpderetta on Wednesday October 04, 2023 @11:12AM (#37766349)
wait, are you saying that any sufficiently complicated lisp program contains an ad hoc, informally-specified, bug-ridden, slow implementation of a static type system?
Re:Strong typing, a hill I'm willing to die on by packetlost on Wednesday October 04, 2023 @10:06PM (#37774136)
No. I'm saying you can build almost whatever static analysis tools you want right into the compiler
Re:Strong typing, a hill I'm willing to die on by PrimeMcFly on Wednesday October 04, 2023 @09:56AM (#37765240)
In my experience whenever you put effort into making a post like this, outlining the common arguments you hear and your attempt at refuting them, people don't really pay attention and will just repeat the arguments you already addressed, ignoring your refutations.
Re:Strong typing, a hill I'm willing to die on by stratigos on Wednesday October 04, 2023 @10:17AM (#37765550)
Youre missing the perspective of a business owner and operator that has to hire many people with diverse patterns of thoughts and beliefs who will most likely work for their organization for less than 24 months.
Re:Strong typing, a hill I'm willing to die on by AlanYx on Wednesday October 04, 2023 @10:26AM (#37765703)
If you have a considerable amount of staff turnover, strong typing is a godsend for a large codebase.

Having an order of magnitude more unit tests is another option, but that undermines the alleged "less code" benefit of weak typing.

Re:Strong typing, a hill I'm willing to die on by 1-more on Wednesday October 04, 2023 @10:42AM (#37765896)
What does "strong" mean as regards typing. I've heard a few different definitions so I'm curious what yours is in the context of this article.
Re:Strong typing, a hill I'm willing to die on by bigstrat2003 on Wednesday October 04, 2023 @10:59AM (#37766148)
As far as I'm aware, the generally accepted definition of strong typing is: some object in memory has a type, and the compiler (or interpreter) will not let you treat it as another type without some kind of explicit instruction to do so. This is in contrast to weak typing, where the compiler/interpreter will happily try to treat a Bar object as a Foo object if you do some Foo operation on it.
Re:Strong typing, a hill I'm willing to die on by gpderetta on Wednesday October 04, 2023 @12:21PM (#37767430)
That's the definition of type-safety (or memory safety that is pretty much equivalent). "strong typing" has no generally accepted definition.
Re:Strong typing, a hill I'm willing to die on by bigstrat2003 on Wednesday October 04, 2023 @06:51PM (#37772828)
Memory safety is definitely not equivalent. Memory safety is more like not going past the end of an array, not doing use after free, etc. I agree that what I said is pretty much also the definition of type safety. But in my experience it is also the generally accepted definition of strong typing.
Re:Strong typing, a hill I'm willing to die on by 1-more on Wednesday October 04, 2023 @04:21PM (#37771142)
That seems to be a subset of static typing. Is there an example of this that does not involve non-static typing?
Re:Strong typing, a hill I'm willing to die on by bigstrat2003 on Wednesday October 04, 2023 @08:03PM (#37773343)
I think you mean "involves non-static typing"? If so, Python. You can't (for example) do something like '1 + "2"', because those types aren't compatible. It's dynamically, but strongly, typed.
Re:Strong typing, a hill I'm willing to die on by ndr on Wednesday October 04, 2023 @11:13AM (#37766371)
Consider reading/watching Rich Hickey's talk Effective Programs [0][1] and Maybe Not [2][3]

In [0] in particular there're slides 22/23, here is part of the transcript but makes more sense with the slides on:

> And you can call them problems, and I'm going to call them the problems of programming. And I've ordered them here [...] I've ordered them here in terms of severity. And severity manifests itself in a couple of ways. Most important, cost. What's the cost of getting this wrong? At the very top you have the domain complexity, about which you could do nothing. This is just the world. It's as complex as it is. > > But the very next level is the where we start programming, right? We look at the world and say, "I've got an idea about how this is and how it's supposed to be and how, you know, my program can be effective about addressing it". And the problem is, if you don't have a good idea about how the world is, or you can't map that well to a solution, everything downstream from that is going to fail. There's no surviving this misconception problem. And the cost of dealing with misconceptions is incredibly high. > >So this is 10x, a full order of magnitude reduction in (?) severity before we get to the set of problems I think are more in the domain of what programming languages can help with, right? And because you can read these they'll all going to come up in a second as I go through each one on some slide so I'm not going to read them all out right now. But importantly there's another break where we get to trivialisms of problems in programming. Like typos and just being inconsistent, like, you thought you're going to have a list of strings and you put a number in there. That happens, you know, people make those kinds of mistakes, they're pretty inexpensive.

[0] Video: https://www.youtube.com/watch?v=2V1FtfBDsLU

[1] Slides and transcript: https://github.com/matthiasn/talk-transcripts/blob/master/Hi...

[2] Video https://www.youtube.com/watch?v=YR5WdGrpoug

[3] Slides and transcript https://github.com/matthiasn/talk-transcripts/blob/master/Hi...

Re:Strong typing, a hill I'm willing to die on by sumtechguy on Wednesday October 04, 2023 @02:09PM (#37769256)
Weak typing has its uses in one use case. Transition between systems. Even then you usually want to know what the type is (unless you really do not care about validation errors).

The reality is I never get to choose. I prefer strong typing. But the projects I am on that ship sailed long ago 2 developers back who used this project as a resume builder.

Re:Strong typing, a hill I'm willing to die on by bitblender on Wednesday October 04, 2023 @09:37AM (#37764977)
I don't consider it productive to be personal about technical topics. It's best to divorce yourself and the other party from the issue to limit as much bias as possible. You don't need to worry about the good-faithness of an objective, egalitarian discussion. It's never truly objective, but you can at least catch yourself saying things like "I might think less of you as a developer" and recognize that's a preconceived notion. In some cases, it may be turn out to be accurate, but it's definitely not always. Dynamically typed languages have had an important role historically in software. We should not categorically denounce people who prefer it as lesser developers. I also generally prefer static types.
Re:Strong typing, a hill I'm willing to die on by insanitybit on Wednesday October 04, 2023 @09:39AM (#37765014)
I explicitly said "as a developer" because it's not a personal judgment. You can be a good person and also have a terrible take as a software engineer.

> We should not categorically denounce people who prefer it as lesser developers

I don't think you've justified this point. I'm comfortable with my position on this.

Re:Strong typing, a hill I'm willing to die on by eduction on Wednesday October 04, 2023 @11:13AM (#37766364)
What you say is true, but it’s also true that the person you are replying specifically made their remarks about productivity - you’re both talking about what is best at work.

It seems reasonable to argue that statements that you won’t even discuss X any more and would rather judge the person as less competent professionally are unproductive. Not saying I agree, btw. But it does seem like a pretty basic point. One of you is talking about preserving your sanity and the other about output. It’s not necessarily a disagreement even.

Re:Strong typing, a hill I'm willing to die on by PH95VuimJjqBqy on Wednesday October 04, 2023 @12:54PM (#37768043)
> any more and would rather judge the person as less competent professionally

That is absolutely NOT what the other poster said. They said they _MAY_ judge them that way.

Re:Strong typing, a hill I'm willing to die on by eduction on Wednesday October 04, 2023 @04:04PM (#37770885)
Fair point, you're right!

I still think it's reasonable to argue that's not a "productive" approach, but like I said, that's not my own opinion, I just think it's a reasonable argument.

Re:Strong typing, a hill I'm willing to die on by PH95VuimJjqBqy on Wednesday October 04, 2023 @12:53PM (#37768031)
to add, I agree with you mostly.

I don't necessarily think it makes someone a "lesser developer" if they prefer untyped languages, but I DO think they've either had to maintain anything long term or it stayed relatively small.

Whether that makes them lesser or not isn't really for me to say, but I can say I'm definitely on board with the idea that types increase productivity the longer a system is maintained. Unless used poorly, types don't automatically mean you use them well, but they make it a hell of a lot easier to do the right thing.

Re:Strong typing, a hill I'm willing to die on by bitblender on Wednesday October 04, 2023 @03:05PM (#37770034)
Again, I don't mean "personal" in the sense that you are making a statement about someone's worth as a person. It's "personal" because you extrapolate information about an individual person's technical skills from a single opinion than you have any real factual justification to do so. People will always find ways to defy your preconceived notions.
Re:Strong typing, a hill I'm willing to die on by loup-vaillant on Wednesday October 04, 2023 @09:45AM (#37765093)
Some prejudices are rational. To paraphrase, it would take an enormous amount of prior trust and respect before I even humour someone trying me to convince me the sky is green with a straight face.

Some issues are settled enough that there is no need to discus them any further. It is okay to automatically mark people on the wrong side of such issues… let’s say ill-informed.

Static typing, I believe, is close to being one of those issues.

Re:Strong typing, a hill I'm willing to die on by kdmccormick on Wednesday October 04, 2023 @10:18AM (#37765583)
I think this is OK as long as you keep your mind open to situations that you have not considered.

Imagine someone is working in a relatively niche new programming language ecosystem which is dynamically typed, allowing the language to have some richness that modern type systems don't support. I don't have an example because I don't know of any such language in 2023... BUT back in the 70s and 80s this would have been Lisp. Lisp couldn't have been strictly typed back then because, AFAICT, type systems hadn't advanced enough to express the sort of metaprogramming that made Lisp unique and awesome. This was at a time when most popular languages were strictly typed.

I would hope that you would keep your mind open to whatever that maps to in the 2020s.

Now, if someone says "I like JS over TS because types are annoying and slow me down", then yeah, I don't have much patience for that either.

Re:Strong typing, a hill I'm willing to die on by digging on Wednesday October 04, 2023 @11:34AM (#37766686)
You make points that seem great to me although I know almost nothing about Lisp or 20th century programming.

The thing is, I've yet to encounter a single instance of such an argument today. Every single time it ends up being "I like JS over TS because types are annoying and slow me down". It hadn't even occurred to me that laziness and sloppiness weren't the the only reasons to write in dynamically typed language.

I suppose what I'm saying is I'm quite interested in seeing what kind of evolution some dynamically typed language could offer in the future. Although with no signs of its coming, I'm going to stick to TS because it's objectively better for anything but very small projects.

Re:Strong typing, a hill I'm willing to die on by hansvm on Wednesday October 04, 2023 @02:39PM (#37769670)
TS is an interesting example to pick when trying to argue that types are better. You have all the same downsides people pick on when arguing against strong, static typing, but since the type system isn't sound you still can't rely on the input to a function being the type you expect (and the problem is worse anywhere you inevitably interact at least a little with the JS world outside your TS bubble).

At best it's a form of documentation that enables some simple linting rules and a bit of jump-to-definition magic. Like, that's a benefit (mostly -- I tend to think that type signatures implying more guarantees than they provide is a recipe for inadvertently relying on falsehoods), but it's not as clear-cut of a win as you see in other statics/dynamic tradeoffs.

Re:Strong typing, a hill I'm willing to die on by lelanthran on Thursday October 05, 2023 @01:52AM (#37775301)
> The thing is, I've yet to encounter a single instance of such an argument today.

I don't mean to be unnecessarily contentious, but isn't that the point of undiscovered territory?

We haven't encountered it yet, when we do then as awareness grows that pattern, idiom, theorem or concept will be picked up by mainstream statically typed languages.

It's enough to believe that the properties of (for example) JavaScript might lead to an as yet undiscovered pattern that is not possible in current statically typed languages.

Unlikely, but still possible.

Re:Strong typing, a hill I'm willing to die on by digging on Thursday October 05, 2023 @10:45AM (#37779248)
Yes sure, it's always possible. My narrow experience leads me to believe, however, that some necessary threshold hasn't been crossed yet. And there's vanishingly little chance that I personally will be participating in such a revolution. Therefore from my perspective, it isn't happening yet and I can only wait to see if it does - meanwhile, I'm on the opposite side.
Re:Strong typing, a hill I'm willing to die on by monocasa on Wednesday October 04, 2023 @01:42PM (#37768846)
Python fits that niche now. Half the way tensorflow, et al work is by doing brain surgery on the AST in a way that resembles hey day Lisp's 'even the code is just s-expressions, process it as much as you want to the point of 80/20ing your way to your own compiler'.
Re:Strong typing, a hill I'm willing to die on by mikelevins on Wednesday October 04, 2023 @01:44PM (#37768887)
Imagine working on a networked system that uses types to make it impossible to express operations that violate data security and integrity constraints, and where such constraints control whether data is allowed to be read or written from or to a given endpoint. Imagine further that the types governing permission to read or write depend on environmental state that can change at any time--for example, as soon as a specific person changes roles, the set of ports they are allowed to read and write changes.

The type system enforces those permissions: writing to an impermissible destination is a type error. The types applicable to an entity are not necessarily knowable at compile time; some of them might change at any time.

I had a job working on such a system. It supported a type system implemented in Haskell with both static and dynamic type disciplines, where values were tagged with base types designed to be checked dynamically in hardware.

Was the programming language dynamically typed? Yes. Was the programming language statically typed? Yes.

Re:Strong typing, a hill I'm willing to die on by uoaei on Wednesday October 04, 2023 @02:14PM (#37769337)
It sounds like you have an implicit prejudice against those who do not "keep [their] mind open to situations that [they] have not considered", since the way you phrased your concern is moral in nature. You see it as morally bad not to have an open mind in that way.
Re:Strong typing, a hill I'm willing to die on by mvdtnz on Wednesday October 04, 2023 @02:18PM (#37769392)
As Carl Sagan said: it's good to have an open mind, but not so open your brains fall out.
Re:Strong typing, a hill I'm willing to die on by kdmccormick on Wednesday October 04, 2023 @02:21PM (#37769428)
Yeah, sure, I do in fact think it is virtuous to be aware that we don't always have complete information and that we should be willing to revise our opinions when new information is encountered. Is that controversial?
Re:Strong typing, a hill I'm willing to die on by uoaei on Wednesday October 04, 2023 @04:49PM (#37771564)
No, no, not controversial. I intended to make it easier to understand the point by demonstrating for the more literal-minded that using moral language sets up two halves of a dichotomy, one preferred to the other, so that such prejudices needn't be personal but rather merely moral. The difference is of course that which side of a moral dichotomy is a choice that can be reversed (e.g. making an effort to open the mind) while personal matters are immutable in those people.
Re:Strong typing, a hill I'm willing to die on by jimbokun on Wednesday October 04, 2023 @11:02AM (#37766198)
If your prejudice prevents you from having a conversation with Matz or Jose Valim or Van Rossom or the creators of Julia about software development, you may want to reconsider your prejudice as a hard and fast rule.

You can't honestly believe no one who likes to develop in a dynamically typed language has nothing interesting to say about software development?

Re:Strong typing, a hill I'm willing to die on by insanitybit on Wednesday October 04, 2023 @11:12AM (#37766344)
If I have pre-existing respect for someone I will hear them about. But the bar for that conversation is high.
Re:Strong typing, a hill I'm willing to die on by betenoire on Wednesday October 04, 2023 @11:27AM (#37766572)
I'm not sure what is worse, loving dynamic languages or having all these pre-existing conditions
Re:Strong typing, a hill I'm willing to die on by insanitybit on Wednesday October 04, 2023 @11:51AM (#37766965)
Doesn't everyone have those? Like, I'm unlikely to really engage with someone about my health unless they're a doctor or otherwise have some area of expertise. Or if it's just a casual, friendly conversation, to kill some time.
Re:Strong typing, a hill I'm willing to die on by betenoire on Wednesday October 04, 2023 @11:55AM (#37767029)
Everyone has biases. But you aren't describing a bias, you are describing a refusal to engage with people below you. Speak for yourself, I don't have that.
Re:Strong typing, a hill I'm willing to die on by sixstringtheory on Wednesday October 04, 2023 @12:12PM (#37767284)
We’re all humans and life is very complicated with many facets. If we all looked hard enough I’m sure we could find a person you’d refuse to engage in a debate with over their “thing.”

But that wouldn’t be a wise use of time in my opinion. And that’s what they’re ultimately driving at: we all have limited time to expend, so do it in things that matter to you. I believe “matters to you” is a bias.

Re:Strong typing, a hill I'm willing to die on by insanitybit on Wednesday October 04, 2023 @01:50PM (#37768972)
"Below you" is a bit of an exaggeration, I think. I said that I might think less of someone as a software engineer if they express an opinion that I think is particularly bad. Hardly egregious, in my opinion. I also might not - it frankly depends a lot on the situation.
Re:Strong typing, a hill I'm willing to die on by wredue on Wednesday October 04, 2023 @12:09PM (#37767240)
These people opinions are based on bad information.

Beliefs inform decisions and other beliefs

I disagree with them on a huge number of fundamental things in software. Most of their fundaments are claims with no evidence. Due to that, I simply do not care about what they have to say most of the time.

Re:Strong typing, a hill I'm willing to die on by mcronce on Wednesday October 04, 2023 @12:21PM (#37767434)
I can't (or, more accurately, don't) believe that, but I can certainly believe they have nothing interesting to say about the topic of static vs dynamic typing.
Re:Strong typing, a hill I'm willing to die on by _a_a_a_ on Wednesday October 04, 2023 @01:57PM (#37769093)
I'm very much with you on static typing but you've closed your mind with a slam. Please don't.
Re:Strong typing, a hill I'm willing to die on by lovich on Wednesday October 04, 2023 @02:15PM (#37769343)
An open mind is like a fortress with its gates unbarred and unguarded.

It is both useful and allowed to have a certain level of belief that won’t be crossed without heavy effort. The OP didn’t even say they were closed to the conversation completely, but that a random person with no pre built trust isn’t going to get the time of day from them to rehash the same settled argument.

Re:Strong typing, a hill I'm willing to die on by _a_a_a_ on Wednesday October 04, 2023 @02:24PM (#37769465)
"Matz or Jose Valim or Van Rossom or the creators of Julia"

from memory Matz -> ruby, Valim-> elixir, Van Rossum -> python, and 'the creators of Julia' -> julia

Not 'random persons' then

Re:Strong typing, a hill I'm willing to die on by lovich on Wednesday October 04, 2023 @07:37PM (#37773159)
Yea, the OP was referencing randos from his perspective and the responder subbed in famous software developers. They weren’t arguing on the same point
Re:Strong typing, a hill I'm willing to die on by scns on Wednesday October 04, 2023 @01:59PM (#37769117)
Python got type hints bolted on. A type system for Elixir is being worked on. Dynamic typing was a prerequisite for Erlang to enable hot-code-reloading. Julia is can be typed for an extra speedup. Stripe built a type checker for Ruby called Sorbet.
Re:Strong typing, a hill I'm willing to die on by adgjlsfhk1 on Wednesday October 04, 2023 @02:25PM (#37769478)
Julia generates fast code without type annotations (except for your data types).
Re:Strong typing, a hill I'm willing to die on by sundarurfriend on Wednesday October 04, 2023 @03:12PM (#37770120)
> (except for your data types)

This confused me for a moment, but I think you mean annotating the types of the fields in your `struct`s, right?

An addition to that: any non-constant global variables (if you must have those) should also be type annotated.

Re:Strong typing, a hill I'm willing to die on by _dain_ on Wednesday October 04, 2023 @02:03PM (#37769169)
idk about the others but much of Guido's development energies the past few years have been spent building Python's gradual static typing system.
Re:Strong typing, a hill I'm willing to die on by yetanotherloser on Wednesday October 04, 2023 @02:10PM (#37769270)
To be honest, I think dynamic typing must contain a mind trap. Very smart people fall in.
Re:Strong typing, a hill I'm willing to die on by SAI_Peregrinus on Wednesday October 04, 2023 @11:07AM (#37766280)
I'd love a dynamically typed scripting language with the following two properties: no "import" mechanism to split code over multiple files, and no way to execute more than (say) 256 lines of at most 128 bytes each in the file.

Dynamic types are nice for quick & short scripts, and actively detrimental for anything long and complex. Why not enforce that? As soon as it gets so long it doesn't run you know it's time to rewrite in a statically typed language. Instead all existing scripting languages allow unlimited growth in code size, making it easy for programs to grow beyond the point where the language is useful.

Re:Strong typing, a hill I'm willing to die on by gls2ro on Wednesday October 04, 2023 @12:57PM (#37768091)
> Dynamic types are nice for quick & short scripts

A long list of big products and companies are there to disagree with this. I am not saying that dynamic is better or worse. But saying that dynamic languages are only good for quick short scripts is a wrong generalization that has not one exception but many exceptions.

Re:Strong typing, a hill I'm willing to die on by soperj on Wednesday October 04, 2023 @11:15AM (#37766389)
> To paraphrase, it would take an enormous amount of prior trust and respect before I even humour someone trying me to convince me the sky is green with a straight face.

But people regularly say the sky is blue, and it's clear as day that it's not when the earth has turned and your side isn't facing the sun.

Re:Strong typing, a hill I'm willing to die on by bluGill on Wednesday October 04, 2023 @11:28AM (#37766587)
The sky is still blue, the lack of light means you cannot tell, but the color is still there.
Re:Strong typing, a hill I'm willing to die on by soperj on Wednesday October 04, 2023 @11:41AM (#37766792)
no... the sky is clear, and it's the refraction of light through the atmosphere that's confusing you.
Re:Strong typing, a hill I'm willing to die on by bluGill on Wednesday October 04, 2023 @12:35PM (#37767679)
As someone who would die without an atmosphere the distinction is meaningless.
Re:Strong typing, a hill I'm willing to die on by soperj on Wednesday October 04, 2023 @01:52PM (#37769019)
you're going to die regardless. The sky still isn't blue, which is quite obvious at night, or during sunsets and sunrise.
Re:Strong typing, a hill I'm willing to die on by digging on Wednesday October 04, 2023 @11:48AM (#37766903)
I don't think that's a statement that most would agree with. What is the sky? Sure the atmosphere can be called blue, but the sky is what's visually above the earth. At night, that's black space. The atmosphere is mostly transparent at night.
Re:Strong typing, a hill I'm willing to die on by stouset on Wednesday October 04, 2023 @12:25PM (#37767513)
The sky isn’t inherently blue. It’s essentially colorless.

Only due to Rayleigh scattering do we perceive it as blue, but that’s not due to the absorption and reflection of different wavelengths we associate with innate color. Note that the color changes depending on the angle of the sun, even to the point that it’s purple and red at a few times during the day.

Re:Strong typing, a hill I'm willing to die on by quonn on Wednesday October 04, 2023 @05:20PM (#37771969)
Perhaps, only because the sky is blue we perceive blue as blue. If the sky were red we would perhaps perceive all red like we do blue.

Our perception of the important colors (sky blue, ocean blue, vegetation green, …) probably evolved along with our physical needs.

Re:Strong typing, a hill I'm willing to die on by klyrs on Wednesday October 04, 2023 @01:16PM (#37768407)
> To paraphrase, it would take an enormous amount of prior trust and respect before I even humour someone trying me to convince me the sky is green with a straight face.

Don't venture into tornado country; your doubt may be your downfall.

Re:Strong typing, a hill I'm willing to die on by ilaksh on Wednesday October 04, 2023 @12:03PM (#37767162)
As someone who usually prefers JavaScript over TypeScript but has used many typed languages over the years and generally finds then easier to work with in a way, I agree that one should not pre-judge based on something like that.

But he's just being honest. Many developers have been making that judgement for many months or even years.

Re:Strong typing, a hill I'm willing to die on by HideousKojima on Wednesday October 04, 2023 @01:17PM (#37768417)
Nah, someone opposed to typing is either a shit developer and/or a madman who codes too clever by half mad shenanigans that take advantage of the lack of strong typing. I wouldn't want to have to maintain or depend on code written by either.

For the very rare cases where a lack of strong typing is needed, most languages with strong typing offer ways to handle that (i.e. the Object and Dynamic types in C#)

Re:Strong typing, a hill I'm willing to die on by mvdtnz on Wednesday October 04, 2023 @02:15PM (#37769357)
I think you're being a bit too sensitive, and it's not personal. Someone is espousing a (bad) technical opinion about their field of work, it's not unreasonable to say you respect them less in their field of work. That's not personal.

It's like if you met a builder who refused to use a hammer and insisted on bashing nails in with the back of their drill. It's not "personal" to say you'd respect that person less as a builder, regardless of how much you'd enjoy having a drink with them.

Re:Strong typing, a hill I'm willing to die on by bitblender on Wednesday October 04, 2023 @02:56PM (#37769921)
It is "personal" if you attach someone's technical opinion to broader implications about their own competence. If you disagree with a technical opinion, say so and move on, there is no reason to even discuss someone's own personal skillset, experience, or value as a developer. It's a silly fallacy to automatically label people who disagree with you as incompetent. All it does is foster bias and stifle actual discussion. The responses to this post are evidence that this is not as cut and dry as the original posts suggests, so I suggest we try our best not to cover our ears and embrace tribalism just because we think less of someone's opinion. I don't think I'm being oversensitive by saying this is unproductive dogmatism. It is my honest opinion, yet I do not extrapolate to mean anything about the proponents' value as a developer. Unconscious bias is a pervasive problem for everyone, especially when it comes to binary holy wars like static vs. dynamic types. This is more akin to a builder who uses a nail gun rather than a hammer. Hammer enthusiasts can either acknowledge that both approaches have tradeoffs or they can petulantly insist that people who don't use their methods aren't "real" builders.
Re:Strong typing, a hill I'm willing to die on by mvdtnz on Wednesday October 04, 2023 @03:42PM (#37770536)
I'm sorry but this is a discussion about their competence. You can't separate someone's opinions on technical topics from their competence in the very technical field you're discussing. If a cartographer has the "opinion" that the world is flat then that directly speaks to their competence as a cartographer.
Re:Strong typing, a hill I'm willing to die on by bitblender on Wednesday October 04, 2023 @05:30PM (#37772078)
For starters, "the world is flat" is falsifiable and trivially disproven with evidence. "Dynamic types are better" is neither of these. If you're going to pin someone's professional value to a single technical opinion, you should at least be able to back it up with data.
Re:Strong typing, a hill I'm willing to die on by halfmatthalfcat on Wednesday October 04, 2023 @09:28AM (#37764813)
I've worked with my fair share of vanilla JS devs who refuse to acknowledge the benefit of more statically typed variants of the language. Most of them bemoan the upfront cost of typing everything without realizing the benefits of it. I absolutely think less of them as developers.
Re:Strong typing, a hill I'm willing to die on by giraffe_lady on Wednesday October 04, 2023 @09:51AM (#37765169)
Not liking typescript is not the same thing as denying that types are valuable.

TS has a very complex type system in exchange for relatively weak guarantees about correctness. That's a tradeoff you can choose to take or leave depending on the problem at hand, and holding that position is not the same as believing types have no value.

Unless you're talking about elm or rescript or something then sure sure. But usually when people say things like this they mean typescript.

Re:Strong typing, a hill I'm willing to die on by smallerfish on Wednesday October 04, 2023 @10:22AM (#37765642)
Typescript's typing system is great and (for me) makes frontend development tolerable. It's annoying that it's optional. tsconfig and the related ecosystem is a disaster.

I still have hopes that Kotlinjs can fix the distribution size and the tooling around binding to js libraries.

Re:Strong typing, a hill I'm willing to die on by rafaelmn on Wednesday October 04, 2023 @10:19AM (#37765595)
Typescript can be very complex - it can also be incredibly simple - it's up to you how far you want to take it.

Sure it can be an adventure to express something fully in it - but this is true for any type system I've seen.

And I haven't seen another type system that's integrated into a dynamic ecosystem as well (IMO python is 5 years behind in terms of type checking experience) and that lets you chose the level of type sophistication that makes sense.

Static typing, code analysis, automated testing, etc. are all great tools that become counterproductive past a certain point. Where that point is highly depends on what you're doing and typescript is one of the most flexible type systems at letting you make that choice. I'd say a lot of people are terrible at recognizing when they went too far with it for no practical gain.

My only problem with it is that they can't fix the shit JS semantics.

Re:Strong typing, a hill I'm willing to die on by giraffe_lady on Wednesday October 04, 2023 @10:31AM (#37765762)
I am professionally familiar with typescript and explicitly not making a concrete argument for or against it right now.

I'm just pointing out that having an opinion about typescript is not the same thing as having an opinion about types. Something I think people are (intentionally?) conflating in these comments.

Re:Strong typing, a hill I'm willing to die on by rmilejczz on Wednesday October 04, 2023 @10:44AM (#37765919)
I think it’s just a path a lot of developers have traveled, starting with JavaScript and moving to TypeScript. If you’ve gone through that pipeline than you probably feel very strongly about the benefits that TypeScript provides and it’s the fulcrum for your opinion on static vs dynamic typing

Too many web developers, basically, I don’t think the conflation is intentional

Re:Strong typing, a hill I'm willing to die on by PH95VuimJjqBqy on Wednesday October 04, 2023 @03:25PM (#37770304)
I think you have to give typescript a bit of a pass in terms of types. MS had unique constraints when designing it originally, so it's never going to meet the expectations of more hardcore "typists", but I think they've done a great job given the unique challenges. Not perfect for sure, but it's one of the few newer technologies where I think it's a clear win.
Re:Strong typing, a hill I'm willing to die on by junon on Wednesday October 04, 2023 @09:58AM (#37765282)
This is pretty much my take, too. I don't hate the idea of TS, but TS is so painful to work with, and it's owned by a company I really don't like, too.
Re:Strong typing, a hill I'm willing to die on by dmix on Wednesday October 04, 2023 @10:07AM (#37765406)
OP is saying it's provides weak guarantees which is a result of the fact they made it easy to adopt and implement among legacy untyped code. It's the opposite of painful to work with for typing systems, compared to something like Rust which has stronger guaruntees and more predictable patterns but hard requirements the full stack is type. The result in TS is plenty of "any"s everywhere and in legacy code some situations where it's mostly just a thing veneer of type safety.

But all of that makes plenty of sense because in the early days it was rare to work on a real life production JS project that was pure TS from day one in addition to having TS only libraries.

These days it's everywhere and the work has been done to move away from rampant anys in popular libraries. The tooling is also mature and it's rare to find major JS libraries not already packaged with types or a @types import. Turbo moving away from TS was the rare exception.

Re:Strong typing, a hill I'm willing to die on by arp242 on Wednesday October 04, 2023 @10:27AM (#37765713)
> The tooling is also mature these days

Well:

  % cat a.ts
  console.log('Hello, world!')

  % time tsc a.ts
  tsc a.ts  2.39s user 0.10s system 232% cpu 1.066 total
2.4 seconds to compile a "hello, world" is orders of magnitudes slower than any other compiler or interpreter that I know of. It's a ridiculous start-up time.

esbuild is not an alternative as it doesn't check types.

What I want is "GET /foo.js" to "just" compile TS "on the fly" in dev; it's a simple "just works" kind of setup, but not possible with TS.

Or for a simple system, just "roll your own":

  for f in *.ts; tsc $f >|$f:r.js

  watch-files *.js --run tsc

  (for f in *.ts; tsc $f) | minify >production.js
Doesn't need to be shell, can be a simple JS script or whatever. You really shouldn't need millions of lines to call a compiler even in simple scenarios.

What exists now is an explosion of complexity to deal with all this and I guess these systems are "mature", kind of, but for a lot of systems it's massive overkill (and even for larger systems it's not particularly great IMO). Besides, it's really a bad fix for more fundamental problems.

Personally I wouldn't call TypeScript mature until compile times are roughly within the range of literally ever other compiler that has ever seen wide-spread adoption. It doesn't need to be fast: just not a huge outlier.

Re:Strong typing, a hill I'm willing to die on by zdragnar on Wednesday October 04, 2023 @10:53AM (#37766039)
You can still use tsc for type checking via editor language server and quality gates (with the noEmit flag) and get stupid fast compilation with swc or esbuild.

Explosion of complexity and "bad fix for fundamental problems" sounds a lot like you just have an axe to grind.

Many other popular languages have multiple build systems and tools to choose from as well; it isn't a particularly novel challenge.

Re:Strong typing, a hill I'm willing to die on by arp242 on Wednesday October 04, 2023 @11:29AM (#37766594)
Points out real-world practical problems

"You just have an axe to grind!"

Hmkay.

I just want things to compile, with errors, like literally everything else works. It's really not a huge ask. I don't want complex bespoke setups with multiple compilers and background processes and whatnot. The classic JS/TS response is "here is the happy path with all this tooling, but if you want something outside of that then there is something wrong with you".

Re:Strong typing, a hill I'm willing to die on by zdragnar on Wednesday October 04, 2023 @02:50PM (#37769841)
I mentioned using tsc with the noEmit flag for quality gating, which is the same workflow you would use.

`tsc --noEmit a.ts` (possibly flipping the position of the flag, I forget if it is sensitive).

That'll check the types without spending unnecessary time compiling with the slower tooling.

From there, esbuild or swc binaries compile the code as desired. They use the same tsconfig file that tsc does, so no need for any extra complexity. They build so fast that you'll not mind having a separate command, I promise.

You could even combine the two into a simple one-liner if you wanted.

Compared to, say, java where you have to fight over maven or Gradle or ant, plus endless config options in XML or groovy or whatever, typescript really isn't much to complain about.

Hell, trying to set up a clojure full stack project is a nightmare of conflicting opinions over tooling between lein and shadowjs or whatever.

Of the big languages, C# is about the only one with a "one true way", and of the smaller ones, they simply haven't yet developed a big enough base to grow contentious enough to have divergent solutions.

Re:Strong typing, a hill I'm willing to die on by dmix on Wednesday October 04, 2023 @04:05PM (#37770904)
Yep almost every (serious) TS dev only uses --noEmit for development by default because they use VSCode/IDEs as their typechecking engines and then have something like esbuild for delivering the content to the browser locally. I've never had performance issues with either step and I use both daily.

The raw output speeds aren't a very good 'practical real world example' as the OP described it.

If anything in dev ESLint (+ Copilot) is the slow ones that I sometimes noticed, but there is already Rust driven replacements maturing in the pipeline as we speak.

Re:Strong typing, a hill I'm willing to die on by arp242 on Wednesday October 04, 2023 @04:42PM (#37771444)
The performance of "tsc --noEmit a.ts" is identical, and it makes no difference vs. just typing "tsc a.ts", and it doesn't really solve "compile on demand" (with type checks) in any case.

I looked in to this some time ago, because I couldn't believe it was this slow, and tsc just has a huge startup cost. Once it gets going it's alright (I think? Don't quote me) but to get started takes a long time. It's actually already improved because not too long ago it was more like 3 seconds (probably because of the parallelisation, which is kind of cheating IMO).

I don't know about Java as I never really used it, but complex build systems are not unique to TS of course, but what they are in TS is mandatory for any reasonable experience because it works around the fact the compiler is so damn slow. That's a huge difference you can get started without too much effort, and you can do "smart" things fairly easily as I mentioned in my earlier comment.

> they simply haven't yet developed a big enough base to grow contentious enough to have divergent solutions.

C, C++, Go, Rust, Python, Ruby, PHP don't have a "big enough base"? Ehhh

And my entire point is that TS LACKS "divergent solutions". Because it's so slow lots of solutions are simply not practical.

Re:Strong typing, a hill I'm willing to die on by jdeisenberg on Wednesday October 04, 2023 @10:58AM (#37766120)
You might want to look into ReScript (https://rescript-lang.org/). It has strong static typing with type inference, and it is very fast.
Re:Strong typing, a hill I'm willing to die on by arp242 on Wednesday October 04, 2023 @11:19AM (#37766445)
Yep, Rescript is nice, but also comparatively obscure. It's okay for personal projects; in company setting: maybe? It's certainly more complex.
Re:Strong typing, a hill I'm willing to die on by 2c2c2c on Wednesday October 04, 2023 @01:56PM (#37769085)
This take is common, but personally never understood it. The typing is optional. Use it for the easy stuff and enjoy the low hanging fruit
Re:Strong typing, a hill I'm willing to die on by junon on Wednesday October 04, 2023 @05:23PM (#37772000)
If the tooling is a pain to use, slow, and owned by a crappy corporation, and I'm not going to use the types anyway, then I have even less of a reason to use it...
Re:Strong typing, a hill I'm willing to die on by arp242 on Wednesday October 04, 2023 @10:09AM (#37765438)
Are these people who used types but didn't like it, or people who never really used it and refuse to even try it?

IMHO these are markedly different scenarios: the first is essentially just a difference of opinion, the second is a rather myopic attitude.

Re:Strong typing, a hill I'm willing to die on by lo_zamoyski on Wednesday October 04, 2023 @11:25AM (#37766521)
Have they considered languages with type inference?
Re:Strong typing, a hill I'm willing to die on by digging on Wednesday October 04, 2023 @11:53AM (#37767003)
> bemoan the upfront cost

This applies to much more than static typing as well. Anything built, can be built well or it can be built quickly.

Although I often have to make trade-offs for immediate gain at work, there is a big difference between the quality of my work over time vs the quality of other devs who default to immediate returns. I will say in their defense, they play a role in the team. But I wouldn't want to work on a team where avoiding upfront costs was the expectation rather than the exception.

Re:Strong typing, a hill I'm willing to die on by waffletower on Wednesday October 04, 2023 @12:12PM (#37767290)
And I definitely think less of you as you as a developer as you openly admit to dogmatic and myopic prejudice regarding the nuances of typing systems and the complexity of software development contexts.
Re:Strong typing, a hill I'm willing to die on by lijok on Wednesday October 04, 2023 @12:35PM (#37767687)
Interesting. Would you have had the same response if GP stated:

"I've worked with my fair share of vanilla JS devs who refuse to acknowledge the benefit of testing. Most of them bemoan the upfront cost of testing everything without realizing the benefits of it. I absolutely think less of them as developers."

Re:Strong typing, a hill I'm willing to die on by waffletower on Wednesday October 04, 2023 @01:58PM (#37769110)
Again another binary dichotomy that doesn't neatly fit reality. I imagine the number of developers that would unilaterally dismiss all testing practices is very small.
Re:Strong typing, a hill I'm willing to die on by halfmatthalfcat on Wednesday October 04, 2023 @04:19PM (#37771106)
I mean, I'm not going to say it to someone's face but I'll definitely be judging them. Most of those who have pushed back against typescript have done so for similarly dogmatic reasons or even straight ignorance (I dont want to learn something new), so I'm not sure who is really the winner or loser in this situation.
Re:Strong typing, a hill I'm willing to die on by leptons on Wednesday October 04, 2023 @01:20PM (#37768485)
I absolutely realize the benefits of it, and I also recognize it doesn't cure all. Everything has trade-offs. There were plenty of amazingly complex and large projects written in vanilla JS before typescript ever existed, and somehow they aren't falling apart and crippled. It really depends on the developers involved more than the language or the dogma.
Re:Strong typing, a hill I'm willing to die on by ecshafer on Wednesday October 04, 2023 @01:59PM (#37769122)
This sounds like its just Typescript evangelizing. But while I love types, Typescript kind of sucks and sucks the fun out of writing Javascript. If I am going to add a compilation step to get types, I would rather write Scala or F# and compile to JS, then you also get rid of all of the warts of JS that Typescript doesn't get rid of.
Re:Strong typing, a hill I'm willing to die on by IshKebab on Wednesday October 04, 2023 @06:18PM (#37772576)
I agree Typescript doesn't solve all the warts. But it does solve a lot.

The really issue with compile-to-Javascript languages is debugging. Have fun stepping through your incomprehensible generated code in dev tools.

(Except Dart which has really good Dev tools support; I guess they can poke the right people to make it work.)

Re:Strong typing, a hill I'm willing to die on by manicennui on Wednesday October 04, 2023 @02:16PM (#37769370)
The problems with JS go far beyond its dynamic typing.
Re:Strong typing, a hill I'm willing to die on by pfdietz on Wednesday October 04, 2023 @09:37AM (#37764965)
Strong static typing is useful in the environment where the code is not adequately tested. That's because tests adequate to make the code bulletproof will also detect the problems strong static typing could detect, rendering SST superfluous.

So, how often is poorly tested code out there? From the popularity of strong static typing, it must be ubiquitous.

Re:Strong typing, a hill I'm willing to die on by ozr on Wednesday October 04, 2023 @09:40AM (#37765018)
Ubiquitous is a good guess.
Re:Strong typing, a hill I'm willing to die on by dolmen on Wednesday October 04, 2023 @09:44AM (#37765077)
The point of static typing is that the compiler does checks before your program even starts. And that avoids to write lot of coverage tests that are needed (but usually just ignored) with languages that massively use loosely typed data containers (variables).
Re:Strong typing, a hill I'm willing to die on by pfdietz on Wednesday October 04, 2023 @10:17AM (#37765536)
Sure, if you're going to be in an environment where the code is going to be bad because of inadequate testing (and I admit this is quite common, due to the cost of the testing needed), static typing lets it be somewhat less bad. It's just important to understand it's a band-aid, not a panacea.
Re:Strong typing, a hill I'm willing to die on by marcosdumay on Wednesday October 04, 2023 @10:46AM (#37765953)
Testing is a bandaid that only pretends to show that your code is correct.

Static verification (what includes static types) is the real deal.

That said, WTF is there with people insisting that types must be either static or dynamic, and that dynamic types are useless?

Re:Strong typing, a hill I'm willing to die on by pfdietz on Wednesday October 04, 2023 @12:22PM (#37767458)
Static typing, as done in mainstream languages, doesn't show your program is correct. Is you compiler written in a mainstream language correct just because it compiles? Of course not. Don't point to academic curiosities with dependent types if they aren't actually used. Extensive testing, on the other hand, is used in the "real world" for assurance.
Re:Strong typing, a hill I'm willing to die on by yakshaving_jgt on Wednesday October 04, 2023 @03:34PM (#37770413)
This is the classic "Uncle Bob" style false dichotomy.

Whoever said you can only pick one of the two approaches?

Re:Strong typing, a hill I'm willing to die on by marcosdumay on Wednesday October 04, 2023 @05:18PM (#37771944)
Every code out there on the real world is full of baindaids and duct tape. Yet, the actual amount varies a lot, as does the centrality of the patched things.
Re:Strong typing, a hill I'm willing to die on by ShellfishMeme on Wednesday October 04, 2023 @09:46AM (#37765108)
Strong types aren't just a correctness guarantee, they also help to discover structure and interfaces that previously were implicit.

If a developer can jump into an unknown part of a codebase and quickly see that following a certain structure will automatically make their code work for them without needing to read all the code first and double checking if it's just a random convention versus a strict interface so they don't reinvent the wheel or build code that doesn't fit in with the existing structure, then that's worth a lot and something you cannot simply cover with tests.

Re:Strong typing, a hill I'm willing to die on by user3939382 on Wednesday October 04, 2023 @09:53AM (#37765197)
Integration tests are different, but I tend to believe that a strong enough type system should be able to negate the need for unit tests completely.

If anyone can think of something a unit test could test for that an arbitrarily* complex/strong type system couldn't I'd be interested to hear it. It's possible, I just can't think of any.

Re:Strong typing, a hill I'm willing to die on by pfdietz on Wednesday October 04, 2023 @10:08AM (#37765421)
When I say adequately tested, I mean much more than unit tests. Unit tests aren't going to give you bulletproof code. They don't detect bugs that arise from interactions at a higher level.

An arbitrarily complex type system, with dependent types, could detect any bug, since it's formally equivalent to requiring the program be proved correct. But using such a type system is so onerous that I don't know anyone who realistically does it in production.

If you wrote such types, you're basically giving a formal specification of what the program is supposed to do. That could then be used, and likely much more easily, for high volume property-based testing.

Re:Strong typing, a hill I'm willing to die on by bluGill on Wednesday October 04, 2023 @11:50AM (#37766942)
Unit tests and types solve somewhat different problems. You can force a unit test to check everything a type system does with effort (mostly by throwing wrong types at your API and verifying you get an error), but I'm not sure how you would use the type system to enforce sort() actually sorts. Sure sort can take a listOfFoo and return a sortedListOfFoo - but that doesn't verify sortedListOfFoo is actually sorted - and in many cases I want an API that is find with listOfFoo but should handle sortedListOfFoo as well.
Re:Strong typing, a hill I'm willing to die on by skulk on Wednesday October 04, 2023 @12:09PM (#37767241)
With dependent types you can encode any proposition in first-order logic (?). You can indeed define an array type that is necessarily sorted. It won't be pretty but it's possible.

More info here: https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspon...

Re:Strong typing, a hill I'm willing to die on by _dain_ on Wednesday October 04, 2023 @02:23PM (#37769460)
I like type systems as much as anyone but I can't see how your type system will check that sin(pi) == 0

if you have a type system expressive enough to do things like that, you've basically got another turing-complete layer on top of your existing language, which is itself ... dynamically typed.

Re:Strong typing, a hill I'm willing to die on by xmcqdpt2 on Wednesday October 04, 2023 @10:10AM (#37765449)
High test coverage is useful in the environment where the code is not adequately typed. That's because static types adequate to make the code bulletproof will also detect the problems unit tests could detect, rendering high unit test coverage superfluous.

So, how often is poorly typed code out there? From the popularity of test coverage tools, it must be ubiquitous.

Re:Strong typing, a hill I'm willing to die on by pfdietz on Wednesday October 04, 2023 @10:19AM (#37765590)
The turned-around argument has a problem: testing should reveal type bugs, but static typing (of the kind typically discussed for mainstream languages) can't reveal non-type bugs.

In a situation where extreme levels of testing occur, the extra assurance from strong typing is minimal. In a situation where strong typing is enforced, extra testing is still very useful.

Re:Strong typing, a hill I'm willing to die on by xmcqdpt2 on Wednesday October 04, 2023 @07:34PM (#37773140)
I don't think it's possible to test a sufficiently complex system that isn't somewhat restricted in the states it goes through, which requires typing.

Consider a finite state machine with N states. There are a priori NxN possible transitions. In many cases however most of them are impossible, and you really have only O(N) feasible transitions.

Sure if you make O(N^2) tests you don't need typing... but typing could have made many of those transitions literally impossible. You don't need to test the impossible. For a sufficiently large codebase, you want to limit as much as possible the amount of tests you need.

Also I have more than once identified issues in our testing framework because when I made stronger types I uncovered bugs that escaped our tests. Non-deterministic concurrency bugs are extremely hard to test for. So yes, testing can uncover type bugs, but typing can uncover untestable bugs.

Re:Strong typing, a hill I'm willing to die on by yakshaving_jgt on Wednesday October 04, 2023 @10:10AM (#37765457)
> Strong static typing is useful in the environment where the code is not adequately tested. That's because tests adequate to make the code bulletproof will also detect the problems strong static typing could detect, rendering SST superfluous.

Ok, but it's cheaper to not have to write those tests than it is to write those tests.

Re:Strong typing, a hill I'm willing to die on by pfdietz on Wednesday October 04, 2023 @12:24PM (#37767490)
Yes. It's cheaper to have a lower assurance your program is correct than to have a higher assurance. The claim I'm making is that at the high end, the extra assurance from strong static typing becomes minimal.
Re:Strong typing, a hill I'm willing to die on by yakshaving_jgt on Wednesday October 04, 2023 @03:30PM (#37770367)
> Yes. It's cheaper to have a lower assurance your program is correct than to have a higher assurance.

That's quite clearly not what I'm saying.

Re:Strong typing, a hill I'm willing to die on by soggybutter on Wednesday October 04, 2023 @10:18AM (#37765571)
Good tests only render SST superfluous insofar as the person writing the tests is capable of never making a mistake. The thing about good static type systems is they don't typically make mistakes in the domain they work in. The fact that you don't have to muddy your test with a bunch of type checking logic and instead focus on the thing actually being tested is just the cherry on top.
Re:Strong typing, a hill I'm willing to die on by Kuinox on Wednesday October 04, 2023 @10:20AM (#37765613)
Tests is testing your program against samples, where strong typing make your program incorrect on a whole spectrum of samples.
Re:Strong typing, a hill I'm willing to die on by mejutoco on Wednesday October 04, 2023 @10:57AM (#37766111)
That is a very original take, but I think you have it reversed. Typing removes the possibility of _some_ errors. Those are tests you do not _need_ to write (you can still write them if you want), thus having more time and attention to write tests that matter. Typing is a baseline, and anything over that baseline you can deal with with tests.

It is like the things you already trust when you code. Let's say, that the file system works, that the network stack of your OS works, or that the cpu works. You can rely on them to use your time for the things that matter. This is a much better model than simply testing everything yourself since, as the tests number increase, any change to the codebase involves more and more test changes.

> Strong static typing is useful in the environment where the code is not adequately tested. That's because tests adequate to make the code bulletproof will also detect the problems strong static typing could detect, rendering SST superfluous.

Your logic is the same as follows: seat belts are useful in an environment where drivers are not driving adequately. That's because adequate drivers will drive in a way to avoid any danger that the seat belt would prevent, rendering seat belts superfluous.

Ultimately, the problem is adequate drivers (as in described above) or bulletproof tests do not exist, they are just a concept. A test can prove the presence of an error, not the lack of errors, and the argument only works in absolutes.

Re:Strong typing, a hill I'm willing to die on by pfdietz on Wednesday October 04, 2023 @02:20PM (#37769415)
You seem to be thinking that testing for type errors is something additional to general testing. It's not. With sufficiently strong logic testing, the testing for type errors comes along for free.

The analogy with driving doesn't make much sense. After all, accidents sometimes happen without the driver being to blame, and the marginal cost of putting on a seat belt is very low.

Re:Strong typing, a hill I'm willing to die on by mejutoco on Wednesday October 04, 2023 @05:02PM (#37771744)
With sufficiently adequate drivers seatbelts are superfluous indeed.

Apart from an analogy is a template of your argument. It is the logic of the argument itself.

Errors also happen sometimes without type systems being to blame (they only catch a subset of errors).

The marginal costs of a type system is usually very low too, so it seems to be a great fit.

Re:Strong typing, a hill I'm willing to die on by d3w4s9 on Wednesday October 04, 2023 @11:17AM (#37766416)
No. It is useful in almost every environment other than things like REPL. I can write TypeScript for hours without writing any tests, run it and fix a few minor logic bugs and code is production level, which is great for prototyping. No chance with plain JavaScript without typing -- it would be at least a day or two and I would constantly run into stupid typos or other errors that can only be found at runtime.
Re:Strong typing, a hill I'm willing to die on by sneed_chucker on Wednesday October 04, 2023 @01:21PM (#37768500)
Yeah, big piles of untyped Django spaghetti need a behemoth suite of integration tests in order to remotely approach the sort of runtime guarantees that typed languages give you for free.

When you use a typed language, you can use your integration tests to actually verify business logic, exception handling, etc. instead of having to write a dozen test cases to make sure that doThing(table, index,*kwargs) doesn't blow up when 'table' is a list or 'index' is bytes...

Re:Strong typing, a hill I'm willing to die on by pfdietz on Wednesday October 04, 2023 @01:29PM (#37768634)
If you adequately test your code for logic bugs, you test the type correctness for free. So, yeah, writing those logic tests is hard. But at least they are finding bugs that static type checking never will (absent the unrealistic scenario of proving your program correct via a type system.)

(It won't find latent bugs that can't currently be exercised, so the testing can't be one and done.)

Re:Strong typing, a hill I'm willing to die on by _dain_ on Wednesday October 04, 2023 @02:20PM (#37769403)
you can't ensure that you hit every possible case in your test suite. type errors can still slip through in production, just like logic bugs do. it happens all the time in real-life code. that "adequately" is a no-true-scotsman.

if you use a static type system you can guarantee there will be no type errors at runtime. why on earth wouldn't you choose that? you can still write logic tests!

and when you leverage the type system to make illegal states unrepresentable, you can make certain classes of logic error impossible as well. some of your tests become tautologies and you can delete them.

Re:Strong typing, a hill I'm willing to die on by pfdietz on Wednesday October 04, 2023 @02:29PM (#37769532)
You are assuming type errors are caught by tests explicitly written to detect them, as opposed to being found by other kinds of tests. For example, property based tests, with automated generation of inputs to a program or module, don't explicitly test for type errors, but are still (in my experience) quite good at hunting them out.

What testing cannot find are latent errors not exercised by the program. Do I care about these, though? Arguably these would be found by testing internal interfaces and elimination of code not reachable by tests.

The general argument I am trying to make is that the marginal value obtained by strong static typing declines as testing increases, and that in the limit goes to zero. If a program is adequately tested, is it still worth doing? This is not clear to me, and the arguments given here have not convincingly demonstrated that it is worth it.

Also: if you find yourself in a situation where strong static typing seems useful, you should be alarmed. It means you aren't testing your code very thoroughly.

Re:Strong typing, a hill I'm willing to die on by _dain_ on Wednesday October 04, 2023 @05:44PM (#37772246)
>You are assuming type errors are caught by tests explicitly written to detect them, as opposed to being found by other kinds of tests.

I am not assuming that.

honest question: what language do you have in mind when you think "static types"? your perspective is so starkly different to mine, you seem to be operating under totally different assumptions about what types can and can't do.

I mean this sentence:

>Also: if you find yourself in a situation where strong static typing seems useful, you should be alarmed. It means you aren't testing your code very thoroughly.

is just baffling to me. it's so self-evidently absurd that I can't even argue against it. what is there even to say?

have you even used a modern statically typed language, with type inference, generics, null safety, algebraic data types, pattern matching, etc? I cannot imagine trying to maintain a big codebase without them. they don't slow me down, they speed me up. they aren't just about catching trivial int-instead-of-string bugs, they are are core tool for modelling data and business logic. they let me define problems out of existence (see e.g. this series of posts https://fsharpforfunandprofit.com/posts/designing-with-types... for an introduction).

and then there's rust and newer-generation languages with borrow checkers and affine/linear types, ruling out entire classes of memory and concurrency bugs ... your test suite cannot rule out data races, but rustc sure can.

you are making the same arguments people were making in the 2000s when most static languages sucked because they didn't have these features. I don't want to go back to a time before sum types.

>What testing cannot find are latent errors not exercised by the program. Do I care about these, though?

you should, because in production your program must endure orders of magnitude more variety in inputs, uptime, and runtime conditions than the test suite can exercise. it can and will get into weird states you didn't anticipate. yes, you can fuzz, yes you can property test, I know all about that. those things are good. but I don't get why you wouldn't also use a static type system to provably rule out classes of problem across all possible code paths. why settle for less?

Re:Strong typing, a hill I'm willing to die on by ReflectedImage on Thursday October 05, 2023 @01:26PM (#37781376)
"you should, because in production your program must endure orders of magnitude more variety in inputs, uptime, and runtime conditions than the test suite can exercise. it can and will get into weird states you didn't anticipate. yes, you can fuzz, yes you can property test, I know all about that. those things are good. but I don't get why you wouldn't also use a static type system to provably rule out classes of problem across all possible code paths. why settle for less?"

Because type errors in unit tested code are basically non existent. It's a fictional problem and as such there is no point in spending real resources chasing fictional problems.

There is plenty of research that shows that static typing gives no benefits (statistically insignificant) when it comes to software correctness.

What you are asking is why shouldn't the local government spend money on a Yeti patrol to protect the general public against Yeti's? The Yeti patrol will eliminate an entire class of problem (Yeti attacks).

Re:Strong typing, a hill I'm willing to die on by _dain_ on Thursday October 05, 2023 @02:25PM (#37782148)
>Because type errors in unit tested code are basically non existent.

this is short-sighted. I am not talking about trivial string-instead-of-an-integer errors here. powerful type systems let you encode far more sophisticated constraints on the program. safe rust makes data races into a compile-time error via its type system, for example. unit tests can't do that.

I think you're greatly underestimating what types can do for you. you seem to have this mental model where you would write the exact same kind code with a type checker as without one, and the only difference is whether you have to convince some pedantic bureuacrat that your code is correct when you already know it is.

but when you have a powerful type system, you don't write the same kind of code. the type systems helps drive design, similar to how tests can drive design. you have probably seen code that is bad because it wasn't written with testing in mind. there wouldn't be much value in adding unit tests to the code right away -- you probably need to do some highly invasive re-architecting to make it testable.

so, is it really such a stretch of the imagination that code can also be deficient because it's untypeable? perhaps the reason you don't see much benefit to types is because you didn't write the code with types in mind, as a design tool.

there is a learning curve to writing testable code. the same is true for types.

read this if you haven't, about type-driven design: https://fsharpforfunandprofit.com/series/designing-with-type...

Re:Strong typing, a hill I'm willing to die on by ReflectedImage on Thursday October 05, 2023 @03:18PM (#37782994)
Sadly, it still took 4 days to clear the deadlocks out of my Rust program.

No, my mental model is removing the type checker allows me to write shorter, more concise and higher quality code. Dynamic typing enables much better code styles than static typing.

> the type systems helps drive design

Ahh you are an complexity merchant, if only I made my code more complicated all my problems would be solved. I'm afraid not, the more complicated your code the worse it is.

No I'm afraid, I have actual real commercial experience of doing both styles of software development, the dynamically typed code is the better approach by far.

It's not that I don't understand you, it's just what you are saying is a load of rubbish. :p

Re:Strong typing, a hill I'm willing to die on by bennyelv on Wednesday October 04, 2023 @09:37AM (#37764982)
Amen!

I'm currently responsible for a very large system built in raw javascript where function definitions like this one in the article: function birthdayGreeting1(...params)

...are the religion.

It's awful. I hold the people responsible in very little regard.

Re:Strong typing, a hill I'm willing to die on by c048 on Wednesday October 04, 2023 @09:20AM (#37764714)
People that still want to try and fight it either:

- Use notepad for development (don't laugh, I've actually encountered a dev who's choice IDE was notepad).

- Never worked with more than 1 person on a project.

- Never worked on anything but tiny projects.

- Never re-opened a project after having worked on a different project for several weeks.

Re:Strong typing, a hill I'm willing to die on by Qwertious on Wednesday October 04, 2023 @10:00AM (#37765309)
You should legitimately try a project in notepad. Not Notepad++, specifically Notepad. Probably a very short project, but you should give it a shot. It'll give you a bit of a perspective. And some real appreciation for Notepad++.
Re:Strong typing, a hill I'm willing to die on by bluGill on Wednesday October 04, 2023 @11:58AM (#37767088)
I've been forced to use ed (serial connection to an embedded device that didn't support TERM), what does notepad give?
Re:Strong typing, a hill I'm willing to die on by msla on Wednesday October 04, 2023 @09:29AM (#37764826)
Similarly, choosing between 'int' and 'long' isn't part of a type system, unless the only semantics your data has is being an integer of a given width. Types are semantic, and telling me "height is 32 bits" tells me jack shit about units of measure or anything else.
Re:Strong typing, a hill I'm willing to die on by wiseowise on Wednesday October 04, 2023 @09:16AM (#37764634)
The only absolute truth there is. Static typing is nonnegotiable.
Re:Strong typing, a hill I'm willing to die on by dartos on Wednesday October 04, 2023 @09:20AM (#37764704)
There’s strong typing and weak typing.

And then, kind of orthogonal to that, there’s also static typing and dynamic typing.

I think strong, dynamic typing is just as good as strong static typing (weak typing is objectively bad)

As long as the types of your variables don’t change from under you, that’s good, but I’m also okay with the compiler / runtime figuring out what those types are for me.

Re:Strong typing, a hill I'm willing to die on by chongli on Wednesday October 04, 2023 @09:28AM (#37764816)
With "dynamic typing" there is no compiler to figure out the types for you. There is only the runtime to print a stack trace (if you're lucky) and bail out. The whole point of types is to be able to check things without running the program, because exercising every possible code path becomes increasingly untenable at scale.

A side (but many would also say critical) benefit of types is that they act as a form of documentation that can never go stale (because they are enforced by the compiler). "Dynamic typing" does not offer this benefit whatsoever.

Re:Strong typing, a hill I'm willing to die on by dartos on Wednesday October 04, 2023 @09:32AM (#37764908)
Many dynamically typed languages have static analyzers, but retain the flexibility of not needing to prescribe types up front (it’s impossible to know exactly what data structure you need at the start of a project)

That’s the crux of why I’m not all in on static typing all the time. (Especially for networked programs that expect a wide range of different kinds of input)

Having to prescribe the types I need before I actually need them goes against how I tend to build.

Re:Strong typing, a hill I'm willing to die on by sfn42 on Wednesday October 04, 2023 @09:55AM (#37765229)
Sounds like you'd like C#. It does type inference with `var` and similar things, so you don't always have to specify types explicitly, but everything does have a type at compile time.
Re:Strong typing, a hill I'm willing to die on by Smaug123 on Wednesday October 04, 2023 @10:22AM (#37765651)
(C#'s type inference is so much worse than F#'s. I find it deeply painful to go back.)
Re:Strong typing, a hill I'm willing to die on by loup-vaillant on Wednesday October 04, 2023 @09:57AM (#37765256)
> Many dynamically typed languages have static analyzers, but retain the flexibility of not needing to prescribe types up front

Almost all static type systems have escape hatches that let you go dynamic when you really really need it. Also, I bet that most of your use cases for dynamic typing could be solved with a simple tagged union. Most people bemoaning the lack of flexibility of static typing just don’t know about how tagged unions can easily emulate dynamic typing when we need it, such that we rarely even need to reach for the actual escape hatches.

> (it’s impossible to know exactly what data structure you need at the start of a project)

Thankfully data structures are even easier to change with static typing: change it, gets a ton of type errors, fix them, done. With dynamic typing you run the risk of missing a call site.

> Having to prescribe the types I need before I actually need them goes against how I tend to build.

There’s type inference for that. I personally take advantage of it any chance I get.

Re:Strong typing, a hill I'm willing to die on by k__ on Wednesday October 04, 2023 @09:32AM (#37764903)
As far as I know, JS is weakly typed and Python is strongly typed.

JS will convert types under your butt if you're not careful, Python won't.

Sure, static typing (when done well) is superior to that, but the title talks about strong typing.

Re:Strong typing, a hill I'm willing to die on by pfdietz on Wednesday October 04, 2023 @10:12AM (#37765475)
Dyanmic typing doesn't exclude the compiler from being able to detect some things that would cause errors at run time. It just means that these turn into compile time warnings, not compile errors.

In Common Lisp, it's common practice to not accept code unless all such warnings are gone.

Re:Strong typing, a hill I'm willing to die on by chongli on Wednesday October 04, 2023 @10:39AM (#37765859)
That is static typing. You can add static types to a dynamic language, but then you introduce a compilation step. This is not an argument in favour of dynamic typing. If your language requires a compilation step anyway, then what you have is a static language with only one type: the ‘any’ type.

Every argument I’ve seen in favour of dynamic typing is some variation of “I like it this way.” They’re not technical arguments because dynamic typing is a strict subset of a statically typed language, equivalent to passing a flag to turn the type checker off.

Sure, not every compiler offers such a flag, but that is an argument against one particular static language (or group of languages), not an argument against static types itself.

Re:Strong typing, a hill I'm willing to die on by marcosdumay on Wednesday October 04, 2023 @10:54AM (#37766057)
> There is only the runtime to print a stack trace

Types are not exclusively for verification, and even if you decide it is, you can do a lot more with a type error than exiting the program.

That stance most people keep repeating is actually ridiculous. The most common usage of static type systems is to verify badly-written ad-hock dynamic ones that handle user errors.

Re:Strong typing, a hill I'm willing to die on by kerkeslager on Thursday October 05, 2023 @09:27AM (#37778332)
> With "dynamic typing" there is no compiler to figure out the types for you. There is only the runtime to print a stack trace (if you're lucky) and bail out.

This is just incorrect. Plenty, if not most, dynamically-typed languages are compiled. Indeed even the idea that there's a clean dichotomy between compiled and interpreted is an outdated idea: I'm not aware of any production languages which run tree-walk interpreters entirely without compilation. Modern "interpreters" typically compile to bytecode but in some cases even can compile to native code, they simply do so in a just-in-time manner. These compilation steps are quite capable of applying type systems.

For example, if you run a Python script, you can see the results of compilation cached in .pyc files (these will be either in the same directory as the source files, or in your __pycache__ folder, depending on your configuration).

> The whole point of types is to be able to check things without running the program, because exercising every possible code path becomes increasingly untenable at scale.

Is it? I would argue that the point of types is to report errors at the place where they occur, rather than doing the wrong thing silently and reporting an error elsewhere, or simply behaving incorrectly.

If a tree falls in a forest and nobody hears it fall, does it really fall at all? If a bug happens on a code path, and nobody exercises that code path, is there really a bug?

Re:Strong typing, a hill I'm willing to die on by IKantRead on Wednesday October 04, 2023 @10:01AM (#37765323)
Dynamic vs static typing is a similar level of design decision as interpreted versus compiled. It's ridiculous to try to claim one is universally better than the other as they both have styles of programming and domains they are better suited for.

I would never want a statically typed, compiled awk for example.

I generally think large, production, multi-developer software should be written in a statically typed, compiled language.

Strong vs Weak typing is a closer to a debate about having a name spacing system or not. There is really no great reason to have weak typing or not use a name spacing system.

Re:Strong typing, a hill I'm willing to die on by wiseowise on Wednesday October 04, 2023 @10:38AM (#37765841)
It’s not ridiculous at all.

Mainstream dynamically typed languages are moving in statically typed direction. Python (Mypy, Pyright and others), Ruby (Sorbent, Rbs), JavaScript (Typescript, Flow). How many statically typed languages optionally removed types?

Re:Strong typing, a hill I'm willing to die on by IKantRead on Wednesday October 04, 2023 @11:21AM (#37766484)
It's a bit sad to me that people can only image writing code for large production systems. Static types are hugely beneficial in this area which is why we see this trend.

Personally I think Python moving in the direction of static typing is a mistake, dynamic typing is very useful for domains where python is strongest: modeling, statistics, scientific computing etc. It's also part of the basic design of Python to be a dynamic language. Likewise Ruby, with it's heavy use of metaprogramming, also benefits tremendously from a lack of types.

But let me be clear: I do think statically typed languages are a very good idea for large production systems, I just personally do a lot of programming that's not for these systems.

> How many statically typed languages optionally removed types?

I wouldn't say "removed" types, but I've been in software along enough to remember when dynamic typing was the big hot thing and crusty old Java devs complained that we couldn't possibly live without static type annotations. I distinctly remember when C# introduced `var` (which is of course really type inference, not dynamic typing) to appeal to devs that were growing weary of types.

There's a great example in SICP of implementing a full object system in just a few lines of code that would not be possible to implement as elegantly in a statically typed language. Do I want that for a production system? No. But there is, or at least used to be, a world of computation being done for reasons other that quickly getting PRs pushed out to prod.

Re:Strong typing, a hill I'm willing to die on by wiseowise on Wednesday October 04, 2023 @02:52PM (#37769863)
Ok, maybe my previous message was too radical. Of course there's a space for dynamic types (I use Clojure in free time), but there's no reason for static types to obscure your program. When I talk about static typing I mean Ocaml, Haskell, Scala, F# where you program is statically typed but you'll rarely see any types.
Re:Strong typing, a hill I'm willing to die on by pharmakom on Wednesday October 04, 2023 @09:48AM (#37765137)
Also on the “types good” side of the fence. HOWEVER, I also believe that mainstream typed languages cannot represent some situations very well. Often the only attempts to do so are in some weird Haskell extension and it feels rather… inelegant. Bottom line: types are better; but our current type-systems are not the final word on types.
Re:Strong typing, a hill I'm willing to die on by omnicognate on Wednesday October 04, 2023 @09:51AM (#37765174)
> The amount of pre-existing respect for someone I'd need to have before I engage in a good-faith discussion on "are types good" is pretty high.

> edit: To clarify, I am on the "types good" side of things

I agree. Python 1 would have been worthless if it didn't have types.

Re:Strong typing, a hill I'm willing to die on by fsdjkflsjfsoij on Wednesday October 04, 2023 @10:10AM (#37765456)
This is basically where I am at. Most libraries and applications are trivially typed even in languages with relatively poor type systems like Go and Java. The necessity, or even benefit, of weak and/or dynamic typing is extremely rare and most languages have workarounds or escape hatches for those exceedingly rare cases.

Dynamic typing also makes a ton of optimizations basically impossible and even after monumental efforts languages like Javascript are still quite slow, inconsistent and memory inefficient outside of trivial benchmarks.

Re:Strong typing, a hill I'm willing to die on by diggan on Wednesday October 04, 2023 @10:45AM (#37765940)
> Javascript are still quite slow, inconsistent and memory inefficient outside of trivial benchmarks.

I thought this meme was dead already. Of course, you might not be able to squeeze out the same amount of performance compared to a brilliantly written C or Rust program, but for what it is, JavaScript is pretty damn fast already.

DOM manipulation on the other hand, is still a very common bottleneck people come across when writing typical JavaScript code.

Re:Strong typing, a hill I'm willing to die on by fsdjkflsjfsoij on Wednesday October 04, 2023 @10:55AM (#37766064)
> but for what it is, JavaScript is pretty damn fast already.

It's fast compared to other dynamically typed language implementations but it's still very slow compared to basically all of the popular statically typed languages.

Re:Strong typing, a hill I'm willing to die on by cogman10 on Wednesday October 04, 2023 @11:25AM (#37766532)
> It's fast compared to other dynamically typed language implementations

true

> it's still very slow compared to basically all of the popular statically typed languages.

Not true.

The main slowdown for javascript (AFAIK) is the checks the optimizer has to put into place to ensure the assumptions it's made about the type are still valid. If, however, those assumptions are valid then javascript ends up emitting pretty much the same assembly that you'd see for and highly optimized statically typed language. In fact, there are some circumstances where it can beat a language like C++ or Rust due to the fact that it has to incorporate runtime information into optimizations.

With C++ or rust, if you add dynamic dispatch, unless you are doing PGO and whole program optimization, you are pretty much sunk with 2 memory lookups on every function call. This is the case where javascript can end up beating C++/Rust.

(All of this is talking about hot code after warmup. During the initial execution javascript will almost certainly always be slower).

Part of the proof of this was asm.js, the precursor to wasm. V8 at the time it was introduced could execute asm.js nearly as fast as what firefox could do with it's optimized asm.js compiler. That is, when you stripe out all the actions that make javascript slow, it very often ends up being just as fast as a compiled language.

What stuff ends up making it slow? Generally speaking, stuff that makes the types unpredictable (adding fields, removing fields, sending in a number and a string and expecting the VM to be able to handle both).

You can see a lot of this writeup around the discussions about why Dart was originally "optionally typed". Basically, the entire selling point to make dart fast was simply to remove the abilities to dynamically change types like you have in javascript. With that, the VM authors at the time were capable of making a VM that's every bit as fast as what Java has.

Re:Strong typing, a hill I'm willing to die on by gpderetta on Wednesday October 04, 2023 @12:06PM (#37767200)
> With C++ or rust, if you add dynamic dispatch, unless you are doing PGO and whole program optimization, you are pretty much sunk with 2 memory lookups on every function call. This is the case where javascript can end up beating C++/Rust.

GCC at least is capable of speculative devirtualization by using local heuristics, without PGO. And of course it is capable of devirtualizing in many cases when the knowledge actual type can be constant-propagated.

Also note that the vast majority of calls are not dynamic in C++ (as opposed to most dynamic languages), so devirtualization is significantly less impactful.

Re:Strong typing, a hill I'm willing to die on by cogman10 on Wednesday October 04, 2023 @07:29PM (#37773112)
Fair point, AFAIK C++ templates are pretty heavily used to avoid a dynamic dispatch. Couple that with the fact that polymorphic OO has fallen out of favor generally and I could see this mattering a lot less now-a-days.
Re:Strong typing, a hill I'm willing to die on by fsdjkflsjfsoij on Wednesday October 04, 2023 @12:07PM (#37767216)
> That is, when you stripe out all the actions that make javascript slow, it very often ends up being just as fast as a compiled language.

ok...

> In fact, there are some circumstances where it can beat a language like C++ or Rust due to the fact that it has to incorporate runtime information into optimizations.

People used to make the same claim about Java and in every single example I've ever seen the Java/Javascript is extremely optimized, performance isn't consistent across VM versions, and the C++/Rust is extremely naive (usually allocating unnecessarily and not using arenas in hot paths that are allocation heavy).

Re:Strong typing, a hill I'm willing to die on by PH95VuimJjqBqy on Wednesday October 04, 2023 @12:59PM (#37768130)
absolutely spot on, there was a time when Hotspot was going to bring Java to the promised land.

It never happened.

Re:Strong typing, a hill I'm willing to die on by cogman10 on Wednesday October 04, 2023 @07:28PM (#37773101)
None of these tests really show JS winning, but they are showing that it's within spitting distance of C++ in multiple tests [1]

And, you can look at the code yourself, most of the examples read pretty much exactly the same as their C++ counterparts.

Mind you, this is also a test that looks at execution start to finish and doesn't give warmup time (which will always favor statically compiled languages).

> performance isn't consistent across VM versions

That's true for C++ compilers, so why would you expect performance to remain constant with a JIT compiler?

[1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re:Strong typing, a hill I'm willing to die on by wilde on Wednesday October 04, 2023 @11:21AM (#37766472)
Re:Strong typing, a hill I'm willing to die on by fsdjkflsjfsoij on Wednesday October 04, 2023 @11:28AM (#37766581)
Trivial benchmarks where all of the significant data structures and networking are done in C++ and the tiny amount of Javascript is just passing some strings around. I guess it's "fast" if you can restrict yourself to little more than hello world where you do nothing more than pass a few strings to functions written in faster languages.

Notice that in the Java, C#, Go, Rust, Swift or Ocaml examples almost all of the underlying data structures and much of the networking stack are built in the respective language. This is not possible with Javascript, Python, Ruby etc. because it would be ludicrously slow and extremely memory inefficient.

Re:Strong typing, a hill I'm willing to die on by PH95VuimJjqBqy on Wednesday October 04, 2023 @12:57PM (#37768093)
I think what cracks me up about this conversation is that it's an almost verbatim repeat of a conversation I had on reddit a few weeks ago.

There's a certain segment of the developer population that I don't think realizes just how fast C and C++ are. Javascript is _relatively_ fast when compared to other dynamic languages, but not when compared to C, C++, FORTRAN, etc.

Re:Strong typing, a hill I'm willing to die on by da4c30ff on Wednesday October 04, 2023 @11:31AM (#37766617)
The take I have is that with a dynamically typed language you still have a static analysis step. It’s just that the analysis happens in your and other developers’ brain and it is objectively worse. I honestly can’t think of a single thing in favor of dynamic typing.

I write Clojure in my day job and it’s insane how often we have issues where it would have been immediately caught by a static type check.

Re:Strong typing, a hill I'm willing to die on by waffletower on Wednesday October 04, 2023 @11:50AM (#37766934)
May I interest you in some unmentioned static analyzer possibilities for Clojure: https://github.com/clj-kondo/clj-kondo https://github.com/jonase/eastwood You seem dissatisfied with Clojure in your day job -- I am sure that there are others that would be happier in your situation.
Re:Strong typing, a hill I'm willing to die on by da4c30ff on Wednesday October 04, 2023 @12:10PM (#37767249)
I'm aware of these, but thank you nevertheless. Clojure has plenty of nice things balancing the scales, so it's not all pain and misery!
Re:Strong typing, a hill I'm willing to die on by stefcoetzee on Wednesday October 04, 2023 @01:31PM (#37768659)
I'd love to learn more. Are you part of a large team (enterprise or SMB, whatever you can share)?

How have you experienced using Type Clojure, spec, Malli, etc. to determine correctness?

I've only worked on solo projects with Clojure, with most of it fitting into my head. I imagine with teams of size N > 1 things can change quite a bit.

Re:Strong typing, a hill I'm willing to die on by vasergen on Wednesday October 04, 2023 @12:37PM (#37767721)
> Javascript are still quite slow

Can you describe your usecase for which JavaScript is slow? There are many languages that are slower than js like python or elixir, but they are doing just fine, that's why I won't agree that js is slow, but sure there are cases for which js just wasn't designed, and any CPU intensive task will be slow, but there are ways to get around it as well.

Re:Strong typing, a hill I'm willing to die on by throw10920 on Wednesday October 04, 2023 @08:15PM (#37773409)
> Dynamic typing also makes a ton of optimizations basically impossible and even after monumental efforts languages like Javascript are still quite slow, inconsistent and memory inefficient outside of trivial benchmarks.

Please provide evidence for this extreme claim. I can point to benchmarks[1] where JavaScript is competitive with or even better than compiled static-typed languages like Java.

(any argument that those are "trivial benchmarks" is automatically invalid without actual empirical evidence)

[1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Re:Strong typing, a hill I'm willing to die on by jerf on Wednesday October 04, 2023 @10:12AM (#37765474)
There's a temporal component to the argument. Strong typing in the 1990s wasn't very good. Dogma at the time resulted in very rigid designs. The verbosity of it all was staggering. Incorrectly-used Hungarian notation ran rampant and made everything hard to read while still not helping anything [1]. The costs were a lot higher than it is today and the benefits a lot less.

Nowadays, the static typing is much nicer, with both higher benefits and lower costs, and it makes the costs/benefits analysis much more likely to come out in favor of static types.

In the late 1990s when I was cutting my teeth, I did a lot of Python, and I was almost 100% dynamic language until ~2015. In hindsight, I might do the same again even if thrust back in time. There just isn't a great static option back then. (I'm not saying 2015 is the year it became practical, I'm saying that's when I finally moved into static languages. 2010-2015 or so I was in Erlang, doing things that most other languages couldn't do at the time, so that forced me into a dynamic language. C# was looking pretty good in that time frame too, it just wouldn't have run the systems I had on anything like the resources I had at the time. It could probably easily do it in 2023 though.)

Now I even prototype in static systems, and it's a better experience than prototyping in Python was. Like, by quite a lot, honestly. In the end, I don't find it that much of an impediment to make sure that if I want to call a method on a thing, that the method actually exists.

Dynamic typing will never disappear; there's a certain small size of task for which it'll always be more advantageous than static typing, and while said tasks may be small, there's a lot more of them than there are large tasks, so it's a completely valid and sizable niche. But I do think over the next 10-20 years we're going to see the "scripting" languages return back to "scripting" and away from "systems".

I think that in the end, the dynamic scripting languages being used for large tasks will be seen as a reaction to a misdiagnosis of the problems in the 1990s. The code was atrocious in the 1990s not because it was statically typed, and therefore the solution is to go dynamically typed. The code was atrocious in the 1990s because it was poorly statically typed, and the solution was to get better. That said, "getting better" did take a long time, and for many legitimate reasons.

(Much ink is spilled on the so-called rapid pace of technological innovation in our industry, but programming languages move on decadal scales. Programming languages still have only barely grappled with a multicore world, and haven't grappled with a heterogenous computing world at all (GPUs on one end, efficiency cores on the other). Things are not always in as much motion as we fancy.)

[1]: Particularly, Hungarian notation is supposed to supplement the type, not just reiterate it. If you're in a language where you can't easily declare "a width is an int", then Hungarian notation suggests calling a width variable something like "wdthDialog", so that you stand a chance of noticing that you passed a "hghtDialog" in the wrong place. But the way it was used a lot of the time is you got "u16Width" instead, where u16 meant unsigned 16 bit int... but that's already in the type. Using it that way just adds an extra layer of hierglyphicness to the already ugly code. One of the several innovations that made static typing languages more feasible is that in most languages designed in the last couple of decades, you can declare something like this with something like "type Width int", and then you don't need to label any variables with it at all, the compiler enforces it.

Re:Strong typing, a hill I'm willing to die on by throw1234651234 on Wednesday October 04, 2023 @10:14AM (#37765510)
I think this is especially true for line of business applications that have the following qualities:

1. It's simple. Let's not lie, let's not pretend. It's CRUD. You can put in K8S, you can add AI, it can be behind an API Gateway, you can make it all Event Driven, you can use CQRS for every entity because you really, really want to feel clever. But it's still CRUD.

2. Other people are working on it, many other people.

3. People from other companies are interfacing with it.

So knowing what to expect trumps everything. Types help with that. They help a lot.

Re:Strong typing, a hill I'm willing to die on by stratigos on Wednesday October 04, 2023 @10:16AM (#37765530)
Unfortunately this attitude is not profitable, and also smacks of someone who works on their own island and costs a business more than they add value given their inability to work as a team. This attitude might find a way to be profitable when held by a university professor, though that does not mean its desirable.
Re:Strong typing, a hill I'm willing to die on by insanitybit on Wednesday October 04, 2023 @10:58AM (#37766138)
This is not a "work" attitude. I would never impose my opinions on a team. I've worked professionally in many languages with a variety of type systems. In virtually all cases I have reviewed very positive feedback throughout my career, in particular in terms of my ability to work well with others, to mentor, etc.
Re:Strong typing, a hill I'm willing to die on by WirelessGigabit on Wednesday October 04, 2023 @10:18AM (#37765572)
I actually like this approach. I believe in mentoring. I believe in building bridges. But if we're on opposite sides of the Grand Canyon, it's not worth my time.
Re:Strong typing, a hill I'm willing to die on by mpweiher on Wednesday October 04, 2023 @10:18AM (#37765580)
Well, getting this personal about a purely emotional preference might make people think less of a person that does that, with significantly better justification.

To be clear: people have tried to show the long-claimed safety benefits for a long time, and they just refuse to appear.

Re:Strong typing, a hill I'm willing to die on by AlchemistCamp on Wednesday October 04, 2023 @10:27AM (#37765710)
This is a very arrogant and dismissive attitude to take. Consider that both pg and DHH prefer dynamic typing. Maybe you can think less of them as devs, but what each built is undeniable.

What have you built or added to the field that justifies such a lack of tolerance of those who don’t subscribe to your point of view?

Re:Strong typing, a hill I'm willing to die on by insanitybit on Wednesday October 04, 2023 @10:57AM (#37766112)
I reject the idea that pg/DHH should be treated with any authority here, and I reject the idea that I need to prove my authority to you.

That said, yes, of course my post is arrogant and dismissive. I am outright saying I won't engage in a conversation. I'm comfortable with that.

Re:Strong typing, a hill I'm willing to die on by LaGrange on Thursday October 05, 2023 @06:12AM (#37776765)
> I am outright saying I won't engage in a conversation.

It's actually arrogant and dismissive because you say that in a way clearly intended to spark a conversation.

Also, pretty much all arguments for explicit typing suffer from mechanistic bias (see, https://www.youtube.com/watch?v=NmJsCaQTXiE&t=143s). I'm comfortable saying I just enjoy tinkering with a formal description of a data structure, because I'm a type enjoyer, not a type fan.

Re:Strong typing, a hill I'm willing to die on by insanitybit on Thursday October 05, 2023 @08:26AM (#37777690)
> It's actually arrogant and dismissive because you say that in a way clearly intended to spark a conversation.

I don't follow at all. Why would it be arrogant or dismissive to say something in an attempt to discuss it? I commented in good faith to an article that has a strong opinion ("willing to die on this hill") with a reflection of my own strong opinion ("unwilling to discuss").

At most you could say it was inflammatory, which wasn't intentional although looking at the insane number of child comments it apparently ways.

Re:Strong typing, a hill I'm willing to die on by nkozyra on Wednesday October 04, 2023 @10:30AM (#37765756)
I'm baffled it's even a debate. Who wouldn't want strong typing? What's the argument?
Re:Strong typing, a hill I'm willing to die on by digging on Wednesday October 04, 2023 @12:04PM (#37767181)
Mostly, it boils down to selfishness and "laziness". (Although I try to be very careful about that term, because I do not believe in it as generally used. I use it here to define: an unwillingness to plan ahead and to have to learn something new. Not applied as a global personality trait but only used in context.)
Re:Strong typing, a hill I'm willing to die on by pxmpxm on Thursday October 05, 2023 @08:28PM (#37785932)
These days you get loads of people without CS degrees that spend their days as python/js "coders" for things that don't really matter.
Re:Strong typing, a hill I'm willing to die on by zare_st on Wednesday October 04, 2023 @10:33AM (#37765771)
I'm not sure what I'm reading here.

Types are integral part of standard programming languages. If you mean "types bad" as in BASIC/Javascript variables, then yes I fully agree. These languages were never meant to be a solution for professional software engineering.

Once a language has proper types, it can be "weak typed" by not forcing "strong typing" by being dynamically typed in nature. If the language has normal preprocessor support, the static type system can be added on the project level. And then in essence you get a strong typed environment in a very thin programming language such as C.

Let's take a big C or C++ software project, the process behind it. Of course, the project is in those languages because it requires native opaque pointers and hardware access. The project has coding style, it has arbitrary rules. Although there is little to stop anyone from making a mess in C or C++ code there is entire code infrastructure and CI/CD chain around it. Lets say the rule is no void pointers without encompassing struct that's a type that can be checked via macro system. If you wrongly use the type struct, you get stopped by the project build. If you go around the rule, you get stopped by a code analysis after commit (and get in trouble for doing that).

Re:Strong typing, a hill I'm willing to die on by edem on Wednesday October 04, 2023 @10:42AM (#37765888)
Same here. Whenever someone starts babbling about why __language x__ is hard because of types or whatever, I just disengage. I don't care what anyone thinks about types. I use them, and I will keep using them no matter what.
Re:Strong typing, a hill I'm willing to die on by yowlingcat on Wednesday October 04, 2023 @10:42AM (#37765891)
> The amount of pre-existing respect for someone I'd need to have before I engage in a good-faith discussion on "are types good" is pretty high.

I think that says more about the strength of your zeal than of your argument.

Re:Strong typing, a hill I'm willing to die on by yetanotherasian on Wednesday October 04, 2023 @10:44AM (#37765929)
How often do you write bash scripts or do you always write all automation in some other language? Just curious how much your conviction influences your behavior
Re:Strong typing, a hill I'm willing to die on by bigstrat2003 on Wednesday October 04, 2023 @10:53AM (#37766042)
Speaking for myself, I never write bash scripts if I can help it (though sometimes I can't help it). That isn't so much because of typing, though... it's because bash is a fucking horrible language that should have died 30 years ago. The fact that there's no such thing as types in bash is just one of many reasons why it sucks to use.
Re:Strong typing, a hill I'm willing to die on by insanitybit on Wednesday October 04, 2023 @11:54AM (#37767016)
I write code without static types all the time. Daily probably. I am "pro types" in a hand wavy way. My conviction is to no longer engaging in the debate.
Re:Strong typing, a hill I'm willing to die on by scbrg on Wednesday October 04, 2023 @12:39PM (#37767766)
I'm glad to see that you've replaced debating type systems with debating debating type systems. I'm sure it's a great productivity improvement ;-P
Re:Strong typing, a hill I'm willing to die on by insanitybit on Wednesday October 04, 2023 @01:30PM (#37768646)
It's not like I've barred myself from engaging in any discussion where the word "type" shows up
Re:Strong typing, a hill I'm willing to die on by codegeek on Wednesday October 04, 2023 @10:45AM (#37765942)
I don't necessarily die on that hill but I definitely want to fight on that hill.
Re:Strong typing, a hill I'm willing to die on by nsajko on Wednesday October 04, 2023 @10:55AM (#37766068)
You're confusing static typing with the existence of a type system. As an example, Julia has a rich type system, but the language is dynamically typed.
Re:Strong typing, a hill I'm willing to die on by iopq on Wednesday October 04, 2023 @11:07AM (#37766278)
There's ONE argument that I'm partial to:

if you get the static type system wrong once, there's no going back

Take for example, Rust: mut, Send, Copy, Drop, Debug, dyn have all their warts because they are special and you can't fix them because you'll break previous code.

In a gradual typing language you could potentially bolt-on your own type system as a package where it just runs the type checker if you want one. It just so happens people who favor these gradual typing systems don't do a good job of creating those typing systems because they are not that into types in the first place.

But in theory, this kind of a system would let you not worry about types when prototyping the system, then put some bounds later based on your requirements.

Re:Strong typing, a hill I'm willing to die on by patrickthebold on Wednesday October 04, 2023 @11:11AM (#37766325)
I'm with you, especially in my professional life. That said, I think Clojure is interesting and Rich Hickey has some good talks in support of dynamic typing.
Re:Strong typing, a hill I'm willing to die on by TheBlight on Wednesday October 04, 2023 @11:11AM (#37766339)
Not really interested in discussing it. posted on discussion forum ;)
Re:Strong typing, a hill I'm willing to die on by JonChesterfield on Wednesday October 04, 2023 @11:13AM (#37766353)
It really matters which static type system is in question.

SML or Haskell? Yep, like those ones. The languages would not be so useful without their compile time type checking.

C? Not worth the trouble. C++? Not worth the tarpit or the trouble.

Python? Definitely not keen, that language was much better without the annotations.

Typescript people really like but I haven't played with. I'm pleasantly surprised that unsound static + sound dynamic works well.

Type annotations are not inherently good. Some type systems add a lot of value, some really don't.

Re:Strong typing, a hill I'm willing to die on by xigoi on Wednesday October 04, 2023 @11:44AM (#37766855)
> C? Not worth the trouble. C++? Not worth the tarpit or the trouble.

The OP said strong static type system, so C and C++ are out of the question.

Re:Strong typing, a hill I'm willing to die on by chongli on Wednesday October 04, 2023 @11:52AM (#37766986)
This is not about type annotations, it’s about type systems. You can write Haskell programs without any type annotations. Your program will type check and compile just fine. The value comes from the checks (as well as the inference, documentation, optimization, and everything else a modern type system gives you), which you don’t have to write yourself, you get them for free.

People who say they prefer dynamic languages are really just saying ‘no’ to all these free benefits.

Re:Strong typing, a hill I'm willing to die on by JonChesterfield on Wednesday October 04, 2023 @12:12PM (#37767285)
If your language is wholly type inferred, and the type system is expressive enough to deal with whatever one wishes to write, it is indeed "free". If you ignore compile time performance, run time performance, and that you're writing in something between Idris and vapourware.

Otherwise the cost is merely being unable to write anything that the type checker does not understand, and however long your compiler takes to do the checks on what it does understand.

Also a fair chance the whole program must type check before you can see the results of changing a subset. In the worst case you get to hunt down all the unused variables before it'll run the test suite.

I prefer dynamic languages. That makes me a heathen on these boards, to be ignored or chastised for my stupidity. Regardless, those benefits do not come for free.

Re:Strong typing, a hill I'm willing to die on by WJW on Wednesday October 04, 2023 @12:16PM (#37767348)
Even though I usually fall more on the "types good" side of the discussion, the advantages you listed are not free at all. They come at the cost of at least:

- having a compile step in between writing and running your code. This drastically slows down the feedback loop of development. The more your compiler has to check for you, the slower it gets.

- being able to run your program in a half-broken state. This may not seem like much of an advantage, but sometimes it is good to just be able to run a broken piece of code to see how it crashes. This is especially important when learning to program, but is still very beneficial when learning a new language or framework, or sometimes for debugging.

- As someone who has contributed to the main Haskell compiler, I can definitely confirm that a more complicated type system can slow down development of the language itself too. It takes significantly more effort to grok all the possible interactions as the codebase of the compiler grows.

Don't get me wrong, I think encoding and enforcing program properties with types is a great idea that will grow further in the future. But the dynamic languages gained popularity for good reasons, and some of those reasons are still valid today.

Re:Strong typing, a hill I'm willing to die on by ActorNightly on Wednesday October 04, 2023 @01:14PM (#37768368)
>SML or Haskell? Yep, like those ones

Not strong enough.

If you are proponent of strong typing, you need something that is effectively a theorem prover. I.e when you define a type, you define the scope of the data it can hold, operations on that data, and the resultant types of those operations. That way, when you code compiles, it is by definition "correct".

When you accept anything less then that, you are basically making a statement that you are willing to forgo some of that correctness for convenience, which is fine, but that means that no language out there is really good or bad.

Re:Strong typing, a hill I'm willing to die on by DonaldPShimoda on Wednesday October 04, 2023 @01:27PM (#37768597)
Theorem provers' type systems are not necessarily stronger than SML's or Haskell's; they are more expressive, which is a separate thing entirely.

That said, your position is also just weird to me. Yes, theorem provers have nice type systems that are wonderfully expressive. The trade-off is that some common programming patterns become difficult to use or are even impossible.

When it comes to everyday programming, I don't think theorem provers are at a point where they are particularly useful. Not everything needs to be proved formally, and I don't think this position is at odds with the belief that static type systems are generally "better" than dynamic ones.

Re:Strong typing, a hill I'm willing to die on by ActorNightly on Wednesday October 04, 2023 @02:49PM (#37769809)
> The trade-off is that some common programming patterns become difficult to use or are even impossible.

Not really. Strong and expressive typing at its core is simply creating data packaging containers that have defined operations on them. It says nothing about logic. You may be referring to the functional programming aspect that comes with strong typed languages, which is related but not the same as strong typing.

The point is that typing is just a tool that a programer can use, whether its built into the language or ran statically like MyPy. You can take a piece of code in C, and write a test suite on input and output of that piece of code, and accomplish much of the same thing that typing accomplishes. However, in the case of strict+explicit typing, the idea is that you wouldn't need tests in the first place, because your code would be correct by nature of compilation.

Re:Strong typing, a hill I'm willing to die on by DonaldPShimoda on Wednesday October 04, 2023 @03:36PM (#37770455)
No, you are wrong.

Some theorem provers, such as Coq, are not Turing-complete. This means you cannot write some programs, and in particular you cannot write infinite loops in Coq. Infinite loops are a common pattern (e.g., a REPL or a GUI display waiting for input).

This is a trade-off, as I said. You gain the expressive type system, but lose the ability to implement certain programming patterns. It has nothing to do with the strength of the type system.

---

> whether its built into the language or ran statically like MyPy.

All (true) type-checking is static, so MyPy "running statically" is not a noteworthy feature to distinguish it from other type checkers. I guess this point may seem trivial to some, but the broader context of this conversation involves conflation of the terms "static type system" and "strong type system", so your misuse of the word "statically" here seems worth pointing out.

That said, whether you use an external tool to check your types or the type-checker is built into the compiler is irrelevant, and I'm not sure why you brought it up at all.

---

> You can take a piece of code in C, and write a test suite on input and output of that piece of code, and accomplish much of the same thing that typing accomplishes.

Depending on the perspective, this is factually incorrect.

Type-checking is an ahead-of-time operation that guarantees the absence of certain classes of errors at run-time. Writing tests to check for the absence of such errors is not equivalent, because you have not proved anything; you merely gain confidence. They are semantically distinct, even if you write many tests to gain a lot of confidence.

Re:Strong typing, a hill I'm willing to die on by ActorNightly on Wednesday October 04, 2023 @04:14PM (#37771032)
>Some theorem provers, such as Coq, are not Turing-complete. This means you cannot write some programs, and in particular you cannot write infinite loops in Coq.

You are talking about languages, Im talking about the concept. The modern theorem provers aren't up to the task. Due to Rices theorem, you cannot "fully prove" a program, so a language that does this couldn't even exist. The strict typing however can be applied to subsets of the programming space, namely the data processing pipeline, whereas higher level stuff like the actual server code that does have an infinite loop to listen to requests can be written in whatever.

The point is that no language recommended for strong type safety today is anywhere fully complete to include the rigor of something like a theorem prover, and anything less then that is basically your own opinion on what is "good enough".

>Type-checking is an ahead-of-time operation that guarantees the absence of certain classes of errors at run-time.

Run time errors are no different than compile time errors as far as testing is concerned. Its not like the computer blows up when you have a seg fault. And you absolutely can prove what you need for operation.

Say your input to your code is an HTTP request of length x. And output is some data processing on that request. You can write a test suite that is basically like this

1. Ensure that code returns a well defined error for x values outside of given range.

2. For all valid ranges in x, test all possible values of every byte in that range, and ensure correct behaviour.

While overkill, this will absolutely exercise every single piece of your code and prove correctness. You can also couple this with checking things like memory access

Re:Strong typing, a hill I'm willing to die on by JonChesterfield on Wednesday October 04, 2023 @05:26PM (#37772022)
SML is good enough for theorem proving. That's what it was written for. Though you probably want convenience libraries on top, maybe the one called HOL.
Re:Strong typing, a hill I'm willing to die on by yxhuvud on Wednesday October 04, 2023 @02:38PM (#37769652)
100% this. Developer experience in a language is a so much bigger question than if it has static types or not.
Re:Strong typing, a hill I'm willing to die on by sbjs on Wednesday October 04, 2023 @11:13AM (#37766366)
Yeah I've been in that camp since like 2016. TypeScript is basically an essential for me now, and I don't debate it with anyone. If they don't get it, it just gives me a baseline understanding of how little experience they have in real world software development.
Re:Strong typing, a hill I'm willing to die on by Rapzid on Thursday October 05, 2023 @10:52AM (#37779362)
That's a good year; TS had just added async/await.
Re:Strong typing, a hill I'm willing to die on by oweiler on Wednesday October 04, 2023 @11:15AM (#37766397)
God, what has become of healthy discussions? People getting more and more toxic these days...
Re:Strong typing, a hill I'm willing to die on by insanitybit on Wednesday October 04, 2023 @11:58AM (#37767078)
I'm all for healthy discussions, but I think it's fair to say "I've had this discussion enough times, unless you're really bringing something new to the table, I'm opting out".
Re:Strong typing, a hill I'm willing to die on by digging on Wednesday October 04, 2023 @12:00PM (#37767121)
Is it really a healthy discussion? At least with respect to JS vs TS (which is the most common argument as it's a choice every front end team has to make), it's blogs saying "fuck types, I like JS only." I'm not going to step in and tell another team what to use but whining about the difficulty of static typing is just not a productive conversation. I've been converted by the top level comment; I'm not longer interested in entertaining the discussion.
Re:Strong typing, a hill I'm willing to die on by bcrosby95 on Wednesday October 04, 2023 @11:21AM (#37766476)
I don't use dynamically typed languages because they're dynamically typed. I use them for other reasons and they happen to be dynamically typed.

I'm not going to argue that these features are only possible because of dynamic typing, but regardless, statically typed languages tend not to have them.

Elixir may get "some form" of typing, but it likely won't be traditional static typing.

Re:Strong typing, a hill I'm willing to die on by syndicatedjelly on Wednesday October 04, 2023 @11:43AM (#37766824)
What are those features?
Re:Strong typing, a hill I'm willing to die on by bcrosby95 on Wednesday October 04, 2023 @12:10PM (#37767258)
STM, REPL, and data driven nature of Clojure. I know most people don't use STM in Clojure, but I find it to be a killer feature for some projects. Combined with pervasive immutability and it enables concurrent designs that are very difficult to pull off in other languages.

For Elixir, the concurrency model and supervisor trees. It's a perfect fit for some problems, and in general as a small company, the projects we use Elixir on greatly simplifies our production environment which is always a win.

Most of my focus when designing a project is to enable people with less experience than me to contribute in a bug-free fashion in the face of concurrency and parallelism. Sometimes that involves picking a funny language, sometimes it doesn't.

Re:Strong typing, a hill I'm willing to die on by optymizer on Wednesday October 04, 2023 @11:27AM (#37766569)
I find it interesting that people in this thread seem to have absolute certainty that "types good" is true, while to me those two words together are largely non-sensical, just like "bytes good" wouldn't make much sense to debate.
Re:Strong typing, a hill I'm willing to die on by prewett on Wednesday October 04, 2023 @12:18PM (#37767371)
After you repeatedly waste a bunch of time debugging things that static typing would have caught on the first compile, and you start developing a "types good" attitude. If you just do simple React development, you might not ever run into the problem. But once your programs get to a couple thousand lines, you start occasionally forgetting what your function takes and passing in the wrong things, which then get passed around for a while and throw an exception long after the problem happened. This results in very unfun print-debugging, particularly in a recursive descent parser or an algorithm that processes a lot of data.
Re:Strong typing, a hill I'm willing to die on by leptons on Wednesday October 04, 2023 @01:28PM (#37768616)
>But once your programs get to a couple thousand lines, you start occasionally forgetting what your function takes and passing in the wrong things, which then get passed around for a while and throw an exception long after the problem happened.

I've been writing code for 40 years, I can't estimate how many loc I've written, but likely over a million. One of my personal projects is currently over 65k loc vanilla js, and I never once had a problem with not knowing what type a function took. If you're so bad at naming things and knowing what a function does, I guess maybe types can help you. But not everyone needs it.

Re:Strong typing, a hill I'm willing to die on by optymizer on Wednesday October 04, 2023 @02:12PM (#37769301)
I'll take the time to reply to both of you, because you seem to have opposing views.

I think such a debate is largely unproductive. Like anything else, types have value (ha) and successfully capitalizing on that value depends on the context of the project, which includes things like developer experience, tooling, project complexity, requirements, deadlines etc.

The only productive outcome of these debates is that each developer gets to slowly and frustratingly build a list of pros and cons as they go through the arguments presented by either side debating this topic. In addition, developers who completely disregard either the cons or the pros are necessarily making subjective decisions with incomplete data, and the project gets to pay the price. Just because the developer is personally OK with all of their projects paying that price, doesn't mean it's the best decision for a project.

My experience has been that when starting out, projects get the most value out of not having types, and as they grow in scope and size, and the cons of not having types start creeping up, that's the point when gradually transitioning the code to being strongly typed allows the project to maintain its velocity _and_ quality.

Re:Strong typing, a hill I'm willing to die on by flohofwoe on Wednesday October 04, 2023 @11:41AM (#37766799)
So... about the strong part in 'strong static typing':

Many years ago I thought that it's a good idea for a game math library to have separate strong types for 'point' (a location in 3D space) and 'vector' (a direction and magnitude in 3D space), and allow/disallow certain operations (e.g. 'point + vector => point' 'vector + vector => vector', 'point - point => vector', while 'point + point' is illegal).

Sounds absolutely great in theory, but in practice it was a royal PITA to work with, but it took me much too long to realize this (how can it be such a hassle when in theory it's such a good idea!)

I soon went back to a general 4D vector class (where a 'point' is defined by .w = 1.0, and a 'vector' by .w = 0.0), and some debug-mode runtime validation (which catches things like trying to add a point to a point).

Of course strong typing also often makes perfect sense, for instance in a 3D rendering API it should be a compilation error to provide a texture-handle where a buffer-handle is expected, but after this experience with points vs vectors (which should've been a classic showcase for strong typing) I would never again "die on that hill" :)

TL;DR: static typing: yes! strong typing: it depends.

Re:Strong typing, a hill I'm willing to die on by Someone on Wednesday October 04, 2023 @12:02PM (#37767154)
> For things like kilometers versus hours I'm still undecided.

Those help you more if you do a lot of math involving both them, but that’s also when it becomes a nightmare in most programming languages because of an explosion in the number of types.

Let’s say your code computes

  3km × 4hours
If so, you need a “km hour” type.

In many languages, you also have to write code to make that happen, and to make it have the same type as

  4hours × 3km
Even if you don’t ever store values with those types in variables, you also may need types for per km, per hour, km² and hour² for expressing the types of intermediate values (for example, in a physics computation, you may encounter √(3km²/4hour² to compute a velocity in km/hour)

And that’s ignoring that you may

- encounter minutes, meters, yards, etc.

- want to use algorithms that compute exp(3km) or log(4hours). What types do these have? Here, you probably want to forget about string typing values.

Re:Strong typing, a hill I'm willing to die on by flohofwoe on Wednesday October 04, 2023 @12:19PM (#37767397)
Apologies, I edited my post while you wrote your reply and removed the kilometers vs hours thing. But your reply makes perfect sense, and I think this "type explosion" is my main gripe with too extremist strong typing.
Re:Strong typing, a hill I'm willing to die on by sneed_chucker on Wednesday October 04, 2023 @01:13PM (#37768345)
That's not a shortcoming of strong or static typing, that's just you realizing that your initial data model was flawed and that you either needed to unify them into a single type (like you did) or utilize an abstract class/interface.

The good thing about stricter typing systems is that it forces you to handle all the cases when you're doing a refactor like this before it compiles.

When changes to the data model happen in large codebases of dynamic code, it frequently gets shipped in a non complete state and turns into a production runtime error later down the line.

Re:Strong typing, a hill I'm willing to die on by waffletower on Wednesday October 04, 2023 @11:42AM (#37766814)
In my country, the United States, we have broad protections for religious beliefs.
Re:Strong typing, a hill I'm willing to die on by scarythrowaway on Wednesday October 04, 2023 @12:15PM (#37767331)
I mean, that's one reason I like dynamic typing, I get to avoid a bunch of psycho cargo culters for free.

cries at the thought of insanitybit not respecting me

Re:Strong typing, a hill I'm willing to die on by thefaux on Wednesday October 04, 2023 @12:23PM (#37767473)
> If you don't get it I probably don't want to talk to you about it, I might even think less of you as a software developer.

The feeling is mutual.

Re:Strong typing, a hill I'm willing to die on by fargle on Wednesday October 04, 2023 @12:36PM (#37767713)
and yet... here you are discussing it. ;)

discussions are a two-way street. if you aren't getting it, then how do you expect someone else to "get" your position?

    "The whole problem with the world is that fools and fanatics are always so certain of themselves, and wiser people so full of doubts"
-- Bertrand Russell

[edit: To clarify, i am on the "i like strong static typing most of the time but also understand their pros/cons wrt. dynamic languages" side of things]

Re:Strong typing, a hill I'm willing to die on by lasermike026 on Wednesday October 04, 2023 @12:38PM (#37767742)
Understand that there is no hope. You will die on that hill. Get over it.
Re:Strong typing, a hill I'm willing to die on by leptons on Wednesday October 04, 2023 @01:17PM (#37768414)
Trigger warning: I love to write assembly language.

I probably love assembly language more than C#, or C++, or any of the strongly typed languages I use.

Assembly language has no types. It doesn't pretend types even exist.

Are you going to look down on me because I like to write assembly language?

Re:Strong typing, a hill I'm willing to die on by insanitybit on Thursday October 05, 2023 @08:27AM (#37777699)
> Are you going to look down on me because I like to write assembly language?

Nope.

Re:Strong typing, a hill I'm willing to die on by ActorNightly on Wednesday October 04, 2023 @01:45PM (#37768903)
Here is a fun fact that you don't realize.

Say you can do the project in 2 ways.

First way is to use a strongly typed language, think about the data, and design your code in the appropriate way. You code it up, go through the loop of compiling and fixing errors, and get your code to run.

The second way is to write your code in Python, without worrying about strong types. You complete the code quite a bit faster, but since you also want your code to be correct, you spend time writing an end to end test suit for your code.

The second approach is not only faster (since you are writing tests in both cases), its overall better. Spending time writing tests allows you to essentially validate things that modern mainstream strongly typed languages can't catch at compile time (for example, what happens when the input is unicode strings?). It also forces you to think about end to end behavior and making sure that is correct, rather than just the behavior within your code.

Strong typing is a simply hand-holding tool for programmers. If you cannot write correct code without it, you are on a fast track to being replaced by AI eventually. The future of programming is not going to be designing data structures and types, its going to be using English to generate large chunks of code in most likely Python, and then tweak fine details in those.

Re:Strong typing, a hill I'm willing to die on by cjfd on Wednesday October 04, 2023 @02:39PM (#37769671)
I think this is completely false. It completely breaks down as soon as you get into your first refactoring that is a bit larger than completely trivial. Typically the mess one ends up is one or more of the following. (1) Nothing is refactored because people do not dare to do it. (2) Not just some but most of the uncommon code paths are broken. (3) Tools that are used to interact with a running application are regularly in a broken state. You want to prevent these problems with 100% test coverage. As such this may be a laudable goal on occasion but I do notice that the code described in (2) and (3) are highly non-trivial to cover 100%. I also have to wonder what mythical developer is does not have the discipline to use static typing but does have the discipline to attain 100% code coverage. I first want to see such a developer before I believe in his/her existence.
Re:Strong typing, a hill I'm willing to die on by ActorNightly on Wednesday October 04, 2023 @02:52PM (#37769861)
>It completely breaks down as soon as you get into your first refactoring that is a bit larger than completely trivial.

This is, in fact, MUCH easier to do with a strong test suite that only cares about input and output rather than internals.

The most common approach to starting a refactoring project is write or enhance a test suite to the point where there is no undefined behavior, either the program works or handles the appropriate errors.

You don't need to aim for 100% test coverage either, you just need your tests to cover all possible inputs (including fuzzing).

Re:Strong typing, a hill I'm willing to die on by gdcbe on Wednesday October 04, 2023 @01:51PM (#37769000)
Call me sceptical, but I don’t buy it. What makes you certain that’s the (one) future… Also programming is a super broad field, and more then a field is almost more like a medium then a field.

I honestly don’t know if we’ll still program by hand or not, but I do look skeptical at people who are very certain we won’t. Don’t think that’s the first time in history people make that prediction…

Re:Strong typing, a hill I'm willing to die on by ActorNightly on Wednesday October 04, 2023 @03:16PM (#37770177)
Compilation at its core is a translation problem. Right now, it would be fairly trivial to train an LLM to essentially be a compiler. And, you can already prompt LLMs on generating code for a wide array of things.

As far as adoption, there is a reason why dynamic type languages that feature a lot more natural syntax (Node, Python) are used WAY more than others.

Re:Strong typing, a hill I'm willing to die on by jghn on Wednesday October 04, 2023 @02:03PM (#37769164)
Using your example - have a type that that enforces Unicode strings (or vice versa)
Re:Strong typing, a hill I'm willing to die on by _dain_ on Wednesday October 04, 2023 @02:08PM (#37769247)
why can't I write it in a statically-typed language and also write end-to-end tests?

also it's pretty ridiculous to say "static type systems are handholding" and then say the remedy is to write your code with AI ..

Re:Strong typing, a hill I'm willing to die on by ActorNightly on Wednesday October 04, 2023 @02:54PM (#37769897)
You can, but the reason you do this in practice is because the static typing languages are often not sufficient or strong enough. And if you are writing tests, you may as well do everything through testing and focus on rapid dev rather than worrying about types.
Re:Strong typing, a hill I'm willing to die on by gwervc on Wednesday October 04, 2023 @04:55PM (#37771650)
Except the kind of people "saving time" writing in a dynamic language will skip the step of writing tests as well since it can be viewed as lost time.
Re:Strong typing, a hill I'm willing to die on by brightball on Wednesday October 04, 2023 @01:55PM (#37769063)
I'm firmly in camp "it depends" but it was nice almost talking to you. :-)
Re:Strong typing, a hill I'm willing to die on by auggierose on Wednesday October 04, 2023 @02:02PM (#37769155)
I don't know, that is so last millennium. If you prove your software correct, you won't need a static type system, it just gets in your way. And that's a hill I am willing to die on.
Re:Strong typing, a hill I'm willing to die on by RHSeeger on Wednesday October 04, 2023 @02:03PM (#37769176)
Sometimes the question isn't "are types good", it's "are the costs associated with static types worth it for this particular use case". And the answer is almost always yes; but the "almost" there is important.
Re:Strong typing, a hill I'm willing to die on by manicennui on Wednesday October 04, 2023 @02:14PM (#37769327)
This is the sort of position that is baffling to me. Software engineers claim to be very logical, but this boils down to a preference being stated as some kind of objective truth. Show the evidence (not anecdotes) that static typing gives benefits that are worth the cost. My anecdotal evidence is that I rarely come across problems in production code that would be solved by static typing and people make the same sorts of logic mistakes in languages like Java and Typescript.
Re:Strong typing, a hill I'm willing to die on by manicennui on Wednesday October 04, 2023 @02:15PM (#37769349)
Arguably, nullability and mutability are issues that cause far, far more issues than dynamic typing.
Re:Strong typing, a hill I'm willing to die on by tubthumper8 on Wednesday October 04, 2023 @05:17PM (#37771930)
Null reference errors are examples of errors that can be caught before runtime by a static type system. The fact that static type systems like Java don't catch this is evidence that static vs. dynamic is not a binary - some static type systems are better than others.
Re:Strong typing, a hill I'm willing to die on by asdajksah2123 on Wednesday October 04, 2023 @02:16PM (#37769365)
I think the conversation becomes a lot easier once you recognize that there is no such thing as untyped data.

There's only explicit typing and implicit typing.

So the only real argument you're having with someone is when writing a piece of code, do they want the caller of the code or the input of the code's data type to be known or they want the data type to be a mystery to be figured out, occasionally in production when shit hits the fan.

Re:Strong typing, a hill I'm willing to die on by throw10920 on Wednesday October 04, 2023 @08:02PM (#37773339)
> I reject the idea that pg/DHH should be treated with any authority here, and I reject the idea that I need to prove my authority to you.

> That said, yes, of course my post is arrogant and dismissive. I am outright saying I won't engage in a conversation. I'm comfortable with that.

This is an extremely toxic attitude. I wouldn't be interested in working with you in any professional capacity, on an open-source project, or having you as a friend, and as a matter of fact if someone expressed this attitude at work I would complain to HR.