What is the recommended programming language one should learn, when learning electronics?

Thread Starter

iv0live

Joined Feb 1, 2015
4
I mean as additional knowledge that can be useful in the long term.
Also please give some clarification as to why choose one over another.
 

Papabravo

Joined Feb 24, 2006
21,157
I don't think there is a recommended language. IMHO you should learn every language that you can find information about. Haw can it hurt you to be multi-lingual?
 

djsfantasi

Joined Apr 11, 2010
9,156
Start with one that suits the problem at hand. Then, after you've had success in that one, learn a second.

From that point on, learning new languages get easier. For often, it's not the language that you will learn, but the algorithms to solve a problem. Those algorithms or programming techniques are almost universal.

Don't have a problem at hand? What are you looking to program? Learn the language of that device, be it PIC, 8051, Pi, Arduino and it's variants... Then the next and so on.
 

Papabravo

Joined Feb 24, 2006
21,157
Many will disagree with me: If you are going to program microcontrollers, learn .asm first (for a MCU of your choice). You can always learn C later, but at least then you'll have an understanding of what goes on on the inside.
No argument from me on that score. My first assembly language was for a piece of BIG iron*.

*Edit -- FAP (FORTRAN Assembly Program) for IBM 7090
 
Last edited:

djsfantasi

Joined Apr 11, 2010
9,156
I don't think the order is important. As a matter of fact, I think ASM is easier to learn as a later language. My sequence was Fortran, LISP, Basic, Pascal, Algol, COBOL, ASM, Perl, Java, C. (To the best of my memory, which means no guarantees )

As I mentioned above, a good foundation in programming algorithms is important. Having that before programming in ASM made it easier.

Don't get me wrong! I believe ASM should be in every programmer's toolbox.
 

WBahn

Joined Mar 31, 2012
29,976
Depends on what you are going to do. If you are going to be programming FPGAs and the like, I'd recommend either VHDL or Verilog. If you are going to be programming small microcontrollers, I'd recommend assembly following by C. If you are going to be programming larger embedded systems having operating systems, I'd probably recommend C plus a good understanding of Linux (which is probably the O/S being used). If you are working at a higher level and your programs are supporting your electronics work (as opposed to be a part of the system itself), the Matlab is likely one useful candidate as well as just getting good at using spreadsheets.
 

cmartinez

Joined Jan 17, 2007
8,218
I don't think the order is important. As a matter of fact, I think ASM is easier to learn as a later language. My sequence was Fortran, LISP, Basic, Pascal, Algol, COBOL, ASM, Perl, Java, C. (To the best of my memory, which means no guarantees )

As I mentioned above, a good foundation in programming algorithms is important. Having that before programming in ASM made it easier.

Don't get me wrong! I believe ASM should be in every programmer's toolbox.
My first love was BASIC... and later I learned Pascal and COBOL (may they both RIP)... learning C was a pain in the you-know-what, but it taught me the importance of keeping things structured, orderly, and well-commented. Later on I became a LISP expert for AutoCAD, and finally... I learned ASM for the 8051 MCUs.... now I feel that maybe I should've learned that last one first...
 

cmartinez

Joined Jan 17, 2007
8,218
Programming Languages are kinda like Lay's potato chips. Betcha can't eat just one!
And I'm still looking for challenges!.... Truth being told... I haven't bothered to learn Java or Perl... yet. Maybe soon I'm going to find myself cornered into taking a dip in them.
But computer languages are definitely NOT like riding a bicycle... if you don't practice them you will forget. I see them more like musical instruments instead.
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
First programming languages are like butt holes. Everyone has one and things theirs is the only one that doesn't stink.

Anyone who does programming on any sort or regular basis knows many many languages depending on what they are doing at the moment, and what platform they are doing it on. At the core all programming languages kinda sorta all do the same thing. Some make certain things easier, some make every thing incredibly hard.

So anywhere you start will get you where you want to be. And one day you will have forgotten even the names of a large part of the languages you once used.

I would start with something where you can see your results fast. PC computers are nice to work on so something like the free Visual Studio Express package is something to look at. I would try getting Visual Basic to do some things for me.

Assembly language is a concept and not a language as every device may (and most always does) have it's very own custom language. I don't recommend stating there at a "higher level" unless you want to do things like learn how to write a division routine when you are still trying to figure out how to write any program at all.
 

bertus

Joined Apr 5, 2008
22,270
Hello,

It depends on what you want to do with the programming.
An Raspberry Pi uses Python for the programming.
An Arduino uses a Basic like style for the programming.
PICs and AVRs can use several laguages like C or assembly.

Bertus
 

nsaspook

Joined Aug 27, 2009
13,079
Hello,

Ok, I am not that familiar with the Arduino.
I just started with a Raspberry Pi 2 over here.

Bertus
I'm loving my RPi 2 here. Most of my programming is in C at the kernel level where C is just a high level assembler for the Linux abstract machine.

I would tell a person to have the C language in the tool-box as the first electronics related computer language. It has the structure to do what the books teach you and the freedom to do it the 'quick' way when needed.
Most of the books say don't use 'goto', it's bad style. (something that BASIC makes too easy) That's great if you have lots of cycles to kill but in an embedded systems you usually don't, so properly using explicit jumps in structure just to terminate execution is sometimes the 'best' answer.
 

Thread Starter

iv0live

Joined Feb 1, 2015
4
I don't think there is a recommended language. IMHO you should learn every language that you can find information about. Haw can it hurt you to be multi-lingual?
The only problem to be multi-lingual is that it takes lots of time.
For example i've heard that it takes lots of years to master C++.
I would rather focus on a single language. The one that would be most useful.

As a side note, i also don't understand why so many programming languages do exist.
Just like speaking languages, wouldn't it be better to have just one that does the work.
I mean wouldn't it be better if all the people in the world spoke the same language?
 

Papabravo

Joined Feb 24, 2006
21,157
Anything worth doing is worth spending a great deal of time on. The reason there are so many languages is that there are an even larger set of problems and no one language is adequate for the solution of all problems. Focusing on the "single language that would be most useful" is a certain guarantee that your skills will become obsolete in the blink of an eye. Better to be flexible and have a wide range of skills.
 

djsfantasi

Joined Apr 11, 2010
9,156
BASIC doesn't have the loop structures (except for BASIC-based languages like FreeBASIC) to make eliminating Goto commands simple. The use of Boolean variables, properly constructed code blocks controlled by While or Switch statements and judicious use of the C Break statement will eliminate most Goto statements AND result in clearer code.

I've implied in earlier posts that I agree with @nsaspook. Programming style is as important, if not more so, than the languages. Standard programming structures or algorithms are language agnostic; can be applied to Asm, C, Php,... etc.
 

nsaspook

Joined Aug 27, 2009
13,079
BASIC doesn't have the loop structures (except for BASIC-based languages like FreeBASIC) to make eliminating Goto commands simple. The use of Boolean variables, properly constructed code blocks controlled by While or Switch statements and judicious use of the C Break statement will eliminate most Goto statements AND result in clearer code.
I limit the use of C goto to this type of function, where failure is fatal and we need a bug-out shortcut to quickly run a simple sequence.

Code:
/* called for each listed spigert device in the bcm270*.c file */
static int spidev_spi_probe(struct spi_device *spi)
{
struct comedi_control *pdata;
int ret;

pdata = kzalloc(sizeof(struct comedi_control), GFP_KERNEL);
if (!pdata) return -ENOMEM;

... just dump out or do stuff ...

pdata->tx_buff = kzalloc(SPI_BUFF_SIZE, GFP_KERNEL | GFP_DMA);
if (!pdata->tx_buff) {
ret = -ENOMEM;
goto kfree_exit;
}
pdata->rx_buff = kzalloc(SPI_BUFF_SIZE, GFP_KERNEL | GFP_DMA);
if (!pdata->rx_buff) {
ret = -ENOMEM;
goto kfree_tx_exit;
}

...  free alloc memory or do stuff ...

/* Check for basic errors */
ret = spi_w8r8(spi, 0); /* check for spi comm error */
if (ret < 0) {
dev_err(&spi->dev, "SPI not working\n");
ret = -EIO;
goto kfree_rx_exit;
}
if (!(spi->mode & SPI_NO_CS) &&
(spi->chip_select > spi->master->num_chipselect)) {
dev_err(&spi->dev,
"setup: invalid chipselect %u (%u defined)\n",
spi->chip_select, spi->master->num_chipselect);
ret = -EINVAL;
goto kfree_rx_exit;
}
return 0;

... free memory ... 

kfree_rx_exit:
kfree(pdata->rx_buff);
kfree_tx_exit:
kfree(pdata->tx_buff);
kfree_exit:
kfree(pdata);
return ret;
}
 
Top