-2

We all know the dangers of gets.

It is also on the way out in C11.

That makes me wonder: how did it ever get into the standard to begin with? Weren't the problems with it obvious at the time of standardization?

closed as primarily opinion-based by gnat, Scant Roger, kevin cline Nov 26 '15 at 7:43

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • recommended reading: On discussions and why they don't make good questions – gnat Nov 26 '15 at 4:40
  • Standardized... when? getstring with the same functionality existed in B. And something similar existed in BCPL. – user40980 Nov 26 '15 at 4:48
  • 3
    Things were a lot different in 1972. – whatsisname Nov 26 '15 at 5:53
  • The tendency has seemed to be to create a second method with a prefix in front, as to not break old code, for example wcprintf rather than just printf for a wide-character version. So compatibility seems to hold more importance in C++ than forcing usage of more proper methods. – Neil Nov 26 '15 at 7:29
  • @gnat I'm sorry, but how is this supposed to be a discussion? – Pablo Almeida Nov 26 '15 at 9:15
5

gets was invented at a time when there were no millions of malicious hackers trying to steal your financial data via the internet. There was no internet to speak of. People didn't put their entire personal lives on computers. Only highly paid specialists were ever supposed to have access to digital computers at all.

Briefly, the threat-countermeasure trade-off was totally different in 1972 - so different that what seems like an incredible oversight today was more like a hasty but ultimately inconsequential pragmatic choice of leaving out error checking.

  • Also, at that time, computer resources where scarce and costly. So perhaps passing an additional argument was not worth the trouble. – Basile Starynkevitch Nov 26 '15 at 7:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.