PDA

View Full Version : Got a few minutes to spare? Know what a 'quine' is?


scratt
2006-04-24, 11:15
No! It is not a fart from a girls front bottom! ;)

Really cool article.. Make sure you read the first two or three paragraphs at least.. and then as annoying / trivial / mind numbing as the prospect of a quine sounds, I guarantee that you will be hooked and read the rest. If you are a real geek programmer that is!

A quine is a program which prints its own listing. This means that when the program is run, it must print out precisely those instructions which the programmer wrote as part of the program (including, of course, the instructions that do the printing, and the data used in the printing).

Think about it.. How would you do it?

http://www.madore.org/~david/computers/quine.html

Luca
2006-04-24, 11:23
*queef*

ghoti
2006-04-24, 11:50
No! It is not a fart from a girls front bottom! ;)
It's not? :err:

Scratt, if you're into this, you should dust off that copy of Gödel, Escher, Bach (http://en.wikipedia.org/wiki/G%C3%B6del%2C_Escher%2C_Bach) that you have sitting somewhere (everybody has one, that book was such a best-seller and yet hardly anybody actually bothered reading it), and start reading! This is fascinating stuff, and it's not just funny little programs, Kurt Gödel (http://en.wikipedia.org/wiki/Goedel) took down the whole concept of mathematics being a complete and perfect system using similar ideas.

scratt
2006-04-24, 12:13
I shall go and dig in my spare room... ;)

I do find stuff like this very interesting..

One of my favorite pieces of code that I ever developed was the first revision of what we called a "scan conversion strip".

This was an inline piece of machine code which wrote the routine which was then used to display one horizontal line of a polygon in a 3D scene.

That piece of self modifying code was so elegant.

The third revision actually sacrificed a chunk of memory which was a pre-written piece of code to draw a full horizintal line one pixel thick on the screen. This was jumped into at a variable point, with every register on the processor maxed out holding variables to make that code chunk draw in the correct colour, and correct length, from the correct starting position.

It was basically the fastest way to do renderring for 3D in colour on an 8 bit machine that did not have a graphics processor..

But I still loved the version that actually wrote itself, as even though it was slower it was more elegant and exciting. Particularly when you thought of the whole program actually hurtling towards an area of memory that was full of garbage which was being written just infront of the program counter as it sped towards it.

:)

EDIT - And remember that in a lot of cases (We developed it for many 8 bit machines)this was being done on machines who's memory was mapped for characters. So pixels had to be calculated as parts of bytes, which were themselves parts of characters mapped into the video memory! Wicked geeky stuff! Lot's of masking and stuff!

Kickaha
2006-04-24, 12:16
Damn man, self-modifying code *and* quines in the same thread??

"And that was the day that AN collapsed into a geek singularity, and none of the members were heard from again. Legend says that if you go to www.applenova.com and turn up your speaker all the way, you can just make out a very faint chorus of "C'mon Carol, just one pic?", but that's just legend."