Electronics > Beginners
what is the most relevant programming language for ee?
JPortici:
--- Quote from: Crazy_Pete on November 05, 2018, 12:03:31 pm ---As i pointed out in a private message (and to the wrong person i think, i DO apologise!) Religion is also obsolete and here to stay whether we like it or not. C++ was designed as and functions as a drop in replacement for C. The arduino environment is C++ to a great extent. The compiler is the g++ compiler and the Arduino environment both includes and happily accepts code written in strict ANSI C++. Saying that Arduino uses a "Subset" of C++ is demonstrably false.
The problem with learning C is that it like religion, it will train your mind towards obsolete thinking. If you are lucky enough not to be have been taught C, then forget C. Learning C++ will teach you everything you need to know about C and also give you the ability to use a higher level programming language. To say that there is no place for abstraction in hardware is a absurd. The arduino people used to say that until about 10 years when i showed them you could reduce program size by a few hundred bytes using C++ over C. I am sure that my efforts are a small part of a greater demonstration by many that convinced the Arduino people to make the Arduino environment C++. I hardly consider "It's here to stay whether you like it or not" as a positive endorsement. I can say the same thing about Herpes. (Which like religion, i am also immune to!) Of course C++ obsoletes C. I am not aware of ANYTHING you can do in C that you can't do in C++. If you choose for whatever reason not to use the OO features of C++, the increased type checking, overloading and namespaces found in C++ simply render ANSI obsolete as a matter of fact. (C++ when used as strictly a procedural language obsoletes C at the starting gate.)
I knew this would turn into a typical religion versus science war, but to finish it off, exactly what can you do in C that you can't do in C++?
Hilariously, the machines on which i learnt C++ are dwarfed by many of todays microcontrollers. I just purchased a half dozen ESP32 boards on the cheap from China! (Xi Xi China!!!!!) It is a 32 bit RISC machine with half a meg of STATIC RAM!!!! I can remember telling a fellow who was a certified Genius (you know they have a test for that, it is a called an IQ test.) "You know, i am really glad i learned C++, although i admit, having a machine with128K of DRAM sort of makes it cheating since that much RAM is a huge playground. I dream of one day having a computer running at 10MHz with half a meg of STATIC RAM! " He laughed and said "Not in our lifetimes." Now that unbelievable dream machine is an $8 USD dev board and people are saying "There is no room for abstraction on a platform like that". This is the ULTIMATE "HA! WHEN I WAS A BOY!" :-)
Thanks to all.
Peter
--- End quote ---
This is all good and everything. Too bad my architecture of choice only has a (good) C compiler.
It would be nice to have other options but there is only a (good) C compiler available.
Until this changes, C is going to stay
brucehoult:
--- Quote from: Crazy_Pete on November 05, 2018, 12:03:31 pm ---As i pointed out in a private message (and to the wrong person i think, i DO apologise!) Religion is also obsolete and here to stay whether we like it or not. C++ was designed as and functions as a drop in replacement for C. The arduino environment is C++ to a great extent. The compiler is the g++ compiler and the Arduino environment both includes and happily accepts code written in strict ANSI C++. Saying that Arduino uses a "Subset" of C++ is demonstrably false.
--- End quote ---
Nothing in the example code that comes with Arduino or on the Arduino or Wiring examples web sites uses:
- multiple inheritance
- templates
To name just two C++ features.
Yes, you can use those features in your own code if you know that it will only be used in the Arduino IDE with boards that use a C++ compiler.
--- Quote ---Hilariously, the machines on which i learnt C++ are dwarfed by many of todays microcontrollers. I just purchased a half dozen ESP32 boards on the cheap from China! (Xi Xi China!!!!!) It is a 32 bit RISC machine with half a meg of STATIC RAM!!!! I can remember telling a fellow who was a certified Genius (you know they have a test for that, it is a called an IQ test.) "You know, i am really glad i learned C++, although i admit, having a machine with128K of DRAM sort of makes it cheating since that much RAM is a huge playground. I dream of one day having a computer running at 10MHz with half a meg of STATIC RAM! " He laughed and said "Not in our lifetimes." Now that unbelievable dream machine is an $8 USD dev board and people are saying "There is no room for abstraction on a platform like that". This is the ULTIMATE "HA! WHEN I WAS A BOY!" :-)
--- End quote ---
This I *emphatically* agree with. My early experience was on Apple ][ and CP/M machines with with 32 KB to 64 KB RAM, or PDP-11 with 64 KB for an individual program.
Everything was running at under 1 MIPS -- the clock could be a couple of MHz, but instructions took a number of clock cycles each. And the instructions were so awkward and the number of CPU registers so small that you needed a lot more instructions to complete any particular task than on even an AVR, let alone ARM or RISC-V or MIPS.
Even the number of bytes of code it took to do anything was much bigger than now, which further wasted the limited memory.
And those were the big machines, capable of running usable programming IDEs and symbolic assemblers or compilers. You can use "advanced" programming techniques and facilities on much smaller systems than that, provided that you have a bigger system to compile it on.
Crazy_Pete:
>Nothing in the example code that comes with Arduino or on the Arduino or Wiring examples web sites uses:
So what?
I probably should quit while i am ahead since "So what?" sinks that argument, but....
You are utterly and absolutely sure that no third party library ANYWHERE uses Templates or Multiple Inheritance? I am sorry but that is the sort of semantic hair splitting that comes when you engage in a religious argument. The arduino IDE uses and supports C++. The claim that no embedded project uses C++ is just nonsense. The one feature of C++ that tends NOT to be implemented on MCUs is new/delete and that is simply because many mcus lack a proper memory controller. Like i said in an earlier post, the Joy of the ESP32 is that it is half a meg of STATIC RAM! It is so far advanced beyond the "DESKTOP" machines of 1990 that even C++ features like new/delete are obsolete. The C++ standard is 100s of pages long. AFAIK i am the only person who ever wrote code that uses C++ "Template Template Arguments" and it wasn't all that useful and i took it out of the code. Since nobody chooses to use that feature i guess only a subset of C++ is used on Mainframes and desktops as well.
1) Show me an Ard that doesn't use a C++ compiler
2) Since when is "hardware specific" not a given in MCU programming?
thanks
Crazy Pete
Crazy_Pete:
>This is all good and everything. Too bad my architecture of choice only has a (good) C compiler
What arch has only a C compiler, i am curious because AFAIK g++ has been ported to a HUGE variety of MCUs.
Also the original posters questions was (IIRC) not "What language should i use on a platform that supports only C?" It was "What language should i learn if i am new to the field?"
As these C programmers are demonstrating, once you learn C, you will have a terrible time learning C++. However if you learn C++ first you will have no trouble at all reading other people's C code. C is to C++ what religion is to science. If you learn science first you will have no trouble understanding religion. If you learn religion first your thinking will alway tend towards circular reasoning and "I belong to a community that thinks this way and we can't all be wrong" sort of thinking that you see people using to justify C.
You will see C (catch the chinese pun? ;-) everywhere and you need to be able to read and understand and maintain it. You will also see C++ everywhere and will need to be able to read and maintain it. The only way to kill BOTH of those birds with ONE stone is to learn C++ first.
Xi Xi :-)
Crazy Pete
rjp:
Its a shame that nobody with serious clout has done a c+ yet - which is the useful subset of c++ that every damn modern language has run with - python,c#,java. dart etc.
Bascially c structs with single inheritance that makes building core framework plugins like "Stream" easier without pointer casting.
Namespacing to avoid foo_bah_wah clumsyness in libraries.
then a more modern std library.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version