# Julia for Scientists: summary slides

**URL:** https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397
**Category:** Teaching & Outreach
**Tags:** plotting, outreach, teaching, ttfx, advent-of-code
**Created:** [December 8, 2022, 1:15am UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397 "2022-12-08T01:15:01Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [December 8, 2022, 1:15am UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/1 "2022-12-08T01:15:01Z")

</div>

I gave a presentation on Julia today, for staff of my uni’s Psychology department.  
Many interested people in the audience!

These are the slides:  
[![image](https://global.discourse-cdn.com/julialang/original/3X/0/2/02b6fd9c74374dd9ad77742f9176bcc48d00e63c.png)](https://tomasfiers.net/content/2022-12-07-Julia-for-research.pdf)

(It starts slow but quickly goes into more nerdy terrain; The audience is varied, hence the different registers).

I’m posting here as they might be useful for someone else discussing Julia with colleagues.

And also to get feedback: for example, is the explanation of why base Python / R / Matlab is slow correct?  
i.e,

- manifold more CPU instructions per line of source code
- and these extra instructions are all type checking
- …type checking that is run every time the line is run (also in inner hot loops)

There’s also a slide on “Julia tips” where you might find something helpful.  
Plus, shoutouts for @bkamins & @tim.holy 🙂

---

<div class="post-metadata">

### Author: ![garrek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/garrek/32/27937_2.png) [@garrek](https://discourse.julialang.org/u/garrek)
#### Post date: [December 8, 2022, 4:20am UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/2 "2022-12-08T04:20:31Z")

</div>

Thank you for posting this. I’m currently doing up a presentation for data analysis for experiments using Julia and trying to sell people on learning to code instead of using Excel. Your slides have a lot of great points I haven’t thought of!

I’d be curious to read what other people think.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [December 8, 2022, 10:52am UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/3 "2022-12-08T10:52:20Z")

</div>

Nice presentation! The one thing that surprised me about the gripes section was

> Getting floats to print with lower precision is way more difficult than  
> it should be for new users

What do other languages do differently here? It seems to me R and Python print roughly the same things as Julia by default (with R chopping off a bit more)?

```julia
julia> 3/7
0.42857142857142855

>>> 3/7
0.42857142857142855

> 3/7
[1] 0.4285714

```

---

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [December 8, 2022, 11:30am UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/4 "2022-12-08T11:30:56Z")

</div>

Yes (though Matlab has [a shorter default](https://www.mathworks.com/help/matlab/matlab_prog/display-format-for-numeric-values.html))  
But, customizing the default is harder.

NumPy:

```python
np.set_printoptions(precision=4)

```

R:

```nohighlight
options(digits=4)

```

Julia: …  
type pirating Float64’s `show`?  
Which assumes you have learned how Julia’s display system works (a big topic!)

```julia
using Printf # Ok, but, Python has f-strings; built-in!

Base.show(io::IO, x::Float64) = @sprintf "%.4g" x
# Or should this be for ::MIME"text/plain" rather?
# That would allow you to use `print(x)`/`show(x)` to temporarily see more digits.
# BUT, most composite datatypes containing floats would then not use our new compact printing.

```

---

<div class="post-metadata">

### Author: ![t-bltg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/t-bltg/32/25526_2.png) [@t-bltg](https://discourse.julialang.org/u/t-bltg)
#### Post date: [December 8, 2022, 11:41am UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/5 "2022-12-08T11:41:50Z")

</div>

I miss the `numpy` context manager [`np.printoptions`](https://numpy.org/doc/stable/reference/generated/numpy.printoptions.html), really handy.

---

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [December 8, 2022, 11:53am UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/6 "2022-12-08T11:53:07Z")

</div>

> [@garrek](#):
>
> trying to sell people on learning to code instead of using Excel

To be fair to Excel and the like, it has so many killer features that most programming languages don’t have:

- Edit your plots by point and click. Plots are graphic – it’s silly to tweak them with code.
  - [Pylustrator](https://pylustrator.readthedocs.io) (for Matplotlib) is a great experiment that combines GUI-editing of plots with code/reproducibility (though it’s too buggy for practical use atm for me).

- Your data is always easily visible / inspectable
  - Not so in the middle of a for loop in a function in a function; both at runtime and in your code editor

- Reactivity!
  - Though props for the likes of Observable, [natto.dev](https://natto.dev), Pluto.jl

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [December 8, 2022, 12:03pm UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/7 "2022-12-08T12:03:22Z")

</div>

In “why programming” I think a big missing is “reproducibility”

this is also missing in the Julia advantages… when you deal with packages, a huge advantage of Julia is the easy you create thin environments, so that each project you deal with has its own (reproducible) environment…

---

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [December 8, 2022, 12:04pm UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/8 "2022-12-08T12:04:48Z")

</div>

> [@sylvaticus](#):
>
> In “why programming” I think a big missing is “reproducibility”

Oh excellent point! I’ll add it

> [@sylvaticus](#):
>
> when you deal with packages, a huge advantage of Julia is the easy you create thin environments, so that each project you deal with has its own (reproducible) environment

Yeah; I mention Project.toml / Manifest.toml (and talked about it in person); but might be good to add something.

Is there a big difference with R / Python here? (Yes it’s a bit more ergonomic in Julia, and Python has decision fatigue for its plethora of env/pkg management options; but they do the same thing I think)

---

<div class="post-metadata">

### Author: ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)
#### Post date: [December 8, 2022, 12:36pm UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/9 "2022-12-08T12:36:19Z")

</div>

> [@tfiers](#):
>
> Is there a big difference with R / Python here?

The biggest difference here is BinaryBuilder.jl and Yggdrasil for reliably managing binary dependencies.

---

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [December 8, 2022, 6:36pm UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/10 "2022-12-08T18:36:08Z")

</div>

> [@BeastyBlacksmith](#):
>
> The biggest difference here is BinaryBuilder.jl and Yggdrasil for reliably managing binary dependencies.

I hadn’t used Artifacts.jl yet. This looks like it could be amazing for scientists?!  
Automatic downloading of datasets (too big for git) from a URL, plus checksum’ing, plus avoiding unnecessary duplicates? 😮

---

<div class="post-metadata">

### Author: ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)
#### Post date: [December 8, 2022, 7:00pm UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/11 "2022-12-08T19:00:33Z")

</div>

Oh! BinaryBuilder + Yggdrasil is great for binaries (like `pandoc`, `pq`, etc.) but not really meant too much for datasets. I would heartily recommend DataDeps.jl for the case you are thinking of though!

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [December 8, 2022, 7:42pm UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/12 "2022-12-08T19:42:01Z")

</div>

If you are trying to get people to code rather than excel, do you mind if I plug my package [ClipData.jl](https://github.com/pdeffebach/ClipData.jl)? It might help people slowly transition their workflows from excel to Julia.

---

<div class="post-metadata">

### Author: ![tfiers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tfiers/32/32427_2.png) [@tfiers](https://discourse.julialang.org/u/tfiers)
#### Post date: [December 8, 2022, 8:59pm UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/13 "2022-12-08T20:59:46Z")

</div>

I love that @pdeffebach.  
“Copy-paste is the universal API”.

* * *

I updated the slides based on the feedback, thanks all.

(Changes:

- Emphasize reproducibility
  - Mention data tracking & binary dep mgmt

- More on how to type and find unicode characters / LaTeX names
- Added link to [top posts of Seven Lines of Julia](https://discourse.julialang.org/t/seven-lines-of-julia-examples-sought/50416?filter=summary)
- Various new illustrations
- A more fun Syntax example 🙂

)

---

<div class="post-metadata">

### Author: ![garrek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/garrek/32/27937_2.png) [@garrek](https://discourse.julialang.org/u/garrek)
#### Post date: [December 8, 2022, 10:44pm UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/14 "2022-12-08T22:44:29Z")

</div>

Looks neat! I’ll keep it in mind.

---

<div class="post-metadata">

### Author: ![pjgorski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pjgorski/32/4802_2.png) [@pjgorski](https://discourse.julialang.org/u/pjgorski)
#### Post date: [December 9, 2022, 9:17am UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/15 "2022-12-09T09:17:04Z")

</div>

Thanks for sharing!

I recommend mentioning `DrWatson` package. It is perfect for beginners IMO. One doesn’t need to learn about environments and the code becomes truly reproducible.

---

<div class="post-metadata">

### Author: ![denius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/denius/32/3607_2.png) [@denius](https://discourse.julialang.org/u/denius)
#### Post date: [December 9, 2022, 3:18pm UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/16 "2022-12-09T15:18:00Z")

</div>

Somewhere I found this shortening print solution:

```julia
julia> struct IOContextDisplay <: AbstractDisplay ctx end;
       function Base.Multimedia.display(d::IOContextDisplay, x)
           io = IOBuffer()
           ctx = d.ctx(io)
           show(ctx, "text/plain", x)
           println(stdout, String(take!(io)))
       end
       disp = IOContextDisplay(x -> IOContext(x, :compact => true, :limit => true, :color => true))
       pushdisplay(disp)

```

or all in one line

```julia
julia> struct IOContextDisplay <: AbstractDisplay ctx end; function Base.Multimedia.display(d::IOContextDisplay, x) io = IOBuffer(); ctx = d.ctx(io); show(ctx, "text/plain", x); println(stdout, String(take!(io))) end; disp = IOContextDisplay(x -> IOContext(x, :compact => true, :limit => true, :color => true)); pushdisplay(disp); # prettyshow

```

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [December 9, 2022, 4:44pm UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/17 "2022-12-09T16:44:38Z")

</div>

> [@denius](#):
>
> Somewhere I found this shortening print solution:

There is a much easier way nowadays that is [documented in the REPL manual](https://docs.julialang.org/en/v1/stdlib/REPL/#The-Julian-mode):

```julia
julia> 1/pi
0.3183098861837907

julia> Base.active_repl.options.iocontext[:compact]=true
true

julia> 1/pi
0.31831

```

---

<div class="post-metadata">

### Author: ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)
#### Post date: [December 9, 2022, 4:48pm UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/18 "2022-12-09T16:48:12Z")

</div>

I think we should probably have a better interface for this (i.e. a function in InteractiveUtils)

---

<div class="post-metadata">

### Author: ![denius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/denius/32/3607_2.png) [@denius](https://discourse.julialang.org/u/denius)
#### Post date: [December 9, 2022, 10:13pm UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/19 "2022-12-09T22:13:10Z")

</div>

`OhMyREPL.jl` breaks this trick.

---

<div class="post-metadata">

### Author: ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)
#### Post date: [December 9, 2022, 11:04pm UTC](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397/20 "2022-12-09T23:04:32Z")

</div>

> [@Oscar\_Smith](#):
>
> I think we should probably have a better interface for this (i.e. a function in InteractiveUtils)

_probably_ ? 🙂

[Next page](https://discourse.julialang.org/t/julia-for-scientists-summary-slides/91397.md?page=2)
