# 1.6: Writing Code for Scientific Computing

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$

( \newcommand{\kernel}{\mathrm{null}\,}\) $$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\id}{\mathrm{id}}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\kernel}{\mathrm{null}\,}$$

$$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$

$$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$

$$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

$$\newcommand{\vectorA}[1]{\vec{#1}} % arrow$$

$$\newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow$$

$$\newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vectorC}[1]{\textbf{#1}}$$

$$\newcommand{\vectorD}[1]{\overrightarrow{#1}}$$

$$\newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}}$$

$$\newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}}$$

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

Look back at the list of requirements for Scientific Computing projects. A general rule of thumb is to use a computing language that you know will work well for those tasks. Typically, most students have learned one or two languages and aren’t quite sure which to use. In most cases it doesn’t matter what to use, but for complex problems it will matter.

One of the best languages for scientific computing has been Matlab over the past 3 or 4 decades. It is used extensively in engineering firms throughout the world (and the headquarters is in nearby Natick, MA). We won’t be using Matlab here though. One of the nice things about taking a class is exploring new languages. Here we will use Julia, which is a very new language that a lot of people in scientific computing are excited about. We will give examples using Julia, but the ideas here should be applicable to other languages.

Julia was designed as a scientific computing language, but in short is a modern language. There are number of aspects that makes julia a good language for this. Julia is

• a scripting language with dynamic types. This means you can get started right away–there’s no need to learn about compilation–and you can prototype things quickly.
• a language with just-in-time compilation. Most of the time scripting languages are slow, however with modern under-the-hood tools, languages can be compiled on the fly to create very fast runtimes. There is a webpage on benchmarks comparing julia to other standard languages.
• open source. Although often open-source implies free but not high-quality, the free part holds, but more important is that anyone can contributed to the code. The Julia community is committed to creating a high-quality piece of software and many discussion revolve around writing code that will improve the speed or other aspects. This is very opaque and unclear if it happens with commercial software.
• easy to use. The syntax of julia is similar to that of python, a very popular language, and is often intuitive.
• a joy to use. Additionally, the structure of the language makes it easy to start with, but as projects get more complex, it can be written in a simple way.

This page titled 1.6: Writing Code for Scientific Computing is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Peter Staab.