Posts Tagged ‘programming’
Please note this is part of documentation I wrote for the opensource feather web framework currently available on GitHub. You can find the document in its original form here: https://github.com/maddogawl/feather/blob/master/featherdoc/docs/state%20machines.md
feather Finite State Machines
Finite State Machines (FSM) are well understood in computer science, and as such they won’t be covered much here. There are some really good articles online that you can check out to read more in depth analysis on FSM’s.
Links to some good articles
In the simplest definition a FSM is a set of states and transitions. A FSM can only be in one state a time, thus allowing you to easily build state driven applications like Rich Internet Applications. In more complex systems that utilize state machines you will begin to see hierarchical state machines, and states that have their own state machines.
In general Finite State Machines are a tool that simplifies common problems including UI management and async flow.
Benefits of State Machines
An application could easily be created without utilizing FSM’s, but there are some clear advantages to using them.
– Flexibility : Code can easily be tweaked and extended with proper use of state machines.
– Debugging : Code that is isolated in small testable states makes it much easier to track down defects in the software.
– Simplicity : Its human nature to think of things in terms of states. It is generally simple to break down parts of software in terms of states.
Over the last month I have been working on learning the basics of CUDA, and I have come to realize the methodology in using CUDA is most likely the future of how development will be done. As processors scale not by speed but by number of cores, it is only going to make sense to use the same ideas when working on the CPU. Granted CUDA only works on NVIDIA Cuda enabled devices but the work that has been done to support very simple parallel processing across the GPU is phenomenal. I have attempted to utilize CUDA to solve some of the http://projecteuler.net/ problems, but I still find the biggest bottleneck is in the size of values that are supported in 32 and 64 bit float and integers. I have a custom integer class that supports infinitely large values, but I don’t have anything for floats yet. Truly when working on those problems its best to stick with the algorithm design and use a language that supports infinitely large numbers such as python.
A few things that I am really thinking about is how to design and architect a cpu api or engine that supports what CUDA does on the GPU but rather on the CPU. There are already some paradigm’s that work in tasks, where every action is a task, and some tasks have dependencies which force the order of tasks, but truly I believe there is more room to improve. I think we need to step back and rethink how programming is done. We have been so ingrained in to object oriented programming that the thought of doing something different seems illogical. I believe we need to start thinking about the data first which I have been hearing talks about over the last few years. Think about it this way, the code we develop is just a small fraction of the memory in a large scale application, while a huge percentage is the data we are processing ( textures, audio, meshes, etc). When we work in objects we aren’t truly utilizing the cache or optimizations that the CPU can make for us.
I want to make a new prediction that in 10 years game development as we know it will be completely different. Data Oriented programming is the future, and Object Oriented will start to teeter out.