Auld's introduction and reasoning for writing 4kb intros

4ks: An Introduction

The Joy of 4k

May aim in this article is to inspire you to try 4k coding if you have never done it before. Its a fantastic experience learning how to do it and knocking down the information barriers one by one as you get to the goal. In essence I’d like to share some of my ethusiasm and passion for this rather obscure little art and hope it rubs off. Making 4ks is a coding joy, a challenge that you are unliekly to encounter at college or work. It pushes you to think differently and to embark on a voyage of discovery - just for the sheer adventure of it all. Yet its an adventure that can be done from your armchair safely in the comfort of your own brain.

What is it Really?

Demos, as you probably know are non-interactive real-time computer graphics and music. Intros are, in essence, demos in a limited space. One category of intros is the 4k. Yes, 4096 bytes. Using fairly simple (initially) tricks, techniques and tools, code can be trimmed, squeezed and squashed into a tiny space and still include the essential elements of demos: music and graphics. Starting out it seems impossible. You compile your minimal “Hello World” code and its suddenly 20k or worse.

The great thing is, with a little help, yoiu can get below 1k in a matter of a few hours and then you can start being creative, btoh in your demo and in the techniques you use.

So Why do it?

Well, its not for money. Largely its not useful for employment either. For me, I can’t spreak for others, I find it a new dimension in programming I simply havent thought about before. As such the challenge is fresh. I’ve coded for 20+ years but when I discovered 4ks, I had a fresh new burst of coding energy. What I thought had become a boring or repetitive task (such as writing a for loop) suddenly became full of questions. Something as simple as a for-loop came into question and became a revelation.

In addition to this an intro is a joyful thing. It has graphics and music and is limited by size and imagination only. Its a way for a coder to express things, be they emotional (a dark moody demo) or intellectual (my code is awesome- watch this).

In the end though, for me at least, the intellectual challenge in taking a graphics algorithm and squeezing it down and down to impossibly small size is one I take great pleasure from. There is very little documentation and its a very personal journey (I might even say introvert) but it feels like you are pushing barriers and learning everyday.

Of course its also a proving ground. Maybe your goal is to get into conspiracy and do kick-ass 64k intros. Well 4k is a way to prove yourself, to show how good you are. 4 or 5 4ks later and you might find yourself recruited by rgba or fairlight. Maybe.

Why 4k, not 64k or 256b?

Of course the other intro sizes are great too and you’ll want to try them. 256b is for assembly code writers which you may want to do. Its a limited field and doesnt show your potential to do something larger. 256b is hardcore and definitely to be respected but 4k gives you so much more room to express yourself and to produce something that will leave a lasting impression. As well its much easier to get started in C coding a 4k than in assembler coding if you dont already know assembler.

4k, as I said above is good training for doing a 64k which is a huge undertaking for a newcomer. 64k may seem like a tiny amount of space to you but have a look at Paradise by rgba and you’ll know just how much work has to go into a good 64k. Its just not so easy for a newcomer to do well in 64k which is perhaps the hardest category of all which has demo quality expectations but a limited size too. Really only teams can achieve good 64ks today.

4k is not a lot of space but its enough. Its a manageable job for a newcomer and honestly many 4ks are still quite low technology or quite simple effects. There is a lot of room for newcomers at this size. Inferno, my first 4k, is a great example of fairly easy technology that did very well because it was put together well and squeezed a lot in. There are no great secrets here - anyone could do it.

Who Does it?

Well 4k isnt big enough for artists to squeeze in images of any quality. Music too is often quite functional and often done by the coder. So 4ks are for coders. They are the largest size done by only coders because today 64ks are usually done by coders, artists and musicians working together. So if you write code and you want to try making an intro, 4k is the size for you.

4ks are small enough that they can be done by one person (the coder) yet large enough that several ideas can be squeezed in, geometry, texturing, music, storyline and so on are all possible in just 4k of executable.

In general most people doing this are around 20-30 judging by surveys but there are some oldies too (like me) so don’t worry.

What Skills Do you Need?

Well I started a year ago now and I have won one competition. I started with no knowledge of how to get code small, some C programming skills and some graphics knowledge. I guess you dont need anything more to start therefore than I had. On the way you will learn about music, what makes a good intro versus a bad one, some assembler (dont worry its almost optional at 4k, but advanced intro coders use it), some graphics, some basic tools and a heck of a lot about which is smaller, a for loop or a while loop.

You learn and learn and learn. There is now a lot of information to help you but you still have to search hard. IN4k is a great place and has simplified the job enormously. It took me almost 3 months from finding out what a demo was to making my first 1k product for launch on Pouet! No sound involved.

Do you Have to be a Kick Ass Coder ?

Yes and no. Yes it helps, no I am not. You need two real skills: determination and software design. I’ve seen too many examples of “kick-ass” coding using an algorithm thats twice as large as a possible alternative. Being able to think laterally about design and the determination to scrap your code and try another way for 50 bytes saving is what it really takes it seems.

You will learn each day to improve your coding skills. There are quite a few source codes around and you will be amazed how skilled some people are in coding.

I Learnt so Much

Hmmm I didnt know about in-line GCC assembler, nor the difference between __stdcall and __fastcall. I didn’t know that double was the default in GCC nor how to create DLLs for windows (I was a Unix guy). I didnt know about music or the 44 byte wav header. I didnt know how a triangle wave sounded. I didnt know it was possible to do raytracing in 1k or entire games for that matter. I didn’t know my code was bloated. I didnt know how to link delphi and C. I didnt know how the floating point stack on an intel processor works, nor how to use OGL and DX maths together. I didnt know how to write opengl shaders. I didnt know how to handle extensions under windows. I didnt know about methods for importing functions form DLLs.

I could go on. Really I could. You will learn so much, use a fraction of it and become a better programmer for it.

Conclusion

4k demo coding is a wonderful learning adventure. Its a serious element of programming that teaches you to think laterally and differently to your peers. It strengthens you as a programmer and pushes you to get better. I don’t know where the end is for me. I’m a much stronger programmer now plus I get a wow factor from my colleagues (you did that in 4096 bytes - no way!). Its like becoming a magician with code as your magic. Yet, for something average its really not that hard.

Its an individual thing, something you can do alone. Its accessible these days and not so hard to start. Yet to an outsider, a coder who never did it, it still causes wonder and amazement. I’m a software manager who has a lot more respect from his staff now when I pull out my latest 600 bytes of code than I ever did before.

Want respect? Code a 4k! You’ll love doing it.