Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Lines of Code...

#1
My coding style has changed so, so much over the years. 

I taught myself at a young age. That being said, I didn't realize just how much I didn't know until I started studying computer science at university. And oh my, do you learn so much. I occasionally dabble with old code of mine, and I realize that I've learned quite a bit over the years. 

That being said, if there is one thing I learned, it's how to NOT one-line code. As it turns out, having fewer lines of code does not mean that the code is faster. (In many cases, it's actually slower. Some of the complex functions that can help you one-line sections of code are very heavy-weight under the hood. Even in python, I write my own code to multiply matrices, because Numpy's functions are far too slow for the task. )

As a result, I end up writing quite a few lines of code to do even a simple task. I try to make my code as readable as possible, and don't worry so much about the line count. I'm often told that my code is overkill (or that it takes too many lines to do something simple). yes, I know how to use complicated functions and language constructs. I just choose not to. I value stability and readability, and performance, over elegant forms of creatively one-lined code. 

That being said, sometimes less code is advantageous. With larger files, it's often harder to pin-point sections of code that exist in a huge file with 2,000 lines. It also introduces more places where bugs could exist (more code is being used), so there is often a trade off. You find yourself limited by the speed that you can type.

What are your thoughts on code's line count? Do you find that you try to make your code compact, verbose, or somewhere in between?

Reply


Messages In This Thread
Lines of Code... - by Darth-Apple - March 1st, 2020 at 9:38 PM
RE: Lines of Code... - by Lain - March 1st, 2020 at 10:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  What code editors do you use? Darth-Apple 6 2,913 January 19th, 2023 at 6:04 AM
Last Post: tc4me
  Object Oriented Code Darth-Apple 1 6,142 October 13th, 2014 at 3:14 PM
Last Post: Electric2Shock



Users browsing this thread: 1 Guest(s)

Dark/Light Theme Selector

Contact Us | Makestation | Return to Top | Lite (Archive) Mode | RSS Syndication 
Proudly powered by MyBB 1.8, © 2002-2024
Forum design by Makestation Team © 2013-2024