Standardizing syntax?

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.

1 Like

(Edit: this post was moved from the longer thread, it doesn’t make as much sense in this context, so removing it.)

6 Likes

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?

2 Likes

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.

8 Likes

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.

5 Likes

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.

8 Likes

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.

1 Like

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.

4 Likes

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.

9 Likes

To be clear: I prefer function over def. That said, I can understand the counterpoint in two parts:

  1. 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 “define foo to be a function which does
”.
  2. 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.

1 Like

But that hardly generalized. What about other definitions, such as class or struct?

That’s hardly generally agreed upon.

3 Likes

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.

6 Likes

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.

5 Likes

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.

3 Likes

Oh well, it does not seem like a good idea then. Good to see healthy opposition to standardization!

1 Like

Bringing this back now that the context is here
standards
People don’t tend to agree or be agreeable, that’s why standardization can take centuries on the occasions it even happens.

14 Likes