Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.mso.anu.edu.au/pfrancis/ObsTech/WhichLanguage.htm
Дата изменения: Tue Apr 10 10:16:58 2007 Дата индексирования: Tue Oct 2 05:05:51 2012 Кодировка: Поисковые слова: merging galaxies |
In astronomy, here is my subjective league table of language popularity:
Rank |
Language |
1 |
Fortran |
2 |
C & variants |
3 |
Perl |
4 |
IDL |
5 |
Python |
6 |
Java |
Fortran and C are used for high performance applications.
Most code more than 10-15 years old (in its initial form) will be in Fortran.
IDL is used for data analysis and graphics. Perl is used for scripts and short
programs. Python seems to be gaining popularity fast, for data analysis and
virtual observatory work. Java is used for user interfaces (such as the Gemini
observing tool). C is used for real-time telescope and instrument control.
In the real world, there have been many attempts to gauge the
popularity of different languages, but most modern league-tables look something
like this:
Rank |
Language |
1 |
C & variants |
2 |
Java |
3 |
Perl |
4 |
Visual Basic |
5 |
Python |
6 |
Pascal/Delphi |
7 |
COBOL |
8 |
Ruby |
9 |
Tcl/Tk |
10 |
Fortran |
Advantages of a language that is popular in the real world
are the existence of web resources such as tutorials, a wide range of libraries
of existing code you can use and modify, and better job prospects for you if
you ever want to venture into the real world.
There have been various studies of how many lines of code
are needed to write a given program in different languages. Languages seem to
fall into two camps:
Most studies find that ~ 5 times more lines of code are
needed in low level languages to perform a given task. Given that the number of
bugs scales as a fairly high power of the number of lines of code, this can be
a HUGE advantage.
Once again you can break languages up into two groups: fast
and slow.
Most studies find that the fast languages are 3 – 100
times faster, depending on what you are trying to do. So donуt try to simulate
a billion stars in Perlи
There are immense amounts of existing code out there that
you can borrow and re-use in your own programs. This generally will save you
months of effort – if you are not using these libraries regularly, you
are shooting yourself in the foot.
Numerical libraries (solving equations, matrix
manipulations, random number generation).
Interfacing with Astronomy Data:
Data reduction:
Text/Web handling:
Virtual Observatory:
Plotting:
Use C or Fortran. Probably C would be the language of choice
unless you are building on existing Fortran code. This is because (a) there are
more libraries available, and (b) it might get you a job outside of astronomy
at some future time.
A common variant is to write most of the code in Perl or
Python, but write the performance-critical bits of code in C or Fortran. They
can easily be called from Perl or Python.
Most programs take days or weeks to write and debug, but
only seconds to run. Perl or Python are best for these.
Scripting is writing a program whose main purpose is to run
other programs repeatedly. Such as taking lots of data files, sorting them out
and processing them. Use Perl or Python for this. An alternative is a UNIX
script, or Tcl/Tk.
If your program will have more than ~ 100,000 lines of code,
and is being developed by a team of 10+ programmers, JAVA is apparently the
code to use, as itуs designed to avoid common problems that beset this sort of
mega-project. C# would be a (Microsoft-only) alternative.
IDL or Python. IDL has more pre-written code available, but
is expensive so not everyone may be able to run your code. Python is probably
the nicer language and is free, but is harder to install.