Julia is a very different and interesting language

I actually found the opposite, but maybe that’s because of my background with Scheme & CLU (almost 4 decades ago), and C/C++ since school.

There’s been some tension in the design, IMO, because some of the things were taken from C, the operators, string literals (with the addition of $ for interpolation), and printf style formatting, while others were taken more from Python or Matlab.

The stuff based on C sometimes feels both familiar and antiquated to me (for example, Swift has a cleaner string literal syntax, that doesn’t use up another common character, $, for interpolation, and doesn’t have the strange \uXXXX vs. \UXXXXXXXX Unicode escapes).
One of the great things about Julia is that you don’t have to live with that if you don’t like it, it’s not hard to add new string literal formats (which I did first in my StringUtils.jl package, and then updated it to StringLiterals.jl`)

In your PR, there’s still a place that was missed, in the precendence table
I also I think it would be better to simply do what it does with %, and say "equivalent to div(x,y)".

Nice that you’ve got your first PR!

I agree with him.
Julia started very simple.
Yet the current syntax seems to be overly smart.
If you come from MATLAB it really looks complicated.

5 Likes

I come from MATLAB and find it straightforward. I find Julia is as simple as MATLAB if I only use it to do things that are easy in MATLAB. If I want to do more, faster, and I do, Julia is the way to go …

2 Likes

What part of the syntax do you think has become harder to understand?
(I think it’s good to learn contrary views, can learn something)

For instance I encountered this:

I think it’s me but this frighten me :-).
I understand simple types (Int, Float, Double) and structures (Array, Struct, etc…).
Then I see this…

1 Like

Well, A*x*B seems like very simple and straightforward syntax, and the same as in Matlab, BTW.

Or are you objecting to advanced use of types? In that case, you can stick with the simple types. Also, you can make weird and complex classes and hierarchies in Matlab too.

Hi sirtom67,

I read in your github notebook that you wonder how to get the ÷ operator in the vi text editor.
You can get it in vi (and also in vim and neovim) through julia-vim typing “\div” followed by “tab”

2 Likes

The whole type system is something which I enjoy to learn, but I have some fears, that it can be quite complex but, on the other hand, it seems to be vital to create good (in many senses) julia code.

So, this is my concern, while I am digging deeper into julia. Still I am very delighted about the language. The first time, after many languages I used and tried, I am not thinking, ok, just another flavor of the same (don’t pick at this last statement = all the same, its just for brevity).

I had almost been about to ask before whether it was the new where syntax that you felt it had gotten more complex.

Once you understand it, it’s actually a lot more consistent and easier to understand than the old:
function foo{type_variable_names}(....parameters with type_variables...)...
IMO, and definitely a lot more powerful.

As @DNF said, it really only comes up when you are doing advanced things with types, and the nice thing with Julia is that most times, you can just leave off the types entirely, and let Julia infer them.
All the where stuff is only needed if you are writing functions where you need to specialize methods based on the type, and that, only for advanced cases.
Usually something like:

function myfunc(val::Number)
    # Scalar numeric operation 
end
function myfunc(val::AbstractVector)
   # Vector operation
end

is about all you’d need until you get to fairly advanced cases.

1 Like

Well, it is only reasonable that most of my fear is based on old habits compared to something new.

Is there a simple guide about this Type System?
I’d love to learn it and utilize it properly.

In general there is a tension between those who create the language and have deep understanding on how things work to the users of the drivers.
I read once that car engineering is harder than spacecraft engineering mainly because of the use cases and the users.
In spacecraft the use case is well defined and the users are highly competent and well trained.
While in cars you can never know what the user will try doing with it and also the dynamic range of the user capabilities is amazing and still the car must perform reasonably in any case.
Hence its engineering is challenging yet must be kept simple.

I can see this trend in many languages.
I don’t have enough knowledge in Julia to say its balance is too shifted towards those designed it or are amazingly capable, but it is just something to keep in mind.

https://docs.julialang.org/en/stable/manual/types/ is a good start.

1 Like

This explanation is holding up pretty well after 5 years.

Regarding your notes: while surface syntax has its importance, it is arguably not the most interesting or novel thing about Julia. If I had to pick one key feature that defines the language, it would be efficient multiple dispatch on parametric types. This is not to say that everything else is unimportant, but this is the most novel part.

Coming from an engineer, “steep learning curve” may be used in the sense of “accumulating knowledge at a rapid pace”.

3 Likes

Although I’m an engineer myself, I’d never heard it used with that (opposite) meaning. Thanks for the info! (I do like to learn something new every day!)

Unlike many of the curves shown in the article you pointed to, that are steep and then flatten out, one thing I love about Julia is that, while I felt it had a very fast learning curve at the beginning (I was making PRs right and left [that got accepted!], just a few weeks after learning the language, and I feel that’s true for a lot of people, it’s a very accessible language), I’m still learning interesting and cool things (as are all of us, even Jeff, I think!) about the possibilities of Julia, 3 years, 1 month, and 2 weeks later! :sunglasses: (Julia’s so bright, I need to wear shades!)

2 Likes

Here’s the thing: it’s waaaaaay easier to think about all that stuff than classes and inheritance in OOP. It’s just much more intuitive.

Julia has many wonderful attributes as I’m sure you are now discovering. For me the most important aspect of Julia is multiple dispatch as a core paradigm of the language. This is the thing that makes me never want to use any other language ever again. I now view object-oriented programming as a broken concept, and this is coming from someone who’s primary language was C++ for about 8 years and, in that time, couldn’t conceive of writing any complex code without OOP.

4 Likes

Totally agreed. Ignore types while writing in the REPL. But any large project needs an organizing principle (try writing a whole project in C. I dare you to call it nice or concise. C+MPI days…). In the past that was OOP, but OOP is verbose and usually heavily slows down code. 8 years or so of OOP, 2 years of Julia’s multiple dispatch yet the latter is so much easier to use. It took about 3-6 months to really start making good use of it, but here’s a summary of some things to know:

Julia software designs are different than OOP designs, which is totally fine because it’s more concise, performant, and legible anyways. Sometimes it’s better to throw aside old paradigms when you have a better answer.

7 Likes

@davide - beautiful, I will try it out, thank you!

Julia peeps: A lot of good discussion and ideas - THANK YOU!

I haven’t grokked “multiple dispatch” yet and that is now high on my list.

What makes it seem bigger and scarier are two things: unicode and the syntax.

Unicode variable and function and operator names just totally blow my mind. The fact that you can type “\pi” and use greek letters. Wow.

Here’s an example of syntax that seems rich and yet I have a lot of questions about what all those “<:” and “{}” mean.

struct ZeroPoleGain{Z<:Number,P<:Number,K<:Number} <: FilterCoefficients
    z::Vector{Z}
    p::Vector{P}
    k::K
end

The syntax for the types I don’t get yet. Also there are numerous operators that seem very specialized like === and >>> (where is <<<??)

I think once I learn what is what, yeah it might be awesome but I am not there yet.

It has the feel of how MATLAB was when I was learning it - pretty much anything you could think of, yeah MATLAB could do it somehow.

The other thing is I am learning Julia in my free time which is pretty limited, so that also makes the learning process seem slower to me. It’s very bursty.

One final thought - yeah using the REPL seems easy. But then when looking at adding stuff to a library such as DSP.jl, there is a lot more to it.

Regards,
Tom

1 Like

For example Z<:Number just means that Z has to be a number. What does that mean? Well, look just bellow it and you’ll see z::Vector{Z}. This means that z is a Vector, and that the elements of said vector are numbers. Numbers are just what you are probably imagining. So, z can be a vector of floats, integers, or complex numbers, but it cannot be a vector of strings or anything else that is not a number. Same goes for p and P. You can probably now infer that k must itself be a number.

=== is actually quite common across many programming languages. It basically is just testing whether two references refer to exactly the same object. >>> is also common, it’s just a slightly special type of bitshift operator.

By the way, also be aware that you can access documentation by typing ? into the REPL. For instance, type in ?>>> for a full description of that operator, all in the REPL.

2 Likes

Reading through the whole manual would be a good place to start. Also, the built-in docstrings.