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

0 Members and 1 Guest are viewing this topic.

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
"Stop Teaching C" - Kate Gregory
« on: October 30, 2016, 11:33:16 pm »


Kate Gregory explains her reasons in this funny video  :-+
 

Offline dave_k

  • Frequent Contributor
  • **
  • Posts: 265
  • Country: au
Re: "Stop Teaching C" - Kate Gregory
« Reply #1 on: October 31, 2016, 12:53:39 am »
.. and it's for sale? Or you want to swap it for a tin of striped paint?  :-DD
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 18028
  • Country: nl
    • NCT Developments
Re: "Stop Teaching C" - Kate Gregory
« Reply #2 on: October 31, 2016, 01:07:13 am »
Maybe Legacy figured out tggzzz isn't browsing this section and wanted to hide this lecture  :popcorn:

IMHO this thread should be moved though and I think the lecture has some very valid points on how to use C++ to create robust programs and leave the bad things of C out.
« Last Edit: October 31, 2016, 01:22:10 am by nctnico »
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline Brumby

  • Supporter
  • ****
  • Posts: 9409
  • Country: au
Re: "Stop Teaching C" - Kate Gregory
« Reply #3 on: October 31, 2016, 01:53:16 am »
Yes.  Move it.  This is the wrong place.


As for the content - I must applaud it wholeheartedly.

Teaching new people the old ways - and then having to un-learn a lot of that to be able to learn the better way of doing things is demonstrably idiotic - but it happens through laziness and complacency... and, all too often, through the lack of support by the establishment to retire the archaic tools they were brought up on.

There was one line near the start that I found as rather profound - and a key element of learning

"You can focus on whatever you want to focus on - whether it's "If"s or loops or something... the fact that there's a string class for them is a minor miracle to those of us who started learning in the 80's.  It's not a minor miracle to the people you are teaching today - it's just how the world is."

This is why the kids of today grow up using the technology as they do.  They don't need to understand the history; they don't need to understand the engineering to get to make the technology do something useful - and they can get pretty advanced in the utilisation without it.  Certainly, there will be a point where some individuals will take things further and some of this obscure information may be necessary, but not for 80% of those who want to get into it - at least not in the first day or two!
« Last Edit: October 31, 2016, 02:19:39 am by Brumby »
 

Offline DimitriP

  • Super Contributor
  • ***
  • Posts: 1055
  • Country: us
  • "Best practices" are best not practiced.© Dimitri
Re: "Stop Teaching C" - Kate Gregory
« Reply #4 on: October 31, 2016, 02:43:02 am »
Yes.  Move it.  This is the wrong place.


As for the content - I must applaud it wholeheartedly.

Teaching new people the old ways - and then having to un-learn a lot of that to be able to learn the better way of doing things is demonstrably idiotic - but it happens through laziness and complacency... and, all too often, through the lack of support by the establishment to retire the archaic tools they were brought up on.

In some cases a one trick pony is better than a jack of all trades. But not in most.
Eventually people gravitate to sowemewhere in between. A few tricks pony or a jack of most trades , master of some.
Deciding what should be considered for retirement as archaic, would make a great PhD thesis, getting a concensus and applying it in real life would be a different story.

Most of the annoying/long running/recurring threads "here" are mostly because of lack of basic fundamental "archaic" knowledge or skills.

 


   If three 100  Ohm resistors are connected in parallel, and in series with a 200 Ohm resistor, how many resistors do you have? 
 

Offline AlfBaz

  • Super Contributor
  • ***
  • Posts: 2009
  • Country: au
Re: "Stop Teaching C" - Kate Gregory
« Reply #5 on: October 31, 2016, 03:07:22 am »
The crux of the story can be summarised into one short paragraph, as it is in most C++ books, and easily undersood...
It takes a c++ devotee to drag it out to an hour, not unlike a lot of c++ code >:D  :box:
 

Offline timb

  • Super Contributor
  • ***
  • Posts: 2528
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
"Stop Teaching C" - Kate Gregory
« Reply #6 on: October 31, 2016, 05:43:45 am »
Yes.  Move it.  This is the wrong place.


As for the content - I must applaud it wholeheartedly.

Teaching new people the old ways - and then having to un-learn a lot of that to be able to learn the better way of doing things is demonstrably idiotic - but it happens through laziness and complacency... and, all too often, through the lack of support by the establishment to retire the archaic tools they were brought up on.

In some cases a one trick pony is better than a jack of all trades. But not in most.
Eventually people gravitate to sowemewhere in between. A few tricks pony or a jack of most trades , master of some.
Deciding what should be considered for retirement as archaic, would make a great PhD thesis, getting a concensus and applying it in real life would be a different story.

Most of the annoying/long running/recurring threads "here" are mostly because of lack of basic fundamental "archaic" knowledge or skills.

Fun Fact: Most people quote the "Jack of All Trades, Master of None" part of the saying, but invariably leave out the ending...

"Jack of All Trades, Master of None, but surely better than a Master of Some."
Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9211
  • Country: my
  • reassessing directives...
Re: "Stop Teaching C" - Kate Gregory
« Reply #7 on: October 31, 2016, 05:59:27 am »
i dont read it but i kinda agree with the topic. reusable functions "only" procedure as in C is obsolete. what we need is reusable object and of course still reusable functions. i cannot distinguish a pure C code since when i learnt C/C++, C++ was already there, so terms like "extern C" is pure nonsense to me. they should teach C++ first, and then if necessary C just for additional knowledge, or limited resources platform like embedded mcu.

if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Offline Brumby

  • Supporter
  • ****
  • Posts: 9409
  • Country: au
Re: "Stop Teaching C" - Kate Gregory
« Reply #8 on: October 31, 2016, 06:16:48 am »
they should teach C++ first, and then if necessary C just for additional knowledge, or limited resources platform like embedded mcu.

I think Kate Gregory might agree with you.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9211
  • Country: my
  • reassessing directives...
Re: "Stop Teaching C" - Kate Gregory
« Reply #9 on: October 31, 2016, 07:33:09 am »
they should teach C++ first, and then if necessary C just for additional knowledge, or limited resources platform like embedded mcu.
I think Kate Gregory might agree with you.
btw i think learning C++ is also learning C at the same time, its just C is subset of C++, and C++ is superset of C. so when we learn C++, all is not lost in C, except some subtleties specific to C calling convention important when you want to interface with older/external codes/binaries.
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Offline blueskull

  • Supporter
  • ****
  • Posts: 12479
  • Country: cn
  • Power Electronics Guy
Re: "Stop Teaching C" - Kate Gregory
« Reply #10 on: October 31, 2016, 07:40:13 am »
i dont read it but i kinda agree with the topic. reusable functions "only" procedure as in C is obsolete. what we need is reusable object and of course still reusable functions. i cannot distinguish a pure C code since when i learnt C/C++, C++ was already there, so terms like "extern C" is pure nonsense to me. they should teach C++ first, and then if necessary C just for additional knowledge, or limited resources platform like embedded mcu.

extern C tells the linker to find library in C calling convention, which is standardized. C++ calling convention is not, so MSVC's output may not be linkable with GCC's object file.
Using extern C allows the linker to forget about overload and only search for a single function prototype which fits exactly the name.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9211
  • Country: my
  • reassessing directives...
Re: "Stop Teaching C" - Kate Gregory
« Reply #11 on: October 31, 2016, 07:47:48 am »
Fun Fact: Most people quote the "Jack of All Trades, Master of None" part of the saying, but invariably leave out the ending...
"Jack of All Trades, Master of None, but surely better than a Master of Some."
why people ruling out the possibility of "Jack of All Trades, Master of Everything"? dont tell me what i cant do! :P

extern C tells the linker to find library in C calling convention, which is standardized.
yeah i mean if you are building your app from scratch, there is no reason for you to make an archaic convention for new functions anymore. hence there should be no need for "extern C". except for some specific, diminishing and subjected to extinction reasons mentioned above.
« Last Edit: October 31, 2016, 07:51:54 am by Mechatrommer »
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Offline DimitriP

  • Super Contributor
  • ***
  • Posts: 1055
  • Country: us
  • "Best practices" are best not practiced.© Dimitri
Re: "Stop Teaching C" - Kate Gregory
« Reply #12 on: October 31, 2016, 07:52:46 am »
Fun Fact: Most people quote the "Jack of All Trades, Master of None" part of the saying, but invariably leave out the ending...
"Jack of All Trades, Master of None, but surely better than a Master of Some."
why people ruling out the possibility of "Jack of All Trades, Master of Everything" dont tell me what i cant do! :P


Anarchy!!! How can quarterly earnings be possibly predicted when too many people have this kind of attitude ?  ;)
   If three 100  Ohm resistors are connected in parallel, and in series with a 200 Ohm resistor, how many resistors do you have? 
 

Offline blueskull

  • Supporter
  • ****
  • Posts: 12479
  • Country: cn
  • Power Electronics Guy
Re: "Stop Teaching C" - Kate Gregory
« Reply #13 on: October 31, 2016, 08:00:01 am »
yeah i mean if you are building your app from scratch, there is no reason for you to make an archaic convention for new functions anymore. hence there should be no need for "extern C". except for some specific, diminishing and subjected to extinction reasons mentioned above.

With the standardized calling convention, I can write my GUI in C++ form MSVC, then link some C libraries compiled with a different vendor's compiler, such as OpenACC compiler pgcc, or icc, or gcc.
Had I wrote my library in C++, I have to stick with a compatible compiler.
Also, due to minor differences of runtime functions, a C++ object file may not statically link correctly to object files compiled with different version of the same compiler or a different compiler using same calling convention. In C, none of these issues exist.
Finally, I have to include a several MB runtime library for my C++ programs, while many C compilers depend on no DLL files except for msvcrt.dll and common Win32 dll files.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9211
  • Country: my
  • reassessing directives...
Re: "Stop Teaching C" - Kate Gregory
« Reply #14 on: October 31, 2016, 08:05:26 am »
Fun Fact: Most people quote the "Jack of All Trades, Master of None" part of the saying, but invariably leave out the ending...
"Jack of All Trades, Master of None, but surely better than a Master of Some."
why people ruling out the possibility of "Jack of All Trades, Master of Everything" dont tell me what i cant do! :P
Anarchy!!! How can quarterly earnings be possibly predicted when too many people have this kind of attitude ?  ;)
i'm not sure what you mean, but what i understand is why people who spend to much things on a particular timeframe can be the same as a person who spend on one particular thing on that same particular time frame? right? well my answer is because that "speciallized" person who spent on one particular thing to become a master could waste alot of time in the process in clubbing, beering and partying, the jack of all trades could be not.

Finally, I have to include a several MB runtime library for my C++ programs, while many C compilers depend on no DLL files except for msvcrt.dll and common Win32 dll files.
mee too, but its (calling convention) handled by macro nowadays, and i will avoid nasty call like passing the whole class to a dll with hope that the pointer who take it whatever data type it is, will point to the right location, because i'm aware of runtime virtual table.
« Last Edit: October 31, 2016, 08:15:06 am by Mechatrommer »
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Offline blueskull

  • Supporter
  • ****
  • Posts: 12479
  • Country: cn
  • Power Electronics Guy
Re: "Stop Teaching C" - Kate Gregory
« Reply #15 on: October 31, 2016, 08:14:52 am »
and i will avoid nasty call like passing the whole class to a dll, because i'm aware of runtime virtual table.

Same here. When I have to export a C++ DLL for some reason (for example, a GUI panel in a library to be called by a console program), I statically compile it as a standalone DLL without dependencies and export only functions without classes and declare them as standard calls.
 

Offline Karel

  • Super Contributor
  • ***
  • Posts: 1401
  • Country: 00
Re: "Stop Teaching C" - Kate Gregory
« Reply #16 on: October 31, 2016, 08:17:55 am »
"C++ is a horrible language. It's made more horrible by the fact that a lot
of substandard programmers use it, to the point where it's much much
easier to generate total and utter crap with it. Quite frankly, even if
the choice of C were to do *nothing* but keep the C++ programmers out,
that in itself would be a huge reason to use C."

http://harmful.cat-v.org/software/c++/linus

From my personal experience, I tend to agree with this.
I want to believe that there are C++ programmers who really know what they are doing.
I guess I just haven't met them...
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.
 
The following users thanked this post: boffin, Ian.M, Bruce Abbott, george.b

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9211
  • Country: my
  • reassessing directives...
Re: "Stop Teaching C" - Kate Gregory
« Reply #17 on: October 31, 2016, 08:22:09 am »
"C++ is a horrible language."
here we go again :palm:
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #18 on: October 31, 2016, 08:44:29 am »
C and C++ both have their own problems. Neither is superior to the other. Lisp sucks. ADA sucks. Python sucks. Go sucks. D sucks. This is 50 years of computer science turd shuffling.

We need a new language that reaches down to the hardware and up to the application with some fresh ideas.

But until then everyone needs to STFU with the whining about C and build things with whatever tools you have.
 

Offline blueskull

  • Supporter
  • ****
  • Posts: 12479
  • Country: cn
  • Power Electronics Guy
Re: "Stop Teaching C" - Kate Gregory
« Reply #19 on: October 31, 2016, 08:53:40 am »
But until then everyone needs to STFU with the whining about C and build things with whatever tools you have.

Correct. Till now, our university still offers mandatory C programming for ECE undergrad students, but C++ is not mandatory. In fact, for graduate students, C++ is not offered anymore. Instead, for graduate students we offer Ruby on Rails now.
While being a hobbyist programmer using VB6 and C for more than 15 years and I taught C lab sessions in university, I cannot use C++ except for calling functions in Classes, and I feel C enough for all my needs except for GUI programming, which I use C# or C++.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #20 on: October 31, 2016, 09:32:05 am »
Maybe Legacy figured out tggzzz isn't browsing this section and wanted to hide this lecture  :popcorn:

... which would be mistaken, of course.

I'm certainly not going to waste an hour of my remaining life watching the whole video, but it seems to me she is saying that when teaching beginners (inc 12y year olds!) to use the "high-level" abstractions  in C++, you shouldn't teach C first. That seems pretty sensible.

But most people have figured that if you want to teach "high level" abstractions to beginners in a way they can use them to earn money, there are much better languages to use.

I didn't see (but quite probably missed it in my quick skim), how to teach what people should do when something doesn't work as expected, e.g. a non-standard library or the compiler. The suggestion to use the debugger is, um, optimistic since C++ data in memory is untyped: when you most need a debugger, it can't accurately tell you what's there, let alone how it got there.
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 #21 on: October 31, 2016, 09:51:08 am »
tgzzz - spot on. I rarely use a debugger and only in early dev to debug test cases. It's a crutch that isn't there when you have to take the biggest falls. Most things I get handed are steaming core dumps with no debug symbols. You need to know how to fight these.

I'd rather people started at the bottom and got an idea of assembly and how the CPU works at least roughly, then looked at slightly higher level languages (C), then looked at high level languages (C#/Java) if you need that sort of thing.

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.
 

Offline blueskull

  • Supporter
  • ****
  • Posts: 12479
  • Country: cn
  • Power Electronics Guy
Re: "Stop Teaching C" - Kate Gregory
« Reply #22 on: October 31, 2016, 09:59:31 am »
tgzzz - spot on. I rarely use a debugger and only in early dev to debug test cases. It's a crutch that isn't there when you have to take the biggest falls. Most things I get handed are steaming core dumps with no debug symbols. You need to know how to fight these.

I'd rather people started at the bottom and got an idea of assembly and how the CPU works at least roughly, then looked at slightly higher level languages (C), then looked at high level languages (C#/Java) if you need that sort of thing.

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.

If you have some weird evil memory access issues that screws up your data structures or pointers, check out valgrind, a powerful memory access sanity and memory leak checking tool.
 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #23 on: October 31, 2016, 10:10:40 am »
I'm a prolific user of valgrind. Finds all sorts of nasties like use after frees as well.

I wrote my own data type library in C about 15 years ago as well that is quite good in these circumstances. Firstly it is heavily splattered with assert macros to force the fail fast methodology. Secondly, it gives you a to_graphviz() function for each fundamental type that will puke a graphviz file to stderr. Then a shell script that picks these out with cut marks, drops them in tmp and then renders the graphviz when it hits it and throws it in an image viewer. You can step through a program (usually with getc(), no debugger) and see the data structure changes graphically then.

I may tidy it up and stick it on github one day.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #24 on: October 31, 2016, 12:50:11 pm »
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?)
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 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.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • 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: 2954
  • 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: 13942
  • 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: 4349
  • 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: 4349
  • 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: 4349
  • 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 :-+
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • 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: 4349
  • 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
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • 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: 4349
  • 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
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • 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: 4349
  • 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

Offline snarkysparky

  • Regular Contributor
  • *
  • Posts: 174
  • 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.

 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 6655
  • 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.
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 6655
  • 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: 4349
  • 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: 2954
  • 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: 3077
  • 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 :)
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #50 on: October 31, 2016, 11:40:02 pm »
@westfw
as gentoo user I hate python :D

emerge is written in python along to a lot of tools
and python is always the first reason of my troubles
(especially under catalyst when I "cook" new stages
or when I emerge --sync an old stage4)

ok, it's not due to the language, which is fine, elegant, etc
it's just the tool, implementation and handling matter

the behavior of python v2.* is not exactly compatible with v3.*
and this may cause (and practically it does) troubles when you upgrade

I mean the code is not exactly portable "as is", it needs some work  :-//
 

Offline Karel

  • Super Contributor
  • ***
  • Posts: 1401
  • Country: 00
Re: "Stop Teaching C" - Kate Gregory
« Reply #51 on: November 01, 2016, 12:12:56 am »
has anyone bought the license for the C++ compiler  :D ?

One of the best C/C++ compilers is available for free. Why on earth would somebody pay for it (apart from donations)?
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.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #52 on: November 01, 2016, 12:38:58 am »
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.

A few months before C# was released, Anders Hejlsberg (the C# designer) gave a talk on C# at my workplace. After listening to what he had to say, we said we thought it sounded like Java with a different philosophy to the runtime environment, and asked him if that was the case. He didn't disagree, so we presume we did understand :)

The key difference is that C# does static optimisation based on what the compiler guesses the code will do at runtime, whereas HotSpot measures what the code is actually doing and optimises what is actually occurring. Both approaches are valid, of course, and are advantageous in different situations.

Quote
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.

There was worse: it was discovered the c++ template was Turing-complete, but the design committee didn't believe it until someone rubbed their noses in it by causing the compiler to emit the sequence of prime numbers during (infinite) compilation! That's from https://en.wikibooks.org/wiki/C%2B%2B_Programming/Templates/Template_Meta-Programming#History_of_TMP with my emphasis added. The original is at http://www.erwin-unruh.de/primorig.html Note: not designed, but discovered - and that's exactly what happened.

Personally I prefer my languages to be designed, not discovered!

Quote
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.

Snort :) Having said that, Java is showing similar behaviour :(

Quote
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.

Just so :(

Quote
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."

Just so. I can't comment on D, only having briefly looked at it and never used it.
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 tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #53 on: November 01, 2016, 12:47:59 am »
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 ...

Well, yes, they are both Turing complete. You can also use a hammer to insert a screw :)

Quote
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 ...

Yes, that kind of thing; there are many. Probably not APL, even though the characters no longer require changing the typewriter's golfball :)

Quote
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.

That's precisely my point!

Quote
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.

Such students should be kept away from keyboards. And yes, it is my business and duty (as an interviewer) to question their motivation :)
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 nctnico

  • Super Contributor
  • ***
  • Posts: 18028
  • Country: nl
    • NCT Developments
Re: "Stop Teaching C" - Kate Gregory
« Reply #54 on: November 01, 2016, 12:51:47 am »
A few months before C# was released, Anders Hejlsberg (the C# designer) gave a talk on C# at my workplace. After listening to what he had to say, we said we thought it sounded like Java with a different philosophy to the runtime environment, and asked him if that was the case. He didn't disagree, so we presume we did understand :)
AFAIK C# is Java which works. I recall reading that somewhere down the line Microsoft abandoned C++, didn't manage to get people into using Visual basic, found Java to be a mess (which it is) and came up with C# as a final solution to have an alternative for C++. The rest is history.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #55 on: November 01, 2016, 12:56:54 am »
Quote
there are certainly more jobs for C/C++
programmers than for ADA ones

sure, but consider the good side of the coin:

those in the circle of ADA programmers
are paid more money than those
in the circle of C/C++ programmers :D

good, ain't it?
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #56 on: November 01, 2016, 01:09:19 am »
if you know Prolog then you can find
a lot of job opportunities with AADL
e.g. the Stood Team

yes, unbelievable but Stood is actually written in Prolog

well paid job, unfortunately it's a damn complex job
and they don't need a lot of programmers  :palm:

(I know a few dudes in that team, their emails
due to Stood bugs report
I mean Stood is used in avionics for everything,
including code-design and documentation)
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #57 on: November 01, 2016, 01:32:26 am »
A few months before C# was released, Anders Hejlsberg (the C# designer) gave a talk on C# at my workplace. After listening to what he had to say, we said we thought it sounded like Java with a different philosophy to the runtime environment, and asked him if that was the case. He didn't disagree, so we presume we did understand :)
AFAIK C# is Java which works. I recall reading that somewhere down the line Microsoft abandoned C++, didn't manage to get people into using Visual basic, found Java to be a mess (which it is) and came up with C# as a final solution to have an alternative for C++. The rest is history.

Not quite.

MS couldn't use their usual "embrace and extend" tactic with Java, so they decided to triumphantly reinvent that particular wheel.

Unfortunately due to their strategy, they couldn't abandon C++, so they brought it inside the runtime via the "unsafe" keyword. That ensured they threw away an advantage of managed runtime environments - leaving them with the (small) overhead of a managed environment without its (major) advantage.

While the business rationale is impeccable, as an engineer I think that tradeoff is wrongheaded.
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 free_electron

  • Super Contributor
  • ***
  • Posts: 7242
  • Country: us
    • SiliconValleyGarage
Re: "Stop Teaching C" - Kate Gregory
« Reply #58 on: November 01, 2016, 01:37:50 am »
C is a slapped together (it was made so they could make an OS) , language for an obsolete computer architecture (PDP) , based on a lexer and parser that is so stupid it needs semicolons to figure out where a line ends ...
it's time it dies.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9211
  • Country: my
  • reassessing directives...
Re: "Stop Teaching C" - Kate Gregory
« Reply #59 on: November 01, 2016, 03:41:41 am »
Personally I prefer my languages to be designed, not discovered!
the only thing that is designed proof is a dead stone. once you open the complexity, how do you expect it is more perfect than the source of its existence? i mean, a language that put more restriction on the users, hence more controlled parameters from inside, designed by the language architech... granted it will be easier to make it turing complete, but is it worth the cost? to the users/programmers freedom side of things?

C is a slapped together (it was made so they could make an OS) , language for an obsolete computer architecture (PDP) , based on a lexer and parser that is so stupid it needs semicolons to figure out where a line ends ...
it's time it dies.
oh you havent typed in the modern languages. the ;, at, on, in... whatever syntaxes is notoriusly overwhelming, if i use that words correctly... be careful on what you pray for..
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Offline John Coloccia

  • Super Contributor
  • ***
  • Posts: 1199
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #60 on: November 01, 2016, 04:00:04 am »
C is a slapped together (it was made so they could make an OS) , language for an obsolete computer architecture (PDP) , based on a lexer and parser that is so stupid it needs semicolons to figure out where a line ends ...
it's time it dies.

Well, as many bad things as I have to say about C++ I can say good about C. I think C is darn near the perfect at doing what it was designed to do.
 

Offline John Coloccia

  • Super Contributor
  • ***
  • Posts: 1199
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #61 on: November 01, 2016, 04:07:17 am »
Just so. I can't comment on D, only having briefly looked at it and never used it.

Oh, you should definitely try it. The next time you have a small little utility to write, give it a try. You'll slowly find yourself using it more and more. A lot of it looks deceptively like C, but that was just for familiarity. It's what a modern language should look like.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3077
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #62 on: November 01, 2016, 04:23:47 am »
Quote
ADA
I was at ARM TechCon last week, and I finally figured out why Ada (and other langauges) have no popularity in embedded...
There was this big trade show, and lots of vendors.
IAR and Greenhills were there with their C compilers (plus ARM themselves with Keil, and Atmel/etc with gcc.)
Assorted vendors offering specialized debugging tools.  For C.
Assorted vendors with networking stacks: USB, Bluetooth, TCP/IP, assorted random wireless protoocols.  In C.
Assorted vendors with operating systems:  mBed.  Micrium.  MyNewt.  Zephyr.  All in C.

And, on the edge of the room, there was AdaCore with their Ada Compiler...  All by themselves.

I didn't see any "D", and I'm not sure about C vs C++.   There might have been some Java.  No C#, AFAICT.  After C the most "interest" was in the BBC Micro Bit, which has its own graphical programming language (for kids, you know.)

Most of the realistic alternatives to C in the embedded space are just languages.  C is ... multiple industries!
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #63 on: November 01, 2016, 05:33:47 am »
based on a lexer and parser that is so stupid
it needs semicolons to figure out where a line ends

I don't agree, the problem is not the semicolon at the end of the line
the problem is the C grammar itself which allows silly constructs
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #64 on: November 01, 2016, 05:44:28 am »
And, on the edge of the room, there was AdaCore
with their Ada Compiler...  All by themselves.

so, no chance to promote my own made language :D ?
it looks ADA-like, not yet decided how to call it

p.s.
but on Irc I have seen a lot of ADA-dudes

p.s.2
Code: [Select]
2016-11-01--13-14-37---2016-11-01--16-51-50 - emerge  =sys-devel/gcc-4.1.2 - success - root
2016-11-01--18-14-10---2016-11-01--20-02-04 - emerge  =sys-devel/gcc-4.9.3 - success - root
2016-11-01--20-11-57---2016-11-01--20-38-24 - emerge  =dev-lang/gnat-gcc-4.1.2 - failure - root
2016-11-01--21-04-40---2016-11-02--00-34-12 - emerge  =dev-lang/gnat-gcc-4.6.4 - failure - root
2016-11-02--00-53-29---2016-11-02--04-18-11 - emerge  =dev-lang/gnat-gcc-4.9.3 - failure - root

it seems GNAT is having some ... difficulties (on gentoo)


Most of the realistic alternatives to C in the embedded space
are just languages.  C is ... multiple industries!

exactly the point: companies have invested money
resources, effort, etc
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #65 on: November 01, 2016, 05:55:22 am »
Quote
Bugs
327043 : dev-lang/gnat-gcc-4.3.4 - precompiled bundled gcc is linked against old libmpfr
386661 : [portage-multilib] dev-lang/gnat-gcc: configure error for x85-abi due to gnatboot-4.4-amd64.tar.bz2
402157 : Remove dev-lang/gnat-gcc and dev-ada/asis-gcc
501178 : dev-lang/gnat-gcc-4.6.4: gnatmake always fails because it cannot find liblto_plugin.so
502444 : dev-lang/gnat-gcc version bump request
520154 : dev-lang/gnat-gcc-4.7.3 ?/gnatboot-4.6 - add HPPA support
536124 : dev-lang/gnat-gcc-4.4.7 - In file included from .../work/gcc-4.4.7/gcc/unwind-dw2.c:333: .../work/gcc-4.4.7/gcc/config/i386/linux-unwind.h:138: error: field ‘info’ has incomplete type
549546 : dev-lang/gnat-gcc-4.3.6 fails to build on ppc
554966 : dev-ada/glade-2006.0: wants dev-lang/gnat-gcc-4.2.3 which fails with "configure: error: installation or configuration problem: C compiler cannot create executables."
560286 : dev-lang/gnat-gcc-4.6.4-r1: USE Flag 'multilib' not in IUSE for dev-lang/gnat-gcc-4.6.4
561968 : dev-lang/gnat-gcc-4.5.4 fails to merge in install phase with `USE Flag 'lto' not in IUSE`
586538 : dev-lang/gnat-gcc: old lto wrapper breaks newer gcc (e.g. using -march=native)
596932 : dev-lang/gnat-gcc-4.6.4 - src_install(): /bin/sh: line 3: cd: host-x86_64-pc-linux-gnu/lto-plugin: No such file or director

the fortune algorithm is required in order to emerge dev-lang/gnat-gcc  :-//
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #66 on: November 01, 2016, 06:00:19 am »
ARM TechCon

I see more bootstrappers for PowerPC
(which are also mainly used in avionics)
I believe ARM is less ADA friendly
perhaps less interests in the industry
 

Offline Karel

  • Super Contributor
  • ***
  • Posts: 1401
  • Country: 00
Re: "Stop Teaching C" - Kate Gregory
« Reply #67 on: November 01, 2016, 07:38:08 am »
AFAIK C# is Java which works.

Nope. C# works on windows. Java works everywhere.
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 blueskull

  • Supporter
  • ****
  • Posts: 12479
  • Country: cn
  • Power Electronics Guy
Re: "Stop Teaching C" - Kate Gregory
« Reply #68 on: November 01, 2016, 07:51:34 am »
Nope. C# works on windows. Java works everywhere.

Ubuntu's default music player is written in C#.
 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #69 on: November 01, 2016, 08:30:32 am »
It's deeper than that. Even the official ASP.net framework, official CLR, C# compiler,  visual studio core and recently SQL server work on Linux and MacOS. There's even an LLVM front end that compiles C# to native. All of them are open source apart from SQL Server.
« Last Edit: November 01, 2016, 08:32:15 am by setq »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3077
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #70 on: November 01, 2016, 08:51:31 am »
I've now watched the video.  The title is a bit misleading - it's actually "Stop teaching C as the first step to teaching C++", and I think I mostly agree with the things she says. (particularly WRT skipping the whole "char*" "strings" that C requires.)  I think I disagree with her WRT "use the debugger to look at results" vs learning printf(); printf() may be awful, but not having your results actually print out is ... not satisfying.  (The assembler class did that for the PDP11 portion.  You'd write little programs that ran on a simulator, giving them things to work on by sticking them in memory before you started and looking at your results in memory when they finished.   Yuck.)  (although I also really dislike C++ "<<" streams.)

(It's a shame that strings in the C++ sense are so ... incompatible with deep embedded systems.  And that's a bit strange; they worked OK in BASIC on far less powerful computers, didn't they?   There would be so many fewer problems in the Arduino world if their String types actually worked well.)
 

Offline Brumby

  • Supporter
  • ****
  • Posts: 9409
  • Country: au
Re: "Stop Teaching C" - Kate Gregory
« Reply #71 on: November 01, 2016, 08:59:37 am »
We're getting away from the point of the video....

For beginners on their way to learning C++, getting them to learn C first is going to make it harder to get into C++, as you've already taught them to think the wrong way.

If you want to teach an object-oriented language, then loading them up with archaic and inappropriate techniques is just making their journey harder and absolutely confusing, especially when the tendancy for thinking in object concepts is how they have been naturally processing the world up to this point.

Doing the retrograde learning process makes just as much sense as teaching water engineers how to build aquaducts ... and then tell them to forget about all that as you try to teach them about using pipes.  They're still holding to constrained thinking of open waterways and gravity - instead of the freedom from those constraints and the importance of pressures.

Remember, this is for beginners on their way to C++.

Once you've got there, then - by all means - let them learn more advanced stuff - like the issues involved in developing embedded systems ... and how to use the primitive features of C.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #72 on: November 01, 2016, 09:04:52 am »
We're getting away from the point of the video....

For beginners on their way to learning C++, getting them to learn C first is going to make it harder to get into C++, as you've already taught them to think the wrong way.

If you want to teach an object-oriented language, then loading them up with archaic and inappropriate techniques is just making their journey harder and absolutely confusing, especially when the tendancy for thinking in object concepts is how they have been naturally processing the world up to this point.

Yes, that was the point of the video and I wouldn't quibble with it.

But if your objective is to teach an OOP language without loading them up with archaic and inappropriate techniques, then C++ is completely the wrong endpoint! Use a modern language!
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 JPortici

  • Super Contributor
  • ***
  • Posts: 2560
  • Country: it
Re: "Stop Teaching C" - Kate Gregory
« Reply #73 on: November 01, 2016, 11:22:40 am »
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
i pulled the trigger. i HAVE to learn new languages, i'ts about time and i can't live with visual basic and c only so i went to the local library and took two books on c++. unfortunately those are from 1990 and 1993.
what yuo quotes was the very first chapters.
i guess 20 years of stressing it has not been enough :)?
 

Offline Brumby

  • Supporter
  • ****
  • Posts: 9409
  • Country: au
Re: "Stop Teaching C" - Kate Gregory
« Reply #74 on: November 01, 2016, 11:30:01 am »
We're getting away from the point of the video....

For beginners on their way to learning C++, getting them to learn C first is going to make it harder to get into C++, as you've already taught them to think the wrong way.

If you want to teach an object-oriented language, then loading them up with archaic and inappropriate techniques is just making their journey harder and absolutely confusing, especially when the tendancy for thinking in object concepts is how they have been naturally processing the world up to this point.

Yes, that was the point of the video and I wouldn't quibble with it.

But if your objective is to teach an OOP language without loading them up with archaic and inappropriate techniques, then C++ is completely the wrong endpoint! Use a modern language!

I would agree - but what is the criteria that specifies the endpoint?  If it is an academic exercise to teach OOP, then you may be right (I'm not familiar enough with what's on offer to comment any further).  However, if it is to skill up someone going into a C++ environment, then there's no need to look any further.
 

Offline snarkysparky

  • Regular Contributor
  • *
  • Posts: 174
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #75 on: November 01, 2016, 11:38:12 am »
C++ and Java contribute to global warming with their wasted CPU cycles over what is possible with a clean well written  C program.

Case Closed  :-DD :-DD :-DD
 

Offline John Coloccia

  • Super Contributor
  • ***
  • Posts: 1199
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #76 on: November 01, 2016, 11:42:40 am »
I would agree - but what is the criteria that specifies the endpoint?  If it is an academic exercise to teach OOP, then you may be right (I'm not familiar enough with what's on offer to comment any further).  However, if it is to skill up someone going into a C++ environment, then there's no need to look any further.

I think what guys like me are saying is that the whole point of C++ is that it's an extension to C. Without C, no one would ever in a million years use C++ because it's an absolutely awful OOP style language. On the other hand, if you throw out all of the garbage that comes with C++ and just use the basic OO features combined with standard C programming, C++ now becomes an extremely usable and powerful language.
 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #77 on: November 01, 2016, 11:48:27 am »
C++ and Java contribute to global warming with their wasted CPU cycles over what is possible with a clean well written  C program.

Case Closed  :-DD :-DD :-DD

How about all the farting programmers required to keep the thing from dumping core ;)

Actually I agree. I just used an old piece of C to rip through a 3 million line 4.2Gb text file and find me some text in under the JIT time of a Java program...
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 18028
  • Country: nl
    • NCT Developments
Re: "Stop Teaching C" - Kate Gregory
« Reply #78 on: November 01, 2016, 12:08:28 pm »
(It's a shame that strings in the C++ sense are so ... incompatible with deep embedded systems.  And that's a bit strange; they worked OK in BASIC on far less powerful computers, didn't they?   There would be so many fewer problems in the Arduino world if their String types actually worked well.)
Well.. nothing stops you from creating your own string type.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #79 on: November 01, 2016, 12:10:53 pm »
I think I disagree with her WRT
"use the debugger to look at results"
vs learning printf(); printf() may be awful,
but not having your results actually print out is ...
not satisfying

that's evil and you know why
"use the debugger to look at results"
is the best advice ever!
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #80 on: November 01, 2016, 12:18:09 pm »
in my case string_t is a struct
which includes the length
and the current position

also being a type implies methods
{ compare, assign, append, … }

therefore if (msg isEqualTo "hallo") makes sense
as long as "hallo" + " " + "world"

it consumes +8 bytes
and a few more cycles(1) to fetch out the method

what is the problem about that?


edit:
(1) checked now, +10 cycles
« Last Edit: November 01, 2016, 01:36:43 pm by legacy »
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9211
  • Country: my
  • reassessing directives...
Re: "Stop Teaching C" - Kate Gregory
« Reply #81 on: November 01, 2016, 12:35:17 pm »
(It's a shame that strings in the C++ sense are so ... incompatible with deep embedded systems.  And that's a bit strange; they worked OK in BASIC on far less powerful computers, didn't they?   There would be so many fewer problems in the Arduino world if their String types actually worked well.)
Well.. nothing stops you from creating your own string type.
we dont need a new language. what we need is a unified data type and safe coding style education. but well, everybody like to make their own philosophy...
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #82 on: November 01, 2016, 12:43:27 pm »
Code: [Select]
ev-lang/gnat-gcc-4.6.4/image//usr
mkdir -p -- /var/tmp/portage/dev-lang/gnat-gcc-4.6.4/image//usr /var/tmp/portage/dev-lang/gnat-gcc-4.6.4/image//usr
/bin/sh: line 3: cd: host-i686-pc-linux-gnu/fixincludes: No such file or directory
Makefile:4750: recipe for target 'install-fixincludes' failed
make[1]: *** [install-fixincludes] Error 1
make[1]: Leaving directory '/var/tmp/portage/dev-lang/gnat-gcc-4.6.4/work/gcc-4.6.4'
Makefile:2689: recipe for target 'install' failed
make: *** [install] Error 2
 * ERROR: dev-lang/gnat-gcc-4.6.4::gentoo failed (install phase):
 *   emake failed
 *

may Saint Kate Gregory help me :palm: :palm: :palm: :palm:
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #83 on: November 01, 2016, 12:46:16 pm »
(It's a shame that strings in the C++ sense are so ... incompatible with deep embedded systems.  And that's a bit strange; they worked OK in BASIC on far less powerful computers, didn't they?   There would be so many fewer problems in the Arduino world if their String types actually worked well.)
Well.. nothing stops you from creating your own string type.

That's the problem: many people have done just that, badly and incompatibly.

The same is true for anything to do with time and dates.
« Last Edit: November 01, 2016, 12:53:14 pm by tggzzz »
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 tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #84 on: November 01, 2016, 12:52:15 pm »
We're getting away from the point of the video....

For beginners on their way to learning C++, getting them to learn C first is going to make it harder to get into C++, as you've already taught them to think the wrong way.

If you want to teach an object-oriented language, then loading them up with archaic and inappropriate techniques is just making their journey harder and absolutely confusing, especially when the tendancy for thinking in object concepts is how they have been naturally processing the world up to this point.

Yes, that was the point of the video and I wouldn't quibble with it.

But if your objective is to teach an OOP language without loading them up with archaic and inappropriate techniques, then C++ is completely the wrong endpoint! Use a modern language!

I would agree - but what is the criteria that specifies the endpoint?  If it is an academic exercise to teach OOP, then you may be right (I'm not familiar enough with what's on offer to comment any further).

I've been using C since 1981, Smalltalk since 1986, C++ since 1988, Objective-C since 1988, and Java since 1996. Plus quite a few other domain-specific languages :) The more radically different languages you know, the less likely you are to try to insert a screw with a hammer.

Quote
However, if it is to skill up someone going into a C++ environment, then there's no need to look any further.

Skilling someone up sufficiently that they can be safe and productive in C++ requires much more than a short course. Hells teeth, there's ample evidence even the "designers" don't fully understand their creation!
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: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #85 on: November 01, 2016, 01:00:49 pm »
there's ample evidence even the "designers"
don't fully understand their creation!

and ... the explanation given by their project manager is
because they haven't  (properly) used AADL, ain't it ?  :-DD
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #86 on: November 01, 2016, 01:04:53 pm »
p.s.
just for my curiosity, do you/your team use Stood for your own designs?
if yes, is it really helpful?
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #87 on: November 01, 2016, 02:37:38 pm »
Kate Gregory's Blog looks very interesting  :-+
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #88 on: November 01, 2016, 03:05:49 pm »
Kate says Yes on Lambdas in C++
and she promotes the use,
but I haven't yet understood if
I really like this C++11 feature  :-//
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7242
  • Country: us
    • SiliconValleyGarage
Re: "Stop Teaching C" - Kate Gregory
« Reply #89 on: November 01, 2016, 03:09:59 pm »
based on a lexer and parser that is so stupid
it needs semicolons to figure out where a line ends

I don't agree, the problem is not the semicolon at the end of the line
the problem is the C grammar itself which allows silly constructs
it goes deeper than that.

have you ever wondered why there is a need for .h files ?

The c compiler had to run on a machine with very little memory. this was a shared user machine and as students they were only allocated a small amount of resources....
They designed the compiler as single pass. simply because anything else didn't fit and was too complex. Same goes for that stack/heap construct.
all the c compilers compile for this 'virutal model and then shoehorn the output on the target architecture. this is not optimal. memory is not laid out that way on all machines.

Take a look at header files. In 2016 that is the most stupid thing ever (when the language was create it was not !). As a human ,i have to declare the functions in the header file ,and then write the same construct once again in the real code section. Why do i need to forward declare functions ? i don;t know what the final format of those functions will be ! i have not designed them yet ! and i need to fix stuff in different files every time i make a modification to the function i/o.

Why can't the compiler just go over the source code once, collect all the functions , and then start compiling ? There is not even a need for  includes. simply go look in other files in the directory and see if you can find it there first. descend into subdirectories automatically. if files reside on a central server then you can point to them if needed.

The reason is historical . disk i/o was non exisitent ( the machine had TAPE for crying out loud... so you could not just randomly access files... ) and multipass meant eating lots of ram at compile time.. ram the machine did not have !

so we are stuck anno 2016 with a language and compilation method that was built for a long dead architecture with very limited resources.

C should evolve. Any language should evolve. compilers must be made multipass. I want to do away with all the overhead as a human. the less keyboard pounding i need to do the better. any character i type is a potential source of mistake. (speelling erroooors )

Now people will pitch in : use a good code editor with autocompletion blablabla.. that is not solving the problem, it is just a workaround ...
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #90 on: November 01, 2016, 03:29:38 pm »
.h files have a purpose past that. You stick your contract with the library or program in it. Then you implement it inside the .c.

Private/internal stuff just has to be higher up the .c file. I do believe this is modular programming or whatever it was called.
« Last Edit: November 01, 2016, 03:31:34 pm by setq »
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #91 on: November 01, 2016, 03:34:16 pm »
Take a look at header files. In 2016 that is the most stupid thing ever

they are useful to describe interfaces
in ada and pascal you have to do something similar
due to the separation before interface and implementation

modular design
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 1794
  • Country: fi
  • Embedded SW/HW.
Re: "Stop Teaching C" - Kate Gregory
« Reply #92 on: November 01, 2016, 03:34:36 pm »
In addition to providing the interface, the .h files make it possible to provide the libraries of the functions without providing the actual source code.
 

Offline John Coloccia

  • Super Contributor
  • ***
  • Posts: 1199
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #93 on: November 01, 2016, 03:36:21 pm »
Kate says Yes on Lambdas in C++
and she promotes the use,
but I haven't yet understood if
I really like this C++11 feature  :-//

Like everything else in C++, if you use it right it's convenient and powerful. Sometimes you have to generate a value, and it's more complex than a simple expression but you don't want to clutter up your code with generating it where it's just going to be used once and passed into a function. Here, the lambda function is useful. It's like a block of statements that returns a value.

It's also convenient to be able to pass a code snippet as data. So you can do things like give a function this snippet of code and say, "here, run this on all of your elements." Sure, you can do it other ways, but this particular way is very convenient and flexible.

Lambdas have been around for a LONG time. They just happen to be new to C++. I suspect that some C++ programmers out there have already figured out ways to abuse the hell out of Lambdas, but I think they're generally good things to have around.
« Last Edit: November 01, 2016, 03:41:05 pm by John Coloccia »
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7242
  • Country: us
    • SiliconValleyGarage
Re: "Stop Teaching C" - Kate Gregory
« Reply #94 on: November 01, 2016, 03:51:14 pm »
In addition to providing the interface, the .h files make it possible to provide the libraries of the functions without providing the actual source code.
and why is that needed ?

if the compiler traverses all files in a directory ti will find the libraries. whether those exist as .c files or as .obj . doesn't matter.

my claim is : there is no need for includes and .h files. all the compiler has to do is look in the directory where the project is stored (and its subdirectories) and see if it can find the function, either in source or object. if it can't find it there : stop compilation.
you would only need an include statement if some stuff resides outside the project directory. then you can point to it. (now people will com up with the excuse : so a function deep in a subdirectory would still need to declare outside . no it wouldn't as compilation does not start at the low level. it starts with the main file which resides at the highest level. the compiler traverses the entire directory tree from the root point of compilation.

all headers and includes would become obsolete. no more misery with function prototypes that mismatch the actual functions. no more cleaning up missing dots and semicolons and other keyboarding mistakes that prevent the program from compiling. i want to focus on developing the actual code as opposed to fixing typing mistakes.

same goes for the stupidity with typecasting. on some compilers an in is 8 bit , on other it is 16 bit , ... why on earth does that have to change ? remember the ariane rocket that blew up ? that was because the real hardware had an int as 16 bit while on the emulator it was treated as 32 bit.... the same code overflowed in the rocket ... because the idiots who build compilers think it is ok to have different definitions for the same type....

The c language has many constructs and limitations that stem from the resource cramped machine it was developed on.  think about this whole stream.io thing. data is only a stream ... if it comes from an ff-ing tape ! who uses tape these days ?

It should evolve. ( and im not talking c++ c# evolution , those are supersets to create object oriented stuff.  i'm talking compiler intelligence and eliminating stuff that does not make sense anymore on modern machines.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline John Coloccia

  • Super Contributor
  • ***
  • Posts: 1199
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #95 on: November 01, 2016, 04:01:34 pm »
As I mentioned previously C and C++ are very difficult to parse reliably. I think the .h files (or more generally forward declarations) makes the compiler's job a lot easier.
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #96 on: November 01, 2016, 04:04:09 pm »
if the compiler traverses all files in a directory
it will find the libraries. whether those exist
as .c files or as .obj . doesn't matter

yes, in the theory
but it's problem when you don't provide sources

imagine you have a library with a lot of .obj
you need their public interfaces

and here we go: you need them


for my own made compiler, I am also using them
to automatically build the dependency tree

I have removed the "#include" meta statement
instead I am using "use yyyy.dep.*;"

which includes the output from the dependencies tree

yyyy is the filename of the module

e.g. lib_stdio_v1 -> lib_stdio_v1.{ body, interface, dep }

body: implementation
interface: prototypes, types, global shared variables, alias (constant)
dep: dependencies with other modules

 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #97 on: November 01, 2016, 04:12:53 pm »
Code: [Select]
ls /idp.do/mysrc/lib/

Code: [Select]
lib_basen2_v3.h
lib_basen2_v3.interface
lib_basen2_v3.o
lib_bit_set_v1.h
lib_bit_set_v1.interface
lib_bit_set_v1.o
lib_bitmap_v2.h
lib_bitmap_v2.interface
lib_bitmap_v2.o
lib_bitmap_v3.h
lib_bitmap_v3.interface
lib_bitmap_v3.o
lib_cal_stamp.h
lib_cal_stamp.interface
lib_cal_stamp.o
lib_debug_v1.h
lib_debug_v1.interface
lib_debug_v1.o
lib_endian.h
lib_endian.interface
lib_endian.o
lib_env_collector_mini_v1.h
lib_env_collector_mini_v1.interface
lib_env_collector_mini_v1.o
lib_env_disk_io_v1.h
lib_env_disk_io_v1.interface
lib_env_disk_io_v1.o
lib_env_pool_label_v1.h
lib_env_pool_label_v1.interface
lib_env_pool_label_v1.o
lib_env_pool_string_v1.h
lib_env_pool_string_v1.interface
lib_env_pool_string_v1.o
lib_env_shell_cmd_v1.h
lib_env_shell_cmd_v1.interface
lib_env_shell_cmd_v1.o
lib_env_toy_v1.h
lib_env_toy_v1.interface
lib_env_toy_v1.o
lib_env_wrapper_v1.h
lib_env_wrapper_v1.interface
lib_env_wrapper_v1.o
lib_fileIO_unix_v1.h
lib_fileIO_unix_v1.interface
lib_fileIO_unix_v1.o
lib_file_utils.h
lib_file_utils.interface
lib_file_utils.o
lib_file_utils_v2.h
lib_file_utils_v2.interface
lib_file_utils_v2.o
lib_filename_filter_v0.3.h
lib_filename_filter_v0.3.interface
lib_filename_filter_v0.3.o
lib_filename_utils_v8.h
lib_filename_utils_v8.interface
lib_filename_utils_v8.o
lib_fs_folder_level.h
lib_fs_folder_level.interface
lib_fs_folder_level.o
lib_fs_folder_level_v2.h
lib_fs_folder_level_v2.interface
lib_fs_folder_level_v2.o
lib_lexer_reserved_word_language_l1_show_v7b.h
lib_lexer_reserved_word_language_l1_show_v7b.interface
lib_lexer_reserved_word_language_l1_show_v7b.o
lib_lexer_reserved_word_language_l1_v7b.h
lib_lexer_reserved_word_language_l1_v7b.interface
lib_lexer_reserved_word_language_l1_v7b.o
lib_lexer_reserved_word_v7b.h
lib_lexer_reserved_word_v7b.interface
lib_lexer_reserved_word_v7b.o
lib_lexer_tokenize_v7b.h
lib_lexer_tokenize_v7b.interface
lib_lexer_tokenize_v7b.o
lib_lexer_v7b.h
lib_lexer_v7b.interface
lib_lexer_v7b.o
lib_linea_v2.h
lib_linea_v2.interface
lib_linea_v2.o
lib_list_handler_v1.h
lib_list_handler_v1.interface
lib_list_handler_v1.o
lib_mystring_v0.7.h
lib_mystring_v0.7.interface
lib_mystring_v0.7.o
lib_mystring_v2.h
lib_mystring_v2.interface
lib_mystring_v2.o
lib_net_udp_ip_v1.h
lib_net_udp_ip_v1.interface
lib_net_udp_ip_v1.o
lib_pico_shell_slush_addon_v4.h
lib_pico_shell_slush_addon_v4.interface
lib_pico_shell_slush_addon_v4.o
lib_pico_shell_slush_v4.h
lib_pico_shell_slush_v4.interface
lib_pico_shell_slush_v4.o
lib_pico_shell_toy_v4.h
lib_pico_shell_toy_v4.interface
lib_pico_shell_toy_v4.o
lib_progress_bar.h
lib_progress_bar.interface
lib_progress_bar.o
lib_queue_gp_v3.h
lib_queue_gp_v3.interface
lib_queue_gp_v3.o
lib_safestring_v2.h
lib_safestring_v2.interface
lib_safestring_v2.o
lib_serial2.o
lib_serial_unix_v3.h
lib_serial_unix_v3.interface
lib_serial_unix_v3.o
lib_serial_unix_v4.h
lib_serial_unix_v4.interface
lib_serial_unix_v4.o
lib_string_fuzzy_match_v1.h
lib_string_fuzzy_match_v1.interface
lib_string_fuzzy_match_v1.o
lib_tokener_fast_v8.h
lib_tokener_fast_v8.interface
lib_tokener_fast_v8.o
lib_tokener_fast_v8b.h
lib_tokener_fast_v8b.interface
lib_tokener_fast_v8b.o
lib_tokener_fussy_v8.h
lib_tokener_fussy_v8.interface
lib_tokener_fussy_v8.o
lib_tokener_language_show_v1.h
lib_tokener_language_show_v1.interface
lib_tokener_language_show_v1.o
lib_tokener_language_v1.h
lib_tokener_language_v1.interface
lib_tokener_language_v1.o
lib_tokener_v8.h
lib_tokener_v8.interface
lib_tokener_v8.o
lib_uart_unix_v5.h
lib_uart_unix_v5.interface
lib_uart_unix_v5.o
lib_udpip.h
lib_udpip.interface
lib_udpip.o
lib_unix_termio_kb_v2.h
lib_unix_termio_kb_v2.interface
lib_unix_termio_kb_v2.o
lib_unix_termio_kb_v4.h
lib_unix_termio_kb_v4.interface
lib_unix_termio_kb_v4.o
types.h

dependencies are automatically built using { .h, .interface }
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9211
  • Country: my
  • reassessing directives...
Re: "Stop Teaching C" - Kate Gregory
« Reply #98 on: November 01, 2016, 04:23:01 pm »
my claim is : there is no need for includes and .h files. all the compiler has to do is look in the directory where the project is stored (and its subdirectories) and see if it can find the function, either in source or object.
how do you suggest a wise thing to practice encapsulation or intellectual anonymousity of functions in a library/object/module? above all, how do you suggest another language that solves this problem but... maintain capabilities and freedom experiences to users similar to C/C++?

if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #99 on: November 01, 2016, 04:24:05 pm »
who uses tape these days ?

bad example, dude, I use tapes  :D

LTO-2-6 Ultrium technology
DLD-1-4 technology

both available for SCSI (obsolete) and SAS(modern)
usually for Unix big-iron servers and workstations

basically you are talking about DAT@SCSI.narrow.SE
and their predecessors, but I get your point
and I agree :D
 

Offline AG6QR

  • Frequent Contributor
  • **
  • Posts: 812
  • Country: us
    • AG6QR Blog
Re: "Stop Teaching C" - Kate Gregory
« Reply #100 on: November 01, 2016, 04:24:50 pm »
In addition to providing the interface, the .h files make it possible to provide the libraries of the functions without providing the actual source code.
and why is that needed ?

if the compiler traverses all files in a directory ti will find the libraries. whether those exist as .c files or as .obj . doesn't matter.

In large projects, developed by large, distributed teams, there's often a need to control the distribution of function signatures.  I worked on a commercial product which included libraries distributed to customers.  It was divided into a number of components.  We had four levels of function distributions:

  • Public -- documented to our customers and available for them to call
  • Intracomponent -- sort of "internally public", meaning different components that we developed in our company could share Intracomponent functions, and they were somewhat documented internally among ourselves, but we didn't allow customers to call them.
  • Within a single component -- shared inside a single component only
  • Within a single source file

Why the need for the different levels of publishing and sharing functions?  It's a form of encapsulation.  By limiting the distribution of a component's internal functions, those internals could be freely changed as the software evolved, without having to worry that someone had already written software that relied on a particular function signature that, in retrospect, wasn't a good one.  It meant we could freely and safely put hidden internal things into functions without worrying that some customer would write software that called those functions.

We implemented this by having different header files in different directories, and sharing those directories appropriately.  Not all projects would need this particular set of levels of sharing, but the header file concept makes it easy to implement whatever level of sharing is appropriate for your project.


I do agree that, in general, it's bad to have something expressed twice when it can be expressed once.  Header files express a function's signature twice, once in the header file and once in the function definition.  Having the function signatures expressed only one place would be preferable.  But header files can express another thing about the function: They can express how widely you intend to share the function.  If you do away with header files, you would need to provide another mechanism to express this.
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #101 on: November 01, 2016, 04:38:36 pm »
I do agree that, in general
it's bad to have something expressed twice
when it can be expressed once. 
Header files express a function's signature twice,
once in the header file and once in the function definition. 

mmm, in my case you write the body
and the compiler will automatically build the interface

therefore you write boolean_t is_foo() { ... }
and it will fill  "boolean_t is_foo()" in the module.interface
which is included in module.h

it's saving a lot of troubles here, and it's damn productive
the downside of this approac is that if change the interface
e.g.   boolean_t is_foo( uint32_t magic ) you are breaking
the compatibility of your library, therefore I have implemented
a mechanism which refuses to accept the new commit
until you have turned it into a branch and changed the
module name or - at least - increased the revision

it's not a definitive solution, but it works  :-+
 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #102 on: November 01, 2016, 04:49:17 pm »
Have some more C++ buggery now I have a few minutes. Firstly, we'll compile a couple of hello worlds:

First the C version

Code: [Select]
#include <stdio.h>

void say_hello(char *to_whom) {
        printf("Hello %s", to_whom);
}

Now the C++ version

Code: [Select]
#include <iostream>

using namespace std;

void say_hello(string to_whom) {
        cout << "Hello " << to_whom << endl;
}

Compile them quickly into object files only...

Code: [Select]
[setq@shodan ~]$ g++ -c hellocpp.cpp
[setq@shodan ~]$ gcc -c hello.c

Now let's look at the symbol table in the ELF file generated by the C program:

Code: [Select]
[setq@shodan ~]$ readelf -s hello.o
Symbol table '.symtab' contains 11 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS hello.c
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    1
     3: 0000000000000000     0 SECTION LOCAL  DEFAULT    3
     4: 0000000000000000     0 SECTION LOCAL  DEFAULT    4
     5: 0000000000000000     0 SECTION LOCAL  DEFAULT    5
     6: 0000000000000000     0 SECTION LOCAL  DEFAULT    7
     7: 0000000000000000     0 SECTION LOCAL  DEFAULT    8
     8: 0000000000000000     0 SECTION LOCAL  DEFAULT    6
     9: 0000000000000000    36 FUNC    GLOBAL DEFAULT    1 say_hello
    10: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND printf


Yep that made sense. There's a FUNC in there called say_hello and it calls out to printf. Easy money.

Now for C++

Code: [Select]
[setq@shodan ~]$ readelf -s hellocpp.o
Symbol table '.symtab' contains 23 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS hellocpp.cpp
     2: 0000000000000000     0 SECTION LOCAL  DEFAULT    1
     3: 0000000000000000     0 SECTION LOCAL  DEFAULT    3
     4: 0000000000000000     0 SECTION LOCAL  DEFAULT    4
     5: 0000000000000000     1 OBJECT  LOCAL  DEFAULT    4 _ZStL8__ioinit
     6: 0000000000000000     0 SECTION LOCAL  DEFAULT    5
     7: 0000000000000039    61 FUNC    LOCAL  DEFAULT    1 _Z41__static_initializati
     8: 0000000000000076    21 FUNC    LOCAL  DEFAULT    1 _GLOBAL__sub_I__Z9say_hel
     9: 0000000000000000     0 SECTION LOCAL  DEFAULT    6
    10: 0000000000000000     0 SECTION LOCAL  DEFAULT    9
    11: 0000000000000000     0 SECTION LOCAL  DEFAULT   10
    12: 0000000000000000     0 SECTION LOCAL  DEFAULT    8
    13: 0000000000000000    57 FUNC    GLOBAL DEFAULT    1 _Z9say_helloSs
    14: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZSt4cout
    15: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZStlsISt11char_traitsIcE
    16: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZStlsIcSt11char_traitsIc
    17: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZSt4endlIcSt11char_trait
    18: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZNSolsEPFRSoS_E
    19: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZNSt8ios_base4InitC1Ev
    20: 0000000000000000     0 NOTYPE  GLOBAL HIDDEN   UND __dso_handle
    21: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZNSt8ios_base4InitD1Ev
    22: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __cxa_atexit

Wow that was a really clean abstraction. Not! Looks like Perl laid a turd in the middle of the symbol table. And all the other shit it has to bring in just to talk to a stream. And that's the tangle that C++ leaves you in all the time. Ugh kill me.

I'm off to go and write some PIC16 assembly now - that stuff is eye bleach programming bliss.
« Last Edit: November 01, 2016, 04:53:05 pm by setq »
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #103 on: November 01, 2016, 04:55:08 pm »
assembly now

it happens because in C++ you have
string_t, which is not just an array with '\0' at the end
it's true type, a struct, which implies methods, e.g. "<<"

a part of the machine code needs to be taken
to fetch out these details e.g. invoking the method
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7242
  • Country: us
    • SiliconValleyGarage
Re: "Stop Teaching C" - Kate Gregory
« Reply #104 on: November 01, 2016, 05:04:40 pm »
who uses tape these days ?

bad example, dude, I use tapes  :D


but not as primary random access storage ! that would be fun compiling a project. waiting for the tape robot to find the tape where the file is stored , load it, fast forward / rewind to where it sits, read it , save the obj to another tape... people are now already complaining if a compile takes 5 seconds or longer ....

Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #105 on: November 01, 2016, 05:07:33 pm »
assembly now

it happens because in C++ you have
string_t, which is not just an array with '\0' at the end
it's true type, a struct, which implies methods, e.g. "<<"

a part of the machine code needs to be taken
to fetch out these details e.g. invoking the method

I know why. It just feels like ceremonial on the lines of:

 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7242
  • Country: us
    • SiliconValleyGarage
Re: "Stop Teaching C" - Kate Gregory
« Reply #106 on: November 01, 2016, 05:15:55 pm »
As I mentioned previously C and C++ are very difficult to parse reliably. I think the .h files (or more generally forward declarations) makes the compiler's job a lot easier.
multipass compilation solves parsing problem.

pass 1 : go over source file and collect functions and subroutines. build a map in memory of their definition (what goes in and out) and attach the source or object. once all the files are loaded in ram then all source and object is loaded as well. at this point all routines available are known and also all routines that are being called are known. if a callee is missing : stop compilation as something is missing. if something is not called : remove it as it is unused and not necessary for the program. (this results in automatically stripping superfluous functions from libraries.)

pass 2 : compile all standalone functions ( functions that do not call others ) into machine language. create a callable and in-line variant for each.
pass 3 : compile functions that call others. direct calls become in-line. nested calls become true calls.
repeat pass 3 until top level of hierarchy is reached.
pass 4 : map final memory allocation for all function and assign hard addresses. (essentially linking)
pass5 : spit out binary.

pl/m compilers back in 1972 already could do that. it's 2016. don't you think it is time C started doing that too ?
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 2560
  • Country: it
Re: "Stop Teaching C" - Kate Gregory
« Reply #107 on: November 01, 2016, 05:33:09 pm »
same goes for the stupidity with typecasting. on some compilers an in is 8 bit , on other it is 16 bit , ... why on earth does that have to change ? remember the ariane rocket that blew up ? that was because the real hardware had an int as 16 bit while on the emulator it was treated as 32 bit.... the same code overflowed in the rocket ... because the idiots who build compilers think it is ok to have different definitions for the same type....
while i agree, fixed lenght types do exist (int8_t, uint32_t etc.)
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 1794
  • Country: fi
  • Embedded SW/HW.
Re: "Stop Teaching C" - Kate Gregory
« Reply #108 on: November 01, 2016, 05:39:17 pm »
In addition to providing the interface, the .h files make it possible to provide the libraries of the functions without providing the actual source code.
and why is that needed ?

if the compiler traverses all files in a directory ti will find the libraries. whether those exist as .c files or as .obj . doesn't matter.

my claim is : there is no need for includes and .h files. all the compiler has to do is look in the directory where the project is stored (and its subdirectories) and see if it can find the function, either in source or object. if it can't find it there : stop compilation.

How about the constants, type definitions, data structures etc. There is a lot more than just functions in programming.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 18028
  • Country: nl
    • NCT Developments
Re: "Stop Teaching C" - Kate Gregory
« Reply #109 on: November 01, 2016, 05:51:52 pm »
As I mentioned previously C and C++ are very difficult to parse reliably. I think the .h files (or more generally forward declarations) makes the compiler's job a lot easier.
multipass compilation solves parsing problem.

pass 1 : go over source file and collect functions and subroutines. build a map in memory of their definition (what goes in and out) and attach the source or object. once all the files are loaded in ram then all source and object is loaded as well. at this point all routines available are known and also all routines that are being called are known. if a callee is missing : stop compilation as something is missing. if something is not called : remove it as it is unused and not necessary for the program. (this results in automatically stripping superfluous functions from libraries.)

pl/m compilers back in 1972 already could do that. it's 2016. don't you think it is time C started doing that too ?
GCC can do that just fine for many years BUT you have to be carefull with interrupt routines which aren't called from anywhere else.
Besides that there is much more to compiling C than you seem to be aware of. The first step is collecting all the header files and evaluating the pre-processor macros by the pre-processor and put everything in one file with pure C code which is then compiled by the compiler into an object file. Compiling a C program consists of: pre-processing, compiling and linking. The pre-processing stages makes it easy to re-use code by using constants defined in one place and/or include/exclude parts of code depending on variables (which can be supplied on the command line).
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #110 on: November 01, 2016, 06:08:51 pm »
you have to be carefull with interrupt routines
which aren't called from anywhere else

in the theory the body of an isr should be at least loaded
therefore their names should compare inside an initializer

e.g.
Code: [Select]
void isr_init()
{
  ..
  isr_set(isr_machine_exception, 0x00000100);
  ..
}

it's not the only way to handle isr, I find it useful
 

Offline John Coloccia

  • Super Contributor
  • ***
  • Posts: 1199
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #111 on: November 01, 2016, 07:01:20 pm »
As I mentioned previously C and C++ are very difficult to parse reliably. I think the .h files (or more generally forward declarations) makes the compiler's job a lot easier.
multipass compilation solves parsing problem.

pass 1 : go over source file and collect functions and subroutines. build a map in memory of their definition (what goes in and out) and attach the source or object. once all the files are loaded in ram then all source and object is loaded as well. at this point all routines available are known and also all routines that are being called are known. if a callee is missing : stop compilation as something is missing. if something is not called : remove it as it is unused and not necessary for the program. (this results in automatically stripping superfluous functions from libraries.)

pass 2 : compile all standalone functions ( functions that do not call others ) into machine language. create a callable and in-line variant for each.
pass 3 : compile functions that call others. direct calls become in-line. nested calls become true calls.
repeat pass 3 until top level of hierarchy is reached.
pass 4 : map final memory allocation for all function and assign hard addresses. (essentially linking)
pass5 : spit out binary.

pl/m compilers back in 1972 already could do that. it's 2016. don't you think it is time C started doing that too ?

I'm not sure you're thinking this through clearly. Consider something like this:

a * b;

To do what you suggest would require looking through every tiny little bit of code to see just what the heck "a" is. Do you intend to multiply a*b, or are you declaring a pointer to something of type a? That's just one example.

I could keep going on this, but there's a reason C is the way it is, and why it hasn't really changed. More modern languages don't have ambiguities like this, or at least they're limited and easily addressed, so the compiler doesn't run into a brick wall. C is just not well suited for this sort of thing.
 

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 616
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: "Stop Teaching C" - Kate Gregory
« Reply #112 on: November 01, 2016, 10:18:21 pm »
my claim is : there is no need for includes and .h files.
Correct. Just put everything in a single source file - makes the compiler's job a lot easier!  ;)
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9211
  • Country: my
  • reassessing directives...
Re: "Stop Teaching C" - Kate Gregory
« Reply #113 on: November 01, 2016, 10:50:25 pm »
same goes for the stupidity with typecasting. on some compilers an in is 8 bit , on other it is 16 bit , ... why on earth does that have to change ? remember the ariane rocket that blew up ? that was because the real hardware had an int as 16 bit while on the emulator it was treated as 32 bit.... the same code overflowed in the rocket ... because the idiots who build compilers think it is ok to have different definitions for the same type....
while i agree, fixed lenght types do exist (int8_t, uint32_t etc.)
the rocket programmer was not aware of that, so the compiler programmer is to be blamed.
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Offline John Coloccia

  • Super Contributor
  • ***
  • Posts: 1199
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #114 on: November 01, 2016, 11:22:59 pm »
Believe it or not, it's for machine independence. Blame the idiot programming team that depends on running the code in simulation to check for overflows and things like that. It's a failure in specification and could happen regardless of language.
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 18028
  • Country: nl
    • NCT Developments
Re: "Stop Teaching C" - Kate Gregory
« Reply #115 on: November 01, 2016, 11:34:19 pm »
same goes for the stupidity with typecasting. on some compilers an in is 8 bit , on other it is 16 bit , ... why on earth does that have to change ? remember the ariane rocket that blew up ? that was because the real hardware had an int as 16 bit while on the emulator it was treated as 32 bit.... the same code overflowed in the rocket ... because the idiots who build compilers think it is ok to have different definitions for the same type....
while i agree, fixed lenght types do exist (int8_t, uint32_t etc.)
IMHO you should always use the fixed length types (inttypes.h) and not the typical C types (char, int, long, etc) because they are defined poorly. Also check the range of floating point types to make sure you don't run into trouble. See http://stackoverflow.com/questions/752309/ensuring-c-doubles-are-64-bits
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3077
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #116 on: November 02, 2016, 02:06:55 am »
Quote
remember the ariane rocket that blew up ? that was because the real hardware had an int as 16 bit while on the emulator it was treated as 32 bitthat was Ada.   "AdaTran", actually - badly converted Fortran.
https://vimeo.com/44792649#t=530s
Language used sounds like it was one of the least of their problems :-(
(Though I like the comment "If it had been written in C, it wouldn't have blown up.")
« Last Edit: November 02, 2016, 02:26:54 am by westfw »
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #117 on: November 02, 2016, 07:49:51 am »
my claim is : there is no need for includes and .h files.
Correct. Just put everything in a single source file
- makes the compiler's job a lot easier!  ;)

sarcasm?  :-DD
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #118 on: November 02, 2016, 07:58:56 am »
they are defined poorly

yep, a mess

e.g.
m68k (CISC)
a long is 32bit
a short is 16bit
a char is 8bit(2)
a word is 16bit
there is no half
a long long is 64bit

MIPS (RISC)
a long is 32bit
a short is 16bit(1)
a char is 8bit(2)
a word is 32bit <------
there is also half (word), which is 16bit
a long long is 64bit <-----


(1) but sometimes with PowerPC (RISC) is 32bit
I have seen sizeof(short)=2byte, sometimes =4byte
WTF  :wtf: :wtf: :wtf:


(2) some DSP by TI says that char is 16bit  :-// :-// :-//
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #119 on: November 02, 2016, 08:07:57 am »
word and half are not *C terms*
they come from CPU manuals
like a contribute to the confusion  :palm:

I believe "word" was 16bit with 68K
(which is a true 32bit machine)
because the 68000 bus was 16bit
while the R2000 bus was 32bit

therefore half (word) makes sense for MIPS

the problem is: the C language should not stay
so close to the hardware, especially if it aims
for being a portable language

it's just an example, it shows the wrong attitude
 

Online hamster_nz

  • Super Contributor
  • ***
  • Posts: 2137
  • Country: nz
Re: "Stop Teaching C" - Kate Gregory
« Reply #120 on: November 02, 2016, 08:20:00 am »
word and half are not *C terms*
they come from CPU manuals
like a contribute to the confusion  :palm:

I believe "word" was 16bit with 68K
(which is a true 32bit machine)
because the 68000 bus was 16bit
while the R2000 bus was 32bit

therefore half (word) makes sense for MIPS

the problem is: the C language should not stay
so close to the hardware, especially if it aims
for being a portable language

it's just an example, it shows the wrong attitude

It shows that the language doesn't fit your problem you are using it for.

It doesn't really show that the language has the wrong attitude...

Take for example early PC development, with 'near pointers' and 'far pointers' and 'huge pointers'. Much to C's credit it could actually be made to work with such painful system with only a few extra key words.

The problem isn't that the language wasn't portable, it is that the programmer was unaware of the assumptions they are working under.

 I am currently working on something to process audio files. It would be really easy for me to write a program that reads a WAV file on my PC, but fails on other h/w due to endian mismatch.

Do I say "Stupid language", or "Stupid hardware designer", or "Stupid me"?

I say "stupid me" - I should be doing it in something like MatLab anyway, but hey, I know C, I am lazy, and the problem looks like a nail to me. :)
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3077
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #121 on: November 02, 2016, 08:21:28 am »
Quote
m68k (CISC)
a long is 32bit
a short is 16bit
  :

x86 (CISC):
depends on compiler settings.  (actually, I'm pretty sure that's true of MIPS64 as well.  Probably ARM64 too; it's at least a gcc thing.)
I think you get your choice of "longs and ptrs are 32 bits", "longs are still 32bits bit pointers are 64", "longs are 64bits but pointers are still 32bits", and "longs and ptrs are both 64bits."
It's a bit shocking how much code breaks when sizeof (long*) != sizeof(long)...
« Last Edit: November 02, 2016, 08:23:22 am by westfw »
 

Offline John Coloccia

  • Super Contributor
  • ***
  • Posts: 1199
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #122 on: November 02, 2016, 08:28:02 am »
they are defined poorly

yep, a mess

e.g.
m68k (CISC)
a long is 32bit
a short is 16bit
a char is 8bit(2)
a word is 16bit
there is no half
a long long is 64bit

MIPS (RISC)
a long is 32bit
a short is 16bit(1)
a char is 8bit(2)
a word is 32bit <------
there is also half (word), which is 16bit
a long long is 64bit <-----


(1) but sometimes with PowerPC (RISC) is 32bit
I have seen sizeof(short)=2byte, sometimes =4byte
WTF  :wtf: :wtf: :wtf:


(2) some DSP by TI says that char is 16bit  :-// :-// :-//

The basic way it works is:

- int is USUALLY the word size of the machine, thought that's generally no longer true on 64 bit systems
- char is the smallest addressable unit, which is normally 8 bits, but there are a number of processors (usually DSPs) where it's larger. It's always 8 bits or more regardless, though

Beyond that, the types are defined like this:

- each type must hold some MINIMUM value. For example, a char must be able to hold at least +/-127
- each type must not be smaller than the one that came before. So for example, just looking at the minimums, it's conceivable that a short be 64 bits and an int 32 bits, but that's not allowed.

So anyhow, if it's not enough to know the minimums, then you need to use fixed width types. I agree...it's a mess.
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 1794
  • Country: fi
  • Embedded SW/HW.
Re: "Stop Teaching C" - Kate Gregory
« Reply #123 on: November 02, 2016, 08:33:15 am »
In C  the sizeof(char) == 1, but the char may be 8, 16, 24 bits or something else depending of the architecture. For example, in some DSPs a char is 16 bits or even 24 bits.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #124 on: November 02, 2016, 08:40:51 am »
It shows that the language doesn't fit your problem you are using it for.

That's a valid observation, but it raises two important questions:
  • why do people (plural) use the "wrong" language for the problem
  • what is the domain for which there are no better languages
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: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #125 on: November 02, 2016, 10:03:53 am »
I'm pretty sure that's true of MIPS64 as well

yes, I confirm it, it's a big mess with MIPS64

I have recently bought a few cpu modules for my Malta board

although "CoreLV-5KC" sounds like the cpu used by SGI in their Indy-station
"5K" doesn't mean "R5000"

"4KC" means MIPS32r2, "5KC" means MIPS64
the first one is a true 32bit machine, the second one is a true 64bit machine
but it also comes with 32bit legacy mode

confused? well … looking at the cpu user manual you will have a shock
especially if you compare what you read with the Core20K's UM

Core20K is "5kc", but … it has different definitions in its AN

so, what the frog is 64bit? it's not clear when they talk about
pointer, and data, sometime p_uint64_t is NOT a 64bit pointer
(especially in legacy 32bit mode) so, why they call it _64_t ?
not clear at all  :palm: :palm: :palm:

It's a bit shocking how much code breaks when sizeof (long*) != sizeof(long)...

yes, an example is the Atlas board  :palm: :palm: :palm:
it accepts both the cpu modules, 32bit and 64bit
but you can't recompile the same examples without having to deal a lot of messes

actually you have two branches, the same code forked into two branches
because of messes with sizeof (long*) != sizeof(long)
 
long* is 64 bit with "5kc" (but it can also be 32bit if you use the legacy mode)
long* is 32bit with "4kc"

computer science, feelings of pity and sorrow for someone else's misfortune  :D
 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #126 on: November 02, 2016, 10:06:39 am »
computer science, feelings of pity and sorrow for someone else's misfortune  :D

This is why my bench is analogue only. It's an escape from the insanity.
 

Offline obiwanjacobi

  • Frequent Contributor
  • **
  • Posts: 925
  • Country: nl
  • What's this yippee-yayoh pin you talk about!?
    • Marctronix Blog
Re: "Stop Teaching C" - Kate Gregory
« Reply #127 on: November 02, 2016, 10:12:50 am »
Although the D language looks excellent, it also states it was designed for 32 bit and up.
I can find compilers for the Windows and Linux and some ARM (not an expert).

So for smaller MCU there is no support it seems.

My 2c.
Please continue with the C/C++ bashing..

:horse:   

:popcorn:
Arduino Template Library | Zalt Z80 Computer
Wrong code should not compile!
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #128 on: November 02, 2016, 10:14:10 am »
That's a valid observation, but it raises two important questions:
  • why do people (plural) use the "wrong" language for the problem
  • what is the domain for which there are no better languages

good question, I have no answer

concerning being the wrong language, or the right language
that is the reason why I am developing my own language

mainly because I am tired to have to deal with gcc
but I am also tired to have to deal with C itself
but it's pure hobby for my own research (=pleasure)

I mean, I am obliged to use C/C++ for my job  :-//
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #129 on: November 02, 2016, 10:19:40 am »
that is the reason why I am developing my own language

but it's pure hobby for my own research (=pleasure)

The language is, of course, the easy bit. Thereafter comes the tools, libraries, documentation, staff training... The tools and staff training are very siginificant issues with domain specific languages (DSLs).

But "because I want to have fun doing it" is a perfect, sufficient reason :)
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 hamster_nz

  • Super Contributor
  • ***
  • Posts: 2137
  • Country: nz
Re: "Stop Teaching C" - Kate Gregory
« Reply #130 on: November 02, 2016, 10:22:12 am »
  • why do people (plural) use the "wrong" language for the problem
  • what is the domain for which there are no better languages

In my case, it is because I am now old and feel that most languages are fads, and the language isn't really what is of interest to me. I'm doing things for fun, and there is nothing I can't explore in C...

I am currently mostly using the TCC compiler (http://bellard.org/tcc/ ) - the entire compiler is well under 300kB. I have it on a USB stick which I can plug into any PC I have handy and scratch out some ideas, compile in seconds and do stuff with zero fuss, rather than multi-MB downloads.

When I need to I can also compile and use exactly the same code on Intel, Sparc, PowerPC and various ARM systems (using GCC) and get the benefits of a pretty good optimizing compiler.
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #131 on: November 02, 2016, 10:33:37 am »
computer science, feelings of pity and sorrow for someone else's misfortune  :D

This is why my bench is analogue only. It's an escape from the insanity.

LoL, it sounds like when a customer wanted a *light dimmer* for his helicopter
and as solution I offered a very pretty cpu board with a tiny MPU aboard

I told him that I already had the firmware, it would have saved the development cost
since I would have given him a super discount, already DO178b level D compliant
and, come on, we were talking about a *light dimming*, not critical,
it could be considered "aesthetic" … but no way  |O

he didn't want to change his mind, he wanted to erase and rewind the whole project
because he wanted to see just operational amplifiers and transistors aboard

it was a very easy circuit but it also meant having to deal with TinaLT
and simulations and test reports to be made with DSO and probes

so at the end of our discussion … I tried my last chance
- can I … use a CPLD, sir? it's not a cpu, there is nor C neither assembly, it's HDL code
- No! I want to see transistors and OAmps!

I believe that with airplanes, helicopters, and trains it's actually a wonderful job :-DD
« Last Edit: November 02, 2016, 12:17:52 pm by legacy »
 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #132 on: November 02, 2016, 10:35:20 am »
Yep! Current source, ramp generator, schmitt trigger, flip flop, diff amp as a comparator then a driver stage. It's already in my head, all in BJTs ;)
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #133 on: November 02, 2016, 11:36:36 am »
  • why do people (plural) use the "wrong" language for the problem
  • what is the domain for which there are no better languages

In my case, it is because I am now old and feel that most languages are fads, and the language isn't really what is of interest to me. I'm doing things for fun, and there is nothing I can't explore in C...

Old: yes :(
Fads: definitely.
Interest in language: only as far as it helps/hinders me in doing interesting things
Fun: the best justification!

Quote
When I need to I can also compile and use exactly the same code on Intel, Sparc, PowerPC and various ARM systems (using GCC) and get the benefits of a pretty good optimizing compiler.

Only if you are very careful to choose a subset where all the "implementation defined" and "nasal daemon" language constructs are completely aligned or avoided. For embedded work, that's particularly problematic where caches, multithreading, and multiprocessors are involved. Original C explicitly defined those as library problems - which is a problem for libraries which must rely on things the language explicitly leaves undefined!

I believe the latest C has finally included a "memory model", but the success of that is yet to be determined. (Even Java had to modify their memory model after a decade's experience!)
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 Kalvin

  • Super Contributor
  • ***
  • Posts: 1794
  • Country: fi
  • Embedded SW/HW.
Re: "Stop Teaching C" - Kate Gregory
« Reply #134 on: November 02, 2016, 12:26:48 pm »
One hint for the compiler language designer: Separate the physical data type representation from the logical data type definitions. In C the type definitions mixes the logical presentation and the physical presentation: unit8_t loop_counter means that loop_counter is an unsigned char with a range 0 ... 255 and it is supposed to map to a single 8-bit byte. That is pretty pathetic. In reality the loop_counter should map to the index and the value range it is supposed to iterate. For example in pseudo code: loop_counter : array'first ... array'last. That states clearly the intention of the loop counter and the compiler is now able to detect if the loop_counter is assigned to a wrong value outside the intended value range and the compiler is able to select appropriate internal representation. The physical presentation is useful when dealing with the hardware level and the protocols dealing with registers and octets. There needs to be a way to make a mapping between the physical representation and the logical representation so that the compiler can produce necessary type checking and map the physical representation to the logical representation. 
 
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #135 on: November 02, 2016, 01:19:01 pm »
separate the physical data type representation
from the logical data type definitions

sure, well written, I agree  :D

Code: [Select]
typedef us_r16_t as subrange of uint32_t within { 0 .. 15 };

uint32_t is directly mapped into a cpu register
therefore sub-defining us_r16_t as uint8_t does not make sense

borders are embedded within the type
and they can be checked in hardware on demand
(there is a specific opcode-class to do so)

Code: [Select]
    uint32_iterator_t i; /* it can be used only inside a loop */
    us_r16_t j;

    for i within { 0 .. 4 }
    {
      ..
    }

    for j within { 0 .. 4 }
    {
      ..
    }

    for j within j'range
    {
      ..
    }


I guess this is also interesting
and already implemenmted :D
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #136 on: November 02, 2016, 01:30:10 pm »
Original C explicitly defined those as library problems
- which is a problem for libraries which must rely on things
the language explicitly leaves undefined!

umm some bells are now ringing in my head
some memories from lectures like ...
... why Threads Cannot be Implemented as a Library  :-//

haven't yet understood if C++ gives some help about that
(probably no, but ... it might be yes with C++11/14/..
I still have to study them)


btw, I don't want to deal with multiprocessing and multi threading
and I don't have caching and pipelining in my hobby plans

Arise-v2 is a pure multicycles mono core. My Choice.

even my tattoo says "if you ease your troubles, you enjoy the double"
well, it's a paint, but this is the sense, easy man, easy life  :D
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #137 on: November 02, 2016, 01:38:50 pm »
Original C explicitly defined those as library problems
- which is a problem for libraries which must rely on things
the language explicitly leaves undefined!

umm some bells are now ringing in my head
some memories from lectures like ...
... why Threads Cannot be Implemented as a Library  :-//

haven't yet understood if C++ gives some help about that

In general, no it can't, but...

Quote
(probably no, but ... it might be yes with C++11/14/..
I still have to study them)

... are, I'm lead to believe, getting there. But as I say, I'm not holding my breath. "Castles built on sand" and all that.

Quote
btw, I don't want to deal with multiprocessing and multi threading
and I don't have caching and pipelining in my hobby plans

It is closer that many people realise. Even (high-end) hobbyist FPGA boards have dual-core ARMs, each with their own cache and shared memory. Example: https://www.extremetech.com/computing/216866-know-what-a-fpga-is-then-the-snickerdoodle-is-for-you-and-better-than-the-raspberry-pi

(Yes I do realise you are also creating your own processor :) )
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 Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9211
  • Country: my
  • reassessing directives...
Re: "Stop Teaching C" - Kate Gregory
« Reply #138 on: November 02, 2016, 02:08:40 pm »
btw, I don't want to deal with multiprocessing and multi threading
thats why people like you, or the other guy want to invent a new language with multithread correctness support. hence this neverending pissing contest. as someone said, use the right tool for the right job. btw, no one can stop multithread programming in C/C++. this thread has gone off-topic and i hate pissing contest thread keep popping in my "unread topic" lists, just like the other unrelated threat thread in the beginner's section, because i will get tempted to reply to all this nonsense. they serve no purpose.
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #139 on: November 02, 2016, 02:28:42 pm »
off-topic

I could argue "stop teaching C, C++, whatever
we need a new language, let's design it!
"

do you prefer a split into this title?
they are related, and following two topics
in my opinion will consume more time

I have understood that the original question "C++ vs C"
is just the beginning of the problem since neither of them
seems good, at leas for a good computer science course

thanks for your attention
greetings
 

Offline Kjelt

  • Super Contributor
  • ***
  • Posts: 5739
  • Country: nl
Re: "Stop Teaching C" - Kate Gregory
« Reply #140 on: November 02, 2016, 02:53:56 pm »
You should stop teaching all programming languages.
The only way to learn how to program is to start programming and IMO it doesn't make a big difference in which language you do it, as long as you get the way of thinking.
Give a student any language book to read for help in max. 15 hours and then asignments for 85 hours, instead of teaching for 85 hours and an asignment for 15 hours.

This year alone I had to read code in (for me) 8 new programming/scripting languages (most webapp stuff) and although I (luckily) do not have to write in all those languages I could still read/understand them and what they were doing (with some obscure libcalls being explained through Google). Times are changing and languages are popping up as mushrooms, we do not need anymore experts in one language, we need flexible people that can adjust and adopt any language that is put on their desk.
If I look at the twenty+ year old new employees that build the web and cloud apps they just google the solution if they are stuck.
That is currently the way that things get done in 1 month instead of 1 year (before the internet when every programmer needed all the info to do their job).
Just my two cents.
 

Offline John Coloccia

  • Super Contributor
  • ***
  • Posts: 1199
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #141 on: November 02, 2016, 03:08:29 pm »
Although the D language looks excellent, it also states it was designed for 32 bit and up.
I can find compilers for the Windows and Linux and some ARM (not an expert).

So for smaller MCU there is no support it seems.

My 2c.
Please continue with the C/C++ bashing..

:horse:   

:popcorn:

Yeah, it was never designed as an embedded language, though nothing really precludes you using it like that. You can even turn garbage collection off, and just use C mallocs if you want to. If you're careful to stay away from features that trigger garbage collection, then you're all set....or you can run garbage collection when it's convenient. But then you have to think, "what the hell's the point?" because it turns into an even worse version of C, IMHO.

I would certainly consider it for SOME embedded stuff, though, like when you're writing embedded systems code on some sort of linux/windows platform and you don't care about real-time performance.

C/C++ will rule the embedded world for some time to come. Maybe even forever. I don't actually think that's a bad thing. C/C++ is pretty much ideal for a lot of this kind of when you toss out the stupid language features and simply ignore the bulk of crap libraries it comes with.
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 1794
  • Country: fi
  • Embedded SW/HW.
Re: "Stop Teaching C" - Kate Gregory
« Reply #142 on: November 02, 2016, 03:26:05 pm »
If one scraps the C/C++ macro preprocessor and replaces it with a much more powerful macro language engine (preferably lisp-like), one could  do quite magical stuff like generating the state machines, lists, containers, iterators, simple objects - just name it. At the top level of the design one could allocate the resources and describe the system, and at the lower level - the implementation level - the macros will produce the actual C/C++ code to be compiled by any suitable compiler. It may even be possible to implement compilation and run-time time asserts etc. so the macros can check that the parameters match the requirement and the values are within specified ranges.  Yes, I know that the early C++ compilers were actually macro-expansion compilers producing C code. This powerful macro language would be used to replace the existing macro preprocessor with hygienic macros, improved capabilities and ability to provide the real code generator. :)
 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #143 on: November 02, 2016, 03:34:18 pm »
Or you could just use Lisp :)

(Note my username)
 

Offline AG6QR

  • Frequent Contributor
  • **
  • Posts: 812
  • Country: us
    • AG6QR Blog
Re: "Stop Teaching C" - Kate Gregory
« Reply #144 on: November 02, 2016, 04:24:32 pm »
You should stop teaching all programming languages.
The only way to learn how to program is to start programming and IMO it doesn't make a big difference in which language you do it, as long as you get the way of thinking.

Or you could just use Lisp :)

There are a lot of fairly similar languages (C, C++, PL/1, JAVA, Ada, Python, etc.) that are, broadly speaking, pretty nearly equivalent for the purpose of teaching the first semester or two of programming.  There are practical reasons to choose one over the other, but a student who has learned to implement a linked list in one will be able to write the same algorithm in another pretty quickly.

But not all languages are like that.

I've heard it said that any computer language worth learning is worth learning because it makes you think in a way you hadn't thought before, and you approach problems differently after you've learned it.  Certainly Lisp is one of those.  PostScript is another (it's a full general purpose programming language, not just a printer interface).  Learning any assembly language gives you insight into the architecture of the processor that you wouldn't get any other way.  If you fully grok pointers, casting, structs, and unions in C, you can approach recursive data structures in a way that you wouldn't if you knew only FORTRAN 66 (Old FORTRAN supports neither pointers nor recursion).

Pascal was developed as a teaching language.  I'd say it's sort of like "C with training wheels".  It's strongly typed.  It's a procedural language that supports recursion.  It won't let you have an out-of-bounds array reference.  It's pretty good at teaching abstract algorithms and data structures.  The original language forces you to write your entire program in one file (no header files, no separately compiled files that link together) so it's completely unsuitable for real-world large projects, though there are implementations that work around that issue.  I wouldn't recommend Pascal for any serious work, but I think it's still not a bad language for the purpose of teaching programming.

I actually think it's better to learn at least a couple of less-popular languages, not because you need to know them, but because they expand your horizons into knowing that there are ways of doing things other than the way today's most popular languages do them.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9211
  • Country: my
  • reassessing directives...
Re: "Stop Teaching C" - Kate Gregory
« Reply #145 on: November 02, 2016, 04:25:55 pm »
I could argue "stop teaching C, C++, whatever
we need a new language, let's design it!
"
new language that nobody can complaint? you are dreaming.
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #146 on: November 02, 2016, 04:47:18 pm »
Pascal

the first I ever learned back in '90  :D

I have seen some pascal compilers for embedded boards
and you can also find pascal compiler for 8051 boards
never tried, but I know they exist

edit: found!
here it is, Mikroe pascal, for arm!
my memory is still good :D

also, there is freepascal, used on Teensy and GBA
« Last Edit: November 02, 2016, 06:16:10 pm by legacy »
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #147 on: November 02, 2016, 04:49:31 pm »
Quote
The embedded target is still under development and only a few controllers are supported. Nevertheless, it's possible to create programs for embedded arm devices. The embedded target targets systems without any operating system and typically several kBs of RAM and several dozens of kB of flash. A typical target is the LPC family of NXP with popular members like the LPC2124 with 16 kB RAM and 256 kB flash using the ARM7 instruction set.

experimental (free-)pascal_embedded  :-//
 

Offline C

  • Super Contributor
  • ***
  • Posts: 1345
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #148 on: November 02, 2016, 05:05:16 pm »

Think of some foundation things.

C's great, just add a library to do ______ .

I think you are not asking some thing simple here.
What is the difference when you use C's version of array vs a matching library? Just simple things like compile time _____.
Adding a library lets C compile something to do more while putting more work on programmer using library.

free_electron's complaining about header files.

Think here you need to ask, is it a language problem, a compiler problem or the tool used to create the program source?

How about it's all three for an answer.
A header file or section lets a programmer know what hooks can be used with this code with out having to read and understand all the code. To me that is a good thing. It lets many programmers work on separate parts of a program. It allows for a simpler faster compiler.

One problem is where is the key word that states this has a matching part in the header.
Some languages have a flag or key word that states this is a header part so you no longer need a separate header. Removes the need to match the header part to where it's defined, but also puts more work on programmer as you have to read all code and build the header part your self. One simple fix is normally missing, the command to Compiler/language to build a separate header.
With out flag or key word in language, programmers work load also increases with the need to match some things in header and code.

 the tool used to create the program source
This is the really sad part of the whole process. If the editor understands the language, then when you add the flag or key word stating it's part of header, the editor could maintain the matching part in the header. Programmer gets the best of it. You have a header for compiler and programmer to use with just the cost of adding flag or key word.

Need to remember that what is currently called a compiler is translator. If you look at C, A poor translator. It is too low level and too high level not counting the other bad parts. Some of the hiding at low level causes big problems or compiler bloat. Look binary integer math for example. At the binary level it's and array of bits that you do math on. Some math can create results larger then the input array of bits. Some CPU's supply almost zero cost functions when doing binary math to reduce need for some instruction steps. With C's hiding this, higher level code has problems.  Note here that an array of bits does not just = integer.

A CPU works with bits with some instructions working with array of bits.
Starting at this level gives the compiler options on how to get job done. It actually makes programmers job easer.
With array of bits, any bit size math is possible. Some will use one CPU instruction, while others can still be done using many CPU instructions. 
With array of bits, any bit size logic is possible. Some will use one CPU instruction, while others can still be done using many CPU instructions.  As the compiler gets smarter everything improves, Little simple things in compiler. The smart compiler knows that an array of bits of size ___ can have ___ states. It can create the bit masks when needed removing one source of programmer errors. 

Also need to think of what a macro preprocessor really is.
For C it's a hack to patch a poor language using text editing. A hack that can result in all source needing to be checked and recompiled again. For a language that uses type names & headers a lot of the need vanishes with proper language use. 
A simple what CPU is this code to run on at compile time removes more need. Note here that it is not a choice of one, it is a list of CPU's. In source then a case statement can then select what is needed.

I worked with a pascal compiler that had modules and a few added key words for system programming back in the 80's. The output of compiler was one file that contained the header for other pascal source to use this module, The machine code & the linking/patch information needed. The one file removed many problems like does header match the code. The header was simple to get as it looked like a text file but contained more after the end of the text. Pascal to assembly was also very easy, a simple command to compiler would take a text header as input and create a file containing assembly code needed for linking to pascal. Add needed assembly code and run through assembler and done. Assembly code that linked with pascal.

By fixing the low level problems, you have something you can easily build on. No big steps to run compiler on one CPU and generate output that can run on many different types of CPU's. The question becomes do you include code generator for all CPU's, A few or just one in the new compiler program.
If you have source for compiler, the hard part becomes what key or key word to use to add more smarts to compiler. What parts of compiler to include in editor.

Stop the compiler hiding things as only option. For binary math, an overflow error is a fact. Question is does compiler handle it here and/or does source program. For an object you then have many options. For garbage collection you have option of NONE. Compiler then knows what to show as an error when trying to use garbage collection based things with no garbage collection enabled. When you create an object, you also have options, Use default, Heap, stack, special memory area.

When you think of this foundation, not hard to add option to change rules for a section of code as long as lower level matches up at some point and helps other sections of code. It's just a key word that is needed stating what language follows.

Why create a new language when the editor makes a mess of it.
New language should be part of editor and part of compiler, interpreter with choice of may types of outputs in one program. All have a need at times.
Adding compile time checks and code generation should be part of language.
Hacking the hack needs to stop.


 
 
   




 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #149 on: November 02, 2016, 05:40:18 pm »
The question becomes do you include code generator for all CPU's

I am running my own research for hobby
therefore the answer is: no, sorry

btw, the don't look at me

there are smarter dudes around,
cleaver ans more skilled than me

so, I wonder: if we feel that both C and C++ are not good
why do we have forked the research into "Go" and "Rust"?

does they solve *the* problem? ...

they are based on Clang, therefore it's easy to support
existing CPUs, but ... those languages are not solving
*the* problem, the reason why we don't feel good
with C and C++ etc  :-//
« Last Edit: November 02, 2016, 05:57:44 pm by legacy »
 

Online hamster_nz

  • Super Contributor
  • ***
  • Posts: 2137
  • Country: nz
Re: "Stop Teaching C" - Kate Gregory
« Reply #150 on: November 02, 2016, 05:49:08 pm »
Starting at this level gives the compiler options on how to get job done. It actually makes programmers job easer.
With array of bits, any bit size math is possible. Some will use one CPU instruction, while others can still be done using many CPU instructions. 
With array of bits, any bit size logic is possible. Some will use one CPU instruction, while others can still be done using many CPU instructions.  As the compiler gets smarter everything improves, Little simple things in compiler. The smart compiler knows that an array of bits of size ___ can have ___ states. It can create the bit masks when needed removing one source of programmer errors. 

It sounds like a unrealistic fantasy - Let me riddle you this.... In this new language, what is returned by the equivalent of the sqrt(x) function, esp when x = 2.0?
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline helius

  • Super Contributor
  • ***
  • Posts: 2859
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #151 on: November 02, 2016, 05:53:37 pm »
It sounds like a unrealistic fantasy - Let me riddle you this.... In this new language, what is returned by the equivalent of the sqrt(x) function, esp when x = 2.0?
A generic can return whatever type its caller expects.
A really "future"-oriented language would "return" an infinite result (pun intended).
 

Online hamster_nz

  • Super Contributor
  • ***
  • Posts: 2137
  • Country: nz
Re: "Stop Teaching C" - Kate Gregory
« Reply #152 on: November 02, 2016, 05:59:54 pm »
Strange how many have an adversarial relationship with their computers and tools. Isn't the idea to work with the machine, not against it, to achieve your aim?

If is just that C (and I guess C++) is more up-front and honest (some say blunt and rude) and shows a machine's personality more strongly than other wishy/washy languages. Internally a computer can only do a limited set of things on a limited set of primitive data types, and hold that in memory, and on different platforms things can be different. It allows you to work with the hardware, not in spite of the hardware.

C was the first language to be honest with the programmer about that, and allowed programmers to write efficient code without knowing all the details (making it portable if written with care). That is why the language has been so well adopted and long lasting.
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Online hamster_nz

  • Super Contributor
  • ***
  • Posts: 2137
  • Country: nz
Re: "Stop Teaching C" - Kate Gregory
« Reply #153 on: November 02, 2016, 06:06:48 pm »
It sounds like a unrealistic fantasy - Let me riddle you this.... In this new language, what is returned by the equivalent of the sqrt(x) function, esp when x = 2.0?
A generic can return whatever type its caller expects.
A really "future"-oriented language would "return" an infinite result (pun intended).

That is just waving the problem off... say a user is expecting to see the answer... "print sqrt(18)" what does your language give? "4"?, "3*sqrt(2.0)", an endless stream of digits? or "Sorry Dave, that answer can not be computed with the time left in the universe"

Or even worse
  i = sqrt(2.0)
  print "The square root of 2.0 is " i
  j = i * i
  print "Hang on, i * i is " j " which either isn't 2.0, or I didn't use the number printed above when calculating it!"

 
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 6655
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #154 on: November 02, 2016, 06:09:40 pm »
<snip>

If you fully grok pointers, casting, structs, and unions in C, you can approach recursive data structures in a way that you wouldn't if you knew only FORTRAN 66 (Old FORTRAN supports neither pointers nor recursion).

One point of view is that FORTRAN only supports pointers.  All variables are passed by reference, not by value.  To interface gfortran with C, I had to write a little shim code to dereference the gfortran's pointers and pass the values to the C code (or rewrite the serial IO library I was using).  So, I can do serial IO from FORTRAN!  I can control the world!

Fortran 90 added pointers and derived data types (structures).  Pointers are passed by reference so you get a pointer to a pointer.  Linked lists are now possible but I haven't tried this 'feature'.

Quote

Pascal was developed as a teaching language.  I'd say it's sort of like "C with training wheels".  It's strongly typed.  It's a procedural language that supports recursion.  It won't let you have an out-of-bounds array reference.  It's pretty good at teaching abstract algorithms and data structures.  The original language forces you to write your entire program in one file (no header files, no separately compiled files that link together) so it's completely unsuitable for real-world large projects, though there are implementations that work around that issue.  I wouldn't recommend Pascal for any serious work, but I think it's still not a bad language for the purpose of teaching programming.


I absolutely loved UCSD Pascal and, to this day, I play around with FreePascal on a PC.  I used the 8051 variant to code up an embedded control system several years back.  The code was elegant.

UNITS was invented to allow Pascal to have separately compiled units.

At one time I was working on an FPGA project to implement Niklaus Wirth's P4 output code directly in hardware.  I managed to implement all of the required instructions but it didn't occur to me at the time how I would implement system calls.  Today, I would use one of the Zynq devices and use the ARM component to implement system calls and the FPGA fabric to interpret the P4 code.  The system would absolutely rip!

"Algorithms Plus Data Structures Equals Programs" by Wirth is probably the best introductory programming text ever written.  I haven't followed along with the Modula2 and Oberon successors.  Oberon is available for embedded programming.

Quote
I actually think it's better to learn at least a couple of less-popular languages, not because you need to know them, but because they expand your horizons into knowing that there are ways of doing things other than the way today's most popular languages do them.

I still write a little FORTRAN from time to time.  It's a language I enjoy and the first I ever learned back in '70.  I'm not so enamored of the later additions of objects but I do like the syntax cleanup.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #155 on: November 02, 2016, 06:53:04 pm »
Strange how many have an adversarial relationship with their computers and tools. Isn't the idea to work with the machine, not against it, to achieve your aim?

If is just that C (and I guess C++) is more up-front and honest (some say blunt and rude) and shows a machine's personality more strongly than other wishy/washy languages. Internally a computer can only do a limited set of things on a limited set of primitive data types, and hold that in memory, and on different platforms things can be different. It allows you to work with the hardware, not in spite of the hardware.

C was the first language to be honest with the programmer about that, and allowed programmers to write efficient code without knowing all the details (making it portable if written with care). That is why the language has been so well adopted and long lasting.

What you are describing is the "high level assembler" concept, with "close to silicon" abstractions. That's justifiable, fine and dandy. Arguably C is still the best for that.

There are also many languages (especially Java and Python) aimed at "general purpose application-domain" abstractions that are far removed from the silicon. That's also justifiable, fine and dandy. They are a damn sight better than C for those purposes; hence the explosion in their popularity.

But the real serious unresolvable dichotomy is that C (and deliberately in the case of C++) has mutated into something that attempts to do both and ends up doing both poorly. It has become unnecessarily complex for the "high level assembler" use case, and has too many badly defined constructs and leaky abstractions for the general purpose application use case.

The reasons for its longevity and adoption are more to do with history than technical merit. "Science advances one death at a time"; the same can be said for programming.
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: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #156 on: November 02, 2016, 07:02:13 pm »
@tggzzz
what do you think about
  • Rust by Graydon Hoare (Mozilla)
  • Go by Rob Pike and Ken Thompson (Google)
  • Caml by Xavier Leroy, Jerome Vouillon e Damien Doligez (INRIA.)

do I'd better loot at them?
skip? leading to damnation?
 

Offline helius

  • Super Contributor
  • ***
  • Posts: 2859
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #157 on: November 02, 2016, 07:08:07 pm »
That is just waving the problem off... say a user is expecting to see the answer... "print sqrt(18)" what does your language give? "4"?, "3*sqrt(2.0)", an endless stream of digits? or "Sorry Dave, that answer can not be computed with the time left in the universe"
That seems like an obvious case, but mixing user interface code with calculation is a jumbling of concerns and is bad design. In the MVC paradigm, the code that does the calculating (the model) shouldn't be too concerned with how the results will be displayed (the view). The view for a calculator program can truncate results to fit its window.

Quote
Or even worse
  i = sqrt(2.0)
  print "The square root of 2.0 is " i
  j = i * i
  print "Hang on, i * i is " j " which either isn't 2.0, or I didn't use the number printed above when calculating it!"
Same problem, and further mixing up what should properly be separated into a controller module (inputing expressions to calculate).

Strange how many have an adversarial relationship with their computers and tools. Isn't the idea to work with the machine, not against it, to achieve your aim?

If is just that C (and I guess C++) is more up-front and honest (some say blunt and rude) and shows a machine's personality more strongly than other wishy/washy languages. Internally a computer can only do a limited set of things on a limited set of primitive data types, and hold that in memory, and on different platforms things can be different. It allows you to work with the hardware, not in spite of the hardware.
The problem is that computers exist to run programs, not the other way around. When a computer cost today's equivalent of $100 Million and ran a thousand operations per second, the low-level approach made sense. That hasn't been true in living memory, though. Since before I've been breathing, the expense of development has dwarfed the cost of the hardware, and software is much longer lived, as well. Who cares what is "the machine's personality"? You are speaking of a disposable gadget as if it were a dinner guest.
 

Offline C

  • Super Contributor
  • ***
  • Posts: 1345
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #158 on: November 02, 2016, 07:16:02 pm »
hamster_nz
Thinking of ONLY One is a problem.
sqrt(x) function returns what the caller of function wants and uses what the caller supplies.
what prevents this

error, functionresult = sqrt(x)

What says that compiler only has access to just One sqrt(x). You know that is not true now as you have sqrt(x) that returns a byte, integer, ..., real. The compiler is just selecting the proper one or generating proper code for the one needed. The compiler just needs the information to make the choice.

legacy
  Think of your list of parts.
  When you split something into two parts, you cure some problems while adding problems. Think of why the parts are there.

Why do you need a make file? For a language that has a header to a block of code, the compiler for that language knows what is needed when you compile a program. It has option of doing this it's self or passing buck to make program. It's not a one or other choice, both can do a part. In a lot of cases, one program trying to remote control a second program adds great costs for very little benefit. 

The same is true for linker. why elf, dwarf as only option. Why not one file that contains the header for many languages, code & linking information. The code is no good with out a language header, why remove it? When doing this, nothing stops you from also having a linker header or not. Also nothing stops you from having many code sections.
Linking is two parts, link at compile time and/or link at run time. For embedded, you want link at compile time. When using an OS, compile time, run time or both. Run time also adds problems of what version of code that is not present at compile time. Can the code be shared at run time? Are you just linking for the sake of linking? Granted run time does let you update a chunk of code that is not linked at compile time with the added cost of time.
   
If you look at language rules for Pascal & language rules for Oberon, you should see that less rules can make a more powerful language. Less rules also makes it easer to create a compiler.
The big problem for Pascal & UCSD Pascal was it's lack of complete foundation in the compiler. As I said, I used a pascal compiler where few problems of lack of foundation remained. 
C's answer to most things is Make the Programmer do what the compiler could do. 

If you want a fast compiler, don't add dumb things that require all code to be compiled each time. Don's leave out simple to type things that makes compiler quicker. This is really dumb when you can have the editor type a lot of this for you.
A good language would let you type code & at same time be able to access lists of options while in the editor.

A little code that can process a lot of data can be much better then a lot of code processing little. Processing data is what a CPU is good at.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #159 on: November 02, 2016, 07:17:59 pm »
@tggzzz
what do you think about
  • Rust by Graydon Hoare (Mozilla)
  • Go by Rob Pike and Ken Thompson (Google)
  • Caml by Xavier Leroy, Jerome Vouillon e Damien Doligez (INRIA.)
do I'd better loot at them?
skip? leading to damnation?

I don't have a valid opinion.

I've glanced at the first two, but haven't attempted to do anything with them. They look sensible, but... Quite frankly, the dominant considerations are the available tools, libraries and skilled personnel - all of which are a serious problem for any new language.

Sincel learning C in 1981, the only times I've jumped into using new languages are with:
  • Prolog -because you express some concepts so differently and succinctly
  • Smalltalk - on a fat Mac, the first affordable OOP
  • Objective-C - a good marriage of Smalltalk OOP with procedural concepts (unlike C++)
  • Java - because of Gosling's track record and the quality and clarity of the whitepaper. I just said "yes" to each of the design decisions, and knew it was A Good Thing
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 John Coloccia

  • Super Contributor
  • ***
  • Posts: 1199
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #160 on: November 02, 2016, 08:00:10 pm »
IMHO, Go doesn't deserve to be mentioned in the same sentence as something like D or C...or even Rust. If it weren't for Google pushing it, Go wouldn't have passed the laugh test.

Rust is interesting. They certainly have better marketing than D. Overall, I think D is a more useful, general purpose language but I can certainly see where Rust has advantages.


« Last Edit: November 02, 2016, 08:02:32 pm by John Coloccia »
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 6655
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #161 on: November 02, 2016, 08:17:43 pm »

The big problem for Pascal & UCSD Pascal was it's lack of complete foundation in the compiler. As I said, I used a pascal compiler where few problems of lack of foundation remained. 
C's answer to most things is Make the Programmer do what the compiler could do. 


I don't want the compiler writers deciding how my program should run.  In C, I can, and indeed I am forced to, provide clues about my intent.  If I want an integer result of a real square root, well, I simply cast the result.  Now the compiler and I both agree on what the result should be.

I don't write payroll programs and I certainly don't write code to cure world hunger.  I don't need a language tailored to do either one.  I want to twiddle bits in a register and make LEDs blink (or some similar but more sophisticated example).  I'm perfectly happy with a language that doesn't force me to use a heap (if I ignore certain library functions) and I have no problem telling the linker exactly where to put the code and data.  In fact, for embedded programming, I am forced to tell the linker because every chipset is different.

Makefiles allow me to use alternative libraries, compile for different execution environments (debug versus release), different chipsets, even different compilers and so on.  FWIW, Eclipse is doing a pretty nice job of generating simple Makefiles.  Makefiles also handle partial compilation based on revision date/time.  If I only change one file, there is no need to compile the entire tree.

The reason C is still hanging around (and the same for FORTRAN) is that, in their domain, they are the best tools to use.  Nobody would keep hanging on to FORTRAN for 60 years if it didn't provide a service.  Inertia would have been overcome decades ago.  Same story for C.  Yet, here we are, still using both.  Gigantic chunks of code are still being written in C.

What the world needs is a decent application language.  C++ isn't it!  In my view, neither is Java.  I can't imagine writing a really large program in Python (large, like a 3D CAD program). I have no idea what such a language would look like.  The problem is to provide the features without the complexity.


 

Online hamster_nz

  • Super Contributor
  • ***
  • Posts: 2137
  • Country: nz
Re: "Stop Teaching C" - Kate Gregory
« Reply #162 on: November 02, 2016, 08:41:21 pm »
The problem is that computers exist to run programs, not the other way around. When a computer cost today's equivalent of $100 Million and ran a thousand operations per second, the low-level approach made sense. That hasn't been true in living memory, though. Since before I've been breathing, the expense of development has dwarfed the cost of the hardware,  Who cares what is "the machine's personality"? You are speaking of a disposable gadget as if it were a dinner guest.
I'ld rather spend my spare time with a dinner guest who can show me interesting things, then one completely lacking in personality.  :D

You mustn't be working on any interesting problems in interesting domains:

- CUDA has personality
- SIMD has personality
- Multiprocessing can be psychopathic,
- Mixed HDL / Software development is sometimes like having genius preschoolers at university

If you are not bumping into these edges you are not pushing very hard. I regularly have less CPU cycles than I want or need - esp for DSP stuff.
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline Sal Ammoniac

  • Frequent Contributor
  • **
  • Posts: 921
  • Country: us
    • Embedded Tales Blog
Re: "Stop Teaching C" - Kate Gregory
« Reply #163 on: November 02, 2016, 09:00:19 pm »
What the world needs is a decent application language.  C++ isn't it!  In my view, neither is Java.  I can't imagine writing a really large program in Python (large, like a 3D CAD program). I have no idea what such a language would look like.  The problem is to provide the features without the complexity.

Agreed. I've been looking for the ideal application language for 35 years and I haven't found it yet. C++ is an abomination. Java isn't much better. C# is a step in the right direction, but not there yet. I'm still holding out hope that some of the new languages that I haven't looked at yet (Rust, Swift, Go) might be the answer, but based on past experience I'm not holding out too much hope.

In the embedded arena, I've been reasonably happy with C and don't see any need to go to a more complex language (heaven forbid C++) for embedded work.
 

Offline timb

  • Super Contributor
  • ***
  • Posts: 2528
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
Re: &quot;Stop Teaching C&quot; - Kate Gregory
« Reply #164 on: November 02, 2016, 09:22:04 pm »
What the world needs is a decent application language.  C++ isn't it!  In my view, neither is Java.  I can't imagine writing a really large program in Python (large, like a 3D CAD program). I have no idea what such a language would look like.  The problem is to provide the features without the complexity.

Agreed. I've been looking for the ideal application language for 35 years and I haven't found it yet. C++ is an abomination. Java isn't much better. C# is a step in the right direction, but not there yet. I'm still holding out hope that some of the new languages that I haven't looked at yet (Rust, Swift, Go) might be the answer, but based on past experience I'm not holding out too much hope.

In the embedded arena, I've been reasonably happy with C and don't see any need to go to a more complex language (heaven forbid C++) for embedded work.

Swift is actually very nice as an application development language. The initial version still had a few, um, idiosyncrasies, but most of that has been fixed with Swift 2.0.

It's like someone plucked all the good parts of ObjC, C#, Python and RoR, then put them in a blender.

The compiler is available for Linux now, you should give it a try! (It's been mostly ported to ARM as well; someone has nightly builds targeting BeagleBone and Raspberry Pi 2/3, but I think it only supports Ubuntu at the moment, which is less than ideal.)
Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 

Offline C

  • Super Contributor
  • ***
  • Posts: 1345
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #165 on: November 02, 2016, 10:04:08 pm »

The big problem for Pascal & UCSD Pascal was it's lack of complete foundation in the compiler. As I said, I used a pascal compiler where few problems of lack of foundation remained. 
C's answer to most things is Make the Programmer do what the compiler could do. 


I don't want the compiler writers deciding how my program should run.  In C, I can, and indeed I am forced to, provide clues about my intent.  If I want an integer result of a real square root, well, I simply cast the result.  Now the compiler and I both agree on what the result should be.
You should ask your self which is better, get what you want creating code with bugs and not being told of the bug errors or get what you want and being informed of the errors.
A good language does not prevent you from getting what you want.
A simple  = integer(real square root) does what you want above.

Quote
I don't write payroll programs and I certainly don't write code to cure world hunger.  I don't need a language tailored to do either one.  I want to twiddle bits in a register and make LEDs blink (or some similar but more sophisticated example).  I'm perfectly happy with a language that doesn't force me to use a heap (if I ignore certain library functions) and I have no problem telling the linker exactly where to put the code and data.  In fact, for embedded programming, I am forced to tell the linker because every chipset is different.

Makefiles allow me to use alternative libraries, compile for different execution environments (debug versus release), different chipsets, even different compilers and so on.  FWIW, Eclipse is doing a pretty nice job of generating simple Makefiles.  Makefiles also handle partial compilation based on revision date/time.  If I only change one file, there is no need to compile the entire tree.
  alternative libraries only work when they are compatible to source.
Compiler is program that can state if this works or not.

Think of your debug
A better option that does not prevent total debug is a language where you can state,
I want to debug this type, this structure, this function. this part of code.
Again your make file debug option is the poor choice. 

Your whole thing here is move information to a point where language is less or no help to you instead of where a language could help.
Guess you like increasing your work load.

Quote
The reason C is still hanging around (and the same for FORTRAN) is that, in their domain, they are the best tools to use.  Nobody would keep hanging on to FORTRAN for 60 years if it didn't provide a service.  Inertia would have been overcome decades ago.  Same story for C.  Yet, here we are, still using both.  Gigantic chunks of code are still being written in C.

What the world needs is a decent application language.  C++ isn't it!  In my view, neither is Java.  I can't imagine writing a really large program in Python (large, like a 3D CAD program). I have no idea what such a language would look like.  The problem is to provide the features without the complexity.
A good language can go to lower level then C while also telling you about coding errors. It can also work at a higher level then C.
Type name checking is a simple concept that can show a lot of errors in source, done correctly does not prevent the stupid assignment of a voltage to a temperature variable. 
 
The point is a language can not help if you do not give it the information needed to help.



 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 892
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #166 on: November 03, 2016, 12:50:49 am »
... Looks like Perl laid a turd in the middle of the symbol table. And all the other shit it has to bring in just to talk to a stream. And that's the tangle that C++ leaves you in all the time. Ugh kill me.

No need to get killed. That's called "name mangling" and it enables C++ to represent it's more complicated notion of symbols in the same namespace that C uses. To get back your programmer readable names, pipe readelf output through a program called "c++filt".
 

Offline helius

  • Super Contributor
  • ***
  • Posts: 2859
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #167 on: November 03, 2016, 02:47:29 am »
No need to get killed. That's called "name mangling" and it enables C++ to represent it's more complicated notion of symbols in the same namespace that C uses.
Yes, C++ requires this mangling. BUT there is no standard, so interoperability of libraries with different compilers is nil :(
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 892
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #168 on: November 03, 2016, 03:22:24 am »
Yes, C++ requires this mangling. BUT there is no standard, so interoperability of libraries with different compilers is nil :(
If you say so.  :-//  I've never had a problem with it, but most "libraries" I use are distributed in source or via straight C calling conventions.
 

Offline setq

  • Frequent Contributor
  • **
  • Posts: 444
  • Country: gb
Re: "Stop Teaching C" - Kate Gregory
« Reply #169 on: November 03, 2016, 07:42:51 am »
IMHO, Go doesn't deserve to be mentioned in the same sentence as something like D or C...or even Rust. If it weren't for Google pushing it, Go wouldn't have passed the laugh test.

Indeed. It's a fine language to code yourself into a corner with.
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #170 on: November 03, 2016, 08:20:58 am »
Yes, C++ requires this mangling. BUT there is no standard, so interoperability of libraries with different compilers is nil :(
If you say so.  :-//  I've never had a problem with it, but most "libraries" I use are distributed in source or via straight C calling conventions.

Oh, you lucky person. For me that's only been the case with "small" projects.

But that's one reason why the number and scope of commercial libraries in C/C++ is dwarfed by those in more modern languages, especially Java.
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 John Coloccia

  • Super Contributor
  • ***
  • Posts: 1199
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #171 on: November 03, 2016, 09:11:29 am »
Yes, C++ requires this mangling. BUT there is no standard, so interoperability of libraries with different compilers is nil :(
If you say so.  :-//  I've never had a problem with it, but most "libraries" I use are distributed in source or via straight C calling conventions.

He's absolutely right. There is not standard, and in fact it's important that you don't use different compiler/linkers when using C++ because there are other implementation details that are also undefined. It's a good thing that everything resolves to an unknown reference or you'd end up linking together bits of code that are binary incompatible and it would be a disaster.

Some compilers have made themselves compatible by convention, but it's only convention and nothing else.
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #172 on: November 03, 2016, 09:50:35 am »
it only supports Ubuntu at the moment

yep, the get started appears here, and

Quote
Linux

Requirements
Ubuntu 14.04 or 15.10 (64-bit)
Supported Target Platforms
Ubuntu 14.04 or 15.10 (64-bit)

concerning linux, only ubuntu is in the list

edit:

and (stupid me) ...

Code: [Select]
swift-v2.2 # file usr/bin/swift

Code: [Select]
usr/bin/swift: ELF 64-bit LSB executable, x86-64,
version 1 (SYSV), dynamically linked,
interpreter /lib64/ld-linux-x86-64.so.2,
for GNU/Linux 2.6.24,
BuildID[sha1]=5fd987725e5349f6c7aa7706e8c0e5c2c325fe9d
not stripped

… my x86 laptop is 32bit :palm: :palm: :palm:
« Last Edit: November 03, 2016, 09:54:18 am by legacy »
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 9211
  • Country: my
  • reassessing directives...
Re: "Stop Teaching C" - Kate Gregory
« Reply #173 on: November 03, 2016, 10:01:29 am »
my x86 laptop is 32bit my laptop is x86
fixed that for you...
if something can select, how cant it be intelligent? if something is intelligent, how cant it exist?
 

Offline timb

  • Super Contributor
  • ***
  • Posts: 2528
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
"Stop Teaching C" - Kate Gregory
« Reply #174 on: November 03, 2016, 11:38:13 am »
it only supports Ubuntu at the moment

yep, the get started appears here, and

Quote
Linux

Requirements
Ubuntu 14.04 or 15.10 (64-bit)
Supported Target Platforms
Ubuntu 14.04 or 15.10 (64-bit)

concerning linux, only ubuntu is in the list

edit:

and (stupid me) ...

Code: [Select]
swift-v2.2 # file usr/bin/swift

Code: [Select]
usr/bin/swift: ELF 64-bit LSB executable, x86-64,
version 1 (SYSV), dynamically linked,
interpreter /lib64/ld-linux-x86-64.so.2,
for GNU/Linux 2.6.24,
BuildID[sha1]=5fd987725e5349f6c7aa7706e8c0e5c2c325fe9d
not stripped

… my x86 laptop is 32bit :palm: :palm: :palm:

Not exactly what I meant... There's a group working on an ARM port; they have a nightly build available for download, but it only seems to support bleeding edge Ubuntu at the moment. (Perhaps because it already comes with LLVM and a bunch of other pre-reqs.)

That said, there at least two separate other ports available, both with build scripts that work on any distro with the required tools. The issue is the build can take up to 12 hours on a Raspberry Pi 3!

As for the official Swift binaries, I'm sure they're x64, but nothing should be stopping you from compiling it yourself on x86. There's also no reason that the x64 binaries won't work on other distros, either.  (Assuming all the prerequisites are in place).

Apparently the reason Ubuntu is on their list is because that's the distro they happen to use for their Linux development. Keep in mind that up until like a year ago, it wasn't even available for Linux! I'm sure in a few years, they'll have binary installs for all the major package managers (Yum, apt, fetch, etc.)
« Last Edit: November 03, 2016, 11:40:36 am by timb »
Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #175 on: November 03, 2016, 12:07:27 pm »
but nothing should be stopping you
from compiling it yourself on x86

yep, yesterday I compiled gnat on my gentoo box
(with a lot of fighting in the middle … dammit gentoo)
It would have been a lucky event to find some x86-32
already done, ready out the box

not yet happened, I still have hope :D

There's also no reason that the x64 binaries
won't work on other distros, either.
(Assuming all the prerequisites are in place).

yes, I see, it's just a matter of time
I have to create an ebuild inside an overlay
(gentoo terms) fix it, test it, emerge it etc

long time story, 2 or 3 working days at least

I need a "time doubler" machine , or, still better
a cloning machine, two is better than one :D
« Last Edit: November 03, 2016, 12:15:12 pm by legacy »
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #176 on: November 03, 2016, 12:09:24 pm »
BTW Swift seems THE language 
is it the one? good question :D

"Stop Teaching C" + "teach Swift"
(might it be? who knows …)
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 892
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #177 on: November 04, 2016, 04:52:24 am »
BTW Swift seems THE language 
is it the one? good question :D

"Stop Teaching C" + "teach Swift"
(might it be? who knows …)
Don't think there is such a thing as "the one" language. But Swift is pretty interesting. It's got a lot of the good parts of C++ with some of the sharp edges removed. Documentation is insufficient right now. And it won't be the tool of choice for mcus because it depends on dynamic memory allocation.
 

Offline Brumby

  • Supporter
  • ****
  • Posts: 9409
  • Country: au
Re: "Stop Teaching C" - Kate Gregory
« Reply #178 on: November 05, 2016, 12:41:59 pm »
Somewhere buried in this thread is the original topic... a matter of a re-think on how to teach a language...

... not whether it's any better or worse than another.
 

Online Marco

  • Super Contributor
  • ***
  • Posts: 4472
  • Country: nl
Re: "Stop Teaching C" - Kate Gregory
« Reply #179 on: November 05, 2016, 12:49:32 pm »
Somewhere buried in this thread is the original topic... a matter of a re-think on how to teach a language...

The original topic was in how to better teach C++. I think it's blatantly obvious that teaching how to write consistent C++ code using the standard C++ mechanisms is better served by directly starting with C++. With the blatantly obvious out of the way we moved on to the desirability of doing so immediately (ie. not).

IMO programming should be taught by pseudo-code with assembly language implementation, teach them about micro-optimization (with a focus on memory coherency) at that level. Then skip C/C++ entirely and move up the abstraction chain to java or some fashionable high level language du jour. As much as I hate Apple, all the students are sitting there with macbooks any way ... so I guess swift would make sense.
« Last Edit: November 05, 2016, 01:04:56 pm by Marco »
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 2796
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: "Stop Teaching C" - Kate Gregory
« Reply #180 on: November 05, 2016, 01:02:05 pm »
Seen few minutes of the video: What a bullshit that is. Yeah. Just stop teaching anything, because it requires to learn.  :palm:

 
The following users thanked this post: amyk, gocemk, XFDDesign

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #181 on: November 05, 2016, 02:37:46 pm »
@Marco, Brumby
the topic is mine, and I have no problem with the  brain storming we are actually doing
someone can comment the video where saint Kate explained her right
someone can agree, someone can disagree
someone can explain his/her points
someone can confirm the sanctity to saint Kate ( I do )
someone can revoke the sanctity to saint Kate
someone can argue that we are still looking for a modern language ( I am still )
someone can give me some good advice helping me to design my own made language
(thanks dudes )

no problem at all

come, take a beer, a coffee, a tea (I know, British have tea-time)
( I know, Americans prefer coffee, with/without milk? )
some chocolate ("after eight") ? some biscuits? some red wine?

enjoy my emoticon :popcorn:


there is just a rule: never ever talk about GCC!
immediately permanently banned if so  :-DD
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #182 on: November 05, 2016, 02:50:38 pm »
at the end, I have chosen "Swift" because
it seems to have some legacy with C/C++
and I will follow some "Saint-Kate's points"
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 18028
  • Country: nl
    • NCT Developments
Re: "Stop Teaching C" - Kate Gregory
« Reply #183 on: November 05, 2016, 03:39:37 pm »
Seen few minutes of the video: What a bullshit that is. Yeah. Just stop teaching anything, because it requires to learn.  :palm:
That is not the point of the video. The point is that C++ offers many ways to program smarter with less chance of errors but most teachers start with C because they think that C has basics but that is a false assumption. You really don't need to know the low level C stuff in order to create good C++ programs so don't teach/learn that if you want to get going quickly. The C stuff is just extra luggage you can do without.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 6655
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #184 on: November 05, 2016, 04:06:57 pm »
IMO programming should be taught by pseudo-code with assembly language implementation, teach them about micro-optimization (with a focus on memory coherency) at that level. Then skip C/C++ entirely and move up the abstraction chain to java or some fashionable high level language du jour. As much as I hate Apple, all the students are sitting there with macbooks any way ... so I guess swift would make sense.

Well, that's the approach that Donald Knuth took with MIX and MMIX in "The Art Of Computer Programming".  I'm not sure that physical MIX computers were around but, given FPGAs, it would be trivial to built the 64 bit MMIX computer.  At his web site, Dr. Knuth reiterates why he continues to discuss low level machine instructions and how to use them to deal with complex structures:

http://www-cs-faculty.stanford.edu/~knuth/mmix.html

I like to think of C as one step up from assembly language.  C++ and Java are several flights up.  Perhaps C++ should have been named something else.
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 2796
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: "Stop Teaching C" - Kate Gregory
« Reply #185 on: November 05, 2016, 04:24:00 pm »
Seen few minutes of the video: What a bullshit that is. Yeah. Just stop teaching anything, because it requires to learn.  :palm:
That is not the point of the video. The point is that C++ offers many ways to program smarter with less chance of errors but most teachers start with C because they think that C has basics but that is a false assumption. You really don't need to know the low level C stuff in order to create good C++ programs so don't teach/learn that if you want to get going quickly. The C stuff is just extra luggage you can do without.

There is no such "without luggage". Either you will carry the luggage and produce some nice code, or you will support bloatware bullscheisse and the CPU will take care of your luggage.  ;D

Modern days dictate to teach only high level programming languages - but I am fed up with the bullmerde software the world is now full of, will be glad to see some skilled low level programmers  :-+

To sum up: Everyone shall learn what he or she is interested in.  :-/O
 
The following users thanked this post: amyk

Offline vodka

  • Frequent Contributor
  • **
  • Posts: 456
  • Country: es
Re: "Stop Teaching C" - Kate Gregory
« Reply #186 on: November 05, 2016, 08:39:22 pm »
 I am disagree with several topics this video.

First point, I  have never been a fan of the language C and i  have always found very weaknessed(my opinion bad design) that  i gave  many troubles when i performed several projects .
I don't know as is programming with C++ because i never used , but i have experienced with other programming language that are oriented  to objected (.NET .JAVA) and it is crap , worse than C.
The POO tends to be messed,cumbersome to read and understand and  you always terminate to write more code than the vintage paradigm programming.

When i saw the video  and i do a list of fallacies.

Strings -10:16

I acknowledge  that C  is very bad handling strings and with C++ enhances something.  But Is it necesary using OOP ?
No , COBOL  uses  UNSTRING for splittig strings and STRING for concating string. 

Printf - 11:30

This certain that the system out screen  on C is bad with the type the casting . But the solution on C++ is putting sprats between variables instead  the commas.
They have  resolved us the headache but now we have eyepain.

Arrays  14:31

Here the POO begin to pervert the names  , renaming with exotics names as "Collections"  , let's go  "the monkey is monkey although you wear him  of silk"
The main problem with the arrays on C++ is that the programmer doesn't have to think , he goes to class  get the method, and copies pastes a several times. The programmers loose the agilty of design algorithm.
On change C , too it exists funtions for handling arrays , but it has more flexibility on vary the  code for adapting to situation than with C++, besides the programmer gains agility.

Namespaces 19:30

Other example of like the POO complicates the life , with stupids renames. The namespace is as the classic assigned of the libraries on C.  But the great difficult that the old programmers see this , it is knowing that do this namespace ,because when they  go to help , they find a giant holybook inside this there are other holybooks as  russian dolls


Lambdas & polymorphs & cons & new  25:50-38:24

The pointers on C is a headache with the operators * and &  due to a bad design on  compared with the  ASM opcodes.

Now , when she says that the polymorphism and the pointers are the same, that is for laughing.

Then  the classical POO  theory  is dropped because  if it  does the same but without than the programmer handling pointers . Apart  that the programmers loose the know-how of handling the indirect access, which is the diference with  the visual basic.


On resume, i believe that don't have to leave to teach C due to this language has the main basic of the programming as  manual control arrays and the pointers .
On change the C++  i believe is a bad example of the modern programming : ideological ,incoherent with the actual culture ecologist ( consumed every time more memory while it reduces the consume power),disordering and unstructured programming.




« Last Edit: November 05, 2016, 08:52:59 pm by vodka »
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #187 on: November 05, 2016, 08:55:15 pm »
I acknowledge  that C  is very bad handling strings and with C++ enhances something.  But Is it necesary using POO ?
No , COBOL  use  UNSTRING for splittig strings and STRING for concating string. 

She underlined that string is a type, and each type comes with "operators"
e.g. if (string == string), the "==" is a type_string_operator

But the solution on C++ is putting sprats between variables instead  the commas.
They have resolved us the headache but now we have eye pain

and "<<" is a type-operator, left-associative

 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #188 on: November 05, 2016, 08:59:50 pm »
POO

object oriented programming
O O P, on the mirror, is P O O
like UNIX and XINU, nice trick
 

Offline Syntax_Error

  • Regular Contributor
  • *
  • Posts: 204
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #189 on: November 07, 2016, 11:42:19 pm »
I hope this isn't considered too off topic. I watched the following video recently, and found it very interesting. Beware! He speaks very quickly throughout the video; it took some getting used to.



I watched the video by Kate Gregory when it came out, and honestly, I hate that video. Maybe she's right, I don't know. I'm not in a qualified position to know. But it strikes me as incorrect and also the presentation was quite irritating, which is difficult to ignore.
It's perfectly acceptable to not know something in the short term. To continue to not know over the long term is just laziness.
 

Offline karoru

  • Regular Contributor
  • *
  • Posts: 196
  • Country: pl
Re: "Stop Teaching C" - Kate Gregory
« Reply #190 on: November 08, 2016, 02:16:58 am »
For all these people with very strong opinions and saying that it's a blasphemy to use these "overbloated" things like vectors and strings and OOP instead of static tables, malloc and pointers - "stop teaching C" means "stop teaching C in C++ language course", not in "introduction to programming" course.

This talk was mainly about the big problem (that I also encountered in real life working with new programmers) that typical student after finishing typical C++ course writes code that won't pass any code review and often doesn't use any features of language that decided to choose it in the first place!

As a nice food for though there is another video from CppCon, explaining game for Commodore 64 written in modern C++ (and x86 to 6502 machine code translation) using all these naughty words like templates or classes showing how much can be done without any overhead in resulting machine code.

 
The following users thanked this post: thm_w

Online rstofer

  • Super Contributor
  • ***
  • Posts: 6655
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #191 on: November 09, 2016, 12:32:03 am »
That CppCon video was excellent.  That embedded code can be written with zero overhead has caused me to rethink writing only in C.  Of course, every concept he used is well beyond my existing understanding of C++ so I'll have to go back and watch it a couple more times.  And hit the books...
 

Offline asgard20032

  • Regular Contributor
  • *
  • Posts: 184
Re: "Stop Teaching C" - Kate Gregory
« Reply #192 on: November 09, 2016, 01:51:36 am »
Both of these video made me rethink about using C++ in an embedded system, I really enjoyed these two video.

I still think that we should teach C first, not anymore because of C++ is bloated for embedded, but more because using C++ correctly require a certain degree of experience. And expecting people to learn the base of programming, while also learning object oriented while also learning how to use C++ feature correctly to produce correct embedded system code is maybe too much.

But if people already had some exposure to programming (and i am talking about true exposure, not exposure to some obscure language like visual basic)... and are taking a course focused on embedded programming (with a prerequisite programming course experience) then yes, do it, having a full semester to learn how to use C++ feature while also keeping controle of the compiler output is feasable.

I don't think that learning a language like C before is bad before learning C++, it only expose the student to basic programming mechanism that will be used in C++ anyway : pointer, if, else, while... After learning those, they just need to learn object oriented. What is the difference between learning C first then C++ VS learning C++ without teaching OO now (because before learning OO, we learn how to do basic statement first like if, else...), except that in the first case not to much syntax is involved while in the second case, C++ has lot of syntax that could confuse some student?

Introductory to programming (C, python... but no OOP yet) --> Embedded system programming (MCU, interrupt, RTOS, using C++ the right way for embedded...)
 

Online legacy

  • Super Contributor
  • ***
  • Posts: 4349
  • Country: ch
Re: "Stop Teaching C" - Kate Gregory
« Reply #193 on: November 09, 2016, 07:06:54 am »
Like some mining companies explore possibility of digging for gold,
I was exploring possibility of digging for Kernel development in C++
and this is interesting  :D
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 6655
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #194 on: November 11, 2016, 01:06:39 am »
Here is another video by Dan Saks re: trying to get C programmers interested in C++.  He starts with a slide that show an increasing trend to use C versus a decreasing trend to use C++ and that C is used three times as often as C++.

Somewhere around 1:16:00, he gets to the meat of the issue (from my point of view):  C++ is a hard language - FAR more difficult to understand than C.  100x, 1000x?  In any event, it is a LOT more difficult.

He follows up by saying that a lot of embedded programmers are EEs, not CSs.  Their total exposure to programming in college was the instructor handing out copies of K&R and expecting to see LEDs blink.

The entire video is about how to approach the task of getting C programmers interested in C++.  Only a couple of code examples and those weren't all that helpful since he doesn't really discuss the C++ implementation.



I don't know why it is so difficult!  Just develop an embedded project in C++ (including interrupts and, potentially, an RTOS) and serve it up as an example.  Keyboard input via PS/2, LCD text screen output, some SPI or I2C, perhaps something truly difficult like a USB or Ethernet stack.  I watched one of the other CppCon videos re: embedded development and I'm totally fascinated.  Unfortunately, EVERY book I buy wants to develop an application to solve world hunger.  That's not in my area of interest!

« Last Edit: November 11, 2016, 01:09:27 am by rstofer »
 

Offline westfw

  • Super Contributor
  • ***
  • Posts: 3077
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #195 on: November 11, 2016, 02:33:22 am »
Kate's talk seems to be aimed at the instructors of "5 day C++" classes.  Presumably (?) people who have programmed in bash or javascript, and are looking for info on a more efficient programming language.   This is a pretty scary demographic; it reminds me of my teen son who wanted to wait till age 18 to get his driver's license so he wouldn't have to deal with "silly classes." :-)
You can't become a competent programmer in ANY language in 5 months, much less 5 days.  So it becomes a matter of "what do you teach them first, so that they can do the most without hurting themselves."  In that context, her suggestions make some sense...
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 2560
  • Country: it
Re: "Stop Teaching C" - Kate Gregory
« Reply #196 on: November 11, 2016, 11:27:40 am »
For all these people with very strong opinions and saying that it's a blasphemy to use these "overbloated" things like vectors and strings and OOP instead of static tables, malloc and pointers - "stop teaching C" means "stop teaching C in C++ language course", not in "introduction to programming" course.

This talk was mainly about the big problem (that I also encountered in real life working with new programmers) that typical student after finishing typical C++ course writes code that won't pass any code review and often doesn't use any features of language that decided to choose it in the first place!

As a nice food for though there is another video from CppCon, explaining game for Commodore 64 written in modern C++ (and x86 to 6502 machine code translation) using all these naughty words like templates or classes showing how much can be done without any overhead in resulting machine code.


finally watched that video
* very long whistle *
 

Online rstofer

  • Super Contributor
  • ***
  • Posts: 6655
  • Country: us
Re: "Stop Teaching C" - Kate Gregory
« Reply #197 on: November 11, 2016, 04:53:37 pm »

finally watched that video
* very long whistle *

And I am having a heck of a time finding reference material (books, class notes (no, not that kind of class)) that will get me started.  I was blown away by the elegance of the code and the display of generated code was compelling.  So, how to get started?  I'm talking only about  embedded programming.

I'm a 'cut and paste' kind of person.  I like to find working examples and then incorporate them into my projects.  So far, I'm not finding anything useful.
 

Offline Bruce Abbott

  • Frequent Contributor
  • **
  • Posts: 616
  • Country: nz
    • Bruce Abbott's R/C Models and Electronics
Re: "Stop Teaching C" - Kate Gregory
« Reply #198 on: November 11, 2016, 06:24:35 pm »
I'm a 'cut and paste' kind of person.  I like to find working examples and then incorporate them into my projects.
Thief!  ;)

But seriously, you should just use working examples as a guide to writing your own code. It will be more satisfying, you will learn more, and when you need to do something different you won't be out of your depth. 



 

Online Marco

  • Super Contributor
  • ***
  • Posts: 4472
  • Country: nl
Re: "Stop Teaching C" - Kate Gregory
« Reply #199 on: November 11, 2016, 07:36:49 pm »
I saw a mention of ZeroMQ in the stackoverflow thread, the developer has some choice things to say about C++ for lower level programming.

What seems to be necessary for C++ to be suitable for projects to be maintainable is a big stick, as always with programmers. The adherence to the C++ subset chosen for a project should be guaranteed by a code sanitizer, rather than depending on programmer discipline.

We need C++-.
« Last Edit: November 11, 2016, 07:38:29 pm by Marco »
 

Online tggzzz

  • Super Contributor
  • ***
  • Posts: 10299
  • Country: gb
    • Having fun doing more, with less
Re: "Stop Teaching C" - Kate Gregory
« Reply #200 on: November 11, 2016, 07:40:38 pm »
I saw a mention of ZeroMQ in the stackoverflow thread, the developer has some choice things to say about C++ for lower level programming.

What seems to be necessary for C++ to be suitable for projects to be maintainable is a big stick, as always with programmers. The adherence to the C++ subset chosen for a project should be guaranteed by a code sanitizer, rather than depending on programmer discipline.

We need C++-.

See the FQA (q.v.) :) Don't build castles on sand :)
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
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf