Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recommended Programming Language 1

Status
Not open for further replies.

sykimk

Electrical
Dec 28, 2003
55
US
I need your advices on choosing programming languages for my study. Actually, I am going to study abroad to achieve MS degree on power engineering from coming fall semester.

Although I am an engineer, I don't have any experiences on any kinds of programming langauges. But, I think I need to learn how to use programming languages such as C/C++, Fortran, etc. to take advanced cources on power engineering. However, I don't have enough time to learn more than only one programming language. It's time to select one of C/C++ and Fortran as my preferable programming language. I am well aware of the fact that using MATLAB is a mandatory for graduate study. I want to get knowledgement on using any other programming language addionally.

C/C++ or Fortran what I have to learn as my programming language for power system analysis programming.

Please advise and thanks in advance.


 
Replies continue below

Recommended for you

C/C++ every time (C itself is a subset of C++), C++ is a bit complex to learn (and getting a little outdated now), but it is object orientated which is the key for all modern computer languages. Also there is still a big market for C++ programmers (with large salaries) which I don't think is the case for Fortran. C is also useful in that it helps with understanding UNIX which was programmed in C.
That said however, if I only had to learn one language it would be visual basic, since it is extremely easy to learn, has a well supported knowledge base and you can knock up applications in minutes, which is great for engineering.
 
I never miss an opportunity to tell people about FORTH (yes FORTH, not Fortran).

It is an extremely good language for embedded control - as close as you can get to assembler without having to master the native assembly code for all processors you are going to work with.

It is interactive, memory efficient and fast. It uses a stack and works like the good old HP calculators do.

Syntax is easy. Almost non-existent. Here is an example that calculates percentage. It is not the smartest thing to do with this language, but it illustrates how simple and intuitive it is.

: percent 100 * SWAP / . ;

The colon :)) starts a definition of a word that is called "percent". 100 * multiplies first item on stack with one hundred and "SWAP /" divides with second item on stack and "." prints it. The semicolon (;) finishes the definition.

To calculate what percentage 17 is of 345 just write 345 17 percent.

* SWAP / and . are predefined words in the system. You add the "percent" word when you define it. You build the "dictionary" to suit your application and the main program uses the words in the dictionary to do the job.

You can define simple little words and nest them to any depth. I/O is simple and reliable. You can test a word directly, setting and resetting pins directly from the key-boad. I love it! Google "forth" for a welth of examples and affordable development systems.
 
I would advise Basic first of all. Its quick and dirty and the easiest to learn. It should be sufficient for your studies. Alternatively, Pascal is what many professional first learn, as it is very clean and you do not pcik up any nasty habbits from it.

However, you must remember that Basic is for amateurs and Pascal, has not been deveoped as much as it should have been. Having become famiiliar with the basic ideas in either of them, you can then move on to Visual Basic that will let you programme in Windows. That is very popular world wide.

As for a proper language, these can be quite fearsome to learn from scratch. C and then C++ are very widly used in Windows and Unix software. Java is pretty hot at present for Unix and Web work and is being stretched into other areas. However, there appears to be a swing to the new Visual Basic.Net and C#. The last one, C#, is worth watching as many professaional programmers are moving over to it. It is the newest and most powerful of the lot.

However, be prepared for viscious, nasty arguments over the choice of languages. Discussions on these matters are worse than arguments between religious fanatics, particulary from people who think they are experts, but in truth haven't a clue !!!

 
A star for you, ajingram. You are so right in what you say in your last paragraph.
 
I completed an MSEE in power in 2000 and my recommendation would be Matlab and a symbolic math language such as Maple, Mathematica etc.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
Unless Basic has evolved to include complex functions, I'd advise avoiding it. Fortran has the functions built in, don't know about C.
 
The old discussion about math libraries is quite stale and no longer valid. There are something like 3 Fortran compilers vs. dozens for C on the PC. There are plenty of math libraries for C available.

Additionally, most other control languages follow C syntax. And there are no Fortran compilers at all for embedded applications.

Forth may or may not have advantages, but it definitely is a niche language and, I think, mostly used for proprietary embedded applications.

I think one issue that you need to properly address is that as an engineer, you cannot and should not be so narrowly focused on a SINGLE solution. You, as a engineer, should be familiar with ALL of the aforementioned languages, just as you should be familiar with all sorts of transistors and all sorts of logic families. Each language that has survived the test of time has unique features that are relevant to particular applications.

C --> general purpose programming

Basic/VBA --> mandatory if you want to write macros for MS Office applications, but don't want to make a living at it

Fortran --> probably no new programming, but maintenance and understanding of legacy programs requires knowledge thereof

Forth --> I've never had a need for it, but it's extremely popular with some embedded programmers.


TTFN
 
If you had to choose one, I would go for C. This is something that can be used in many, many applications. Basic language is extremely simplistic and would be very easy to pick up on once you know a language (like C). I do not have any Fortran experience but based on Skogs example of FORTH, seems like it is a powerful tool as well but more like assembly language (which is generally the hardest to learn next to the real deal of machine language). I think C will take you many places as their are many compilers available in C for many different types of processors, controllers, and DSP's. Once you understand C all the other languages can be quicked up quickly (except assembly).
Just to let you know what I base my suggestion on is someone who knows assembly language the best and have used C, C++, Turbo Pascal, Basic, and Visual Basic.
 
Forth is a nice niche language to have in your repertoire. I have embedded Forth in to C programs in embedded systems, it lets me tweak and monitor the system remotely.

I have utilized Fortran in embedded systems, but I had to rewrite the math libraries and I/O routines and roll my own OS. Small company the Engineering manage was a ME and only knew Fortran I wrote the main program in Fortran and everything else in assembler.

If your are just starting out learn three languages, C/C++, Forth and Assembler.
 
IRstuff,
Did you call my comment about Basic stale and invalid, and then proceed to say nothing about Basic functions? I don't mind being wrong, but please explain where I missed. Or did I misunderstand?
 
No, it was regarding your comment about Fortran and C. The stale argument relates to the availability of math libraries and functions for Fortran and not C.

TTFN
 
I stick by my original recommendation regarding what I think is needed for your program, but I reread the original post and I see what is requested is specifically a choice between 2 languages: C/C++ and Fortran.

First of all, why do you need either? Isn't Matlab itself a good enough tool to learn basic... I mean fundamental programming? There are plenty of books that can get you started from any level.

Your stated reason for learning is because you expect you'll need those languages...I didn't need anything other than Matlab and Maple in my program. Did your school tell you something different? I will mention that a math program (Maple) helped make very intimidating algebraic problems become much more user-friendly. But if you enjoy writing equations until your hands cramp then feel free to ignore me.

Assuming you really have made up your mind to choose one and only one from the choice of C/C++ or Fortran:

I learned Fortran early on and I thought it was easy. Probably on par with basic in terms of ease of learning if the purpose is just to learn a programming language. I don't know C or C++ but if you don't live in a cave you know that C++ is very tough to learn (6 months full-time starting from scratch?) and also very marketable for programmers. I would say C++ is out of the question based on difficulty and your mention of limited time. Maybe someone else can comment whether C is reasonably easy and a good stepping stone to possible future C++?

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
My last comment is a summary and then I'll shut up.

Assuming your primary purpose is to learn what you need for your program, my recommendation is start by learning Matlab only. If later in your program you start finding out for some reason that you need another language, then you can learn the other languag at that time but I don't think you'll see any need for those other languages with possible exception of a math program.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
I learned C and C++ and cant honestly remember the differences. The reason I say C is it is more of a universal language which can be used to program a processor or microcontroller, PLC, amongst other custom controllers. I would say that anything (just about) that can be done in assembly, basic, fortran (not familiar with fortran apps so could be wrong here), pascal, etc probably has a C compiler for the same application so you don't have to learn all the different languages.
Since the poster is a power type I am not real certain of the applications he will need to know. Matlab is real close to C as well.
 
If you plan to work as a power engineer, there is no need to learn any high-level language, except as required by your coursework or job function. For you MS study, I'd just wait and see what is required.

If you are wanting to learn a language just to learn programming or for "fun", I'd recommend Java. It will give you good understanding of C/C++ from which it is derived, as well as object-oriented programming. But it is much easier to program than C++ because it handles a lot of the onerous memory management and garbage collection automatically.

 
i recommend you study C first, then Matlab or MathCAD. It really is easiest to understand and develop. There are also a lot free IDE/Compilers in the net for your interest.

Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top