Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Which computer language program is best for undergrads?

78 views
Skip to first unread message

gk...@yahoo.com

unread,
Jun 16, 2008, 6:41:51 PM6/16/08
to

I will be starting at a 4-yr institution for a math degree.

The school material states that the student should be learning a high-
level computer language such as Fortran, C, or C++.

My question is... having a choice, is any one language better in any
way over the others? I might be asking 'better' in terms of 'ease of
use', 'ease of learning', or 'difficult to learn but more powerful/
useful once learned', or 'less likely to become obsolete in the next
20 yrs', etc...

So what do you folks think? What is the best language for a beginning
student to choose, and what are the some of the reasons that you think
so?

I might post this question in a programming group as well.

thanks


JohnF

unread,
Jun 16, 2008, 7:12:40 PM6/16/08
to
gk...@yahoo.com wrote:
> I will be starting at a 4-yr institution for a math degree.
> The school material states that the student should be learning
> a high-level computer language such as Fortran, C, or C++.

>
> My question is... having a choice, is any one language better in any
> way over the others? I might be asking 'better' in terms of 'ease of
> use', 'ease of learning', or 'difficult to learn but more powerful/
> useful once learned', or 'less likely to become obsolete in the next
> 20 yrs', etc...
>
> So what do you folks think? What is the best language for a beginning
> student to choose, and what are the some of the reasons that you think
> so? I might post this question in a programming group as well.
> thanks

None of these languages is likely to become obsolete in 20 years.
Beyond that, "better language" is pretty much subjective.
What do you want to accomplish?...
...get a programming job: C++
...satisfy a curriculum requirement as easily as possible: Fortran
...get a solid foundation in programming concepts: C
That's just my opinion.
--
John Forkosh ( mailto: j...@f.com where j=john and f=forkosh )

Mensanator

unread,
Jun 16, 2008, 7:40:55 PM6/16/08
to

Keeping in mind that if you have a solid foundation in programming
concepts, other languages, like Python, are much easier to pick up.

Joshua Cranmer

unread,
Jun 16, 2008, 7:51:31 PM6/16/08
to
gk...@yahoo.com wrote:
> I will be starting at a 4-yr institution for a math degree.
>
> The school material states that the student should be learning a high-
> level computer language such as Fortran, C, or C++.

There are dozens of languages, expanding the pool also to languages such
as R, Mathematica, Maple, Matlab, Java, python, perl, etc.

I personally have not seen to many guides on programming languages for
mathematical purposes, but I can summarize my opinions.

In short:
Fortran - oldest major language; it was designed for engineers
originally, so it will look more foreign to programmers. Despite its
age, it is one of the most heavily-used languages on supercomputers.

C/C++ - the core of these are the same. I believe statistics give the
two about equal amounts, although that is dubious since C can be easily
called from C++. Many libraries are C, though, so C would probably be
preferred over C++ simply from a neophyte's perspective.

R, Mathematica, Maple, Matlab: All of these are specifically designed
for mathematics. The latter three all require specific mathematics
packages (although Octave as an open source near-implementation of
matlab). I've used each of these a tad, but I'm willing to bet that
these are not what the school intends for learning.

Java - One of the most popular languages; typically used in introductory
programming courses. For that reason, the largest body of material can
generally be found in Java, although its default library setup isn't
terribly mathematics-welcoming.

C# - Similar to Java, although it is a Microsoft derivative. I haven't
played around here much, but I think it's more welcoming to mathematics
work, although not from a cross-platform point of view.

Python, ruby, perl, etc. - these are your newer languages, which tend to
have more cult-ish proponents. I would stay away from these, as they are
your scripting languages, and less concern themselves with mathematics work.

My recommendation is to pick up Fortran, C, or C++, with no real
preference between them. All of these have vibrant communities and are
so widely used that the largest mathematics packages (e.g., lapack) will
be accessible from them. And don't worry about them dying away; they've
been here and heavily used for several decades, and still will be used
through your working career.

> I might post this question in a programming group as well.

This is not a good question for comp.lang.*, since it tends to invite
flame wars. The (good) advice you will get will most likely amount to
the following: "Pick a language that suits you well and stick to it."

Daniel da Silva

unread,
Jun 17, 2008, 1:27:34 AM6/17/08
to

I'm not an experienced C or Fortran programmer, but I can say that
Python is very easy to learn and from experience has a growing number
of mathematical and computational science packages. For someone who
would like to learn to program in something that makes programming
less tedious than C, but is still very powerful, python may be of
interest.

If you chose to go the python way, you can use of Matplotlib (http://
matplotlib.sourceforge.net/) to achieve some Matlab(tm) plotting
functionality, and SciPy/NumPy (http://www.scipy.org/) for numerical
work. If after learning python you find that computation is something
that interests you, you should look into other languages, like C.

I admit, I'm just as much a (theoretical) computer scientist as I am a
mathematician, so take what I say with a fair grain of salt.

Daniel da Silva

Toni Lassila

unread,
Jun 17, 2008, 1:50:24 AM6/17/08
to

Realistically, to work in scientific computing you need to learn two
programming languages: one for prototyping and another for doing
actual heavy-duty computations.

For prototyping: Matlab, Python

For computing: Fortran, C/C++

Also, for mathematicians knowing Maple or Mathematica is a big
benefit. Which ones you learn depends on what is used in teaching and
which software is available. If decent ability is reached, picking up
further languages later as needed is not a problem (at least as long
as one remains inside the procedural/object-oriented family).

Peter Webb

unread,
Jun 17, 2008, 2:17:13 AM6/17/08
to

<gk...@yahoo.com> wrote in message
news:0934b97f-9b22-450e...@f36g2000hsa.googlegroups.com...

You are talking about two different types of languages. C and Fortran are
traditional "procedural" languages. They are both easy to learn.

C++ is an "object oriented" language. Whilst it pretty well contains C as a
proper subset, if you are learning C++ you are really learning object
oriented programming, and this is very powerful but with much more abstract
structure.

If all you want do with a computer is solve computational programs, like
numerically solving integrals, counting permutations, or running Monte Carlo
simulations, C and Fortran will do fine. If you want to write programs to be
used by others, including full on Windows applications (eg with a Windows
style interface), then you will pretty much have to learn object oriented
programming which means in this case C++.

I think Fortran is somewhat simpler than C because its a bit more verbose,
but that may only be me. However, Fortran is a complete dead-end. C is far
more widely used (now, for writing programs) than Fortran and has a clear
"upgrade path" to C++ and hence object oriented programming.

So I would learn C in the first instance, and "upgrade" this to C++ when and
if required.

You can download for free a state of the art Windows C++ programming
environment by downloading Microsoft Visual Studio 2008 Express Edition,
which has several other (object oriented) languages packaged in as well. If
you tell it to create a C++ console application, it will set it up so you
can pretty well just write normal C code and it will work. The Help,
Documentation and Tutorials are superb, but unfortunately are written from
an object-oriented perspective. You will need to either buy a book on C, or
use any of the billion online tutorials and references on C that exist on
the internet.

Finally, on another note, it is very much more effective for you and people
who use Usenet if you cross-post rather than sending similar posts to
different groups; all the answers from all different groups will appear as a
single thread in all groups.


Peter Webb

unread,
Jun 17, 2008, 4:45:27 AM6/17/08
to
>
> C# - Similar to Java, although it is a Microsoft derivative. I haven't
> played around here much, but I think it's more welcoming to mathematics
> work, although not from a cross-platform point of view.
>

C# is the language I do all my programming in. It is more similar to Java
than C, as you say. Its superb, but the maths functions available in the
libraries (more specifically .NET) are shithouse. I use it for maths
programming only because everything else about it is great.

Again, its a fully object-oriented environment, and you can't write in C#
without understanding these concepts. These are tricky. Its easier to learn
a procedural language like Fortran or C than an object oriented one. Your
course advisory doesn't require you to do object oriented programming, hence
my suggestion to simply learn C first.

I might also add that the people who suggested specialist mathematics
packages are missing the point. The course requirements are basically that
you be able to write a machine readable algorithm for solving questions
about numbers, not that you can Google a symbolic calculator.


David C. Ullrich

unread,
Jun 17, 2008, 7:11:42 AM6/17/08
to
On Mon, 16 Jun 2008 19:51:31 -0400, Joshua Cranmer
<Pidg...@gmail.com> wrote:

>[...]


>
>Python, ruby, perl, etc. - these are your newer languages, which tend to
>have more cult-ish proponents. I would stay away from these, as they are
>your scripting languages, and less concern themselves with mathematics work.

You know nothing whatever about Python. (Or maybe you're
confusing mathemtatics with numerical computation.) I do
abstract mathematical things in Python all the time, very
easily.

An example of something that it seems to me would be
much more difficult in the languages you recommend
for mathematical work: I have a Sqrt function such that
Sqrt(5) is _exactly_ the square root of 5. Exactly,
not a numeric approximation like sqrt(5).

>My recommendation is to pick up Fortran, C, or C++, with no real
>preference between them. All of these have vibrant communities and are
>so widely used that the largest mathematics packages (e.g., lapack) will
>be accessible from them. And don't worry about them dying away; they've
>been here and heavily used for several decades, and still will be used
>through your working career.
>
>> I might post this question in a programming group as well.
>
>This is not a good question for comp.lang.*, since it tends to invite
>flame wars. The (good) advice you will get will most likely amount to
>the following: "Pick a language that suits you well and stick to it."

David C. Ullrich

Pubkeybreaker

unread,
Jun 17, 2008, 8:26:11 AM6/17/08
to
On Jun 17, 7:11 am, David C. Ullrich <dullr...@sprynet.com> wrote:
> On Mon, 16 Jun 2008 19:51:31 -0400, Joshua Cranmer
>

MIT teaches Scheme to its incoming freshmen. With good reason.

Jaap Spies

unread,
Jun 17, 2008, 9:31:59 AM6/17/08
to

Anybody interested in computations, computing and mathematics should
definitely look at Sage:

http://www.sagemath.org

The language of Sage is Python. Sage includes many high-quality
open source math packages.

Jaap Spies

> Daniel da Silva

scattered

unread,
Jun 17, 2008, 10:17:04 AM6/17/08
to
On Jun 16, 6:41 pm, gk...@yahoo.com wrote:

Two more suggestions at the opposite ends of the coolness spectrum

1) Excel VBA. Despite its roots in Basic, modern VBA is a perfectly
adequate procedural language with all of the standard control
structures, etc. with the added benefit that it has an gentle learning
curve. The spreadsheet which can be programatically manipulated gives
a natural IO with little programming overhead. This is because it is
natural to place input and/or output in columns and to generate graphs
of it as well, both of which are easy from Excel. The problem with
this suggestion is that Microsoft is not cool in academia (often for
good reasons) and even apart from that there are drawbacks to tying
yourself too closely to one operating system.

2) Haskell. This is a modern functional language whose basic notation
is fairly mathematical. It has a steeper learning curve but there is
finally a good elementary introduction in "Programming in Haskell" by
Graham Hutton. The book "The Haskell Road to Logic, Maths and
Programming" by Kees Doets and Jan van Eijck is a good exploration of
the link between Haskell and mathematics. This language is a good
choice if you are more interested in pure as opposed to applied
mathematics. SML is another language in the same genre.

In addition to my two suggestions I agree what others have said to the
effect that you can't go wrong in learning C.

hth

-scattered

Angus Rodgers

unread,
Jun 17, 2008, 11:14:14 AM6/17/08
to
On Tue, 17 Jun 2008 07:17:04 -0700 (PDT), scattered
<former_...@hotmail.com> wrote:

>The book "The Haskell Road to Logic, Maths and
>Programming" by Kees Doets and Jan van Eijck is a good exploration of
>the link between Haskell and mathematics. This language is a good
>choice if you are more interested in pure as opposed to applied
>mathematics.

In the dim and distant past, I learned Miranda from Bird & Wadler;
and in the even dimmer and more distant past, I did a degree in
mathematics; on the other hand, in spite of some dabbling, I don't
have a sound knowledge of either theoretical computer science or
"real-world" programming techniques. Would this book be at too
elementary a level for me, or might I still learn something from
it if I want to try my hand at programming again?

--
Angus Rodgers
(twirlip@ eats spam; reply to angusrod@)
Contains mild peril

Daniel da Silva

unread,
Jun 17, 2008, 11:59:12 AM6/17/08
to

Unfortunately, not anymore. MIT now teaches with python in its place.
http://www.amk.ca/diary/2006/11/mit_to_try_python_for_introduc.html

Daniel

scattered

unread,
Jun 17, 2008, 12:17:41 PM6/17/08
to
On Jun 17, 11:14 am, Angus Rodgers <twir...@bigfoot.com> wrote:
> On Tue, 17 Jun 2008 07:17:04 -0700 (PDT), scattered
>

The book by Hutton is better for learning the language. It has some
mathematically interesting examples such as an version of Conway's
Game of Life (albeit with no graphics - just ASCII representations of
successive generations). I don't have a copy of the other readily
accessible (I had obtained it via inter-library loan) but I seem to
recall that it was primarily a discrete math text which used Haskell
as a tool and didn't go very deep into the language per se. A good
book for delving deeper into the language and seeing more real-world
example is "The Haskell School of Expression: Learning Functional
Programming through Multimedia" by Paul Hudak. This book has
interesting examples which include simple fractal-drawing programs.

-scattered

Alan Crowe

unread,
Jun 17, 2008, 12:50:13 PM6/17/08
to
gk...@yahoo.com writes:

> I will be starting at a 4-yr institution for a math degree.
>
> The school material states that the student should be learning a high-
> level computer language such as Fortran, C, or C++.
>

Here are some arguments in favour of Common Lisp (CL) over C and
C++

Automatic "garbage collection" so you can write
sophisticated programs without having to learn how to manage
memory.

Unlimited integers, rationals, gaussian integers, and
Q[i]. This is usually seen as a draw-back (bloated) but
handy if you are studying mathematics.

Built in complex numbers eg (expt -1 1/3) => #C(0.5
0.8660254) ie cube root of minus one is 0.5+0.866i The
specification devotes about 40 pages to nailing down the
details of where the branch cuts run for all the
transcendental functions.

Programs will run without type declarations, which is
convenient for trying things out interactively, and getting
programs written quickly.

If you go round putting in type declarations, eg,
(declare (type (integer 0 100) i)
(single-float x y)
(type (complex double-float) z)))

most CL compilers will make good use of them and generate
native code about half the speed of C. Good enough for any
undergraduate numerical work.

Array bounds checking. There are commands for adjusting
arrays and for "displaced arrays". They look quite
complicated. They let you set up different "views" of blocks
of memory. For example, twelve numbers might be a 3 x 4
matrix in one view and a vector of 12 elements in another. C
also lets you do that, but more simply, because it does not
check array bounds. As a maths student you don't have time
to master the difficult art of debugging code in languages
without array bounds checking.

Better scoping rules. In C all variables are lexical and
have dynamic extent. In CL the lexcial variables have
indefinite extent. (This is related to garbage collection.)
CL offers the option of special variables that have
indefinite scope and dynamic extent, which is occasionally
useful.

Lexical variables with dynamic extent, which is all C
provides, are obselete and there is no reason for a
mathematician to waste time learning to code around the
difficulties they cause.

The built in object system, CLOS, is well suited to the
needs of mathematicians, see "Common Lisp, Typing and
Mathematics" amongst the papers of Francis Sergeraert at

http://www-fourier.ujf-grenoble.fr/~sergerar/Papers/


Here is an ambiguous point.

CL uses fully parenthesised prefix notation. (+ x y) instead
of x + y. This is clumsy. On the other hand C and Fortran do
not offer the kind of two-dimension notation used in
mathematics. You still have to take your mathematics and
encode it in the special notation of the programming
language, and you have to learn the precedence rules. Fully
parenthesised prefix notation is clumsier but simpler.

Here is a contingent disadvantage of CL

All those parentheses. You have to use a syntax-aware editor
and learn to read the indentation that it does
automatically. Trying to count parentheses doesn't work. You
have to auto-indent and work out whether you have got the
parentheses right by the way things are lined up
vertically. http://www.cawtech.demon.co.uk/lisp/before-you-start.html

This pretty much restricts you to Emacs. Many people use
emacs anyway, for other reasons, and find that the
syntax-aware editing commands makes up for the clunkiness
for the notation. For them there is no
disadvantage. However, if you cannot find a syntax-aware
editor that you are happy with, don't bother with CL, the
language isn't usable without one.


Here is an important disadvantage.

CL is out of fashion and not widely used. It is popular
enough that you can get prompt help on comp.lang.lisp, but
there are still big advantages to using the same language as
your fellow students. You could end up having to link to
library routines written in C using the Foreign Function
Interface, (FFI), which is more computer cruft you don't
want to waste time on.

Alan Crowe
Edinburgh
Scotland

David Bernier

unread,
Jun 17, 2008, 2:07:46 PM6/17/08
to

I don't think it's a good idea to start with C++; it's more difficult
to learn than C. There are many good books as well as an active
newsgroup for C. As a first language to learn, I would put
C ahead of C++ and Fortran.

I've read many good comments about Python, but haven't learnt it.
I've used one-line perl commands to edit several files at once.
I think some have called Perl a "write once" language; it
can be difficult to decipher . I didn't like Java because
of all the public classes; but we had to do programs
with graphics, so we needed to use many classes.
With just math, fewer classes would be needed.

Some languages such as Haskell or APL are interpreted.
Today, I wouldn't really recommend APL, because
of the special character set. But having a language
for prototyping is good, and often speed isn't
important.

So I'd consider C, Python and Haskell.

David Bernier

scattered

unread,
Jun 17, 2008, 3:10:28 PM6/17/08
to

Good suggestions. A minor point of fact is that Haskell has both
interpreted (Hugs) and compiled (GHC) implementations, though someone
learning it would probably want to start out with Hugs.

-scattered

Richard Henry

unread,
Jun 17, 2008, 4:15:28 PM6/17/08
to

C has been obsolete for 20 years but it is still probably the most
common language used in industry, especially behind the doors.

Phil Carmody

unread,
Jun 17, 2008, 4:19:17 PM6/17/08
to

At least 2 good reasons. Sussman, and Steele being 2, of course.

Phil
--
Dear aunt, let's set so double the killer delete select all.
-- Microsoft voice recognition live demonstration

Mensanator

unread,
Jun 17, 2008, 4:52:14 PM6/17/08
to
On Jun 17, 3:19 pm, Phil Carmody <thefatphil_demun...@yahoo.co.uk>
wrote:

Why do you think they switched to Python?

Lack of qualified teachers of Scheme?

A desire to see a larger fraction of the students pass the course?

>
> Phil
> --
> Dear aunt, let's set so double the killer delete select all.

> -- Microsoft voice recognition live demonstration- Hide quoted text -
>
> - Show quoted text -

Michael Press

unread,
Jun 17, 2008, 6:30:31 PM6/17/08
to
In article
<0934b97f-9b22-450e...@f36g2000hsa.googlegroups.com>,
gk...@yahoo.com wrote:

Learn several. The more you learn, the easier they are.
UNIX shell and canonical command set will serve you well.
"Read the man pages" as I was counseled.
There is a surprisingly powerful set of UNIX utilities.
Avoid the c shell. Stay with Bourne shell or bash or Korn shell,
all virtually the same these days.

Perl for text formatting and filtering of the classical variety;
really a powerful language.
Python is highly regarded.
Fortran can be a read-only language for a while.
You can do almost all the math you need with Maple;
expensive unless the institution buys it for you.
Learn some assembly language.
C is a requirement.

I do not see the point of C++, but it may be forced on you.
It is not really an extension of C.

You can ignore this advice and muddle through.
You will be better off taking the bull by the horns.

--
Michael Press

Michael Press

unread,
Jun 17, 2008, 6:31:36 PM6/17/08
to
In article
<4bd484d7-c892-4e6e...@q27g2000prf.googlegroups.com>,
Richard Henry <pome...@hotmail.com> wrote:

Oh yeah! Well fortran has been obsolete for 30 years. So there.

--
Michael Press

Richard Henry

unread,
Jun 18, 2008, 12:21:43 AM6/18/08
to
On Jun 17, 3:30 pm, Michael Press <rub...@pacbell.net> wrote:

> I do not see the point of C++, but it may be forced on you.
> It is not really an extension of C.

The biggest advance of C++ was the // comment prefix.

Michael Press

unread,
Jun 18, 2008, 4:35:39 AM6/18/08
to
In article
<97ab4305-22ef-42a5...@n19g2000prg.googlegroups.com>,
Richard Henry <pome...@hotmail.com> wrote:

:)

Now available in many C installations.

Code reuse: Cut and paste
Debugger: printf

--
Michael Press

David C. Ullrich

unread,
Jun 18, 2008, 7:03:11 AM6/18/08
to

Knowing nothing of Scheme I couldn't say whether the change
was fortunate or not. But Python seems like an excellent choice,
independent of whether Scheme would be even better. A _very_
high power/difficulty ratio.

>http://www.amk.ca/diary/2006/11/mit_to_try_python_for_introduc.html
>
>Daniel

David C. Ullrich

David C. Ullrich

unread,
Jun 18, 2008, 7:05:03 AM6/18/08
to
On Tue, 17 Jun 2008 07:17:04 -0700 (PDT), scattered
<former_...@hotmail.com> wrote:

>[...]


>
>Two more suggestions at the opposite ends of the coolness spectrum
>

>1) Excel VBA. [...]
>
>2) Haskell. [...]

Wow. When you said opposite you meant opposite.

>In addition to my two suggestions I agree what others have said to the
>effect that you can't go wrong in learning C.
>
>hth
>
>-scattered

David C. Ullrich

Frederick Williams

unread,
Jun 18, 2008, 8:13:45 AM6/18/08
to
gk...@yahoo.com wrote:
>
> I will be starting at a 4-yr institution for a math degree.
>
> The school material states that the student should be learning a high-
> level computer language such as Fortran, C, or C++.
>
> My question is... having a choice, is any one language better in any
> way over the others? I might be asking 'better' in terms of 'ease of
> use', 'ease of learning', or 'difficult to learn but more powerful/
> useful once learned', or 'less likely to become obsolete in the next
> 20 yrs', etc...
>
> So what do you folks think? What is the best language for a beginning
> student to choose, and what are the some of the reasons that you think
> so?
>
> I might post this question in a programming group as well.
>
> thanks

I think no one has mentioned Eiffel, and how about Forth just for fun?

--
He is not here; but far away
The noise of life begins again
And ghastly thro' the drizzling rain
On the bald street breaks the blank day.

scattered

unread,
Jun 18, 2008, 10:48:48 AM6/18/08
to
On Jun 18, 7:05 am, David C. Ullrich <dullr...@sprynet.com> wrote:
> On Tue, 17 Jun 2008 07:17:04 -0700 (PDT), scattered
>
> <former_schiz...@hotmail.com> wrote:
> >[...]
>
> >Two more suggestions at the opposite ends of the coolness spectrum
>
> >1) Excel VBA. [...]
>
> >2) Haskell. [...]
>
> Wow. When you said opposite you meant opposite. [...]

My taste in computer languages is like my taste in music, which ranges
from Alice Cooper to Bach. They are all fun when you are in the right
mood. I don't program for a living, so I can afford to play around
with a language if it strikes my interest.

-scattered

0 new messages