They have got one thing right like Mojo in that it looks and feels like Python.
It is about time we had something like an ISO standard on syntax.
(Edit: this post was moved from the longer thread, it doesnât make as much sense in this context, so removing it.)
Ha ha, thatâs a good one.
But, we do not have even one standard?
What would that mean? Isnât syntax an intrinsic part of a language?
Let me know when Python becomes a âstandardâ.
Meanwhile, Iâm pretty sure the C-style curly-braced syntax languages are way ahead in terms of standardization by a formal body like ISO.
Like Mojo and now Bend.
If you were to come up with a new language, then function definition looks like
def func(...):
...
return x
loop definitions look like
for i in range(n):
...
and so on in your language,
Or whatever the standard says. Does not have to be Python.
In other words, the same code (subject to caveats) should compile in all languages following the standard.
I write programs in C, Rust, Go, Julia and Python on regular basis. I am annoyed having to use function, fn, func, def to do basically the same thing.
How far should the standardization extend? Surely syntax is different for a reason? Otherwise, there would be just one programming language with different compilers.
They have both fn
and def
.
They have a good reason for this.
Anyway, syntax is easy compared to semantics when moving from one language to another.
Sure, Mojo is a superset.
Syntax may be easy, but language designers have taken this game too far, IMO with every new language coming up with highly personalised syntax. It is a bit silly at this point.
Surely syntax is different for a reason?
Not all of it I suppose. Julia could have used def foo()
as its function syntax without any impact?
I prefer function foo()
which I learned in Pascal 20 years ago.
Most of the syntax in Julia can be traced back to some other language, just not necessarily Python. Itâs not like Julia is trying to reinvent the wheel.
Of all examples, I could not even begin to imagine how def
is a better standard name than function
. For a function. And itâs not something new in Julia at all.
To be clear: I prefer function
over def
. That said, I can understand the counterpoint in two parts:
- Instead of a label read as âthis is a function
foo
that takes 2 arguments and has this logicâŠâ, it can be read as a verb âdefinefoo
to be a function which doesâŠâ. - For common keywords, itâs better to have an abbreviation. If you disagree with point one, then Julia should use
fn
.
I like things labeled (python uses the keyword class
to label a class definition). And I have an IDE with tab completion⊠So I donât really see the ergonomic benefit.
But that hardly generalized. What about other definitions, such as class
or struct
?
Thatâs hardly generally agreed upon.
Sure, although there are other other languages that also use function
as a keyword to declare a function.
By shear popularity, JavaScript is the most popular language by some measures, which also uses function
as a keyword.
That said, debating superficial surface syntax does seem a little silly. Source-to-source translation is not a terribly difficult task. With JuliaSyntax.jl being the main parser now, making an alternative parser for Julia is easier than it has ever been.
To be clear, I do not care whether it is Pythonâs or Juliaâs or Rustâs.
It would be nice if programs are like math, where \int is integral everywhere and not like in a case where one group decides to denote their integral as \Psi and contends that it is a trivial substitution, so should not matter. At the end of the day it is a cognitive overload.
But programs are like actual languages.
And even used in a lot of different contexts, with different backgrounds and things in mind.
And also in math â it depends. For example the Fourier transform ( Fourier transform - Wikipedia ) has different forms depending on your preferred interpretation.
All of them have their origin (maybe in different scientific fields, which is nearly the same as different languages).
So I would say math has the same thing we discuss here. Things are called differently depending on context.
Integration didnât start with that symbol universally, and its notation wasnât standardized for a long time and involved multiple steps. For example, the current definite integral notation appeared 145 years after \intâ«\int did. We canât wait a few centuries so weâll have to make do with the variation like everyone else in history.
Iâm personally partial to fn
. While more removed from natural language, the meaning of a handful of keywords becomes intuitive quickly, and a shorter âmainâ function end
syntax would be more viable for anonymous functions. Hell, ___ end
seems a tad long, why not end on spaced periods .
, or even curly braces if it could be distinguished from parameter syntax? Too late for this to happen in Julia anyway, and saving a few keystrokes is not so important.
Oh well, it does not seem like a good idea then. Good to see healthy opposition to standardization!
Bringing this back now that the context is here
People donât tend to agree or be agreeable, thatâs why standardization can take centuries on the occasions it even happens.