Astro 585 discussion 1

29 January 2014 astro585

I'm taking Eric's class: Astro 585, topics in Astronomy and Astrophysics; High-Performance Scientific Computing for Astrophysics. Its a very discussion based class, and I thought I might try to post my notes here.

These notes are typed quite quickly during class - but I'll try my best to minimize wrong spelling!

Anyways, lets see how it goes!

Discussion Wed Jan 29, 2014

Q: IDL precision, single or double?

IDL's default is single precision - many oblivious grad students have suffered through history because of this.

I myself, a grad-student am started to be exposed to this! - Why are we still using a thing born in the 70s of which you can almost physically see the rust covering it? - Not even mentioning the digital handcuffs... Stallman, are you picking your feet about this?

Automating processes

Using scripts like make

Often if you find yourself doing stuff again, and again (3 or 4 times). Then automating might be useful. Say you have a humongous table that lists lots of things about a new planet you found. For the next planet you find, you might want to have this table be automated.

You can automate things pretty easily in Julia.

Reusing code

The difference between writing astronomical software and developing drugs for a pharmaceutical company

The readings were pretty supportive of reusing code. However, you have to have two things in mind:

Beware of Licenses - This can be troublesome, and can become very hindering for the expansion of projects. - Remember Eric's story about Numerical Recipes - sort of like: All of your thoughts belong to us type of deal.

Libraries - Be sure to know that they are actually doing what you want them to do!

Any tips about refactoring code, or start from scratch?

Difficult to answer, depends on the problem. Rather than rewrite everything maybe focus on rewrite a few functions. And do it in a ridiculously incremental level. Use assertions, debuggers, warnings, print statements etc.

Q: Top-Down vs. Bottom-Up type programming

Difference between academic programming and commercial programming

In the old days, everybody had these massive plans (in the Extreme Programming movement) to make everything perfect from the beginning. Then it sort of transitioned to the quick-and-dirty movement (sometimes making programs that didn't even work!). Nowadays its a kind of pendulum between the two extremes.

For an academic setting: Its very good to make small incremental changes. Still you have to have some overview. So maybe actually programming from the middle might be the right thing to do. Do keep in mind Donald Knuth's words: "Premature optimization is the root of all evil"

Somebody suggested: Bottom up, but keep it general.

Q: Functional programming vs. Object oriented programming

Reusing objects as containers, or making functions do all the work.

For example, you can have a galaxy-class and you can make it do photometry, redshifts, etc.

Object oriented Languages like C++, and Java, make it easy to think in that way. Once you start writing functions that have. You don't need classes really, you can do things you want in C!

Template meta programming (still not exactly sure what this is - you can do it, but supposedly it is a little bit obnoxious).

Say you have a function, an abstract integrator say, and you are gonna pass it a variable. But what if your function doesn't know what type you are gonna pass it? Those types have different internal data structures. If you had a pre-compiled language, the compiler wouldn't really know what type you are gonna pass it - and it might barf. Julias approach is to compile everything at runtime, so it then knows the type, and does it right. So it is a way of getting a compile-type function arguments.

Ergonomically handwritten code, with a little help from my friends; vim, jekyll and twitter bootstrap