Welcome to the world of Haskell!

In the past three months I have had the pleasure of learning a strange yet interesting new programming language: Haskell. Initially I was quite sceptical about this language. After all, some of the most basic (imperative) concepts I knew looked so hard to implement in Haskell. And the fact that people allegedly had finally found some use for functional programming languages, did not really excite me either. But in the end, Haskell turned out to be quite fun.

In this article I would like to look at some Haskell features I really liked. As I know that most of our readers are not Haskell experts I have decided to keep it quite general and simple.

Function transformations

Function composition

Function composition is a technique of combining two functions into one function.

f1 . f2

This says that function f1 should be applied to the result of applying f2 to its first parameter. So, above code could be rewritten to:

(.) f g = h
where h x = f (g x)

The type of h can be deduced like this:

f :: a -> b
g :: b -> c
– Thus:
h :: a -> c

Function application

Function application is not exactly a very exciting feature, but it is helpful as it helps you to get rid of annoying extra parantheses.

f1 $ f2

This says that function f1 should be applied to the result of function f2. Now you are probably what the difference is with f1 f2.

When you simply type f1 f2, f2 is considered as a parameter for f1 and all of the parameters of f2 will be considered as n-ary parameters of f1. When you type f1 $ f2 you first apply f2 to all the following parameters, and f1 is then applied to the result of f2.

So, for example:

sum x y z = x + y + z

successor x = x + 1 — A better alternative is discussed in the next section!

test1 = successor sum 1 2 3 — Will not work. After all, you cannot take the successor of a function.
test2 = successor $ sum 1 2 3

Partial parameterisation

Partial parameterisation is a technique to partially satisfy a function. This technique can be used to create new specialized functions.

For example, if we would want to declare a function that gives us the successor of the given integer, we could simply write:

successor = (+) 1

or

successor = (+1)

This would make the following example valid:

> successor 41
42
> successor $ successor 41
44

successor is of course an incredibly easy example of partial parameterisation, and it might give you the impression that its just a gimmick. However, in combination with function application and function composition its an incredibly useful mechanism.

A slightly more complex example, is a function that gives us the successors of all elements in the given list.

successors = map (+1)

Operators

Another cool feature of Haskell is the ability to define your own operators. As this is actually rather simple I am not going to spend much attention to it.

Lets say we would want to express addition and substraction through smilies. It could be done like this:

x ^-^ y = x + y
x -.- y = x – y

Or with partial parameterisation in our mind:

(^-^) = (+)
(-.-) = (-)

Which would make the following valid:

> 1 ^-^ 2
3
> 3 -.- 1
2

In the latter definition you can see how operators can also be used as functions: you simply put parantheses around them. And the fun thing is that a similar trick can be applied to functions with two parameters:

min :: Int -> Int -> Int
min = (-)

> 3 `min` 1
2

In order to use a function as a operator you have to put backquotes around it.

Again, this might seem like a gimmick, but it can be pretty useful in the field of “symbolic evaluation”. But more on that another time.

Lazy evaluation

Lazy evaluation is one of the most powerful features, if not the most powerful feature, of Haskell. Lazy evaluation is the technique of delaying a computation until the result is required. This means that the data that is required for a computation is retrieved at the moment that the computation is actually executed. This makes it possible, for example, to work with lists of infinite length without actually computing the complete list. As lazy evaluation is beyond the scope of this article I would like to refer interested readers to Wikipedia, which has a nice article on the matter.

And with that I would like to conclude my first article about Haskell. I hope you enjoyed reading it. And as always: if you have questions or comments feel free to post them.

Re: Language

These features are pending proof of concept implementation. Currently I’m very busy with my study and my job and Maurice is as well so you probably won’t see anything anytime soon. But to be honest, from my side it’s also laziness. But today I sat down and wanted to come up with some algorithms.

Read the rest of this entry »

HAI! / Language

Hello World! I’m Maurice, I’m new to .simplicity, nice to meet you, etc.

Language

I’ve been experimenting with some fun stuff lately, it involves language, programming, password-dictionaries, spell checkers, and more :) .

Read the rest of this entry »

Free Gaming Alliance – Continued

Some while ago I wrote an article about the Free Gaming Alliance, an organization that could help with the promotion and development of Free Open Source Games. At the time that I wrote that article I was not sure how well it would be received by the public. In the end the reactions turned out to be fairly positive.

Lets start with a reply to the original article. Some while after the article was published on .simplicity Valentin Anastase from the non-profit organization Freezing Moon replied. He provided a link to two sites, including Freezing Moon’s, dedicated to free gaming. Freezing Moon comes close to the idea that I sketched in the previous article, but it is not completely the same. Opposed to the Free Gaming Alliance, Freezing Moon actually develops games themselves. While I think that we should first deal with other issues concerning free gaming, I am happy to see an initiative like Freezing Moon and I encourage people to check it out.

Another interesting development can be found at OpenGameArt.org. OpenGameArt.org is a website that hosts “free, legal art for open source game projects”. It started small, but the amount of art has been growing fast. And the art that is being hosted on OpenGameArt.org is certainly not bad; it looks very good. If you are looking for art for your Free Open Source Game or want to support free game art (OpenGameArt.org accepts donations), then definitely check OpenGameArt.org.

So, there are initiatives focused on Free Open Source Gaming, but what about me? Through Sirrf I am trying to improve the Free Open Source Gaming ecosystem. I am wondering if I can have an impact on it in other ways, though.

.simplicity Code and Java Sigslot Event System

Today we are launching .simplicity Code. .simplicity Code is a project created to maintain open-source projects from .simplicity that are too small to be considered as full-blown projects, but too big to be considered as simple code snippets. We are launching this project, because we often work on small projects without any other target audience than ourselves. These projects are the typical projects that are started out of self-interest. We recognize, though, that the code we write for these projects can be of interest to our visitors. .simplicity Code offers us the opportunity to publish this code, without having to offer complete support as a full-blown project would require. As a matter of fact most projects on .simplicity Code will have limited to no support. That does not mean that you will find junk on .simplicity Code. On the contrary, you will find that the code will be most of the time of the same quality as our bigger projects.

Read the rest of this entry »

Sirrf version 0.2.1 released!

0.2.1 is here, 9 days later the simple irrlicht framework team re-emerges with a feature and bug release. Some bugs have been fixed and some new features introduced, the changes include :

  • Script-side GameStates
    It is now truely possible to derive from the GameState class (through CGameState) in scripts. A bug in previous versions prevented this, but this bug has now been fixed.
  • Script-side Components
    EntityComponent can be derived from script-side (through CEntityComponent), classes in script can now create components and register them with entities from script or engine side.
  • Script-side Events
    The event system is now integrated into the script engine. Script-side classes can derive from IHasSlots and can register, connect and disconnect from slot events.
  • Important Bug Fixes:
    • Construction of entity components with parent is now relatively safe. If you are not sure whether your component has a parent, check it after construction. If the component has no parent, destroy it as quickly as possible
    • AssetProcessors on windows were never loading assets unless the files were all lowercase, restrictions were irrlicht related but solved.
    • Minor bug fixes with script side things, Scolor fixes, asset groups on entities and much much more.

Useful links
SourceForge.net page – http://sourceforge.net/projects/sirrf
Downloads – http://sourceforge.net/projects/sirrf/files/ | http://www.ohloh.net/p/sirrf/download?package=Sirrf
Documentation – API | Tutorials

Sirrf version 0.2.0 released!

The latest release of Sirrf, the Simple Irrlicht Framework, version 0.2.0, is now available for download. In the two months since the previous release a lot of changes have taken place. These changes range from small API changes to major feature additions. The most noticeable changes include:

  • Asset Management
    The biggest new feature is asset management. Assets are managed by the AssetManager class. This manager manages so-called asset groups, which represent a collection of assets (meshes, textures, etc). These assets are retrieved from a directory with the appropriate directory structure. In turn the found assets are processed by asset processors. And at the end of the road, the user can use these assets without having to deal with paths. Furthermore asset management makes it possible to reload all assets in realtime, with direct results on the current scene. Reloading assets is as simple as one function call.
  • XML-based Entity files
    It is now possible to load data concerning entities and their components from XML-files. This means that you can now define a scene through XML-files.
  • Local Event System
    As of version 0.2.0 a HasEvents class, which provides the base for a local event system, is available. The availability of local event systems makes the entire framework more performant. Currently the HasEvents class is used by entities and asset groups.
  • Microsoft Visual C++ 2008 support
    Version 0.2.0 is the first release that officialy supports Microsoft Visual C++ 2008. This should make it easier to set up Sirrf-based projects accros multiple platforms.

See the change log for more information regarding the changes in Sirrf version 0.2.0.

This is not the end of Sirrf’s development, though. Sirrf’s development will continue and Sirrf will undoubtely become even better in the future. And you, as a Sirrf user, as a member of the Irrlicht community, can help us improve the framework. This can be done by contributing code to the project, but also by testing the framework. Either way, we hope that Sirrf will be of use.

Useful links
SourceForge.net page – http://sourceforge.net/projects/sirrf
Downloads – http://sourceforge.net/projects/sirrf/files/ | http://www.ohloh.net/p/sirrf/download?package=Sirrf

Ohloh

For some time now I’ve been active on Ohloh. Ohloh is a website dedicated to tracking open source software development. By retrieving data from Source Code Management (SCM) systems Ohloh generates statistics about languages, projects and users. Thanks to this developers get access to new information concerning their projects, which in turn can be used to improve those projects. However, the real value of Ohloh will be found by outsiders of a project. Ohloh’s project pages are simple and provide those details that one might need to determine the status of a project. And while it might sound insignificant, it’s actually quite important as it might be a user’s first impression of a project.

All in all, I think Ohloh is an interesting service. Certainly something worth a visit. And if you decide to visit Ohloh, don’t forget to visit my user page too.

Arduino Electrical Drumkit and superint

We’re (Maurice and I) building one! I hope it works out well, so far it looks really neat and extremely basic. The “drums” are wood with a mousepad on glued on top, standing on a wooden pole that stands on a wooden base. The 2 drums in the middle are hopefully looking the best but are yet to be made. Their base is handcrafted and polished and rounded and owell. The electronics aren’t too hard we hope, some piezo buzzers, zenerdiodes and resistors and an arduino. Nothing too complicated right? We did run into a small problem: We need 7 analog inputs. We have 6. So the first version will probably have a digital basedrum. Owell.

Besides that we’ve (Maurice and I again) a arbitrary length number class, dubbed superint. Original huh? It’s efficient with the bytes and cycles, uses x86 ASM for all the instructions and gives the right answers. Currently support addition, substraction, multiplication, division and modulus. We’re making a version 2 with what we’ve learned so far which will have some more features. Stay tuned for the source, zlibbed we thinks.

What’s Nick Doing?

Hey guys,

Sorry for the long time no post! I promised an abstraction tutorial. It isn’t coming, still can’t find examples. The articles I write just spin around my mind a bit, evolve in there and then come out with some reviews. And besides half of my review crew is currently unavailable (Maurice is on a vacation), they aren’t spinning in my mind.

“But Nick,”, I hear you say, “what ARE you doing, programming-wise?”

Glad you asked! However, it’s very, very little. I’m busy with Pixlings. I realized that this is a much bigger project than I anticipated. There are so many parts doing different things that need to work flawlessly together. In contrast, all of my programs until now had one objective and were no longer then a few hundred lines perhaps. I wrote tons of those, but bigger projects are really a lot harder. Therefore, I’m now focusing on game-development in general, development on Pixlings has seized until I am a better game programmer. Can’t tell a couch potato to run the marathon eh.

Besides programming there are many, many parties. This weekend wrecked me, slept very little and when I did it was at unfortunate times. I leave it up you to figure that one out for yourself.