Author Topic: "Stop Teaching C" - Kate Gregory  (Read 29946 times)

0 Members and 1 Guest are viewing this topic.

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2009
  • Country: au
Re: "Stop Teaching C" - Kate Gregory
« Reply #25 on: October 31, 2016, 01:19:35 pm »
Although I learnt C before C++ existed, i.e. I've been programming for a long time, I'm only a very casual programmer and know nothing of the software industry.

With that in mind, my question is:
Given all of the higher (than C++) level languages doing the rounds on all the major OS's and the reluctance to fully embrace C++ in the embedded world, is C++ jostling for somewhere to sit or does it have a dominant field somewhere?
 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #26 on: October 31, 2016, 01:27:48 pm »
Although I learnt C before C++ existed, i.e. I've been programming for a long time, I'm only a very casual programmer and know nothing of the software industry.

With that in mind, my question is:
Given all of the higher (than C++) level languages doing the rounds on all the major OS's and the reluctance to fully embrace C++ in the embedded world, is C++ jostling for somewhere to sit or does it have a dominant field somewhere?

C++ is pretty much the glue underneath most of our non-unix style computing i.e. windows and desktop applications. It has some applications in the server space such as SQL Server etc. Google also seem to use it for a lot of their stuff although they saw fit to start funding their own language (Go) that fits the same niche as it's expensive to build software in.

I see it occasionally in the finance sector, but it's dying rapidly. Managed languages (Java and C#) is where it's at with some Python creeping in and some people in shorts with macbooks writing Clojure or ruby but we have to rewrite all their shit in Java after they've gone anyway...

As for C vs C++, every place I'd use C++ I could use either Java or plain old C and tend to choose them respectively. C++ lumbers me with abstractions that are historically poorly conceived or memory heavy so I either don't use them and just use C or do use them and might as well use Java and get some higher level OO support. C++ sits in a weird void in the middle full of type, cast, structure and object weirdness.

Yes indeed. I'm reminded, w.r.t. high level abstractions, that C++'s predecessors Smalltalk and Objective-C are an improvement on C++.

C++'s designers chose to take the attitude that "we don't know what's best, so we'll punt difficult decisions to the ordinary developers". The predictable consequence is a range of implementation decisions that significantly reduces the chances that one library/implementation will play nicely with another.

One of the interesting phenomena when Java was introduced was that the papers on it and discussions about it frequently mentioned hard-won experience from other languages. In contrast C++ only mentioned C++ and C, and it was clear that many authors had a very narrow, blinkered view of the world. It is not surprising that they slowly reinvented concepts, poorly.

C has the conceptual integrity of staying close to the silicon, but even then the computer science bods have added a lot of ill-fitting cruft. (Is it possible to "cast away constness" now?)

Couldn't agree more. I keep receiving tangles of boost and stl to this day that proves that point. I can usually rewrite the whole damn thing in Java from scratch including the test suite before I've even untangled the mess even as a seasoned C++ wrangler. And then there's sticky tape like cmake and the like that just never work properly.

Anyway I'm going to stop ranting now and go and make some money :)
 

Offline Karel

  • Super Contributor
  • ***
  • Posts: 1401
  • Country: 00
Re: "Stop Teaching C" - Kate Gregory
« Reply #27 on: October 31, 2016, 01:45:11 pm »
Although I learnt C before C++ existed, i.e. I've been programming for a long time, I'm only a very casual programmer and know nothing of the software industry.

With that in mind, my question is:
Given all of the higher (than C++) level languages doing the rounds on all the major OS's and the reluctance to fully embrace C++ in the embedded world, is C++ jostling for somewhere to sit or does it have a dominant field somewhere?

Java, C and C++ are the three major programming languages.

http://www.tiobe.com/tiobe-index/

The difference between theory and practice is less in theory than
the difference between theory and practice in practice.
Expensive tools cannot compensate for lack of experience.
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 10227
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #28 on: October 31, 2016, 04:42:24 pm »
I see [C++] occasionally in the finance sector, but it's dying rapidly. Managed languages (Java and C#) is where it's at with some Python creeping in and some people in shorts with macbooks writing Clojure or ruby but we have to rewrite all their shit in Java after they've gone anyway...

Snort :)

Interestingly, some soft-realtime Java financial applications are very adept at avoiding GC pauses and maintaining high throughput - which is usually claimed to be an advantage for C++. Some telecom applications are the same.

OTOH if hard-realtime behaviour is required, then most of C++'s "advantageous facilities" have to be avoided, and it is necessary to write in a subset of C.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #29 on: October 31, 2016, 05:17:43 pm »
Indeed. In fact that's how the Windows kernel looks. It's C++ but it's not.

Erlang is the other option in this space. Now that's a platform :)
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 2952
  • Country: fr
Re: "Stop Teaching C" - Kate Gregory
« Reply #30 on: October 31, 2016, 05:57:41 pm »
There is one good reason why C tends to be taught first and only later C++ (if ever or as an elective). C is usually part of the first introductory programming courses, where the students need to learn some basic algorithmic thinking first, with many having never programmed before. While C is far from an ideal language for that, the idea is, especially in engineering and not CS oriented curricula, that the student is given a tool they can use to solve real world (as opposed to toy) problems right away.

The CS students will have opportunities to learn other languages than their Python or Scheme or whatever is used in the 1st semester programming course later. For the engineering students these courses could be the only formal exposure to programming they will get during their study, that's why the language of choice is often C.

C++ in this context would be unnecessarily complex - I can't talk about OOP or metaprogramming or iterators to people who don't have a clue what a loop is or how to represent data using variables yet. You could certainly do this using C++ syntax as well, but then there would be a lot of things you would need to handwave away as something the students should take for granted and not focus on just yet (e.g. C++ strings or STL vectors and such). That's a bad thing pedagogically, because such "black magic" will reliably confuse the students. The reasons for the choice are really not technical but pedagogical in this case. (been there, done that, having taught undergraduate programming courses).

On the other hand, where the students know to program already because they are moving from e.g. Java, C# or something else, then yes, start with C++ right away. At that point the foundations should be fairly solid already. I believe that that is the situation the video is assuming.

BTW, someone said above that C++ is superset of C - it isn't. At least not a proper superset. There is plenty of perfectly valid mainstream (no obscure tricks) C code that will not compile using C++ compiler. For example C99 style struct initialization doesn't work in C++, there are more reserved words in C++ than in C (new, delete, template, auto has different meaning, etc.)
« Last Edit: October 31, 2016, 06:09:31 pm by janoc »
 
The following users thanked this post: all_repair

Offline Simon

  • Global Moderator
  • *****
  • Posts: 13920
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: "Stop Teaching C" - Kate Gregory
« Reply #31 on: October 31, 2016, 05:59:21 pm »
So should I be learning C++ instead of C for AVR microcontrollers?
https://www.simonselectronics.co.uk/shop
Varied stock of test instruments and components including EEVblog gear and Wurth Elektronik Books.
Also, if you want to get ripped off: https://www.ebay.co.uk/usr/simons_electronics?_trksid=p2047675.l2559
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4345
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #32 on: October 31, 2016, 06:03:55 pm »
ups, I had two tabs in my browser
and I filled the topic in the wrong one 

thanks for the fix  :-+ :-+ :-+
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4345
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #33 on: October 31, 2016, 06:13:00 pm »
I like a few things about C++

operators overloading
the language is more typed
it allows passing arguments by reference
string_t is actually a string type
exceptions (even if .. well there are a lot of problem, but the idea is good)
iterators
RAII
scopes


for my own learning curve, I followed this approach

  • step0: Accelerated C++ (book)
  • step1: Beyond the Standard Library (book)
  • step2: RAII (tutorial)
  • step3: STL (tutorial)
 

Offline John Coloccia

  • Super Contributor
  • ***
  • Posts: 1199
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #34 on: October 31, 2016, 06:15:09 pm »
With that in mind, my question is:
Given all of the higher (than C++) level languages doing the rounds on all the major OS's and the reluctance to fully embrace C++ in the embedded world, is C++ jostling for somewhere to sit or does it have a dominant field somewhere?

There's no problem with C++ in the embedded world. Much embedded programming is simply too simple to warrant  doing a proper design that would take advantage to C++, but you can and I certainly have many times.

I do question the idea of teaching C++ as it's own language, distinct from C. Yes, you can do that, but it is frankly not a great language. There are better languages, depending on what you're doing, that are probably better fits for the kind of programming she wants to teach. The only reason C++ is popular is that you can use C++ kinds of things when you want to, and C kinds of things when you want to. If someone snapped their fingers and suddenly removed all of the C kinds of things from C++, C++ would die overnight.

So while the intent of the presentation is good, I think it's a bit counterproductive. Without C, there is no C++. We'd all just move over to something like D, or C#. But I guess when you have to teach a 5 day course, which is pretty ridiculous IMHO and the root of the problem, you have to make strange decisions.
« Last Edit: October 31, 2016, 06:18:07 pm by John Coloccia »
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4345
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #35 on: October 31, 2016, 06:16:43 pm »
So should I be learning C++ instead of C for AVR microcontrollers?

sure, the alternative is C, and then "Accelerated C++"
this book covers the difference from C to C++
it shouldn't be boring, I was not bored :-+
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 10227
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #36 on: October 31, 2016, 06:41:11 pm »
So should I be learning C++ instead of C for AVR microcontrollers?

That depends on:
  • how you want to express your solution, i.e. what abstractions you will employ
  • available RAM/ROM
  • mandatory run-time behaviour
  • externally imposed standards, e.g. MISRA
  • what libraries you will use
  • what tools are known by you and any local guru
  • how long before your solution is required

My personal preference is to stick with C, but that can be overriden by any of the above considerations.

Be aware that C++ has a steeper learning curve than C, it punts many design choices to the developer, and there are more pitfalls than with C. Read learn and inwardly digest some of the pitfalls in the FQA http://yosefk.com/c++fqa/
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4345
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #37 on: October 31, 2016, 06:43:50 pm »
Some of the perceptions that discourage the use of C++
in embedded systems are:

C++ is slow and C++ produces bloated machine code
and Objects are large and Virtual functions are slow
and C++ isn’t ROMable and Class libraries make large binaries
and Abstraction leads to inefficiency

and most of these ideas are wrong  :D
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 10227
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #38 on: October 31, 2016, 06:48:31 pm »
I do question the idea of teaching C++ as it's own language, distinct from C. Yes, you can do that, but it is frankly not a great language. There are better languages, depending on what you're doing, that are probably better fits for the kind of programming she wants to teach. The only reason C++ is popular is that you can use C++ kinds of things when you want to, and C kinds of things when you want to. If someone snapped their fingers and suddenly removed all of the C kinds of things from C++, C++ would die overnight.

That's pretty sane.

Quote
So while the intent of the presentation is good, I think it's a bit counterproductive. Without C, there is no C++. We'd all just move over to something like D, or C#.

Don't forget that C# is, to all intents and purposes, Java with a different runtime.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4345
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #39 on: October 31, 2016, 06:52:35 pm »
That depends on:


perhaps I can add a new point:
has anyone bought the license for the C++ compiler  :D ?
in my case: emmm VisualDSP++ comes with a license for C
but there is no C++KEY cardboard in the box on my desk

therefore trapped, no escape way :-DD
 

Offline tggzzz

  • Super Contributor
  • ***
  • Posts: 10227
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #40 on: October 31, 2016, 07:01:10 pm »
I can't talk about OOP or metaprogramming or iterators to people who don't have a clue what a loop is or how to represent data using variables yet.

I can, and have, with good success. The prerequisite is that the student can think about their problem in an abstract way, without being obsessed with a particular syntax and semantics. That's a valuable start, because then they will have a clue that they need to choose an appropriate language in which to express their problem. Good luck expressing an FSM in Prolog, or a forward/backward chaining algorithm in a matrix-based language, etc, etc, etc!

Quote
On the other hand, where the students know to program already because they are moving from e.g. Java, C# or something else, then yes, start with C++ right away. At that point the foundations should be fairly solid already. I believe that that is the situation the video is assuming.

Why bother introducing them to another language trying to do OOP (and failing to do it well), when there are so many completely different domains out there? If you want to get the students into the deeply embedded domain, use C or ADA.
There are lies, damned lies, statistics - and ADC/DAC specs.
Glider pilot's aphorism: "there is no substitute for span". Retort: "There is a substitute: skill+imagination. But you can buy span".
Having fun doing more, with less
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4345
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #41 on: October 31, 2016, 07:04:50 pm »
what I really like from the Kate's talk is what she has underlined:

C++ is fundamentally different than C, everything that is valid C is valid C++
but C++ is a very different language and one needs to learn how to program in C++
and not C, to effectively use *the language* in any situation

in a nutshell: in C++, you need to program object-oriented, not procedurally
and not a hybrid of the two (big classes with lots of functions … Arduino way?)

well said, Saint Kate immediately :D
 

Offline John Coloccia

  • Super Contributor
  • ***
  • Posts: 1199
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #42 on: October 31, 2016, 08:15:28 pm »
Don't forget that C# is, to all intents and purposes, Java with a different runtime.

Well, I'll have to respectfully disagree there. There's a good deal of difference between Java and C#, though I know what you're trying to say. And I've always hated Java, BTW. Really, though, the natural successor to C and C++ is D. It really is an excellent systems language, and is very pragmatic in it's approach.

C++, in it's infancy and before STL, was a simple language and more or less an extension of C. Despite that, it was still notoriously difficult to write a compiler for it. I remember I had all sorts of problems getting templates to work if you went too far off the reservation and tried something clever. That right there should have been a sign that something was conceptually wrong.

But that's how I like C++. It's an excellent extension to the C language. But it didn't stop there. It's turned into this whacky, steam-punk like contraption, with random pipes and valves tacked on all over the place, lumbering, belching steam and black smoke, and there's no end in sight for what else might get tacked on.

No one actually even uses the entire language, or even close to it. I'm not talking about all of the libraries. I'm talking about just the basic language features. People pick the handful of things they like, and that's all they use. You go somewhere else, and they use different things. Two C++ programs written by two different groups that do EXACTLY the same thing can written so differently that an expert C++ programmer might understand one perfectly well, but have significant trouble understanding the other. Each group will have their arbitrary rules: we use THIS, we don't use THAT. It's kind of ridiculous. Streams are a perfect example.

D is completely different. It's very simple, straightforward and easy to understand. I don't mean that it's like BASIC. It's a very rich language, but it's more like a C++ that's been designed from the ground up to be a cohesive language that makes sense. C++ is a nightmarish mish-mosh of almost academic and "safe" OOP concepts, combined with coiled cobras ready to strike, and in between is an incomprehensible  labyrinth of strange notation and obscure behavior. It's like someone took 2 or 3 completely different and incompatible language, tossed them in a blender and said, "Screw it...let the programmers figure it out."
« Last Edit: October 31, 2016, 08:30:43 pm by John Coloccia »
 
The following users thanked this post: helius

Online snarkysparky

  • Regular Contributor
  • *
  • Posts: 172
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #43 on: October 31, 2016, 08:36:50 pm »
The thing that makes C difficult is the need to grasp basic computer architecture.  Pointers are basic to any implementation even behind the scenes in C++ programs.

Learning C teaches needed basics.

 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 6614
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #44 on: October 31, 2016, 08:41:02 pm »
The video was pretty good!  I went looking for her books and other than one on parallel programming using a GPU, they are all OLD.  Like 2003 old.  Bummer!  She wants to use C++14 but has yet to write anything about it.

In the back of my mind I had wanted to see a book using her concepts just in case I decided to look at C++, again.  I went to the web site but, alas, their membership fees are a little rich for me.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 6614
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #45 on: October 31, 2016, 08:49:55 pm »
The thing that makes C difficult is the need to grasp basic computer architecture.  Pointers are basic to any implementation even behind the scenes in C++ programs.

Learning C teaches needed basics.

Over the last 20 years or so, there has been a move away from understanding hardware for anyone not involved with embedded or system programming.  Memory is gigantic, disk space is unlimited, speed is blazing so why spend any time worrying about the details?  Write code that fills the machine and wait for a bigger machine!  Keeps everybody busy...

I like simple languages!  When people start talking about the features of C++, I am lost.  I like C and I like FORTRAN.  I also like the expressive power of Python and I think PL/I was ahead of its time.  Introduced today, I could see PL/I taking off.  Java and C++ are just not languages that interest me.  They just don't fit in my little corner of the sandbox.  For dealing with data structures, I really liked Pascal.
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4345
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #46 on: October 31, 2016, 08:51:56 pm »
Bummer!  She wants to use C++14 but has yet to write anything about it

well, I will draw and list any saint immediately upon request  :D
(kidding, my humor)
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 2952
  • Country: fr
Re: "Stop Teaching C" - Kate Gregory
« Reply #47 on: October 31, 2016, 09:57:55 pm »
I can, and have, with good success. The prerequisite is that the student can think about their problem in an abstract way, without being obsessed with a particular syntax and semantics.

Which is exactly the point - many first year students can't do that yet, having never encountered neither programming nor abstract problem descriptions before.

Heck, high schools don't teach hands-on math or physics anymore, they "only talk about it" for the sake of making it "accessible" to everyone, because it has been perceived as "too difficult" by the government experts (Denmark, the answer I have received from high school teachers when I was wondering how come that the students don't know what a fraction is and don't understand basic symbolic notation - dead serious, not joking here!).

So this stuff is not something you can take for granted and you must start from the real basics. The time when kids were spending their afternoons and evenings hacking in Basic on their 8bitters and Amigas are long gone. The students I have had all had expensive MacBooks and similar, but beyond browsing web, pirating movies, watching porn and chatting on Facebook they didn't know at all how to use them. I have even met a guy who was copying files by opening them in Word, then copy & pasting the content into a new document and saving it under a different name.  Another one kept the protective film on the display of his new laptop for several months, squinting around the creases when he couldn't see the text properly :palm:

So that is the "material" these courses have to work with.

That's a valuable start, because then they will have a clue that they need to choose an appropriate language in which to express their problem. Good luck expressing an FSM in Prolog, or a forward/backward chaining algorithm in a matrix-based language, etc, etc, etc!

Why? FSM in Prolog is perfectly fine:
http://cs.union.edu/~striegnk/courses/nlp-with-prolog/html/node5.html

Not that I would teach introduction to programming with Prolog, though ...

Not sure what you mean by "matrix-based", something like R or Matlab? I don't see why such algorithm would be difficult in these. Befunge (https://en.wikipedia.org/wiki/Befunge) on the other hand ...

Quote
Why bother introducing them to another language trying to do OOP (and failing to do it well), when there are so many completely different domains out there? If you want to get the students into the deeply embedded domain, use C or ADA.

Because not all curicula are about (deeply) embedded programming? The uni I was at was teaching basics of programming even to future chemistry and mechanical engineers that would go on to design oil rigs and refineries, for example. They may never develop software for sale during their careers but they may have to build a simulation of something, to analyze some data or to build a plugin for that Matlab they are most likely going to be using. So knowing at least the basics is going to be useful for them.

But as I have said - C++ is often not taught or it is an elective - in that case it is not my business to question the motivation of the students why did they choose the course. Perhaps they want to simply increase their value on the job market - there are certainly more jobs for C/C++ programmers than for ADA ones, for example.

« Last Edit: October 31, 2016, 10:08:28 pm by janoc »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3066
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #48 on: October 31, 2016, 10:50:07 pm »
So, I've been taking some python classes.    Interesting stuff; just what I need for dealing with .xml files (for example.)
But as an old C/asm OS/embedded programmer, there are definitely some "disturbing" aspects (common to a a LOT of these modern languages that are being pushed in CS):
1) All containers are dynamically allocated and resizeable (in python, this includes integers!)
2) algorithmic elegance and theoretical performance beats implementation quality.
2a) If performance is A*f(n), only the magnitude of f(n) matters (ie O(n**2))
2b) recursion is an elegant and desirable implementation tool.
3) performance of language elements is not considered.
4) size of runtime environment is not considered.

 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #49 on: October 31, 2016, 11:19:06 pm »
I do a fair bit of work with python. It's slightly horrible to merge, slow as anything and the packaging story is horrible. Great for one shot quick projects, prototypes and testing ideas etc. I have a script running on a Pi Zero that hangs off the back of my Xbox for power that is headless and runs a python script every ten minutes scans gumtree for things before anyone else gets them :)

Scored me a Marconi 2019A for £10 :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf