Re:Show HN: Lumix Engine – Open source C++ 3D game engine
by galangalalgol on Wednesday March 01, 2017 @09:54AM
(#13764069)
That guy says his must-have feature of c++ is operator/function overloading. That seems an odd choice to me. I have been a c++ developer for over a decade. I would have leaned more towards it being a necessary evil.
[ Parent
| on HN ]
Re:Show HN: Lumix Engine – Open source C++ 3D game engine
by iainmerrick on Wednesday March 01, 2017 @11:24AM
(#13765025)
It's a must-have for 3D programming, for working with vectors and matrices. OpenGL's shader language is basically C with (hard coded) operator overloading for this reason.
Re:Show HN: Lumix Engine – Open source C++ 3D game engine
by schoen on Wednesday March 01, 2017 @12:12PM
(#13765697)
Could you explain a little more about how the operator overloading is used in this context? Is it just that arithmetic operators are made to work in their linear algebra sense on objects representing matrices, so M*N will return a new object representing the matrix product M×N?
Re:Show HN: Lumix Engine – Open source C++ 3D game engine
by hacoo on Wednesday March 01, 2017 @03:59PM
(#13768267)
That's exactly how it would be used. Game programming involves a pretty enormous amount of geometry and vector arithmetic, so it's a domain where being able to write s*(u+v) is an advantage over scaleVec(s, addVec(u, v)). Same logic applies to matrices, as you described.
Personally, I think there are more important advantages of C++ over C, and operator overloading can get ugly FAST if you're not careful.
Re:Show HN: Lumix Engine – Open source C++ 3D game engine
by schoen on Wednesday March 01, 2017 @05:47PM
(#13769339)
That makes sense. Thanks for the explanation!
Re:Show HN: Lumix Engine – Open source C++ 3D game engine
by mikulas_florek on Wednesday March 01, 2017 @10:17AM
(#13764308)
Must-have necessary evil :)
Anyway, I do not agree with all the stuff in the linked article. He was just used as an example for need of programmer-focused engines.