When we started coding in our school days, we have always been told to keep width of code to 80 characters. I never questioned it. I was like if teacher say’s 80 then it is 80. In fact when we started coding in ABAP the same was recommended to us by our tutors. So, this magic 80 character’s width stayed with me for a long time.
Off late we have see an amazing guide Clean ABAP helping us how do we write clean code. I thought of checking what does Clean ABAP has to say about this Magic number 80. I just searched through the guide and under “Stick to a reasonable line length” section found a mention of it.
What it mentions now is to follow a maxim length of 120 Characters and also gave some hint regarding the origins of 80 character limit.
That is all what triggered me to go down the memory lane and understand from where this 80 character’s limit came from.
80 Character Initial Origins
The 80 character’s limit has its roots in IBM Punch Card where the data or instructions were stored on card. The earlier days did not have any magnetic tapes and all to share data with other computers etc. You can only store Maximum 80 of Characters on the punch card. As can be seem below in punch card you have 80 columns where each column represents a character.
So if a program needs to be stored on punch card an ABAP one practically one punch card would represent one line of card. Imagine the number of card’s you will need to store your program😊 Below is picture of lady who is holding 62500 punched cards which were used to create 1950s SAGE air defense system. This was all just 5 MB of data. Imagine if one of the card get misplaced the whole program fails, that all you will know once everything is loaded not like ours where we just compile and we get to know errors.
Photo Credits – https://www.computerhope.com/jargon/p/punccard.htm
So at least now we know one of the origins from where this limit might have originated. Another place where the use of this limit could be seen was in earlier times terminals which were 80 columns width by default
Photo Credits – https://en.wikipedia.org/wiki/Computer_terminal
So at least now we know what are the origins of this 80-character limit, the bigger question is Do we actually need a limit?
Do we need any such limit while coding?
Given the way things have changed I feel setting some ground rules for writing a clean code is important but not limits like these. Of course, if your team has limited screen width then it makes sense but these day does not look like it is needed. The call must be more of practical one, some of the logical scenarios which I can think of.
- Shall we put one complete statement in one line? No if we can not see it all at one go better break it, make sure by breaking it should be readable😊
- Shall we put multiple statements on one line? Yes, you can if statements are basic and related.
- Does not matter what the limit is whether 80 or 132 or 200 at least it helps in adding uniformity to the code. Creating some rules helps in stopping people from arguing about inconsequential formatting rules, and get on with writing good, consistently formatted code.
- Given the width of the screen’s which normally developer use, I think we can increase this limit like anything. If developer can keep two source code files open side by side along with folder explorer, it is amazing.
Feel free to provide your feedback and comments on the same.