Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My friend told me that it's something about 40 lines of code for 1kB.

For an old 8-bit computers with 48kB of RAM it is only 1920 lines of code!

Then when I think about it, it seems to me incredible that sometimes my CSS files have more than 2000 lines of code.

How can somebody create something like a game e.g. Dizzy on the ZX Spectrum within 2000 lines available?

Even if they have used assambly or machine code for some parts it seems to me incredible.

Is really 1kB about 40 lines of code or is it different?

share|improve this question

closed as off topic by Nicol Bolas, Byte56, Anko, John McDonald, Tetrad Apr 16 '13 at 19:17

Questions on Game Development Stack Exchange are expected to relate to game development within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

What does this have to do with game development? Also, 40 lines per 1KB seems more likely to be about the number of lines in the source file, not the compiled binary. – Nicol Bolas Apr 16 '13 at 14:33
I am programming games in Basic, that's why I am asking on a game dev forum. Is this forum only for specific languages and not Basic? – Derfder Apr 16 '13 at 15:23
This information about 40 lines of code = approximately 1kB was told to me by my friend when I was younger and we programmed stuff on the ZX Spectrum. He was quite good and was complaining about that he was only in the half of the coding when the memory was full and he needs to make the game shorter and make additional changes to it etc. ;) – Derfder Apr 16 '13 at 15:28
Basic has nothing to do with game development (specifically). Also, your question has nothing to do with Basic (or if it did, then you should have mentioned it somewhere), so even if Basic were closely linked to game development (which again, it is not), your question still isn't a gamedev question. – Nicol Bolas Apr 16 '13 at 15:34
thats a useful question. lol – GameDev-er Apr 16 '13 at 17:54
up vote 6 down vote accepted

1 kB = 1024 Bytes.

Most of programming languages have 1 Byte = 1 character, so:

  • If your lines are 1 character long, 1 kB = 1024 lines
  • If your lines are 1024 characters long, 1 kB = 1 line
  • If your lines are 25 characters long, 1 kB = about 40 lines

BTW. if your programming language is compiled, it has nothing to do with memory-efficiency.

BTW2: There is a very interesting site JS1K, where people submit cute things that use 1024 Bytes of Javascript code.

share|improve this answer
I think the OP meant binary, not source size. – Panda Pajama Apr 16 '13 at 10:43
Actually, since the OP mentions CSS source a proper answer would address the difference. – jhocking Apr 16 '13 at 14:28

Especially in the time of games like Dizzy your code was compiled something as long as this

while(myLongVariable < 10)

Would become (line numbers added for clarity, some pseudo assembly code here)

10: cmp_s r1 10 40
20: add r1 1
30: jmp 10

Now this is a textual representation of pseudo assembly, but actual assembly is not in a text format but is binary which is even smaller. In very old games like Dizzy they also use a lot more tricks by jumping through memory.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.