Programming
I got into programming sometime in high school. I started
making simple programs on my TI-85 calculator. They were mostly useless
programs like a game taht would pick two random numbers, and if based on
the relation between them you either won or lost. I soon expanded
this to make a simple "eight-ball" type program. You would ask it
a question and based on the two random number the program would either
tell you yes or no (It would also give you a "maybe" if the two numbers
were equal, but there is almost no chance in that happeneing). So
I went on to college and thought that it might be a fun idea to minor in
Computer Science. Afterall it's a very useful field. However
I really did not like the computer science department at Ohio State so
I dropped the minor, but not before learning a little java and C++ (actually
it wasn't really C++, it was RESOLVE/C++ which anyone who has used can
attest to how bad it is). During my little stint as a Computer Science
minor I got a job with a physics professor writing visualization programs.
It is here where I have gotten most of my programming experience.
Here are the languages that I know:
Java
Out of all the languages I know (which really isn't many) I know the most
about java. I really like java for visualization programs, I think
it has one of the easiest GUI's, and a really good API. In fact I
use java in my job to make visualizations. I am also learning about
Java Server Pages (jsp's). These are webpages which use java to dynamically
generate the HTML code. Part of my job is to develop an applet which
will allow people to view molecules on the web, and part of this will use
jsp's.
more information about java:
-
java.sun.com - java's homepage,
here you can download the java API and get other useful information.
They have a reallygood java tutorial here.
-
O'Reilly & Associates - I
reccommend the O'Reilly books on java. They are very well written
and provide good descriptions of the language.
-
java Technology forum -
You can get an answre to just about any question you have at sun's java
forum.
Some example programs
-
hello.java - the all essential
helloworld program, its stupid but its a good starting point.
-
pay.java - a simple java program
which calculates the amount of money someone makes in two weeks
-
PayApplet - an applet version of
the pay.java program. The source is here
Perl
Since java was really the only language that I knew for a while I used
to use it for mosly everything. However I eventually acquired a book
about perl, and it has changed my view dramatically. Perl is now
my programming language of choice for basic, command-line-oriented programs.
Perl stands for Practical Extraction and Report Language, and it is very
good for things like text manipulation. One of the major advantages
about Perl is that it doesn't need a compiler. It's run just like
a script, a script.
more information on Perl:
-
www.perl.com - go here to
download the latest version of the Perl interpreter.
-
www.samspublishing.com
- I am going through the Sam's Teach Yourself Perl In 21 Days.
I find it a really good book, its starts out really basic and gets really
advnaced so it is good for both experienced and inexperienced programmers.
Some Perl programs:
-
cookie.pl - a fun little program
that will not quit untill you give it a cookie
-
energy.pl - a perl program written
for my 416 lab class. It's a good, simple example of reading in input,
performing operations and outputing an answer.
-
leastsquares.pl - This
programs asks you for a set of (x,y) coordinates then gives you the coefficients
for the best fit straight line. It gives you an A and B for
the equation: y = A + Bx
C programming
I took an OSC workshop on the C language. I
choose to learn C because it is a very fast language, well suited for computational
physics which is something I am interested in. The nice thing about C is that many
of the commands are unix commands too, so to find information about them you can use
the man pages. I think that is also why C is fast. Anyway, here are some programs
that I wrote while I was at the workshop:
Some C programs:
- calculator.c - a program which can evaluate
expressions using the four basic operators (+, -, *, /). Good demonstrtaion
of the case/switch statement
- quadratic.c - This program can calculate real
and imaginary roots of a quadratic equation. Uses the math.h library.
- palindrome.c - Asks the user to input a string
then checks to see if it is a palindrome or not. Good demonstration of how to
use the character array version of strings.
- circle.c - Reads in the diameter of a circle from
the user and prints out information about the circle. Example of user defined
functions.
Unix Scripts
I have just started geting into the world of unix scripts, so I can't really
say much about them right now. However they seem to be a little harder
than the Perl or Java. The problem is that there are many different
shells and each shell has slightly different syntax. For me thats
a problem because at work I have to use C-shell, but at home I prefer bash
or ksh. Anyway, I don't have any examples of unix-scripts because
all the ones I have made so far do not work! But here are some websites
that may help you out if you are interested in programming in unix.
To cite this page:
programming
<http://www.physics.ohio-state.edu>
[]
Edited by: ray@pacific.mps.ohio-state.edu on
For questions or comments send mail to:
ray.163@osu.edu