Code Programing

There's a lot of danger in learning 'some C'. It's a fantastic language, and the lingua franca of the embedded world (though C++ is making more inroads all the time), but it has possibly more ways to shoot yourself in the foot than any language I've used - and I've used more than a few. As @WobblyHand noted, it's not the language for extreme productivity, it's the language of extreme economy in time and memory. Only assembly could be any more sparse. But, you really need to know the device you're programming, understand the different types of memory (storage duration) that you're using, and grok Undefined Behavior. A little C is a dangerous thing. You can put something together that appears to work - maybe today, or every other run, or for the next month or year before it suddenly stops working, and without a deep understanding (sometimes even *with* a deep understanding...) the reason can be incredibly hard to suss out. Don't get me wrong, I think learning C is great, but only if you commit to really learning C - a process that will take quite some time.

GsT
It's a relatively hard language, but it's not that bad. There's many ways to get into trouble with any programming language. To be honest, the worst sort of thing in micro-controllers is if you point to undefined memory or execute out of undefined space and random (bad) stuff happens. If you are controlling big things, then really bad stuff can happen. Depending on what it is, it could kill you, no joke.

Just take a basic Arduino like processor - any at this point, and start with the basics. The entry price is cheap, and you will soon know if it is for you, or not. Some cheap Nano AT328 for $5-6 could at least get you practice. Add some LEDs and buttons, and you can check your programming skills.

Get your dumb mistakes over with little projects while the consequences of mistakes don't matter! It will take awhile, but the only way to learn is to read, AND PRACTICE. Reading just isn't good enough, you have to do it. Screw up as much as you can, as early as you can - and learn from it. This is the way towards proficiency. It takes time and effort, there's no short cut, at least to my knowledge.
 
For this particular use case, wouldn’t it actually make sense to learn C/C++ as the first language.

I’d encourage @Just for fun to go for it! It can be done and has been done. The O’Reilly learning platform’s 10-day free trial is a good staring point :encourage:
If you're already a competent programmer yep (or you're lucky and there was a programmer inside you trying to get out all this time).

The OP does not sound like that (which is no criticism of the OP; the vast majority of people get through life never having to touch a single line of code).

For people who have never programmed before, C/C++ is nobody's idea of a good starting language. Leaving aside the mess one can get oneself into with memory management, it's simply not a beginners language, syntax-wise.

Programming (or rather, programming well; bad code is much easier to create) is one of the harder cognitive activities humans do, and learning to do it well enough not to regret attempting it is best done with a language that has some accommodation for beginners.

The OP would be best advised to learn how to program first and then learn how to write code for controllers and only then learn C.

Let me put this another way: apprentice machinists do not start out learning how to use an indexing rotary table, they start with a vice, a chunk of mild steel and a file.

I've been a software engineer for nearly 30 years and whilst I have on occasion had to work on C++ codebases and managed okay (I get paid to write complex functionality, I ought to be able to cope!), higher level languages (mainly Java and C# these days) make me much more productive and I definitely introduce fewer nasty, hard to track down bugs in those languages.
 
Thanks for all the great responses. I really wasn't looking at becoming a full fledge programmer. Well really, I wasn't planning on programming anything. I was just thinking it would be nice to have a basic idea of what I was looking at when looking at the code.

But now after all of the responses I'm thinking I should at least pick up one of the basic Arduino kits and get my feet wet.

And the other thing that caught my eye was the Python language. Correct me if I'm wrong but isn't that what is used in FreeCAD? So that sounds like something I should look into.

I actually have done a little computer programing years ago if you can call it that. Probably 1981 or 82 I had an Apple IIe and did some basic programing. Lots of IF Then and Go To commands. LOL
 
Thanks for all the great responses. I really wasn't looking at becoming a full fledge programmer. Well really, I wasn't planning on programming anything. I was just thinking it would be nice to have a basic idea of what I was looking at when looking at the code.

But now after all of the responses I'm thinking I should at least pick up one of the basic Arduino kits and get my feet wet.

And the other thing that caught my eye was the Python language. Correct me if I'm wrong but isn't that what is used in FreeCAD? So that sounds like something I should look into.

I actually have done a little computer programing years ago if you can call it that. Probably 1981 or 82 I had an Apple IIe and did some basic programing. Lots of IF Then and Go To commands. LOL
Do get your feet wet with Arduino, you can learn a lot with one. The cheap ones aren't that powerful, but you can do a lot of little automation tasks, or make little amusing gizmos. It does help exercise one's mind, which is generally a good thing.

Python is used in FreeCAD. One can extend parts of FreeCAD using Python. Many of the macros in FreeCAD are written in Python.

You should be able to download a relatively simple python IDE (integrated development environment) and be able to learn quite a bit. There are lots of online resources to learn the language. I was self taught, and learned it on the job, while doing other stuff, so I'd expect you'd be able to pick it up rather quickly if you have any time to apply yourself.
 
While Arduino boards are low powered, it's relative. You can do a LOT with one, and it's plenty fast for 90% of what people want an embedded device for. They ran all 3D printers for a really long time. Cheap and good enough. Sure, an ESP32 or teensy makes it look slow, and disconnected. :)

One advantage of the faster chips is the ability to run things like Python without any real slowdown. The slower stuff can struggle with it, but newer chips can handle it easily.
 
Not to be a downer, but why not ask Clough42 if any of this is even necessary?
 
@jwmay It's definitely not necessary. I have my ELS system up and working, and it works great.

On my original post I mentioned Clough42 and the ELS system as that was my first exposer to code. I have heard about people writing code to do this or do that but never had seen it. I just thought it would be nice to know a little more about code programing.
 
Interesting topic.
So, what language would a person use other than C/C++ to program something like an Arduino or Raspberry Pi to operate a small test apparatus, for example, that operates on air or electricity? I have been thinking about dipping my toes into it for developing tests at work.
 
So, what language would a person use other than C/C++ to program something like an Arduino or Raspberry Pi to operate a small test apparatus, for example, that operates on air or electricity?
Rust is becoming more and more popular for programming microcontrollers. It has various advantages over C, such as memory safety and of course, is way easier to learn.

The official Rust community is to be avoided though. The last time I checked, it was more focused around the users' preferred pronouns than coding.
 
Last edited:
Rust is becoming more and more popular for programming microcontrollers. It has various advantages over C, such as memory safety and of course, is way easier to learn.
Great call. :encourage::encourage::encourage:

I've only had the briefest of plays with Rust but rather liked it. Nobody is going to ask for a product written in Rust where I work, so it'll probably continue to be of academic interest to me but if someone really wants to learn programming and feels they have a brain that suits (learning to write good code at any non-trivial level, requires an engineering type mind) Rust looks to be an excellent candidate.

The official Rust community is to be avoided though. The last time I checked, it was more focused around the users’ preferred pronouns than coding.
I absolutely don't want to turn this into any kind of discussion about anybodies perspective on any social or political issues (people should believe what they believe, think what they think; it's absolutely none of my business what goes on anybody else's head;)) but I don't really feel the impression you're giving is entirely accurate, and might put some people off.

Here's a reddit post from the creator of Rust about this:

Well, I wrote the initial CoC and put the "We will exclude you from interaction" phrase in there, so maybe I'll mention the impetus and meaning.

I was given the opportunity to start a language project by my employer, Mozilla corp. I'd had the experience of working -- both professionally and on volunteer time -- with many PL communities in the past. Communities that were prone to several norms of discourse that I found extremely difficult to deal with, that would have prevented me, and several people I knew and wanted to work with, from bothering to work on a language at all. In other words: I would not have built the language, nor participated in a project of building the language, if I had to subject myself to the kind of discourse normally surrounding language-building communities.

In other other words: the norms of _other_ communities were already excluding _me_.

So I wrote down the norms and behaviours that I knew chase people away (including myself) and said look, in this community I'm setting up, on these servers that my employer is paying for and paying me to moderate, this behaviour is not welcome. It's a big internet and we can't prevent people from behaving how they like in their own spaces, but we can control who we interact with in online spaces we set up. So these are the ground rules for those spaces.

I was careful to chose the phrase "exclude from interaction" because, in practice, that's all one can control on the internet, and it's silly to pretend one has more control over a situation than one does. I can't control what you do on your time, on your own servers, on your corner of the internet. I can only control _who I interact with_.

As it's happened, lots of people felt the same way: the rust community has attracted and retained a lot of people who _did_ feel they were repelled from other PL communities because they're so aggressive, so abusive, so full of flaming and trolling and insults and generally awful behaviour, that they had given up even participating. Many people have found a home in the rust community that they had not been able to find elsewhere.

Some people, naturally, feel that the norms spelled out in the rust CoC makes _them_ feel excluded. To which all I can say is, yes, it's true: the rust CoC focuses on behaviour, not people, but if there's a person who _cannot_ give up those behaviours, then implicitly it excludes such a person. If someone just can't get their work done effectively or can't enjoy themselves without stalking or harassing someone, or cracking a sexist or racist joke, or getting into a flame war, or insulting their colleagues, I suggest they go enjoy the numerous other totally viable language communities.

Or heck, fork the community if you like. Make the "rust, but with more yelling" community. Big internet. Knock yourself out.

So basically in this post, Graydon is saying that his intention with the Rust official community code of conduct was to exclude those who refused to, or were unable to stop themselves behaving in specifc ways; specific ways that the owners of the sites that the Rust official community is hosted on, saw as unacceptable to them.

Which is fair enough, really. If one can't or won't moderate one's behaviour to fit in with the norms of a privately owned and hosted community space, then those that pay for/host/put the effort into creating/maintaining have the right to show one the door. I personally rather like the transparency and upfrontedness of his approach.;)

The reddit thread is actually worth a scan through (as much as any reddit thread is:grin:).

As I suggested above, I just wanted to clarify Graydon's intentions as he stated them, so people didn't get the wrong impression; not to start a discussion on the rights and wrongs of his (or indeed my) social or political views. :)
 
Back
Top