Programming languages for embedded system

Thread Starter

Parth786

Joined Jun 19, 2017
642
I don't understand on what basis embedded programmer select language. I am trying to find out how embedded programmer select programming language for his project. Embedded programmer write a program code for embedded project. I have seen mostly we use embedded C , C++, Python, Java in embedded system.

I know here are the many experience person's having many year's of experience in embedded programming. I want to know how do you choose language for your project. When do you think you should write program in C or C++ or java or Python

Example: If you wrote program in C ++, then any reason why did not use C, java or python ?
 
Last edited:

MrChips

Joined Oct 2, 2009
30,810
There is no distinction between regular programming and embedded programming. Get that out of your head.

You can choose any language to get the job done.
The best language to choose is the one that best gets the job done.
 

AlbertHall

Joined Jun 4, 2014
12,346
If you have and know how to program with an IDE and C compiler but don't have and wouldn't know how to program in java then you would need a very good reason to switch. You might need to use assembler for some time critical parts of the program even if most of the code is in some high level language.
 

nsaspook

Joined Aug 27, 2009
13,277
I don't understand on what basis embedded programmer select language. I am trying to find out how embedded programmer select programming language for his project. Embedded programmer write a program code for embedded project. I have seen mostly we use embedded C , C++, Python, Java in embedded system.
Often you inherit a existing project with a existing code base because of a specific hardware design. I've got embedded systems that use Forth because of the Harris Forth chips were used in the original design years ago. Some of the systems are 20+ years old and are used to make today's generation of chips.

https://forum.allaboutcircuits.com/...s-that-are-still-running.132038/#post-1092256
 

MrSoftware

Joined Oct 29, 2013
2,200
Typically you would select the language based on which one would get the job done. If there is a good C compiler/debugger and libraries for the platform that you need to use, then C would be a good choice. If there is no java compiler or libraries for the platform that you need to use, then java would be a poor choice. If there are multiple language options, then you weigh the pluses and minuses of each and choose the one that will make your life easier (or make your boss happy, which will in turn make your life easier). :)
 

ebp

Joined Feb 8, 2018
2,332
Exactly what do you mean by "embedded"? Most of the languages you mention are unsuitable for small microcontrollers because they are interpreted, not compiled.
 

MrChips

Joined Oct 2, 2009
30,810
Now you've really thrown the TS for a loop. TS likely does not know the difference between interpreted and compiled.
 

nsaspook

Joined Aug 27, 2009
13,277
Now you've really thrown the TS for a loop. TS likely does not know the difference between interpreted and compiled.
and there are cases where the difference (in terms of performance while retaining interpreted source) is not clear. In the Forth processor I linked to earlier the chips hardware machine is almost the same as the Forth language abstract machine. The human form source code is immediately tokenized (the Forth text interpreter) much like at typical processor Assembler does with symbolic statements that run directly on the hardware (the Forth address interpreter). In this case an interpreted Forth program is usually faster than the equivalent compiled C program on a processor of the same raw clock speed.

There are (or were) also processors with a implementation of the Java virtual machine (JVM) in hardware.
 
Last edited:

Thread Starter

Parth786

Joined Jun 19, 2017
642
There is no distinction between regular programming and embedded programming. Get that out of your head. You can choose any language to get the job done. The best language to choose is the one that best gets the job done.
You all are the experienced person's and you have the experience in c, c++ , java, python. suppose you made the project where you wrote c++ program. Now if someone ask you why did you write program in C ++, any reason why did not use C, java or python ? what would be your answer ?

I think it's depend on hardware. I have seen mostly we use c program for 8051/PIC/ARM. We write c++ program for ESP8266 board and Python or java for Raspberry PI
 

miniwinwm

Joined Feb 2, 2018
68
I don't understand on what basis embedded programmer select language...
In real life the selection is largely because...

1) it's the only language compilers are available for, for the processor you are using
2) someone higher up in the food chain has made the decision already
3) you are extending or modifying existing code

and after that, for low level code or small devices, it's going to be C anyway, or less often, C++, so that's the language you should learn before trying to get a job.
 
Last edited:

miniwinwm

Joined Feb 2, 2018
68
I think it's depend on hardware. I have seen mostly we use c program for 8051/PIC/ARM. We write c++ program for ESP8266 board and Python or java for Raspberry PI
That's just not true. As the processor gets bigger the number of options gets larger, but to say we use the interpreted languages at the RPi end at the exclusion of C and C++ is not correct. The language chosen for the small devices is limited by what's available. The language chosen for larger devices is made by a whole range of factors - what's available for your processor, what you are trying to do, who's trying to do it, company history and culture, existing code base, experience of the staff, project budget, OS choice, timescales, regulation, project lead's favourite...and on and on.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
I still can't understand reason. I am taking another example just for understanding. why c++ is better for esp8266 then c language. I can see most of program available on internet in c++ language. But as I know we can also write c program. so I am just trying to find the reason why we prefer c++ for esp8266 then c coding
 

nsaspook

Joined Aug 27, 2009
13,277
I still can't understand reason. I am taking another example just for understanding. why c++ is better for esp8266 then c language. I can see most of program available on internet in c++ language. But as I know we can also write c program. so I am just trying to find the reason why we prefer c++ for esp8266 then c coding
The person who wrote the popular toolchain for esp8266 used c++ (on a cross-compiler), everybody else is too lazy to rewrite it in another language because the toolchain works.

The reason is, people are lazy.

That's not a bad thing if people are lazy in the correct way and don't waste time on things that are not very important in the long run.
 

ebp

Joined Feb 8, 2018
2,332
I think you need to spend some time learning about the strengths and weaknesses of each of the languages. For example, C++ makes object oriented programming easy whereas standard C does not. Python manages memory for you, C makes you do it for yourself. C has a goto if you really want to use it (and I have because I've seen PIC compilers that will generate a goto to a goto to a goto). Java has no goto because Jim Gosling doesn't believe they should ever used. (Silly man. I do rather miss Saturday trips to Ye Old Pizza Joint with Jim & the gang in the old days before he departed for CMU, rarely to be seen again.) Of course rejecting a language because it lacks a goto is absurd.
 

nsaspook

Joined Aug 27, 2009
13,277
http://www.gotw.ca/publications/c_family_interview.htm

Q: In your experience, how long does it take for a novice programmer to become a reasonably proficient [C/C++/Java] developer, capable of writing nontrivial production code? How long for a programmer with experience in one or more other languages? How can this time be shortened?

Ritchie: I don't know the answer to this question either--my stock joke on similar ones is, "Well, I never had to learn C...."
 
Last edited:

WBahn

Joined Mar 31, 2012
30,062
You all are the experienced person's and you have the experience in c, c++ , java, python. suppose you made the project where you wrote c++ program. Now if someone ask you why did you write program in C ++, any reason why did not use C, java or python ? what would be your answer ?
As people have been saying over and over, there is not a single answer to that question (other than, "It depends."). There are all kinds of possible reasons, ranging from what language we are most comfortable with in general, what IDE and related tools we have available for the processor being targeted, what relevant libraries are available, what are the memory/speed/other requirements that have to be met, how much development time is available, is this a quick one-off program or does it need to be maintained in the future, what other code do I already have that I can use as a starting point, and probably a dozen other questions that could be thrown in there.
 

ebp

Joined Feb 8, 2018
2,332
With regard to how long it takes to become proficient:

Learning the syntax of the language and how to use is a small part of programming. The big part is learning how to solve problems in an efficient and organized fashion.

It is not uncommon that a company that does software development will employ two classes of people. One class (who may be called programmers or something more "fancy") will analyze problems and develop the general approach and "shape" of the program(s). Another class, sometimes called "coders" will take what they are given by the other people and actually write the program "code." It is rather like the distinction between engineers who design something and technicians or machinists or equipment operators who build it. A welder may have exceptional skill and ability in welding, but she probably won't have the knowledge to allow her to design the machine she welds together. The engineer who designs a bridge has to know a great deal to do it and what is involved in getting the pieces put into place, but she probably won't be too interested in operating a crane all day long, even if she could do it if she had to. Programming is a little different because people who start out on the low end writing code someone else designs may move up to doing the design if they are good enough.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
As people have been saying over and over, there is not a single answer to that question (other than, "It depends."). There are all kinds of possible reasons
Thank's to all of you for helping me I did not want to repeat the same question but it is very important for me to know the answer to this question.

Actually I went for interview there interviewer asked me Do you know about the wifi chip. I said, yes sir I know about the esp8266 and I have been written program for esp8266. He asked me what language do you use to program esp8266. I said I wrote program in c++ language. Again he asked we can use c language also so why do you use c++ why don't you use c language.. I said c++ programming more faster then c but he said This is not a valid reason

I was stuck there because I wrote only one program that was to control LED. I just have little bit knowledge about c++.The same question was asked before me, there I could not give an answer. So that's the reason I asked this question here
 
Last edited:

joeyd999

Joined Jun 6, 2011
5,283
Thank's to all of you for helping me I did not want to repeat the same question but it is very important for me to know the answer to this question.

Actually I went for interview there interviewer asked me Do you know about the wifi chip. I said, yes sir I know about the esp8266 and I have been written program for esp8266. He asked me what language do you use to program esp8266. I said I wrote program in c++ language. Again he asked we can use c language also so why do you use c++ why don't you use c language.. I said c++ programming more faster then c but he said This is not a valid reason

I was stuck there because I wrote only one program that was to blink LED. I just have little bit knowledge about c++.The same question was asked before me, there I could not give an answer. So that's the reason I asked this question here
Telling a prospective employer that you know something that you really don't is a good way to get temporary employment.
 

Thread Starter

Parth786

Joined Jun 19, 2017
642
Telling a prospective employer that you know something that you really don't is a good way to get temporary employment.
I did not lie anything. I told the work that I did really . I did a Mention in my resume that I have knowledge of c programming and microcontroller. It's very hard to get job as fresher. God know when a day will come when I will get the job. anyway I am trying my best

This is my working code to control LED
C:
#include <ESP8266WiFi.h>
const char* ssid = "xxxxxx";
const char* password = "xxxx";
int ledPin = D5;
WiFiServer server(80);
void setup() {
  Serial.begin(115200);
  delay(10);
  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, LOW);
  // Connect to WiFi network
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  // Start the server
  server.begin();
  Serial.println("Server started");
  // Print the IP address
  Serial.print("Use this URL : ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");
}
void loop() {
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
    return;
  }
  // Wait until the client sends some data
  Serial.println("new client");
  while(!client.available()){
    delay(1);
  }
  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();
  // Match the request
  int value = LOW;
  if (request.indexOf("/LED=ON") != -1) {
    digitalWrite(ledPin, HIGH);
    value = HIGH;
  }
  if (request.indexOf("/LED=OFF") != -1){
    digitalWrite(ledPin, LOW);
    value = LOW;
  }
  // Return the response
  client.println("HTTP/1.1 200 OK");
  client.println("Content-Type: text/html");
  client.println(""); //  do not forget this one
  client.println("<!DOCTYPE HTML>");
  client.println("<html>");
  client.print("Led pin is now: ");
  if(value == HIGH) {
    client.print("On");
  } else {
    client.print("Off");
  }
  client.println("<br><br>");
  client.println("Click <a href=\"/LED=ON\">here</a> turn the LED on pin 5 ON<br>");
  client.println("Click <a href=\"/LED=OFF\">here</a> turn the LED on pin 5 OFF<br>");
  client.println("</html>");
  delay(1);
  Serial.println("Client disconnected");
  Serial.println("");
}
 
Last edited:
Top