Is Fortran a good first programming language? I'm transferring from a CC to a 4 year college next semester. One of the first courses I'll take is an intro programming for physics majors that uses Fortran. They also use C++ but that seems to come towards the end of the course.
Would it be good to start trying to learn Fortran now? Or pick a different language to get comfortable with before I have to take that class?
Fortran is really awful, but also it's dead easy to do simple things, so it might be an okay introduction to programming. It's not as nit-picky as C++.
It'll introduce bad habits that you'll never get out of if you decide to learn high level programming languages later on in life. But it kind of depends on what you want out of it. If those are the only programming languages you ever intend to use, then you may as well start learning it.
I'm currently doing large molecular dynamics simulations in Ruby. The savings in debug and development time more than offset any performance losses from using a high level language. But if you're not going to use it in your class, maybe hold off on that.
It's not it's the only thing I'll use. Hopefully with some self-control, I'll teach myself more C+ and another language or two over time while I'm still there.
How damaging would those habits be if I tried another (maybe Python) over the summer once the class ends?
I want both, just unsure of the best way to start before I transfer.
Yeah but I mean what do you have to even do? I don't know what sort of systems they're used in but lets say its a database. This database was written in, say, 1985, and has been functioning since then. What are you expected to do? Suddenly revise the code if some 30 year old bug suddenly shows itself? Alter it to make it compatible with Win 10 computers that access it? What is it you do to ancient systems that you'd have no idea how to recreate anyway if they did somehow fuck themselves to hell through some weird corruption of their program?
Learn python and fortran. Python is a solid general language that will let you do a lot, however it's not very good when it comes to heavy numerical work, which is where Fortran comes in. So what you can do is use f2py, which allows you to place Fortran subroutines inside python functions. What this means is that you can quickly and easily generate a python script to pass a series of values to a Fortan programme, which will do all the heavy lifting, then pass the all the outputs back to your python script to do what ever you want with it.
lmao go fuck yourself, what are you 30-40 year old with a dead end job?
This. As a physicist you want to learn one language that's easy to write in, and one language that can crunch numbers really really well. In addition, Fortran has been in use for a long time, so there are a lot of routines (in the world of physics) that are written in Fortran.
f2py is a python module. If your class is in Fortran, then learn Fortran and python on the side. It's a fairly simple language to pick up, since there's not much to it. Pic related is an implementation of Eulers method.
>inb4 /sci/ hates on me
Fucking love fortran. It has its annoyances, but its so goddamn easy to use.
Probably less ideal, but I tend to use bash scripting for this because its easier and im lazy.
misspelled finish in the call cpu_time. Also, is that geany?
Its also the easiest to run in parallel AFAIK. Though i believe theres a c++ offshoot designed purely for use in parallel coding. As far as I've seen in hydrodynamics/astrophysics, the big codes are fortran or c++ with the occasional python code ( https://github.com/zingale/pyro2 ) for example.
> how damaging
It won't be that terrible. I mean, everyone else goes through it... some people spend entire careers writing in nothing but Fortran. They'd have been much more productive if they'd used something else, but they didn't know better and it gets the job done. But you'll find yourself writing a lot of unnecessary code that, when you finally go learn a high level programming language, you'll want to replicate. It's hard for the ego to spend years working with a 40 line loop of code, building a hideous spaghetti-like mess of conditions and entry/exit points, and then learn a higher level language and realize that you could have done it in 2 lines.
Python is okay. I don't use it, but that doesn't mean you shouldn't. It doesn't do anything in particular really well, but it does most things adequately. A lot of people know the basics of it (though few know it really well), so at least you don't get retarded reactions like >>7583682 when you tell someone you use it.
The fortran code is pretty self contained, just needs input files. So will generally bash script over loops and use sed to fix the input file for each run. Then in the script, run gnuplot and move all the files to other folders so I keep the working directory clean. I suppose I could do all of this in python and in the next phase of my project will end up having to wrap everything in python, but for now I think bash is ideal?
>> large molecular dynamics simulations in Ruby
WHY? That does not make any sense anon. Why aren't you just using a ready made molecular dynamics package like LAMMPS that has been highly optimized? Writing your own (presumably classic ) MD codes does not make any sense in this day and age.
I mean with LAMMPS you can run everything from python if you really have too.
>be me, taking a class on molecular dynamics
>"model 36 argon gas atoms in a periodic boundary box of this size at this temp"
>"write it in matlab, include the code in your submission"
But yeah, LAMMPS is GOAT
OH SHIT WHAT ARE YOU DOING
This, learn C++ and Fortran so you can do the heavy programming with those and then use python for the rest. This is what we do in our research group in computational physics (although I'm the only young one that knows Fortran, C++ is preferred generally).
>a 40 line loop of code, building a hideous spaghetti-like mess of conditions and entry/exit points
Only legacy/shit code is like that in Fortran.
If you are only going to run your code in your machine it's ok if it works, but only *4 and *8 are universally supported. Now I'm not sure if this is only an issue for old computers, but yeah. Also, it's slower.