Re: How much C++ does a noob need?

Teach coding or teach begging or worse?

Entrepreneur HEAVEN is not paying to get a device working!
Sure, there needs to be fewer jobs writing code, right?

Degree chasing slackers who become Management/Entrepeneurs build whole skill sets on getting free code. Don't encourage them!

I'd rather give code or clues that show what to do. Too many times I find that they pretended to understand... and get very disappointed over what isn't exactly what they want.
Give them a fish and they'll come back when they're hungry. Try and teach them to fish, too much like work! Feed me!

I can confirm that this is the best way to develop and programme projects in the Arduino world.

you can teach/write object oriented code -- code based on data and functions operating on that data -- without needing to use/know the syntax of classes.

To some extent.

I could see a couple notation worth knowing :

  • the dot notation to call a member function is needed.
    Serial.print();

  • sometimes the :: scope resolution operator
    AccelStepper stepper1(AccelStepper::FULL4WIRE, 2, 3, 4, 5);

I like @Robin2's tagline:

Two or three hours spent thinking and reading documentation solves most programming problems.

For instance ".", "->", and "::" docs are available from C++ Operator Precedence - cppreference.com

In terms of "How much X does Y need?" I'd think the answer is "Enough to solve Y's problems."

Wouldn't it be cool if there was a feature in the IDE that we could toggle that automatically allowed little definition/info popups when the mouse is hovered over say, the # in #define and so on? The list provided by @westfw would be a great list to use to add such a feature, imo.

Arduino IDE 2.x does have something like that. For example, here is what you get if you hover the mouse pointer over a pinMode call:

However, you don't get a hover for basic syntax and keywords. So it is useful for getting information about the Arduino core API and libraries, but not for learning the fundamentals of the C++ language.

Oh, cool! I'm a luddite running 1.8.10 so I wasn't aware.

An absolute beginner has three hurdles.

Gain an ability to describe a process or algorithm in steps that can be performed by the microprocessor.

Understand the nature of embedded systems programming. Inputs and outputs, communication with sensors and a raft of trouble with motors and wiring and power supplies. And so forth. Electronics 1.01 plus a bit.

And

The particular pesky details of the computer language being used.


My opinion is that C++ is not needed. Some hand waving around the little bits of C++ that are seen, like Serial.pritn() or just about every library is enough.

Libraries can usually be used by following examples slavishly, and exploiting them in one's code without deviating. Many libraries can be installed, a bit of obscure initialization and or set up pasted in and then the use is straight ahead.

Like neopixels. Once you get it squared away, there's only changing the colour of a pixel and publishing the strip. Every other problem or challenge is a matter of programming to the process or algorithm. or a power supply issue. :expressionless:

My opinion is that C++ is not needed, and I can go a bit further to say that putting C++ in front of an absolute beginner is counterproductive. Even C lacks a gentle introduction path, but it is far less daunting even in the first hour.

Just like some features of C can wait until the need for them becomes painfully obvious (functions and arrays and structs, e.g.), most of what separates C++ from C is probably easier to learn for someone who knows how to program in any style in any language for any purpose.

Someone for whom that language is C is many steps ahead. Someone already doing embedded systems work has an advantage. And someone already using OOP concepts as can be practiced in whatever language they know will get further sooner.

I will always tell noobs to learn C. Not just get a bit of it under your hat, but really learn it. Probably best in the context of getting a few LEDs to do things based on a few buttons and things like that.

As for "an ability to describe a process or algorithm in steps" goes, I'm surely not the only one who can't remember ever not being able to do, and who has spent a good deal of time thinking about how that might go.

I will say in my experience there are ppl who are just not going to make good programmers, whatever else they might be talented enough to pull off. I don't think we see many of the ppl Prof. Molzberger was referring to when he said "you can't teach a jerk to program" around here…

a7

that's no longer learning C++ :wink:

sure, it's possibly and you can stop at those using a C++ training and never go visit classes in details. The C++ training I've seen start by the basics anyway

I don't know.. Java is one of those languages where everything is a class, so yeah, you don't go far indeed if you don't embrace that :slight_smile:

Apple has 2.2 billions+ devices out there running Objective C, C++ and Swift code... that's a sizeable market for OO apps...

A C function with pointers to data and a state machine with cases that have functions or pointers to functions can do what a Class does, just not as cleanly.
With less work, a function can operate as an object, it has been demonstrated here many times.

Doing block record file work with fields all set up (many languages) is a step in that direction it took me years to understand, now over 40 years ago after Forth set me free.

There's views and there's tools, once you see through you can take what you want and use it as you can. The object view is very powerful, no bout adout it!

The programmer needs to understand what they are doing,
otherwise they make half-fast work as useful as Micro$oft Help.

there's no need for a structure containing function ptrs

you can define a data structure and a set of functions to operate on that data structure where a ptr to the data structure is passed as an argument to the functions. This can be done in C

Everything I suggested works with plain C.

There's no need until you want to flex the code creatively, then it becomes another way to achieve generality. I don't foresee it used on Arduinos but I do see it could be used.

I've done in customer-had-to-have basic... after Forth set me free!

the earliest example i read of what i later learned was object oriented is symbol.c (Unix Programming Environment pg 248, pdf pg 260).

talking about succinct, the authors described the development of a small yet fairly complete scripting language in one 56 page chapter and the chapter, Program Development wasn't about small languages

That's a good book :+1:

getting one step closer to OOP : )

that's a .c file so you would not expect cpp constructs in it anyway (but I get your point)