Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've read and written a huge amount of python and rust, also a fan of rust and don't find it particular difficult to read.

As long as there is proper linting, both should be readable.

That being said, python is about the simplest language there is to read.

Of course if you have many times nested and improperly indented list comprehensions- sure that gets confusing. But that should be fixed with proper linting (black on its own should do it)

Curious about the examples you've seen that were difficult to parse!



I don't necessarily agree that Python overall is difficult to read, but one thing that seems to get my every time is the

    foo = x if y else z


I see where you're coming from.

Many languages support the ternary operator, where it would be:

  foo = y ? x : z
Which "feels better" but I think that's because I learned ternaries first.

Some languages like Rust and Kotlin do support assignment of an if statement like

  foo = if (y) { x } else { z }
And I think that's a good step, as it doesn't need to introduce new syntax, just allows assignment of "blocks"


Yes. It requires that `if else` can be used as expressions, which for some reason in most languages that can not.

In the beginning of doing Rust I was missing the ternary operator, but now I couldn't care less.

    foo = if y { x } else { y }
Works well :-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: