
AstonJ
What's all the fuss about static-typing?
If you’re a fan, why?
If you’re not fussed on it, how comes?
Most Liked

Qqwy
To put it very concisely, these are I believe the two most important advantages of static typing:
- It removes whole class of potential bugs. Essentially all the
undefined is not a function
-style bugs are impossible in static type-systems. This means easier testing but also that less ‘defensive programming’ is required. - Knowing that something is guaranteed to e.g. always be an integer allows for extra optimizations to happen.

lpil
I find this an interesting statement as in my mind Go is a language with a painful lack of inference, types are required everywhere.
Here’s a fully type safe program in Elm:
main =
let
double a = a + a
twice f a = f (f a)
in
{ name = ("Louis", "Pilfold")
, score = twice double 50
}
And here’s the same program written in Go:
type Name struct{
First string
Last string
}
type Person struct{
Name Name
Score int
}
func Main() Person {
double := func(a int) int {
return a + a
}
twice := func(f func(int) int, x int) int {
return f(f(x))
}
return Person{
Name: Name{
"Louis",
"Pilfold",
},
score: twice(double, 50),
}
}
The Go version requires many more type annotations, and I would argue that many of them (especially the annotations on anonymous functions) provide no technical benefit at all. If anything they’ll make the code very slightly slower to compile as they need to perform inference inside the compiler to assert that they are correct.
To make matters worse, the Go version isn’t type safe (it lacks null checking and many other features), and it is less flexible (the double function only works with ints).
I like many things about Go, but in my opinion its type system leaves an awful lot to be desired.
Popular General Dev topics










Other popular topics










Latest in Dev Chat
Latest (all)
Categories:
Sub Categories:
- All
- In The News (10779)
- Dev Chat
- Questions (29)
- Resources (118)
- Blogs/Talks (26)
- Jobs (3)
- Events (14)
- Code Editors (58)
- Hardware (57)
- Reviews (3)
- Sales (15)
- Design & UX (4)
- Marketing & SEO (1)
- Industry & Culture (15)
- Ethics & Privacy (19)
- Business (4)
- Learning Methods (4)
- Content Creators (7)
- DevOps & Hosting (9)
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /rails
- /js
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /java
- /haskell
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /ash
- /centos
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /sublime-text
- /textmate
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /django
- /spring
- /diversity
- /nodejs
- /lua
- /slackware
- /julia
- /c
- /neovim