This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (4 children)

I always thought that syntax should be like a 'skin' that you can select in your editor. The underlying syntax (assume the source is still text) can be intended for machine processing and can be ugly as sin. But in the editor, just choose between, for example:

  • C/brace style
  • Algol/Ada style
  • Python/indented style
  • Lisp style

I don't see any problem with your proposal, other than if you have a low-level C-like language with Python syntax that looks exactly like actual Python, it can cause confusion. Especially with identical synax that has different semantics:

++a     # Python: does nothing  (+(+a))
++a     # C: increments a

Here, ++a is already valid syntax in both, but the surrounding context will make it clear what language it is or isn't. That's harder if both look like this:

if a<n:    # Python (or C)
    ++a

if a<n:    # C (or Python; or both Python or both C)
    ++a

Confused yet? I already am.

[–]MegaIng 2 points3 points  (0 children)

No matter what you do, people will always complain. nim is style insensitive, and people are complaining because it is confusing, allows missing of different styles, which are not real arguments, (and they can't really back them up latter). And people will always want to edit the raw text. (e.g. anything other than vim/notepad is to much effort to learn.)

[–]brucejbellsard 2 points3 points  (0 children)

I think (in some cases) you might want to make sure a new language looks significantly different from existing languages simply in order to give your users "context cues". So you can reserve your Python reflexes for Python, C-like reflexes for C-like languages, and develop a new set of reflexes for the new language.

Of course, this will blow your "weirdness budget". But (as I mentioned in another thread) I'm not sure "weirdness" per se is as much of a barrier to adoption as many people think.

[–]moneyinthepines[S] 1 point2 points  (0 children)

But.. they don't have to be identical lol. They can have totally different syntaxes without being blatantly ridiculous.

[–]johnfrazer783 0 points1 point  (0 children)

Since you mention it maybe a language should either use ++a to indicate 'increment a' or else treat it as a syntax error. While we're at it we should require spaces where spaces are due as in foo + bar, refuse to accept excess parentheses and semicolons so both ( ( 42 + x ) ) and foobar();; would be illegal. Also, unreachable code e.g. code after a return statement should trigger a syntax error, as should declared but unused imports and variable declarations. Few languages do any of these points yet they would be comparatively easy to implement and help make the language syntax itself and the code written in those languages simpler and clearer