One of the most distinctive features of Common Lisp and Lisp in general, are its code-generation and code-manipulation capabilities.
Probably the best example is the LOOP macro – a Swiss Army knife of iteration that can do pretty much anything. The following snippet iterates a list of random numbers collecting some statistics of its contents and does that while being very concise and readable:
So, I finally found some time for a Template Metaranting follow-up post. This time let’s get down to business as this one contains a fair amount of code.
Sadly, I won’t rant as much but instead I’ll try to show how awesomeD‘s templates really are. We’ll write a piece of code, based on this Scheme implementation, that is, a simple monad that we’ll use to build a binary tree, with uniquely numbered nodes containing their height, without any global state (therefore purely) entirely at compile time.
Let’s talk about templates.
If you’ve ever tried templates in C++ you surely as hell recall the pages and PAGES of compiler errors and seemingly random placement of typename keyword.
Trust me, there are EVEN WORSE problems with templates in C++… Consider the following:
Hello fellow programmers.
Look at your favourite programming language.
Now back to Lisp.
Now back to your favourite language.
Now back to Lisp.
Sadly, it isn’t Lisp, but if you stopped wasting your time, it could feel like it’s Lisp.
Where are you?
Reading in OldSpice-guy’s voice as I introduce the ASM programming language.
What’s on your mind?
Back at me.
ASM has it. The expressiveness and brevity augmented by powerful and extensible features.
Look again. ASM is now usable.
Anything is possible when your programming language is functional and not imperative.
It’s highly munctional. Continue reading →
Our library is quite successful and many people are using SomeMetaVariables despite its obvious flaws.
Now, say we get many requests for additional functionality, for example:
“Make bartrue only when foo is set to “foo” and other way arround.”
“Well, ok.” – we say and commit this new version of SomeMetaVariables:
I didn’t make it on time with (car ‘(3)) and it’s been quite a while without any updates, so let’s have a quicky with a little tool I’ve made lately.
The assignment was to load a part of the OpenStreetMap and give the good ol’ Dijkstra a spin in it, pretty simple yet quite fun.
I figured it would look nicer with some sweet GUI so… I didn’t make any.
Instead, I went with some minimal OpenGL window and a buncha’ lines and squares. Still cool, right?
I called it City Blueprints and you can get it here. Some screenshots follow.
It’s been a while since my last post, more than I’d wish for actually, and that is because I was hunting a man by the name Iain Bucław on the IRC.
I had to make sure he was ok with me using some of his work in this next project/post (and he obviously is, oh the kind gentleman he is).
Last time I shared some thoughts on latmab, a simple algebraic calculator, I have… commited and todays topic is somewhat related. It’s a continuation I’d say, but let’s go on with the story… Continue reading →
So, I’m going to break the usual design-quirk rutine and actually show something fun this time and then we’ll return to some OOD stuff I was planning to post.
It all started with an assignment me and my brethren freshmen got on our programming subject that would be loosely translated to Programming languages and design methods I believe.
We had to code a rather simple algebraics calculator that uses infix notation and supports several math functions such as factorial, power et cetera.
The more advanced version of this assignment had to implement integrals and plotting so I thought “why the hell not?”.
Obviously I didn’t aim for the second version as it implied a rather advanced framework that would support all kinds of goodies, because I can’t stand writting a piece of crap that’s only purpose is to work past the rating tests, and such a framework, the fun experience it might be, would take lot’s and lot’s of time to become of a satisfying elegance level.
Yeah, I am picky, you don’t even imagine.
Anyway there it was, although I wasn’t quite satisfied with it, keeping in mind all this “advanced” and “framework” stuff, it turned out quite… we’ll see.
It’s a fairly specialized class hierarchy providing some functionality, let’s say for the sake of this example that SomeClass provides a kind of player-game interaction interface and HierarchyWith defines it as a trigger based interaction (as in “a player does something – it triggers a response”).
Our ExampleClass represents an entity that can be triggered by the player and that generates some response and in addition to that is further specialised to have some concrete functionality – let’s say it’s a lever that a player determined enough can pull to flood something with delicious magma. As we clearly can see ExampleClass is well-defined in terms of OOP, it’s highly specialised and modular, but as an in-game entity it lacks a rather crucial functionality – it can’t even be displayed on the screen.
What do we do now? Continue reading →