GameGlis gamedev studio

Line orange 3

DOES LINE COUNT MATTER?

Line orange 3
Blog post 1 img

Summary (TL;DR): It depends – a well structured programming project will actually have less lines and assets, and thinking that more lines means a more complex game or IT product of any kind is a misconception. 

Recommended music to listen to while reading: America – You Can Do Magic

Some background

We’re mainly using GameMaker for our work, which is an object oriented game development engine environment. It is excellent for making 2D games, and has everything prepared and designed for – you guessed it – OOP (Object Oriented Programming).

Why does this matter for explaining the answer to the question? Well, OOP can exacerbate the difference a programmer makes by using OOP to his advantage and actually simplify the project he’s working on – making a well-thought project and its mechanics almost a necessity when thinking about speeding up production.

Why less code lines are a good thing

Let’s try and think a bit about why less code lines might be helpful while programming an IT product. I’ll be mostly thinking about videogames, GameMaker and OOP, but most of the things mentioned apply to any kind of software product.

  • Readability: the less lines to read – the easier it is to navigate code. Find stuff. Get into it. Less noise to work with, and a smaller pond to swim in.
  • Debugging: with less time spent going through hundreds or thousands of lines of code comes a faster recognition of the problem in it. Multiply it by the times a code you’re working on doesn’t work (probably every 5 minutes or less) and suddenly you find out where all that time goes and why experienced software devs cost more.
  • Teamwork makes the dream work: What if I gave you a 1000 page long book and told you to read it and then find mistakes in it or translate it (or do something else with it, whatever fancies your imagination)? What if I asked you to do the same with a 20-page book? It is similar in coding. Often times a project requires more than 1 programmers to work on it, and being able to work on the same thing is much easier if people don’t have to spend energy on reading a lot of code. Quality > quantity.
  • Code execution speed: this is bit of a tricky one, as it might not always be the case and depends on the compiler (or interpreter). Still – any kind of CPU will need more time to read a bigger quantity of code lines than what it would take for it to go through less amount of code lines. There’s compilation to take in account, as machine code quantity generated might be less in some cases from from bigger code bases, but generally speaking, much more often (and especially the bigger the projects are), having less code lines will speed up the execution – meaning less energy wasted by the end-user device and also faster execution as well.
  • Compile speed: this is similar to the point above really and even more often true – less code means less lines the compiler needs to go through and translate, optimize etc. When you’re making a game or another application, you will often compile and test things – and again there comes the time decrease with having fewer lines of code.
  • Practice: working like this all the time makes it natural

There's no way having more code lines can be good

Well… As you grow older, the more you’re aware there is no pure black & white. Everything has a pro and a con. Additionally, you appreciate more the things that are simpler – pure black and pure white 🙂

Although you could intentionally write more code lines to prevent somebody else from actually working on the same project, as that somebody would have to waste lots of time on getting into it, there is one (f)actual reason why having more code lines is sometimes beneficial.

Speed of development! Thinking about how to structure the code, mechanics and everything else in the project just takes time. Time to sit down and think (+ sometimes sketch on paper). This is time you could be spending writing code. So here comes the caveat – writing code is never just ‘writing code’. It is not the same as talking or writing a letter or a book (or a blog post). Speaking is easiest – you talk about what comes to mind and the process is fast. Writing a letter/email/post is slower – you need to think what you wanted to say, how to bring emotion into words (as there are no facial expressions and body language). And programming is even more thought-intensive! You need to think and think about how to first solve the problem, but then also how to write down and structure the solution, so you don’t break other things. Plus, so it is readable and is somewhat optimized, and people (including you) doesn’t waste a lot of time reading it later when you need to change it. 

See what I did here? I’m trying to come up with a good reason to have more lines of code, and I’ve navigated around it. Well, it is actually simple – if mechanics you’re developing are light and the project is small – don’t overthink it! Just making it work sometimes beats having crystal-clear code which is short and nicely written. So if it will take you a few hours to complete the whole game (which is very unlikely and something I’ll talk about in another post probably) – don’t spend time making it small in terms of code lines. Just make it work. The bigger the project – the more you’ll HAVE to worry about keeping the code line count in check. Please don’t even think about working on a project which will take several months or more without spending time on thinking how to organize the code base. Just don’t!

This is all just talk - real world is different!

Heh.

Line_turquoise 2
Line_turquoise 2
Line_turquoise 1
4.2 5 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest
Inline Feedbacks
View all comments