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?


2 Answers 2


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.


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.


Not the answer you're looking for? Browse other questions tagged .