Dienes' Blog

Drifting In The Developers' Dilemma

4 notes &

Forum Drift

What is it with people not being able to stay on topic in message board threads?

I was just checking the status of Magic Online’s new client that is in development. Headed over to their site and read through the first page of the discussion about the latest news topic they published. Then I was like “Okay, nothing new here, think I’m just gonna jump to the last page to see what the current status is.”

Turns out, current status was:

Aug 19, 2011 — 5:53PM, nushae wrote:

Pizza is a mess.

Aug 20, 2011 — 7:43AM, SharpChute wrote:

It sounds like you’ve never had a good sandwich…

I mean… seriously, guys?!

Filed under forum off-topic magic the gathering

0 notes &

Breeding Spiders

There’s been a big spider on my window for some weeks now.

Today, I came home from work and suddenly - 15 (fifteen!) tiny little spiders on my window. All having their tiny little webs and catching tiny little flies.

Cute.

Getting vacuum cleaner now…

Filed under spiders

4 notes &

Befunge and RunFunge

As mentioned last time, I’m going to say a few words about Befunge.

Befunge is an esoteric programming language, i.e. a language not meant to be used in actual projects but to experiment with unconventional ways of programming. It has a limited set of commands to perform basic tasks like standard I/O and maths. Memory is managed via an internal LIFO stack you can push to and pop from. Seems to be nothing special, right? Well, there are some interesting aspects I particularly like.

2-Dimensional Instruction Pointer Movement
In Befunge, every instruction is written with one single character (think Brainfuck). By default, commands are processed left-to-right in the source file. But having each instruction as a single character means we can arrange the commands in a 2-dimensional “grid” just by using line breaks and spaces (and preferably a mono-space font). And suddenly, it’s obvious to think about processing them not only left-to-right and/or downwards, but in any direction we want - changing on demand during runtime.

And indeed, Befunge can do that. There are commands (like “<”, “>”, “^” and “v”) that cause the instruction pointer to immediately change its moving direction and process the instructions in a different order. This allows the same code portion to behave completely different by “playing it backwards” or to create visually and logically looping code segments without a dedicated “while” or “repeat” statement. Also, conditional statements visually split into two separate code paths, e.g. one leading downwards and the other upwards.

Reflection
Oh yeah, reflection. Code that is aware of itself. Code that can modify itself during runtime. I love it.

Befunge allows you to access the “code grid” (the source file basically) as a x/y coordinate system. Having a position, you can read the instruction at the given cell and change or erase it. This technique allows for adaptive code, code that learns, or it can be abused to store data and circumvent the memory stack.

Expandability
Befunge has such a simple structure, that it is easy to write interpreters and debuggers for and to extend by inventing new instructions and assigning them to characters on your keyboard.

RunFunge
Some years ago, I had written a Befunge interpreter in C++ called RunFunge. Today, I did some minor refactoring of the code and released it under GPL on Bitbucket. Along with a Befunge-93 mode, there are a bunch of extension commands implemented that I came up with. Those include new ways to change the IP’s processing direction, two distinct and interchangeable memory stacks, and a technique to write sub-routines/procedures that can be called.

Have fun with the code!
And since I did not test it properly, feel free to report any issues and bugs to either me or Bitbucket’s issue tracker :)

Filed under programming coding c++ befunge runfunge esoteric interpreter

3 notes &

What the Thread?!

BackgroundWorker… ThreadPool… ManualResetEvent… I think I lost the thread.

First attempt at doing multi-threaded applications in .NET and I’m reading more MSDN and StackOverflow than coding.

Why oh why can’t I access GUI controls from within BackgroundWorker’s DoWork()? :(

Edit:

Spend 12 hours refactoring an application to make it multi-threaded, measure a performance increase of 3%, rage. Then find out you have a single-core CPU at work.

Everything went better than expected.

Filed under .net multi-threading programming threads coding

7 notes &

See Sharp Reflection

Reflection in .NET is awesome.

I’m only scratching the surface so far, but I already love the possibilities that come up with this mighty tool.

At work I’m currently developing some internal QA tool in C# in which I needed to save properties of classes to XML. The thing is, the classes I need to save could be anything (but deriving from a known base class) and bring their own bunch of properties that need to be saved as well.

At first I tried to use an XmlSerializer, but it was not flexible enough for my needs. So I did some googling and found out about Reflection, which then allowed me to just iterate through all PropertyInfos of the class, do some checks on them and write the desired ones into the XML stream.

Code that is aware of itself and can modify itself during runtime is mind-boggling but amazing. I first heard about such a thing some years ago when I stumbled upon Befunge, an esoteric language for which I had also written an interpreter in C++. I’ll do a post on that one, too, i guess :)

Filed under programming c sharp c reflection .net

0 notes &

The Developers’ Dilemma

So I realized that I’m in the Developers’ Dilemma. Specifically in the Game Developers’ Dilemma. What that means? Well, the more you program, the more you create and build, the less you enjoy the things others made for you.

Back in the day, I was a gamer.
I played all kinds of games, on PC and on consoles. I had been in several clans and spent most of my free time playing. It was fun, I really enjoyed the games and I was totally excited for every game or update release.

But I also loved programming.
In first grade elementary school, we were asked to write down our dream jobs on little pieces of paper and pin them on the classroom door. Mine said “Game Developer”. With as little as seven years I knew what I wanted to do. I had never seen a single line of code, but I had played games and it was an amazing thought to be able to create games on your own, games that are exactly how you want them to be, games to express your infantile imaginations.

With eight years, my parents bought my first computer, a Commodore 64. This was a life determining day. I played lots and lots of games on it, until one day, my brother (who is eight years older than me) told me, that he had written an adventure game on it. It was just a plain and simple text-based multiple-choice system game, but I was fascinated. I could not imagine how he had done that. And it took me quite a while until I convinced him to show me the “internals”.
Basically, it was a bunch of conditional statements and interweaved string outputs and looked like total garbage to me, but I knew I wanted to learn how to do it. I grabbed a BASIC manual and started copying different code samples to see what they did. To me, those codes had no structure whatsoever. I imagined each “result” you want has a specific set of wildly thrown together characters and numbers which you had to either guess or learn by heart or something.
But as time went by, I found similarities between code fragments, things that appear everywhere and vary only in specific parts. And with the help of my brother, I learned a few statements (print, input, if and for) I could concatenate to achieve certain behaviors. After a while, I was able to write my own little text adventure and I was proud of myself.

This marked the beginning of my passion for programming. The journey continued on the PC, where I coded in Blitz Basic, Object Pascal, Visual Basic and finally C/C++ when I had computer science at school. I fell in love with C/C++’s syntax and the total freedom you have with your code, so this became my language of choice to further deepen my knowledge and skills.

Over the years, I made a lot of progress and wrote hundreds of little programs. But the more skill you have, the more you can do, the more you want to do and the more time you need to invest in always bigger and bigger projects.

And at some point, you start to look at things with different eyes. I experience this mainly with games. Before, you could just play and enjoy the game, have fun with your friends, and that’s it. But now, you start to question the game, you start to over-analyze it. You ask yourself, how this and that was done, how it was programmed, how it would look like “under the hood”. And the more you analyze, the more flaws and limitations you notice. The game loses its magic, it merely becomes a predictable system. You feel the desire to change the game, to copy it, to make it better. To a certain degree, you even develop jealousy of the creators thinking “I can do that as well!”.

Now I’m enjoying developing games way more than playing them. In fact, I cannot play a game for longer than let’s say 30 minutes, after that I have to quit and do something else, something more “productive”. I play a game and immediately ask myself why technology X is not implemented even though it has been in game Y. I subconsciously analyze the game mechanics while playing which allows me to determine precisely what will and will not work in the game. All the apparent freedom you have in the game instantly vanishes, and the game gets boring.

Nowadays, I come home from an eight hour day of work, boot the PC, fire up Steam with 108 registered games and then start coding stuff.

This is a Developer’s Dilemma.

Filed under coding programming dilemma