• Home
  • |
  • Blog
  • |
  • Number one JuliaLang beginner tip: Do not delay the active learning.

June 8, 2021

Number one JuliaLang beginner tip: Do not delay the active learning.

If someone would ask me about my number one JuliaLang beginner tip, without hesitation I would say: do not delay the active learning!

If you are new to the language, like I am at the time of writing this post, I would recommend starting with reading the Julia documentation and begin experimenting with some code right away.

Pick your project. Perhaps you want to write a program to calculate how far the projectile will fly, or how Fast Radio Bursts signals get “lensed” by the interstellar plasma, or whatever it is that you are hoping to use Julia for. Please don’t wait until you know it all! You probably never will… But if you delay the practice of code writing by using the excuse of not knowing enough basics to start coding, you will do yourself a big disservice. The sooner you start making mistakes and learning from them, the faster your progress will be. Speaking from experience.

Here is the concrete example: within the next week I am supposed to write some basic Julia programs to experiment with for simulating random temperature-dependent spin flipping (up and down for now) in a very simple spin system (e.g. a linear spin chain composed of just a few spins). This simulation should be based on the Monte Carlo Metropolis algorithm. Statistical mechanics governs the physics aspect of this simulation.

Well, where do I start? I do not know much about Monte Carlo algorithms; I know the basic idea of the method. I need to revise and make sure to understand the physics involved. I know very little Julia to be able to write the program. And I do not have much time to dedicate to learning about just mentioned things before doing the actual work.

My approach to this is as follows. I found an excellent video series on Statistical Mechanics: Algorithms and Computations. It covers the physics I need, it teaches the Monte Carlo methods, and it uses another programming language (Python) to create the simulations. Perfect! I’ll use the codes provided and discussed in this course and “translate” them into Julia.

However, here is the catch. If you know nothing about Julia’s structure, implementation, and syntax, you will get stuck a lot. Just like I did. I attempted to write a simple Julia program to estimate the number of \pi by using the direct random sampling Monte Carlo algorithm. It ended up being just a few lines of code, but it took me about three! hours to get it done. All because I knew nothing about the difference between methods vs functions, how to pick a random number on the interval of uniformly distributed numbers between -1 and 1 in Julia (it easy in Python).

I succeeded in the end and learned quite some things along the way. I sure will remember what I learned because I was actively involved in the learning. I encountered a problem, I fixed it. I did spend a lot of time fixing it, but next time it won’t take as long anymore. Here is the code, btw. if you are curious.

Estimating the number of Pi with the direct sampling MC algorithm. Implemented in JuliaLang.

After spending 3 hours writing such a simple code and trying to understand the error messages (big thanks to the Julia Discourse for the help!), which were mostly method errors, I realized that I need to go back to the documentation and read the appropriate sections to get at least the basic understanding on how the language is designed.

This brings me to learning about methods vs. functions and what types have to do with them. After revising those sections, I became clear about what I was doing wrong and what the Method Error messages actually meant. I will discuss my finding in a separate blog post. This post was intended to serve as a motivation to start learning without overthinking things, without waiting until you read every single documentation page, watched tens or hundreds of YouTube tutorials.

As in everything: perfection is an enemy of progress and a form of procrastination in itself.

Related Posts

How to add a date stamp into a file name (aka string interpolation) in Julia.

How to add a date stamp into a file name (aka string interpolation) in Julia.

My preferred Julia IDE after 3 months of coding.

My preferred Julia IDE after 3 months of coding.

Creating Custom Plot Markers in JuliaLang in 2 ways.

Creating Custom Plot Markers in JuliaLang in 2 ways.

Gnuplot with Julia for powerful plotting option

Gnuplot with Julia for powerful plotting option

Julia Frank


Your Signature

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>