News for hackers. Stuff that matters.
Re:Teaching C (2016) by pjmlp on Tuesday October 30, 2018 @07:05AM (#18335387)
> C is dead so let's teach Pascal, Lisp, MIPS assembly and Smalltalk?

Have you missed the time reference?

Java still wasn't invented, Smalltalk had companies like IBM selling products written in it.

MIPS was being adopted across UNIX workstations.

People still though it was worthwhile to buy Common Lisp implementations.

Regarding language comparisons, actually C++ is Italian and C Latin.

Re:Teaching C (2016) by roenxi on Tuesday October 30, 2018 @07:26AM (#18335474)
puts on grumpy C programmer hat

C is C and C++ is C++. The analogy breaks down in a pretty major way because Latin has no native speakers, but important work is done in C. They didn't stop speaking Latin because it had problems as a language, they stopped because the cultural apparatus behind Latin collapsed after an exceptionally long period of dominance that Italian speakers never achieved.

I'd like to believe C has a stronger future in the academic world because it is simpler than C++, but also because C is a designed language and C++ is a cobbled-together language, and maybe that counts for something in a field where people call themselves engineers.

Anyone who sees C as a 'downgrade' has badly misunderstood what design means as an engineering concept. It doesn't mean 'does everything', it means that strategic choices were made early in the process after careful consideration.

* Serious hat *

C has a pretty well defended place in the world - it is an excellent choice for manipulating RAM and controlling the size of variables. C++ isn't as good, because its features add a lot of complexity that isn't really desirable when you have a problem that C can handle.

I wouldn't use it for string parsing. Or GUIs except as an afterthought on a project that used C for a good reason.

Re:Teaching C (2016) by blub on Tuesday October 30, 2018 @07:43AM (#18335587)
C's well defended place is unfortunately mostly defended by folklore, nostalgia and a desire for one-upmanship. There are several good languages available today that can successfully replace C - including at controlling RAM or the size of variables

P.S: there's a book called "The design and evolution of C++" which you should probably read. Where can one learn more about the design of C?

Re:Teaching C (2016) by simias on Tuesday October 30, 2018 @08:02AM (#18335696)
I disagree, C is popular for the same reason that QWERTY is more popular than DVORAK or Colemak or that x86 is more popular than ARM (talking purely from an IA perspective). It's not folklore or nostalgia, it's just that it was here first, there's a ton of legacy applications that rely on it and the cost of the switch is seen as a large, one time cost vs. the small benefits it would bring over a longer period of time.

I'm a huge fan of Rust and I can only dream of having all C codebases in the wild ported to it some day but I'm still writing C at work because it's faster, easier (vendors provide C libraries and code, not Rust) and it's easier to hire C coders than Rust ones.

>P.S: there's a book called "The design and evolution of C++" which you should probably read. Where can one learn more about the design of C?

I'd be surprised if C was really ever "designed" the way we would design a language these days. Basically it was a fork of earlier languages tweaked to more conveniently model the hardware of the time. It was more about getting the job done at the time than making an innovative language. At least that's what I gathered from what I know about the early days of C and it's also fairly apparent in the way the language itself is designed (the whole pointer/array shenanigans come to mind). C is many things but it's definitely not elegant or even clever.

Re:Teaching C (2016) by pjmlp on Tuesday October 30, 2018 @08:46AM (#18335972)
Except that is yet another folklore, as C wasn't there first in any form or fashion.

There is an history of 10 years of systems programming languages, preceding it. Prooving one does not need to throw security out of the window in systems languages.

Had Bell Labs been allowed to sell UNIX, instead of giving it away for a symbolic price and C would have been a footnote on history of system languages.

Re:Teaching C (2016) by simias on Tuesday October 30, 2018 @09:08AM (#18336080)
The parent was talking about "nostalgia" and "replacing C" so I assumed they were talking about more recent languages like Rust, C++, D, Go, Zig and all these newer system languages.

I agree that if we're talking about why C took over in the first place it's a different discussion.

Re:Teaching C (2016) by blub on Tuesday October 30, 2018 @08:37AM (#18335912)
I agree with you regarding existing software - I don't think it's worth discussing too much about, since that software will either live on "forever" or be outright replaced, rather than being rewritten.

I was mainly referring to new projects, where C continues to be selected because of a myriad of reasons, none related to technical uniqueness or superiority.

This is truly infuriating, because we will collectively pay for those poor choices in security vulnerabilities.

Re:Teaching C (2016) by simias on Tuesday October 30, 2018 @03:13PM (#18340328)
Stability and being able to find developer who will maintain the project 5 years from now are still very pragmatical arguments though. Again, I love Rust but I still don't feel comfortable pushing it for critical components at work because who knows where it'll be 5 years from now? Is it here to stay? If I leave my job will they find people to take over?

Furthermore even brand new projects will have to interface with existing code to some extent. C bindings are everywhere, Rust not always. And even when they exist they're not always complete and are often quite experimental.

Still, I'm doing my part and I did write a few smaller components of my current project in Rust at work. But it's not surprising that the shift is not happening overnight.

Re:Teaching C (2016) by nwmcsween on Tuesday October 30, 2018 @12:24PM (#18338320)
There are no current languages that can displace C, none, zero. If you want a language that _will_ displace C it needs to be designed and features mapped, interactions, pros, cons, etc so others can understand it and __why__ choices were made.
Re:Teaching C (2016) by pjmlp on Tuesday October 30, 2018 @01:14PM (#18338937)
Except that C++ is already doing that, even if slower than desired.

AUTOSAR now requires C++14 compliance on software certification.

Android, ChromeOS, Windows, Apple OSes native components are mostly written in C++.

Finally, all major C compilers are written in C++ nowadays.

The only places where C++ is failing to replace C, is among developers unwilling to move beyond C89 on embedded space, or UNIX clones.

Re:Teaching C (2016) by nwmcsween on Tuesday October 30, 2018 @03:14PM (#18340341)
C++ is evolved not designed from the start. A properly (IMO) designed language would have a pro, con wiki/ graph map and features would have _all_ interactions mapped. C isn't this either but it doesn't try to paint over bad feature interactions by adding more.
Re:Teaching C (2016) by blub on Thursday November 01, 2018 @04:13AM (#18352080)
I've already pointed another person to the book "The design and evolution of C++" which I believe puts the not designed argument to rest.

But it is impossible to create a beautiful, "properly designed" programming language that's also backwards compatible with C. I mean look at Objective-C :)

Re:Teaching C (2016) by pjmlp on Tuesday October 30, 2018 @04:09PM (#18340848)
Yes, because C99 was such a design success with mistakes being made optional in C11.
Re:Teaching C (2016) by nwmcsween on Tuesday October 30, 2018 @04:59PM (#18341228)
I'm not advocating for C, I'm just describing a language that could displace C while having some good features. C takes features to the extreme by having few and being somewhat simple, a language designed as I stated could have features and still remain simple.
Re:Teaching C (2016) by geezerjay on Tuesday October 30, 2018 @08:42AM (#18335938)
> I'd like to believe C has a stronger future in the academic world because it is simpler than C++

C is simpler than C++ until we need to manage memory or need to handle basic data structures. When that happens, C requires reinventing the wheel over and over again.

Re:Teaching C (2016) by xamuel on Tuesday October 30, 2018 @11:35AM (#18337610)
Because memory management is an area where C++ over-simplifies and assumes one size fits all. In the C++ worldview, memory allocation is a black box, and no two apps would ever have any desire to use different memory allocation strategies. For many apps, that's fine, but for the type of apps where C shines, memory allocation isn't just a magic black box.

"As simple as possible, but no simpler."

Re:Teaching C (2016) by pjmlp on Tuesday October 30, 2018 @12:18PM (#18338232)
No it doesn't.

In fact C++ allows for flexible memory allocation strategies per data structure, while C forces one to hand code them all and replacing something like malloc affects the whole executable behavior.

Re:Teaching C (2016) by jstimpfle on Tuesday October 30, 2018 @02:53PM (#18340128)
> flexible memory allocation strategies per data structure

You realize that that's not exactly flexible. Tieing shape to behaviour in this way is where the pain starts.

Re:Teaching C (2016) by pjmlp on Wednesday October 31, 2018 @11:12AM (#18346328)
Overloading new/delete, STL allocators, <build your own while giving it as template parameter>, not sure they tie shape to behavior.
Re:Teaching C (2016) by jstimpfle on Wednesday October 31, 2018 @11:16AM (#18346369)
Here, shape = type. Yes, they do. Start thinking why C++ compilation times are so abysmal? Because of this dependency mess. Then realize the same inefficiencies apply to maintainers' heads.
Re:Teaching C (2016) by geezerjay on Tuesday October 30, 2018 @11:38AM (#18337654)
> Because memory management is an area where C++ over-simplifies and assumes one size fits all.

And the fact is that it does. In the rare case that it doesn't then C++ also accomosdates those requirements if developers are willing to put in the same sort of effort that goes into implementing data structures by hand.

Re:Teaching C (2016) by pjmlp on Tuesday October 30, 2018 @08:15AM (#18335765)
I hardly disagree that C was well engineered given how many memory corruption bugs DoD found on Multics codebase vs plain UNIX, and how many we continue to get every single month to this day.

Well engineered tools have quality as their main focus.

C won its place in the world thanks to UNIX adoption, and its commoditization via free beer OSes, nothing else.

Re:Teaching C (2016) by simias on Tuesday October 30, 2018 @07:52AM (#18335641)
My point was that I don't think Smalltalk was ever more popular in the industry than C regardless of the time frame. By the mid 90's lisp machines were pretty long gone, betting on Lisp instead of C if employability is the metric seems rather bold.

MIPS I concede, it was remained fairly popular for a long time.

I guess my overall point is that the subjective choices made by this university back then don't really mean much by now. The fact that they taught Pascal instead of C alone proves that they weren't particularly prescient.

>Regarding language comparisons, actually C++ is Italian and C Latin.

I thought about that while writing this bad analogy but I couldn't come up with a better one. I wasn't really talking about the historical relationship between C and C++ but rather about their relative complexities. Learning C++ is vastly more complicated than learning C. On top of that the coding style of a modern C++ application (which generally involves a lot of metaprogramming, OOP and even some functional constructs) is fairly different from a standard C codebase. You don't write C like you write C++ and vice-versa.

There's this good talk about how we should "stop teaching C" (if we want to teach C++): https://www.youtube.com/watch?v=YnWhqhNdYyk

I think the opposite holds true as well for very much the same reasons.

Re:Teaching C (2016) by sacado2 on Tuesday October 30, 2018 @08:03AM (#18335705)
And Pascal was a big language back then. Big software like photoshop were written in it, IIRC. The very first version of GCC, in the late 80s (when it was not even called that way) was written in a pascal dialect, too (and compiled both C and pascal code).

OTOH, C was just standardized a few years before, and linux was just a side project from an unknown student in a small university. And there was a new version of C, with objects, classes, inheritance and all those buzzwords, so why care about the old C anyway?