开发者

Ruby vs. Python: which one is easier to keep track of different language versions? [closed]

开发者 https://www.devze.com 2023-03-15 15:28 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

I've heard that there are issues with the more recent versions of Python (3.x?) that have led to slower adoption. Is that true? And if so,开发者_开发百科 is it an issue when different people are using different versions of the language? Which version of Python is most widespread?

Does Ruby have a similar issue, or did most people switch to 1.9?

Please note that this is not a general "vs." question at all, but rather a question about this specific issue.


The issues aren't with Python 3.x, but the lack of a reasonable transition path from 2.x to 3.x causing most people to stay on 2.x.

It was a serious blunder, but an isolated one: aside from that, Python updates are very straightforward.


As far as Python, most people are using the latest version of the 2 series. Python in general can be a nightmare as to mixing versions (at least, it used to be), but the solution is simply to deliver your software with the entire python environment it depends on.


Reminds me of the days I spent coding for Python 1.5.2 because 2.x had not had deep enough deployment to use any of the newer features -- it was a choice between customers and nice features.

It feels to me like Ruby users are more accustomed to having multiple versions installed simultaneously for the different levels of support in their software -- some require new 1.9 features, others won't work in the newer worlds. rvm makes it easier to manage multiple codebases, interpreters, and modules.

And it also feels to me like Python users rely more upon distribution-provided Python installs, and have less flexibility in running different versions. (Sure, it's not impossible or even hard to download and compile a new version in /usr/local, but how many do?)


From Python's wiki on choosing the right Python version:

Short version: Python 2.x is the status quo, Python 3.x is the shiny new thing.

Python 3.x is not 100% backwards-incompatible with 2.x. It's only in certain regards, but they happen to be fairly BIG regards. The decision was made in Python 3 to attempt to fix some core architectural mistakes of the past, dating back to Python 1.x. Even having said that, almost all of the syntactical changes have been back-ported into Python 2.6.x and later.

This is by no means a comprehensive list, but here are a few key differences in Python 3:

  • print is now a function and not a statement. This allows print() to be extended and accept arguments. You may access it in Python 2.6.x with from __future__ import print_function. In Python 2.7 both methods are supported (statement: print 'hi', function: print('hi')).
  • Exception handling now requires the except Foo as foo_err syntax. (The former except Foo, foo_err syntax led to confusion in cases where you were catching multiple exceptions because of the comma-separated assignment to the variable.) Both formats are accepted by Python 2.6+.
  • All classes inherit from object by default., there is no longer a need to explicitly subclass object when creating a new class. See (Python's old-style vs. new-style classes).

One of the core problems with adoption of Python 3.x is because of these types of changes, which are major features. Many production environments still run on Python 2 and until we have wide-scale 3rd party library support in Python 3, adoption is going to be slow.

If you are just starting with Python, try the latest available versions. Currently that isversion 3.2. If you find that you don't get the library support you need, fallback to Python 2.7.2 and urge your library maintainers to port to Python 3!

Python 2.7 is going to be around for a long time and is the last major release of Python 2.x. This gives us plenty of time to get used to Python 3, because all of the major syntactical changes are already included by default.


If your OS is linux, you probably have Python installed (mine is Python version 2.6.5). Since linux (Ubuntu in my case) actually uses Python, and Python 3.2 is not backwards compatible, I'd better not remove version 2.6. I can however install Python 3.2 alongside 2.6 and invoke it with 'python3'.

Ruby is generally not part of standard linux and the OS is not dependant on it, so Sysadmins and users are more inclined to upgrade, although ruby 1.9 is also not backward compatible. With rvm (ruby version manager ), you don't have to wait for the OS package manager, and you can switch versions easily.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号