Programming languages in engineering

Post here information about your own engineering projects, including but not limited to building your own car or designing a virtual car through CAD.

Your preferred environment?

Matlab
17
55%
Some flavor of C (C++, C#, etc)
9
29%
Python
1
3%
Modelica
0
No votes
Java
2
6%
VB
0
No votes
Fortran
0
No votes
Other
2
6%
 
Total votes: 31

Jersey Tom
166
Joined: 29 May 2006, 20:49
Location: Huntersville, NC

Programming languages in engineering

Post

I'm curious to hear some opinions on this, given how the breadth of backgrounds we have here on F1T.

What are everyone's preferences and experiences on programming languages for practical engineering computing? (And as an aside for anyone still in school, even as a mechanical engineer without formal computer science background... IMO having some programming skills can be great for your career).

I'll start off. So far in my 6th year of industry, I've been a huge MATLAB fan. It's all I lived and breathed since I got out of college, and after so many years of "learning by doing" I've been pretty proficient with it.

MATLAB
Pro's
  • Relatively easy to pick up, though I didn't think so in college! Partly due to the IDE, partly due to it being weakly (or really probably more dynamically) typed.
  • Extensive toolboxes (libraries) for most if not all engineering computing tasks you can think of.
  • Great for vector or matrix operations (hence the name.. matrix laboratory)
  • Generally good for prototyping
Con's
  • Everything is expensive! Can be a real drawback if you want to do stuff at home, or try the justify the cost of some new toolbox to management
  • Version compatibility can bite you, especially with how often major releases come out.
  • Not that fast compared to some other languages
  • Once you get outside of the hardcore number crunching, some more general purposes operations are a bit of a pain
  • While you can do object oriented programming, I find that most MATLAB programmers (myself included!) don't really get exposed to it.. and that it's more an imperative or script-based language. Again, maybe that's more a function of my not having formal CS background
  • Generally more difficult for broad deployment of applications (in my experience)
Recently I had to take on a project in C++, and then started dabbling in some C# / .NET for little things here and there. Not gonna lie, I'm a big fan of everything it does... outside of hardcore number crunching (filtering, optimization, data visualization, whatever).

C# .NET
Pro's
  • Visual Studio as an IDE is awesome
  • You can get VS Express for free!
  • Fast. Having taken some stuff I was doing in MATLAB and re-coding it to a DLL in C# I've seen speed improvements of several orders of magnitude. Not even kidding. Still blows me away.
  • .NET libraries are great for a lot of general purpose tasks
  • Emphasis on object oriented programming has been eye-opening and made me go about things much smarter and more efficiently
Con's
  • No native libraries for "real" engineering computing... that's a big one!! Might be some commercially available stuff, but at that point.. might as well pay for MATLAB
  • Static typing. I'm sure there are pro's and con's to this in itself. Again not being a real CS guy and having the MATLAB background, it kinda sucked to have to start getting into the practice of declaring data types for all variables
If I could marry some of the best aspects of C# .NET with the libraries of MATLAB, I'd be thrilled. Brings me to my next item - Python. I don't have any real experience with it, but I know it's out there and seems to be gaining popularity. I've heard that the language syntax itself is quite nice.. it's free / open source.. and it seems there are libraries for scientific work, plotting, etc. Anyone around here use Python much? Pro's? Con's?
Grip is a four letter word. All opinions are my own and not those of current or previous employers.

User avatar
Kiril Varbanov
147
Joined: 05 Feb 2012, 15:00
Location: Bulgaria, Sofia
Contact:

Re: Programming languages in engineering

Post

In order of mostly used:
Java - whenever I need to be aligned with the corporate standards
Python - when I need to work with someone else's code (everybody around me uses it when there's a choice)
Perl - when I can choose - very old habit
Shell scripting - for whatever you need to do fast in less than 100 lines. Portable, the (almost) same usage across AIX, Linux and Solaris.

User avatar
Tim.Wright
330
Joined: 13 Feb 2009, 06:29

Re: Programming languages in engineering

Post

I work a lot with Matlab. My opinion is basically similar to what you have already written. Its very good at numbers and has a lot of built in functionality for various disciplines (at a cost as you mentioned).

But recently I have often come across a lot of issues when using it as a programming language (i.e. not just for numbers but handling fileio, guis, actually any user input). Its handling of text files is absolutely awful which pisses me off because a lot of what I do is importing text files from various acquisition systems. More recently I found a nice "feature" where if you name one of your functions after a matlab function of which you do not have a license for, it disables it and every other function in the same folder including your own functions... This took me a few hours to track down this problem and it started my most recent search for an alternative. Roughly once a month I crack the shiits with Matlab and look around for another alternative.

After some searching around I have found that I'm not alone, and there seems to be a bit of a rebellic trend away from Matlab and towards Phython. There is even this website: http://abandonmatlab.wordpress.com.

I have not yet had the time to look at any alternatives in detail but I have at least come across this one: Sagemath http://www.sagemath.org/, which uses python and includes a lot of math functions.

JT, what are the limitations on Visual Studio Express? I'm interested to know how it would stack up against Python as a free option. I learnt C in uni so I think I'd pick up C++ or C# quicker than Python.
Not the engineer at Force India

Greg Locock
233
Joined: 30 Jun 2012, 00:48

Re: Programming languages in engineering

Post

Matlab, or the free, slower, compatible stable Octave at home.

For text file manipulation I still use quickbasic, for example if I am running a DOE on an FEA model I'll use quickbasic to chop the text files up and reassemble them, and then call Nastran's solver, and then analyse the results in quickbasic again.

For interfacing between hardware or blackboxed DLLs and ADAMS I use Fortran, and much of the back end of the GUI we use in ADAMS is written in python, so I spend a bit of time hacking that, but only at a very simple level.

Python has some nice looking analytical libraries, it might be worth looking at.

I used to do a fair bit in VBA and Excel but compared with Matlab it is unreliable and unmaintainable.

Jersey Tom
166
Joined: 29 May 2006, 20:49
Location: Huntersville, NC

Re: Programming languages in engineering

Post

Tim.Wright wrote:But recently I have often come across a lot of issues when using it as a programming language (i.e. not just for numbers but handling fileio, guis, actually any user input). Its handling of text files is absolutely awful which pisses me off because a lot of what I do is importing text files from various acquisition systems.
Likewise, as I also deal with a lot of in and out of various text files with math in between. That's one area where I've found orders of magnitude improvement with C#.
JT, what are the limitations on Visual Studio Express? I'm interested to know how it would stack up against Python as a free option. I learnt C in uni so I think I'd pick up C++ or C# quicker than Python.
Express, compared to the full paid versions... I believe doesn't have performance profiling in the IDE, or support of add-ins, or code management. Things like that - the "nice to haves." Functionally though pretty much everything is there. I haven't run into a spot yet where I've said, "Damn I wish I had a full version."

Beyond that, as I say the lack of native libraries for scientific math and plotting wind up boxing you in quickly. If you have the 'Matlab Builder NE' toolbox I think you can take some of the best bits of MATLAB and compile them into .NET libraries, though that compiler toolbox is probably not cheap!

Still, if you need to do something like make an ASCII file manipulator or convert the data in a test file from pounds force to Newtons or something, I'm finding C# to be very sporty.
Grip is a four letter word. All opinions are my own and not those of current or previous employers.

piast9
20
Joined: 16 Mar 2010, 00:39

Re: Programming languages in engineering

Post

I work at the technical university where I use C# for my projects, even if others prefer MatLab or LabView for some particular job. My knowledge of MatLab is basic so I can't give any opinion about it. And my preference of C# over LabView in measurement system handling is based on the fact that I hate "programming" by creating obfuscated ratnest of blocks and wires. As the programmer I am old fashioned and I prefer to just type as much as I have to create the guts a software and use the visual programming only for the user interface.

I use libraries such as Math.NET or DotNumerics for mathematical operations. I use Ultimate versions of the Visual Studio as they are provided by the University but I've once tried the Express just to see what's what. The first hurdle I've came across in the 2010 versions was that the solution can contain only one project which renders it useless for me because in nearly every piece of software I produce I use my own libraries as well. Maybe there's workaround of this but I haven't looked for them since I may use Ultimate anyway.

User avatar
Tim.Wright
330
Joined: 13 Feb 2009, 06:29

Re: Programming languages in engineering

Post

piast9 wrote:The first hurdle I've came across in the 2010 versions was that the solution can contain only one project which renders it useless for me because in nearly every piece of software I produce I use my own libraries as well. Maybe there's workaround of this but I haven't looked for them since I may use Ultimate anyway.
Does that mean there is a real limitation on creating re-usable code?

E.g. In matlab I have a load of standard functions I wrote which do fileio, preprocessing and vehicle dynamics calculations on a standard data structure. So when I have a new processing job to do, I can include all of the preprocessing and importing functions I have previously written and I only need to write the new processing things.

Is there anyway to setup such a thing in the express version?
Not the engineer at Force India

Jersey Tom
166
Joined: 29 May 2006, 20:49
Location: Huntersville, NC

Re: Programming languages in engineering

Post

I can't speak for the 2010 versions, but in Express 2012 for Desktop you can indeed have multiple projects within a solution and also include references to your existing class libraries (VehDyn calcs, etc).

I may have to look into Math.NET and DotNumerics
Grip is a four letter word. All opinions are my own and not those of current or previous employers.

piast9
20
Joined: 16 Mar 2010, 00:39

Re: Programming languages in engineering

Post

So they must have returned in 2012 to the situation from 2008 Express which allowed for multiple projects in the solution too. I didn't tested it much in 2010 Express - just opened a solution, watched the VS saying that it can't do that, closed, uninstalled.

after stackoverflow.com:
Express editions of the IDE omit the following features included in the Professional editions:
  • Multi-unit testing framework and refactoring support
  • Static code analysis, profiling, and HLSL editing and debugging
  • Third-party extensibility support (though the Extension Manager feature is still present)
  • OpenMP support
But there are few positives I explore in 2012 : Unlike previous version
  • Solution is allowed, you can create multiple projects in a single solutions.
  • 64bit compilations support is there.
So in 2012 there's no limitation on creating reusable code. You create your own class libraries and use them as you want.

netoperek
12
Joined: 21 Sep 2010, 23:06

Re: Programming languages in engineering

Post

May I ask, why assembler is not on the list?! :wtf:

notApineapple
3
Joined: 12 Aug 2013, 10:23

Re: Programming languages in engineering

Post

netoperek wrote:May I ask, why assembler is not on the list?! :wtf:
Because lifes to short :wink:

Jersey Tom
166
Joined: 29 May 2006, 20:49
Location: Huntersville, NC

Re: Programming languages in engineering

Post

netoperek wrote:May I ask, why assembler is not on the list?! :wtf:
Never heard of it or used it... or do you mean actual assembly language?

If so, I feel like that's much more in the realm of what I would call the "real CS guys" as opposed to the more classical engineering (MechEng, Aerospace...) guys like myself. Perhaps I should have been more specific, but the intent here was to focus on high level languages in those fields.

If I had to write so much as "Hello, World!" in assembly language I'd probably hide under the covers. Writing that much closer to the metal I leave to the CS professionals!
Grip is a four letter word. All opinions are my own and not those of current or previous employers.

User avatar
KeithYoung
24
Joined: 02 Jul 2003, 20:21
Location: USA
Contact:

Re: Programming languages in engineering

Post

My go to is Matlab. The reason is that's what our University required us to use. Sadly my Univ license will expire eventually and I'll have to move on.

I have used Fortran, but I didn't use it much. It was MUCH faster in loops than Matlab. The language seemed pretty straight forward.

But probably after Matlab I'll be switching to C++ mostly due to my background using that on the Graduate Robotics Team. I should look at learning another language though, preferably another free one.

Jersey Tom
166
Joined: 29 May 2006, 20:49
Location: Huntersville, NC

Re: Programming languages in engineering

Post

I have to say, I've already had to re-evaluate some thoughts here since posting this thread initially, and now that I've been digging into performance between languages.

First, even though I included it as a poll option, I'd kinda been under the impression that Fortran is a dead or dying language with little use anymore. Probably emphasized by some experience at previous gigs where there was some legacy Fortran code in use... but nobody knew how to or cared to maintain it. Googling around a bit, seems a recurring theme is "Yeah not much new code being written in Fortran these days... except in science or engineering circles with hardcore number crunching. Though I'm not sure whether that's the number crunching that I'd do on a regular basis, or more like writing your own Navier Stokes solver for some big CFD problem. Probably not something I'd care to pick up in any event.

Performance benchmarks between languages are interesting, though most taken with a grain of salt since anyone promoting their own product might be inclined to pick a test where it performs favorably. Fortran seems to always be the gold standard, with some places and cases claiming they can meet it's performance. The various flavors of C seem to be a close or on-par second (ILNumerics being another math library for C#). But then Matlab and Python both distant competitors to C/Fortran even for number crunching.. and Matlab certainly has some brutal i/o.

Python seems less attractive to even look into at this point. Makes me feel better about dabbling in C#.
Grip is a four letter word. All opinions are my own and not those of current or previous employers.

Caito
13
Joined: 16 Jun 2009, 05:30
Location: Switzerland

Re: Programming languages in engineering

Post

Voted MatLab, but I really prefer simulink. I'm finishing my Electronic Engineer degree, specialized in mecahtronics. Simulink is really cool to design control systems.
Come back 747, we miss you!!