Live data from Hacker News

The Development of the C Language

bell-labs.com

11–20 of 24 posts

Re: The Development of the C Language

#11
post #6

Earlier quoted context omitted.

Alexander Stepanov gave STL to ANSI C++ working group, after implementing it originally in Ada 83. What HP and SGI did was to provide the first C++ working implementations of it, outside the ANSI C++ working group work.

It would be nice if the STL would be a common denominator across a few languages.

When Java came out there were a few commercial offerings that were kind of "STL for Java", but with 1.2 Java got its own Collections API and the interest faded away.

Re: The Development of the C Language

#12
post #2

On the other hand, C's treatment of arrays in general (not just strings) has unfortunate implications both for optimization and for future extensions. The prevalence of pointers in C programs, whether those declared explicitly or arising from arrays, means that optimizers must be cautious, and must use careful dataflow techniques to achieve good results. Sophisticated compilers can understand what most pointers can p…

C99 introduced the restrict keyword by which the programmer promises that the pointer doesn't alias anything (or else the behavior is undefined).

memmove versus memcpy only solves the problem for block moves, not for other array operations. Think about a Fast Fourier Transform or whatever where the compiler has to suspect that the inputs overlap in dumb ways.

Re: The Development of the C Language

#13
I love stories like this. All the history behind a very young but rich science.

For example I always assumed C came from a strong typing background and its premises was always about being portable. Neither of them are true.

Re: The Development of the C Language

#14
post #2

On the other hand, C's treatment of arrays in general (not just strings) has unfortunate implications both for optimization and for future extensions. The prevalence of pointers in C programs, whether those declared explicitly or arising from arrays, means that optimizers must be cautious, and must use careful dataflow techniques to achieve good results. Sophisticated compilers can understand what most pointers can p…

> My question to HN is: do any languages that really emphasize pointers and iterators over arrays and indices have a non-cumbersome way of telling the compiler when no aliasing is expected?

Rust has this concept baked into the language: any mutable reference is statically guaranteed to not alias anything else that is accessible. Non-mutable references can alias each other, but I don't think there are any optimizations that could be inhibited by this.

Re: The Development of the C Language

#15
I think it is worth noting that C is special in the sense that compared to other programming languages it is semantically low-level, pretty much on par with assembly. Which is why it offers less opportunity for automatic optimization than most of other languages do.

Therefore, just like with assembly, there is nothing too "unfortunate" about the language's design (including its "treatment of arrays"), and the fact that C has been, and still remains, highly popular is just the result of healthy competition, IMO.

There are a few little things that I wish were different (for example, I see the arrow symbol '->' as noisy and unnecessary - the simple period '.' would work with pointers just as well; also, the "semicolon cancer"...), but the language seems to be pretty usable the way it is.

Re: The Development of the C Language

#16
post #6
post #4

Earlier quoted context omitted.

> I also think the STL is the beautiful thing C++ gave us, [...] It did not. STL was given to us by HP and SGI, and then C++ adopted STL into its standard library.

Alexander Stepanov gave STL to ANSI C++ working group, after implementing it originally in Ada 83. What HP and SGI did was to provide the first C++ working implementations of it, outside the ANSI C++ working group work.

But, if I understand correctly, what HP and SGI did was basically to let Stepanov work on STL while he worked for them, and give some semi-official sanction for the STL releases. They didn't see the STL, decide that they needed to work on it, and set up an independent team to do so.

And, if I understand correctly, Stroustrup saw the STL and said (paraphrased) "Yeah, that's going in."

Re: The Development of the C Language

#17
post #8

Earlier quoted context omitted.

Yet it took up all these years until clang for anyone to start taking static analysis seriously in C In some circles maybe, but some industries have decades of experience applying static analysers to their C code, and companies have been selling static analysers throughout.

Outside industries where MISRA-C is part of the daily vocabulary, I never seen any appreciation for C static analysers.

Some embedded systems places do this, even ones that are not safety-critical. It's more common as the level of concern rises. Medical instruments, for example, aren't MISRA, but at least some of them run static analyzers on C/C++ code. (All should...)

Re: The Development of the C Language

#18
post #13

I love stories like this. All the history behind a very young but rich science. For example I always assumed C came from a strong typing background and its premises was always about being portable. Neither of them are true.

> I always assumed C came from a strong typing background

C is notoriously weakly typed. There are lots of implicit casts that will automatically be applied. And (void *) is your door to freedom from types (this can be a good thing in some cases, of course.)

Re: The Development of the C Language

#19
post #13

I love stories like this. All the history behind a very young but rich science. For example I always assumed C came from a strong typing background and its premises was always about being portable. Neither of them are true.

No, indeed! This obsession with "undefined behavior" and the desire to eliminate it from the language spec is something recent; when I learned C, we all just understood such gaps in the spec to be places where the compiler writer would do whatever was reasonable for the target platform.

Re: The Development of the C Language

#20
post #4
post #2

On the other hand, C's treatment of arrays in general (not just strings) has unfortunate implications both for optimization and for future extensions. The prevalence of pointers in C programs, whether those declared explicitly or arising from arrays, means that optimizers must be cautious, and must use careful dataflow techniques to achieve good results. Sophisticated compilers can understand what most pointers can p…

> I also think the STL is the beautiful thing C++ gave us, [...] It did not. STL was given to us by HP and SGI, and then C++ adopted STL into its standard library.

Thanks dozzie and pjmlp, I should have credited Alexander Stepanov. He is a great programmer and educator that has impacted my CS education. What I meant was that C++ was the first widely adopted language that had memory access and sufficient generic features for the STL to be written and easily used.
Post reply on HN