Static vs Dynamic Typing

The cluster debates the merits of static typing for catching errors at compile time versus dynamic typing's runtime checks, focusing on safety, debugging, and bug prevention in programming languages.

➡️ Stable 0.5x Programming Languages
4,088
Comments
20
Years Active
5
Top Authors
#4373
Topic ID

Activity Over Time

2007
2
2008
3
2009
35
2010
40
2011
66
2012
106
2013
119
2014
227
2015
205
2016
259
2017
330
2018
257
2019
318
2020
310
2021
370
2022
397
2023
362
2024
280
2025
380
2026
22

Keywords

TypeScript ycombinator.com OK CI IDE i.e PL E.g TypeError runtime type static errors typing static typing type checking checking types compile

Sample Comments

simooooo • Aug 27, 2018 • View on HN

Your point doesn't make sense... you talk about the weakness of not being type checked, then say it's ok because that happens at runtime?

brianwawok • Oct 14, 2016 • View on HN

Could you explain how static typing makes less safe programs?

CmonDev • Jul 30, 2015 • View on HN

As compact. Most of type errors will shift to compile time, instead of blowing during runtime. Profit.

ReflectedImage • Feb 2, 2023 • View on HN

That not a bug that static typing would catch as it is not a type bug.

zaphar • Dec 12, 2017 • View on HN

Runtime type checking while useful does not offer the same level of safety as compiler time. It will catch sinner classes of errors but you'll still have bugs lurking in production.

fulafel • Feb 6, 2021 • View on HN

That may be for the static type system but you could still check and signal an error at runtime instead of silently ignoring it.

still_grokking • Aug 19, 2021 • View on HN

As opposed to some modern type system feature that would catch such bugs at compile time rather than let them happen at runtime.

kaba0 • Jun 27, 2021 • View on HN

I disagree. Other than the already mentioned points in replies, static typing and failing at compile time with a helpful error is really important. Runtime errors are much harder to interpret and debug - it is a skill they will have to learn later on, but inferring runtime state at a given point is arguably harder than doing so statically.

scriptkiddy • Jun 20, 2017 • View on HN

I don't think so. I think you're referring to static type checking. I'm referring to dynamic/runtime type checking.For instance, `1 + "hello"` will throw a `TypeError` at runtime because the `+` operator is not supported for use with `str` and `int` types. In a statically typed language, the code would not run or compile unless a `+` operator has been defined that takes a `str` type as it's first argument and an `int` type as it's second argument.I g

smt88 • Feb 11, 2019 • View on HN

This is only true if the bug is caught by the runtime checker. Lots of type bugs aren't, especially in languages with type coercion.