Fair so what are the C/C++ techniques I should know cold to fix that, that Arduinoese doesn't have? Aain, much respect and I'm enjoying this discussion, hope you are , too as anyone else following/chiming in.
That was a bully fix, iirc. It forces the Processing side to call a function that says "No threat detected" or something like that. Could be wrong, as you see, it was almost two years ago.
However, this is just a general C++ tutorial so it is necessary to extrapolate and interpret how some of the information can be applied in the context of embedded systems and the Arduino sketch framework. So I do think that it is not ideal for the average beginner.
I know that @StefanL38 recommends this Arduino-specific tutorial to beginners:
@hallowed31 There is no "Arduinoese". That is the basic fallacy you're laboring under. There is C, and some C++. That's it. Evidence? What compiler is used by the IDE to compile your work? GCC. You can see that every time you click the compile button. It's not ARDUINOCC, it's plain old GCC.
All of the fluffery that the Arduino team has built up around this to support the particular hardware platform, and to make it easier(really!) to do some pretty simple stuff has flummoxed you into believing this is something different - it isn't. Along the way, you've learned the basics of C, despite thinking you didn't have to. Scary, isn't it?
99% of Arduino firmware code is compiled as C++. Users are free to include C files in their sketches if they like, but this is extremely rare. There is some C in libraries, but still mostly C++. There is significantly more C in the cores.
Perhaps, I should have said, "At my level, there is C, and some C++". Others may aspire to greater assimilation in the C++ clouds, but I'm happy with the tools I have, mostly. I came from assembly language on 6800/6809/68000/8085/8051/8088/80188, so down in the mud is comfy for me. I occasionally have to have someone lift my head out of the mud to dimly grasp a C++ construct or two, that's about it.
This is a great question, and as a noob, I would love to know the answer, lol.
As a noob with a few projects under his belt now, I think the most difficult part of programming is actually applying what one reads or watches on web (or books) to their projects. Sometimes you can search for exactly what you are looking for and bam, there is code there to help you. Other times you have to figure out how manipulate that code that you found for your project. Obviously you will learn more from having to manipulate the code, but that sometimes takes you down rabbit holes as well.
What have I learned as a noob?
Basic understanding of variable types.
Basic understanding of functions, the no return void being the easiest to use.
The members of this forum are a wealth of knowledge, even when they tell you something you don't want to hear.
I struggle with passing arguments to functions however. It is too abstract. Now if someone points out to me what I need to do, I think that makes sense, but coming up with it on my own is difficult.
What I can't figure out for the life in me.
Classes... I've managed to add to classes, but I can't make my own class. I've read many articles and watched many videos, yet I can't relate my code to the examples.
Arduino pin commands are fool-safed and filtered, way more than register reads. They are easier than all the caveats and steps one needs to learn direct port manipulation and btw are also slower running, digitalRead() took 5x as long as reading PINx then masking and returning a binary result.
Arduino hardware functions let beginners do something without reading a book chapter's worth of explanation they won't absorb quickly. Arduino is a SYSTEM of hardware and software made to bring all down to beginner level with a manageable amount of effort. Arduino Hello World is BLINK.
It's all free, what used to cost real money, used to take far more effort and/or school to get started. The forum and archives fill in what the Main Site starts with yet How Often Do I See References to Main Site Pages?
But OTOH I did provide links in the past and then the main Site changed, breaking those posts. The Arduino Playground went hide and seek, finding it is work I quit trying to do, there's a book for SALE on Amazon so a major free resource is pretty much GONE! Those parts are frustrating to say the least, what replaced them is a PITA to use. The links on the forum page.. were easier to use before even as the forum went trendy screen space wasting to match trendy fluff elsewhere.
We get what we get. It used to be easier to navigate to helpful answers. now it's a maze that looks more like adverts. New people might not read the ReadMe's and it's a pain trying to give links. ARDUINO, WHAT HAPPENED?
At the latest when programming multiple I/O pins and timers, it will make sense for beginners to familiarise themselves with the paradigm of procedural programming and object-oriented programming.
Arduino provides a excellent play ground to get familar with these concepts.
I started using Arduinos (and joined this forum) in 2015. It took me roughly 8 years before even looking at C++ and getting a bit of experience with it. I get away with the C that I learned in the 80s.
So I do not think that you have to teach any C++ to a beginning Arduino programmer.
I think that the most important message that you need to convey is why one should use classes (or structs): going from some variables with related information to classes.
So writing of a basic class with fields and a constructor should be covered. All fields will be public.
Next you can add / describe the use public methods. And lastly describe why one would use public/private/protected.
With the intended audience, I would stay away from anything more advanced (e.g. inheritance, base classes, templates).
C++ garbage collector in combination with deliberate string usage is a fillhorn of undetermined behaviour not only for beginners. It's especially hard to build a system that reliably does not suffer from memory fragmentation on the long run when using C++ advanced features. In the end I tell students to stick with deterministic C then garbage collected C++ when using a memory constrained system
Do you suggest to teach C instead ? it's not more difficult to get started with a C++ training and then you can get exposed to classes, etc if you want to.
OOP is not a complicated concept, it's actually simple to understand some of the concepts and it feels natural.
My $0.02... I didn't notice anyone above talking about this.
I want to point out that there are very different noobs. Some people come here to learn how to work with Arduino. and others - to solve some problem using Arduino. Their goals are very different and the level of knowledge they WANT to receive is also very different.
The latter, let’s call them "practitioners", very clearly divide knowledge into “necessary” and “unnecessary” in their project, and often directly state that they do not want to “waste time” on studying, because their goal is only to get a working device.
Should we try to teach them C? And if not, then what should we do? Give them ready-made code? Or kick them out of the forum?
After all, in principle, there is nothing wrong with the fact that a person is more interested in making an automatic lock or another hardware device, instead of learning the C language. All people are different. How to help a person who wants to assemble something with his own hands, but does not know and does not want to learn C?
I feel like there are certain "Programming Concepts" common to MOST languages that it would be helpful for beginners to learn.
What are keywords?
What are symbols?
What is a variable? How does this compare with "values" and "memory"?
What is an expression?
What is a statement? (and Block Statements)
What is a function/subroutine/etc? (and why!) (and where do the built-in ones come from, anyway?)
Basic code Building Blocks: statements, decisions, loops, subroutines. Order of execution vs order of code.
What happens to your program when it is compiled. (eg: symbol names go away, in C/C++)
What happens before your code starts?
What happens after your code ends?
What is the difference between compile-time and run-time errors?
It goes HOW fast?!
If you have ANY prior programming experience, you've probably been exposed to most of these, and ... don't really need much else to start programming Arduino. Just ... figure out how those things are done in Arduino vs your previous experience (which you can mostly do by looking at the examples.)
But part of Arduino's claim to fame is that you should be able to do things WITHOUT any programming experience, so some users are blindly copying the examples instead of using them to fine-tune their model of "how does this work."
That's a tough problem to solve - it used to be your first full semester class, more or less (although most people these days already know how to type and use a text editor, so that's helpful )
I don't THINK you need to know any C++ specific stuff. The objects provided by the Arduino core might as well just be subroutines. Serial1.print vs Serial1_print? A subtlety that MAYBE you will notice later...
You don't know so much about bit math
Probably the most important thing that Hernando Barragán did when designing Wiring/Arduino was make it standard to be able to manipulate individual pins without needing to understand anything about bit math.
All too frequently, I see "why isn't PORTB |= PB4; working?", or "PORTB3 = 1; is giving me a compile error!"
OOP did never deliver the promise given in real world applications - as has neither of the hyped programming languages. One can argue if the C++ way to do what scheme does with e.g. (apply max '(1 2 3)) is superior or not. Or if JS is more sane in that context with Math.max(...[1 2 3]);
I was referring to the OOP (classes, inheritance, overriding, ...) aspects of C++ that one happily can live without as a beginner (and even as an advanced user); I'm self-taught and the only difference I'm aware of (if omitting OOP aspects) is passing references to functions.
There are certainly documented critiques surrounding the effectiveness and limitations of OOP in real-world applications but whether OOP has universally failed to deliver on its promises is subjective.
In practice, OOP is being widely used and has proven to be effective in many scenarios, contributing to the development of countless successful software applications and systems.
I've the same background in terms of learning procedural, structured programming first (but I have a few software engineering degrees) ➜ I get what you say — but if you put yourself in the shoes of a beginner who has never learnt procedural or structured programming and is trained with OOP concepts, you would see that it feels quite natural (I've tested this with teenagers).
It's not a complex concept to grasp to identify "classes of objects" in your code (sensors, devices, hardware features, ...) .
See how many people happily use Serial or an LCD instance or a multiple sensors instances in a project and it feels natural as you have a mental representation of what it is. You don't care about the inner workings, you just ask the LCD to print something, in the same way you ask the Serial line to print something.
Writing reusable classes and hierarchy of classes requires more skills of course and you can indeed live without that — but sometimes at the expense of code clarity.
C++ lets you write both in plain procedural, structured way or use OOP concepts. best of both worlds
Especially in small RAM environments, avoid dynamic memory use like Ebola! Do not use the Container Classes, including String!
Plan memory use from the start.