• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Programming Help

The Pig

Thinker
Joined
May 16, 2006
Messages
171
I haven't done any programming since I dropped out of college (early 90s). Back then, the only languages I knew in depth were BASIC & COMAL.

What is a good language for writing programs to work through fairly simple algorithms? I'd be mainly looking to calculate odds and probabilities, nothing fancy, I don't care how it looks.

I assume I can get the relevant book at the library. I'm running XP, what exactly will I need to do to get started? What software will I need to buy, and how much approx?

Grateful for any advice, thanks.
 
Dirt simple would be javascript. You can run it your browser.

A real language, Java or C#, probably overkill.

Do you have performance requirements?
 
Dirt simple would be javascript. You can run it your browser.

A real language, Java or C#, probably overkill.

Do you have performance requirements?
Thanks for that.

I won't be doing anything complex enough to worry about performance.
 
Python is probably the easiest to write in. It's a free download from http://www.python.org/ . The documentation is online too. For example, here's a Python program to calculate the number of outcomes when rolling 2d6. It's not written elegantly, but it shows what Python is like.
Code:
# initialize the results array
results = [0]*13    # entries 0-12 are set to zero

# generate the die rolls
for d1 in range(1,7) :
    for d2 in range(1,7) :
        total = d1 + d2
        results[total] = results[total] + 1 # one more of this total

# print the outcomes
print "Total Outcomes"
for i in range(2,13) :
    print " %2d      %d" % (i, results[i])
 
If you are on a budget, C++ is the way to go. You can get a compiler for free. For XP I would either grab the free version of VC++, or go with MinGW, which is the port of gcc to Win32.

There are also a ton of free libraries for math programming. Check out, for example, the gnu scientific library (GSL). For that matter, I even wrote a C++ math library.

The point is, while C++ is not the easiest language for math programming, it is the most powerful (which is to say, it is equally as powerful as anything else available), and you can do pretty much anything you need for free.

Dr. Stupid
 
Context is the daddy.

I'd personally recommend a version of BASIC, as it's very easy to use, and you'll never dereference a null pointer with it. :)

I know a load of languages, and I always seem to get things done fastest in BASIC. Visual Basic is good, and so is REALbasic.
 
I'm aghast no one mentioned Perl!

I hope I can say this without starting a Holy War: I find Perl much easier to code in than Python because I find Python's use of whitespace as delimiters rather annoying.
 
I use perl alot too, but I always had the impression that it's handling of details maths was somewhat questionable.

I have no real evidence for that, it's just a general impression.

I use VB for most things, in fact, often VBA cos it's handy. :)
 
SkepticScott said:
Python is probably the easiest to write in.
But Python is a whitespace language, which is the work of the Devil.

Zizzy said:
I hope I can say this without starting a Holy War: I find Perl much easier to code in than Python because I find Python's use of whitespace as delimiters rather annoying.
You are correct about Python, but Perl is the work of the Devil's Mentor.

~~ Paul
 
PHP or Bust

I haven't done any programming since I dropped out of college (early 90s). Back then, the only languages I knew in depth were BASIC & COMAL.

What is a good language for writing programs to work through fairly simple algorithms? I'd be mainly looking to calculate odds and probabilities, nothing fancy, I don't care how it looks.

I assume I can get the relevant book at the library. I'm running XP, what exactly will I need to do to get started? What software will I need to buy, and how much approx?

Grateful for any advice, thanks.


If you have a web site, I would recommend PHP. And it's free to get and royalty free to use and most web hosts support it. There are countless PHP tutorial sites on the web - no need to buy PHP books unless you want to.

In fact, this forum we are using was written in PHP.

I'm addicted to PHP. For years I wrote PC software in C, C++, Java, Visual BASIC and several other versions of BASIC, but the programs would only run on Windows. Java was too low level for my needs and the learning curve was too high.

If you are running XP (other than the home edition) you should have a web server on your CD called IIS (Internet Information Services). You can then install PHP to run on the web server. Then you can write and test your programs locally and when done, put your programs on the web for all to use with their browsers.

PHP is not severely difficult to learn. It can be frustrating at first, like any new language until you learn to master it, but it is not too difficult.

The main reason I like it is because PHP can create programs that run on the web or locally, so that you can share your programs with the world without needing any special browser add-ons or any particular operating system. Anyone with a standard web browser can run the programs because it's platform independent. People running Windows or LINUX or MACs, etc. can run the programs equally well.

As a simple example, here's a link to one of the web sites I programmed in PHP. It gives some idea what PHP can do on the web.

http://www.neoprogrammics.com/astronomy/

It performs high-precision astronomical computations, but that's only scratching the surface of its potential.

I can do numerical calculus, trig and all sorts of high-level math, even relativity computations, which is another important reason why I adopted it - I'm heavily involved in math and science, especially physics.

For example, you can do arbitrary precision arithmetic to any number of decimals, even into the thousands of decimals if you wish.

If I wanted the square root of 2 to 100 decimals:
The PHP program code

print bcSqRt("2", 100);

would print the result
1.4142135623730950488016887242096980785696718753769480731766797379907324784621070388503875343276415727


For more normal computations, PHP contains all the essential math and trig and log functions too.

I also have PHP installed on a web server running on my PC so I can run PHP programs locally as well.

Millions of web sites use PHP.

With PHP, you are not restricted to any one specific operating system.
 
Last edited:
I've never written anything in PHP, but I've heard good things about it. I would learn it, but I'm addicted to Gossip.

~~ Paul
 
VB

Context is the daddy.

I'd personally recommend a version of BASIC, as it's very easy to use, and you'll never dereference a null pointer with it. :)

I know a load of languages, and I always seem to get things done fastest in BASIC. Visual Basic is good, and so is REALbasic.

I like Visual BASIC too. I still use VB6 for some of my work. I also use Real BASIC sometimes because I can compile programs for MAC, Linux and Windows.

But when it comes to the web, I prefer PHP.

One problem is that VB is losing support from Microsoft and I have no idea if the programs I made in VB will run on the new Vista OS.
 
I use Octave for anything related to Mathematics. It has a command-line interface, so you can try things out before (or while) writing the code. Any Matlab tutorial can get you started (the languages are very similar).

I second T'ai Chi's suggestion of R. I never used it but I hear good things about it.
 
Last edited:
I have to second Javascript. Being able to get a free compiler is nice, but with Javascript, you don't have to get it, you already have it.
 

Back
Top Bottom