User Tools

Site Tools



About This Cookbook

  • The target audience for this cookbook are novice and intermediate Julia users with some prior programming experience (e.g., in R, perl, python, C, Fortran), and especially researchers with an interest in the social sciences.
  • This cookbook is for finding quick solutions of common patterns and questions, even for regular Julia programmers.
  • This cookbook is not well-suited to learning programming.
  • This cookbook is not well-suited for experienced julia programmers and developers, or those who want to read a book to become one.

The exposition methods are minimalistic examples, which should speak for themselves. The reader should immediately understand the functionality by looking at the (working) example. Long additional text explanations are (sometimes necessary) shortcomings.

About Julia

Julia is a next-generation programming language with many innovations. From my perspective, the most noteworthy general aspects about Julia are:

  • Julia arrays (vectors and matrices, easy to use for both Int and Float forms) are first-class design features, making Julia a great language for scientific computing. In this respect, it is more like Matlab and R than like Python, perl, or C.
  • Julia relies greatly on generic programming—also called function overloading, where a function with the same name can dispatch based on argument type. In this respect, it is somewhat like the C++ STL.
  • Much of Julia's variables can be strongly typed by the user, making it easier both to find bugs earlier and to write efficient programs.
  • Julia is compiled, with requisite compilation overhead. (Think of Julia more as C++, not as perl or R.) It is slow for short programs (compared to python and R), but it is (often blazingly) fast for long programs.

I am recommending Julia for programming, because:

  • Julia user code is cleaner and more logical than python or perl code, where (float) matrices are subsequent grafts. It is cleaner than R, which has never managed to decide whether it is primarily an interactive environment or a programming language. R's weak typing means bugs often manifest themselves very late, and debugging R can be akin to painful analysis of mystical incantations.
  • Julia is less bogged down by its own history than R, Python, or perl. The developers seem to get along and often help users (incl. early users like myself). The julia system has, as of 2018, not yet calcified to the point where even good and simple changes cause endless controversies. Every language must calcify sooner or later, but Julia will do so with the experiences of 2020, not with those of 1990.
  • Think of Julia as a “heavy-duty” tool and R as a “light-duty” tool. R is often faster for small one-time tasks; Julia is often faster for large projects. (This is with respect to programming, debugging, and execution times.) It would be silly to cut a hedge with scissors, or to cut paper with a hedge trimmer. Both can serve to do the other job in a pinch, but they really serve rather different purposes.

In my mind, Julia makes for a worse interactive environment than R (due to R's sloppy language and instant interpreted response speed), and a better programming environment than R (due to Julia's more careful and sane syntax and faster program run speed). Let me state this for the third time.

  • WARNING Julia is often an order of magnitude faster than R/python/perl for long programs. But Julia is also an order of magnitude slower than R/python/perl for short scripts and interactive use.

About JuliaComputing and JuliaPro

Julia is an open-source next-generation scientific computer language, designed by some amazing people at JuliaComputing (such as Jeff Bezanson, Alan Edelman, Stefan Karpinski, Viral B. Shah, and others). It has enthusiastic supporters that have answered many of my questions while I learned Julia (and while I wrote this cookbook). My own contribution for this cookbook was curating, i.e., keeping track of and organizing the smallest clear examples I could think of while I was learning Julia myself. The Perl Cookbook was my primary inspiration for this Julia cookbook. The perl cookbook is what made perl usable for me when I learned perl. (Thank you, Tom and Nathan!) I hope this Julia cookbook will help Julia attract new users.

JuliaComputing employs the core developers for Julia. To help finance Julia's development, please support them by purchasing their products:

  1. JuliaPro is Julia with a set of curated and more stable packages, an IDE, and enterprise support.
  2. JuliaBox is a web-based interface to a working and curated Julia, sold for a modest per month subscription price.

JuliaComputer further sells, but I have not yet used the following:

  1. JuliaBox is a web-based interface to a working and curated Julia, sold for a modest per month subscription price.
  2. JuliaRun is for large distributed cluster operations.
  3. JuliaDB is for operations on large disk-based data sets.

Help, Authors, and License

  • If you want to help, please email me where I got things wrong.
  • This cookbook was written by Ivo Welch, with some early help from Pranav Bhat.
  • Many of the solutions are based on help from folks at JuliaComputing and the julia discourse forum. Special thanks to Tamas_Papp, Nosferican, Mohamed82008, Steveng, StefanK, Elrod, and others.
  • This cookbook is taking intellectual credit only for the organization of the examples and exposition. I am merely a curator. Julia and its packages were written by others, and it is these authors that deserve the intellectual credit. And ultimately, it is they who designed and thus they were really the only ones who could explain originally how to use their features. We hope to make their efforts more worthwhile by highlighting their work and showing how to use it.
  • This wiki uses DokuWiki, with the github-markdown syntax (and not the regular Dokuwiki syntax).
  • This book is free as in beer, but not free as in speech. It is copyrighted by its author.
  • The author grants permission to use individual snippets freely in other code or in postings (preferably with attribution). please do not copy chapters or sections wholesale—this is not permitted.

Startup File

The cookbook uses a few startup functions (in ~/.julia/config/startup.jl), the most important of which is pkgchk(), which makes it easier to check if a package has already been installed.

preface.txt · Last modified: 2018/10/02 13:14 (external edit)