Too many programming languages? - Page 1
Forum section: electronics / general

author: bjdhjy888
author_rank: Regular Contributor
timestamp: September 24, 2019, 12:29:52 am
content: When it comes to learning programming languages, I'm often overwhelmed. The currently popular ones include but not limited to C, C++, C#, Java, Python, etc. You name it, you gotta learn them!I think one should master one specific programming language, rather than being an expert of all.The thing is, as an electronics engineer, which one should I learn most!?p.s.: and one programming language's introduction textbook is often as thick as a brick used in the Empire State Building.

author: wraper
author_rank: Unknown
timestamp: September 24, 2019, 12:35:52 am
content: For MCU you are basically limited to C (8 bit) and C/C++ (ARM) for any serious use. And then there is Verilog/ VHDL if you want to use FPGA.

author: Mechatrommer
author_rank: Super Contributor
timestamp: September 24, 2019, 12:36:22 am
content: it been discussed many times everybody with opinions... but i tell you only once this time and then no more... if you want to risk obsolescence and have to relearn new language in the future, learn anything other than C/C++ now mix up your mind with what replies that will come...

author: RoGeorge
author_rank: Super Contributor
timestamp: September 24, 2019, 12:44:39 am
content: Quote from: bjdhjy888 on September 24, 2019, 12:29:52 amC and Python

author: beanflying
author_rank: Super Contributor
timestamp: September 24, 2019, 01:09:58 am
content: As someone who started programming with Basic/QBasic then Fortran and Pascal and punching Hex codes into 6800 Micros it's all easyI got back into programming Micros after a long long time away and like the others C or C+ makes most sense as a gateway to some of the others. Java is maybe on the way down compared to only a few years ago but Python is on my list of really must get some skills in.Instead of a textbook and killing a few trees grab the Arduino IDE and a starter kit depending on where you already are. Run through the stock bits then come up with a job of your own and start to learn how to write your own. This worked for me and to get the rusty brain wheels turning again. Then kick onto other Micros. None of the skills learned with this step will be wasted moving forward.

author: knapik
author_rank: Regular Contributor
timestamp: September 24, 2019, 03:27:11 am
content: Definitely learn C as its the must know language for anything related to embedded design.When it comes to general programming for PCs, languages start to be chosen as the right tool for the right job, so the diversity can be quite handy. Most of thepopularprogramming languages mainly boil down to C-like with object oriented programming built in, so learning C is a good stepping stone.

author: MarkF
author_rank: Super Contributor
timestamp: September 24, 2019, 03:54:31 am
content: Since I started programming in the late 1970's, I have used various assembly languages, Fortran, Ada, C/C++ and some Java. In the last few years I've seen a call for C/C++ for application work and Java for web based interfaces.On top of all that are all the different graphic and GUI needs. The last place I worked at started requiring programs to be written with Qt because they needed to be cross-platform (Windows and Linux). And don't forget database work is big too.Most of my work was done on mainframe machines. Since PCs have grown much more powerful, they are going away except for specialized cases.I would definitely start with C/C++ and Java for general applications. Just take a look at jobs being advertised (Indeed for example).I would say skip the punch cards and paper tape that I had to deal with.Edit: Programming is logic. Language is syntax. Simple...

author: CatalinaWOW
author_rank: Super Contributor
timestamp: September 24, 2019, 04:34:29 am
content: There are too many languages. But it is the way it is so you will have to deal with it.1. Once you have learned one procedural language the others will come relatively easy. Don't fret too much over which one you learn first.2. They are all hard unless you sit down and code in them. Few people can learn any of these languages by reading a book. That means that a language fits your current situation should be your first language. Whether it is a programming course in school, a lab in school, a work project or a hobby project the need to generate code to solve your problem will force you to learn the language at hand, and most of these situations come with a predefined language requirement.3. Your later languages will follow this pattern - you will pick them up as needed for the current task. Even within a language you will be relearning different flavors as time goes on.If these methods still leave you unsure where to start you can do worse than to start with either Python or C. Both have broad application in engineering and will likely be around for at least a decade or two more, giving you plenty of time to learn whatever might displace them.

author: techman-001
author_rank: Frequent Contributor
timestamp: September 24, 2019, 04:49:54 am
content: Quote from: bjdhjy888 on September 24, 2019, 12:29:52 amIt depends on what you want to do. You said you're a electronics engineer so I'll assume you meant embedded control.This is a contentious and flame prone question, and no doubt will soon devolve into rants, fud and being closed by the admins, especially if one offends the Gods of C, but before it gets that far I recommend :-Low level you can't beat ForthHigh level you can't beat ForthSo my advice is Forth. It's not 'popular' like C, but it's simple enough that you can learn all of Forth and even write your own Forth in a decade or so providing you put in some effort every day. After that you can hold the entire concept in your head.You will need to be fluent in Assembler for your chip type(s) but you can learn Assembler as you learn Forth, they compliment each other.It's quite unlikely you can learn all of C and write your own comprehensive C compiler in that same time frame.Here is a Forth sample: I recommend asking other programming language advocates to submit their code for this same task so you can compare them. Note I didn't need any libraries, there are no hidden include files, everything is present here for a STM32F0xx, Cortex-M0 MCU.This Program calculates baudrates by reading the MCU configuration. Only works with USART1 16 bit oversampling which is the reboot default and will exit if 8 bit oversampling is in use.It uses Mecrisp-Stellaris s31.32 fixed point support to calculate the Baudrate to two decimal places so you can choose the best BRR integer to use when setting up your terminal baudrate.More information about Forth is available in my SIG below.................... start.................$40021000 constant RCC ( Reset and clock control )RCC $4 + constant RCC_CFGR ( Clock configuration register RCC_CFGR )$40013800 constant USART1 ( Universal synchronous asynchronous receiver transmitter )USART1 $0 + constant USART1_CR1 ( Control register 1 )8000000 constant clock \ default, change if not.: rcc_cfgr_pllmul? ( -- ) %1111 18 lshift $40021004 @ and 18 rshift ; ( PLL Multiplication Factor ): clock_multiplier? ( -- ) RCC_CFGR_PLLMUL? 2 + ; \ clock multiplier value: usart1_cr1_over8? ( oversampling8? -- true ) %1 15 lshift usart1_cr1 bit@ ; \ oversampling mode. reboot default: 16: oversampling? ( -- )usart1_cr1_over8? if ." USART: 8 bit oversampling ! MUST use 16 bit oversampling" exit then;: >s31.32 ( u -- s31.32 ) 0 swap ; \ convert to a s31.32 number: brr? ( desired baud rate -- brr ) \ brr = ((pll multiplier * clock)/desired baud)/2>rclock_multiplier? clock * >s31.32 \ calculate bus clock, convert to s31.32r@ >s31.32 \ desired baud ratef/ \ f. divide2 >s31.32 \ last step is divide by 2f/ \ f. divide2 \ only display 2 comma places." for a baud rate of " r> . ." the usart1_brr should be: " f.n cr;: baud? ( -- ) cr croversampling?." CLOCK: " clock . ." PLL multiplier: " clock_multiplier? . ." BUS CLOCK: " clock clock_multiplier? * . ." Hz " cr115200 brr?460800 brr?921600 brr?1843200 brr?cr;......... end............\ Output\ baud ?\\ CLOCK: 8000000 PLL multiplier: 6 BUS CLOCK: 48000000 Hz\ for a baud rate of 115200 the usart1_brr should be: 208,33\ for a baud rate of 460800 the usart1_brr should be: 52,08\ for a baud rate of 921600 the usart1_brr should be: 26,04\ for a baud rate of 1843200 the usart1_brr should be: 13,02

author: MarkF
author_rank: Super Contributor
timestamp: September 24, 2019, 05:53:39 am
content: I'm sorry. But I have never seen a military or commercial contract that requested Forth be used.I worked for someone years ago who loved Forth solely for how much he could do in 'one' line of code.@techman-001 appears to be another. Not a reason to invest time learning Forth.And as far as Assembler, you would have to be doing something very very critical NOT to use a higher level language. Even for todays microcontrollers.The customer will always opt for the 'readability' and 'long term support' of a high level language.I have seen 5000+ line Assembly programs. It is NOT going to happen any more.Unless it is for a home project. Then have at whatever suites your fancy.If you are looking for a career, stick with the main stream languages.

author: Berni
author_rank: Super Contributor
timestamp: September 24, 2019, 05:58:34 am
content: As others have said CNot only is it a popular language that is similar in syntax to a lot of others, but it also teaches you a lot of low level things about how computers work, yet is high level enough to be useful for large projects.If you are going to be programming modern microcontrollers you are going to be using C/C++ because this is what everyone else uses.If you are going to be programing for PCs then the choice is a lot more broad as the resource hunger of bigger languages is not a problem due to how powerful PCs are. There you might be looking at C#, Java, Python... And if you work with web applications then also PHP, Javascript, Ruby...

author: tggzzz
author_rank: Super Contributor
timestamp: September 24, 2019, 07:55:10 am
content: Quote from: bjdhjy888 on September 24, 2019, 12:29:52 amYou should learn the concepts, advantages and disadvantages of one example of eachtypeof programming language. That will enable you to choose the right tool for the job, just as you should know whether to use screws, or nails, or bolts. Once you know the concepts, picking up the next language of that type is simple.So, what types are there?Procedural: C is the best choice.Object Oriented: Java is the best choice, C# is a me-too version of Java, C++ is an abortionate mess whereknowledgablepeople spend a lot of time arguing over what ought to happen. Neither Java nor C# are for embedded applications.FPGA: either Verilog or VHDL.Multicore/multithreaded: xC for embedded, since that has the only decent theoretical and practical pedigree - and its concepts appear in more mainstream languages.Statistics: I'll leave others to comment.General purpose "get answers soonest": Python.System simulation: that entirely depends on the application domain, and you won't have much choice.

author: techman-001
author_rank: Frequent Contributor
timestamp: September 24, 2019, 10:08:53 am
content: Quote from: MarkF on September 24, 2019, 05:53:39 amThere is no need to be sorry, the OP didn't mention "military or commercial contracts" or even career, this is all you. I do note that you have left out "space". This is a list of 64 space/military projects that featured Forth.https://www.forth.com/resources/space-applications/The OP asked "The thing is, as an electronics engineer, which one should I learn most!?".I think you need to start a new topic if you want to argue against Forth.

author: Howardlong
author_rank: Super Contributor
timestamp: September 24, 2019, 10:45:36 am
content: Quote from: techman-001 on September 24, 2019, 10:08:53 amForth (and derivatives) has definitely been used extensively in space applications in the last century, but I'm not sure how much nowadays. Key was that it allowed for compiled high performance code in space and performance constrained systems, at a time when C was relatively young and lacked cross compilation tools for such limited systems.Me, I haven't touched Forth with a vengence since the 1980s, although around 1999/2000, I had some cursory involvement in an aerospace project that used it because it had a proven heritage in space. Re-use of apparently ancient put proven hardware and software designs and parts happens quite extensively in aerospace as a means of risk mitigation.

author: techman-001
author_rank: Frequent Contributor
timestamp: September 24, 2019, 11:05:38 am
content: Quote from: Howardlong on September 24, 2019, 10:45:36 amYou're absolutely right of course, spacecraft do demand proven systems, and because Forth was there *first* it has the oldest proven systems. The cost of spacecraft failure is always astronomicalIt's all well and good to have the latest "mega libraried, C++ syntax sensitive, self healing, quantum phase locked Arduino Meravigliarsi" but if it's not radiation hardened and spaceflight proven, who will risk a billion dollar spacecraft on it ?There were eight Forth MCU's on the 100kg "Philae Lander" that landed on Comet 67P/Churyumov-Gerasimenko in 2014, tho it was launched in 2004.

author: SiliconWizard
author_rank: Super Contributor
timestamp: September 24, 2019, 03:24:20 pm
content: Quote from: bjdhjy888 on September 24, 2019, 12:29:52 amI suppose you mean embedded software dev, if you strictly talk about "electronics engineer" work. And even mostly dev on low-level targets such as MCUs or DSPs. (Of course an EE could be developing software for higher-level targets, but that's kinda off-topic. How much electronics is there left in that? You could also be an EE an be baking bread.)So, with this in mind, there are actually NOT too many prog languages around, as many have already pointed out. For serious work in real industrial environments. So no need to be overwhelmed really. If you're feeling overwhelmed here, it's probably just because you're suffering from listening too hard to the hype, and not to what gets work done in real professional life.

author: legacy
author_rank: Super Contributor
timestamp: September 24, 2019, 03:39:47 pm
content: Quote from: tggzzz on September 24, 2019, 07:55:10 am"R" (yup, "the R language", so it's called) and Matlabp.s.Mission Critical network applications and databases: erLang!

author: legacy
author_rank: Super Contributor
timestamp: September 24, 2019, 03:41:37 pm
content: Embedded Games: eLUA!

author: Nusa
author_rank: Super Contributor
timestamp: September 24, 2019, 06:52:27 pm
content: There is no obligation to learn all the languages. The important thing is that you have a solid foundation in the concepts and principles of programming. When you do need to become competent in another language, much knowledge is transferable from languages that you do know. The bulk of programming expertise is in knowing how to plan and solve the problem in front of you. The language is merely a tool to express your solution.Similarly, if you're designing circuits, you don't need to know all the CAD packages. One is sufficient, until you have some overriding need to master another one. And that's just details, you already know the principles of making schematics.

author: rstofer
author_rank: Super Contributor
timestamp: September 24, 2019, 08:37:14 pm
content: In my view, the ordering is C, MATLAB and Fortran. C++ and Java are at the bottom of the pile.If you're going to design uC systems, C is the main language. There may be some C++ around the edges so you might need to understand that version as well.If you're going to do ENGINEERING, with numbers, charts and graphs you will need MATLAB. There isn't much you can't do with MATLAB including interfacing with an Arduino (and the idea is workable on other processors). System simulation is also a feature. I REALLY like MATLAB.Fortran - some days you just want to play with numbers. There's a reason that a lot of scientific work is still done in Fortran, more than 60 years since it was introduced. If you want to play with formulas, it is a great way to get it done. There's an enormous code base written in Fortran.

author: bjdhjy888
author_rank: Regular Contributor
timestamp: September 25, 2019, 12:30:40 am
content: haha, MATLAB is indeed very sexy. I'm learning it.wait, ain't it a product with commands? but not a programming language?

author: bjdhjy888
author_rank: Regular Contributor
timestamp: September 25, 2019, 12:33:55 am
content: My purposes of learning programming languages:1. To make my STM32 IMU project.- Schematic and PCB layout done.- Parts soldered- Troubleshooting its I2C to read RX data on my terminal window2. To make a game like Diablo III.- Do I learn C, C++ to make it? I know, it's a huge project.

author: Fungus
author_rank: Super Contributor
timestamp: September 25, 2019, 01:01:46 am
content: Quote from: wraper on September 24, 2019, 12:35:52 amArduinos are programmed in C++, they're 8 bits.

author: westfw
author_rank: Super Contributor
timestamp: September 25, 2019, 01:22:12 am
content: QuoteMaybe still Fortran, if you want fancy math parallelized :-(Be aware that for many languages, there is a subset of features used that is actually quite small, but the knowledge you'll need is more about standard and commercial libraries than the language itself. (and I'm talking about things like "QT" and "beautifulSoup", not "STL" or "Posix." Being able to program a cell-phone app is all about understanding the services available and the libraries to access them, rather than Swift vs Java or whatever (at least, as far as I've been able to tell.) Being able to program deep embedded applications is more about understanding bare metal and critical timing, and being able to program complex physics is about understanding the math.)