Live data from Hacker News

Electronic Arts Standard Template Library for C++ Open Sourced

github.com

41–50 of 60 posts

Re: Electronic Arts Standard Template Library for C++ Open Sourced

#41
post #22

Cute. It's fun to see game programmer code. This is really C with a little C++. Lots of pointer casts, comments like "The user must provide ample buffer space, preferably 256 chars or more." There's a lot of stuff in there to deal with Microsoft Visual C++'s interpretation of the language, which prior to 2010, was kind of off. Why does "swap" use EASTL/move_help.h? There are things that can go wrong with a move that…

`swap` uses `move` to enable swapping objects that can only be moved but not copied (e.g., std::unique_ptr). Note that this swap implementation is meant to be generic---types may implement their own specific `swap` that performs no copies or moves whatsoever. Example:

  namespace NS {
    struct S {
      friend void swap(S& a, S& b) {
        // do something interesting here
      }
    };
  }

  // later..
  template
  void f(T& a, T& b) {
    using std::swap;
    swap(a, b); // calls NS::swap(a, b) if T = NS::S
  }

Re: Electronic Arts Standard Template Library for C++ Open Sourced

#42

Earlier quoted context omitted.

What parts of the EASTL are faster than the normal STL? Does it have better maps? Edit: From a look at the source it definitely at least has some extra map classes for more specialized uses.

One goal of EASTL is to be faster in non-optimized builds compared to other variants. If a game is running too slow to be playable, it can become impossible to debug! This was especially a problem on consoles with no OOE. It achieves this by sacrificing a lot of encapsulation and accepting non-DRY, manually inlined function implementations.

I didn't realise this was a goal, but it's good that it was. C++'s prime faults tend to be spiteful iteration time (common cause: too many templates) and appalling performance in unoptimized builds (common cause: too many function calls, possibly due to overloaded operators and overly-finely-grained code that relies on inlining not to run like shit).

The famous maxim about how much cleverer you have to be to debug code than to write it always applies! No need to make things worse by forcing yourself to debug the optimized build.

Re: Electronic Arts Standard Template Library for C++ Open Sourced

#44
post #22

Cute. It's fun to see game programmer code. This is really C with a little C++. Lots of pointer casts, comments like "The user must provide ample buffer space, preferably 256 chars or more." There's a lot of stuff in there to deal with Microsoft Visual C++'s interpretation of the language, which prior to 2010, was kind of off. Why does "swap" use EASTL/move_help.h? There are things that can go wrong with a move that…

Looks like way more than a little C++ to me. I mean, it's a template library!

Re: Electronic Arts Standard Template Library for C++ Open Sourced

#45
post #22

Cute. It's fun to see game programmer code. This is really C with a little C++. Lots of pointer casts, comments like "The user must provide ample buffer space, preferably 256 chars or more." There's a lot of stuff in there to deal with Microsoft Visual C++'s interpretation of the language, which prior to 2010, was kind of off. Why does "swap" use EASTL/move_help.h? There are things that can go wrong with a move that…

> Move is a swap with a constraint that the destination be empty. Is there actually any constraint here? I thought the only constraint on a moved-from object is that you can't use it in the current state.

The standard defines moved from objects (standard library types, at least) to be in a 'valid but unspecified state'. For container types like std::vector, 'valid but unspecified' usually means empty.

Re: Electronic Arts Standard Template Library for C++ Open Sourced

#46
post #38

Earlier quoted context omitted.

You should see what was in the LibreOffice codebase at one point!

That simply predated the STL by a number of years, no?

Many, many years :-) it wasn't a true criticism

Re: Electronic Arts Standard Template Library for C++ Open Sourced

#47
I have worked for game companies making large console games both with the STL and without. One thing I noticed about STL is that it really bloats the build times because the STL headers are so massive. I did some analysis of the preprocessor output one time and found that just including a couple of headers like vector.h and string.h would increase the size of the preprocessor output by 80000 to 100000 lines, even for a cop file that is otherwise trivially small. Typically almost every cpp file in the codebase would either directly use STL headers or bring them in as dependencies, and so in a codebase of a few thousand files you are talking about hundreds of millions of extra lines of code that the compiler has to churn through. This amounted to each cpp file talking several seconds to compile and the entire codebase taking most of an hour to rebuild. People would not have been able to survive that without using Incredibuild to farm off compilation to other machines. The company I currently work at does not use STL and so largely avoids this problem. I an curious to what extent EASTL has this problem or avoids it.

Re: Electronic Arts Standard Template Library for C++ Open Sourced

#48
post #5

And I thought my workplace was the last shop in the world to still write new code in hungarian notation ...

The "Hungarian" in EASTL is very light. It's not even really Hungarian; it's mostly just m prefixes for members, p for pointers, and n for numbers. Hungarian is a far more draconian set of conventions.

Re: Electronic Arts Standard Template Library for C++ Open Sourced

#49
post #22

Cute. It's fun to see game programmer code. This is really C with a little C++. Lots of pointer casts, comments like "The user must provide ample buffer space, preferably 256 chars or more." There's a lot of stuff in there to deal with Microsoft Visual C++'s interpretation of the language, which prior to 2010, was kind of off. Why does "swap" use EASTL/move_help.h? There are things that can go wrong with a move that…

C with a little C++? It's a full C++11 implementation of each of the components it implements, modulo the namespace and allocator change. Perhaps it seems simpler to you because you are used to complicated implementations.

Re: Electronic Arts Standard Template Library for C++ Open Sourced

#50

I have worked for game companies making large console games both with the STL and without. One thing I noticed about STL is that it really bloats the build times because the STL headers are so massive. I did some analysis of the preprocessor output one time and found that just including a couple of headers like vector.h and string.h would increase the size of the preprocessor output by 80000 to 100000 lines, even for…

EASTL still has this problem. It's worse on Windows where the prerequisite system header (ie: yvals.h, etc.) can bring in a ton of bloat. Until modules are a reliable thing and we can take advantage of them in a reasonable cross platform way it will still remain a problem.
Post reply on HN