rust-lang / reference

The Rust Reference
https://doc.rust-lang.org/nightly/reference/
Apache License 2.0
1.23k stars 478 forks source link

Python influence on Rust #828

Open pickfire opened 4 years ago

pickfire commented 4 years ago

https://doc.rust-lang.org/reference/influences.html

Not sure if it is valid, I found many code similarity between Python and Rust. I would say Python influences Rust in terms to having readable code, Pythonista called it Pythonic code, Rustaceans calls it idiomatic rust code. Doesn't it sounds similar? I know this is quite generic, but Python have autopep8 and Rust have rustfmt, both have an official style guide (unlike other languages).

Also, I think Rust RFC process is inspired by Python PEP. I was surprised when I heard Python PEP is similar to Rust RFC, I know it existed but I did not know they are similar. https://github.com/rust-lang/rfcs/blob/50748904312412849b2edf1c95dfba2b3a44bb1b/text/0002-rfc-process.md

As an alternative, we could adopt an even stricter RFC process than the one proposed here. If desired, we should likely look to Python's PEP process for inspiration.

Boils down to 2 items:

Havvy commented 4 years ago

You'll find the term "idiomatic code" in every programming language including many that have cute names for it. For the RFC process, I don't quite know the prior art that motivated it, but that'd also be more a meta-influence. The RFC process is not a part of the language.

pickfire commented 4 years ago

You'll find the term "idiomatic code" in every programming language including many that have cute names for it.

Yes, but not all languages have official style guide, so far the languages I used are only Rust and Python. Or is this very common?

Havvy commented 4 years ago

Rust doesn't have an official style guide. The tool we use has defaults, but you can change them in the tool itself. And most languages have a tool to do this. JavaScript has JSHint (and before that JSLint). All of the lisp languages universally suggest using the same amount of whitespace (and even having written quite a bit of it, I never learned the rules because the tools did it for me). In the world of C and C++, you find people stick to one of three or four major styles. Almost all Java code looks the same.

pickfire commented 4 years ago

No, Rust does have an official style guide. https://github.com/rust-lang/rfcs/blob/3efb02fe2a934eadf2ca5b3cf4e2acdeb1039f22/text/2436-style-guide.md

Python have https://www.python.org/dev/peps/pep-0008/

JSHint is not an official style guide Three or four is not an official style, an official style guide means that there is one and only style guide, Python only have one which is PEP 8, Rust only have one which is the style guide in RFC 2436.