-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggestion: Add better function/block termination #4
Comments
Counterpoint: C# Historically, that example in C# looked like int loop_over_global() {
return 1
} But later they explicitly added less-noisy syntax, so one can now write int loop_over_global() => 1; Boats did a great job of elaborating on different facets of "explicit" in https://boats.gitlab.io/blog/post/2017-12-27-things-explicit-is-not/ -- can you elaborate on which things you're most interested in here? |
@scottmcm I find that c# syntax bad, Dart has introduced the same convenience syntax and it makes it harder to just look at some code and speed read it with a single glance. I have no problem with implicitness as long as it makes reading code more obvious or faster or just as fast. For example I would never complain that on the lefthand side the type is missing in
Now imagine for a second if it looked like this instead (forget what you would lose in terms of features, just imagine if for some reason this would be just as powerful)
It is so painfully obvious, it's almost offensive how simple it looks right? Well that's where the goal should be. Offensively simple code. I look at this and there is absolutely not a single question I have about it. |
Thanks for the feedback. I will keep your concerns in mind. I can assure you that none of my design decisions result from wanting to make Cone more Pythony or to save keystrokes. The good news for both your suggestions, is that return may always be explicitly specified and one may explicitly specify curly braces, which turns off significant indentation. So your code can definitely follow the conventions you prefer. |
@jondgoodwin it doesnt work for me:
Error:
|
Because once you turn it off, implicit white space is turned completely off for everything inside. At that point you must consistently use curly braces inside (e.g., on the each block). You must also terminate all statements with semicolon, as your example is asking for at the end of 'mut sum = 0'. |
@jondgoodwin I like that rationale, once it's turned off it's completely off, I'd almost go further and do that for the whole file. it'd make it completely unambiguous what's going on and in a way declares that the file is completely copy-paste-able. |
Ok, I've now tried Python for a while and I actually liked it a lot. It's much faster to type and work with when you dont have to write braces all day. Is it more dangerous? Yes, of course. But on the whole I think it's worth it and indentation problems dont appear as often as you'd think. |
Overall goal: More safety and less ambiguous code, faster reading of code, not just faster typing.
Point 1 Remove implicit returns, require writing 'return'
This is the julia syntax that I consider ideal:
This is Cone's pythony syntax right now (remember, Julia was created primarily to replace Python as a better alternative)
I mean can you honestly say that the second is easier and less ambiguous to read?
Point 2 Require writing 'end' to end blocks like functions or loops
Here is a julia loop:
The problem I have with python like identation: How can I be sure that I copy pasted some piece of code correctly or not? I have to check every single line if it was pasted with the right identation. This could introduce errors of an absolutely nightmare kind where oh oops, one line of 2000 didnt copy paste correctly and the variable at the end of a loop went outside of the loop which now changes the behavior of the loop or the rest of the program in silent ways. I mean this is C undefined behavior kinds of dangerous.
So we can see that even for data scientists who arguably want to write one-off, quick and dirty code.. the julia authors felt like moving away from Python syntax was best and to make these changes.
The text was updated successfully, but these errors were encountered: