If you have never used your computer to solve home-made numerical simulations, you probably do not have any compiler installed. There are a few programming languages to choose from. Matlab and Fortran are probably the most widely used languages among civil engineers but they are quite different.
The old Fortran runs considerably faster than Matlab does. If you know that you will need a lot of computing power and that computing speed will be important, you may want to go with Fortran instead of Matlab. I chose Matlab for my master thesis and it was a nightmare. Another good advantage of Fortran is that if you use Linux you will find a lot of excellent compilers for free. Matlab is not cheap and there are a couple of free clones (Scilab and Octave) but the translation of the programs is not straightforward.
On the other hand, Matlab has a very easy to use interface and lots of libraries; it is possible to implement programs faster than with traditional programming languages and they are easy to read and to maintain (programs in Fortran are messy). After running your code, Matlab will graph the result for your variables. In Fortran you need extra routines to do this. In the absence of such routines, you will have to use a tedious spreadsheet to have anything to show.
Picture: Olde Fortran in Futurama. More images here.
What I cannot explain in this blog is why civil engineers still use Fortran and not C. Are we from the past?
Structures, water, computers, languages and people (not necessarily in this order)
Olde Fortran vs Matlab
Subscribe to:
Post Comments (Atom)
I guess you can always plot the results from Fortran with Matlab.
ReplyDeleteI don't know in other sectors, but in Finance, C is not very common now. C++ is, I don't know if that was what you meant.
I am also curious about what Fortran is most used. As you know, the one I used to use was Fortran 77, but I don't know if the new versions, which allow polymorphism, inheritance, and recursiveness, among other features, are more used now.
Anyway, I don't see much point in using them unless you already have a big project built in F77 and want to start using OOP. Otherwise, I would say that C++ is a better choice for OOP, and if OOP is not your thing, then F77 will do. But I may be talking shit (again).
From my humble point of view, the main difference between Fortran and C is that Fortran was never thought as a structured language. However, a lot of civil engineering packages are written in Fortran (F77, F90 or VisualFortran). I suppose it is a question of tradition.
ReplyDeleteUnfortunately, I have never tried C++ but Java in object oriented programming. C and Matlab have very few OO features but I feel both can satisfy most of the scientific and engineering computing needs. C is very fast and very robust and not in vane Linux kernel was programmed using C.
I found these interesting statistics on programming languages that show that C is still a bit more popular than C++.
Finally, just a comment, recursion is a powerful way of thinking, but a recursive algorithm runs faster if it is implemented in an iterative way (function calls delays are avoided).
But you can still write perfectly structured programs in FORTRAN. It has all the capabilities. The same way, in theory, you could write a C++ program full of goto's.
ReplyDeleteThe impression I had is that C is much better for things like OS.
I didn't know that C and Matlab have any OO feature at all. But while I see some advantages in learning Matlab (it is very easy), I don't see any in learning "just C" (it's almost a subset of C++).
Regarding the recursion, I think there are times where it is not worth making an interative impleentation because of the mess it creates.
I agree with you in that the OO is overrated for scientific and engineering computing. Nevertheless, it sometimes allows you to do things that otherwise would be quite messy.
Wow! How come Basic is so high in the list?
ReplyDeleteI'm also surprised to see FORTH at #36. It seems there are more HP-48 left than I thought!!
You are very well informed, imp. Imperative programming is enough for scientific and engineering purposes but sometimes OO makes things look easier (for example, overloading operators and functions is what makes Matlab easy to use and understand). You persuaded me, if I have time I will give C++ a chance.
ReplyDeleteCarreira, I guess you meant procedural or structured programming, since even the paradigm of Java or C++ is the imperative programming.
ReplyDeleteYou can learn C++ if you want, but I wouldn't recommend it. It seems that you know both C and Java, so I don't think it is going to add any value from the conceptual point of view. On the other hand, if you master the other two, C++ shouldn't be too difficult. I don't know Java, but my brother the IT Engineer does, and from what he tells me I would say that Java is more logical than C++ (too complex, too many things can go wrong).
The only reason why I learnt C++ is because it seems it is the standard in Finance.
Yes, you are right again, I used imperative programming in a bad way as a synomin of the first widely used paradigm (Fortran, Pascal, C,...).
ReplyDeleteI have never imagined that C++ were so popular!
I've never really used fortran, its sort of before my time. But I've always hoped there was something better out there than MatLab. To me MatLab code just looks really dirty. The whole organization of the compiler and file usage seems odd after knowing about 4 other languages beforehand.
ReplyDeleteI bought a book on it tho to study. At my school they don't teach you it, but expect you to be able to use it in later years. After taking a look at some of the wicked plots you can do on MatLab I really want to learn it well.
I can't believe I missed that joke in Futurama. Halarious tho.
I was just about to put up a post on this book i got on my engineering blog i just started. The link is NullLifeException. If you want to link trade I'd be up for it but since my blog is new I don't mind if you don't. Have fun engineering!
I'm in second year university and from canada by the way.
You should definitely give Python (plus the Numpy and Matplotlib libraries) a try. They're widely used in the scientific community and are much more pleasant to use (besides somewhat faster than Matlab in many cases).
ReplyDelete