Optimizing Programs: Fortran or Visual Basic?

In summary, Fortran is a language that is still used for number crunching, and it has been around for a long time.
  • #1
Paul_Sm
1
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
  • #2
  • #3
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.
 
  • #4
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
 
  • #5
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.
 
  • #6
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.
 
  • #7
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
 
  • #8
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.
 
  • #9
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:

Related to Optimizing Programs: Fortran or Visual Basic?

1. What is the difference between Fortran and Visual Basic?

Fortran (short for "Formula Translation") is a high-level programming language primarily used for scientific and engineering applications. It is known for its efficient handling of mathematical and numerical computations. On the other hand, Visual Basic is a modern, user-friendly programming language commonly used for developing graphical user interfaces (GUIs) and applications. It is easier to learn and more versatile than Fortran.

2. Which language is better for scientific computing, Fortran or Visual Basic?

Both Fortran and Visual Basic have their own strengths and weaknesses. However, Fortran is generally considered the better choice for scientific computing due to its efficient handling of numerical operations and its extensive library of scientific functions. Visual Basic may be more suitable for developing user-friendly interfaces for scientific applications.

3. Can Fortran and Visual Basic be used together in one project?

Yes, it is possible to use Fortran and Visual Basic together in one project. Fortran can be used for the computational and numerical aspects of the project, while Visual Basic can be used for developing the user interface and other non-computational tasks.

4. Is Fortran or Visual Basic easier to learn for beginners?

This ultimately depends on the individual's background and learning style. Fortran may be easier to learn for those with a strong mathematical or scientific background, while Visual Basic may be more intuitive for those with little programming experience. However, both languages have a relatively simple syntax and are considered beginner-friendly.

5. Are there any notable differences in the performance of programs written in Fortran vs Visual Basic?

Fortran is generally considered to be faster and more efficient than Visual Basic, especially when it comes to numerical and scientific computations. This is due to Fortran's low-level programming capabilities and its optimization for mathematical operations. However, with modern advancements in technology, the performance gap between the two languages may not be as significant as it once was.

Similar threads

  • Programming and Computer Science
Replies
30
Views
4K
  • Programming and Computer Science
Replies
4
Views
7K
  • Programming and Computer Science
Replies
4
Views
14K
  • Programming and Computer Science
Replies
2
Views
3K
  • Programming and Computer Science
Replies
8
Views
5K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
14
Views
4K
  • Programming and Computer Science
Replies
5
Views
3K
  • Programming and Computer Science
Replies
4
Views
70K
Back
Top