tags:

views:

2533

answers:

22

I recently found this article 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 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.

+19  A: 

Elite 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 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 computer and subsequently ported to DOS. The entire game engine was something like 30K lines of code.

Many years ago A friend of mine implemented a 64 channel data logging system on a Cosmac with 256 bytes of RAM and 2K of ROM. In order to do this, he wrote a FORTH 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.

ConcernedOfTunbridgeWells
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
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 - http://en.wikipedia.org/wiki/RCA_1802#Registers_and_I.2FO
ConcernedOfTunbridgeWells
+11  A: 

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

Stu Mackellar
A: 

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).

Mark Baker
The Pawn adventure game did that... my fiend ken write that bit.
Tony Lambert
+7  A: 

The most amazing for me was ZX81 chess, 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.

Shane MacLaughlin
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
+19  A: 

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

Another example of some of these is here.

TraumaPony
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
+8  A: 

I find Teensy ELF Binary fascinating.

bezidejni
Wow, just wow! Great link!
André
Ah, that one takes me back :) Thanks for refreshing that one for me.
korona
+5  A: 

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

Kibbee
+1  A: 

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

4KBintro: 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: 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

fmsf
+3  A: 

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

Website, Screenshots

Bill
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
+18  A: 

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. 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.

T.E.D.
That was... wonderful. Thanks for sharing it.
Firas Assaad
I've read that story a couple of times and think it's brilliant.
Valerion
+1  A: 

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

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

nwn
A: 

I guess I'll contribute my own 64k intro here, since we're posting a lot of demoscene examples: Shaven Raven. 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.

korona
+3  A: 

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

smaclell
Assembly can never be overdone.
Lance Roberts
A: 

For me, it would have to be Omar Al Zabir's portal, 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!!

Shivasubramanian A
+1  A: 

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

+2  A: 

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.

BoltBait
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 http://BoltBait.com/free/games/256byte when I get a chance.
BoltBait
+1  A: 

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

Craig
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.
+1  A: 

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

Tony Lambert
And it was subsequently ported to the Acorn 6502 Tube processor. I've actually seen one of those in production.
ConcernedOfTunbridgeWells
A: 

php playing tetris (just press start)

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

Karsten
+2  A: 

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.

Dipstick
A: 

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.

esjr
A: 

A well-known (in computer chess circles that is...) small chess program is Micro-Max 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!