It's funny how languages can offer multiple forms of syntax, but formatters standardise to a single form.
E.g. single vs double quotes in JS, optional semicolons in JS, different ways of grouping imports in Rust.
Should new languages be more syntactically opinionated?
Wilfred Hughes
@wilfredh everything should be more opinionated IMO
Badly-read literary snob@RosaCtrl@social.vivaldi.net
@wilfredh new languages should accept an IR and make syntax a user level decision instead of having opinions that break people's code
d@nny disc@ mc²@hipsterelectron@circumstances.run
@hipsterelectron
lisp everywhere. i think zag smalltalk is somewhere close to that, given their method stores are ASTs allegedly
@wilfredh
algernon.st@zardoz03@mastodon.online
Yes, they should.
Like, the whole single/double quote thing: I get *why* JS and Python have both options, it's so you don't have to escape quotation marks, just use the other one for the string. But it opens up both being used in code, which then the formatters have to standardize for appearances
@zardoz03 @wilfredh scala 3 has an NIHed format for this they call TASTY
d@nny disc@ mc²@hipsterelectron@circumstances.run
@zardoz03 @wilfredh i think it should be more generic than AST
d@nny disc@ mc²@hipsterelectron@circumstances.run
But with a language like Gleam where your formatter is built into the binary, only double-quotes, organized imports, and they enforce naming semantics (functions *must* be lower snake case, types *must* be capitalized) means there's a nice uniform style and no confusion about anything from the code
@hipsterelectron
i think the sanest option is just a bytecode set/IR atp (with decent chosen semantics). since people will try to compile different semantics into the AST that will just produce weird code on introspection.
@wilfredh
algernon.st@zardoz03@mastodon.online
It's important to remember, we should *read* code as much as we *write* it (or more, as people now have AI writing their code).
@zardoz03 @wilfredh lisp is ok here. i want macros to be more hygienic which to me means recognizing language constructions and lisp doesn't really have a graph matching/transformation API and it seems difficult to retrofit. that's a basic tradeoff that needs to be managed with this approach
d@nny disc@ mc²@hipsterelectron@circumstances.run
@wilfredh I don't like code formatters I find them more annoying than helpful. I think that a language should be consistent with its syntax to reduce ambiguity. Formatting should be a user responsibility.
FoxFunction@FoxFunction@tech.lgbt
@wilfredh Chiming in out of the blue here... My answer as a grumpy old programmer is "No, and neither should those formatters".
Those multiple forms of syntax or variable use of whitespace are useful to as a tool to express minor variances in meaning to the reader of the code, or improve "scannability" of the code. This is why a tool like python's `black` and other highly opinioniated formatters are irritating to me, even though I largely agree with about 85-90% of its behaviour. Even the rest of it is fine in many cases
I don't *think* I have a particularly atypical lexical coding style, but I do, for example, like being able to do things like
- have array data aligned with horizonital whitespace so so that columns are visually obvious,
- align conditional subexpressions across a chain if if/elif blocks, again to make it clearer how the various blocks of the chain are related.
Also, just to be clear, these are highly context dependent for me: most of the time, I do those things in the ordinary way, but when there's some useful structure that I want to make more visible, these sorts of tricks seem valuable to me.
Dale Hagglund@DaleHagglund@hachyderm.io
@hipsterelectron @zardoz03 @wilfredh scheme has hygienic macros
sarah tonin :wlfBlep:@SRAZKVT@tech.lgbt
@SRAZKVT @zardoz03 @wilfredh yeah scheme is cool
d@nny disc@ mc²@hipsterelectron@circumstances.run
@hipsterelectron This is very true
FoxFunction@FoxFunction@tech.lgbt
@hipsterelectron @zardoz03 @wilfredh i wish the type system was more in my face though. i like how srfi253 does things, simple predicates, but not every impl supports it (natively, but at least i can add it if needed)
sarah tonin :wlfBlep:@SRAZKVT@tech.lgbt
@wilfredh if opinionated means more orthogonal features, then yes.
https://fishshell.com/docs/current/design.htmlms@ms@tux.social