Why I am excited about Entity Systems

by moodyharsh 2016-06-30

Computing is still primitive and Fragile.

For example, Typography is an ancient profession.
CSS3 is just cute, compared to what Typographers can do.

It is haughty to think that computers can do everything, with fidelity.

Donald Knuth spent a disproportionate amount of time on typesetting,
and rightfully so.

To put Entity Systems in context, here is a list of programming
paradigms as used in the Software Industry.

Automata Programming

Automata/ State Machines are at the heart of all Software.

  • Parsers
  • Validation Mechanisms
  • Protocols
  • Circuit Design
  • Industrial Robots

Currently state machines can be implemented by the following

  1. State Pattern

    This is the OO way of doing it.

  2. Dispatch Tables

    This uses function pointers.

  3. Goto’s

    I find it appalling that gotos are considered a joke.

    Here is a Knuth’s defence of goto. The paper also has a hint of satire,
    on how programming language designers are complicit in advocating Newspeak,
    for “safety”.

    Just for a perspective, see the tcp/ipv4 code from FreeBSD.

    This code is used by Sony and many embedded systems.
    The Linux implementation is similiar.

The most critical piece of Internet Infrastructure is designed as a state machine using goto's.

Using goto’s is hardly different from Dispatch Tables.
RAM is a hardware implementation of a table.

Why is there, no joke on this page ?
Probably because it’s used in the Electronics Industry.

Blaming goto’s is like blaming a Scalpel.

Structured Programming

This has the following styles,

  1. Procedural Programming

    See Program Development by Stepwise Refinement
    Typically how you write C programs.

  2. Objective Programming

    Encapsulation for me, is the most important idea here.

  3. Modular Programming

    >>> import this ... Namespaces are one honking great idea -- let's do more of those!
  4. Functional Programming

    Functional programming structures code around transformations,
    than state changes.

    It’s tricky to do Games in Pure Functional Programming.
    Impure Functional Programming as seen in Common Lisp, Clojure,
    Perl, Python, Ruby, OCaml is more successful.

Declarative Programming

The following are some fine examples,

  1. HTML, make

  2. SQL, Logic Programming

  3. DSL’s and Scripting Components.

    See Rake, Blender API

  4. Generative Programming

    This includes Lispy Macros, yacc.

Event Driven Programming

Computers react to events.

  1. Messaging

    Zero MQ

  2. Observers

  3. Callback (Hell)

  4. Services

    See REST

Data Flow Programming

This is my favorite paradigm.
Impure Functional programming fits nicely here.

  1. Unix Pipes

    Nuff said.

  2. Max/Pure Data

    You just have to see it.

  3. Spreadsheets

    Most widely used Programming Language if you ask me.

  4. Visual Programming

    A bit of a stretch, but anything from Photoshop layers to Circuit Design goes here.

Parallel Programming

Erlang is a great success story.

What is wrong with objects ?

I would argue that the chief problem is performance.

See – http://research.scee.net/files/presentations/gcapaustralia09/Pitfalls_of_Object_Oriented_Programming_GCAP_09.pdf

In a way Entity Systems, takes concepts from every one of the above.
I am not even sure it’s a new Paradigm.

But the reason I am excited about Entity Systems is, it puts us right back
into Batch Computing. Entities are stored centrally and Systems perform batch operations on them.

And best of all, it is battle tested by Game Developers.

For the past ~10 years or so the Game Programming community has adopted
Data Driven Programming with Homogeneous Data quite successfully.

In contrast to Data Flow and Message Passing, Data Driven Programming
as adopted by Game Programmers resembles Shared Memory style of Process Communication and the Black Board pattern.

There is also a programming language called Linda that does this pattern natively.