this post was submitted on 19 Jun 2025
41 points (97.7% liked)

Programming

21183 readers
342 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
 

Summary by Dan Luu on the question about whether for statically typed languages, objective advantages (like having measurably fewer bugs, or solving problems in measurably less time) can be shown.

If I think about this, authors of statically typed languages in general at their beginning might not even have claimed that they have such advantages. Originally, the objective advantage was that for computers like a PDP11 - which had initially only 4 K of memory and a 16-bit adress space - was that something like C or Pascal compilers could run on them at all, and even later C programs were much faster than Lisp programs of that time. At that time, it was also considered an attribute of the programming language whether code was compiled to machine instructions or interpreted.

Todays, with JIT compilation like in Java and the best implementation of Common Lisp like SBCL being at a stone's throw of the performance of Java programs, this distinction is not so much relevant any more.

Further, opinions might have been biased by comparing C to memory-safe languages, in other words, when there were perceived actual productivity gains, the causes might have been confused.

The thing which seems more or less firm ground is that the less lines of code you need to write to cover a requirement, the fewer bugs it will have. So more concise/expressive languages do have an advantage.

There are people which have looked at all the program samples in the above linked benchmark game and have compared run-time performamce and size of the source code. This leads to interesting and sometimes really unintuitive insights - there are in fact large differences between code sizes for the same task between programming languages, and a couple of different languages like Scala, JavaScript, Racket(PLT Scheme) and Lua come out quite well for the ratio of size and performance.

But given all this, how can one assess productivity, or the time to get from definition of a task to a working program, at all?

And the same kind of questions arise for testing. Most people would agree nowadays that automated tests are worth their effort, that they improve quality / shorten the time to get something working / lead to fewer bugs. (A modern version of the Joel Test might have automated testing included, but, spoiler: >!Joel's list does not contain it.!<)

Testing in small units also interacts positively with a "pure", side-effect-free, or 'functional' programming style... with the caveat perhaps that this style might push complex I/O functions of a program to its periphery.

It feels more solid to have a complex program covered by tests, yes, but how can this be confirmed in an objective way? And if it can, for which kind of software is this valid? Are the same methodologies adequate for web programming as for industrial embedded devices or a text editor?

top 50 comments
sorted by: hot top controversial new old
[–] sxan@midwest.social 21 points 1 week ago (9 children)

An indisputable fact is that static typing and compilation virtually eliminate an entire class of runtime bugs that plague dynamically typed languages, and it's not an insignificant class.

If you add a type checker to a dynamically typed language, you've re-invented a strongly typed, compiled language without adding any of the low hanging fruit gains of compiling.

Studies are important and informative; however, it's really hard to fight against the Monte Carlo evidence of 60-ish years of organic evolution: there's a reason why statically typed languages are considered more reliable and fast - it's because they are. There isn't some conspiracy to suppress Lisp.

[–] HaraldvonBlauzahn@feddit.org 2 points 1 week ago (1 children)

you've re-invented a strongly typed, compiled language without adding any of the low hanging fruit gains of compiling.

This is aside from the main argument around static typing which claims advantages in developer productivity and eventual correctness of code.

Now, I think it is generally accepted that compilation with the help of static typing enables compilation to native code which leads to faster executables.

Now, did you know that sevral good Lisp and Scheme implementations like SBCL, Chez Scheme or Racket compile to native code, even when they are dynamically typed languages? This is done by type inference.

And the argument is not that these are as fast as C or Rust - the argument is that the difference might be significantly smaller than what many people believe.

[–] sxan@midwest.social 4 points 1 week ago (9 children)

Now, did you know that sevral good Lisp and Scheme implementations like SBCL, Chez Scheme or Racket compile to native code, even when they are dynamically typed languages? This is done by type inference.

Compiled or not, inferred or not (Go has type inference; most modern, compiled languages do), the importance of strong typing is that it detects typing errors at compile time, not at run time. Pushing inference into the compile phase also has performance benefits. If a program does type checking in advance of execution, it is by definition strongly typed.

load more comments (9 replies)
load more comments (8 replies)
[–] TehPers@beehaw.org 8 points 1 week ago (15 children)

Honestly I'm surprised this is even still discussion. I plan to read this, but who out there is arguing against static typecheckers? And yes, I know it's probably the verifiable NPCs on Twitter.

[–] BatmanAoD@programming.dev 6 points 1 week ago* (last edited 1 week ago) (1 children)

Notably, this article is from 2014.

[–] TehPers@beehaw.org 2 points 1 week ago

Thanks. I couldn't find a date on it.

[–] FizzyOrange@programming.dev 2 points 1 week ago (11 children)

You'd be surprised. Every time I try to introduce static type hints to Python code at work there are some weirdos that think it's a bad idea.

I think a lot of the time it's people using Vim or Emacs or whatever so they don't see half the benefits.

load more comments (11 replies)
load more comments (13 replies)
[–] verstra@programming.dev 8 points 1 week ago (9 children)

My conclusion is that it is hard to empirically prove that "static type systems improve developer productivity" or "STS reduce number of bugs" or any similar claim. Not because it looks like it is not true, but because it is hard to control for the many factors that influence these variables.

Regardless of anyone's opinion on static/dynamic, I think we still must call this an "open question".

load more comments (9 replies)
[–] Ephera@lemmy.ml 7 points 1 week ago (2 children)

It feels more solid to have a complex program covered by tests, yes, but how can this be confirmed in an objective way? And if it can, for which kind of software is this valid? Are the same methodologies adequate for web programming as for industrial embedded devices or a text editor?

Worth noting here that tests should primarily serve as a (self-checking) specification, i.e. documentation for what the code is supposed to do.
The more competent your type checking is and the better the abstractions are, the less you need to rely on tests to find bugs in the initial version of the code. You might be able to write code, fix the compiler errors and then just have working code (assuming your assumptions match reality). You don't strictly need tests for that.

But you do need tests to document what the intended behaviour is and conversely which behaviours are merely accidental, so that you can still change the code after your initial working version.
In particular, tests also check the intended behaviour of all the code parts you might not have realized you've changed, so that you don't need to understand the entire codebase every time you want to make a small change.

[–] HaraldvonBlauzahn@feddit.org 3 points 1 week ago* (last edited 1 week ago) (1 children)

In my experience, tests can be a useful complement to specifications but they do not substitute them - especially, specs can give a bigger picture and cover corner cases more succintly.

And there are many things that tests can check which the respective type systems can't catch. For example, one can easily add assertions in C++ which verify that functions are not called in a thread-unsafe way, and tests can check them.

load more comments (1 replies)
[–] PolarKraken@programming.dev 2 points 1 week ago

That's a useful way to look at it, as verbose / extended documentation (amounts to exhaustive usage examples, if you've got thorough tests).

I don't have a metric that's quick to relate, but for me the...attractiveness or value in testing relates heavily to:

  • Project lifecycle - longer and slower -> more tests
  • Team size (really more like 1st derivative of team size...team "churn"?) - larger, changing faster -> more tests

Both of these are influenced by your description of tests as docs. Onboarding new engineers is way, way easier with thorough tests, for the reasons you've mentioned. Plus it reduces that "gun shy" factor about making changes in a new codebase.

But it's not always better. I've been writing less (few, honestly) the last year or so, sadly.

[–] BatmanAoD@programming.dev 6 points 1 week ago (7 children)

Note that this post is from 2014.

load more comments (7 replies)
[–] verstra@programming.dev 2 points 1 week ago (1 children)

Will read, looks interesting and I already agree with the premise but,

please people, add metadata (date, author, institution) and a bit of formatting to your pages. Not much, 10 lines of global CSS would help already.

[–] verstra@programming.dev 2 points 1 week ago

Or post to gemini instead

[–] luciole@beehaw.org 2 points 1 week ago (1 children)

I know far too little about compilers & interpreters to have anything to say about performance so I’ll leave that subject to wiser programmers.

What I can say about the usage itself of dynamically vs statically typed languages is that I struggle with assessments that attempt to quantify the differences between the two paradigms. I’ve come to consider programming has a craft, and as such the qualitative properties of the tools, and especially the languages, matter significantly.

I’ve been switching back and forth between dynamic and static languages lately. Although dynamic languages do feel more straight to the point, static languages are easier to navigate through. All that typing information can be harnessed by intellisense and empower the non-linear reading needed to understand a program. That’s valuable for the whole life cycle of the software, not just the time to reach initial release. It’s kind of a rigid vs fluid dichotomy.

[–] HaraldvonBlauzahn@feddit.org 2 points 1 week ago (1 children)

There are also in-between approaches. Python for example has optional typing (for type checks with mypy), whereas Lisp/SBCL allows type hints for performance. Racket and Clojure allow to add types as pre-conditions (Typed Racket and Clojure Soec).

And many modern languages like Scala or Rust mostly need types in the function signature - the rest of the time, types are usually inferred. Even languages which were rigorously typed in the past, like C++, have the auto keyword added which activates type inference.

[–] luciole@beehaw.org 2 points 1 week ago (1 children)

Oh I love it when the language has advanced type inference! I have fond memories of tinkering with Haxe.

[–] verstra@programming.dev 2 points 1 week ago (1 children)

Hindley-milner type inference for the win!

It's hard to implement, but the result is a statically typed language, mostly without type annotations.

load more comments (1 replies)
[–] tetrislife@leminal.space 2 points 1 week ago (1 children)

Thanks for posting this! That blogsite is always very productive reading.

I don't get the obsession with the scientific method. Movie quote: "we don't live in the courtroom, your Honor; do we?". You can eliminate outliers like experts and students, hobby projects and lives-at-stake projects; everything you are left with is a good reflection of the industry. Example: any study with Java versus Python has to count.

I have no real experience with dynamic languages, so I can understand where the blog responses about dynamic languages having extra bugs come from. But they miss the important point about dynamic languages allowing for non-trivial solutions in fewer lines of code - matching that would basically need to be implemented in the static language, with the accompanying code bloat, under-implementation, bugginess, etc.

I think the reference to 0install's porting is real experience of the difference between Python and OCaml. Caveat: author Thomas Leonard is a seriously expert practitioner.

[–] HaraldvonBlauzahn@feddit.org 5 points 1 week ago (5 children)

I don't get the obsession with the scientific method.

Because actually knowing and understanding something is better than believing stuff. There is a lot of stuff that sounds plausible but is wrong.

load more comments (5 replies)
load more comments
view more: next ›