Remix.run Logo
zareith 3 days ago

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?

tinfoilhatter 3 days ago | parent | next [-]

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

moigagoo 3 days ago | parent | prev | next [-]

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__m 3 days ago | parent | prev [-]

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