6 ms·
I’m not sure if it was the original purpose of C, or of it’s what made C popular, but compared to BASIC, processing strings in C was much faster.
by anikom15 6y ago
I’m not sure if it was the original purpose of C, or of it’s what made C popular, but compared to BASIC, processing strings in C was much faster.
- deleted 6y ago[deleted]
- ajuc 6y agoEverything was faster in C - it was compiled and BASIC was interpreted. Better comparison would be between C and Turbo Pascal strings in DOS times. TP strings were limited to 255 characters but they were almost as fast as C strings, in some operations (like checking length) they were faster, and you had to work very hard to create a memory leak or security problem using them. I've learnt Pascal before C and the whole mess with arrays/strings/pointers was shocking to me.
- indymike 6y agoI learned C before Pascal and having to write so much code to deal with 255 character limits was kind of jarring.
- schlupa 6y agoUCSD and Turbo-Pascal had it easy with the 255 byte strings. They had real strings but these were compiler extensions. Real Pascal didn't have string support and you could only work with packed array of chars of fixed size and as the language was extremely strong types, to packed chars types of different lengths were considered different types, so you had to write procedures and functions for all used packed array sizes.
- mcguire 6y agoBrian Kernighan on "Why Pascal is not my Favorite Programming Language" (https://www.lysator.liu.se/c/bwk-on-pascal.html https://www.lysator.liu.se/c/bwk-on-pascal.html) [1981]. Turbo Pascal wasn't released until 1983, if the wiki is to be believed.
- ajuc 6y agoI find it strange that he complained about Pascal's lack of dynamic arrays, when the Pascal solution is to use pointers (exactly what C does for all arrays and strings anyway). Many of his other points are solved by Turbo Pascal and Delphi/Object Pascal. But of course nowadays there are better languages for real world programming. It's just a shame that there's nothing as simple and elegant for teaching programming (). () lisp is even more elegant, but it has a lot of gotchas and it's so far from mainstream that using it for teaching isn't a good idea IMHO