12

I've been working with a lot of FORTRAN 77 lately, and though I had reservations at first, I now see some great qualities of the language. It is:

  • Simple to learn (no object-oriented or functional-programming complications)
  • Easy to read
  • Blazing fast at number-crunching

Those qualities are naturally attractive to non-programmer engineers and scientists who just want a way to make a computer give answers quickly. But it has a lot of limitations based on its age and some of its basic assumptions. I'm skeptical about how easily non-programmers can understand some of the added capabilities of later versions of Fortran, as well.

Is there a modern language that is as straightforward as FORTRAN, just as fast for mathematical applications, and less limited? Or is the answer Fortran 90, 95, 2003 . . . ?

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
JasonFruit
  • 7,764
  • 5
  • 46
  • 61
  • 1
    Don't quote me on this but I believe the target audience of F# includes engineers/scientists. – ChaosPandion Aug 23 '10 at 16:45
  • 1
    Dr Seuss is simple, but once you start reading larger texts you may find a different style more appropriate. Romeo and Juliet written in the style of Dr Seuss wouldn't be readable, neither would a large, complicated codebase. On the other hand, now I'm considering re-writing Romeo and Juliet--maybe I'm wrong about that one... – Bill K Aug 23 '10 at 16:55
  • You may have a point, @S.Lott; submit it as an answer, and it'll at least get votes. – JasonFruit Aug 23 '10 at 17:03
  • Btw, what did you mean under "limitations based on some of its basic assumptions"? – Rook Aug 23 '10 at 21:06
  • One of its basic assumptions is that computers are for computation, and interaction with a user is purely secondary. Part of that is no doubt because of how (little) computers interacted with their users when FORTRAN was first written. There are other points like that, too. – JasonFruit Aug 23 '10 at 22:35
  • @JasonFruit - Yes, you're right. And have a point there, I agree. But, I believe we also agree, that when designing a language, one must put some goals as more important then others, must even disregard some! Fortran - as it's development through time was heavily influenced by industry which used it - has set its goals as backward compatibility, and portability to a great extend. History issues are also in here (although not that influential as one may imagine), but with those considerations to implement any graphical – Rook Aug 23 '10 at 23:02
  • libraries is rather difficult, wouldn't you say? Can you imagine a GUI which would be backward compatible, yet portable over platforms, in a world where an OS changes every 5 years (I've trouble running my Win95 programs on XP, less alone something more drastical). This may seem like a major drawback at this point, but most engineers in their calculations don't rely that much on visualization (in the user interface sense) as much as a numerical result (visualization of results aside, as in CFD visualization or alike - for that there are a plethora of standalone programs - – Rook Aug 23 '10 at 23:04
  • http://www.tecplot.com/ to give one of many (since it's currently running in the background :-) – Rook Aug 23 '10 at 23:05
  • Also, but of different flavour: http://www.gino-graphics.com/home.html and http://www.winteracter.com/ ... just to show that things are not so bad :) – Rook Aug 23 '10 at 23:30
  • I didn't really mean graphical interface; just that, as an example, user interaction of any kind seems like an afterthought. There are other things I find awkward; a little more attention to strings would have been welcome, for example. – JasonFruit Aug 24 '10 at 03:20
  • 1
    @JasonFruit - Maybe. But do take that string handling is not in the top priorities in Fortran's users. Never was really. There was at one time some pressure as to introduce something ... in that area, but other features were voted as more relevant. However, most of such operations one finds a way to do ... just in a little different manner than in other languages. – Rook Aug 24 '10 at 15:22

12 Answers12

17

Or is the answer Fortran 90, 95, 2003 . . . ?

Yes. Fortran 95 supported by most compilers is the language you are looking for. However Fortran 2003 has some major enhancements (besides unnecessary from your point of view support of OOP) which might be useful. Compiler Support for the Fortran 2003 Standard.

Wildcat
  • 8,701
  • 6
  • 42
  • 63
  • I believe gfortran and Intel "rectified" some things off that list in their newer versions. – Rook Aug 23 '10 at 21:07
10

Well, I'm a non-programmer engineer (whatever that means; I gather it means not having much contact with computer sciences studies) and ...

Partically in continuation to JasonFruit's comment on S. Lott's answer:

Yes, the standard has added quite a few features from F90 to 2003. But the "problem", if one can call it such (I cannot think or care to of a more appropriate word) is that many people who use Fortran do not know it, save the basic features they need. It is a blessing and a curse all in one, in a way. They have never learned it, never read a book on it - they kinda just picked it up as they went along. That way can certainly work for a time (if you structure your programs simply, as many have done for centuries, and have a sort of mental discipline, this approach can last for a lifetime/your entire career), but after a while it starts to show its disadvanages. Try for example, following some of the discussions on the recent features on comp.lang.fortran to test your knowledge.

So, take a good book (many recommend one of the three for beginners; a) Chapman J. Stephen's b) Maine, or c) Metcalf, Reid and Cohen (known as the "M.R.C. book") - after which a lot of the "more obscure" features not only become clearer, but also "obvious" (as in a way; this really is the better way - why did I did it that way ... before?).

That takes care of that question. Now, the other question -- which will certanly arise -- is Fortran worth learning nowadays? (it always does, trust me on this :). This has been covered numerous times, so I'll just direct to my own post regarding the above, and my older post (you'll have to scroll a little down) which regards some issues in comparison with some of the other langugages mentioned here.

The last thing, which is in a way the cause of all these question in most cases is people opinion on Fortran, with the emphasis on opinion! Generally speaking (and we can take this forum as a pretty good sample for our analysis) is that it's not so good. Few like it [ follow questions marked fortran on this forum for a month, and you'll quickly learn who they are. Btw, judging from the frequency your name's been appearing, you're quickly becoming a member of the club :) ], most are either indifferent, and some hate it, out of sheer ignorance (comparing F66 with today's languages is often used), some out of their own reasons. Now, if we take those and compare it with the general population, by simple an account, the result is bound to come out bad. If you interviewed just traditional engineers the results would be quite different.

Thhhh-aaa-ttt's it.

Oh, one more thing - Fortran is/was and still remains primarily aimed at engineers, not mathematicians. It is better suited for solving large systems, then calculating pi to a ka-zi-llionth decimal. I don't know if that was a typo in your question, or intentional. For purely mathematical applications (in a classical sense of mathematician) I would (were I a part of that field) probably choose, I don't know, Mathematica? Or Pascal (don't know why it was always Pascal; but it seems terribly popular with those chaps).

Community
  • 1
  • 1
Rook
  • 60,248
  • 49
  • 165
  • 242
  • Good point; when I said "mathematical applications", I should have written "computationally intensive applications". – JasonFruit Aug 23 '10 at 22:38
  • 4
    Isn't that the nice thing about Fotran? You don't have to spend your entire time on comp.lang.xx studying the latest detail of partial template specialization through not virtual lamba functors - in order to do the work you are actually being paid for! – Martin Beckett Aug 24 '10 at 17:07
10

I'm surprised that the consensus here is for modern Fortran, and I grudgingly agree.

Whatever its failings, Fortran is the only language out there being designed explicitly for scientific programming. Scientific programming is both more subtle (per line) and less complicated (in structure) than, say, a web server, and it just needs different tools. Garbage collection, for instance, is almost never useful for solving large 2d/3d PDEs where your primary data structures are fixed.

Any programming language that doesn't even have multi-d arrays as first-class objects can be dismissed immediately for scientific programming. and that's all of the C-based languages. Any programming language which is inherently god-awful slow -- Java, I'm looking at you -- can be dismissed immediately. Any programming language which is proprietary and requires thousands of dollars of licensing fees -- Matlab -- can be dismissed immediately.

Python and related languages are good for prototyping, and plotting is easy, and once you've got things working can write the numerical kernels in compiled languages for speed; but it again suffers from the lack of real arrays (Numpy is good, but not great) and it is s..l..o..w.

By the way -- don't ever by the Numerical Recipes books. They're crap, the algorithms they pitch are of date, and the code ranges from poor to wrong. Take a real numerical algorithms course - there's good ones on line - or buy a real numerical algorithms book -- and for the love of God, don't type in code from a book to do linear algebra or whatever; use the zillions of real, professional quality libraries out there.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Jonathan Dursi
  • 50,107
  • 9
  • 127
  • 158
6

For the most direct answer to your question, I think that kemiisto's answer is correct, with the caveats identified by Idigas.

That said, I've found more of my numerical code coming into contact with things like FTP, web, and closer to graphics. I've seen MATLAB suggested in another answer, but I've been writing more and more Python (with NumPy) and calling out to Fortran when I need the speed. I'd almost certainly not write a whole system (e.g. an entire numerical weather prediction model) this way, but it does allow me to have the best of both worlds in many respects.

Community
  • 1
  • 1
Tim Whitcomb
  • 10,447
  • 3
  • 35
  • 47
5

Or is the answer Fortran 90, 95, 2003 . . . ? Yes. For scientific computing, Fortran >=90 removes the limitations of FORTRAN 77. Learn how to use allocatable arrays to have dynamically sizable arrays. Learn how to use modules to organize your procedures and variables -- and easily provide automatic consistency checking between actual and dummy arguments. Starting from FORTRAN 77, you can gradually learn Fortran 90/95/2003, using whichever features seem useful to you. You don't have to learn the OO features and can ignore that portion of the language, until perhaps someday it offers utility to you.

I recommend the Metcalf, Reid and Cohen book.

Community
  • 1
  • 1
M. S. B.
  • 28,968
  • 2
  • 46
  • 73
4

You may be looking at MATLAB. Many engineer undergraduates learn that so I think it's easy for non-programmers to grok.

If you want to get hardcore, take a look at J.

kizzx2
  • 18,775
  • 14
  • 76
  • 83
  • 5
    J is a horrible suggestion. One of his criteria was "easy to read". I can't think of a language that is harder to read. – Turtle Aug 23 '10 at 16:49
  • 2
    @Turtle: You're right. I said that half-wittingly. I'm also surprised that got upvoted thrice :P – kizzx2 Aug 23 '10 at 16:54
  • Matlab is indeed a nice choice for undergraduates and many more; it has a lot of nice features, and it's graphical capabilities, are, well, practical to say the least, in a number of situations. But, just like every "pro" has a "con", it suffers from some historical development issues. To me, when I was (still do for some things) using it was organization of larger programs, sometimes bad documentation (incorrect on some issues) and backward incompatibility (combined with the fact that it was a /one company language/ -> fear). – Rook Aug 23 '10 at 21:29
  • Just so this is not misunderstood; I still think of it as excellent for some purposes, such as rapid prototyping in some fields. – Rook Aug 23 '10 at 21:31
2

I think Fortran 95 should be your choice it looks more modern and extends Fortran 77 quite significantly. The Fortran 2003 standard is not completely supported by most compilers. The great advantage of Fortran is that there is an optimized subroutine for every mathematical problem (such as root finding, matrix multiplication, eigenvalue problems, etc.). Other people mentioned legacy libraries and lapack is just one very powerful example. A major disadvantage of Fortran is that nobody is using it in the real world.

The best book around is is my opinion "Fortran 90/95 for Scientists and Engineers".

Of course all other suggestions are valid, but matlab is not free while Fortran is.

Python is free and has support for a lot of scientific applications through extra packages such as Numpy and Scipy. Python is however rather slow when it comes to numerical performance. It's probably a good option for small projects that don't require a lot of computational power. The syntax is very easy to understand.

C is of course also a free option and has a lot of (constantly updated) scientific libraries available. However, when it comes to readability it cannot beat Fortran. Fortran is well set-up to work with vectors and arrays.

C++ is a superset of C so it's definitely also a possible choice. However, it is a language that might be to complex for the problems that you're looking at. The number of scientific C++ libraries is rather limited. There are some around but they cannot beat the Fortran versions (or are just wrappers of those). It's probably a very good option for very big projects but some very big programs that run on the world's fastest computers are written in Fortran. C++ is definitely worth learning since it is used for a broad number of real world applications.

There are of course other languages or tools but I think these are the most commonly used across scientific disciplines.

Lucas
  • 918
  • 1
  • 9
  • 18
1

If you're really excited about using Fortran, you might consider using Fortran for Microsoft.NET. The idea behind this project is that it allows you to use the Fortran language while taking advantage of a mangaged code environment via the Common Language Runtime (CLR).

Ben McCormack
  • 32,086
  • 48
  • 148
  • 223
  • 4
    Mybe mine is a stupid question, but how does CLR help non-programmers scientists? – Federico klez Culloca Aug 23 '10 at 16:51
  • 2
    I'm guessing, but garbage collection would be quite helpful. – Turtle Aug 23 '10 at 17:03
  • 1
    @klez Well, If you have ever worked in a constrained library you would probably know this. The CLR and Java's runtime have support for thousands of operations that old Fortran compilers couldn't dream of. GUI creation when necessary, easy graphing, arbitrary precision math and real-world data collection capabilities would all greatly benefit a non-programmer tying to develop software to solve a real-world "science" problem. – Bill K Aug 23 '10 at 17:05
  • You don't have to be a CLR expert to *consume* the CLR and gain its benefits. F# has gained immense popularity in academic/research communities and it compiles down to the same IL code that runs on the CLR as C# and VB.NET. If the OP likes the benefits of Fortran but wants to be able to run it in a modern environment, Fortran for .NET seems like an excellent choice. Heck, if you wanted, you could write your own "number-crunching" libraries in Fortran and consume them in an easy GUI-based framework such as WinForms or even a console application. This idea is just one option among many. – Ben McCormack Aug 23 '10 at 18:38
0

I've worked recently with a lot of Matlab, and I can see it's benefits today. Yes is is slow because it is an interpreted language, but it's matrix algorithms are fast. And I like it exactly because of that behavior. The slowness of the for loops and the performance of the matrix operations encourage you to think in a more mathematical way instead of sticking to loop oriented programming. But I can agree that Matlab can be dismissed, because it is not open.

Currently I am looking forward to the Julia language. It is heavily inspired by Matlab except that it does want to be fast. Also it has static types which is also a very big advantage. But Julia is still very young, so do not expect that does already fulfill all your requirements.

Arne
  • 7,921
  • 9
  • 48
  • 66
0

@S.Lott: Cannot imagine Fortran users such as scientists, having to switch over and dump all their Fortran work..... :S The OP is looking for input on what's new...

To the OP: Have you read up on Wikipedia which details the changes made to Fortran, for 2003 version, allows interoperability with C, so maybe S.Lott does have a point, perhaps, bit by bit, gently port some stuff over or write a wrapper in C to call the Fortran modules? I'll quote from that Wikipedia page...

Interoperability with the C programming language.

t0mm13b
  • 34,087
  • 8
  • 78
  • 110
  • 5
    Modern Fortran is much better than C. So the advice to port some code to C is bad to say the least. – Wildcat Aug 23 '10 at 17:02
  • 1
    Yes, I've read about the updates since 1990, and I'm skeptical about some of their suitability for non-programmers --- object orientation? recursion? pointers? – JasonFruit Aug 23 '10 at 17:07
  • "Cannot imagine Fortran users such as scientists, having to switch over and dump all their Fortran work". The question is a search for a programming language. So, what point are you making? That changing programming languages is bad? Impossible? Unimaginable by you? – S.Lott Aug 23 '10 at 17:08
  • 1
    @S.Lott: I'm talking about from a perspective of $$$$ Can the scientists afford to ditch *ALL* of their codebase and go through some intensive courses to learn another language.... not in your words *unimaginable by you* or *impossible*... wise up! – t0mm13b Aug 23 '10 at 18:02
  • @tommieb75: "I'm talking about from a perspective of $$$$"?? Why? That's not part of this question? Why are you mentioning this? – S.Lott Aug 23 '10 at 19:22
  • $$$ are part of any reasonable question. It is one of the few objective criteria which can be applied to most of life's choices. – Rook Aug 23 '10 at 20:14
  • @ldigas: First. That's not part of this question. Second. And far more important. You don't know how much of a Fortran code base they have. Nor do you know anything about the quality of the code base. Rewriting in C could be the best way to improve it. Since we haven't actually seen the code (nor do we even have metrics on the volume of code) these random considerations of cost seem way out of place. Perhaps you should open a new question on "cost of conversion of an unknown and unspecified code base from F77 to C"? Since we have no facts, why is this so important? – S.Lott Aug 23 '10 at 20:51
  • 2
    @S.Lott: Right, let's put this back on you - what makes you think that the existing code (regardless of lack of posting metrics etc) can be rewritten into C - HOW do you know that? The OP did not give any clear indication - but yes I can see your viewpoint as much as I hope YOU can see my viewpoint also! These needs to be considered firstly before 'diving in and you making that recommendation into rewriting the codebase into C...' Why is everyone so quick to jump in and say 'Rewriting in C could be the best way to improve it' without looking at other angles also!? – t0mm13b Aug 23 '10 at 20:54
  • @tommieb75: Where in the question did it say "rewrite"? – S.Lott Aug 23 '10 at 21:03
  • @S.Lott... let me quote your comment you wrote above addressed to ldigas... **Rewriting in C could be the best way to improve it** ^^^^ so do not twist up my words... – t0mm13b Aug 23 '10 at 21:12
  • @tommieb75: "having to switch over and dump all their Fortran work" Why did you say that? Rewrite is not in the question. Dump their Fortran work is not in the question. Why say that when it's not in question? I did not "twist up your words". I'm trying to understand why you keep mentioning cost and dumping Fortran. It's not in the question. – S.Lott Aug 23 '10 at 21:17
  • @S.Lott: All of this stemmed from your answer which you posted earlier on and was down-voted and ended up on the bottom of this page (I did not down-vote you btw in case you're wondering) as it was not the answer the OP was looking for as I was against that opinion you expressed. – t0mm13b Aug 23 '10 at 21:21
  • 2
    @S.Lott - I see you are wise in the ways of the taking a discussion, while putting practical aspects aside (until it becomes purely theoretical and the only goal is to win the argument). Unfortunatelly, I've given up on that trolling game some decades ago. – Rook Aug 23 '10 at 21:21
  • ... and there it goes ... meaningless comments, catching other people's words, instead of understanding their meanings, in hope of winning for no purpose whatsoever. I can't want to see who'll mentionn Nazi's first :-)))) – Rook Aug 23 '10 at 21:24
  • @tommieb75: "having to switch over and dump all their Fortran work" Why did you say that? I'm just trying to understand the comment. Please explain the comment. That's all I'm asking. I don't care about downvotes. I'm trying to understand the comment. Please explain why "dump all their Fortran work" is so important when it's not in the question. Please explain. – S.Lott Aug 23 '10 at 21:34
  • @S.Lott: This is my last comment to this. Look at it another way, with 94.1K reps and 13347 views expressed, you *should* know! I spelled it out, justified it. You're missing what I've said as all of this was in *response* to your post! What I do find **remarkably odd** is this - you were quick to point out in your post *Sounds like C. Buy Numerical Recipes in C. etc*, but reading your comment underneath addressed to Bill.K **I agree that C is complex. Personally, I avoid it as much as possible** This begs the question why did you post it in the first place? You argued instead - go figure! – t0mm13b Aug 23 '10 at 22:01
  • @tommieb75: Please explain why "dump all their Fortran work" is so important when it's not in the question. Please explain. I understand you're responding to a comment. I don't understand the response. Please explain it. – S.Lott Aug 23 '10 at 22:03
-1

Simple to learn (no object-oriented or functional-programming complications)

Easy to read

Blazing fast at number-crunching

Sounds like C.

Buy Numerical Recipes in C. That pretty much covers all the bases in a clear, readable style.

http://www.amazon.com/Numerical-Recipes-Art-Scientific-Computing/dp/0521431085

Community
  • 1
  • 1
S.Lott
  • 384,516
  • 81
  • 508
  • 779
  • 7
    C is not neither easy to learn nor easy to read. And it's not for number crunching. http://latticeqcd.blogspot.com/2006/11/why-we-use-fortran-and-python.html – Wildcat Aug 23 '10 at 17:14
  • @kemiisto: Take it up with the Numerical Recipes authors and readers. Not me. They seem happy, even if you Georg von Hippel aren't happy. – S.Lott Aug 23 '10 at 17:17
  • 6
    When I compare the ease with which I picked up FORTRAN 77 with the difficulties I've had with C, I have a hard time recommending C for the non-programmer. Still, +1, since this seems to be what a lot of people are doing, rightly or wrongly. – JasonFruit Aug 23 '10 at 18:06
  • 4
    Can anyone name a worse choice as far as easy to use? Readability you MIGHT have competition with WORN (write once read never) languages like APL. I'm serious--please attempt to name one. – Bill K Aug 23 '10 at 19:15
  • @Bill K: Perl is a WORN language. Far more so than C. Again, you may have personal problems with C. But you'll have to take it up with the Numerical Recipes in C folks. They're happy and successful using C for scientific computing, not matter how many problems you see with what they're doing. – S.Lott Aug 23 '10 at 19:21
  • 1
    @S.Lott - what is the point of your above comment ? You state something and then reffer to "folks at NR"? Argument it if you wish it to stand. – Rook Aug 23 '10 at 21:09
  • @ldigas: My argument remains the same. Other folks are happy and successful using C for scientific computing. I personally would never use it. But my preferred scientific programming language has "functional-programming complications". My point is simple. Other people use C. Simply discarding C as "not for number crunching" or the worst "choice as far as easy to use" seems to fail to recognize that it's already being done by people who are already successful. Their success is my argument. – S.Lott Aug 23 '10 at 21:13
  • 2
    @S.Lott I admitted other languages might be less readable, but I can't imagine one less easy to use--where you have to keep track of memory allocation, deal with pointers vs references and can't even use "abc" + "def". Ease of use. I'm coding in C right now, by the way. – Bill K Aug 23 '10 at 21:24
  • @Bill K: Please look at the book. They provide macros, hints, techniques, suggestions, libraries, all kinds of support for make C not so complex for numerical calculations. I agree that C is complex. Personally, I avoid it as much as possible. But the question -- as asked -- sure seems to point toward C as a candidate answer. "no object-oriented or functional-programming complications" and "Blazing fast at number-crunching". Nothing can touch C for these two features. It's uncluttered buy OO or FP. And it's fast. – S.Lott Aug 23 '10 at 21:37
  • @S.Lott - Where did I disgard it in that manner (catching words here; really annoying habit I learned off some in here :) But to say "Their success is my argument." is an an oxymoron by itself. What is better - a 747 or a Concorde for fast flying? Obviously, a 747, since so many happy and successful air companies use it - their success is MY argument. – Rook Aug 23 '10 at 21:49
  • 1
    @S.Lott 2nd comment (please keep it clear when answering this one; this is gonna turn confusing anytime now) - actually, Fortran can quite catch it in that field - C is fast when used properly, no one is arguing that. But it is a language designed originally for text processing, and it takes a significant effort to optimize it in a way that match optimization of Fortran's compilers in combination with a properly written program. For, in contrast to C, Fortran was written primarily for nc. (num. calc.), and its compiler's writers have for a long time now, been working on methods for improving – Rook Aug 23 '10 at 22:00
  • primarily that. I've seen many "optimizations" in many cases, in several languages, only for them to turn out several orders of magnitude slower than the basic algorithm with some compiler options turned on/off. – Rook Aug 23 '10 at 22:01
  • @ldigas: C simple. C is fast. And -- most importantly -- C is already used for this. I hoped that "it's already used for this" would be enough. I hoped that providing factual evidence for "it's already used for scientific computing" would be enough. It's hard to provide more factual evidence than books, authors, readers and users. We can debate many features of the language. But we can't debate people already using it. My point is to avoid the debate and present the only fact I have. It's my only fact. I have no others. – S.Lott Aug 23 '10 at 22:01
  • @S.Lott - Apart from repeating that your argument isn't really an argument, and from a plea that you try to read my last/semilast comment with understanding, I've really nothing to add to this. 'cept that it's now closing to 01 a.m. in my part of the world, and that I'm going to sleep. So, do not take my not answering your comments the wrong way - although I will probably not be answering them anymore anyhow. – Rook Aug 23 '10 at 22:42
  • @ldigas: I'm not sure what your point is. I presented my facts. What more do you want? – S.Lott Aug 23 '10 at 23:36
  • 1
    @S.Lott --- My preferred scientific programming language also has functional-programming complications --- and I love that. But for a scientist who is not primarily a programmer, I think it's more complication than they need. Would you disagree with that? – JasonFruit Aug 24 '10 at 03:25
  • 6
    The Numerical Recipes book in C was first written when Fortran was FORTRAN 77 (1st edition 1985, 2nd edition 1992 -- even then Fortran 90 was rarely available). FORTRAN 77 has several deficiencies, so people were switching to C in that era. But we have long had Fortran 90, which rectifies those deficiencies, e.g., providing dynamic memory allocate. Fortran 90/95/2003 are a higher level languages that I would strongly recommend in preference to C for scientific programming. I mix Fortran & C in order to reuse existing C code. – M. S. B. Aug 24 '10 at 07:18
  • @M S. B: That F77-to-C is the same evolution I'm suggesting here. – S.Lott Aug 24 '10 at 09:58
  • @JasonFruit: "I think it's more complication than they need" No. Functional Programming is not a "complication". It's a simplification. I find it to be a considerable simplification. And quite easy to learn. But you removed it from the answer *a priori*. – S.Lott Aug 24 '10 at 09:59
-2

I assume you are considering small, dedicated programs written to solve specific problems. In that case, if the complexity of OO really bothered you I'd just write a C# or Java app and not use OO. Visual Basic should be pretty darn fast these days as well.

Nearly all compiled languages will be mathematically quick these days, all operations are done on the math co-processor--so unless you have found some language to be particularly lacking I wouldn't let any languages "math speed" bother me much.

Bill K
  • 62,186
  • 18
  • 105
  • 157
  • 2
    " Nearly all compiled languages will be mathematically quick these days, ... " - hardly. Even simple programs (models) can become very slow very quickly when it comes to commercial applications (where the grids have to be refined in a way not such to show only trends, but to give practical results). – Rook Aug 23 '10 at 18:57
  • @Idigas isn't that the program's implementation more than the language? I'm pretty sure if you check the "Programming language shootout" you'll find C & java to be about 2-5x faster than Fortran even for heavy math stuff like the Mandelbrot benchmark. That's still not bad--they are all in the same general area (10x speed from each other, whereas Ruby and others tend to be 100x slower). – Bill K Aug 23 '10 at 19:11
  • "Programming language shootout" - which has been discussed numerous times before (just google it, you're bound to stumble onto one of them discus.) is not an objective criteria for speed, since it obviously fits some more than others. Want an opposite example; write a sparce system solver in most of those (or pretty much anything similar). – Rook Aug 23 '10 at 20:07
  • @Idigas Actually, it's a pretty good criteria since it has a variety of different problems it solves and each problem can be tailored to be faster by people who are the best programmers in a given language. If you think your language isn't adequately represented, submit a better test or solution. It is biased that it runs on Linux so it can't represent languages that only reside on a single platform. – Bill K Aug 23 '10 at 21:33
  • 2
    @Bill K - (btw, my name is Ldigas, but I agree, in this font the error is easily made) - No, no. Quite the opposite. I'll go from the last, if you don't mind. Platforms aside; 'tis not that relevant, so we can skip that for now. As far as "each problem can be tailored to be faster by people who are the best programmers in a given language" - it's simply not correct. Instead of putting it in my own words, I'll link to http://stackoverflow.com/questions/1196814/fortrans-performance/1236830#1236830 who's already put it nicely (particularly first paragraph). Second, to submit my own problm; – Rook Aug 23 '10 at 22:29
  • why would I want to do that? Like the above said, I've nor the motivation, nor the time, nor the will. But a good counter example of "variety of different problems" as you say, is a fact, that I cannot recognize not one problem which would befit traditional engineering disciplines, in two or three fields (depending how you look at it), which I'm to some moderate extend familiar of. – Rook Aug 23 '10 at 22:31
  • @ldigas That answer had no example of performance--just more theories. It's just not possible that Fortran (or any other language) is SIGNIFICANTLY faster (say within 3x) to EXECUTE than C, C++ or Java and is likely a bit slower but still darn fast--but they all run at very close to machine speed. Some languages may be easier to code and some are easer to code efficiently. Fortran may have libraries that already do some things very efficiently whereas on other languages those libraries don't exist and people create sloppy replacements, but that has nothing to do with the language itself. – Bill K Aug 24 '10 at 17:33
  • @Bill K - Uhm, yes/no ... you're losing me here now. On what comment is this a reply? No, the answer has no example of performance - it just gives an opinion very similar to mine on those benchmarks (see also my upper comment). I linked to it as not to repeat the same thing here. Why the "yelling" ? – Rook Aug 24 '10 at 18:19
  • @Idigas Sorry about the emphasis, I forgot caps tend to mean yelling--just couldn't figure out how to do italics in comments. I wonder if many math fortran libraries are hand-coded in assembly or something, otherwise there is just no way it's as fast as C and is going to be much difficult to code large solutions in than any modern language as far as having a usable IDE, decent error handling, coding-time error correction and all the other things that make programming scalable these days. – Bill K Aug 24 '10 at 20:30
  • @Bill K (from LDIGAS <- please :) - No, from my understanding they are not in most cases hand coded in assembly. Exceptionally some small parts. But, let me try to put it from another perspective - from the beginning. Assume equal speed of C and Fort. (just so we put a stop to that part of this discussion, which is leading us nowhere. I'm sure you'll agree.). I'm sure you'll also agree that for many types of libraries which deal with stuff fortran is used for, effort/cost for implementing a function (not a programming function, but as a feature function) is greatly on the side of fortran - it – Rook Aug 25 '10 at 00:45
  • is purely simpler and much more quicker to write it. Combine that with rather rigorous optimizations from the compiler side, which are very strong in that respect (speed was always more important in fortran then C, simply by nature, since in fortran that was the only measure in a lot of cases) and maybe some low level optimizations, and you'll quickly come to the conclusion that for many purposes, it is, even for things which require performance, unplausible financially to try to write it in for example, C. This is an argument which still stands today. Hopefully, that answers the first part of – Rook Aug 25 '10 at 00:46
  • your question. As far as the second part goes, no, it is not overly difficult to code large projects in fortran (functions, subroutines, modules, private/public, interfaces ... >=F90 versions have extremelly nice organization features), although I agree, it is missing a little on the side in regards to tools which support it (IDE's for example). You mentioned error handling - many errors which you commonly encounter in C are however very hard (sometimes – Rook Aug 25 '10 at 00:46
  • impossible) to produce in Fortran programs (segfaults for example). It's rules/design regarding pointers, aliasing, passing array infomation, restrict quite a few of those errors, to a point where they become quite rare in practice. One can of course, always produce an exception, but those are, as their name says, exceptions. – Rook Aug 25 '10 at 00:48
  • *italic with stars* <-- yup, just checked it myself. For italics use stars (as in multiplication). **bold with two stars** For bold two stars (as in fortran exponential operator). – Rook Aug 25 '10 at 00:49
  • @Ldigas I agree wrt C, wouldn't use it. I'm writing mathematical libraries in Java right now. The infinite precision, speed, strict typing, strict error checking, etc are really helpful. I'm not crazy about the syntax for this particular problem set. Generally it's great, but Java is better for making solutions than for making libraries. Perhaps we should come up with a fairly simple benchmark, each implement it and see where we end up? I think the ideal might be to make a new language that allows nicer mathematical syntax but compiles to a known fast language like Java, C#, ??? – Bill K Aug 25 '10 at 17:27
  • @Bill K - It is not a problem to write/to make something, but to make it in a way so that people will want to use it, yet still for it to be "good" (in numerous criteria). After all, these last 5 decades, one can find a number of "great languages which are the future" (or so it seemed) which practically you can't even hear of today. Here, an article which deals with the idea that we should write a new language for hpc to replace fortran. http://cacm.acm.org/magazines/2010/7/95060-the-ideal-hpc-programming-language/fulltext – Rook Aug 25 '10 at 18:10