Live data from Hacker News

Show HN: Crown – A flexible game engine written from scratch in C++

github.com

121–130 of 179 posts

Re: Show HN: Crown – A flexible game engine written from scratch in C++

#121

While I find the "sane C++" approach pragmatic and practical all things considered, I'm firmly in the "time to use a better language if possible" camp. The problem with approaches requiring extra discipline is: it's an extra mental burden to bear while programming. Also, you'll always be limited by the fact that you're working in a less pure ecosystem and will likely end up using libraries written in "not very sane C…

I think what you're referring to is D.

Re: Show HN: Crown – A flexible game engine written from scratch in C++

#123
post #68

Earlier quoted context omitted.

You don't have constructors that 'fail'.

So, allocating memory for objects is not part of construction? Again, why not just stick with C?

C doesn't let you have destructors that automatically clean up whatever got initialised in the Init method (if it was called), but C++ does.

Re: Show HN: Crown – A flexible game engine written from scratch in C++

#124

If you come to finance, most of the developers love premature templatization, it makes them feel like they know something. Not sure it that can be attributed to their insecurity about C++ coding skills, but it gets really ridiculous at times.

What does this have to do with the link?

Re: Show HN: Crown – A flexible game engine written from scratch in C++

#125
post #83

Earlier quoted context omitted.

What's wrong with using templates vigorously?

Well, let me give you an example that I have seen recently. There was this function that suppose to convert numeric value to string. So numeric type was templatized. Then with combination of enable_if and static_asserts there were checks to avoid doubles/floats negative numbers. So whats there left besides unsigned integers?

explicit overloads or concepts

Re: Show HN: Crown – A flexible game engine written from scratch in C++

#126
post #99

Earlier quoted context omitted.

It was almost the exact proposal specified by my grandparent post except using a pointer rather than an optional. It's also a technique that is widely used. See for example the cocos2d-x game library. The benefit of such a technique is that you can then make the constructor private, making it impossible to create an object and not also call the initialize() method.

It is very different from having a static method returning an optional, which guarantees that you can access the optional (with at least an assert in debug mode) only if the object is actually successfully constructed. Using a separate initialize member function means that you may have objects in a zombie state laying around after a failed construction which lead to all kind of initialization order issues (you might…

> It forces heap allocation though, which is bad.

It does, and it can be, but in situations where it matters, the static create function typically returns a value from a preallocated pool of memory, so objects are all contiguous and cache friendly.

Re: Show HN: Crown – A flexible game engine written from scratch in C++

#127

While I find the "sane C++" approach pragmatic and practical all things considered, I'm firmly in the "time to use a better language if possible" camp. The problem with approaches requiring extra discipline is: it's an extra mental burden to bear while programming. Also, you'll always be limited by the fact that you're working in a less pure ecosystem and will likely end up using libraries written in "not very sane C…

The best argument I've seen for using orthodox C++ is when writing something you want to compile to both native platforms and web using emscripten, while aiming for good performance and small distribution size.

For example, this is what Oryol achieves, targeting OpenGL on native and WebGL on web. I don't think anything could beat the "Orthodox C++" approach for that purpose, aside from using C (which is what I'm using for a project right now).

https://github.com/floooh/oryol/

Re: Show HN: Crown – A flexible game engine written from scratch in C++

#128

If you come to finance, most of the developers love premature templatization, it makes them feel like they know something. Not sure it that can be attributed to their insecurity about C++ coding skills, but it gets really ridiculous at times.

I have a friend who runs a hedge fund, not really insecure at all but uses templates vigorously. More stuff in compile time rather than runtime. In critical sections inheritance can be prohibitively expensive because of the use of lookup tables.

Thrashing your I$ because you have too many template instantiations can be prohibitively expensive too, it's just harder to metric.

Re: Show HN: Crown – A flexible game engine written from scratch in C++

#129

While I find the "sane C++" approach pragmatic and practical all things considered, I'm firmly in the "time to use a better language if possible" camp. The problem with approaches requiring extra discipline is: it's an extra mental burden to bear while programming. Also, you'll always be limited by the fact that you're working in a less pure ecosystem and will likely end up using libraries written in "not very sane C…

For embedded systems there is MISRA C. It is a set of guidelines that is included in some compilers and analysis tools. MISRA C++ exists too but I don't know how well supported it is.

It is, however, a rather restrictive standard with critical systems in mind. Usually, you don't want such restrictions in regular software development, you want the full power of the language.

Ensuring sanity is better served with static analyzers (linters) that can be tailored to the specific needs of the project and be regularly updated with new rules.

Re: Show HN: Crown – A flexible game engine written from scratch in C++

#130
post #83

Earlier quoted context omitted.

What's wrong with using templates vigorously?

Some things that are not so nice about templates: - dozens to hundreds of compiler error lines for a single error, where it's hard to find out what the real problem is (IDEs often point to the wrong line) - Code is hard to follow. E.g. try to figure out from boost asio source code which code is actually used if if you do a async_read(socket). I personally gave up after the second level of template substitutions, and…

As a bonus you can meditate deeply on all conseqences of using tempates in the vastly increased compilation time that they are going to introduce.
Post reply on HN