4 ms·
That's partly true. However, you do get rid of the complexity you never wanted in the first place. For me this is OOP, RAII, C++ allocators, exceptions, refere
by crafn 11y ago
That's partly true. However, you do get rid of the complexity you never wanted in the first place. For me this is
OOP, RAII, C++ allocators, exceptions, references, vtables (see my post about runtime recompiling), templates (mostly), C++ standard library (I'd have to write my own vector for fast compilation. I'd have to write my own hash map to get contiguous storage (IIRC))
C is by no means optimal, but it's still one of the least bad languages to write games with.
- hellofunk 11y agoI really like this idea of using C as a main language, but when you mention writing your own vector and hash map implementations (and undoubtedly many other fundamental tools that are otherwise provided for you by STL), doesn't that get quite time-consuming to re-invent the wheel in those areas that it's great to have a wheel already there for you?
- nautical 11y agoGenerally speaking , people tend to re-use the code . I have a complete folder filled with tons of reusable snippets which I keep optimizing there and there if some new idea comes up , otherwise they are good .
- hellofunk 11y agoPut those puppies up on github for the rest of us to enjoy! or, if not, can you recommend some good repos that showcase great C snippets that help in a lot of situations?
- crafn 11y agoWhen you drop the semantic silliness of C++, like having the container to take care of constructing, copying, moving, and destructing, not to mention exception safety, a basic implementation of a "templated" dynamic array implementation in C comes down to like 100 lines. Hash map will be a bit more, and is not so trivial to write. It's true that there should be no need to write these things yourself. The alternative C++ gives is not really tempting. A language designed for demanding game development doesn't exist (yet), so one evaluates which is the least worse option.
- hellofunk 11y agoConsidering that vector, map, etc are widely used and expected features of software development, I would think that good libraries in C exist for these already, so you don't have to even write your own 100 lines. Are there any?
- typedef_struct 11y agohttp://troydhanson.github.io/uthash/ http://troydhanson.github.io/uthash/
- a3n 11y agoThis is one of the reasons why every time I get nostalgic about C I then immediately get depressed. Having to find the next level of functionality, libraries, all over the internet, just makes my brain turn to peanut butter. I think this is one of the biggest disadvantage of a mostly standards based, no particular organization in charge type of language like C, as opposed to, say, python. I am fortunate that, at the moment, my needs are mostly casual and very rarely performance focused. If I needed C I would just STFU and use C, accumulating my own workarounds for the dispersed nature of its resources.
- lobster_johnson 11y agoGLib (not to be confused with glibc) from the GNOME project has a wide range of functionality -- generic lists, hash tables, strings etc.: https://en.m.wikipedia.org/wiki/GLib https://en.m.wikipedia.org/wiki/GLib Qt, I believe, also comes with a bunch of "standard library" stuff unrelated to UIs.
- hellofunk 11y agoBut Qt is all c++, no?
- unscaled 11y agoYes, GLib basically implements its own full-fledged OOP system on top of C. At which point, you start asking yourself, why are you not using C++? In my experience, most of the people who say they don't need OOP or generics end up implementing a limited (or even a full-fledged) version of these things themselves.
- je42 11y ago- OOP you only get if you use it. - RAII you only get if you use it. - exceptions you only get if you enable them. - references. no overhead. - vtables. you only get them if you need them. - templates. no overhead runtime. - C++ standard library. you only get it if you need it. - what's wrong with vector ? hash map ?
- crafn 11y agoYeah, and what's left is not much of C++. See my post about runtime recompiling for arguments to use C compiler instead of a very limited subset of C++. (References make the type system more complex for little benefit. Templates create massive amounts of complexity and slow down my iteration loop. Already explained what's wrong with std::vector and std::unordered_map.)
- je42 11y ago- Compile times with templates are on my system under 10 seconds. - I missed your vector and unordered_map discussion. - "more complex" is not a useful metric to compare the language systems. Similar, I can easily say, that C pointer arithmetic is creates more complex situations when verifying that code is safe to use.
- crafn 11y agoCompile times are not a problem in small codebases. Try to compile a 100kloc codebase using templates generously. Even your link times will easily grow over 10 seconds. Maybe even a minute. And 100kloc is still a pretty small codebase in terms of AAA development. It's true that complexity somewhat depends on the context. Complexity of a language is a useful metric when talking about mental overhead of the programmer (which translates to productivity), and when writing custom tools for the language, both of which are relevant when developing a game engine. Safety has traditionally been a quite small priority in gamedev. I assumed this was the context.
- je42 11y ago