
Electronic Arts Standard Template Library for C++ Open Sourced - hising
https://github.com/electronicarts/EASTL
======
pcwalton
We on the Rust team got to speak about the lessons learned from the EASTL with
Paul Pedriana (the author of much of it) while designing the Rust standard
library. It's a significant influence on the proposed allocators API currently
in RFC. The EASTL is worth looking at for anyone interested in designing
libraries that work well in low-memory environments. (Much of this library was
written with devices like the Nintendo DS in mind, which had 4 MB--4 MB!--of
RAM as I recall.)

~~~
sshumaker
I had the pleasure of being Paul's intern way back in 2000. At the time, Paul
was at Maxis and if IIRC the library actually had its roots in the C++
frameworks Paul built for SimCity 3000. Those games actually were quite a bit
ahead, engineering-wise, in terms of the C++ of the day.

------
albertzeyer
STL is maybe a bit missleading because it doesn't seem like it is a drop-in
replacement for the STL.

However, this is certainly interesting because the emphasis on speed (and thus
also on simplicity) is what I'm sometimes missing in the real STL or in Boost.
That's exactly what you need in a game but also in much other performance
critical code.

As far as I remember, Chrome has used the STL earlier. But I looked now and I
see this:
[https://chromium.googlesource.com/chromium/blink/+/master/So...](https://chromium.googlesource.com/chromium/blink/+/master/Source/wtf/)

Gecko also seem to have a lot of custom stuff:
[https://github.com/mozilla/gecko-
dev/tree/master/xpcom/strin...](https://github.com/mozilla/gecko-
dev/tree/master/xpcom/string)

Doom3 idLib: [https://github.com/id-
Software/DOOM-3-BFG/tree/master/neo/id...](https://github.com/id-
Software/DOOM-3-BFG/tree/master/neo/idlib)

Unreal engine: [https://answers.unrealengine.com/questions/2695/rocket-
and-t...](https://answers.unrealengine.com/questions/2695/rocket-and-the-
stl.html)

You'll find much more similar libs when you search in some of the big games.

~~~
CyberDildonics
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.

~~~
corysama
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.

~~~
to3m
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.

------
United857
Writeup on the key design and advantages of EASTL for their target platforms
(game consoles): [http://www.open-
std.org/jtc1/sc22/wg21/docs/papers/2007/n227...](http://www.open-
std.org/jtc1/sc22/wg21/docs/papers/2007/n2271.html)

------
uglycoyote
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.

~~~
egoots
Isn't part of this addressed by taking advantage of the new C++ 11 extern
template feature? [http://www.stroustrup.com/C++11FAQ.html#extern-
templates](http://www.stroustrup.com/C++11FAQ.html#extern-templates)

------
Negative1
This was open sourced years ago on the EA open source page:
[http://j.mp/1Kh4L2C](http://j.mp/1Kh4L2C)

It's just on Github now.

~~~
plorkyeran
The previously released version was significantly incomplete (it only included
what was needed for the copy of webkit they embedded in some games), was years
out of date, and was GPL rather than BSD.

------
captn3m0
A quick reference guide in PDF is available at
[https://github.com/electronicarts/EASTL/blob/master/doc/EAST...](https://github.com/electronicarts/EASTL/blob/master/doc/EASTL%20Quick%20Reference.pdf).
Lists all Algorithms, functions etc.

------
Animats
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 can't go wrong with a swap. Move is a swap with a constraint that
the destination be empty.

(Doing things through swapping has its uses. It preserves single ownership,
for example.)

~~~
ixtli
> Cute. It's fun to see game programmer code.

This. I work almost exclusively with game programmers and it can be ...
difficult at times. They seem to be largely unaware of the larger computer
science community that's existed since the mid sixties, often "discovering"
things that were solved by the science years ago.

~~~
pcwalton
On the other hand, game programmers are just as frequently the only ones
exercising anything close to the full functionality of today's hardware. It's
kind of depressing how little use SIMD, multicore, and GPU (compute or
otherwise) get outside of games. Games have done a pretty good job keeping up
with the ending of Moore's Law for sequential code, but we continue to use our
old sequential libraries and leave so much performance on the table in the app
world.

I do agree that the apps and server world is ahead, in many cases way ahead,
in terms of effective development practices and programming languages. But
we've lost sight of how to get performance out of the hardware.

~~~
nickpsecurity
I was re-exploring that issue recently. It wasn't obvious to me which of two
strategies I commonly saw are best: extend existing languages with parallel
constructs as in Cilk/C, ParaSail/Ada, or Lime/Java; create custom languages +
compilers like Cray's Chapel or academic Triolet whose output cleanly
integrates with apps in an existing language. My uncertainty comes from the
fact that general-purpose languages founded in sequential use might be too
hard to max out on arbitrary multi-core & CPU architectures. What's your
opinion on which looks to be the best route so far?

Cilk [http://supertech.lcs.mit.edu/cilk/](http://supertech.lcs.mit.edu/cilk/)

ParaSail [http://www.embedded.com/design/other/4375616/ParaSail--
Less-...](http://www.embedded.com/design/other/4375616/ParaSail--Less-is-more-
with-multicore?page=0)

Lime Compilation [http://researcher.watson.ibm.com/researcher/files/us-
bacon/D...](http://researcher.watson.ibm.com/researcher/files/us-
bacon/Dubach12Compiling.pdf)

Chapel
[http://chapel.cray.com/overview.html](http://chapel.cray.com/overview.html)

Triolet
[http://impact.crhc.illinois.edu/shared/Papers/dissertation-r...](http://impact.crhc.illinois.edu/shared/Papers/dissertation-
rodrigues.pdf)

~~~
pcwalton
Anything and everything. I don't believe there's a one-size-fits-all solution
for parallelism.

------
mkl
Scott Wardle gave an interesting talk at CppCon 2015 which mentions EASTL a
bit, with the reasons they use it (and other non-standard tools): “Memory and
C++ debugging at Electronic Arts”
[https://youtu.be/8KIvWJUYbDA](https://youtu.be/8KIvWJUYbDA)

~~~
jonkalb
CppCon 2015 was also the site of the first formal meeting of SG14, the game
developer study group of the C++ standards committee. Michael Wong has just
announced that it will meet again at CppCon 2016:
[https://groups.google.com/a/isocpp.org/forum/?fromgroups#!to...](https://groups.google.com/a/isocpp.org/forum/?fromgroups#!topic/sg14/9CcqpRTe-
yw)

------
delroth
Note that EA had already released some of the code in 2010:
[https://github.com/paulhodge/EASTL](https://github.com/paulhodge/EASTL)

~~~
agumonkey
But 2016 version is full HD. Can't wait for 2017.

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

~~~
greggman
That's "bad" systems hungarian instead of "good" apps hungarian

[http://www.joelonsoftware.com/articles/Wrong.html](http://www.joelonsoftware.com/articles/Wrong.html)

~~~
Noughmad
If you use C++, you should really be using a separate type for this, rather
then rely on variable names. The compiler is much better at catching these
things than you are.

------
SoulMan
Looks like build is failing !

------
wslh
I just upvoted the same news just 4 days ago:
[https://news.ycombinator.com/item?id=11069305](https://news.ycombinator.com/item?id=11069305)

There is some issue with duplicates in HN, I think points should go to the
original poster, more if it's recent.

~~~
dikaiosune
Eh, is it really that big a deal? I have a few times posted something which
gets no attention and is then reposted with up votes and comments (sometimes
only a few hours later). Maybe a little irksome, but I don't think HN
karma/score/points should be that big of a concern.

------
frign
Now we can at least explain with code examples why Electronic Arts Games suck
so much.

~~~
pearjuice
That's a pretty low punch under the belt. If you are being serious, please
give some examples of why this STL sucks. Corporations like EA, which is a
long hauled bureaucratic labyrinth should be celebrated for open sourcing
code.

