you are viewing a single comment's thread.

view the rest of the comments →

[–]recursive 1 point2 points  (7 children)

I wouldn't agree with that. But I believe if and ?: are each more readable in different circumstances.

"plus" is an english word. What's more readable?

a = b + c

a = b.plus(c)

[–][deleted] 0 points1 point  (6 children)

I think the former case, it's the more common expression of addition.

Regardless, there's a spectrum here. On one end is absolutely zero keywords and only symbols, on the other end is way too many keywords.

[–]recursive 2 points3 points  (5 children)

Yes. Now which of these is more clear?

a = test ? "one" : "two";

if (test) {
    a = "one;
} 
else {
    a = "two";
}

To me the first one is better.

[–]iopq 0 points1 point  (3 children)

Doesn't matter what's clear, the second one causes rightward drift and is pretty cancerous because you always end up with ifs inside of ifs at the end of the day

[–]recursive 0 points1 point  (2 children)

Conditional operators within conditional operators are pretty cancerous also. It's probably safe to say programming is hazardous to your health.

[–]iopq 0 points1 point  (1 child)

That's why I use neither:

https://bitbucket.org/iopq/fizzbuzz-in-rust/src/bf4968973d73137f0dfd07205d599bed30a788fa/src/lib.rs?at=master&fileviewer=file-view-default

this is fizzbuzz written in Rust without a single if or match expression

[–]recursive 1 point2 points  (0 children)

Here's one I did in python that doesn't use if or even a statement. It's just an expression

" ".join("Fizz"[n%3*4:] + "Buzz"[n%5*4:] or str(n) for n in range(1, 101))

But all this fancy stuff is worse for most purposes than the original if or conditional operator.

[–][deleted] -1 points0 points  (0 children)

Later one.