Make your Julia package in 10 minutes

I built my blog some time ago using Franklin.jl and Bootstrap, and I was just waiting for the suitable blogpost material.

It’s a common question here how to make your own package, so I decided to write a post about it. Here it is:

40 Likes

Very nice! Great to have more simple tutorials out there in the world. One thing I noticed: in your package code, you have the exports at the end of the module. I think conventionally they go right after the module is declared.

Of course both work, but I think it would be good to have idiomatic code in beginner tutorials as much as possible.

8 Likes

I second @kevbonham. I believe it is OK to go the idiomatic way and explain that in your blog. A beginner will read your tutorial and be even more confused because you do it differently than done elsewhere. At least I would.

1 Like

Something is wrong with formatting, it’s looks weird in chrome on iPhone.

@mzaffalon @kevbonham I added an explanation. Is this what you had in mind?

@Skoffer thanks, page’s width was set to 50% for all screens instead of large ones only. It should be fine now.

3 Likes

Yes.

As a remark: you can drop the term (-φ)^-n/sqrt(5) because it is smaller than 1/4 for all n>0.

1 Like

That’s true, great suggestion for readers. :smile:

I left that part out because it didn’t fit into the “Suppose you came up with the formula to calculate n-th term of the famed Fibonacci series” idea.

1 Like

Nicely done - that looks useful to me!

1 Like

Glad to see Julia being very international :slightly_smiling_face:


(based on pageviews)

9 Likes

Oh! How do you look at pageviews?

Thanks, this is a very useful page! I created my first package with these instructions.

Most likely, our custom packages will have dependencies. Could you also add instructions for adding a dependency, and how to update Project.toml and Manifest.toml accordingly?

Additionally, if you want to show-off your shiny new package to others, how would you ensure that the package compiles only once and doesn’t recompile every time? AFAIK it does not re-compile if Manifest.toml stays the same. But this info would be very important from day-to-day use of our package.

3 Likes

I use Google Analytics for that, but any other similar service will do. You just need to own the web page to put Google Analytics on it.

I’m very glad for this! :smile:

Added to the post, please check it out.

Manifest.toml shouldn’t be manually edited. I think you are right about re-compiling, but I’d need confirmation for that info from someone more experienced. If someone is up to it, they could actually write a post about compiling in Julia.
Edit: for anyone wondering about the same issue, there is a thread about it: Is it correct that it recompiles packages every time a new REPL is opened?.

1 Like

This was really useful. Thanks. How about extending it to putting the package up on github and adding automatic testing? (I’ll see if I can figure it out myself…)

This video I made is relevant too Why Julia - Package Development in Under 4 Minutes - YouTube
It’s part of the Why Julia series

5 Likes

URL changed to https://zlatanvasovic.github.io/blog/2020/06/make-your-julia-package/, but it seems I can’t edit the original post anymore.

3 Likes

Link in the original post has been updated.

3 Likes