3 ms·
John Carmack spent some time in one of his famous keynotes talking about functional programming. On the one hand, obviously video games tend to be very stateful
by oconnor663 6y ago
John Carmack spent some time in one of his famous keynotes talking about functional programming. On the one hand, obviously video games tend to be very stateful, and implementing them in imperative terms is natural. On the other hand, tons of specific things you do inside a game (or in any program) can be described as pure functions, and doing that is often a great idea. I think it was this part of this keynote: https://youtu.be/Uooh0Y9fC_M?t=4660 https://youtu.be/Uooh0Y9fC_M?t=4660
- milesvp 6y agoYour comment made me feel compelled to mention a Blizzard talk I came across recently on the ECS (Entity Component System) architecture they used for Overwatch. It looks suspiciously like a function first architecture in that they don't allow mixing of data and functions. I'm not sure how purely functional it is, but it certainly strikes me as the kind of architecture that Carmack would appreciate in dealing with complexities that lead him to a more functional programming style. This talk is 3 years after release, and includes all the hindsight they gained from that. Also, the parts talking about the netcode are quite amazing, and the precision of their predictors that they attribute to using ECS. https://www.youtube.com/watch?v=W3aieHjyNvw&feature=youtu.be https://www.youtube.com/watch?v=W3aieHjyNvw&feature=youtu.be
- fredrikholm 6y ago> I'm not sure how purely functional it is ECS systems overlap functional programming (FP) only in that both are data first. Purely functional would mean never mutating an existing value, functions only receiving one value and returning another, monadically binding side effects and so on. To put it bluntly, a non-trivial computer game in pure FP would hog every resource in your system to barely hit single digit frame rates. (Disclaimer: I love FP, and use it at my day job. It is not fit for games though)