EPIC news
So playing with clojure has spawned some useful results :). Namely EPIC, an engine for game combat. This is part of a huge secret project some friends and me are working on.
It works nicely so far, speed is - even so not at all optimized yet, quite good. Clojures STM and concurrency methods do a good job in allowing some stuff to run in paralell. So after a meeting on wednesday we decided to make this part of our project open source and publically available.
But what does EPIC do exactly? It calculates the outcome of fights mostly. You can define modules with certain propaties to them - a good set of them are predefined but you are free to extend them as you see fit if you want to do something else. Then once you've a set of modules they assamble to units, as in the unit is build from a certain cet of modules. Finally you toss in some AI for the units, stirr on medium heat and voila, you are ready for a fight.
We have set up a little demo if you want to see what EPIC can do. The fights on this page are all pre calculated and played back only (not live). But the calculation is done in EPIC with the current master branch from github with some custom modules.
So we don"t yet have a way to post combats yourself, but I can offer to add your own combats if you drop me a line and would like to see something. An example can be found here.
Have fun and let me know if you have any questions/suggestions.
Oh and you can find the source on github ;)/
A venture into 'new' technology
Lately I looked into a few new technologies. Namely Clojure - a very interesting and young language and MongoDB a also quite interesting database.
Clojure
Clojure is a new (it celebrated it's second birthday just this month) language. It is a functional programming language that is based in LISP and runs on the JVM. This is an interesting combination in itself, but to be honest it would not have cought my attention, while I always wanted to lern LISP just that it runs on the JVM isn't a reason to sit down and try it out, acutally since I'm not really fond of Java it is rahter something that makes me careful.
Saying that Clojure has a great way to deal with it's Java heritage, it claims to make Java suck hless (I think it's not their wording but it's the essence). It either hides the Java entirely from you or gives you a ver nice interop thtat indeed makes using java less painful. My cudos to that. I would like to show an example from the clojure.org website:
(. javax.swing.JOptionPane (showMessageDialog nil "Hello World"))
That is about what needs to be done for a Hello World in Java, no classes no crazy main functions, I find that quite impressive.
Okay but I wanted to get to the point what made me curiose enough about Clojure to touch it even so it has the smell of Java stuck to it. Concurrency, since I usually work with ruby and this is the one thing ruby really does horribly, it cought my attention that Clojure promised to be very good with concurrency. It achiefs that by being functional and keeping all datatypes imutabel, which makes sense, everything that can't change is thread safe. But it does not stop there Clojure implement STM (Software Transactional Memory) to deam with cases where you actually have to change state from more then one thread - a nice solution since you don't really have to deal with the details of why it works even in cases where you've a concurent environment.
So in short, I really love this languyge, it is great work and the community is very nice. Everyone who had pondered with the idea to learn LISP it's now a good mement to do so, Clojure provides a good reason to sit down and learn, and it's even quite easy to do so.
MongoDB
Another new software I stumbled upon, acutally in combination with clojure, is MongoDB. MongoDB as the name suggests is a Database. So it is not a traditional relational database but a Document Store. That means it does not store tables with rows and fields that follow a fixed structure but collections that have documents which again have key value combinations without a enforced structure.
MongoDB is fast, I was impressed, since you can add keys for about everything most queries can be performed in close to no time. Another thing that is really nice is that you can store complex data structures as nexted structures or arrays, which is very nice since you don't have to care about refferential integrety and all that annoying stuff.
So it is not hard to notice that MongoDB still is young there are things that just don't work well yet, updating is a pain at times or requires workarounds, the Java Driver is confusing and leaks features, fortunately there is a quite good Clojure driver that encapsulates most of the confusion into a clean interface. And the concurrency support is more or less non existant.
Non the less I think MongoDB is a very nice database and I found it way easyer to use then traditional databases as MySQL, also while I've not tried it yet, MongoDB promisses a good scalability on clusters and clouds which is a big plus in my eyes.
AmberVM 0.0.19
Good news everyone!
Murphy from murfy.de and me set together to work on the next release of AmberVM. It was quite an endeavor, he has worked parallel on a different approach on the ECMA interpreter and and we took the time to merge his work into AmberVM itself so combine the best of the two worlds. We worked through a whole night to get everything done but finally every spec is working perfectly again.
The result are a few cool new features in the ECMA interpreter and Amber itself. The main changes are that the whole parser is rewritten from scratch, or rather we decided to merge in Murphy’s parser for the AmberVM ECMA implementation, then another big move is that the namespace for functions and variables are now combined in AmberVM, this allows it to handle functions as variables or even parameters.
A more complete list of new features of AmberVM in version 0.0.19:
- ambervm now supports -s switch to show the source code it executes.
- ambervm now supports -p switch to show a pseudo code that describes the internal representation of the code it executes.
- The Namespace for Functions and Variables is now merged.
- The this keyword is working corectly!
- Objects scope correctly
- Now a big thing, Closures are working, even mostly correct. Only some odd cases brake the systems as using global variables in Closures. But that’s bad style in my eyes so just don’t do it ;).
- Some optimization.
So let’s see how this works. Have fun with it and if you happen to decide to use it, drop me a line ;)
rVM envolves
Lately I got some chance to work more on rVM, and there is some good progress.
Just the day before version 0.0.12 was released and it steadily progresses towards the 0.1.0. 0.0.12 ships with some nifty new features which mostly results for the fact that I already got the chance to use rVM in two projects, and I’ve to admint I’d not thought it would really work out that well.
A few words to what is new, 0.0.12 now pretty completely covers ECMA script, of cause there are still some things that do not work like the option to create own objects is still missing and the support for leaving away ’;’s in some places is missing. On the other hand it runs quite stable now and even passes most JSON test from http://json.org. Only some negative tests are not passes as the rVM compiler is too forgiving or implements non required features as allowing expressions within a associative array.
For the goal of making rVM easily usable, which is in my eyes one of the most important tasks, acts_as_rvm_type was added which allows to declare own objects as types for rVM in just a few lines.
Here a short example for that:
class Dog
attr_accessor :race, :name
include RVM::ActsAsRVMType
acts_as_rvm_type
register_variable :race, false # Declares race as a readonly variable in rVM
register_variable :name # Declares name as a writable variable for rVM
register_function :bark # Declares bark as a function of the dog object
def initalize race, name
@race = race
@name = name
end
def bark
puts "#{@name} barks!"
end
endThis is in my opinion a big step forward, and it works pretty smoothly with Rails which is nice, some time in the future I’ll add a rails plug in to make this even easier.
At another note due to adding a good few (still not enough I fear) specs to then rVM implementation lots of bugs were tossed away in the last few releases.
Visions
There are a few things I very much would love to see for rVM, one and perhaps the most ambitious is that with rVM it would be possible to run Tests or Specs over JavaScript code without the need of a browser – given it would take a good bit of effort and certainly some work to make the ECMA implementation more conform but I believe that it /is/ possible. Even now I think that for basic and well written JS code rVM might do the job in parsing and interpreting it correctly. But this is just a crazy idea for me ;) while it would be pretty darn cool to be able to do all tests of a rails app within ruby and no need for any foreign frameworks.
rVM on Rails
Since version 0.0.13 rVM includes rvm/rails which is a easy bridge between rails and rVM that allows to quickly add scripting capabilities to rails applications.
The basics are pretty simple rvm/rails comes in 2 parts: First a plugin for ActiveRecord::Base that makes it easy to use act_as_rvm_type with it and second functions specialized for Rails. Currently this is only print() which is used to generate output.
If you are interested have a look at the Screencast or the API documentation .
Open Source frustration
Here a thought about one problem I personally encounter with open source. I like to call it the Open Source Void Frustration which I think a lot of great, and probably even more not so great projects die from.
Generally I’m talking about the feeling that strikes coders when their work hits the world and totally goes under in a void. The leak of feedback, so I believe is a serious problem in the Open Source community. If you’re employed you get feedback, if you want or not – either you keep the job or not, if nothing else.
Think honestly about it, for how many Open Source projects did you actually provide feedback. Ashamed I have to admit that I do so for only a small fraction of those I use. Properly should change that now that I think about it like that.
But getting back to the topic, feedback is important. Even if it’s just submitting a feature request or reporting a bug. The pure knowledge that there is someone out there that uses what a programmer puts likely lots of energy into helps to keep going.
It is the one way that actually is ‘paying’ open source developers, not getting money feedback is often the one thing they ask for in return for their work. Shame on me for being late on a lot of bills here – and likely shame on a lot of those who read that for being as late as I am.
rvm on speed?
After finding this link I got the crazy idea to write the core of the VM in C. I am quite certain it would give a good bit of speed boost especially concidering that at this point speed might matter.
What is the downside? Well I can think of two – it is way more likely that I mess up something in C and thus create a bug that allows harm the system the VM runs, the second is … our best friend Microsoft Windows. Also I’ll have to look into how JRuby handles things like ruby extensions.
So I was thinking to package the whole thing with two versions of the VM core, one written in C if you are either trustfully or sure enough bugs won’t harm too much or speed does matter a lot for you. Then a second version written in pure ruby which would likely be a good bit slower but only bugs in the ruby interpreter would be a concern.
Any thoughts?
rVM
rVM going public
Okay, here we go, I published some ruby gems with rVM, it is way not done and leaks some important features but it is working already. The latest version, SVN trunk, currently supports a quite nice and complete math interpreter. Sure it does not do as much as some full blown implementations yet it can do quite a lot.
It supports now:
- All usuall opperations, +, , -, /, ^ with right priorities.
- Functions sin(123), and custom functions if you wish.
- Parentheses to group operations and overwrite operator priorities.
- Variables, as in x + 3. Those can be set outside of the code by manipulating the passed environment.
- Assignments, as in x=23+19. Which can be read outside the code by reading from the passed environment.
- Sequences of expressions separated by the ; operator.
With the latest two items here new to the implementation and perhaps most important. And most interesting. One feature added today is allowing to generate sequences by using ; as a separator, thus making it possible to chain up operations over multiple lines.
If you feel like checking it out:
svn co http://code.licenser.net/rvm/trunk rvm
cd rvm
rake gem
gem install pkg/
also
rdoc README lib/
gives you a nice overview about some things as well as the short howto and example at
http://code.licenser.net/documents/show/5
That will install you the latest gem from the trunk – Have fun and I’m always happy about feedback ^^ and or tickets at:
http://code.licenser.net/projects/show/rvm
Lice! goes Redmine
Okay, Here I found a new peace of software. A lot of you will know Trac already, it’s a nice tool. So recently I got hinted to redmine. It is also a issue tracker, and seems to be quite similar in it’s functionality to Trac. Good part is, it’s written in ruby.
The for me most interesting feature is that you can have multiple projects at once. Beside of that it of cause has a Wiki, bug reports, feature requests, version management, a repository browse and a bunch of more features.
Now the best news is that I’ll not use this thing with nothing, two projects (RMush and RedICE) are right now there, including read access to the SVN repository. Of cause I hope that some people are going to try them out ;) and give some feedback. Bugs are fixed quicker when reported – I promise!
Lice.
Ruby Mush goes public
Okay just a short note here.
Ruby Mush goes public, kind of at least. I’Ve set up a issue tracker for people who are interested to follow the development.
The current task I am at is writing specs which is a nice alternative to Test::Unit and at least for me, way better suited.