Go Interfaces Debate

The cluster focuses on debates about Go's interfaces, including their structural and duck typing nature, comparisons to type classes in other languages, criticisms like interface pollution and overuse of interface{}, and defenses of their design.

📉 Falling 0.5x Programming Languages
3,375
Comments
18
Years Active
5
Top Authors
#1907
Topic ID

Activity Over Time

2009
9
2010
8
2011
36
2012
83
2013
254
2014
318
2015
234
2016
218
2017
272
2018
172
2019
231
2020
171
2021
332
2022
338
2023
197
2024
239
2025
258
2026
5

Keywords

IsActive e.g BarService.URL GC TypeScript BarService UUID FooService pkg.go i.e interface interfaces type types typing typed func methods duck functions

Sample Comments

happysanta Nov 28, 2018 View on HN

Not proficient in Go but I see an interface{} somewhere in the answer.

assbuttbuttass Sep 27, 2023 View on HN

Go has type classes, they're called interfaces

rvense Jul 23, 2017 View on HN

Is it possible to write a reusable version of something like this in Go without using interface{}?

stonemetal Sep 15, 2015 View on HN

Not really, Go uses duck typing for interfaces. You declare an interface to require functions X, Y, and Z. Any type that has functions X, Y, and Z suddenly implements that interface whether you want it to or not.

bad_user Feb 15, 2016 View on HN

Go's interfaces are not type-classes and type-classes aren't about structural typing.

bunderbunder Jan 7, 2025 View on HN

Go is not immune. See: interface pollution.

DanWaterworth Jan 21, 2013 View on HN

Go's interfaces are not like Haskell's typeclasses. Just try and write a Go interface that allows you to add two of the same things together.

sidlls Jan 28, 2023 View on HN

Go’s structural interfaces are one of the worst features of the language, partially due to the implementation and partially due to the fact that structural typing like in Go is just a terrible idea in a statically typed language. May as well just use a dynamically typed language: because that’s what go’s duck typing leads a code base to be in practice anyway

acchow Sep 15, 2021 View on HN

Because Go doesn't support userland generic types, I see liberal use of `interface{}` types in APIs. There must be a better way.

tuetuopay Sep 4, 2024 View on HN

Go is horrible due to the absence of specific "interface implementation" markers. Gets pretty hard to find where or how a type implements an interface.