logoalt Hacker News

zareithtoday at 4:47 PM3 repliesview on HN

I like the nim language, but the lack of interfaces has been a bit of a turn-off for me.

Do nim programmers not see the need for abstracting out behavior in a manner that different implementations can be switched somewhere else, or is there different idiomatic way to handle this?


Replies

moigagootoday at 5:54 PM

We use custom types for that usually, optionally with parametric polymorphism.

But as others said already, Nimony (codename for the next Nim iteration) introduces revamped concepts which should be even more convenient.

nick__mtoday at 5:16 PM

The concepts feature of Nim really looks like what your looking for https://nim-lang.org/docs/manual.html#concepts

tinfoilhattertoday at 5:01 PM

Nim doesn't have interfaces, but concepts + parametric polymorphism gets you a long way - https://jasonbeetham.ca/writeups/codereuse.html