Blog post about my experiences with Julia

Right? I absolutely get where static language advocates are coming from, but there are a lot of very experienced programmers who prefer using a dynamic language for day-to-day work and I don’t think we’re just gluttons for punishment. Once you become really good at using a production-grade dynamic language like Lisp or Julia, it’s really hard to beat for development and debugging. Obviously there are people who feel differently, which is totally fine, but the assertion that no one prefers debugging in a dynamic language, is just false and completely ignores at least half of the professional programming world.

20 Likes

I mean… I would argue that even the industry see a benefit of using something that mimics capabilities of Julia, like Live++.

You can see the companies that use it, and I’m sure there are a lot more not listed. The capabilities and commodities of REPL + Revise + Debugger developing and debugging are just not comparable in my experience.

(P.D. I will give a point that the languages with interfaces/traits (C++20/Rust), the errors that you can get from having or mimicking them are really nice.)

3 Likes

You are missing an s : methodswith, not methodwith.

Rants are not a bad thing.

Same. I don’t want to defend C++ template compiler error messages.

4 Likes

Oh man, @StefanKarpinski agreed with me that debugging dynamic languages is actually easier :smile:. Spotting logical errors, perhaps the hardest of bugs, is much easier in dynamic langs. I too find that debugger can only get you so far. Without interactive user interference (REPL alike), logical bugs are very hard to find.

I agree that catching type-related compile time bugs is a lot faster to spot with static languages, but those bugs are the most “noisy” and least difficult to spot anyways. You might get get nulls or some values that make no sense, all in all things that are simple to trace bugs. I think catching those bugs would be possible in julia ahead of time with sufficiently developed lsp server

4 Likes

Unlike you, I am not a programmer, not even a scientist-programmer, but rather a daft mechanical engineer who writes his own software utilities for different everyday industry purposes. So far I used Objective-C, python, and MATLAB, and I really wanted (and still do want) to learn Julia. My experience with error reporting and especially documentation is nearly identical to yours. I have never tried learning a language that seemed so situational. If I’m stuck in python and MATLAB I will eyeball and try a syntax that kinda makes sense to me, and more often than not it will work - very often much to my surprise. On the contrary, in Julia I will more often than not receive cryptic error messages for attempting to write what I consider a straightforward syntax after I carefully read the documentation, tutorials, etc.

Julia seems more like a language by the mathematicians/statisticians and computer scientists, for the mathematicians/statisticians and computer scientists, focusing on performance parameters under a narrow set of conditions and workflows you beautifully address in your post. Which is perfectly fine, I totally respect that. But as a layman user, it is my deepest impression that if the developers should they ever try to expand the usage of Julia language to a wider population the whole team should stop everything they are doing for like a year or so, and just work on the documentation and errors handling/reporting. Really nothing else. I know this sounds silly but that’s just how it looks like to me.

11 Likes

Having static guarantees and dynamic inspection both help debugging. But I’m not sure what people mean by putting these as opposites.

Haskell, Python, and some Lisps have a REPL and a static type checker, which are helpful for debugging.

I’m a bit curious. Can you think of an example?

I’m somewhat mystified by posts like this. I just don’t get what the problem is, or how Julia is different from Matlab/Python. It would be really interesting to see some illustration.

6 Likes

It’s not really about the dynamic types, it’s about the REPL. It is really, really useful and fast to be able to simply run any little function your code is using to see what they’re doing. You don’t have to write a test for every single part of the program, you don’t have to wait and rebuild the entire program every time you make a slight change, like adding a quick @info to print whatever information. I’m a julia newbie and I’m finding this feature really useful for debugging. Once you get the mindset of how it works, it’s quite useful. For example, I have a script that declares and prepares functions to run a simulation, but that doesn’t run anything. I simply include it into the REPL, and then launch a run() function I’ve declared after having checked that the parameters are just right. I don’t have the fear of launching a simulation and discover I’ve missed a parameter that needed to be changed. I’m not saying that you can’t live without a REPL, I’m saying that debugging it’s not only about the type system (which is awesome in Julia, btw).

3 Likes

If you enable hot reloading of that file with Revise too, then you have incredibly fast iteration on your code—just edit in IDE, save, switch to REPL and rerun whatever part you’re working on. For me this is the most productive way of doing both development and debugging in any language.

5 Likes

How do you edit structs in this workflow?

That’s the only thing you need to restart for.

2 Likes

It is as Stefan said, but there are older threads with workarounds, like using NamedTuple, or using a Wrapper{T} type that you can change the fields freely but you will want to clean up when you decided on the final design.

1 Like

That is a fair point (in general). I’m providing some examples below. As I already explained my background and approach, all I’m asking in return is to please not engage in further discussions on how the particular problem can be solved (already been answered in the linked threads). I’m merely trying to illustrate why I felt the way I felt learning Julia and why I recognized much of the experience OP described as my own too. If you find the examples I provide here useful to understand the thinking of a newbie that is really great. But if not, let me go out on a limb here and say that I do understand that there is a particular solution and/or explanation for each particular problem, and I really do not with to go there right now. I’m describing a bigger picture here, not a particular issue. Thanks.

That being said, this thread is a good example of how a newbie can get stuck with Julia, even with a simplest problem and after reading the docs and trying to implement what was read. What’s not explained in that thread is how I went back and forth through the docs, and even tried to throw some obvious things against the wall as I would do in other languages to see if anything would stick. Ultimately, with Julia you just have to ask here. Another thread is a good illustration of how disconnected and cryptic the docs appear to be to a newbie (again - appear to a newbie, not as an an actual fact). Chances of making the progress without asking the question here is virtually zero. People are polite, on point, and very helpful, but man you just have to ask, no way out on your own.

We both mentioned python and MATLAB. Forgive me for not providing actual examples but describing a couple of things I did the other day. In python I dot-chained half a dozen functions in a truly disgusting fashion while semi-arbitrarily placing parenthesis and square brackets with arguments that were incremented in a loop. The key point here, and the main reason I do not provide the actual code, is that I did it highly intuitively, half-based on the docs I read, and half-based on my own non-programmer intuition. And guess what - the hodge-podge code worked. In MATLAB I similarly put together a horrible Frankenstein’s monster of a function that allowed me to dynamically change the variable name in a loop based on a string array, which in return allowed me to print 1000s of plots automatically. The key point again is that I did this by first reading a couple of help pages and a MathWorks thread strongly advising against dynamically changing the variable names. I took what I read and tried to put together something of my own and guess what - it worked. My experience in Julia is exactly the opposite, for whichever reason, even after reading the docs carefully I am unable to put together even the simplest and the most straightforward functions. That is just my own opinion, not a absolutist statement.

I’ll just stop here because this is one of those things where by now it is quite clear what I’m trying to describe or no amount of additional examples will be sufficient. I hope everyone can acknowledge that I am not a programmer, but merely a person who tries to utilize a tool to automate something.

2 Likes

That’s my biggest gripe with julia. My solution is to try type stuff I’m not sure about in the REPL using dummy names for structs. Once I’m good, I write it in the code base with the real name.

I’ve been using Julia for some years now and my biggest panic is when I have to interpret an error stack trace (for example those that arise from failing tests). The true culprit is never the first, nor the last line but always some in the middle that may also be the first or the last.

In Matlab, relax, it’s always the first.

9 Likes

My only explanations for this (anecdotal evidence;) are

a) either you were extremely lucky or
b) your tools try every possible implicit type coercion to make your code work (which Julia doesn’t always do AFAIU and which could also lead to interesting side effects)

Would be interested hearing other opinions.

1 Like

Yup, I think this is basically it, the “typeness” of the language. I think in Matlab, R and Python, they try that everything works if even remotely you would imagine that it should.

This is really nice because you normally just throw out some half-baked code, and it will probably work. Julia having a stricter type system and a lot less type coercion put you in a harder scenario, you need to know what you have in hands (types) and use it accordingly.

I still like a lot more Julia, but can see how other languages are more beginner-friendly because they don’t expose new users to a type system or a lot of other things.

(Also some docs needs improving, but this is going to get better with time.)

2 Likes

I agree error stack traces can be pretty intimidating. I’ve seen error messages while using Zygote + DiffEqFlux where the name of a single type in the error was over 2000 lines long :sweat_smile:

As discussed in another post though, it sounds like there are tools in the works to make errors more interpretable. And as mentioned here it sounds like pull requests are welcome for simplifying error messages.

1 Like

Is part of the problem that Julia is stricter but without static typing? So you’re stuck in a potentially more frustrating middle ground?

@MK-1138 Are your frustrations with the language semantics, docs, or lack of dot chaining function discovery? (the latter isn’t in matlab) Or the interactions between all 3?

Edit: I think Dot chaining means it’s easy to find a function which works for your datatype, but I’m not sure why matlab would be easier. In julia hopefully something like Tim’s PR will help (can’t find it ATM)

2 Likes