Most useful languages

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
Rasputin
Posts: 85
Joined: Thu Aug 16, 2007 3:07 pm UTC
Location: Albany, NY

Most useful languages

Postby Rasputin » Thu Aug 16, 2007 5:10 pm UTC

If you read my first post, you'd know that I am double majoring in Atmospheric Science and Computer Science. I was wondering what computer languages are the most important ones for me to learn for the future. As of now, I know C++, and I need to learn FORTRAN since all weather people love it. This semester I'll be learning a lot about Java and other OO programming.

Other suggestions?
The Immortal One.
Image

User avatar
WhiteRabbit
Railgun of Infinite Patience
Posts: 242
Joined: Fri Oct 20, 2006 2:30 pm UTC
Contact:

Postby WhiteRabbit » Thu Aug 16, 2007 6:00 pm UTC

If you are planning on doing atmospheric research you should pick up MATLAB and enough math to be able to use it well.
For the Jihad

User avatar
Rasputin
Posts: 85
Joined: Thu Aug 16, 2007 3:07 pm UTC
Location: Albany, NY

Postby Rasputin » Thu Aug 16, 2007 6:20 pm UTC

WhiteRabbit wrote:If you are planning on doing atmospheric research you should pick up MATLAB and enough math to be able to use it well.


I actually did do a little lightning research already, but the programs I had to use along with the data is too far over my head at this point. I was researching lightning statistics, and I didn't find that particularly fun (I wanted to study lightning PROPERTIES). I needed C, FORTRAN, and I needed to learn how to use GrADS all on my own. I tried valiantly, but came up short on my goals since I couldn't do it all. That is why I am now working at Blockbuster (I love working at video stores).
The Immortal One.

Image

User avatar
taggedunion
Posts: 146
Joined: Fri Jul 06, 2007 6:20 am UTC
Location: BEHIND YOU

Postby taggedunion » Thu Aug 16, 2007 8:06 pm UTC

Does Google provide any information in that field? (I don't know, myself.) In that case, I'll pull out my own favorite language, Python, which Google seems to love, too (they hired the creator of the language!). Many of the Google APIs are accessible through a Python interface, though doubtless they are accessible in C and others as well. By itself, it's useful for scripting and extending C and C++ (the interpreter is written in C and easily interfaces with it) which, if anything, gives you the advantage of not having to mess with memory management and pointers and such. Python's also just a good programming language to learn, IMHO.

</evangelization>

Another scripting language that might be found in embedded systems, which I would assume a lot of weather computers would consist of, would be Lua. It's fairly simple, powerful and good at what it does--it was originally designed as a dependable scripting language for offshore oil rigs. And it's even closer to C than Python is, and is much a convenient wrapper around C. Its memory footprint is also a paltry couple kilobytes. :o

Python
Lua

Otherwise, you seem pretty good with C, C++, and Fortran. Though I don't suppose learning assembly would do you any good, neh?
Yo tengo un gato en mis pantelones.

User avatar
djn
Posts: 610
Joined: Mon May 07, 2007 1:33 pm UTC
Location: Oslo, Norway

Postby djn » Thu Aug 16, 2007 11:23 pm UTC

Very much depending on the people and systems you'll be around later, python might indeed be useful. It's good for doing data analysis and massaging, and it's fairly simple to write a python module in fortran if you need more speed. (Or C, but f2py makes fortran the easier choice by far.)

priapus
Posts: 73
Joined: Mon Jul 23, 2007 3:23 am UTC

Postby priapus » Fri Aug 17, 2007 12:28 am UTC

..
Last edited by priapus on Mon Aug 20, 2007 6:42 am UTC, edited 1 time in total.

User avatar
djn
Posts: 610
Joined: Mon May 07, 2007 1:33 pm UTC
Location: Oslo, Norway

Postby djn » Fri Aug 17, 2007 12:37 am UTC

priapus wrote:Learn fortran and learn it well. Nothing beats knowing the language preferred in the domain. Python, Lua and other scripting languages are useless imho unless you can extend it readily with C, so don't learn them until you know C, if at all.

As I said right above, it's easier to extend python with fortran than with C. Which supports your first point: Learn fortran.

However, there's no reason not to do everything that isn't time sensitive in python. It's fast enough for most things, much quicker to write, and there's an easy way to migrate to / integrate existing fortran code if you need that.


Oh, and the "don't learn them if you can't extend them in C" is elitism with dubious roots in reality, except if you're specifically speaking of the small subset of problems that need custom-written C code to be fast enough. I suspect that's what you've been dealing with lately, but ... there is a whole different world out there. ;)
For most things that need doing, having access to the libraries (which will already be in C, if needed) is enough. Having to break out to other languages to get anything done is sort of contrary to the intentions.

User avatar
taggedunion
Posts: 146
Joined: Fri Jul 06, 2007 6:20 am UTC
Location: BEHIND YOU

Postby taggedunion » Fri Aug 17, 2007 1:59 am UTC

Especially since Python is essentially an extension from C... well, an interpreted language with most of its libraries and all of its builtins being C extensions.

I mostly suggested Python and Lua because they are very useful glue languages and don't require all of the worry of manual memory management, pointer & reference juggling, etc.

And priapus -- have you actually looked at Lua? Python may be a bit abstract, but Lua is just a shade above C and was expressly designed to be closely embedded/extended with C. All of its useful libraries and most-to-all of the extensions I know of for Lua are in C. In fact, compared to Lua, Python makes it hard to extend in C. Check out its docs and the source code -- it's all quite transparent. Heck, Lua has 2 levels of datatypes designed to manipulate C data structures. I mean -- did you not read what I said before? Frickin' made for oil rigs, man.

So, I guess my point is that by your definition Lua is perfectly alright. :)

(Sorry if I went a little overboard, there.)

Oh, and djn, I agree with you wholeheartedly.
Yo tengo un gato en mis pantelones.

priapus
Posts: 73
Joined: Mon Jul 23, 2007 3:23 am UTC

Postby priapus » Fri Aug 17, 2007 2:24 am UTC

..
Last edited by priapus on Mon Aug 20, 2007 6:42 am UTC, edited 1 time in total.

User avatar
djn
Posts: 610
Joined: Mon May 07, 2007 1:33 pm UTC
Location: Oslo, Norway

Postby djn » Fri Aug 17, 2007 2:46 am UTC

priapus wrote:
djn wrote:For most things that need doing, having access to the libraries (which will already be in C, if needed) is enough. Having to break out to other languages to get anything done is sort of contrary to the intentions.


But you need to know C to write a Python binding to that C language. (I suppose my main criticism about these languages is the difficulty in writing bindings and extensions.)


I used "libraries" to mean "python modules or similar" here, apologies. So no, it's already done for you. And there really is a surprising amount of useful things that already have a python interface. (This still means that someone had to write it once, granted.)

And it's not hard, either. Especially to fortran: You run a program over the fortran code, and get a python module that contains the same functions, with some translations being done for you. It takes a bit of hinting to get in/out arguments right, and when handling large arrays you want to be careful to avoid unnecessary conversions between C and fortran ordering, but overall it's a surprisingly smooth affair.
C is slightly more work, but not too bad. The API documentation is decent.

priapus
Posts: 73
Joined: Mon Jul 23, 2007 3:23 am UTC

Postby priapus » Fri Aug 17, 2007 3:09 am UTC

..
Last edited by priapus on Mon Aug 20, 2007 6:42 am UTC, edited 1 time in total.

User avatar
Xanthir
My HERO!!!
Posts: 5426
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Postby Xanthir » Fri Aug 17, 2007 5:42 am UTC

Depending on your dialect, Lisp's Foreign Function Interface lets you do just that. You can also call Lisp code from within the foreign code, wee!

User avatar
taggedunion
Posts: 146
Joined: Fri Jul 06, 2007 6:20 am UTC
Location: BEHIND YOU

Postby taggedunion » Fri Aug 17, 2007 6:14 am UTC

priapus wrote:I don't know about the f2py tool so I won't comment on it, but regarding C: the fact that you have to manually write a C binding is a failure in itself. You should be able to call functions from dynamic libraries directly.


I think that's impossible unless the languages already have some sort of forced compatibility -- like ASM embedded into C, C and C++, C and Obj-C, and C and D. So, to me you're essentially saying we're not allowed to use different languages together. And if they don't have that sort of compatibility in the first place, there's some conversion work going on somewhere. If the user isn't writing the interface, then someone else had to.

I know Lua makes interfacing with C the absolutely least painless way out of any other language I know. I agree that the higher-level languages often make extending with C unnecessarily complicated (hell, look at what you have to do for a Java native interface!), but Lua's system seems to value simplicity and brevity in comparison. *shrug* That might just be me, though.

Also, I thought it was assumed that Rasputin knew C? He knows C++, which is close enough, and I think he mentioned using just C later in the thread. And hell, if you know C, C++, and Fortran, I don't think writing a binding is even close to the most scary thing you would have come across.
Yo tengo un gato en mis pantelones.

priapus
Posts: 73
Joined: Mon Jul 23, 2007 3:23 am UTC

Postby priapus » Fri Aug 17, 2007 7:14 am UTC

..
Last edited by priapus on Mon Aug 20, 2007 6:42 am UTC, edited 1 time in total.

User avatar
Cameron Walsh
Posts: 7
Joined: Fri May 18, 2007 5:17 am UTC

fortran, matlab, python with scipy and numpy

Postby Cameron Walsh » Fri Aug 17, 2007 9:11 am UTC

All of the computational science (not computer science) subjects I've done have been taught in matlab or a choice between C and fortran.

Fortran, whilst having hideous readability, is still probably the most commonly used language in that field. It's important to know it, if only so that you can understand what's been done in the past and fix bugs in it.

Matlab is fantastic for modelling anything discretely, anything that can be expressed as a matrix.

Python, with the pylab, scipy and numpy libraries, is what I've been using for most of my computational science projects since. It's array syntax isn't as clean as Matlab's, but it's easier to program everything that is not an array. Like Matlab, numpy array operations are incredibly fast, but loops are slow.

Octave I've heard of, as a free version of Matlab, but I'd be more tempted to fork out for a Matlab student license or stick with Python/pylab/numpy/scipy.

That said, I am probably overly biased towards Python. My fiancee keeps bagging me out whenever I am thwarted by Python not being quite as simple as Matlab. Things like not being able to apply the math.cos etc. functions to each element in an array as an array operation, only as a loop. Must find equivalent in numpy...

User avatar
djn
Posts: 610
Joined: Mon May 07, 2007 1:33 pm UTC
Location: Oslo, Norway

Postby djn » Fri Aug 17, 2007 10:15 am UTC

Well, there is a lot of ugly translations that has to happen if you want it to actually look like python when you call it, which is where the wrappers really enter the game. For straight translations, you can get some of the way with swig, but then you have to write C camouflaged as python around it. (Manually handling memory in python? Pointers? Yay.)

Still, it should be possible to do something with the appropriate header file and dlopen, on the fly.

orangeperson
Posts: 117
Joined: Sun May 13, 2007 2:17 am UTC

Re: fortran, matlab, python with scipy and numpy

Postby orangeperson » Fri Aug 17, 2007 4:44 pm UTC

Cameron Walsh wrote: Things like not being able to apply the math.cos etc. functions to each element in an array as an array operation, only as a loop. Must find equivalent in numpy...

Code: Select all

>>> list = [(math.pi/6),(math.pi/2)]
>>> sinlist = map(math.sin,list)
>>> print sinlist
[0.49999999999999994, 1.0]


voila.
spjork.

User avatar
djn
Posts: 610
Joined: Mon May 07, 2007 1:33 pm UTC
Location: Oslo, Norway

Postby djn » Fri Aug 17, 2007 9:03 pm UTC

Or even faster:

Code: Select all

>>> import Numeric
>>> import math
>>> arr = Numeric.array([math.pi/2, math.pi/6, 0])
>>> Numeric.sin(arr)
array([ 1. ,  0.5,  0. ])


I expect NumPy would work the same. They're usually drop-in replacements for each other.

Of course, having everything do The Right Thing when given an array would be neat.

User avatar
taggedunion
Posts: 146
Joined: Fri Jul 06, 2007 6:20 am UTC
Location: BEHIND YOU

Re: fortran, matlab, python with scipy and numpy

Postby taggedunion » Sat Aug 18, 2007 7:38 pm UTC

Cameron Walsh wrote:Things like not being able to apply the math.cos etc. functions to each element in an array as an array operation, only as a loop. Must find equivalent in numpy...


Note: I wrote this post thinking you were talking more about lists, influenced by djn's post just previous to mine. I think this post might be useful, though, so I'm submitting it.

Some would argue that's a feature. But what precisely do you mean? Are you using straight-ahead loops, like

Code: Select all

sinlist = []
for i in lst:
    sinlist.append(math.sin(i))

(which does suck) or are you using the list comprehension syntax,

Code: Select all

sinlist = [math.sin(i) for i in lst]

which is much nicer and is now the canonical way to do list operations in Python (they're phasing out map, filter, apply/reduce in favor of list comprehensions). Python stole LCs from Haskell*, which uses them to great affect (map and filter are defined as LCs in the Prelude).

* Or an earlier functional language
Yo tengo un gato en mis pantelones.

User avatar
taggedunion
Posts: 146
Joined: Fri Jul 06, 2007 6:20 am UTC
Location: BEHIND YOU

Postby taggedunion » Sat Aug 18, 2007 7:47 pm UTC

priapus wrote:It's not impossible, at all. C# can very painless call DLL functions with the DLLImport attribute. All .NET languages can do this, even on Mono.


Okay, I was thinking you meant binary compatibility. I do think .NET is a little bit too easy to bring up, but meh.

My criticism still stands that the binary/DLL wrapper is invisible extra work, but considering I'm sponsoring HLLs like Python for the reason of hiding memory management and such, I suppose I should drop that, too. :P

It's even easier with Common Lisp and CFFI, here's a binding for sprintf:
...
That's the way it's supposed to be. And if you think about it, since there are dlopen and dlsym, there's absolutely no reason why it should be any other way. Having to write bindings manually is a pure design error and disadvantage.


I definitely take that to heart and put that in my own list of considerations for language design (I wanna be a compiler/interpreter writer when I grow up! ^_^). Thanks, I think the point's been finally made for me--well, finally pushed through my thick skull. ;)
Yo tengo un gato en mis pantelones.

ihope127
Posts: 66
Joined: Mon Jul 30, 2007 3:59 am UTC
Location: 127.0.0.1
Contact:

Re: fortran, matlab, python with scipy and numpy

Postby ihope127 » Sun Aug 19, 2007 9:30 pm UTC

taggedunion wrote:map and filter are defined as LCs in the Prelude


I thought it was the other way around--list comprehensions were automatically turned into map and filter, which were in turn defined using the usual pattern matching and such.
There is a significant chance that an artificial intelligence created within the next few decades will not value humanity and therefore will treat us as we treat animals. It would be awesome if xkcd mentioned this.
----
Find me on freenode as uorygl.

Leetness Jefferson III
Posts: 5
Joined: Sun Aug 19, 2007 5:08 am UTC
Location: Orlando, Flahdah
Contact:

Postby Leetness Jefferson III » Mon Aug 20, 2007 3:57 am UTC

Mainly do business web development so asp.net, C#, and SQL for me :twisted:

recurve boy
Posts: 353
Joined: Wed Jan 31, 2007 5:48 am UTC
Location: Sydney Australia
Contact:

Postby recurve boy » Mon Aug 20, 2007 5:12 am UTC

Other than fortran I would learn one high level language. I like Java since it had so many libraries for it and is fairly high level. I found this useful for prototyping programs where I was a little unsure of the math. Once you know it is correct, porting to your main language is easy.

cathrl
Posts: 427
Joined: Tue Jan 30, 2007 9:58 am UTC

Postby cathrl » Tue Aug 21, 2007 4:36 pm UTC

Make sure you learn Fortran, not FORTRAN. There are still places around which teach F77. It's only been obsolete for 17 years :(

Maybe Mathematica? Not sure how widely used it is in that field.

User avatar
Rasputin
Posts: 85
Joined: Thu Aug 16, 2007 3:07 pm UTC
Location: Albany, NY

Postby Rasputin » Wed Aug 22, 2007 2:16 am UTC

cathrl wrote:Make sure you learn Fortran, not FORTRAN. There are still places around which teach F77. It's only been obsolete for 17 years :(

Maybe Mathematica? Not sure how widely used it is in that field.


People in my field like F90 and Fortran (don't know the differences as of yet...).

And NO CODES ARE OBSOLETE!
The Immortal One.

Image

cathrl
Posts: 427
Joined: Tue Jan 30, 2007 9:58 am UTC

Postby cathrl » Thu Aug 23, 2007 8:07 pm UTC

Rasputin wrote:
cathrl wrote:Make sure you learn Fortran, not FORTRAN. There are still places around which teach F77. It's only been obsolete for 17 years :(

Maybe Mathematica? Not sure how widely used it is in that field.


People in my field like F90 and Fortran (don't know the differences as of yet...).

And NO CODES ARE OBSOLETE!


No, but F77 (= FORTRAN) is a subset of F90 (is a subset of F95 is a subset of F2k...). So learning only the smallest, oldest subset is a mistake. And since by definition a valid F77 program is also a valid F2k program, they're most definitely not obsolete. You'd be startled just how many major, major industries are still underpinned by F77 code. Or maybe you wouldn't.

cathrl, Fortran fangirl :)

User avatar
necroforest
Posts: 195
Joined: Tue Apr 10, 2007 3:46 pm UTC
Contact:

Postby necroforest » Thu Aug 23, 2007 11:12 pm UTC

Two words I'd never imagine ever seeing side by side: "fortran fangirl"
ONE PART CLASS, ONE PART WHISKEY, TWO PARTS GUN! SERVE NEAT!


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 5 guests