Friday, February 3, 2012

Looking at D language again.

Seriously, I need to stop reading so much on the web.  I've got the attention span of a 5yr old in a candy store when it comes to programming languages.  Somehow, I don't know how, I stumbled upon GLFW, which is yet another library aiming to help with OpenGL (like libSDL or freeglut or SFML).  It turns out it natively supports D, and that got me to thinking.   One thing led to another, and I came across an interesting article on concu rrency support in D by the renowned author and C++ guru Andrei Alexandrescu.

Another interesting aspect I discovered is the immutable support in D, and how it seems to mirror Clojure's default immutability (although in D, things aren't immutable by default...kind of like Scala, and that lack of default of default immutability has led people to call Scala not truly functional).  However, while Clojure uses Software Transactional Memory as its way of avoiding ugly locks to memory access, D is using a different approach to its memory model.  For example, by default, threads do not share data, and this has to be explicitly made so.  It seems that D is using the more tried and true message-passing approach made most popular by erlang. It also appears that at least for the PyPy developers, that STM may able to remove the GIL in Python, so I wonder if the message passing model is the best to use, given that clojure is using STM, and even Scala is adding a STM approach to concurrency above and beyond their actor model.

So now I am all the more interested in D.  It's basically a more modern alternative to C/C++...even C++11x.  While C++11x does natively support threads, it still seems to be using the traditional, "lock memory access with mutexes" approach.  Templates seem easier, and of course, there's built in garbage collection.

Since I am just starting, I am seriously considering using D and GLFW instead of C++ and SDL.  SDL does look more advanced than GLFW however.  Plus, as I mentioned before, I don't want my C++ skills to rust away.  But D just looks a LOT nicer than C++ now. 

No comments:

Post a Comment