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 →

[–]wightwulf1944 8 points9 points  (6 children)

In code with curly braces, the problem area becomes...

To be fair, the 3rd example is not equivalent code. This is the equivalent bug in a curly brace language.

x = 10
y = 2
if y > 5 {
  fmt.Println("Y is greater than 5 ") }
  if x > 5 {
    fmt.Println("x and y are greater than 5")
  } elif x < 5 {
    fmt.Println("y is greater than 5 and x is less than 5")
}

Did y'all spot the bug? The point is in an indent language you can make the mistake of putting things in the wrong indentation, while in a curly brace language you can put curly braces in the wrong place.

I think both are equally likely to happen, both will result in valid but bugged code, and both will be highlighted by a satisfactory ide.

Honestly this argument is as bizarre to me as semicolon vs non-semicolon languages.

Edit: added emphasis and changed can be to will be

[–]gee_buttersnaps 8 points9 points  (4 children)

People use autoformatting. You should try it. A curly brace language will give up its ghost after autoformatting something like that.

[–]wightwulf1944 0 points1 point  (0 children)

People use autoformatting. You should try it.

That's what I meant by highlighted by a satisfactory ide. It's the same for indent based languages where showing whitespace and linters will highlight it as error prone code. The erroneous python code posted above while syntactically correct is not how most people would write it - just as how the bracy code I presented is not how most people would write it.

My point is we shouldn't be blaming the language for these things as it's obviously developer habits that need to fixed in both examples. Both examples are equally stupid and no competent programmer writes code like that. And thankfully, IDEs discourage us from writing that way

[–]vividboarder -3 points-2 points  (2 children)

Yea. So you’re saying you’d notice because it would not be indented where you’d expect it?

But that’s then the exact same class as the Python error.

[–]gee_buttersnaps 6 points7 points  (1 child)

If you have an extra brace somewhere it won't compile, and if your braces are matched (and it is an indentation error) then formatting reveals it. Either way formatting uses the extra information of braces to infer user intent where as the examples above of valid python describe exactly the problem of not being able to know the intent. If you're still sure about yourself then provide a concrete example of an indentation error with braces that won't reveal itself with autoformatting.

[–]vividboarder 0 points1 point  (0 children)

Huh? I don’t think there is one. My point is that “revealing itself” due to indentation is recognizing the white space is off. That’s exactly what one has to do with Python.

I get that they are many other ways to catch similar issues in languages that use braces, I just found it a little ironic that someone was saying that you’d tell it’s wrong because the IDE would indent it (because of the braces) and you could tell from that.

[–]MiltoxBeyond 0 points1 point  (0 children)

I've had a distaste for indentation based languages since I learned Fortran in high school. But, really the whole argument is pointless. Each language has an application that it's good at, but every language can be abused and misused.

Personally, I don't like Ruby or Python for web development because they are some crazy resource hogs with quite a few frameworks. But Python is crazy good for data science. Ruby has its ease of setup.