Should not they have used . to end a statement. They could use -> to call a method. Was this just a oversight? Or there is some deeper going on here?
Asked
Active
Viewed 692 times
2
-
5Why they use brakes to stop a car? Cant they just jump out of the car? – Starx Apr 20 '12 at 23:00
-
11@Starx Is that good analogy? – javaguy Apr 20 '12 at 23:04
-
4@Starx Who uses brakes? Normal ppl just crash into the car in front of them. – emory Apr 20 '12 at 23:04
-
3possible duplicate of [Why do certain programming languages use semicolon to separate code?](http://stackoverflow.com/questions/9718567/why-do-certain-programming-languages-use-semicolon-to-separate-code) – kba Apr 20 '12 at 23:05
-
Open the language specification and enjoy the read – GETah Apr 20 '12 at 23:05
-
1@javaguy, Nice you answered this question yourself. – Starx Apr 20 '12 at 23:05
-
3See [Why are statements in many programming languages terminated by semicolons?](http://programmers.stackexchange.com/questions/139482/why-are-statements-in-many-programming-languages-terminated-by-semicolons) on Programmers. – kba Apr 20 '12 at 23:06
-
6Wow, perfectly legitimate question closed by mono-culture provinicialists who cannot stand the thought that there might be more than one valid way to do something. Especially ironic because there is an entirely rational answer to the question based on very well-justified reasons that this particular decision was made. Well, better to remain ignorant of our own profession than to risk challenging our prejudices... I guess ... – RBarryYoung Apr 20 '12 at 23:15
-
@RBarryYoung: the question is open, care to post that reason? – Mat Apr 21 '12 at 07:52
-
@RBarryYoung Have you considered that some people voted to close because it's been asked before? – kba Apr 22 '12 at 01:00
-
1@Kristian: Yes, I did consider that. So I checked and that was ***not*** the reason it was closed. Rather "*Not Constructive*" was the reason given, which borders on imbecilic. Frankly, what I regard as truly "*Not Constructive*" is voting to close a question without at least offering your concerns in a comment first. That way the community would have a chance to point out if your concerns are mistaken. In fact, it's just downright destructive to this community. – RBarryYoung Apr 22 '12 at 18:22
-
Possible duplicate of [Why do some languages need semicolons?](http://stackoverflow.com/questions/4701137/why-do-some-languages-need-semicolons) – Emil Laine Jan 05 '17 at 14:30
2 Answers
5
Java picked the semicolon to have a syntax similar to C and C++.
C++ picked it to have a syntax similar to C.
And I would guess that C picked the semicolon because B, ALGOL and Pascal already used it, and there was no reason not to use an already accepted convention.

JB Nizet
- 678,734
- 91
- 1,224
- 1,255
-
AlgolW provided for the replacement of ";" with ".," and ":" with "..", hence an array x could be declared x[3..5]. Maybe there was a computer character-set at the time that did not have a semicolon?? Algol68 called the ";" a gomma, short for "Go On Comma". Compare with the "," Comma which permitted nondeterminacy (collateral execution) c.f. [Short circuit evaluation using procedures](http://stackoverflow.com/questions/9462051/short-circuit-evaluation-using-procedures) – NevilleDNZ Apr 30 '12 at 03:57
-
In the early Algols the "." is used to denote the end of a "proper program". In Algol68 the "." (or a qed square [□](http://en.wikipedia.org/wiki/Q.E.D.#Electronic_forms)) acts something like a hybrid break/return statement allowing statements to return alternate values. – NevilleDNZ Apr 30 '12 at 04:07
0
... so people understand the comment (and negs), this was the original:
"Additionally, the semicolon stands for a NOP (no operation or null command) in C/C++" might give a clue as to why it's common

Community
- 1
- 1

craniumonempty
- 3,525
- 2
- 20
- 18
-
So then why is the NOP use to signify the end of the statement? I dont think you have answered with question. – Starx Apr 20 '12 at 23:07
-
@Starx You are correct. I was rushed at the time, and still don't have time to finish. I have searched and found one answer in programmers SE which I have posted at the top of the answer. I probably should have waited to answer or at least avoided a rushed non-answer. – craniumonempty Apr 21 '12 at 11:56