# Blog post about my experiences with Julia

**URL:** <https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976>\
**Category:** Community\
**Created:** [April 25, 2022, 8:19am UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976 "2022-04-25T08:19:00Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![Volker\_Weissmann](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@Volker\_Weissmann](https://discourse.julialang.org/u/Volker_Weissmann)\
**Post date:** [April 25, 2022, 7:13pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/62 "2022-04-25T19:13:24Z")

</div>

> [@Henrique\_Becker](#):
>
> > [@Volker\_Weissmann](#):
> >
> > @includeonce
> 
> From where this comes from? Is it `Base` Julia?

No, it’s from [GitHub - tgflynn/IncludeGuards: Provides an include guard mechanism for julia](https://github.com/tgflynn/IncludeGuards) .

> [@Henrique\_Becker](#):
>
> > [@Volker\_Weissmann](#):
> >
> > Another thing is that dynamic typing (without lots of type assertions) is kind of a violation of this guideline.
> 
> This is kinda of a good point but moot. The way Julia is designed asks for you to be as lax as possible with type restrictions in function signatures, what does go against the “fail as soon as possible” school of thought. It is not a problem without workarounds, but these workarounds must be explicitly written instead of just using the type system to do the job. All in all, it is the trade-off that any dynamic language makes at some level.

What would you suggest to debug this code/make the error message nicer?

> <https://github.com/SciML/SimpleDiffEq.jl/issues/48>
>
> Running this code
> \`\`\`julia
> using SimpleDiffEq
> f(u,p,t) = 2u
> g(u,p,t) = 1
> u0… = 0.5
> tspan = (0.0,1.0)
> prob = SDEProblem(f,g,u0,tspan)
> sol = solve(prob,SimpleEM(),dt=0.25)
> g(du,u,p,t) = du .= 2.0 \* u
> function f(du, u, p, t)
> g(du,u,p,t)
> end
> 
> using SimpleDiffEq
> f(u,p,t) = 2u
> g(u,p,t) = 1
> u0 = 0.5
> tspan = (0.0,1.0)
> prob = SDEProblem(f,g,u0,tspan)
> sol = solve(prob,SimpleEM(),dt=0.25)
> g(du,u,p,t) = du .= 2.0 \* u
> function f(du, u, p, t)
> g(du,u,p,t)
> end
> \`\`\`
> outputs:
> 
> \`\`\`
> ERROR: LoadError: MethodError: no method matching copyto!(::Float64, ::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Tuple{}, typeof(identity), Tuple{Float64}})
> Closest candidates are:
> copyto!(::DiffEqArrayOperator, ::Any) at /home/volker/.julia/packages/SciMLBase/dyqr8/src/operators/basic\_operators.jl:112
> copyto!(::Any, ::Base.Broadcast.Broadcasted{var"#s155", Axes, F, Args} where {var"#s155"\<:StaticArrays.StaticArrayStyle, Axes, F, Args\<:Tuple}) at /home/volker/.julia/packages/StaticArrays/xV8rq/src/broadcast.jl:29
> copyto!(::DiffEqBase.DiffEqBC, ::Base.Broadcast.Broadcasted{var"#s7", Axes, F, Args} where {var"#s7"\<:Base.Broadcast.AbstractArrayStyle{0}, Axes, F, Args\<:Tuple}) at /home/volker/.julia/packages/DiffEqBase/qntkj/src/diffeqfastbc.jl:42
> ...
> Stacktrace:
> \[1\] materialize!
> @ ./broadcast.jl:894 \[inlined\]
> \[2\] materialize!
> @ ./broadcast.jl:891 \[inlined\]
> \[3\] g(du::Float64, u::Float64, p::SciMLBase.NullParameters, t::Float64)
> @ Main ~/Sync/DatenVolker/git/sm\_with\_julia/bug.jl:8
> \[4\] f(du::Float64, u::Float64, p::SciMLBase.NullParameters, t::Float64)
> @ Main ~/Sync/DatenVolker/git/sm\_with\_julia/bug.jl:10
> \[5\] (::SDEFunction{true, typeof(f), typeof(g), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing})(::Float64, ::Vararg{Any, N} where N)
> @ SciMLBase ~/.julia/packages/SciMLBase/dyqr8/src/scimlfunctions.jl:395
> \[6\] solve(::SDEProblem{Float64, Tuple{Float64, Float64}, true, SciMLBase.NullParameters, Nothing, SDEFunction{true, typeof(f), typeof(g), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing}, typeof(g), Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, Nothing}, ::SimpleEM; dt::Float64)
> @ SimpleDiffEq ~/.julia/packages/SimpleDiffEq/vIpeG/src/euler\_maruyama.jl:57
> \[7\] top-level scope
> @ ~/Sync/DatenVolker/git/sm\_with\_julia/bug.jl:19
> in expression starting at /home/volker/Sync/DatenVolker/git/sm\_with\_julia/bug.jl:19
> \`\`\`

---

<div class="post-metadata">

**Author:** ![Volker\_Weissmann](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@Volker\_Weissmann](https://discourse.julialang.org/u/Volker_Weissmann)\
**Post date:** [April 25, 2022, 7:16pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/63 "2022-04-25T19:16:21Z")

</div>

> [@goerch](#):
>
> Nice, so you are that kind of guy (as I am or was?). Try some dependent type programming and you might come back to Julia someday to have some fun, as I did.

Never used dependent types or read about them.

But yes, take a cliche vegan, substitute vegan food for rust, that’s me. Every second argument is: “rust does this better”.

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [April 25, 2022, 7:18pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/64 "2022-04-25T19:18:10Z")

</div>

> [@Volker\_Weissmann](#):
>
> Never used dependent types or read about them.

Not sure if I’m qualified to talk about this, but take a look at [Idris](https://www.idris-lang.org/).

---

<div class="post-metadata">

**Author:** ![Volker\_Weissmann](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@Volker\_Weissmann](https://discourse.julialang.org/u/Volker_Weissmann)\
**Post date:** [April 25, 2022, 7:31pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/65 "2022-04-25T19:31:01Z")

</div>

> [@jakobnissen](#):
>
> - We don’t have good autogenerated docs, like `cargo doc` . It should be possible to create a program that reads Julia code, lists exported functions and types, which functions operate on types, etc, and links them together and create a HTML file. That would be a really nice addition to Julia.

You have [Home · Documenter.jl](https://juliadocs.github.io/Documenter.jl/stable/) . Go to [JuliaHub](https://juliahub.com/ui/Packages) and click on the documention links.

> [@jakobnissen](#):
>
> ### Things that are not so bad
> 
> - Having `typeof(x)` give the whole type with tonnes of type parameters is not a problem, IMO. You can always just ask for the base type. See also `https://github.com/JuliaLang/julia/issues/35543`
> - `apropos("Dict")` is not the way to ask for methods with `Dict` . The right way is… `methodwith` .

But `methodswith(Dict)` also returns addenv.

> [@jakobnissen](#):
>
> - You can redefine functions using `Revise`

Run

```julia
using Revise
function func(x::Int)
    print("old")
end
# function func()
# print("new")
# end
func(123)

```

then switch the comments:

```julia
using Revise
# function func(x::Int)
# print("old")
# end
function func()
    print("new")
end
func(123)

```

and it still prints “old”. There is lingering state, which is bad.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [April 25, 2022, 7:33pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/66 "2022-04-25T19:33:31Z")

</div>

> [@Volker\_Weissmann](#):
>
> What would you suggest to debug this code/make the error message nicer?

I do not know `SimpleDiffEq` enough to make a substantiated suggestion. If I understand the problem correctly you did pass `u0` as a `Float64` but then in a hook you did use `du .= 2.0 * u` (where `du` starts with `u0` value). So it is a little strange to me how did you arrive at this situation (you did not have any mutable container defined in the code, why `.=` was used then?).

All in all, in fact, I do not find the error message to be bad. It does point to a line of your code, and it is precise about the problem, the issue is that with the broadcasting machinery involved you get names like `materialize!` and `copyto!` that mean nothing to the novice programmer. It does not seem to me a problem related to what we were discussing (failing as soon as possible) but the fact that broadcasting error messages are confusing to novices. It would be impossible to fail sooner there because the code takes a generic hook (if I am not wrong), and as so it cannot check the input type against anything. This is a common problem with hooks/callbacks, not a language problem, even if some languages like Haskell were able to do some very aggressive trade-offs that may solve this problem of designing code with hooks/callbacks.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [April 25, 2022, 7:33pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/67 "2022-04-25T19:33:53Z")

</div>

> [@Volker\_Weissmann](#):
>
> and it still prints “old”. There is lingering state, which is bad.

Uhm… no, that is because you are not tracking the changes there. If you put the function in a file (or module), Revise tracks the changes:

```julia
julia> using Revise

julia> includet("./teste.jl")

julia> f(1)
1

julia> f(1)
2

```

where `teste.jl` is:

```julia
#f(x::Int) = 1
f(x) = 2

```

---

<div class="post-metadata">

**Author:** ![suavesito](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/suavesito/32/34386_2.png) [@suavesito](https://discourse.julialang.org/u/suavesito)\
**Post date:** [April 25, 2022, 7:34pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/68 "2022-04-25T19:34:29Z")

</div>

> [@Volker\_Weissmann](#):
>
> There is lingering state, which is bad.

I mean, that state is just two different _methods_ of the same _function_ `func`. Revise will not “delete” methods of a function, it will just allow to “reload” methods definitions when you’re editing a file that is included.

---

<div class="post-metadata">

**Author:** ![Volker\_Weissmann](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@Volker\_Weissmann](https://discourse.julialang.org/u/Volker_Weissmann)\
**Post date:** [April 25, 2022, 7:35pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/69 "2022-04-25T19:35:29Z")

</div>

Thanks, cool, I always just did shift+enter in vscode.

---

<div class="post-metadata">

**Author:** ![Volker\_Weissmann](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@Volker\_Weissmann](https://discourse.julialang.org/u/Volker_Weissmann)\
**Post date:** [April 25, 2022, 7:36pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/70 "2022-04-25T19:36:03Z")

</div>

Yes. But this can make for a really funny debugging session.

---

<div class="post-metadata">

**Author:** ![jakobnissen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jakobnissen/32/13477_2.png) [@jakobnissen](https://discourse.julialang.org/u/jakobnissen)\
**Post date:** [April 25, 2022, 7:37pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/71 "2022-04-25T19:37:09Z")

</div>

> You have [Home · Documenter.jl](https://juliadocs.github.io/Documenter.jl/stable/) . Go to [JuliaHub](https://juliahub.com/ui/Packages) and click on the documention links.

Yes, but AFAIK, Documenter’s autogenerated documentation is not very thorough. It adds the docstring. It doesn’t for example, add links to functions automatically found with `methodswith`, or tell which position in the type hierarchy a type is, or which type parameters a type has.

Julia has pretty good human-written docs, but I think Rust shows the autogenerated docs could be better.

> and it still prints “old”. There is lingering state, which is bad.

Revise doesn’t track the REPL. Maybe it should? But if you do what you did there in a file that is tracked by Revise, then it will actually print `new`, not `old.`

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [April 25, 2022, 7:38pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/72 "2022-04-25T19:38:14Z")

</div>

> [@Volker\_Weissmann](#):
>
> Thanks, cool, I always just did shift+enter in vscode.

Indeed, that was something I mentioned right above in some place: I think that finding the right workflow in Julia requires some guidance. I taught courses in Julia, and it was completely different when, on the second time, I started by showing the students what I think is the best workflow, before anything else. Without that people can get a very bad first impressions, and the good workflows are not obvious. It is a barrier that must be overcome.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [April 25, 2022, 7:40pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/73 "2022-04-25T19:40:01Z")

</div>

> [@Volker\_Weissmann](#):
>
> What would you suggest to debug this code/make the error message nicer?
> 
> [MethodError: no method matching copyto! · Issue #48 · SciML/SimpleDiffEq.jl · GitHub](https://github.com/SciML/SimpleDiffEq.jl/issues/48)

> [@Henrique\_Becker](#):
>
> All in all, in fact, I do not find the error message to be bad. It does point to a line of your code, and it is precise about the problem, the issue is that with the broadcasting machinery involved you get names like `materialize!` and `copyto!` that mean nothing to the novice programmer. It does not seem to me a problem related to what we were discussing (failing as soon as possible) but the fact that broadcasting error messages are confusing to novices. It would be impossible to fail sooner there because the code takes a generic hook (if I am not wrong), and as so it cannot check the input type against anything. This is a common problem with hooks/callbacks, not a language problem, even if some languages like Haskell were able to do some very aggressive trade-offs that may solve this problem of designing code with hooks/callbacks.

FWIW, I think this is pointing at something I’ve been meaning to open an issue for. Broadcast should really catch errors and throw a higher level error. It really can. Saying “I cannot `materialize!`” assumes people know some deep stuff. `materialize!` is not even one of the documented interface functions for Broadcast:

[https://docs.julialang.org/en/v1/manual/interfaces/#man-interfaces-broadcasting](https://docs.julialang.org/en/v1/manual/interfaces/#man-interfaces-broadcasting)

So yes, it should catch this and say “In-place Broadcast was not possible with types X, Y, Z.”. And then, even better, if it’s trying to materialize an in-place broadcast to a `Number`, it should catch that and have an explanation as to why `x .= y` is never going to work with `x = 2.0`.

That error message can definitely be better.

---

<div class="post-metadata">

**Author:** ![Volker\_Weissmann](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@Volker\_Weissmann](https://discourse.julialang.org/u/Volker_Weissmann)\
**Post date:** [April 25, 2022, 7:40pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/74 "2022-04-25T19:40:10Z")

</div>

> [@Henrique\_Becker](#):
>
> This is a common problem with hooks/callbacks, not a language problem, even if some languages like Haskell were able to do some very aggressive trade-offs that may solve this problem of designing code with hooks/callbacks.

If you are using [the greatest Runge-Kutta implementation ever written](https://docs.rs/fast_ode/0.1.3/fast_ode/) you get really nice error messages.

---

<div class="post-metadata">

**Author:** ![Volker\_Weissmann](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@Volker\_Weissmann](https://discourse.julialang.org/u/Volker_Weissmann)\
**Post date:** [April 25, 2022, 7:40pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/75 "2022-04-25T19:40:42Z")

</div>

> [@jakobnissen](#):
>
> Yes, but AFAIK, Documenter’s autogenerated documentation is not very thorough. It adds the docstring. It doesn’t for example, add links to functions automatically found with `methodswith` , or tell which position in the type hierarchy a type is, or which type parameters a type has.
> 
> Julia has pretty good human-written docs, but I think Rust shows the autogenerated docs could be better.

Absolutely

---

<div class="post-metadata">

**Author:** ![Volker\_Weissmann](https://avatars.discourse-cdn.com/v4/letter/v/c2a13f/32.png) [@Volker\_Weissmann](https://discourse.julialang.org/u/Volker_Weissmann)\
**Post date:** [April 25, 2022, 7:41pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/76 "2022-04-25T19:41:47Z")

</div>

> [@lmiq](#):
>
> I started by showing the students what I think is the best workflow, before anything else.

Maybe what you showed them should be [here](https://docs.julialang.org/en/v1/manual/getting-started/).

---

<div class="post-metadata">

**Author:** ![suavesito](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/suavesito/32/34386_2.png) [@suavesito](https://discourse.julialang.org/u/suavesito)\
**Post date:** [April 25, 2022, 7:45pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/77 "2022-04-25T19:45:40Z")

</div>

Well, interactive code editing/debugging in Julia has always been nice from my point of view.

`Debugger.jl` and some interactive utils like `@less` are really cool for debugging and exploring code. I had have no problem with them missing the right place to things I need.

You can see [this](https://www.youtube.com/watch?v=EkgCENBFrAY) video from @miguelraz about nice utilities available in the REPL about interactive utils.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [April 25, 2022, 7:45pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/78 "2022-04-25T19:45:49Z")

</div>

> [@Volker\_Weissmann](#):
>
> Maybe what you showed them should be [here](https://docs.julialang.org/en/v1/manual/getting-started/).

Yes, it should, but in Julia it really needs to be pretty much stressed the first time. The good workflow avoids a lot of the Julia development pains (most TTFP, high level use and debugging, etc).

In some sense it its a “problem” because the tools needed (VScode probably in most cases - other editors can be used, but to guide people better stick with one - , and Revise) are not tools of Julia itself. But I think that the language would benefit for having there a very opinionated guide on how to develop in Julia, before just putting people to play with the REPL.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [April 25, 2022, 7:46pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/79 "2022-04-25T19:46:34Z")

</div>

Actionable: [Higher level error message on broadcast `materialize!` failures · Issue #45086 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/45086)

---

<div class="post-metadata">

**Author:** ![isaacsas](https://avatars.discourse-cdn.com/v4/letter/i/f6c823/32.png) [@isaacsas](https://discourse.julialang.org/u/isaacsas)\
**Post date:** [April 25, 2022, 8:42pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/80 "2022-04-25T20:42:33Z")

</div>

Seems like there is an ambiguity here because of there being both in and out of place methods, and [SciMLBase.jl/utils.jl at 38c31b6fdea140e54697e25cb46bb3ad9eeb65c7 · SciML/SciMLBase.jl · GitHub](https://github.com/SciML/SciMLBase.jl/blob/38c31b6fdea140e54697e25cb46bb3ad9eeb65c7/src/utils.jl#L6-L42) auto-selects the version with the most arguments when there are multiple methods. Couldn’t `u0` also be looked at to determine which version to select when there are multiple methods defined?

---

<div class="post-metadata">

**Author:** ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)\
**Post date:** [April 25, 2022, 8:54pm UTC](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976/81 "2022-04-25T20:54:15Z")

</div>

> [@jakobnissen](#):
>
> Yes, but AFAIK, Documenter’s autogenerated documentation is not very thorough. It adds the docstring. It doesn’t for example, add links to functions automatically found with `methodswith` , or tell which position in the type hierarchy a type is, or which type parameters a type has.
> 
> Julia has pretty good human-written docs, but I think Rust shows the autogenerated docs could be better.

This is _the_ gripe I have with the status quo around documentation generation. You may be interested in [GitHub - lorenzoh/Pollen.jl: Format-independent document generation tool built for interactive work](https://github.com/lorenzoh/Pollen.jl). It’s not at rustdoc levels of automation, but IMO it’s taking an important step towards that and it is already [deployed in FluxML](https://fluxml.ai/FastAI.jl/dev/) (with hopefully more repos to follow).

[Previous page](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976.md?page=3)

[Next page](https://discourse.julialang.org/t/blog-post-about-my-experiences-with-julia/79976.md?page=5)
