Programming for science

I want to program science stuff but I also like messing around with making cool OpenGL shit. I know python but it gets really slow as soon as you run anything a bit complex. What's the best language for my needs? C, Lisp, Matlab?

Other urls found in this thread:

sci.brooklyn.cuny.edu/~mate/nml/numanal.pdf
cs.rit.edu/~ats/books/ooc.pdf
amazon.com/Windows-Programming-Dummies-eacute-LaMothe/dp/0764516787
amazon.com/Programming-Abstractions-Computer-Science-Paperback/dp/B004D81WSE
amazon.com/Scientific-Programming-Computational-Science-Engineering/dp/3642302920/
amazon.com/Scientific-Computing-Undergraduate-Computer-Science/dp/1447127358/
amazon.com/Object-Oriented-Numeric-Computing-Scientists-Engineers/dp/0387989900/
amazon.com/Scientific-Engineering-Introduction-Advanced-Techniques/dp/0201533936/
amazon.com/Programming-Principles-Practice-Using-2nd/dp/0321992784/
amazon.com/C -Programming-Language-4th/dp/0321563840
amazon.com/C-Concurrency-Action-Practical-Multithreading/dp/1933988770/
amazon.com/Data-Structures-Algorithms-Adam-Drozdek/dp/1133608426
amazon.com/Algorithms-Parts-1-4-Fundamentals-Structure/dp/0201350882/
amazon.com/Elements-Programming-Interviews-Insiders-Guide/dp/1479274836/
amazon.com/Numerical-Methods-Scientists-Engineers-Mathematics/dp/0486652416/
amazon.com/Numerical-Linear-Algebra-Lloyd-Trefethen/dp/0898713617/
amazon.com/Numerical-Solution-Differential-Equations-Mathematics/dp/048646900X/
stackoverflow.com/questions/26318341/why-doesnt-java-have-true-multidimensional-arrays
stackoverflow.com/questions/8177984/what-is-the-definition-of-a-true-multidimensional-array-and-what-languages-sup
twitter.com/SFWRedditVideos

Julia

In the real world anything under 1000 lines of code Matlab, more than that C or FORTRAN.
C has everything object oriented, procedural, machine level.

sci.brooklyn.cuny.edu/~mate/nml/numanal.pdf
cs.rit.edu/~ats/books/ooc.pdf

Cool book on Windows games in C - get a new one with the disk.
amazon.com/Windows-Programming-Dummies-eacute-LaMothe/dp/0764516787

Basic DS
amazon.com/Programming-Abstractions-Computer-Science-Paperback/dp/B004D81WSE

Also get some openmp books

>I know python but it gets really slow as soon as you run anything a bit complex

that's because you suck at programming. you can try C and openGL but then you will just have even more complexity that you can fuck up. learn to program properly and then try again.

>C has everything object oriented

Uhhhhhhhhhhhhhhhhhhhhhhhhh

There is something wrong in that sentence but I just can't put my finger on it.

HMMMMMMMMMMMMM.

C...

Object Oriented

1960s...

Object Oriented.

HMMMMMMMMMMMMMMMMMMMMM

rude

C++

>I want to program science stuff

Then you're going to have to learn a bit

amazon.com/Scientific-Programming-Computational-Science-Engineering/dp/3642302920/
amazon.com/Scientific-Computing-Undergraduate-Computer-Science/dp/1447127358/
amazon.com/Object-Oriented-Numeric-Computing-Scientists-Engineers/dp/0387989900/
amazon.com/Scientific-Engineering-Introduction-Advanced-Techniques/dp/0201533936/

some additional general coding books:
amazon.com/Programming-Principles-Practice-Using-2nd/dp/0321992784/
amazon.com/C -Programming-Language-4th/dp/0321563840
amazon.com/C-Concurrency-Action-Practical-Multithreading/dp/1933988770/

and some baby CS books:
amazon.com/Data-Structures-Algorithms-Adam-Drozdek/dp/1133608426
amazon.com/Algorithms-Parts-1-4-Fundamentals-Structure/dp/0201350882/
amazon.com/Elements-Programming-Interviews-Insiders-Guide/dp/1479274836/

and some numerical books:
amazon.com/Numerical-Methods-Scientists-Engineers-Mathematics/dp/0486652416/
amazon.com/Numerical-Linear-Algebra-Lloyd-Trefethen/dp/0898713617/
amazon.com/Numerical-Solution-Differential-Equations-Mathematics/dp/048646900X/

>Matlab

Matlab is nice for simple to moderate stuff but anything computationally intensive will be split off into a C++ mex file.

the only useful part of OO programming is the data encapsulation part, and every sane person does that anyway, in any language.
(And C certainly allows you to do it.
Check out openGL. The functions all take some opengl object that has all the relevant state information.
Obviously C doesn't have useless shit like multiple inheritance (like cancer languages such as java and sepples), but if you think the linux kernel can be written without serious levels of abstraction, you're even stupider than the idiot that impregnated your whore mother)

is FORTRAN a meme? Why is it ALL CAPS? (the source code I mean)
Does it use goto's? Isn't it outdated?

Whats the advantage over c? (except for FORTRAN libraries written in the 60s that are still around and that people use because they're lazy)

Human cycles are expensive. Machine cycles are cheap. If you the time you save with a faster script isnt greater than the increased labor it took to make it, fuck it.


The working environment of your colleagues is the other consideration. There's a lot of benefit from using the same tools as your coworkers.

>useless shit like multiple inheritance

If you don't want to use it, then don't. Do you get angry that your calculator has functions you're never going to use?

>like cancer languages such as java and sepples

Java doesn't have multiple inheritances and C++ isn't cancer.

>the linux kernel

Who's talking about linux?
>but Linus said C++ is terrible so it is.

It has multidimensional arrays unless you know a better way.
My friend took CFD at UCLA and at the first meeting the instructor told the class they had the first week to learn FORTRAN.

>It has multidimensional arrays

C also has multidimensional arrays. Every language has multidimensional arrays. Why would a language offer only one-dimensional arrays?

Mathematica

>Whats the advantage over c? (except for FORTRAN libraries written in the 60s that are still around and that people use because they're lazy)
The Fortran code is already written, tested, and runs fast as a motherfucker. What would be the advantage of converting all of this killer old code to C? I seriously doubt there would be any speed advantage and you would almost surely fuck up some important details because you don't know nearly as much about numerical computation as the guys who wrote a lot of that Fortran code in the 60's, 70's, and 80's.

Depends. Established high level numerical codes either done in c++ or fortran for speed or "its what my advisor used" reasons. Fortran is very easy to learn,hard to fuck up and can be used in a parallelized code, but probably not as taught as much as c++ or python.A lot of the astrophysical numerical codes are FORTRAN or c++. If you deal with .fits files then you might try a different language. Also gotta check with your advisor and with your research goals. for instance, recently I had a .json file with a data i needed. Rather then deal with a the awkward fortran syntax to read the file, i read the file into a python code to output the data I needed into a easily readable data file that fortran wont have a problem reading. Once I get the output, I use bash scripts to generate graphs with gnuplot from the fotran data. If you have a hammer, not every problem is a nail.

Take a class and learn python/c++ and learn the logic and methodology of programming well. Once thats done, any other language boils down to syntax and practice.

I'm sorry, what is your point exactly? Mine was, with respect to Fortran, if it ain't broke, why fix it? Would I use Fortran for data munging? No. Of course not. Will I continue to use great Fortran code that I wrote in the 80's to perform certain numerical tasks? Absolutely. Will I write new stuff today in Fortran? Probably not. I like C++.

>and runs fast as a motherfucker

on single cores. and knows absolutely nothing about modern MPI, OMP and vectorization techniques. If any, they're introduced in F2011 or some shit, and then you're lucky if your 1000-years old supervisors code is compatible to his/hers F77 shitwriting.

This. I'm totally bewildered that someone would use multidimensional arrays as a selling point. It's like saying
>you can chain together if-then-else statements with else-if
as a selling point.

Does there even exist a language without multidimensional arrays?

>Does there even exist a language without multidimensional arrays?

I highly doubt it. If you are someone making a new programming language, if you can figure out how to make arrays then you can make n-dimensional arrays.

At the level of pointer arithmethic they are literally just arrays of arrays so by making single dimensional arrays you already made n-dimensional arrays.

The guy posting that probably only knows FORTRAN and has no idea about how trivial multidimensional arrays really are.

I meant true multidimensional arrays. Unless I am wrong only FORTRAN & C# have them.

stackoverflow.com/questions/26318341/why-doesnt-java-have-true-multidimensional-arrays
stackoverflow.com/questions/8177984/what-is-the-definition-of-a-true-multidimensional-array-and-what-languages-sup

But that's wrong you fucktard.
I know for a fact that fortran parallelizes extremely well with mpi and some F77 codes even run on a fucking bluegene/q and faster than any c or c++ shit or whatever.

The key in graphics performance is to minimize the amount of calls to the CPU. Learn about shaders.

there is the old, FORTRAN 77, which has VERY stirct formatting requirements (i got over 100 compiler errors on my first hello world, this shit really teaches you discipline)
and the new Fortran, which is not much different from other modern langues but more convenient for numerics
built in n-dimensional arrays, matrix multiplication, addition/multiplication of array with arrays or scalars. you can even make float-indexed arrays
You are not resticted to float/double, you can have as much precision as you want, even defining custom amount of bits for exponent and mantissa (not that you ever need it)
define custom pre-/post-/infix operators so you can translate mathematical formulas into code more literal [code](x .convolve. y).FFT for example[/code]
very easy to parallelize with openMP/MPI
has list comprehension similar to Python, you can even program somewhat Obejct Oriented. If you really need to it has even pointers and GOTOs

basically the speed of C without all the crap in C that you not ever gonna use in science.
Still, you shouldnt use it on its own, but write the routines that need to be fast, and do the I/O and postprocessing in Python/bash(use f2py to convert the fortran code into regular python modules)

annnnnnnnd back to you go
Nice dubs though

shaders have nothing to do with calls...

you must leave this place,
and never return

If you're working with people, then use whatever everybody else is using and learn more obscure stuff on the side. If you're alone and are curious about the advantages and disadvantages of one system vs another, then try a bunch of them and see what's best.

In a simple sense, Lisp is good for defining languages and modeling complex math but has a trade off of compatibility due to it's expressiveness. Also, if you need Lisp to be faster then you can use SBCL.

C is counter intuitive and cumbersome because of it's association to UNIX, but if you learn it then you have access to practically any level of popular systems management that you want.

I don't know much about matlab.


>If you the time you save with a faster script isnt greater than the increased labor it took to make it, fuck it.

some languages are faster to write than high-level languages. Forth is a good example of this with it's feedback loop sort of programming.

>There's a lot of benefit from using the same tools as your coworkers.

I agree.