I have recently been doing code using C language as I am taking a semester of Computer Science intro and I started to wonder why certain characters meant certain actions. Well many of them make sense such as / for divide and * for timesing I kind of wondered why we used a semicolon for the end of majority of lines of code. My initial thought is that it had to do with the semicolons actual purpose of being used to connect certain ideas to each other as a code is like a web of ideas connected to each other but wanted to know if there was more of a reason behind the use of the semi colon or if I am overthinking this to much lol. 😅
Thanks in advance :)
#Why do many code languages use semicolons?
1 messages · Page 1 of 1 (latest)
well, for starters, some languages can have a piece of code spanning multiple lines. a semicolon is indicating the end of the line of code. for instance, if you have a statement that has a bunch of requirements, you don’t want to span that 250 characters horizontally, it’s better to make it readable and format it.
You are overthinking this a little bit haha but that's alright. In programming language, it makes things easier and often increase readability to have a way to determine when you statements are terminated, the use of semicolons is generally, as far as I know, just a matter of design choice. The semicolons in particular comes from the 50s and the main purpose was to clearly indicate the end of lines so the language designer chose the semicolon. The convention got popular with later languages.
That said, some languages use other characters to terminate statements. It really comes down to being a design choice.
I didn't remember the name of the language that really started, or at least popularized, the use of semicolons for the end of line so I did a bit of research and if I am not mistaken, it's Algol 60. It's a language developed in the 50s.
It's honestly a very good and interesting question you asked there.
they need to include semicolon to show that is the end of the code like writing an essay
BASIC used colon instead : but it was facultative
otherwise, you would be forced to ALWAYS put multiple statements on multiple lines
and the last thing you want is the JavaScript "semicolon injection" patch, which was causing a huge problem with PrototypeJS library minification.