Which programming language is more useful

chesart1

Joined Jan 23, 2006
269
If you were designing embedded software systems, C++ was more popular in 2004. I don't know if JAVA has become popular in embedded systems. When I learned about JAVA, it didn't appear to be adaptable to embedded applications like configuring a communications port or configuring priorities on an programmable interrupt controller.
 

Dave

Joined Nov 17, 2003
6,969
Out of Java and C++: C++ is more common (in my experience) and Java has the cross-platform simplicity (provided you have a supporting JVM on your platform). Both are OO and useful in there own respects.

Dave
 

Caveman

Joined Apr 15, 2008
471
Stream of consciousness answer:
For an electronic engineer that is writing significant firmware, C is the most useful language. C++ doesn't scale down to the smaller parts very well. When you get too small for C, you must use assembly. If you are doing *really* big embedded projects with an RTOS, for example, then you generally have enough resources for C++, but not necessarily java. Note that C is still the most common at this level. Java is typically only used for specific embedded devices such as for cell phones, but just so you know, there is typically special hardware support in the ARM processors that run these.

For non-embedded applications on a PC: C, C++, and Java are all good. C++ is kind of clunky when you compare it to something like Java or C#. In my opinion, C is a little too limited here, so you spend a lot of time handling all of the small stuff instead of being at a higher level. Most electronic engineers don't really write a lot of PC code, though.
 

Mark44

Joined Nov 26, 2007
628
Out of Java and C++: C++ is more common (in my experience) and Java has the cross-platform simplicity (provided you have a supporting JVM on your platform). Both are OO and useful in there own respects.
One of the advantages of C++ is that you can choose to use the OO features or not. You can use the older common runtime (CRT) functionality such as printf(), scanf(), or you can use the newer iostream functionality that comes with cout, cin, and the like. If you want to organize your program using a classes and methods and such, you can, but you're not forced into doing this.

If you need to get down to the hardware, some C++ implementations let you drop in inline assembly, which is impossible to do with Java or C#. I don't have any experience programming microcontrollers and PICs and the like, but I have used C++ to write code for the FPU and MMX/SSE units on Intel processors.
 

Caveman

Joined Apr 15, 2008
471
then what do most electronic engineer do if they dont write code?
Many engineers do only hardware, so PCB layouts, analog circuit design, and FPGA design. There are radio engineers. Some engineers do lower level things like ASIC and IC design. Some only write test and operations documentation, but are still called engineers. The same goes for FAE (Field applications engineers) that support other engineers with particular parts.

Don't forget electrical engineering was around before the processor.
 

beenthere

Joined Apr 20, 2004
15,819
There were EE's around before vacuum tubes. Programmers write code. Computer science, the discipline that trains most programmers, is largely unconcerned with hardware.
 

Dave

Joined Nov 17, 2003
6,969
One of the advantages of C++ is that you can choose to use the OO features or not. You can use the older common runtime (CRT) functionality such as printf(), scanf(), or you can use the newer iostream functionality that comes with cout, cin, and the like. If you want to organize your program using a classes and methods and such, you can, but you're not forced into doing this.
Thanks for the information Mark. I take it C++ can be effectively used to mimic (for want of a better word) C if we drop the OO constructs? As I have mentioned before, I don't know C++ other than it is like C with which I am familiar with.

Java portability and significant support system (java.sun.com) make it viable for cross-platform PC development. That said I don't know many engineers that use Java to any great degree.

Dave
 

Mark44

Joined Nov 26, 2007
628
Thanks for the information Mark. I take it C++ can be effectively used to mimic (for want of a better word) C if we drop the OO constructs? As I have mentioned before, I don't know C++ other than it is like C with which I am familiar with.
Yep, pretty much. I have experience with two compilers -- MS Visual C++ and Borland C++ (a while ago) -- and each supports both code written in either C or C++. If you want to write code in pure C, you can do that. Or if you want to just dip your toe into C++, you can use the iostream insertion and extraction bits, cout and cin. If you want to go whole-hog into the C++ version of OO programming, you can build your classes using inheritance and polymorphism and all the rest, if that's your bent.
 

Caveman

Joined Apr 15, 2008
471
While C is simple C++ is basically true, there are some subtle differences. Mostly they have to do with types. C++ is more strongly typed than C. Check this out: http://en.wikipedia.org/wiki/C++#Incompatibility_with_C

My final say on the whole matter of programming languages is this:
1. How you architect your software is more important than the language. If you can get a language that inherently supports the required architecture, it helps.
2a. You can write good code and bad code in any language (including assembly).
2b. What is good and what is bad depends on the needs of the situation, however, commenting your code is always good. Modular code is always good.
3. Object oriented code is a way of organizing your software into objects. It can be done in any language (including assembly), but some languages support it more than others.
4. You should pick the programming language based on the situation, however, one strong driver of any situation is the amount of time it will take to complete the job. If you know the language, you will tend to use it just because it removes the learning curve time from the job.
5. For electronics-types trying to learn their first (and perhaps only) high-level language, C is the best. The primary reason is that no other high-level language is supported on more architectures than C. Unless you write a compiler, any other language will limit your available architectures when compared to C. The other reason is that almost all other common languages are C-like in syntax.
 

hgmjr

Joined Jan 28, 2005
9,027
As an Electronic Engineer, I find it much quicker to put together a working program for an AVR (my microcontroller device family of choice) based design using C language.

hgmjr
 
I have found in my programming experience that the reason most people use Java is because it is free. There was this whole concept behind Java when they made it about it being portable no matter the computer plateform. Of course, when they installed it to different kinds of computers, it developed different bugs so they fixed it different. Portability = fail.

Java's syntax really reminds me of C/C++ just with less functunality (as far as I can tell) than C++. Then you get to parts of the Java language that just makes you wonder what the heck the developer was on, because you want to avoid whatever it was like the plague. (omg, graphics in Java *shudder*)

Therefore, languages I think you should learn would be Assembler, C, C++, and just get a feel for java because its basically the same syntax as C/C++. I really don't know what other languages are used out there in electronics, except for those. Hope this helps.
 

Dave

Joined Nov 17, 2003
6,969
I think matlab
thank
Matlab is great as a language for rapid development of complex mathematical and S&T problems, however it cannot be compiled to run as generic code requiring the Matlab interpretor to run. Additionally, since it is an interpreted language it can be slow for certain programming constructs (for example for-loops).

Dave
 

roddefig

Joined Apr 29, 2008
149
Matlab is great as a language for rapid development of complex mathematical and S&T problems, however it cannot be compiled to run as generic code requiring the Matlab interpretor to run. Additionally, since it is an interpreted language it can be slow for certain programming constructs (for example for-loops).
I do believe there is a code generator for Matlab that will take your M-files or Simulink models and generate C code. Not that that is how I would go about writing C programs, but it is available.
 
Top