{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# About these Lectures"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Overview\n",
"\n",
"Programming, mathematics and statistics are powerful tools for analyzing the functioning of economies.\n",
"\n",
"This lecture series provides a hands-on instruction manual.\n",
"\n",
"Topics include\n",
"\n",
"- algorithms and numerical methods for studying economic problems, \n",
"- related mathematical and statistical concepts, and \n",
"- basics of coding skills and software engineering. \n",
"\n",
"\n",
"The intended audience is undergraduate students, graduate students and\n",
"researchers in economics, finance and related fields."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Julia\n",
"\n",
"The coding language for this lecture series is Julia.\n",
"\n",
"Note that there’s also a related set of [Python lectures](https://python.quantecon.org).\n",
"\n",
"In terms of the differences,\n",
"\n",
"- Python is a general purpose language featuring a huge user community in the sciences and an outstanding scientific and general ecosystem. \n",
"- Julia is a more focused language primarily used in technical and scientific computing, with an outstanding ecosystem for cutting-edge methods and algorithms. \n",
"\n",
"\n",
"Both are modern, open source, high productivity languages with all the key features needed for\n",
"high performance computing.\n",
"\n",
"While Julia has many features of a general purpose language, its specialization makes it much closer to\n",
"using Matlab or Fortran than using a general purpose language - giving it an advantage in being closer\n",
"to both mathematical notation and direct implementation of mathematical abstractions."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### A Word of Caution\n",
"\n",
"The disadvantage of specialization is that Julia tends to be used by domain experts, and consequently\n",
"the ecosystem and language for non-mathematical/non-scientfic computing tasks is inferior to Python.\n",
"\n",
"Another disadvantage is that, since it tends to be used by experts and is on the cutting edge, the tooling is\n",
"much more fragile and rudimentary than Matlab.\n",
"\n",
"Thankfully, with the v1.x release of Julia the fragility no longer applies to the language itself - now stable and\n",
"carefully managed for [version compatibility](https://semver.org/). However, casual users should\n",
"not expect the development tools to quite as stable, or to be comparable to Matlab.\n",
"\n",
"Nevertheless, the end-result will always be elegant and grounded in mathematical notation and abstractions.\n",
"\n",
"For these reasons, Julia is most appropriate at this time for researchers who want to:\n",
"\n",
"1. invest in a language likely to mature in the 3-5 year timeline \n",
"1. use one of the many amazing packages that Julia makes possible (and are frequently impossible in other languages) \n",
"1. write sufficiently specialized algorithms that the quirks of the environment are much less important than the end-result "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Advantages of Julia\n",
"\n",
"Despite the short-term cautions, Julia has both immediate and long-run advantages.\n",
"\n",
"The advantages of the language itself show clearly in the high quality packages, such as\n",
"\n",
"- Differential Equations: [DifferentialEquations.jl](http://docs.juliadiffeq.org/latest/) \n",
"- Function approximation and manipulation: [ApproxFun.jl](https://github.com/JuliaApproximation/ApproxFun.jl) \n",
"- Interval Constraint Programming and rigorous root finding: [IntervalRootFinding.jl](https://github.com/JuliaIntervals/IntervalRootFinding.jl) \n",
"- GPUs: [CuArrays.jl](https://github.com/JuliaGPU/CuArrays.jl) \n",
"- Linear algebra for large-systems (e.g. structured matrices, matrix-free methods, etc.): [IterativeSolvers.jl](https://juliamath.github.io/IterativeSolvers.jl/dev/), [BlockBandedMatrices.jl](https://github.com/JuliaMatrices/BlockBandedMatrices.jl), [InfiniteLinearAlgebra.jl](https://github.com/JuliaMatrices/InfiniteLinearAlgebra.jl), and many others \n",
"- Automatic differentiation: [Zygote.jl](https://github.com/FluxML/Zygote.jl) and [ForwardDiff.jl](https://github.com/JuliaDiff/ForwardDiff.jl) \n",
"\n",
"\n",
"These are in addition to the many mundane but essential packages available. While there are examples of these packages in other languages, no\n",
"other language can achieve the combination of performance, mathematical notation, and composition that Julia provides.\n",
"\n",
"The composition of packages is especially important, and is made possible through Julia’s use of something called [multiple-dispatch](https://en.wikipedia.org/wiki/Multiple_dispatch).\n",
"\n",
"The promise of Julia is that you write clean mathematical code, and have the same code automatically work with automatic-differentiation, interval arithmetic, and GPU arrays–all of which may be used in\n",
"cutting edge algorithms in packages and combined seamlessly."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Open Source\n",
"\n",
"All the computing environments we work with are free and open source.\n",
"\n",
"This means that you, your coauthors and your students can install them and their libraries on all of your computers without cost or concern about licenses.\n",
"\n",
"Another advantage of open source libraries is that you can read them and learn\n",
"how they work.\n",
"\n",
"For example, let’s say you want to know exactly how [Distributions.jl](https://github.com/JuliaStats/Distributions.jl) implements mean of the exponential function\n",
"\n",
"No problem: You can go ahead and [read the code](https://github.com/JuliaStats/Distributions.jl/blob/master/src/univariate/continuous/exponential.jl#L56).\n",
"\n",
"This goes even further since most of Julia is written in Julia. For example, you could see the code for how the standard library calculates the [eigenvalues of a triangular matrix](https://github.com/JuliaLang/julia/blob/master/stdlib/LinearAlgebra/src/triangular.jl#L2594) or calculates the [mean of a range](https://github.com/JuliaLang/julia/blob/master/stdlib/Statistics/src/Statistics.jl#L162)\n",
"\n",
"Those two examples also provide examples where the “multiple dispatch” allows exploitation of the structure of a problem, leading to specialized algorithms (e.g. if the user calls `eigvals` on a matrix that happens to be triangular, it just needs to return the diagonal).\n",
"\n",
"While dipping into external code libraries takes a bit of coding maturity, it’s very useful for\n",
"\n",
"1. helping you understand the details of a particular implementation, and \n",
"1. building your programming skills by showing you code written by first rate programmers. \n",
"\n",
"\n",
"Also, you can modify the library to suit your needs: if the functionality provided is not exactly what you want, you are free to change it.\n",
"\n",
"Another, more philosophical advantage of open source software is that it conforms to the [scientific ideal of reproducibility](https://en.wikipedia.org/wiki/Scientific_method)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## How about Other Languages?\n",
"\n",
"But why don’t you use language XYZ?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### MATLAB\n",
"\n",
"While MATLAB has many nice features, it’s starting to show its age.\n",
"\n",
"It can no longer match Python or Julia in terms of performance and design.\n",
"\n",
"MATLAB is also proprietary, which comes with its own set of disadvantages.\n",
"\n",
"In particular, the Achilles Heel of Matlab is its lack of a package management\n",
"system, which means that either you need to (1) rely on Matlab’s own packages, which\n",
"are mostly written for engineers and not economists; (2) write the code\n",
"yourself; or (3) use unreliable and manual ways to share code (e.g. email or downloading a zip).\n",
"\n",
"If you are a structural engineer or designing a microcontroller, then Matlab provides a coherent set of packages that takes care of all of your needs.\n",
"\n",
"For economists, on the other hand, the expansion in complexity of numerical methods, the need for researchers to\n",
"collaborate on code, fix bugs, deploy improvements, and have dependencies (i.e. packages relying on other packges) has increased past what Matlab can handle.\n",
"\n",
"Given what’s available now, it’s hard to find any good reasons to invest in MATLAB.\n",
"\n",
"Incidentally, if you decide to jump from MATLAB to Julia, [this cheat-sheet](http://cheatsheets.quantecon.org/) will be useful."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### R\n",
"\n",
"[R](https://cran.r-project.org/) is a very useful open source statistical environment and programming language\n",
"\n",
"Its primary strength is its [vast collection](https://cran.r-project.org/web/packages) of extension packages\n",
"\n",
"Julia is more general purpose than R and hence a better fit for this course"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### C / C++ / Fortran?\n",
"\n",
"Isn’t Fortran / C / C++ faster than Julia? In which case it must be better, right?\n",
"\n",
"For the same algorithms, as a compiled language Julia can often achieve a similar level of performance to those languages.\n",
"\n",
"But even when it doesn’t, keep in mind that the correct objective function to minimize: total time = development time + execution time\n",
"\n",
"In assessing this trade off, it’s necessary to bear in mind that\n",
"\n",
"- Your time is a far more valuable resource than the computer’s time. \n",
"- Languages like Julia are much faster to write and debug in. \n",
"- In any one program, the vast majority of CPU time will be spent iterating over just a few lines of your code. \n",
"\n",
"\n",
"The other issue with all three languages, as with Matlab, is the lack of a package management system. Collaborating on C++ or Fortran packages and distributing code between researchers is difficult, and many\n",
"of the criticisms of matlab equally apply.\n",
"\n",
"Finally, the first-order question of performance is which algorithm you are using, and whether it exploits the structure of the problem. The right algorithm in Matlab or Python is typically faster than the wrong\n",
"algorithm in Fortran - and the right algorithm in Fortran and Julia can be made roughly comparable.\n",
"\n",
"When considering the performance advantages, remember that the design and package system of Julia make it easy to try out algorithms that exploit structure of the problem. We will investigate this more in [Introductory Examples](https://julia.quantecon.org/getting_started_julia/julia_by_example.html#julia-by-example)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Last Word\n",
"\n",
"Writing your entire program in Fortran / C / C++ is best thought of as “premature optimization”\n",
"\n",
"On this topic we quote the godfather:\n",
"\n",
"> We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. – [Donald Knuth](https://en.wikipedia.org/wiki/Donald_Knuth)\n",
"\n",
"\n",
"But, to put the final part of the quote\n",
"\n",
"> … Yet we should not pass up our opportunities in that critical 3%. – [Donald Knuth](https://en.wikipedia.org/wiki/Donald_Knuth)\n",
"\n",
"\n",
"Julia is an excellent language to attain those last few percent, without having to resort to C or Fortran code and mix languages in your project"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Credits\n",
"\n",
"These lectures have benefited greatly from comments and suggestions from our\n",
"colleagues, students and friends. Special thanks are due to our sponsoring\n",
"organization the Alfred P. Sloan Foundation and our research assistants Chase\n",
"Coleman, Spencer Lyon and Matthew McKay for innumerable contributions to the\n",
"code library and functioning of the website.\n",
"\n",
"We also thank [Andrij Stachurski](http://drdrij.com/) for his great web\n",
"skills, and the many others who have contributed suggestions, bug fixes or\n",
"improvements. They include but are not limited to Anmol Bhandari, Long Bui,\n",
"Jeong-Hun Choi, David Evans, Xiaojun Guan, Shunsuke Hori, Chenghan Hou, Doc-Jin Jang, Adam Jozefiak,\n",
"Qingyin Ma, Akira Matsushita, Tomohito Okabe, Daisuke Oyama, David Pugh, Alex\n",
"Olssen, Nathan Palmer, Pooya Rashidi Ravari, Arnav Sood, Bill Tubbs, Natasha Watkins, Pablo Winant, Kaan Yolsever and Yixiao\n",
"Zhou."
]
}
],
"metadata": {
"date": 1607199472.550505,
"download_nb": 1,
"download_nb_path": "https://julia.quantecon.org/",
"filename": "about_lectures.rst",
"filename_with_path": "about_lectures",
"kernelspec": {
"display_name": "Julia 1.4.2",
"language": "julia",
"name": "julia-1.4"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.4.2"
},
"next_doc": {
"link": "getting_started_julia/index",
"title": "Getting Started with Julia"
},
"prev_doc": {
"link": "index_toc",
"title": "Table of Contents"
},
"site_title": "Quantitative Economics with Julia",
"title": "About these Lectures"
},
"nbformat": 4,
"nbformat_minor": 2
}