Java as a scientific programming language

xiaoxiao2021-03-06  90

Java as a scientific programing language (part 1) by Ken Ritley

WE LIVE IN A TECHNOLOGICAL World, At The Heart of Which Arei Scientists and engineers. The next proportant discoveries and bring the next generation of technology to market.

In this article, we'll discuss what scientific programs are and whether Java is suited for the high-performance, numerically intensive applications which technical applications demand -. In short, whether Java has a future for scientific computing We'll also provide a list of resources for scientists new to the Java language. In Part 2, we'll examine the structure of a typical scientific program more closely, and we'll give you a short "style guide" that can help scientists write good Java programs.

The Programs Scientists Use

When the author developed scientific programs as a physics undergraduate in the early 1980s, there was only one type of scientific program: the type you wrote yourself, in Fortran, for large multi-user mainframe systems.

Types of Scientific Programs Commercial scientific applications accomplish some specific task, such as image processing, the analysis of electronic circuits, the simulation of load-bearing structures for mechanical engineering, and so forth These are usually complete with fancy graphics and GUIs -. And cost hundreds to thousands of dollars. Scientific programming environments, such as Mathematica, PV-Wave, MathCad, Origin and Igor Pro, are perfect examples. Similar to the traditional programming IDEs that programmers know and love, these are what scientists and engineers use for their daily work. Some type of procedural programming language (similar to Fortran) is bundled with a user-friendly GUI and packaged with copious scientific tools for solving equations, plotting data, dealing with huge arrays of numbers, performing simulations, and so on. It's Here Test A New Idea, Develop A Scientific Model and See if IT Agrees with Experimental Data, or Devise An ew type of data analysis, for example. Traditional programming languages ​​such as Fortran and C still play a vital role in scientific research, partly because they are optimized for high-performance (many of the most important calculations take hours or days to run!) but mostly because it's too expensive to abandon the extant "legacy" code, literally thousands of Fortran and C programs written, debugged, tested, and re-tested over the decades. It's hard to believe, but many of the cutting-edge programs from THE 1970S Are Still The Scientific Work-Horses of Today. - KR

Today, the mainframe has largely been replaced by high-performance workstations and PCs, and there are roughly three categories of scientific programs: high-cost commercial scientific applications, which accomplish a specific scientific task; scientific programming environments, similar to programming IDEs but with data analysis features scientists need; and traditional programming languages, such as Fortran or C, with which scientists can write their own programs (see the sidebar "Types of Scientific Programs") It's mainly programs in this latter category that are good candidates for Java. (see the sidebar "to GUI or Not to GUI"). What Can Java Do for Scientists? Java is the ideal language for developing business applications because it includes all the tools programmers need, from low-level tools such as hashtables and linked lists , To High-Level Ones for Network Security and Corba. For scientific computing, The Case for Java Is Not So clear. Java Offers Both Advantages and disadvant ages for scientific programming. For the scientist thinking about making the move to Java, it's essential to evaluate these areas carefully. (For the non-scientific programmer, it should be instructive, as well.) To OOP, or not to OOP It's been argued that objected-oriented programming has been so successful because the world is made up of objects, and the purpose of programs is to describe them. It's an interesting argument, which doesn '

. T always apply to scientific programming An object-oriented program might be the natural way to deal with airplanes, for example: airplanes have interfaces to they connect them with other aircraft (refueling airplanes), they have properties (number of engines), and have methods (how to take off and land). In contrast, a scientist is chiefly concerned with pure numbers, such as energy or mass or the velocity of light. The idea is to start with a small collection of numbers, to perform a sequence of distinct, functionally independent mathematical-operations (say, E = mc2), and then to end up with a new set of numbers. The heart and soul of the scientific program lie in mathematical operations. Java imposes a great deal of object-oriented infrastructure on the programmer, even when it's not needed and not natural for solving a programming problem fortunately, there's no need for the scientist to become an OOP specialist -.! there are good ways to cheat and avoid the mess Java provides all the tools necessary for writing procedural (not object-oriented) programs. In Part 2 of this article, we'll offer some tips for creating creating global variables, managing libraries of pre-written procedures, and show how everything labeled "static" ( .

To GUI or Not to GUI The world of scientific programming has a Twilight Zone between two extremes: On the one hand, there are programs that take days to execute; clearly, for such programs a GUI is meaningless On the other hand, there are. programs that run quickly; clearly, for these a good GUI is essential The boundary between the two worlds is continually moving as the speed of computers increases Scientific calculations for which a GUI seems unthinkable today will undoubtedly require a GUI tomorrow This is where... Java can make an important contribution Java has built-in cross-platform capabilities for GUIs By implementing new calculations in Java, scientists can ensure that the cutting-edge programs of today will become the daily work-horses of tomorrow -... KR

"Legacy" Code It's a derogatory term. It conjures notions of dusty boxes filled with punch cards of Fortran GOTOs and Hollerith constants, and mile-high stacks of fan-fold compiler listings! As we've said, the heart and soul of the scientific program lie in mathematical operations. A scientist may spend months or years devising and testing purely mathematical numerical methods (which scientists still call subroutines). and when it's been proven that a subroutine works, it can be published in a "library", facilitating its shared use between scientists These libraries are fundamental to the progress of science:.. like libraries of books, they allow scientists to use the hard work and good ideas of generations of scientists before them In fact, many scientific programs are nothing more than collections Of Legacy Subroutines Patched Together In New Ways. Regarding Legacy Code and Java, The News Is All Bad. Java Was Born in Silicon Valley in 1995. It is a new programming language, and there fore there are few software libraries, at least few in comparison with the massive libraries for Fortran and C. It is not just frustrating - it can stop a scientific project dead in its tracks (see the sidebar "Scientific Resources in Java") And. the bad news gets even worse! from the scientific standpoint, Java is so different from Fortran and C, conversion of legacy code in Java by hand may be impossible. Java is quite accommodating of Fortran's array syntax and adjustable-dimension arrays, but Java doesn '

t support a complex number type, as will be discussed in Part 2. And although Java syntax is similar to C, the elimination of pointer arithmetic means any subroutine involving arrays and matrices - this has been called the "bread-and-butter" of Scientific Programming! - May Not Be Portable To Java. To make Matters Worse, Java Does Not Support Unconditional Branching (Goto), A Feature Very Heavily Implement in Legacy Fortran Code.

Scientific Resources in JavaScientific Resources in Java A large fraction of So the ability to put together a scientific scientific programs are patchwork creations. They may tie together dozens of library subroutines, pre-written methods that have been tested, tested, and re-tested. .. program depends crucially on the available libraries Scientific Libraries The list of scientific libraries in Java is small but growing Instead of trying to list them all, here is a meta-list of other lists which scientific programmers may find useful NETLIB:. A central resource for mathematical computing http://www.netlib.org/ Java Resources for Science and Engineering http://www.npac.syr.edu/projects/tutorials/JavaCSE/ Colt: Open Source Libraries for High Performance Scientific and Technical Computing http://tilde-hoschek.home.Crn.ch/~hoschek/colt/index.htm java numerics http://math.nist.gov/javanumerics/ java classes for Operations research http://opsresearch.com/or -Objects / INDEX.HTML JAVA NUMERI Cal Toolkit http://math.nist.gov/JNT/ Parallel Compiler Run-Time Consortium http://www.npac.syr.edu/projects/pcrc/ java grande forum http://www.javagrande.org/ Titanium : A Dialect of Java for larke-scale scientific computing http://http.cs.berkeley.edu/projects/titanium/ java access to numeric libraries http://www.cs.utk.edu/f2j/hpjhtml/ JIGL: Java Image and Graphics Library http://rivit.cs.byu.edu/jigl/ Image / J - Platform-independent Scientific Image Processing Package http://rsb.info.nih.gov/ij/ Image Processing Package in Java http : //www.ctr.columbia.edu/~dzhong/jimbia.edu/~dzhong/jim/jim.html Educational Applets The Scientific Educational Community Has Jumped on Java Applets - They're A Terrific Way To Implement "Virtual"

scientific demonstrations. As a consequence, the next generation of scientists may be more versed with Java than with traditional scientific langauges such as Fortran or C! For scientific programmers, such Java applets have something to offer, too. Many of them have well-designed user-interfaces, fancy graphics and scientific plots -.. all of which can be "borrowed" for use in your own programs This is by no means a complete list, but it's definitely worth a look Physics Education R & D at North Carolina State University at Raleigh http://sb-dell.physics.ncsu.edu/java/ http://www.physics.ncsu.edu:8380/physics_edu://webphysics.davidson.edu/applets.davidson.edu/applets/Applets .html Physics Illuminations at the University of New Orleans http://www.uno.edu/~rgreene/illum.html The Optics Project at Mississippi State University http://www.uno.edu/~rgreene/illum.html Physics 2000 at the university of coloro at boulder http://www.colorado.edu/physics/2000/index.pl Project Links At Rensselaer Polytechnic Institute http://links.math.rpi.edu/index.html soda constructor http://sodaplay.com/constructor/index.htm - k. r.

For translating between other languages, translation programs (such as f2c) have often helped. These differences between Java and Fortran / C are so significant, however, a translation program may be effectively impossible to write. Interestingly enough, there are projects underway (f2j ) to convert Fortran source code directly to Java bytecode, as well as to make other numerical libraries Java-accessible (NetSolve). For scientific programmers, these are vital steps in the right direction! Memory Like legacy code, memory and storage space is a particularly dangerous area, which requires careful deliberation before deciding to implement a scientific program in Java. in C and Fortran 90, new memory for variables can be allocated, and memory for variables no longer in use can be deallocated. Memory allocation in Java is generally NO PROBLEM; You Cancatchalocation ErroPriaTely If There's Not Enough Memory When You NEED. DEACATION IS TRICKIER. JAVA memory deallocation is handled by the so-called garbage collector, a process that runs in parallel to your program that releases memory for objects which are no longer referenced [please see Understanding Automatic Garbage Collection

]. You can Start a Garbage Collection Thread, But you can't Control It, and you can've. The memory you've. There is the problem, overde aware it exists But you still need to be cautious -.. just because you think your variables are dereferenced, they may not be, creating a nasty "memory leak" that garbage collection can not fix Speed ​​Memory allocation and legacy code issues are good reasons for a scientist to think twice about using Java, but execution speed is not one of them. Speed ​​is a black-and-white issue. There are applications in which speed is so important that the scientist works exclusively with optimized compilers on supercomputers - and must also spend time on program optimization, usually with the help of special "optimizers" that rewrite the code to eliminate every wasted nanosecond These are the calculations that take days to run -. and sometimes take days before confirming the "garbage in, Garbage Out "

principle because of a typing mistake! Such programs are very bad candidates for Java. Any program not in this category is a good candidate for Java. With earlier versions of Java, speed was a signficant issue. But as recent scientific benchmarks, including SciMark, and other benchmarks demonstrate, execution speed on a modern PC should be suitable for all non-supercomputer-based applications. and because the speed of computers seems to be increasing on a monthly basis, even without optimization, a marginal program today will execute just fine on a new computer next year! Additional Factors to Consider for scientists, learning Java and learning to think scientifically in Java may not be an easy step. Here is some additional commentary on the following issues, all of them important for scientists [Java as a Scientific Programming Language (Part 1): More Issues for Scientific Programming in java].

Complex Variables Numerical Precision Hardware Independence IDEs and GUIs And in Part 2 of this article, we'll offer concrete examples about how to write good scientific programs in Java. The Future of Java for Scientific Programming Despite some disadvantages, the future of Java as a scientific programming language looks bright. for those thinking about migrating to Java, there's some very good news on the horizon. Scientific Libraries The benefits of Java for scientific programming have impressed many people, and a few high-quality scientific libraries are available. Still others are under construction. (See the sidebar "Scientific Resoureces in Java".) Interestingly, using such libraries is far easier than in Fortran or C. Java provides good mechanisms for importing and managing external libraries (or packages). and there are standardized programs (javadoc) That create HTML Documents Which Describe the library contents and their use. Distributed scientific computing the Built-in THR eads, networking and client-server features of Java appeal to many scientists at the cutting edge of scientific computing. Such features are lacking in Fortran and C, but these are exactly the tools scientists need to write distributed applications, which subdivide a problem and harness the power of many independent computers to solve it. Known as Grande Applications, these are defined as applications "of large-scale nature, potentially requiring any combination of computers, networks, I / O, and memory"

转载请注明原文地址:https://www.9cbs.com/read-125009.html

New Post(0)