Jump to content


Photo
- - - - -

what's a good programming language to learn?


  • Please log in to reply
194 replies to this topic

#21 D H

D H

    Physics Expert

  • Resident Experts
  • 3,631 posts
  • LocationHouston, Texas

Posted 18 April 2009 - 07:46 PM

It depends which ones you're talking about. Functional languages like Haskell and OCaml perform just fine:

http://shootout.alio...&lang=all&box=1

Surely you jest. Those gross statistics include several programs that are at best peripheral to scientific computing. Haskell even beat C/C++ on a few of those, particular those that are heavy on threads. When you look at the benchmarks that are not peripheral to scientific computing you get a completely different picture. Take one that is near and dear to me: the n-body problem. C++ beats Haskell by nearly a factor of 3, Ruby by a factor of 58, Python by a factor of 73. To boot, this is using the very simple symplectic Euler integration scheme with spherical gravity models. If you look at the Haskell and Ruby and Pascal code, it looks gasp procedural. How much more procedural would the Haskell code look if you had to use a non-simplistic integration scheme and spherical harmonics to represent gravity? How much slower would they be compared to a language suited to scientific computing?

They think procedurally because they were taught to think procedurally. Again, it's a cultural thing.

Exactly, and you are not going to fight that culture. Scientists and engineers who never touch a line of code in their lives think procedurally. Scientists and engineers who program are first and foremost scientists and engineers.

My employers over the past 30 years have uniformly found that it is generally a bad idea to hire computer scientists for anything by computer science type work because computer science majors, for the most part, are incapable of thinking like a physical scientist or engineer. It is a cultural thing.
  • 0

#22 bascule

bascule

    Genius

  • Validating
  • 8,433 posts
  • LocationThe center of the universe (from my frame of reference)

Posted 19 April 2009 - 03:19 PM

When you look at the benchmarks that are not peripheral to scientific computing you get a completely different picture. Take one that is near and dear to me: the n-body problem.


http://shootout.alio...=nbody&lang=all

C++ beats Haskell by nearly a factor of 3


Interesting to see that Fortran only barely eeks out a lead over Scala... Haskell is only a little more than half as slow as Fortran.

Ruby by a factor of 58, Python by a factor of 73.


To reiterate from my previous post:

or any other interpreted language for numerical computing (or even a JITed language with boxed integers/floats)


procedural.


Well, Haskell was the only language you listed which I was advocating for numerical computing, so let's look at some of that:

do
    m <- foldr (.+.) (Vec 0 0 0)
             `fmap` (mapM momentum
                   . take (nbodies - 1)
                   . iterate next $ next planets)

    setVec (vel planets) $ (-1/solar_mass) *. m
  where
    momentum !p = liftM2 (*.) (mass p) (getVec (vel p))

Hmm, maps and folds... not particularly procedural at all. In fact, that's pretty much some quintessential functional programming right there.

Colloquially (thanks to Google) this approach is typically described as a "MapReduce" and is an extremely easy operation to parallelize.

There are ways to write imperative/procedural type code in Haskell, using things like the state monad. This program does not use them.

Merged post follows:

Consecutive posts merged
Here's an interesting success story using Haskell for scientific modeling:

http://www.haskell.o...ril/017050.html

Edited by bascule, 18 April 2009 - 08:19 PM.

  • 0
Radicalism: The conservatism of tomorrow injected into the affairs of today.
-- Ambrose Bierce

#23 ecoli

ecoli

    murderator

  • Moderators
  • 8,606 posts
  • LocationNY, NY

Posted 19 April 2009 - 05:49 PM

I take it that I'm not going to get a consensus on this :-p
  • 0
[14:02] <Sato> I
[14:02] <Sato> want
[14:02] <Sato> Schroedinger
[14:04] == Schroedingers_hat [~matt@CPE-121-222-209-157.lnse1.woo.bigpond.net.au] has joined #sfn

#24 D H

D H

    Physics Expert

  • Resident Experts
  • 3,631 posts
  • LocationHouston, Texas

Posted 19 April 2009 - 08:03 PM

Probably not. Bascule hates useful languages. He has been fully indoctrinated.

A few questions to help you narrow things down, ecoli:
  • What domain are you interested in? I do not mean stochastic modeling; that is far too broad. I mean something like atmospheric modeling, chemical modeling, biological systems, ...
  • Academia or industry?
  • Does one, maybe two, languages dominate in that field? If so, you know what you eventually need to learn.

It would also behoove you to learn something of the art of computer programming. Scientists and engineers for the most part are quite lousy at programming because they have either learned it on their own or have learned it with the aid of other (equally inept) scientists and engineers.
  • 0

#25 bascule

bascule

    Genius

  • Validating
  • 8,433 posts
  • LocationThe center of the universe (from my frame of reference)

Posted 20 April 2009 - 02:29 AM

Probably not. Bascule hates useful languages.


I'm a fan of writing correct programs quickly.

Utility is in the eye of the beholder. Ever use YouTube? You can thank Python for that one.

One of the more interesting apps I've seen demonstrated at our local Ruby group is a web application for controlling the power grid. That's some utility... literally.

He has been fully indoctrinated.


I'm a polyglot who doesn't fall victim to the Blub Paradox:

As long as our hypothetical Blub programmer is looking down the power continuum, he knows he's looking down. Languages less powerful than Blub are obviously less powerful, because they're missing some feature he's used to. But when our hypothetical Blub programmer looks in the other direction, up the power continuum, he doesn't realize he's looking up. What he sees are merely weird languages. He probably considers them about equivalent in power to Blub, but with all this other hairy stuff thrown in as well. Blub is good enough for him, because he thinks in Blub.


  • 0
Radicalism: The conservatism of tomorrow injected into the affairs of today.
-- Ambrose Bierce

#26 Cap'n Refsmmat

Cap'n Refsmmat

    Mr. Wizard

  • Administrators
  • 11,742 posts
  • LocationTexas

Posted 20 April 2009 - 02:44 AM

I think the issue between D H and bascule here is merely a difference of willingness to use what already works to its full potential vs. willingness to learn new concepts and techniques to leverage them to their potential. The former requires less initial effort on the part of the programmer (less learning curve), but may mean uglier code and other disadvantages in the long run. The latter requires more learning but can make programming and debugging faster at the expense of some execution time.

Tradeoffs. What are you willing to lose?
  • 0

Cap'n Refsmmat
SFN Administrator


#27 ecoli

ecoli

    murderator

  • Moderators
  • 8,606 posts
  • LocationNY, NY

Posted 20 April 2009 - 03:22 AM

A few questions to help you narrow things down, ecoli:

  • What domain are you interested in? I do not mean stochastic modeling; that is far too broad. I mean something like atmospheric modeling, chemical modeling, biological systems, ...

Biological systems for sure. Probably infectious disease transmission and/or evolution.

Also I'm interested in social science research and economics.

  • Academia or industry?

academic

  • Does one, maybe two, languages dominate in that field? If so, you know what you eventually need to learn.

I have no idea, I'm a complete newb.

It would also behoove you to learn something of the art of computer programming. Scientists and engineers for the most part are quite lousy at programming because they have either learned it on their own or have learned it with the aid of other (equally inept) scientists and engineers.


would you recommend a class then? That could be possible
  • 0
[14:02] <Sato> I
[14:02] <Sato> want
[14:02] <Sato> Schroedinger
[14:04] == Schroedingers_hat [~matt@CPE-121-222-209-157.lnse1.woo.bigpond.net.au] has joined #sfn

#28 bascule

bascule

    Genius

  • Validating
  • 8,433 posts
  • LocationThe center of the universe (from my frame of reference)

Posted 20 April 2009 - 03:30 AM

would you recommend a class then? That could be possible


Structure and Interpretation of Computer Programs (a.k.a. SICP) is almost universally regarded as the best within the computer science community.

If you click the link you will find their complete video lecture series available for download, taken from an actual class taught at MIT.
  • 0
Radicalism: The conservatism of tomorrow injected into the affairs of today.
-- Ambrose Bierce

#29 D H

D H

    Physics Expert

  • Resident Experts
  • 3,631 posts
  • LocationHouston, Texas

Posted 20 April 2009 - 05:01 AM

Biological systems for sure. Probably infectious disease transmission and/or evolution. Also I'm interested in social science research and economics.

You are in college. There are lots of people there who use computers to do exactly what you are talking about. Rather than asking us what a good language to learn would be, ask them. Ask your advisor. Go snooping around in labs and ask the RAs what they are using. Find out who is publishing papers in this domain at your school and ask those authors.

Don't ask us. All you will do is provoke religious wars and get a bunch of wrongheaded answers.

would you recommend a class then? That could be possible

Absolutely.

Merged post follows:

Consecutive posts merged

I think the issue between D H and bascule here is merely a difference of willingness to use what already works to its full potential vs. willingness to learn new concepts and techniques to leverage them to their potential. The former requires less initial effort on the part of the programmer (less learning curve), but may mean uglier code and other disadvantages in the long run. The latter requires more learning but can make programming and debugging faster at the expense of some execution time.

Tradeoffs. What are you willing to lose?

That is an insult. I am more than willing to learn new concepts. I try to learn a new language every year or so. I can easily list twenty plus languages that I have learned over the last thirty years. I did not count several completely immemorable whose names I can no longer remember.

I'm a fan of writing correct programs quickly.

... and sloppily, and more or less by yourself. You are in academia, and you are in a computer science department. Sloppiness and working in very small teams are almost a given. Some elements of computer science used to address issues of reliability, maintainability, understandability, verifiability, verifiability, traceability, cost, and above all, developing and sustaining a large set of knowledgeable workers. Some computer science departments still do concern themselves with such issues. Many no longer do; those boring, real world concerns are now addressed by a rather new discipline, software engineering.

I think the issue between D H and bascule ...

The above gets at what the real issue is. It is a modern version of Snow's Two Cultures. Bascule and I are from two very, very different cultures.

I worry about reliability and all that crap. Bascule worries slapping crap out quickly. Both concerns are crap, but hey, its the crap we have to worry about.

I worry about competing with other companies. Bascule worries about competing with others in academia. These are very different kinds of pressure that lead to very different world views. Different cultures.

I worry about being able to hire scientists and engineers who have a rather limited concept of computer programming, computer science, and software engineering. Bascule worries about the keeping up with the state of the art in computer science. Again, very different cultures.

I was a part of the 1980-1987 AI revival. I learned several AI languages and made some inroads into applying AI to NASA (one of my programs helped keep a Shuttle flight flying after a major on-board failure). I was also taken in by the AI winter that followed that revival. One reason for that AI winter was that most scientists and engineers could not grok Lisp, rule-based reasoning, or, heaven forbid, backward chaining. The people coming out of schools who could understand logic programming could do Blocks World just fine but were for the most part completely incompetent when it came to real-world applications. There never was a sufficient mass of people who could bridge the different cultures and produce success stories. AI went into a massive decline because of a lack of success.

Academic computer science and real-world science and engineering are very, very different cultures. Bascule comes from the former while I come from the latter.

Edited by D H, 20 April 2009 - 05:06 AM.
Consecutive posts merged.

  • 0

#30 ecoli

ecoli

    murderator

  • Moderators
  • 8,606 posts
  • LocationNY, NY

Posted 20 April 2009 - 07:53 PM

You are in college. There are lots of people there who use computers to do exactly what you are talking about. Rather than asking us what a good language to learn would be, ask them. Ask your advisor. Go snooping around in labs and ask the RAs what they are using. Find out who is publishing papers in this domain at your school and ask those authors.

I currently work in a department that uses zero computation, aside from the odd statistical test. I'll poke around, however.

Don't ask us. All you will do is provoke religious wars and get a bunch of wrongheaded answers.

I haven't read an answer here that I would characterize as "wrong" yet.
  • 0
[14:02] <Sato> I
[14:02] <Sato> want
[14:02] <Sato> Schroedinger
[14:04] == Schroedingers_hat [~matt@CPE-121-222-209-157.lnse1.woo.bigpond.net.au] has joined #sfn

#31 Cap'n Refsmmat

Cap'n Refsmmat

    Mr. Wizard

  • Administrators
  • 11,742 posts
  • LocationTexas

Posted 20 April 2009 - 08:11 PM

That is an insult. I am more than willing to learn new concepts. I try to learn a new language every year or so. I can easily list twenty plus languages that I have learned over the last thirty years. I did not count several completely immemorable whose names I can no longer remember.

No insult intended. I suppose your point is that while you have learned all these other languages, you find that the traditional stuff works best and there's no need for Haskell or any of the other "new" languages brought up by bascule?

What is really called for here is a direct comparison: get some programmers expert in C/C++, some expert in Haskell or Erlang or some other similar language, and give them a task. Time how long it takes both for development and program execution and see what the tradeoffs are. (For added realism, then give them a new task that involves updating the old program to new requirements, and see how easily the code can be updated.)

My suspicion is that the "new" languages make programming faster (to an extent) but program speed slower, unless you're sufficiently clever. But I'd have to try it.


... and sloppily, and more or less by yourself. You are in academia, and you are in a computer science department.

From what I recall, bascule works for an Internet company. But I'll let bascule speak for himself in that department.

Merged post follows:

Consecutive posts merged

I haven't read an answer here that I would characterize as "wrong" yet.

Honestly I don't think you can pick a "wrong" language to learn. All will be useful to you in some way, and learning one language will make it infinitely easier to learn the next -- my knowledge of the workings of Java comes from the object model in PHP, for example. There are so many similar concepts across languages that learning one will help prepare you for learning more.

So take a look through the languages mentioned here, look up some code in those languages, and try reading a tutorial or two from each. (Don't let the look of the code scare you. I know Lisp scared me when I first saw it, but it's actually pretty cool.) If you go into anything computational you'll end up learning several languages anyway, so it doesn't really matter which one you start with.
  • 0

Cap'n Refsmmat
SFN Administrator


#32 PhDP

PhDP

    Formerly Phil

  • Senior Members
  • 763 posts
  • LocationQuébec

Posted 21 April 2009 - 03:23 PM

My suspicion is that the "new" languages make programming faster (to an extent) but program speed slower, unless you're sufficiently clever. But I'd have to try it.


But that's beside the point, again it has very little to do with the actual value of the languages. The languages bascule named might be great but nobody use them in science. Scientists have to work in groups, they have to publish articles, and they very often have to rely on librairies. Who cares if your Haskell program is better than my C++ program, you'll probably need to write a version in C for publication or to cooperate with other people. It's already annoying when scientists publish articles filled with words nobody used in decades, at least they don't write their program in some obscur language.

In my field (population genetics/molecular evolution), programs are written in C, C++, and minority are written in Java. Theoretical scientists very often use CPython for simple programs... and I encounter R a lot when I have to deal with phylogenetics and statistics. That's about it. With the exception of R, all theses languages are derived from C.

That's the crushing force of inertia bascule talked about, which isn't so bad in truth. Communication is very important in science, and it would be messy if we were to follow all the fashions in computer science. I wish more was done with managed languages (Java & C#), they're fast enough for everything that you don't need to run on a supercomputer. And honestly, there's much hype surrounding functional languages these days, and I personally like the concepts, but I doubt we're going to see a truly functional languages in top 10 of TIOBE in the next few years.

Landau wrote an article for computational physics, but I think it's useful for other scientists as well;

In my view, Java's attention to precision, useful error messages, and object-orientation make it good for scientific computing, while its universality, free compilers, and use in the commercial sector make it popular with students. However, it is not as efficient or as well supported for HPC and parallel processing as are FORTRAN and C, the latter two having highly developed compilers and many more scientific subroutine libraries available. FORTRAN, in turn, is still the dominant language for HPC, with FORTRAN 90/95 being a surprisingly nice, modern, and effective language; but alas, it is hardly taught by any CS departments, and compilers can be expensive. C, and its object-oriented brother C++, are good for HPC, have good free compilers and libraries available, but may be too flexible with precision and memory access for beginners to learn good scientific programming practices. Python, a new, interpreted language that has garnered a small but devoted following, is free, user friendly, good for beginning programming, and has a nice 3D graphics library.


Link to the complete article; http://physics.orst....Papers/CP-2.pdf
  • 0
Science is built up of facts, as a house is with stones. But a collection of facts is no more a science than a heap of stones is a house

- Henri Poincaré


#33 bascule

bascule

    Genius

  • Validating
  • 8,433 posts
  • LocationThe center of the universe (from my frame of reference)

Posted 24 April 2009 - 07:51 PM

I'm a fan of writing correct programs quickly.


... and sloppily, and more or less by yourself. You are in academia, and you are in a computer science department. Sloppiness and working in very small teams are almost a given.


You seem to be rather confused about what I do.

I don't work in a computer science department. I work for an Internet TV company. While I work with a small team (3 others besides myself involved on our core product) there is absolutely nothing sloppy about what I do. I am not in academia. I am in the real world, developing products that have real-world deployments.

We have a rather rigorous approach to development with extensive emphasis on testing. We do both unit testing and integration testing, with a continuous integration testing tool checking all our code every time we check it in.

Our software is modularized and packaged for automated deployment. Error reports in production are emailed to us automatically.

The above gets at what the real issue is. It is a modern version of Snow's Two Cultures. Bascule and I are from two very, very different cultures.


What culture is it that you work in exactly? I suspect the environment I work in is much more rigorous and demanding than yours.

I worry about reliability and all that crap.


We absolutely worry about reliability, which is one of the great things about working in a high level language: many of the problems which make systems unreliable are abstracted away.

We're working on internet-connected televisions and set top boxes. These are the sorts of devices people turn on and expect to work, all the time. There is very little room for error. If there is a problem with our service then the customer will call one of our partners call centers, which costs them money.

Our SLA stipulates 99.9% uptime for our services (e.g. 8 hours of downtime per year, total). That isn't exactly easy to achieve.

Bascule worries slapping crap out quickly.


Time to market is of immense concern to us. However, rapid development doesn't mean "slapping crap out quickly". It means using a more rigorous, test-driven approach to building your programs and keeping your debugging workflow as simple as possible. It also means working in a high level language that prevents the sorts of bugs that occur constantly in low level environments.

I worry about competing with other companies. Bascule worries about competing with others in academia.


We have many competitors, and Ruby on Rails gives us a decided advantage in terms of developing quickly. To quote Paul Graham, we are "beating the averages" by working in a high level language, although instead of Lisp we are using Ruby.

Merged post follows:

Consecutive posts merged

The languages bascule named might be great but nobody use them in science.


Au contrare:

http://www.haskell.o...ril/017050.html

That's just one example...
  • 0
Radicalism: The conservatism of tomorrow injected into the affairs of today.
-- Ambrose Bierce

#34 bascule

bascule

    Genius

  • Validating
  • 8,433 posts
  • LocationThe center of the universe (from my frame of reference)

Posted 6 May 2009 - 12:28 AM

This was a pretty interesting article on why C and C++ are terrible languages for scientific/numerical computing:

http://scienceblogs....anguage_fa.php?

Data parallel arrays were certainly one example... you can do this on an architecture like CUDA, if you code for CUDA.

With a language like Haskell you can get data parallelism which abstractly compiles to a GPU through a package like Obsidian.

And therein lies yet another argument for functional programming: when new technology like CUDA comes along, scientists whose code is written in C/C++ will need to put forth tons of effort to get it to leverage the CUDA architecture, and then their code will be bound to the CUDA architecture.

With a language like Haskell, your code is independent from whatever crazy data parallel execution environments hardware designers can dream up. The compiler can figure it out automagically, whereas with a language like C/C++ you're left to your own devices.
  • 0
Radicalism: The conservatism of tomorrow injected into the affairs of today.
-- Ambrose Bierce

#35 woznutyl

woznutyl

    Lepton

  • Members
  • 1 posts

Posted 13 May 2009 - 05:53 PM

python is a good programming language to learn
  • 0

#36 bascule

bascule

    Genius

  • Validating
  • 8,433 posts
  • LocationThe center of the universe (from my frame of reference)

Posted 14 May 2009 - 03:55 AM

python is a good programming language to learn


Yes MIT recently switched to Python as their introductory language for their CS courses (for purely practical reasons, too)
  • 0
Radicalism: The conservatism of tomorrow injected into the affairs of today.
-- Ambrose Bierce

#37 Pangloss

Pangloss

    Wait, what?

  • Moderators
  • 10,883 posts
  • LocationSouth Florida

Posted 6 June 2009 - 09:36 PM

Stickying this thread for future reference, since we get this question a lot.
  • 0
According to the US Census Bureau almost 75% of those who live below the "poverty line" own a car (31% own 2+), 43% have a 3-bedroom house, 97% own a color TV, 78% have VCR or DVD, 62% have cable or sat TV, 89% have microwave, and over half have a stereo. 89% have "enough to eat", 80% have A/C, only 6% are overcrowded, and avg child dietary consumption is on par with children of middle an upper income parents. Wouldn't it be nice to know if we have any POOR people in this country?

"No one party can fool all of the people all of the time. That's why we have two parties." - Bob Hope

"They will be satisfied when we have Canadian health care and we’ve eliminated the Pentagon. That’s not reality." - White House Press Secretary Robert Gibbs commenting on the "professional left", Aug 10, 2010.

"Pangloss, Every time you open your mouth, your brains are on parade!"
- Norman Albers

#38 leviwolf3378

leviwolf3378

    Lepton

  • Members
  • 2 posts

Posted 11 July 2009 - 10:29 AM

:cool:Actually Programming is good factor these days because it have come modern technology,all things mainly depends on computer.There will be great opportunity ,If You learn any programming language.
  • 0

#39 Xittenn

Xittenn

    Atom

  • Senior Members
  • 1,560 posts
  • LocationDelta, BC; Canada

Posted 11 July 2009 - 03:08 PM

This was a pretty interesting article on why C and C++ are terrible languages for scientific/numerical computing:

http://scienceblogs....anguage_fa.php?

Data parallel arrays were certainly one example... you can do this on an architecture like CUDA, if you code for CUDA.

With a language like Haskell you can get data parallelism which abstractly compiles to a GPU through a package like Obsidian.

And therein lies yet another argument for functional programming: when new technology like CUDA comes along, scientists whose code is written in C/C++ will need to put forth tons of effort to get it to leverage the CUDA architecture, and then their code will be bound to the CUDA architecture.

With a language like Haskell, your code is independent from whatever crazy data parallel execution environments hardware designers can dream up. The compiler can figure it out automagically, whereas with a language like C/C++ you're left to your own devices.


http://msdn.microsof...cy/default.aspx

http://blogs.msdn.co...ts-library.aspx oooooo parallel vectors maybe they'll have fixed some resizing issues as well.....

I'm sure this separation won't be the defining end to c++!

Edited by buttacup, 11 July 2009 - 03:13 PM.

  • 0
"He is their god! He leads them like a thing made by some other deity than Nature that shapes man better. And they follow him against us brats with no less confidence than boys pursuing summer butterflies, or butchers killing flies." - Cominius; Shakespears Coriolanus

#40 bascule

bascule

    Genius

  • Validating
  • 8,433 posts
  • LocationThe center of the universe (from my frame of reference)

Posted 11 July 2009 - 06:49 PM

http://msdn.microsof...cy/default.aspx

http://blogs.msdn.co...ts-library.aspx oooooo parallel vectors maybe they'll have fixed some resizing issues as well.....

I'm sure this separation won't be the defining end to c++!


Note that nothing presented on either of those sites will help you target an architecture like CUDA.
  • 0
Radicalism: The conservatism of tomorrow injected into the affairs of today.
-- Ambrose Bierce




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users