Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Julia is not indentation-based like Python?

I really like the indentation-based syntax of Python; it makes code much more terse.

Is there a reason why Julia was not chosen to be indentation-based as well?

Please note that my intention is solely to learn about the motives that Julia developers had behind this decision; whether we agree or not with those motives is another discussion. I do not intend to start a never-ending discussion.

like image 331
becko Avatar asked Feb 12 '16 12:02

becko


People also ask

Does Julia use indentation?

In Julia, the function starts with the function keyword and ends with the end. Note: Indentation is a must in Julia. As you can see in the above code in line number 2 and 3. Please note that there are not any fixed number of indentation spaces, but generally, four spaces are preferred.

How does Julia differ from Python?

Julia is a compiled language, which means programs can be directly executed on a computer processor, whereas Python is an interpreted language. It has math-friendly syntax. Unlike Python, Julia features math-friendly syntax as it was designed with the scientific community in mind using R, Matlab, Octave, and so on.

Is Julia syntax similar to Python?

Julia is a general-purpose coding language, and if you're familiar with Python, you will notice that the syntax in Julia looks remarkably similar to Python. All three languages are also open-source languages, which mean they are free to use and distribute, even for commercial purposes.

Is Julia space sensitive?

Many things in Julia are space-sensitive.


1 Answers

See this post on julia-users: https://groups.google.com/d/topic/julia-users/lOmwPvOKc-o/discussion

From Stefan Karpinski

It's a matter of taste – and the fact that we wanted Julia to feel familiar in particular to Matlab users (and to a lesser extent Ruby users). I personally don't like significant indentation. It gets really awkward and fiddly when you're trying to cut and paste into a terminal or into an editor. I've seen a significant number of live Python demos flounder as the presenter struggled with indentation issues. It feels to me like Python programs trail off into space with never-ending scopes. Jeff and Viral both happen to feel similarly, so Julia ended up looking more like Matlab than like Python.

like image 118
Simon Byrne Avatar answered Oct 17 '22 10:10

Simon Byrne