Fortran Optimizing Programs: Fortran or Visual Basic?

  • Thread starter Thread starter Paul_Sm
  • Start date Start date
  • Tags Tags
    Fortran Visual
AI Thread Summary
The discussion revolves around the choice between Fortran and Visual Basic for rewriting legacy BASIC programs related to structural engineering. Users express a preference for modern programming languages that are more versatile and easier to maintain. While some advocate for Fortran due to its long-standing use in numerical computing, others suggest that Visual Basic is declining in relevance. Python emerges as a strong alternative, praised for its simplicity and extensive libraries like NumPy and SciPy, which can significantly reduce code length and enhance cross-platform compatibility. Emulators for DOS are also mentioned as a way to run existing BASIC programs without rewriting them. The conversation highlights the ongoing debate about the longevity of programming languages, with Fortran still being viable for specific applications, while newer languages like Python are seen as more user-friendly and productive for casual users.
Paul_Sm
Messages
1
Reaction score
0
Fortran / Visual Basic ??

I wrote more then few dosens programs in all flavors of Basics, mostly in DOS. Unfortunatelly with the new Windows systems, 32, 64 bit they are no longer usable. I would like to rewrite some of them. It is mostly structural engineering, cams, linkages. The codes are not that huge, from 120 up to 500 lines. Should I go for Fortran, I have to relearn it, or go with Visual Basic. I would like to compile it as the stand alone and be able to run it on Windows 7 and 8, both 32 and 64 bit systems.
Thanks for the advise.
 
Technology news on Phys.org
Yeah, I like Fortran too...

...but, for the same reasons that an old fortran program can simply be re-compiled with a current compiler to get it working again...what's wrong with just getting a current BASIC runtime?

You don't even need a DOS emulator, just get BASIC for today's computers and you may be up and running with minimal changes...wouldn't you? http://www.basic256.org/index_en.

my 2 cents.
 
If you've decided to go through the trouble of re-implementing your programs in a modern language, don't go halfway! Visual Basic is a dying language, along with the rest of Microsoft's grubby attempts. FORTRAN has already been dead for decades.

Python, along with libraries like numpy, scipy, and matplotlib, will provide an environment where you can probably write your programs in 10 lines instead of 500. Your programs will be simple, easy-to-read, and cross-platform, and will run virtually anywhere (any version of Windows 7/8, any version of Mac OSX, any Linux machine).

If you want to play with some Python, check out sagemath.org. Sagemath pulls together a huge number of mathematical and scientific libraries into a single interface, and you can run it entirely in a web browser. You may find that your programs can be implemented very simply as notebooks in Sagemath.

Your desire to compile the program into a single executable is understandable, but real-world situations rarely demand it. Design your code so that it is easy to read and easy to maintain, and you'll avoid having to go through this same battle again in a few years.

- Warren
 
http://sourceforge.net/projects/fbc/ -it is called FreeBASIC

was a replacement for qbasic. Although chroot's idea has a lot of merit, if you are not a programmer you probably would rather just use your code rather than learn python and redevelop "dozens" of programs.

It is now a compiler, so the compiled code runs pretty fast compared to qbasic which was originally interpreted.
 
Don't believe everything the Python fanboys say. Fortran has been evolving for over 50 years and has quite a large code base developed. I prefer F77, but there are F90/95 compilers out there as well.

I frankly am puzzled about the animus against Fortran. First, BASIC and Algol were developed to replace Fortran, but they fell by the wayside. Forth was kind of a flash in the pan, here today and gone tomorrow (30 years ago at least). Then, ADA was the next big thing, along with Pascal. C and all of its variants are making a valiant attempt, but Fortran is not dead yet. With the advent of the internet, Java, Python, and a whole host of other languages are playing king of the hill. Which will survive, and for how long?

When today's Python fans move into assisted living, there will still be some kind of Fortran knocking around.
 
SteamKing said:
I frankly am puzzled about the animus against Fortran.

Compared to modern languages, it's difficult to read, write, and maintain.

Python uses NumPy, which is based on LAPACK, which is written in Fortran 90... so please bear in mind that I'm not suggesting that all Fortran code should be abandoned. I just think that, for casual users, languages like Python are easier to learn and provide greater productivity.

- Warren
 
Yeah, I was surprised by chroot's attack, too.

Around forums for sometime, I have learned not put down anything when uncalled for...just present what you like and stay away from putting down something else...chances are you do not know everything about it, because you don't like it, because you don't use it.

And, yes, Fortran is very much alive. No, it is not a systems programming language and it was not invented to write operating systems or control hardware; it was invented for number crunching and handle giant arrays, etc...and it's been doing that, very well, for over 5 decades.
 
I am all for Python, too...with everything in it and the kitchen sink
 
  • #10
and f2py :-)
 
  • #11
Although this may not apply to the type of basic programs you currently have, some of my co-workers use visual basic since it's very easy to create chart and graph type user inteface stuff (the programmer drags / drops / edits graphical stuff on the development screen, and visual basic generates code).
 
  • #12
For this situation, I would highly recommend FreeBasic.
 
  • #13
VB .Net is of course well suited for component-centric design and implementation.

So if the apps are meant to cooperate with one another AND possibly with other yet-to-be-written MS-platform specific apps (.Net Server e.g.) migrating to VB .Net should be seriously considered.

In any other cases I would recommend Fortran 95, because that's yet still sort-of lingua franca for numerics and works fine with MPI.
 
  • #14
chroot said:
Python, along with libraries like numpy, scipy, and matplotlib, will provide an environment where you can probably write your programs in 10 lines instead of 500. Your programs will be simple, easy-to-read, and cross-platform, and will run virtually anywhere (any version of Windows 7/8, any version of Mac OSX, any Linux machine).

I like Python a lot and have used it regularly for over a decade, BUT I don't understand why Python and pythonic wrappers are apparently considered the solves-it-all tools¹ by some.

---

Look at scipy's scipy.optimize.curve_fit for instance:

scipy.optimize.curve_fit(f, xdata, ydata, p0=None, sigma=None, **kw)
Use non-linear least squares to fit a function, f, to data.

Assumes ydata = f(xdata, *params) + eps

Parameters :
f : callable
The model function, f(x, ...). It must take the independent variable as the first argument and the parameters to fit as separate remaining arguments.
xdata : An N-length sequence or an (k,N)-shaped array
for functions with k predictors. The independent variable where the data is measured.
ydata : N-length sequence
The dependent data — nominally f(xdata, ...)
p0 : None, scalar, or M-length sequence
Initial guess for the parameters. If None, then the initial values will all be 1 (if the number of parameters for the function can be determined using introspection, otherwise a ValueError is raised).
sigma : None or N-length sequence
If not None, it represents the standard-deviation of ydata. This vector, if given, will be used as weights in the least-squares problem.
Returns :
popt : array
Optimal values for the parameters so that the sum of the squared error of f(xdata, *popt) - ydata is minimized
pcov : 2d array
The estimated covariance of popt. The diagonals provide the variance of the parameter estimate.

That's for sure a most handy interface, seemingly much more enjoyable that minpack's lmdif, lmder, lmstr et al.

But now look at p. 13 of the minpack User Guide ch 1-3.

If I know the Jacobian, and in many cases I will "know" it, because it's often trivial to calculate it, I have a more analytically oriented interface.

---

From experience I can also tell that Fortran modules I write often have a degree of re-usability and code stability that is unprecedented by any Python stuff I ever wrote. Of course one may argue that this totally depends on the programmer, but in this case the Fortran coder and the Python coder of the stuff I'm talking about is the same person (which happens to be me).


¹Look at p. 6 of the supplemental slides of http://channel9.msdn.com/Events/GoingNative/GoingNative-2012/Keynote-Bjarne-Stroustrup-Cpp11-Style?format=flash for a rigorous definition of "tool" :smile:
 
Last edited:

Similar threads

Replies
3
Views
8K
Replies
2
Views
3K
Replies
8
Views
6K
Replies
4
Views
71K
Replies
14
Views
5K
Replies
6
Views
12K
Back
Top