10 ms·
> The most tragic aspect of this bug, howevere, is that it is intended behavior according to the YAML 2.0 specification. This is one of those great ideas that
by WalterBright 6y ago
> The most tragic aspect of this bug, howevere, is that it is intended behavior according to the YAML 2.0 specification.
This is one of those great ideas that sadly one needs experience to realize are really bad ideas. Every new generation of programmers has to relearn it.
Other bad ideas that resurface constantly:
1. implicit declaration of variables
2. don't really need a ; as a statement terminator
3. assert should not abort because one can recover from assert failures
- atleta 6y agoI agree with the general observation, but the need for ";" ? Quite a few languages (over a few generations) have been doing fine without the semicolon. Just to mention two: python and haskell. (Yes, python has the semicolon but you'll only ever use it to put multiple statements on a single line.)
- yakshaving_jgt 6y ago> Yes, python has the semicolon but you'll only ever use it to put multiple statements on a single line. This is also true of Haskell btw.
- Cu3PO42 6y agoHaskell has the semicolon for the same reason!
- lelanthran 6y ago> I agree with the general observation, but the need for ";" ? Quite a few languages (over a few generations) have been doing fine without the semicolon. Just to mention two: python and haskell. (Yes, python has the semicolon but you'll only ever use it to put multiple statements on a single line.) But then it's inconsistent and has unnecessary complexity because now there's one (or more) exceptions to the rules to remember: when the ';' is needed. And of course if you get it wrong you'll only discover it at runtime. "Consistent applications of a general rule" is preferable to "An easier general rule but with exceptions to the rule".
- nightcracker 6y agoHave you ever used Python? If you did you really wouldn't be saying this. There isn't an exception. The semicolon is used to put multiple statements on a single line. That's it's only use, and that's the only time it's 'needed' - no exceptions.
- lelanthran 6y ago> Have you ever used Python? If you did you really wouldn't be saying this. There isn't an exception. For the ';', perhaps not. For the token that is used to terminate (or separate) statements? Yes, the ';' is an exception to the general rule of how to terminate statements. The semicolon also works on some sort of statements and not others, throwing errors only at runtime. It's easier to remember one rule than many.
- pedrovhb 6y agoHonestly, the rule is "don't use semicolons in Python". I don't think there's a single one in the large codebase I work with, and there's really no reason at all to use it other than maybe playing code golf. It's not a language in which you ever need be saving bytes on the source code. Just use a new line and indent. It's more readable and easier.
- c-cube 6y agoBut python has instead the "insert \ sometimes" rule, which isn't better.
- atleta 6y agoThere are no exceptions. You only need it if/when you want to put multiple statements on a single line. That's its sole purpose. And I'd also add that it's something that you almost never do. One practical use is writing single line scripts that you pass to the interpreter on the command line. E.g. `python -c 'print("first command"); print("second command")'` If you don't know about the `;` at all in python then you are 100% fine.
- labawi 6y ago
- ufo 6y agoAnother inreresting example is Lua. It's a free form language without semicolons. It's not indentation sensitive.
- samatman 6y agoLua does have semicolons! It even has semicolon insertion, but because the language is carefully designed, this doesn't cause problems, and most users can go a lifetime without knowing about it. Our coding style requires semicolons for uninitialized variables, so you'll see local x; if flag then x = 12 else x = 24 end As a way of marking that the lack of initialization is deliberate. `local x = nil` is used only if x might remain nil.
- ufo 6y agoI don't like saying that it's semicolon insertion because it might give people the idea that the semicolons work similarly to Javascript. In Lua, inserting a semicolon is always optional and it's an stylistic matter (like in your example). It even allows putting multiple statements on the same line without a semicolon. -- Two assignment statements x = 10 y = 20
- linspace 6y ago> implicit declaration of variables This is so true. I really like Julia and I know that explicitly declaring variables would be detrimental to adoption but I prefer it to the alternative, which is this: https://docs.julialang.org/en/v1/manual/variables-and-scoping/ https://docs.julialang.org/en/v1/manual/variables-and-scopin...
- lixtra 6y agoI’m surprised that with your experience you come to such unbalanced conclusions. Everything in engineering is about trade-offs and while your conclusions may be indisputable for the design goals of D they may wrong in other contexts. 1. If I scribble some one time code etc. the probability of having an error coming from implicit declarations is in the same order of magnitude as missing out edge cases or not getting the algorithm right for most people. The extra convenience may well be worth it. 2. I would relax this it should be clear to the programmer where a statement ends. 3. Go on with a warning is a sane strategy in some situations. I happily ruin my car engine to drive out of the dessert. The assert might have been to strict and i know something about the data so the program can ignore the assert failure.
- tralarpa 6y ago> 1. If I scribble some one time code .... and here is another entry for Walter's list of bad ideas: 4. "It's okay. I will use this code only once"
- erik_seaberg 6y agoMy favorite Red Green quote is “now, this is only temporary … unless it works.”
- unionpivo 6y agoI disagree with most of what you said but I want to specifically call out: > 3. Go on with a warning is a sane strategy in some situations. No, if its sometimes ok, to continue, than you should not assert it. Assert means "I assert this will always be true, and if it's not our runtime is in unknown/bad state." If you think you can recover, or partially recover, throw/return appropriate error, and go into emergency/recovery mode.
- lixtra 6y agoYour reactor is boiling. Your control software shut down with assertion failed: temperature too high, cannot display more than 3 digits. Downvote me if you want to open a bug ticket with the vendor and wait a week for the fix. Upvote me if you’d give it a try to restart with a switch to ignore assertions. You may abstain if you never shipped a bug. Edit: not to forget that this website runs on lisp which violates all three. Was it really a bad choice for the website?
- goatinaboat 6y agoThis is one of those great ideas that sadly one needs experience to realize are really bad ideas. Every new generation of programmers has to relearn it. It's a bad idea because ASCII already includes dedicated characters for field separator, record separator and so on. These could easily be made displayable in a text editor if you wanted just as you can display newlines as ↲. Anyone who invents a format that involves using normal printable characters as delimiters and escaping them when you need them, is, I feel very confident in saying, grotesquely and malevolently incompetent and should be barred from writing software for life. CSV, JSON, XML, YAML, all guilty.
- spion 6y agohow do you write them though
- teddyh 6y agoCtrl-\, Ctrl-], Ctrl-^ and Ctrl-_ for file, group, record and unit separator, respectively. However, your tty driver, terminal or program are all likely to eat them or munge them. Also, virtually nothing actually uses these characters for these purposes.
- goatinaboat 6y agovirtually nothing actually uses these characters for these purposes. Right. Which is why we have all these hilarious escaping and interpolation problems. Any why programmers will never be taken seriously by real engineers. It's like we have cement mixed and ready to go but we decide to go and forage for mud instead and think that makes us cleverer than the cement guys.
- spion 6y ago> your tty driver, terminal or program are all likely to eat them or munge them Maybe that has something to do with this?
- aasasd 6y ago
- asiachick 6y agoWhat do think of implicit member access (C++, Java, C#) vs explicit (python, javascript)? Is there a concrete argument one way or the other? I feel like I prefer explicit self.member = value this.member = value vs implicit member = value But clearly C++/Java/C# people are happy with implicit ... though many of them try to make it explicit by using a naming convention.
- coopierez 6y agoThat was my single biggest pet-peeve of C++. A variable appears in the middle of a member function? Good luck figuring out what owns it. Is it local? Owned by the class? The super-class? (And in that case - which one?) The added mental load of tracking variables' sources builds up.
- logicchains 6y agoFWIF, most C++ style guards recommend writing member variables like mVariableName or variable_name_ so they're easy to distinguish from local variables, and modern C++ doesn't generally make much use of inheritance so there's usually only one class it could belong to.
- aasasd 6y agoI can tell for certain that as a JS/Python man, every time I look through Java code I have to spend a bit of time when stumbling upon such access, until I remember that it's a thing in Java. Pity that Kotlin apparently inherited it. But at least, to my knowledge, in Java these things can't turn out to be global vars. Having this ‘feature’ in JS or Python would be quite a pain in the butt.
- mcv 6y agoThe fact that people introduce naming conventions to keep track of member variables is probably the biggest condemnation of implicit member access. People clearly need to know this, so you'd better make it explicit. It's actually a bit surprising that this is one thing that javascript does better than Java. In most other areas, it's Java that's (sometimes overly) explicit.
- jhomedall 6y agoF#, Kotlin, Python, Nim and many others all seem to get by fine without semicolons as statement terminators.
- WalterBright 6y agoIn Python, a newline is a token and serves as a statement terminator. What I'm referring to is the notion that: a = b c = d; can be successfully parsed with no ; between b and c. This is true, it can be. But then it makes errors difficult to detect, such as: a = b *p; Is that one statement or two?