Which programming language is more useful

Discussion in 'Programmer's Corner' started by nearownkira, May 21, 2008.

  1. nearownkira

    Thread Starter Member

    Feb 19, 2008
    20
    0
    for an Electronic Engineer? JAVA or C++?
     
  2. mik3

    Senior Member

    Feb 4, 2008
    4,846
    63
    I think C++. With C++ you can program MCU's but i dont think with java. I dont really know search it.
     
  3. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    There's a pretty high degree of commonality between C++ and Java.
    If you know one, you know most of the other.
     
  4. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    There are versions of Java that run on micros.
     
  5. chesart1

    Senior Member

    Jan 23, 2006
    269
    1
    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.
     
  6. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    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
     
  7. Caveman

    Active Member

    Apr 15, 2008
    471
    0
    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.
     
  8. nearownkira

    Thread Starter Member

    Feb 19, 2008
    20
    0
    then what do most electronic engineer do if they dont write code?
     
  9. cumesoftware

    Senior Member

    Apr 27, 2007
    1,330
    10
    I think they burn transistors...

    What I'm saying!? I'm not even an electronic engineer!
     
  10. Mark44

    Well-Known Member

    Nov 26, 2007
    626
    1
    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.
     
  11. Caveman

    Active Member

    Apr 15, 2008
    471
    0
    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.
     
  12. beenthere

    Retired Moderator

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

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    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
     
  14. Mark44

    Well-Known Member

    Nov 26, 2007
    626
    1
    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.
     
  15. Caveman

    Active Member

    Apr 15, 2008
    471
    0
    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.
     
  16. hgmjr

    Moderator

    Jan 28, 2005
    9,030
    214
    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
     
  17. stars2night

    New Member

    Jun 7, 2008
    5
    0
    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.
     
  18. Islam Bitar

    New Member

    Jun 8, 2008
    1
    0
    I think matlab
    thank
     
  19. Dave

    Retired Moderator

    Nov 17, 2003
    6,960
    144
    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
     
  20. roddefig

    Active Member

    Apr 29, 2008
    149
    0
    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.
     
Loading...