Additionally, it has stumbling blocks towards achieving the upgrade. Packages you're using aren't upgraded, you have a lot of code dealing with strings, and so on. I worked on a project that tried to use Python 3.x and it was a nightmare in both regards.
In my view, Python 3 doesn't offer any major reasons to upgrade other than we've been told to. Someone tell me: what is it that's so compelling about Python 3? For instance, when you click on "What's new in Python 3" on this page, the first thing in the list is "print is a function". Seriously? The FIRST thing in the list is something that breaks code and has very little impact. Unicode has a lot more impact, breaks a lot more stuff, and is doable in 2.x anyway, yet is the 5th or 6th thing in the list.
So I'm not really sure what the devs were thinking with Python 3.x. It broke a lot of stuff but didn't break enough to make Python notably better. I was around and a heavy Python user for the 1.x -> 2.x upgrade. That was far easier, had some features I could really use, and there was a much smaller installed base. This time around, I just don't see the reason I should upgrade. Eventually, I imagine I will when support is so far gone that there's no choice, or there's some amazing feature that requires it.
For those of you who will respond: "So don't upgrade, or switch off Python". One of those is mission accomplished. The other one remains to be seen, though if Tiobe is at all believed, Python is declining sharply in interest.
There's lots of reasons I find coding in Python 3 more enjoyable and productive. Unicode by default, removing x*() functions and returning generators where appropriate instead, removing old-style classes, improved consistency in standard object interfaces/protocols, standard lib cleanups, etc. Yes, even print() - keyword args are a lot nicer than the old hackish syntax for things like the output file.
These are often called minor and "no compelling reason to upgrade", but I'd submit that when a language does more often what you expect it to do, when the number of gotchas you need to keep in mind is reduced significantly, that's not minor. It might not be a reason to switch a large existing codebase over, but it's certainly a reason to write the next large codebase in it, and that's what Python 3 aims at: The future of Python and its future users.
No, that doesn't make for a fast transition, but indeed, it was never expected to be ("five years" is the plan, we're not there yet, and things look to be on track). Eventually, there just won't be any reasons left not to use Python 3, but plenty of reasons to do so (the better core language, the sum of improvements in the standard lib, the continued maintenance), and then it'll be done.
I guess that's my most major beef with it. The upgrade has been tough, and a lot of the most inconsistent aspects of Python weren't fixed. (A good example: "len()")
BTW, I tried using Python 3 on that project in 2010, if that helps anyone gauge my opinion on it.
Yeah, sure, there are still some things in there that make me wonder why they didn't go one step further to fix it too. Little things even, like the names of the special methods to intercept attribute access: __getattr__ and __getattribute__ should have been swapped for consistency, since __getattribute__ is closer in behavior to __setattr__ and __delattr__, making the current __getattr__ the behavioral outlier.
But meh, any language has its odd little warts, and so has Python 3. It does have significantly less than Python 2, though.
However this is complete and utter bullshit.
Other languages are inconsistent? The answer is not to be inconsistent, and you can be consistent as a method or as a builtin function.
Don't know if it should be a method or an attribute? Python has properties now, the user doesn't have to care.
The 'special meaning' section that follows seems a bit confused as well. Why is it so special to get the length of a collection?
Sorry for going off on a rant, please correct me if I'm wrong here. I just get so frustrated with the eagerness of the Python community's apologetics for things that no longer make sense to be in the language.
I can feel it working within me too, I'm more and more on the fence about explicit self.
With dynamically typed languages, it is very hard to "be consistent as a method" since there are no tools to enforce that consistency. Social cues usually go 90% of the way, but not all the way whereas a function/generic method handles that just fine: to get a length, you call `len`. Period. The developer does not really have the option to do otherwise, unless he wants to opt out of the language's ecosystem.
Actually what I said above is not entirely true, there is one situation where it is "quite easy" to handle method consistency in a dynamically typed language: when you deal with mixins.
Because mixins have preconditions (methods and/or properties which need to exist for it to work), they enforce those names or they can't be used at all. And of course any method brought in by the mixin is "enforced" by default.
So is it with most things iteration in Ruby for instance: Enumerable mandates that a core internal iterator named `#each` exists (as well as #<=> optionally) and as a reward for doing so it gives about 30 methods "for free". That enforces consistency in collection traversal, because even if you reimplement some or all of these methods in the long term (for efficiency and whatnot) getting them "for free" out of the box is valuable.
If it is good design there, should others repeat it? For example, if a module author is defining a new protocol for a set of objects that anyone can implement should they provide functions that delegate to the methods in their protocol?
For myself I think that the python community can be counted on to be consistent without the need for this duplication and indirection.
No, because each collection type (mapping, sequence, set, ...) has very different addition semantics (and potentially arguments as well). On the other hand, there is a builtin to iterate over stuff.
Python didn't have properties when the len protocol was implemented. What exactly will be gained if Python replaces len(a) with a.length(where a.length translates to a.__len__())? If properties were there from the beginning, that would have been the implementation; but since they weren't, len(a) is just fine and I don't see any reason for it to be changed.
> The 'special meaning' section that follows seems a bit confused as well. Why is it so special to get the length of a collection?
Personally I would have preferred __len__ to be just length, because length of a sequence is part of it's public interface, as opposed to other special methods viz. __getattr__, __getitem__. Apart from that, his 'special meaning' section is just saying that following a weird naming convention for the special methods permits programttacily differentiating between public interface and special methods.
> I can feel it working within me too, I'm more and more on the fence about explicit self.
The main reason it is that way is decorators.
> However this is complete and utter bullshit.
This isn't an appropriate response to a well thought out article.
Having tutored students learning python as their first experience programming, I recall that it was confusing that len was a function which merely calls a method on its argument. They wanted to know when they should write their own functions in a similar style.
I looked into it, and the best answer I came up with was that len is an historical artifact. If it were designed with the capabilities of modern Python, then there would be no good reason for doing it that way that I can find. Please correct me if I'm wrong.
The article as a whole is quite good. Its arguments in favor of len being a builtin function are quite bad. I've noticed this as something of a pattern in the Python community that I'm speaking out against. It's ok for there to be things in a project the size and age of Python that are historical artifacts. Python is certainly far and away better in this regard than its sibling languages.
Defending them as good design is counterproductive. I don't want newly designed languages to ape the mistakes of the old.
And readability in itself, I mean alone in its own merit isn't a deciding factor for most projects today.
Far too many factors decide in choosing a language today, they rapidly change and will continue to change over time. Concurrency and JVM's feasibility is giving clojure great mileage in the mainstream.
The problem with python is, its brittle enough to break at any new syntax experiment. This doesn't do good for language evolution.
And evolution is what keeps you in the game. How else do you think Perl and Lisp have managed to survive and grow till today's date.
I don't sort of want to be making a negative point here. But hey Perl has been adding keywords and new syntax to Perl 5 without breaking backwards compatibility.
Some times flexibility is important.
I'm kind of surprised that people think people are surprised that the upgrade to Python 3 has gone so slowly. After all, Guido himself has stated on numerous occasions that the migration would take many years to complete. The time to complete this transition is not so much of a problem for a language that plans to be around for the indefinite future. After all, the future is much longer than the past.
Should they work with 2.x which is going to go away, or 3 whose ecosystem is not ready yet.
I think the minute Django supports Python 3, we'll see the level of whining drop to almost zero.
As the grandparent's author for perspective: I don't use, nor have never used, nor intend to use Django. My issues with Python 3 have no basis in Django's compatibility.
And that is bad news for Python, trust me. We have already seen this in the past.
Perl ~ CGI/Sysadmin
Ruby ~ Rails
Python ~ Django???
C ~ Unix
Association with a very popular project has its downsides, but the upsides are much stronger, in my opinion. For instance, would Ruby be as widely known, deployed and used for non-Rails projects if it wasn't for Rails? It probably would just be another "niche" language rarely used outside of Japan. OTOH gem probably wouldn't be as badly broken as it is.
At the moment, they are pissed off that Django is not moving as fast as the language, so they whine that "nobody is moving to Python 3". As soon as that's fixed, the noise will drop.
Same for the numpy/scipy community, which is the other big one for Python. Lots of academic people there, who have a lot of spare time to bitch on the web.
There are better things to worry than to maintain two parallel versions of the same code supposed to run on two different versions of Python.
Its either going to be one of them or some other language.
You don't have to do all this extra stuff. You could say I'm going with python3 and simply live without (or port or re-implement) any features from third party libraries that don't have a python2 version. Or you could say I'm going with python2 and live with the facts that the language won't be evolving any more and a few years from now most libraries will only see updates to their python3 branch. Both of those approach are also perfectly reasonable depending on the scope of the project.
When there are better alternatives available elsewhere.
Obviously if there are significantly better answers than python to the problem you're facing then you should be using one of those alternatives. I was assuming that you'd already decided that python was the best fit for an upcoming project and needed a plan on how to proceed.
Obviously this depends on a few things - deployment, time/cost etc.
They are either going to use one of them fully or neither.
None of this deters me from thinking that Python 3 was the right thing to do.
Anyway, I think it makes more sense to major-version language than implementation changes. In theory CPython vs. PyPy shouldn't matter to code.
Java script seems to be going strong. Python has fallen by 3 places and has the maximum drop in ratings among top 20 languages.
Python is right next to Perl.
Since according to many Pythonistas and the references they used to point to in the past when they talked of Perl, Perl was dead for the same metrics which Python has now.
1. A major revision whose ecosystem isn't ready.
2. Current stable widely deployed version is going to go away soon.
3. Fall in ratings.
4. Fall in usage.
5. Rise of new languages like clojure.
Can we say Python is dead? It must be since TIOBE says so!
Why do you doubt this? Delphi was huge in the late 90s, and I would postulate that there is a major amount of legacy code still out there.
Delphi/Object Pascal shot up in the rankings just as Google released Chrome.
That's only significant because, at the time, the implementation of Object Pascal on the CLR also had the name "Chrome".
I am just applying the same principles to Python what used to be applied to Perl.
And more importantly there is data to back up everything that I said.
> I am just applying the same principles to Python what
> used to be applied to Perl.
Maybe it is only me, but I feel the number of Python-related articles is higher than ever on HN.
Though, it'd be interesting to write some code to pull language interests off HN. It would be an interesting experiment. Granted, HN is a tiny subset of the programming community, but it would be interesting nevertheless.
Things that would have made Py3 enticing to me:
- Real GIL improvements (no changing from op-slicing to time-slicing is not a real improvement)
- Better OO. Roles, traits, enough with the duck-typing.
- Anonymous subroutines/multiline lambdas. Creating closure generators is too much work in Python compared to Perl.
- Tail recursion
- More stuff that will come to me after I click "submit"
JIT and GIL are not language features, they're implementation details. Once alternative implementations catch up, many will look at this again.
The other things are considered to be language features by many, have been discussed to death by developers and users alike, and are unlikely to be changed or modified any time soon.
Perl 5 is right out.
Finally, I started learning it just a month ago and now I don't know what ever stopped me before. In fact, the most annoying thing I've found about Python3 is that my searches for documentation on DDG or Google all go to the Python2 docs.
(I am dragging my feet on this, too.)
That is, at the same time when they removed some tried and true language constructs people liked and didn't add more of any powerful features that everyone was hoping for.
I bet Python 2.x will dominate for a long time, possibly with PyPy w/ LLVM becoming the de facto implementation instead of the discontinued CPython. Also, another party will at some point continue developing the 2.x line further.
Now, let's talk semantics. Not converting to floating point is precisely the kind of hidden computation that should be avoided, at all costs, in a language. Haskell is efficient and rigorous, and its division operator does floating point conversion. So, no excuses.
The key point in this is that only integer literals get fromInteger applied automatically, so for example
let n=6 :: Integer in n/3
let n=6 in n/3
[^1]: only by default, if you load the rational number library, you can ask for / to compute rational numbers by simply saying the type of result you want: 3/4 :: Ratio Int evaluates to the rational number 3 % 4 (% is Haskell's odd choice of notation for rationals).
- : int = 2
# 5 /. 2;;
Error: This expression has type int but an expression was expected of type float
# 5.0 /. float_of_int 2;;
- : float = 2.5
The more this continues, the more some technology is going to eat Python's lunch.
If Python wanted to break backwards compatibility they should have done so with some big major changes. That would have been justifiable. Right now no one sees a reason to break backwards compatibility to go to a no-so-ready ecosystem at the expense little gains. At the same time no wants to write 2.x either.
At least people planning to maintain their code base for years aren't going to write in a major version that's going to go away.
The only reason I've used Python 3 at all was because of project involving blender. I needed to do in-memory JPEG compression for quickly streaming images from the game engine. In Python 2, this is a couple lines of code using PIL. Instead, I ended up having to write my own pyjpeg module that provided a ctypes interface to a custom libjpeg-based compression library. I'm proud of the result, but the aggravation and frustration that entailed has removed any desire I have to move to Python 3.
Thanks for the Pillow link, btw. I was unaware of it.
The good news is that adoption should pick up very quickly after this fall. Python 3.3 will make it easier to port Python 2 projects and provide more incentives to upgrade. There's also nearly a critical percentage of major packages ported, and Django (which is still on Python 2, and is a deal breaker for many people) will have experimental support for versions up to 3.3.
I expect that by this time next year, the default for most new projects will be Python 3.
That's basically 90% of the time taken right there, since we had to do it one Python version at a time, giving people warnings that we'd be dropping support for 2.3, then 2.4, etc. so they'd be able to migrate up to a newer Python.
I think now that 2.7 is the last we will start to see a bit more migrate.
Edit: I didn't mean they aren't shipping 3.0, but that the default is still 2.7.x
The fact is that almost every major distro is shipping Python 3, and often has been for several releases/years: Fedora, Ubuntu, openSUSE, Debian, Gentoo, ArchLinux ... and many of these also have anywhere from dozens to hundreds of Python 3 libraries packaged.
If you mean that /usr/bin/python still points to Python 2 on most of these (in fact all of them except for ArchLinux): True, and that is unlikely to change, possibly never. It's my understanding that this is in keeping with upstream's wishes (from discussions on python-devel and python-porting): bin/python is to remain Python 2 with python3 being the right way to run the Python 3 interpreter.
Linux developers and sysadmins are lazy by default (with good reasons: they have a lot to do). To make them get off their arses, you have to switch defaults and scream loudly when stuff breaks, otherwise they'll never bother.
If the problem is that it will break package xyz that is so old and completely unmaintained that nobody can fix it, well, it's a good reason to drop a zombie package. If your code depends on a zombie package, things would have broken down sooner or later anyway.
For someone just starting out with python (on linux anyways) that means they are probably going to fire up that interpreter first.
I was wondering myself actually if any of the distros would switch to 3.0. I think a lot of packages would break if that were to happen.
As you've said, Arch has already switched but their package release isn't really typical for most distros.
I think that's probably a too aggressive schedule to actually keep, but here's hoping.
The consensus from Python list discussions like "Shebang lines for Python 3" and "Support the /usr/bin/python2 symlink upstream" seemed to be that /usr/bin/python is to remain Python 2 indefinitely and that newly-written scripts should call python2 or python3 explicitly. If I recall right Guido's stance was the latter, but leaving plain python up to distros.
There's also PEP 394: http://www.python.org/dev/peps/pep-0394/
This is further cemented, if you will, by the new Windows launcher in 3.3 that extends shebang support to that platform and supports the same mappings.
That said, one of the KDE applications I maintain contains a fair amount of Python code, and since I consider Python 3 to be a much nicer language, it of course runs fine on 3.x. And purely from an emotional POV the fact that the Arch packages get to install those scripts without their usual sed call to replace "python" with "python2" does bring a smile to my face.
Python2 is still in base-devel, but /usr/bin/python symlinks to python3, not python2.
But they should also mention they are taking away our beloved print and quick string formatting.
The string formatting syntax did indeed change, but the new syntax is just as "quick" as the old one, just different (see http://stackoverflow.com/questions/517355/string-formatting-...).
Anyway, the observation is to note how long it takes to get people "upgrade" when "breaking" changes are made to languages.