Jeez, next you'll be telling us you don't like perlI hate this sort of thing. There is enough complexity in the world to last us ten lifetimes, don't give me more than one syntax for the same thing.
Jeez, next you'll be telling us you don't like perlI hate this sort of thing. There is enough complexity in the world to last us ten lifetimes, don't give me more than one syntax for the same thing.
Given that the semantics ofSpeaking of which:for
,while
,do... while
. Anyone else in favour of eliminating two of these? Any two, though personally I'd prefer to get rid of thewhile
anddo... while
.
while
and do while
are fundamentally different (0 or more times vs at least once), no, that doesn't strike me as a good idea. Much the same can be said for for
.for
statement. I think for
and while
are by far the most used and can turned into one another pretty easily. However, do... while
is usually handled a little differently. It will execute the code block and then do the check so the code block is always executed at least once, even if the condition is false from the start so a do... while
executes the code block 1+ times. That's not guaranteed with for
or while
, which check the condition before executing the code block which means the code block will be executed 0+ times. You can turn the do... while
into the others but it requires messing with stuff.Is that a fundamental difference?0 or more times vs at least once
while (condition)
we could use for (; condition; )
and instead of a do... while (condition)
we could use for (i = whatever_it_would_otherwise_have_been - 1; condition; i++)
.do... while
loop that wouldn't have been clearer and easier to understand had it been a while
instead. Maybe that's just me.perl is a write-only languageJeez, next you'll be telling us you don't like perl
Is that a fundamental difference?
I'm not saying this is the best syntax possible, but instead of awhile (condition)
we could usefor (; condition; )
and instead of ado... while (condition)
we could usefor (i = whatever_it_would_otherwise_have_been - 1; condition; i++)
.
Also, I have almost never seen ado... while
loop that wouldn't have been clearer and easier to understand had it been awhile
instead. Maybe that's just me.
do... while
until you get an EOF from the file for some reason? It can certainly still be done but what you may have to do may be pretty ugly... especially if the condition is a function call that modifies state somewhere. I guess you could do something like:bool doThisOnce = true;
while (doThisOnce || callThisFunc())
{
doThisOnce = false;
....
}
....
in there may be a little trickier.for
loop and a while
loop is theoretically different. There is a significant difference in meaning between for and while. One refers to a mathematical idea of iterating some collection or a list comprehension: "for each number between 1 and 10" while the other suggests waiting for some kind of external condition: "while it is raining". The idea that you can write the latter as "for it is raining" only obscures the difference between what is going on.Um, but that's pretty much the heart of any discussion of what a "perfect" language would be. Otherwise, everything just boils down to a Turing Machine as the one true form of computation!I hate this sort of thing. There is enough complexity in the world to last us ten lifetimes, don't give me more than one syntax for the same thing.
Well, the abstract construct for them all is conditional execution of a block of code, so you might as well find a way to throw outSpeaking of which:for
,while
,do... while
. Anyone else in favour of eliminating two of these? Any two, though personally I'd prefer to get rid of thewhile
anddo... while
.
if
as a special case of that as well. And, of course, that's all the ?:
ternary operator is, too, so out it goes. And death to all case
statements! . . . Are we really making programming easier when we force it to be less expressive?do-while
loops, and hate when I find myself using a post-if
when a language's syntax doesn't offer anything cleaner for simple conditions.while(var line = f.Readline() != null)
{
// do something with line
}
while (TRUE)
{
line = f.Readline();
if (line == NULL)
break;
// do something
}
do ... while
a long time ago, but I don't remember why. I'd consider it code smell now.for (;;)
and while
has dramatically decreased when iterator-consuming pattern (like foreach
keyword and Linq methods) made it to the language I used back then.If you need to do something an unknown number of times but at least once, anything other thanI know I've useddo ... while
a long time ago, but I don't remember why. I'd consider it code smell now.
do ... while
gets more obscure.if ... break
. That's the best way to do some stuff at least once but other stuff not. But if it's everything at least once then do ... while
is the most appropiate.It's hard to take any arguments against punctuation for any language seriously.
While markup for data formats is a whole different ball game, it's also hard to take seriously arguments against blocks being delimited by{}
and in favor of them being delimited by<thisnonsense:item></thisnonsense:item>
.
}
}
}
}
</street>
</address>
</customer>
</person>
Again I ask, why?My litmus test is a plain text viewer w/o syntax highlighting. Is code easy to read in it?
Again I ask, why?
As I said: I prefer the more outspoken format, as this is easier to spot.
} # street
} # address
} # customer
} # person
So what about this:
Code:} # street } # address } # customer } # person
} # street
} # customer
} # address
} # person
#
is a comment, there's no way to see that at least the comments are wrong, not that it would cause a compile-time or runtime error. And because comments are optional, no one would put them in The XML version can be caught very easily by the tools before you actually try to execute a program using it. At runtime, you will also get an error.If I'm doing serious code in there I type it into (say) LINQPad, then copy paste it in. Also means it compiles most of the time.Because sometimes, that's all you got.
Look no further then e.g. a [ code ] block in a forum like this.
I'm surely not gonna code in something like it. But reading and understanding source code outside of the IDE of my choice is something I do on a daily basis.
I am arguing that making it required to be completely easy to use in all scenarios with an editor as dumb as notepad means other aspects most people spend more time in (and more time doing complex things) may suffer.
I wish @Metasyntactic was still here as he could cover this so much better than I could.Example?
Ease of parsing, generally. You must know that, or you would not be punctuating your sentences here.And the reason for that is exactly what?
Nope, because:Code:</street> </address> </customer> </person>
Seems obvious in this case?
In a text editor, the text is just text. You have to bring in a validating XML parser to know that any of the verbosely formatted text is correctly representing the intended data structure. So, yes, the unadornedKeep in mind: we're talking about language design, not IDE design/features, which helps you with the brackets. My litmus test is a plain text viewer w/o syntax highlighting. Is code easy to read in it?
{}
isn't going to win any awards for clarity, but it's a mistake to think structural commenting is much of a win.Ugh. Give meLook no further then e.g. a [ code ] block in a forum like this.
Markdown
conventions any day of the week when it comes to readability of the text.This all assumes the optimal situation that you and I sit at our well set up developer machine. Maybe my background in help desk and as a sysadmin is showing, but there were many times I had to look (or even fix) at configurations or scripts on a client's/user's machine that had nothing but Notepad (or Editor back in the MS-DOS days).The bit I want to be able to read and understand outside an IDE is in diffs in github's UI and beyondcompare's (or the IDE of my choice). IME the braces and additional syntax often help there not hinder. If you have an immense monolithic xml/json/yaml file in source code then that's basically an antipattern and you should fix it. xml is notoriously unpleasant in git merges too so avoiding that is also good.
That's deeply wrong.This all assumes the optimal situation that you and I sit at our well set up developer machine. Maybe my background in help desk and as a sysadmin is showing, but there were many times I had to look (or even fix) at configurations or scripts on a client's/user's machine that had nothing but Notepad (or Editor back in the MS-DOS days).
Ease of parsing for whom? Men or machine?Ease of parsing, generally. You must know that, or you would not be punctuating your sentences here.
Well, I have no choice what format a 3rd party vendor has it's stuff in. So I have to work with what I find.That's deeply wrong.
If you have to edit something locally and it's JSON then make your parser JSON5, but better is to use TOML or something else actually designed for humans.
Preferably both.Ease of parsing for whom? Men or machine?
Hence using JSON5 compatible parsers...For the latter: the newline character(s) is as good as a separator than any other for a machine. As for me: I don't need it. The opposite is true. As someone already explained above: it's easy to miss to add or remove a comma when editing JSON files.
This is a facile, you know it and are better than it.I mean, if the "kiddie language" BASIC since forever did just fine without an explicit statement separator other then a new line, why are all those "serious adult languages" not capable of it?
I am likely to start seriously coding in a language without semi colon separators full time shortly. IT will be interesting to see how that goes after f#. I might agree with you a lot more on this specific case, but even then that design decision will have been painstakingly factored into lots of other choices so it works as a whole, it's not a one size fits all.And before someone jumps in ... yeah, I know, BASIC has ":" as a separator. But you use that if you want to write multiple separate statements on one line. For such a purpose, I obviously have no issues with a separator, may that be ":" or ";" or whatever.
Right. but that's just saying "a third party tool is shit". Yes it is likely true but since it's out of your control anyway using that to rail against languages/config formats that use commas at all (which is where some of this conversation started) isn't exactly very informative/driving the discussionWell, I have no choice what format a 3rd party vendor has it's stuff in. So I have to work with what I find.
This all assumes the optimal situation that you and I sit at our well set up developer machine. Maybe my background in help desk and as a sysadmin is showing, but there were many times I had to look (or even fix) at configurations or scripts on a client's/user's machine that had nothing but Notepad (or Editor back in the MS-DOS days).
Exactly what ramases wrote, but to add further and explicitly.
The people doing the smaller stuff are just as valid and important and it's totally fine for tooling/languages to cater well to them. But this reinforces that there is no "one perfect language" because homogenous we are not - and that's a good thing
I also think that what constraint a statement separator put on a compiled language are not the same than it put on a script or description language. It's the difference between failing at compile time and failing at run-time; between always been edited in IDE and may be edited in Notepad or nano.I think there's a significant disconnect in this discussion, with one side placing a lot of importance on things that to the other side are almost trivial syntactical details. The above is a good example of this.
[...]
But don't we all start in the first category?The earlier works with relatively small code-bases, so weird issues like yours may consume relatively many resources compared to actually developing software.
The later works in large-scale software projects.
I'd say that XML straddles the edge here. Sure, it's nice that whatever the software that groks XML is called can easily detect errors like closing the wrong tag, but XML is just a disaster to work with as a human without software to help you.
This is whatThis all assumes the optimal situation that you and I sit at our well set up developer machine. Maybe my background in help desk and as a sysadmin is showing, but there were many times I had to look (or even fix) at configurations or scripts on a client's/user's machine that had nothing but Notepad (or Editor back in the MS-DOS days).
tramp-mode
is for... Turns out that so long as there is an ssh connection, there is no need to have emacs installed on the computer where you are editing a file.And this is what tools likeWell, I have no choice what format a 3rd party vendor has it's stuff in. So I have to work with what I find.
pandoc
are for. Turns out that it is fairly simple to turn Json, Yaml, Edn, or whatever into whatever. You can write this party vendor stuff in whatever you want to write it in.It depends on the language, but certainly for some C-alikes, once you get used to using one that doesn't need semicolons, going back to one that does and adding them feels very much like compiler hand-holding that shouldn't be (and arguably often isnt) necessary.I am likely to start seriously coding in a language without semi colon separators full time shortly. IT will be interesting to see how that goes after f#. I might agree with you a lot more on this specific case, but even then that design decision will have been painstakingly factored into lots of other choices so it works as a whole, it's not a one size fits all.
For example to me the ability of a compiler to generate good error messages, even in a syntactically invalid program, is almost infinitely more important than the syntactical convenience of not having to type ';'. I care a lot about the former, because the compiler being able to emit (almost) all errors at once, even for source files with broken syntax, saves me a lot more money (and the developers a lot more work) than not having to type ';' ever would.
When I started programming, most of the interpreters and compilers I had available were beginner-friendly and would stop at the first syntax error. Fix that, then you run it again, it gets a little farther, then you get the second error. Again. Again. If you're writing something that prints out e.g. factorial(atoi(argv[1])) or "hello world", you'll fix all the errors pretty quickly and be able to check that little assignment off as done.For example to me the ability of a compiler to generate good error messages, even in a syntactically invalid program, is almost infinitely more important than the syntactical convenience of not having to type ';'. I care a lot about the former, because the compiler being able to emit (almost) all errors at once, even for source files with broken syntax, saves me a lot more money (and the developers a lot more work) than not having to type ';' ever would.
Operators like + or ?? can't go at the beginning of a line unless the previous line didn't terminate, so the grammar knows that it needs to keep processing tokens for the previous line.Writing in C#, I often use the null coalesce operater:
X = something ?? throw new long_named_exception(long message);
And usually put a line break before the ??
How would that work with no line terminator? Maybe BASIC style
X=something _
?? throw clause