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

Discussion in 'Programmer's Corner' started by iv0live, Apr 25, 2015.

  1. iv0live

    Thread Starter New Member

    Feb 1, 2015
    4
    2
    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.
     
  2. Papabravo

    Expert

    Feb 24, 2006
    10,148
    1,791
    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?
     
    cmartinez likes this.
  3. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,810
    834
    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.
     
  4. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,689
    2,750
    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.
     
  5. Papabravo

    Expert

    Feb 24, 2006
    10,148
    1,791
    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: May 10, 2015
    Eric007 likes this.
  6. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,810
    834
    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.
     
  7. WBahn

    Moderator

    Mar 31, 2012
    17,757
    4,800
    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.
     
    Papabravo and iv0live like this.
  8. cmartinez

    AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    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...
     
    absf and Papabravo like this.
  9. Papabravo

    Expert

    Feb 24, 2006
    10,148
    1,791
    Programming Languages are kinda like Lay's potato chips. Betcha can't eat just one!
     
    cmartinez likes this.
  10. cmartinez

    AAC Fanatic!

    Jan 17, 2007
    3,574
    2,543
    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: Apr 26, 2015
  11. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,606
    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.
     
  12. nsaspook

    AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    What's more important than learning A programming language is knowing the language OF programming in the long run. At this stage programming is still more of an craft or art not a complete science but it does have rules and methods that allow you to engineer a good foundation to build on with any language.

    I would suggest this book: http://www.amazon.com/The-Elements-Programming-Style-Edition/dp/0070342075
     
  13. bertus

    Administrator

    Apr 5, 2008
    15,648
    2,347
    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
     
  14. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,810
    834
    Arduino uses a C like style.
     
  15. bertus

    Administrator

    Apr 5, 2008
    15,648
    2,347
    Hello,

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

    Bertus
     
  16. nsaspook

    AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    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.
     
    Brownout likes this.
  17. iv0live

    Thread Starter New Member

    Feb 1, 2015
    4
    2
    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?
     
  18. Papabravo

    Expert

    Feb 24, 2006
    10,148
    1,791
    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.
     
    cmartinez and iv0live like this.
  19. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,810
    834
    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.
     
  20. nsaspook

    AAC Fanatic!

    Aug 27, 2009
    2,910
    2,173
    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 (Text):
    1.  
    2. /* called for each listed spigert device in the bcm270*.c file */
    3. static int spidev_spi_probe(struct spi_device *spi)
    4. {
    5. struct comedi_control *pdata;
    6. int ret;
    7.  
    8. pdata = kzalloc(sizeof(struct comedi_control), GFP_KERNEL);
    9. if (!pdata) return -ENOMEM;
    10.  
    11. ... just dump out or do stuff ...
    12.  
    13. pdata->tx_buff = kzalloc(SPI_BUFF_SIZE, GFP_KERNEL | GFP_DMA);
    14. if (!pdata->tx_buff) {
    15. ret = -ENOMEM;
    16. goto kfree_exit;
    17. }
    18. pdata->rx_buff = kzalloc(SPI_BUFF_SIZE, GFP_KERNEL | GFP_DMA);
    19. if (!pdata->rx_buff) {
    20. ret = -ENOMEM;
    21. goto kfree_tx_exit;
    22. }
    23.  
    24. ...  free alloc memory or do stuff ...
    25.  
    26. /* Check for basic errors */
    27. ret = spi_w8r8(spi, 0); /* check for spi comm error */
    28. if (ret < 0) {
    29. dev_err(&spi->dev, "SPI not working\n");
    30. ret = -EIO;
    31. goto kfree_rx_exit;
    32. }
    33. if (!(spi->mode & SPI_NO_CS) &&
    34. (spi->chip_select > spi->master->num_chipselect)) {
    35. dev_err(&spi->dev,
    36. "setup: invalid chipselect %u (%u defined)\n",
    37. spi->chip_select, spi->master->num_chipselect);
    38. ret = -EINVAL;
    39. goto kfree_rx_exit;
    40. }
    41. return 0;
    42.  
    43. ... free memory ...
    44.  
    45. kfree_rx_exit:
    46. kfree(pdata->rx_buff);
    47. kfree_tx_exit:
    48. kfree(pdata->tx_buff);
    49. kfree_exit:
    50. kfree(pdata);
    51. return ret;
    52. }
    53.  
     
    cmartinez likes this.
Loading...