3 ms·
Speaking for myself, as an absolute novice, OOPs in Nim is not great. it feels shoehorned in, rather than being a primary citizen of the language design. There
by rishav_sharan 7y ago
Speaking for myself, as an absolute novice, OOPs in Nim is not great. it feels shoehorned in, rather than being a primary citizen of the language design.
There is too much fiddling with methods vs procs, pragmas and such involved for the most basic stuff.
I am tinkering on a small 2d game using Nim. I was planning on using OOPs for most of my game objects. Now I am debating if I should make the effort to actually learn OOPs the Nim way or just do it procedurally.
Considering that my project is tiny, I might go for the latter and skip OOPs altogether.
So for me right now Nim is a better C, with nicer syntax, simple build system and a package manager.
- dom96 7y agoI would say that this is in some ways by design. Nim offers some OOP features, but in general does its best to discourage the use of OOP. In that sense I would say you should skip OOP and implement everything in a procedural style (it will be more efficient too).
- auxym 7y agoThe only OOP-ish thing I've really missed in nim is interfaces. It seems to be a really convenient way to re-use code: "this function (proc) can operate on any type that has implementations of this and that other function (proc)". Googling has left me with suggestions of using macros to re-implement similar functionality, which I guess is in line with nim's philosophy of "small core with powerful macro system". Looking into it however, developing macros seems like more effort than a simple interface. Just the impressions of someone not super familiar with metaprogramming.
- dom96 7y agoThe idea I think is that someone needs to implement it using macros and get it into Nim's stdlib. Then we can all make use of it. If you're passionate enough about interfaces then you may just be able to implement something that works beautifully and get it merged into stdlib (that would be awesome).
- tokai 7y agoThe lack of "proper" OOP is one of the things I really like about nim. Incidentally it's also one of my favorite decisions in Julia.
- tyingq 7y agoIt seems deliberate: "While Nim's support for object oriented programming (OOP) is minimalistic, powerful OOP techniques can be used. OOP is seen as one way to design a program, not the only way." https://nim-lang.org/docs/tut2.html https://nim-lang.org/docs/tut2.html