share
Stack OverflowAmazing programming achievements
[+39] [22] Sandman
[2008-10-22 12:30:37]
[ example ]
[ http://stackoverflow.com/questions/225546/amazing-programming-achievements ] [DELETED]

I recently found this article [1] about how some guy managed to write a super mario game in just 14k of javascript code. Ok, it's not a full game, it's not even a full level, but still - 14k of javascript, without any external graphics files... I, for one, congratulate the person that managed to do that..
Then I found this article [2] about Wolfenstein 3d, also written in javascript(!).
Anyway, I was wondering if any of you know of a similar amazing/weird/fun coding achievement that you would like to share with the rest of us. Write about things like extreme examples of optimization, or successful use of some language/technology to do things it was never intended for.

(4) I hate to be controversial but I do have to say that I don't think these examples are really examples of great programming, most of the code referenced would be horribly unmaintainable, so in a sense these are the worst examples of coding possible... just sayin'... - kronoz
I never said I was looking for the best-written code. You're right when you say that most of the examples here would probably be horrible to maintain. The point was to see how people push the limits of technologies at hand, how they do things most of us would consider nigh impossible. - Sandman
And where is The Mushroom in Mario ? :) - zxcat
[+23] [2008-10-22 13:45:27] TraumaPony [ACCEPTED]

You may want to look into the Demoscene [1]. For example, .kkrieger [2] is a 3d FPS which takes up only 97,280 bytes of disk space.

Another example of some of these is here. [3]

[1] http://en.wikipedia.org/wiki/Demoscene
[2] http://en.wikipedia.org/wiki/.kkrieger
[3] http://conspiracy.hu/releases.php

I have been seeing those 64k demos for years. Absolutely amazing stuff. - Jason Z
Yeah... It's a pity that .Net makes size-demos WAY harder now :/ - TraumaPony
@Jason - yeah, I've been seeing stuff like that for some time now... and I agree - it is pretty amazing what people can do. Imagine the level of both programming and artistic skill you need to make something like that. - Sandman
@TraumaPony: No one is forcing you to use .Net though, are they? - korona
No, but I'm still learning C++. - TraumaPony
kkreiger isn't necessarily demoscene but it's definitely the most impressive example of procedural generation I've come across. FU Spore. - Rob Stevenson-Leggett
1
[+20] [2008-10-22 12:37:34] ConcernedOfTunbridgeWells

Elite [1] ran on a 2 MHz 6502, doing 3D wireframe graphics in a little over 20k of available RAM. It defined its own screen mode (which was actually fairly straightforward to do on a BBC) and timed a change between two and four colour modes to within a single scan line on the display (which was somewhat more clever).

DOOM [2] did texture-mapped graphics fast enough to run playably on a 386 (I played the game on a 20 MHz 386 with an ISA video card). It was also portable - originally developed on a NeXT [3] computer and subsequently ported to DOS. The entire game engine was something like 30K lines of code.

Many years ago A friend of mine [4] implemented a 64 channel data logging system on a Cosmac [5] with 256 bytes of RAM and 2K of ROM. In order to do this, he wrote a FORTH [6] VM in 30 bytes of code and wrote most of the system in Forth. To develop this, he wrote an emulator for the RCA 1802 instruction set on his PDP-11/03. [7]

[1] http://en.wikipedia.org/wiki/Elite_(video_game)
[2] http://en.wikipedia.org/wiki/Doom_(video_game)
[3] http://en.wikipedia.org/wiki/Next_Computer
[4] http://www.fi.uib.no/Fysisk/Teori/KURS/OTHER/newzealand.html
[5] http://en.wikipedia.org/wiki/RCA_1802
[6] http://en.wikipedia.org/wiki/Forth_(programming_language)
[7] http://en.wikipedia.org/wiki/Pdp-11#The_LSI-11

Ok, you had me until "a FORTH VM in 30 bytes of code" - Adam Davis
Yikes, I remember having to develop for the 1802, a truly grotty chip, given I was into z80 at the time. I anticipate 1802 assembler fueled nightmares later tonight :( - Shane MacLaughlin
(2) The Forth VM is for real - apparently the SEP/SEX instructions make them quite simple to implement on an 1802. - ConcernedOfTunbridgeWells
Tell me more about this SEX instruction :-) - Ferruccio
@Ferruccio - en.wikipedia.org/wiki/RCA_1802#Registers_and_I.2FO - ConcernedOfTunbridgeWells
2
[+19] [2008-10-22 14:46:47] T.E.D.

Really the best such stories you are going to find are in the annals of computer Folklore. Back in the day programs weren't quite so big and people had to do really insane things to get them to fit and run properly on the tiny, slow machines that were available then. These days we are kinda spoiled.

One of my personal favorites is the story of Mel [1]. I'll give an executive summary here:

Imagine a system where memory (including instruction memory) was a constantly rotating drum. Now imagine a programming language where every line had a goto (for the location of the next instruction on the drum) at the end. The idea would be that you optimize your program's execution time by scattering your instructions across the drum in such a way that the next instruction always happens to be right under the read head when you are ready to read it. Now imagine that you decide to further optimize things by using instruction codes for constants when the values you need happen to match one of them. Imagine that your method for programming delays would be to ask for memory acesses that you knew would be on the far side of the drum when needed. You'd have to be some kind of genius to keep all this straight in your head, right? That was Mel.

Mel was told to make a Blackjack program for tradeshows. Mel dutifully did so. Mel was then asked to make it cheat in favor of the human when a secret switch was thrown, so their preferred customers wouldn't loose as much. Mel didn't like making his program cheat, and did so only under extreme duress. However, it turned out there was a bug, and instead it cheated it it's own favor when the "cheat" switch was thrown. Mel, happy now, claimed that clearly his "subconcious was uncontrollably ethical" and refused to fix it.

So one day, after Mel leaves, the narrator is asked to look at the code and see if it can be "fixed". A large exposition of various discovered optimizing tricks follows. The final straw came when the narrator came across a loop with no test for exiting whatsoever. It nonetheless exited just fine when run. It turned out Mel used arithmatic overflow to change a neighboring instruction into a branch. Seeing this, the narrator admited defeat and told managment it couldn't be done.

I'd encourage reading the full story though.

[1] http://catb.org/jargon/html/story-of-mel.html

That was... wonderful. Thanks for sharing it. - Firas Assaad
I've read that story a couple of times and think it's brilliant. - Valerion
3
[+12] [2008-10-22 12:39:03] Stu Mackellar

I always find the entries in the International Obfuscated C Code Contest [1] fascinating. Some of the techniques that have been used over the years are truly magnificent.

[1] http://www.ioccc.org/

4
[+8] [2008-10-22 13:41:35] Shane MacLaughlin

The most amazing for me was ZX81 chess [1], which you could play against the computer in just 1k. And that 1k was the entire system memory, some of which was used for display, stack, etc... I don't see many of us ever getting that efficient again.

[1] http://users.ox.ac.uk/~uzdm0006/scans/1kchess/

ZX80 ROM that contained the Basic, character patterns, all I/O for keyboard, tape and display (it used a shiftregister for that)...is pretty impressive too I think :) don't think they did any updates after it was released too - epatel
oh yes, it was only 4096 Bytes - epatel
True, but the screen flicker was way annoying (e.g. no animation), for me the move to a spacious 8k on the ZX81 was well worth the money. I loved the idea of taking out the soldering iron when you got your new computer. Flatpack for geeks :) - Shane MacLaughlin
5
[+8] [2008-10-22 13:52:04] bezidejni

I find Teensy ELF Binary [1] fascinating.

[1] http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html

Wow, just wow! Great link! - André
Ah, that one takes me back :) Thanks for refreshing that one for me. - korona
6
[+5] [2008-10-22 13:59:46] Kibbee

If you think that's good, you'll love DHTML Lemmings [1]

[1] http://games.funnygames.nl/lemmings/index.html

7
[+3] [2008-10-22 14:35:59] Bill

Heaven 7 by Exceed is simply amazing. See for yourself! It's an intro, real-time ray-tracing in 64kb, written in assembly.

Website [1], Screenshots [2]

[1] http://exceed.hu/h7/
[2] http://exceed.hu/h7/parts.htm

Heaven 7 is truly amazing, I concur :) However, I'm pretty certain that only parts of it is assembly and the main part of it was written in C++. Size-wise it's not quite as impressive as some other 64k's but the artistic portion is very good. - korona
Oops, just read the FAQ and it turns out you're right. Assembly all the way :) I'd like to point out that it should fully doable in C++ though. - korona
screenshots link is dead - shoosh
8
[+3] [2008-10-22 16:02:59] smaclell

I know assembly has been a bit overdone but my favourites are from the Assembly Competitions. Here [1] is one of my favourites.

[1] http://www.youtube.com/watch?v=_AN-SB2T3Ag&feature=related

Assembly can never be overdone. - Lance Roberts
9
[+3] [2008-10-22 17:52:42] user9282

The Lone TeXnician [1], who -- all by himself -- put up a convincing entry for the ICFP contest written completely in teX and ended up getting the Judges prize.

[1] http://sdh33b.blogspot.com/2008/07/icfp-contest-2008.html

10
[+2] [2008-10-22 18:03:20] BoltBait

A long time ago there was a 256 byte game competition. The two games I wrote were too late for the deadline, but I did have a great time writing them.

You can download my entries here (along with all of the games): http://www.geocities.com/boltbaits/256byte/games.html

(Commented source code included)

The game that impressed me the most was called Indecent. It is a 2D sideways scroller with 256 color graphics and sound effects. It has Guraud shaded mountains and multiple levels of parallax backgrounds. Even with the commented source code I don't understand how it was done.


Geocities is now defunct. Hopefully, this has been hosted elsewhere. - spoulson
I downloaded the files before the Geocities went down. I'll move them to BoltBait.com/free/games/256byte when I get a chance. - BoltBait
11
[+2] [2009-01-08 12:36:34] Dipstick

Some early (c1979) portable chess machines had 4-bit cpus with 320 bytes of RAM and 2k bytes of ROM.

http://www.chesscomputeruk.com/html/chess_champion_pocket_chess.html

They played at nine levels and could give you a fair game at about level 5.

I also think that the 6 line (472-char) perl program qrpff that cracks CSS DVD encryption deserves a mention.


12
[+1] [2008-10-22 14:16:31] fmsf

I've made this when i was entering university some years ago (yeah i've been doing it slowly and partyfull, improving softskills)

4KBintro [1]: Made in opengl, it's a heart generated with a particle engine. Is actualy 3d but if you rotate it, it will look like a ice cream so i let it stay static. When i showed it to my girlfriend at the time she replied "So!? i've seen much better on tv"

64KBinto: [2] actualy cheated the exe is 88KB but with zip it went to 64KB. It has 2 parts first with a couple of cubes and the second with a particle generator and some attempts to make cool efects.

This were my first attempts with opengl so don't mind if they look newbish compared with the pros :)

As a personal achievement, yeah it did feel good to make it, to bad i don't got more time to keep learning opengl and graphical computing :( i love the field

If you want a really good one check this: was made in 2000 i think or 1998 and it generates 1gb of stuff, lasting for near 15 minutes [3]

[1] http://www.scene.org/file.php?file=/parties/2004/inercia04/in4k/compiler_-_compd4k.zip&
[2] http://www.scene.org/file.php?file=/parties/2004/inercia04/in64/compiler_-_introcompiler.zip&fileinfo
[3] http://www.scene.org/file.php?file=/demos/groups/farb-rausch/fr08_final.zip&fileinfo

13
[+1] [2008-10-22 15:26:23] nonowarn

Mandelblot in less than 128 bytes of html [1] is amazing. Mandelblot is represented by numbers.

This is 113 bytes cheating (but browser readable) DHTML.

[1] http://blog.nihilogic.dk/2008/09/mandelbrot-in-less-than-128-bytes-of.html

14
[+1] [2008-10-22 20:55:19] Craig

I am always amazed at what the computers on the original Apollo missions could achieve. Todays computers are so much more powerful yet they still keep crashing landers into Mars! http://www.abc.net.au/science/moon/computer.htm


(1) Actually, the lander software would have done that too, but Armstrong overrode it. I heard stories that they went so far as to call in Dijkstra to look at it, and still couldn't figure out how to get it to work. - T.E.D.
15
[+1] [2009-01-07 18:13:27] AnthonyLambert

I worked on the Robocom BitStik CAD system in 1981. That was at least 90+k of 6502 assembler running on an Apple ][ in 16k Pages on 128k a bankswitched ram card.

The first version was built without a linker and their was no hard disk so it took 2 hours to assemble on 7 floppy disk drives!

Tony


(2) And it was subsequently ported to the Acorn 6502 Tube processor. I've actually seen one of those in production. - ConcernedOfTunbridgeWells
16
[0] [2008-10-22 13:34:18] Mark Baker

I remember on various home computers there were quite a few programs that changed screen mode half way down the screen. All fairly clever, but I can understand how they did it, you count hsync interrupts and change mode (by register tweaking rather than an API call) after you've had a certain number of them.

But I saw one program, a 3D modeller whose name I've long since forgotten, which changed mode half way across the screen. Presumably it changes to one mode on the hsync interrupt then uses a timing loop to wait until it's time to switch back, and puts up with wasting half of the limited CPU power (but if all you're doing is running the GUI you can probably afford this).

(This was on the Atari ST. ST Medium res was 640x200 4 colours; ST Low res has 320x200 16 colours).


The Pawn adventure game did that... my fiend ken write that bit. - AnthonyLambert
17
[0] [2008-10-22 15:38:41] korona

I guess I'll contribute my own 64k intro here, since we're posting a lot of demoscene examples: Shaven Raven [1]. To be honest, the intro is insanely crap from an artistic point of view, but the code is alright I guess. Somehow, it still managed to win a competition though. And it's 64k. Size optimizing is fun.

[1] http://pouet.net/prod.php?which=1441

18
[0] [2008-10-22 16:47:08] Shivasubramanian A

For me, it would have to be Omar Al Zabir's portal [1], where he is able to simulate the Windows 2000 interface using just HTML and Javascript. I discovered it sometime in 2005 or so. It was a revelation to me!!

Sadly, the link doesn't seem to work nowadays!! It keeps reporting an error (atleast for me) saying "the line or server is too slow". Not sure what it is though... Hope Omar Al Zabir fixes it soon!!

[1] http://omar.mvps.org

19
[0] [2009-01-08 09:35:06] Karsten

php playing tetris [1] (just press start)

coded this around 2003 in school because i was bored... the algorithm needs to be tuned some more, btw ;)

[1] http://www.planetzord.de/aiTris/

20
[0] [2009-01-08 13:53:47] esjr

Two things come to mind...

Back in the day of the ActiveX Notepad I did a Tangram. Div's and 'javascript' only.

Not long after that, using HTML 'Cougar' (3.2 ?), some script and IE's cache control I made a 'PAC' : Portable Application Catalog for automotive after-market spare parts.

It ran from a floppy, no database, no dll's, nada. Just a couple of HTML files and some CSV's. (assuming IE 5 or higher)

You would select Make, Model and Type of Vehicle and the appropriate oil, air, water and other filters would appear. (around 14k 'Vehicles' and well over 30k 'Applications')

The cache control is still available and the old 'PAC' still runs in IE 7.

I never understood why, assuming IE is a given in the environment, that cache control was never put to any use. 'PAC' is the only thing I have ever seem making constructive use of it.

Still think 't was a 'kewl' hack.


21
[0] [2009-01-21 21:54:48] community_owned

A well-known (in computer chess circles that is...) small chess program is Micro-Max [1] by H.G. Muller. There are a few versions, one of which is about 2000 characters of C-source code, and plays at about the 2000 ELO level, giving an impressive 1 ELO / character ratio!

[1] http://home.hccnet.nl/h.g.muller/max-src2.html

22