TIOBE Declares Python the Programming Language of 2007 166
Posted
by
timothy
from the welcome-to-the-annual-proggie-awards dept.
The TIOBE Programming Community Index has declared Python as the Programming Language of 2007 due to a 58% surge in its popularity rating during the year, making it now the sixth most popular programming language and finally surpassing Perl. They also assert that Python has become the "defacto glue language," being "especially beloved by system administrators and build managers."
Great, lets all program python in 2007! (Score:2, Funny)
Re:Great, lets all program python in 2007! (Score:2, Funny)
Maybe we will see more Web (Score:2)
Re:Maybe we will see more Web (Score:5, Informative)
Re:Maybe we will see more Web (Score:3, Interesting)
Re:Maybe we will see more Web (Score:5, Interesting)
I had some features I had estimated out in PHP (over the last 6 months my estimates have been pretty dang close), and I implemented several of them in Django/python instead. I averaged beating my PHP estimate by 1/3rd, and that's including the time I spent trying to learn how the heck to do things in Django. I can't wait to see how things look once I've got at least an intermediate understanding of my framework. I don't hate PHP, I just love python much more.
Re:Maybe we will see more Web (Score:4, Interesting)
Perhaps you learned something the first time you solved the problem which helps you solve the same problem quicker the second time? Perhaps if you redid the project in PHP (I know this would be pointless, but for sake of argument) it would be just as fast as in Python?
Re:Maybe we will see more Web (Score:5, Informative)
That would definitely effect any re-implementation I had to do. I probably didn't make myself clear, but the efficiency was gained on 100% new code adding a new set of basically standalone features (A quizzing module added to a document control system). Of course, the efficiency gain was over my estimates, and they're subject to the accuracy of my initial estimates. I've been using the trac timing and estimation plugin to track my estimations over this project though, and they've been pretty dead-on (especially the last couple months).
When I go back and do re-implementation of features already present in PHP, I should only expect big gains coming from being able to just port code instead of design. I would really like to see more empirical evidence on the topic myself, but all I have to go on is my personal data.
Re:Maybe we will see more Web (Score:2)
We run almost everything in Django -- website, management, and patient records (secured, don't worry, and kept relatively anonymous... no SSN, etc).
Re:Maybe we will see more Web (Score:2)
Re:Maybe we will see more Web (Score:4, Funny)
--
Simon
Your flying! How? (Score:5, Funny)
Python @ xkcd [xkcd.com]
and
Python @ Bash.org [bash.org]
HHSSSHSHSSS
Acceptance Speech (Score:4, Funny)
Re:Acceptance Speech (Score:2)
Re:Acceptance Speech (Score:2)
Yeah, Cleopatra is more Python's style.
But what would be Perl suicide? Let yourself be trampled by camels?
MartRe:Acceptance Speech (Score:3, Funny)
But what would be Perl suicide? Let yourself be trampled by camels?
<obligatory> There's more than one way to do it! </obligatory>
Re:Acceptance Speech (Score:2)
Re:Acceptance Speech (Score:2)
Tried python (Score:2)
Wouldn't call it the year of Python since there's nothing special that's happened with Python this year. Heard a LOT more hype about Ruby (f that).
Tried the twisted framework. Garbage.
Frameworks can't be written successfully in a baby language like PHP, Python frameworks aren't gonna magically appear.
I'll take PHP, Java for backend and Flex/Actionscript for frontend.
Every task has a language/framework to fit it (Score:5, Interesting)
Them's fightin' words, sir!
But seriously.... I've just gotten so tired of PHP in the past two years, and Ruby was such a great improvement to it. I used Python before PHP and my only complaint at the time was that it really was more trouble than it was worth at the time to write whole web applications in Python. You could, but languages like PHP were made for the web, so it got superseded. Once upon a time I wrote a few games in Python using PyGame and PyOpenGL though and had nothing but great experiences with that. I wouldn't call Ruby a cure-all, but it's pretty flexible and really pleasant to use for a wide variety of projects.
That being said, I think that your post really misses the fact that for every task there's usually one or two programming languages or frameworks that would be "best" for that task. While PHP and Java may work as a backend for you, many of my projects are almost completely perfect for a Ruby on Rails implementation or specifically require functionality that exists nowhere else. Meanwhile Actionscript implies Flash, and I only have a couple of things brewing right now where Flash is even an option, much less advisable. I'm not trying to slam you here; I'm just saying that like anything else your mileage may vary.
Also, python's supposedly getting tail recursion and some other tasty features soon. I might be tempted to pick it back up if it can surpass ruby in its efficiency that way.
Re:Tried python (Score:3)
Like Django [djangoproject.com], perhaps?
I'm with you on twisted; you nead to twist your head around it. Python has indeed had a relatively quiet year. Django on the other hand seems to be doing things just right and leaves the programmer with the final say in how he wants to structure his application. I've been using it for various projects over the last 1.5 years: it has never let me down and shortened development time considerably, leading to very happy clients.
Given I charge by the hour, I might have to pick up Java to crank up those invoices...
Re:Tried python (Score:2)
As I understand it, Twisted is more of a framework for writing frameworks; it's not meant to provide the sort of higher-level stuff that people generally expect when they say "web framework." If I'm wrong about that, somebody please correct me.
Re:Tried python (Score:2)
Yes and no. I must admit having to look it up [wikipedia.org], as it has been a while I looked at twisted. Twisted provides a framework for networked applications, be them client-side or server-side. They have their own Web-oriented framework called TwistedWeb, which can be used to write a web-facing server. So yes, it's a (networking) framework with which you can write a framework, however not generally a 'web framework' like in the usual sense.
If you want to make your own (web) server in python, Twisted is a valid choice. If you want to make a web application, Django is a valid choice. There is little overlap, besides the fact that they both are python libraries.
TIOBE? (Score:4, Funny)
The linked page in the summary doesn't give any clues. Do we get to make up our own meanings? How about The Infernal Order of Bastard Evildoers? Seriously, who are these herpephilic people?
Re:TIOBE? (Score:3, Informative)
Re:TIOBE? (Score:4, Informative)
Lies, damned lies, and statistics (Score:5, Insightful)
TIOBE's methodology is distinctly suspect, too. Looking at search engine result counts - which are estimates, and in the case of Google are well documented to be inaccurate - is hardly scientific. And they're using YouTube as one of their search engines?! How is that going to produce meaningful figures?
(Yeah, I'm still bitter that ML is so unpopular. But you can't call me a Perl fanboy, because I dislike all "dynamic" programming languages equally, and program largely in C++ and OCaml.)
Re:Lies, damned lies, and statistics (Score:3, Insightful)
Their measuring the popularity of language foo by "Programming foo" hits, with some special case modifications to deal with particular languages where that kind of query would be problematic. Its not at all a reliable metric, but among the quick-and-dirty language-comparison metrics, it doesn't seem to be notably bad (not, again, that its any good, just that whole pack is really bad and this seems no worse than average.)
Using YouTube makes some sense given the kind of measure they are doing, since "Programming foo" screencasts that might be distributed via YouTube are as meaningful as the average "Programming foo" webpage.
(I hate screencasts, personally, but that's a different issue.)
Re:Lies, damned lies, and statistics (Score:5, Interesting)
The last time I had free rein in something like that, I did just that, and made a clean rewrite to make a few cleanly commented, consistent Python modules that did the work of all the previous scripts, sans bugs. Just the fact that assignment by reference is the default, that building data structures deeply requires no line noise, makes the program design easy to get right the first time. No "oops, need another dollar sign there". No "how do I refer to a value in a hash of lists of hashes again?" You just do it.
Maybe it's that my sense of programming comes from years of looking at some of the cleaner C and C++ out there, and reading Design Patterns, makes me prefer a language that encourages design and clean coding practices by default. I don't want to deal with one more script from someone who munged strings of data with regular expressions where they should have used data structures or objects. Those of you who are about to clean up piles of Perl code with Perl Medic in hand, I salute you. You're braver than I care to be anymore.
Re:Lies, damned lies, and statistics (Score:2)
Yes, yes, yes. That was the exact issue that made me come to love Python. It's not that I can't make complex structures in Perl, but that every time I wanted to do anything non-trivial I had to reach for the camel book. And heaven help you if you wanted to change a function to return a hash of list of hashes instead of a scalar, because then you'd have to change the calling code's semantics for storing the results. Hard? No. Annoyingly pointless? Oh, yeah.
I don't have anything against Perl. I just got tired of doing all the extra work that I had just assumed was a necessary evil until I saw otherwise.
Re:Lies, damned lies, and statistics (Score:3)
Being somewhat conversant in both languages, I can't help but wonder how you would go about the same thing in Python. I mean, the difference between a single value and a dictionary of lists of dictionaries is just as big. If your function returns data in a certain format, and you change the format of the return value, you must adjust the calling code's semantics, there is no way around that. Unless you stick the data in a class and only use accessor functions to manipulate it, but that works in Perl just as well as in Python, and you're still stuck changing calling semantics, albeit in one place only this time.
MartRe:Lies, damned lies, and statistics (Score:2)
That must be it [honeypot.net].
Re:Lies, damned lies, and statistics (Score:3)
I was experimenting with writing an IRC bot in Python from the ground up, opening up a socket and sending data into it (no frameworks or anything). After a while, I got fed up with killing the bot and restarting it every time I wanted to test new code (and people were getting tired of it quitting and rejoining), so eventually I came up with a solution.
I factored the bot class out into a separate module, and wrote a script that instantiated an object of the class, which then connected to the server, joined channels, etc. Then, I added functionality to the class to take all of its data structures (list of channels, list of users, and even the TCP socket itself) and pack them up into a dict, then return the dict. Finally, I added some code to import a dict and replace the data structures with the content of the dict, and then two or three lines of code to unload and reload the IRC bot module.
The result? I now have an IRC bot written in Python which allows me to modify the code live, without restarting the bot. If I want to add a new function, or add support for another command (one of the myriad numeric commands that, at this point, keeps ending up in my console), I can add it and then simply !rehash in IRC, and the bot reloads its own code, swapping out the old for the new.
Because objects are passed by reference, the socket itself moves from one instance to another, and the bot never has to disconnect. It was a rather ingenious hack, imho, was startlingly simple to implement, and was made possible by the amazing dynamicness of Python.
Woo!
Re:Lies, damned lies, and statistics (Score:2)
Kudos for a slick hack! But here's how I might approach that:
Create a class called "Settings" or similar. Change your bot class's __init__ method to accept a Settings object, like "def __init__(self, settings)". Then, change your code to refer to self.settings directly, such as replacing "self.socket" with "self.settings.socket". Once you do that, you can get rid of all the code that deals with saving and restore state, since all state will already be bundled into one convenient object.
Re:Lies, damned lies, and statistics (Score:2)
Its a clever hack, but there is nothing really specific to Python about it. Lots of languages would let you do that: indeed, that's one of the things that I've seen raved about regarding the use of Lisp in, e.g., the space program. Certainly, Lisp/Scheme, Ruby, and Perl all support that kind of hack fairly naturally.
If Python's the place where it clicked for you, that's great, but don't be misled to think that its unique or even part of some new breed in that respect.
Re:Lies, damned lies, and statistics (Score:2)
Sounds good, then someone can come in a few months/years from now and re-write in NBL [blogspot.com] because it's getting 100x as much data and now takes 3 weeks to process the data, using 500GB of RAM. Or because it's dumping pages of backtrace for a: missing file / an int() that should be a str() / misspelled word. Or just that noone can (under)stand the invisible syntax, so can't work with it.
As someone who's worked a lot with both Perl and Python, I'd say the biggest differences are that Perl has had a lot more inexperienced developers writing code for it and that Perl has basically been unmaintained for like 8 years now. Oh and that Python developers think that their languages is the best, but Perl developers know their language used to be;).
Re:Lies, damned lies, and statistics (Score:2)
Re:Lies, damned lies, and statistics (Score:2)
Re:Lies, damned lies, and statistics (Score:2)
Re:Lies, damned lies, and statistics (Score:2)
The problem with the whitespace isn't that it's enforced as a coding standard. It's that it changes the meaning of the code. You could use brackets, parentheses, some other punctuation, or keywords to denote blocks and still enforce indentation in the parser. Then you'd be able to say Python enforces good style but a program could easily reformat code to your own standard whenever the whitespace got screwed up.
Like I said, if you like Python, that's fine. I don't. It's not a bad language. It just has a quirk it picked up from ABC that I really don't care to mess with after having messed with it in ABC years ago.
Perl has odd quirks, too, as do Ruby, C, Pascal, Smalltalk, Forth, and Lisp. Some people hate Lisp for its parentheses. Other people love it for the same reason. Some people hate Perl for all the abbreviations and punctuation characters, while other think that's a great strength. It's all about trading off what you want in a language to avoid things you don't. No language is perfect, including Python, and people seem to make a lot of software work despite that.
Re:Lies, damned lies, and statistics (Score:2)
That could happen, but it wouldn't happen for any lack of making my code clearly readable, maintainable, and extendable by others [filefront.com]. It comes down to good practice, and some languages accommodate it better than others. You can do anything in Perl that you can in Python. However, your cost in time and tedium will definitely be higher in most cases beyond the quick 100-line regular expression script.
Re:Lies, damned lies, and statistics (Score:3, Interesting)
http://www.langpop.com/ [langpop.com]
Hopefully, I'll have trend data up there soon as well.
Certainly Interesting (Score:2)
Build management: Switching from gmake to Python (Score:5, Interesting)
Absolutely. This year we replaced an old build system written in make with a (vastly superior) Python solution written from scratch. The replacement took one programmer about two weeks. The make system had taken two programmers a disgusting amount of time to build and support. What suprised me most upon completing the changeover was that the Python solution was faster than the gmake solution; since Python compiles to bytecode, re-running the build script was a quicker operation than gmake's re-parsing of the make files.
Python's advantage as build glue is that it is just simple enough to be nearly shell scripting (write a simple wrapper, and you can pretty much just write shell script). But it has the features of a decent high-level language---including, most importantly, integrated documentation and a debugger. Anyone who doesn't understand why one would need a debugger for a build system hasn't yet written a build system complicated enough.
Really though, this is less a statement in support of Python and more a statement against gmake. Make's age really shows as a build language, and if not for all the tools in the GNU world that depend upon / assume the existence of a make engine, I would encourage everyone to just toss the whole thing overboard and create all new build scripts in something else. You have better things to do with your time than reverse engineer code written in a nearly incomprehensible string-parsing language by someone who---in spite of the "standards" that have built up around make over the years---has gone off and done his own thing anyway. If you're going to have to deal with custom build code, you may as well own the challenge completely.
Re:Build management: Switching from gmake to Pytho (Score:2)
Erm, make files? Plural? Well, there's your problem...
I forget where, but there is a paper somewhere on the dangers of recursive make, advocating a single makefile instead (with a few includes). And they have a point.
I'm all for replacing Make, but performance isn't the reason.
Re:Build management: Switching from gmake to Pytho (Score:2)
Some of the modules don't need makefiles either.
Those modules are to be packaged in their own separate packages (RPM or whatever).
In the end it just seemed easier to let people handle their own makefiles (with certain limits) for their stuff, assuming of course if makefiles are necessary.
The last I checked FreeBSD used to use some perl scripts to help build its stuff.
Re:Build management: Switching from gmake to Pytho (Score:2)
I'm not advocating makefiles, just saying that the complaint of performance, in particular, isn't relevant.
(Oh, and you can always have different files -- include files and such. But including them is fundamentally different than a recursive make.)
Re:Build management: Switching from gmake to Pytho (Score:2, Interesting)
Apparently some people even have it as their CLI of choice, so I may be missing something, but I've been unable to pry out of them what the secret is.
Re:Build management: Switching from gmake to Pytho (Score:2)
Re:Build management: Switching from gmake to Pytho (Score:2)
If we'd been writing a make process on a brand new project, reading up on scons and understanding the structure it places upon your build process would have been a better choice. As it stands, we had a very specific plan, we could see it fairly clearly in "straight-line" python, and the instant scons's requirements got in the way we tossed it overboard and forged ahead.
tools for the task (Score:4, Interesting)
First off, let me say that I love both Perl 5 and Python 2.x and have used each of them on a wide diversity of projects. I've implemented my own OO system on top of each, I've used each for CGI, I've used each for AI, natural language processing, and game programming. Both languages have their idiosyncratic idioms and it's really annoying when you see a lot of C-ish code in either Perl or Python projects. It's also very possible to write ugly "write once" code in either one, don't be misled by the whitespace arguments: ugly code is about how you express (or fail to express) a problem and a solution.
However, I have to say, pick the tool for the job. There are things that are more naturally expressed in Perl idioms than in Python idioms. There are things that are much more clear and direct about Python code for outsiders to read and understand. If I were doing a ton of regex text scanning work, Perl incorporates it into the language directly, whereas it's a bolt-on for most other languages. If I were doing a ton of object management, I like the compactness of Python's syntax over that of Perl's. Both have great extensibility but the available extensions and support can shape your choice for a given project. I wish Python had true equivalents to Perlmonks and CPAN; conversely I wish CPAN modules were more crisp and consistent, attributes I think I find in the community-written Python modules I've used.
Re:tools for the task (Score:2)
That's why Ruby is nice, it's as readable as Python but it has regex included (of course if you use overcomplicated regex in your code the readability will suffer, but that's not a language issue).
Re:tools for the task (Score:2)
Just curious, are you talking about having to "import re" in Python instead of just having regex support by default, or is there something significant lacking in Python's regex support? (Not trolling, it's just nice to have some additional information about the differences in the languages)
Re:tools for the task (Score:2)
The need to import a library isn't a big deal, but Ruby's core support isn't just support functions "included by default", its also a simple literal syntax available and perl-style magic variables related to regexs. Now, I'm not too fond of the magic variables, but the magic variables are probably convenient to people coming from Perl, and the literal syntax is a convenience if you are using regexs a lot.
So you can test a string against a regexp with something like:
And get nil if there is no match, and the index of the start of the match if there is one. In Python, you get the same with something like:
re.search(pattern, string).start
Re:tools for the task (Score:2)
Just curious - in what way is the Cheeseshop not equivalent to CPAN? Not as many Python eggs as CPAN modules, of course, but otherwise I easy_install as easily as I ppm. Or maybe you mean something else?
Questionable methodology (Score:2)
Put another way, the number of people looking up information on a language X != the number of people programming in language X.
Never let reality temper imagination
Re:Questionable methodology (Score:2, Insightful)
Just Say No! (Score:3, Interesting)
...any language where the author thinks lambda is "too confusing" and should be removed is doomed from the start.
You, Sir, are stupido. (Score:2)
I'd say your plan to get all smart-assy on Python backfired big time.
Re:You, Sir, are stupido. (Score:2)
Except that he isn't limiting how you can program in Python. lambdas are still in Python 3 [python.org] if you really want to use them. But for most applications of lambda in Python, list comprehensions are superior. They're not only easier to read, but also provide better performance.
Considering the vast gulf of language flexibility between Python and actual "bondage and discipline" languages such as Pascal or OCaml, the notion it should be counted among them is difficult to take seriously.
double stupido (Score:2)
MMO written in Python. (Score:2)
First time I realized that was about 3 days after installing the game and seeing all kinds of familiar extensions in cache and library directories. Fun stuff
Re:Hmmm (Score:3, Funny)
Mamama!!!! Make the bad man go away, please.
Re:Hmmm (Score:4, Interesting)
What's up with all the PHP haters on Slashdot? For building most web applications it's the place to be. Zend is working hard to increase the level of professionalism of the PHP community. I've recently started using Zend Framework [zend.com] and it's a really nice way to build web applications.
Re:Hmmm (Score:3, Insightful)
Re:Hmmm (Score:4, Insightful)
Re:Hmmm (Score:5, Informative)
I'm not a troll, just wondering why there's so much bashing of PHP on Slashdot. I am aware of many of the criticisms of PHP. One of them you mentioned:
You'll see that I partly addressed that criticism with my "Zend is working hard to increase the level of professionalism of the PHP community" statement. I'm not going to go into a full length defense of PHP but if you are looking for such a defense I would suggest 10 PHP Myths Dispelled [jaybill.com]. I am not a PHP zealot, I just have a lot of experience with it and would prefer to build web applications using PHP over the alternatives that I've tried (Java/JSP, ASP.NET). I can't compare it to RoR or Python since I have tried neither. I've read about both and have seen nothing compelling to make me consider switching. I'm quite productive developing in PHP and am quite aware of both it's advantages and criticisms.
All languages are bashed on /. (Score:4, Insightful)
The truth is, the people that really are programming and solving problems rarely rant about a PL without having tried it. PHP is an extremely n00by-friendly programming language - also because of it's wide availability - and thus lots of code in PHP is quite wacky actually. This falls back on to the PL itself. Flash/ActionScript has simular problems (aside from having a strong prorpietary touch to it).
In the end PHP, with its neighbourhood to markup, is the web-eras basic. With way more succesfull and impacting open-source web applications than any other solution - Python included.
I *am* a Python fan, but it just didn't have that critical mass of an install base back then when mod_php gained traction. And that the true King and ruler of all webkits, Zope, has had a backend that looks like shit for 7 years now didn't help it either. Nowadays nobody gives a hoot if Zope is lightyears ahead of Rails and a few years older - it's just a niche webkit for people who've bumped into it
There are a lot of factors that make a language successfull, and PHP meets very many of those. Just because people rant about it doesn't mean it really is bad. Nobody I know would say that programming in C is really fun and modern and hip. And many people rant about it. Yet look how many mission critical work still is done with it - because the untested alternatives aren't any better.
On the server-side I've been mostly doing PHP for last 3 years now and am now going totally OOP with the CakePHP Framework and a large international project. It works, is extremely neat and quick to develop with. So be it that PHP has a few bizarly named core functions and arrow->syntax. So *fucking* what? My friend who has a business aswell and is a Sun partner and Java fanboy just moved his webproject from Java to PHP so they could finish it faster.
"Java Fanboy speeds up project by switching to PHP" - enough said.
Slashdotters rant a lot, but reality is allways a tad different.
Re:Hmmm (Score:2)
I'd be satisfied if they just worked to improve the damn language.
no_i_really_mean_it_mysql_really_escape_strings()
Re:Hmmm (Score:3, Informative)
Re:Hmmm (Score:2)
There are people who use PHP with proper modularization, but most of what people see isn't done that way. In a language that's largely used for Open Source software, the state of the code in those OSS projects will be what the language is based on, fair or not.
Re:Hmmm (Score:3)
I tried PHP out for a while a couple years ago. Quite a lot of useful libraries, but the language itself didn't seem to offer much. For just gluing together the existing libraries with minimal new code, it seemed to quite usable (and a lot of web development might get by with that), but it seemed a lot less nice when there was more processing involved. Maybe I just didn't get it, or maybe its improved since then...
Why? Sure, it featured neat embedding in HTML before there were Python or Ruby templating engines that used Python or Ruby in HTML, but why would it be preferred now, for a new, ground-up web application, besides familiarity to the developer? (I'm not trying to be argumentative, just looking for perspectives on "why PHP?")
Re:Hmmm (Score:2)
A few of the reasons:
Re:Cute but (Score:2)
TFA said:
Young Indiana Jones said:
Re:Hmmm (Score:5, Funny)
Man, you take this stuff seriously. Changing your name is hardcore.
Re:Bout Time (Score:2, Insightful)
Re:Bout Time (Score:5, Funny)
Re:You don't change horses.. (Score:3, Funny)
Re:You don't change horses.. (Score:3, Funny)
What the #!$% are you talking about?!
Re:You don't change horses.. (Score:2)
Re:You don't change horses.. (Score:2)
-- Joke --->
o
/ \
(The symbols I used in the blanked word are all notorious line noise syntax in Perl.)
Re:You don't change horses.. (Score:2)
Re:You don't change horses.. (Score:2)
Aw, shucks. I was all set to post the Python version for you, but tragically it seems someone already beat me to it [slashdot.org].:-)
Re:You don't change horses.. (Score:2)
I guess that's the Perl version. Here's the python version:
Hope that turns out, whitespace has a tendency to get munged...
Re:You don't change horses.. (Score:2)
Re:Reasons to love PYTHON! (Score:2)
Not necessarily. Especially if the application used to view the code is not the same one that the code was written on.
List of annoyances I have with regarding Python and white space:
Re:Reasons to love PYTHON! (Score:3, Insightful)
Personally, I hate tabs. Every editor I use seems to have the tab-stops set differently, and looking at 4-space tab code in an 8-space tab editor is not my idea of fun.
Re:Reasons to love PYTHON! (Score:3, Insightful)
What medium?
That's actually a feature -- it forces everyone to agree on a standard there, and use it.
If, for example, one guy uses tabs and one guy uses spaces, and the tab guy has his tabstop set to 2 or 4, while the spaces guy has left it at 8... well, stuff is going to look weird. Forcing everyone to the same convention is something you should be doing anyway, and I'd rather it happen automatically (by breaking stuff).
Re:Reasons to love PYTHON! (Score:2)
What medium?
This one, for instance, when you use the HTML formatted option.
Here's some code for you, from here [www.amk.ca]:
(Yes, I used slashdot's ecode tag, which fails to preserve the leading spaces even though it is for inserting code snippets)
I am aware that the plain old text option mostly works nowadays, but there are sometimes problems with that as well. A few months ago, it was totally broken as well in this regard.
Countless other forums out there have issues with preserving code formatting, not to mention some web-based chat systems where you might want to paste a code snippet.
If, for example, one guy uses tabs and one guy uses spaces, and the tab guy has his tabstop set to 2 or 4, while the spaces guy has left it at 8... well, stuff is going to look weird. Forcing everyone to the same convention is something you should be doing anyway, and I'd rather it happen automatically (by breaking stuff).
In languages that use delimiters as block and line markers, you can run a code beautifier to standardize the code, and even fix code that is horribly malformatted. If the white space gets screwed up really bad in a python program (line endings are deleted somehow), it will it not only fail to run, it will require a human to go in and unscrew it.
Re:Reasons to love PYTHON! (Score:3, Informative)
It's worth mentioning that, at least in IRC, this [pastebin.com] is the preferred medium. It should work elsewhere, too, and there are scripts to assist in it.
Your point is valid, but I don't believe I should constrain the format of a language because it won't work in some mediums. Should I not include []-bracketed arrays because bbcode might hate them?
Ah, but if the whitespace gets screwed up in a python program, that's equivalent to the bracketing getting screwed up in a C-style program. So the difference is that broken whitespace is not the domain of a code beautifier in Python, anymore than brackets and parentheses are the domain of a code beautifier in just about any language.
Also, code beautifiers are still going to leave some things out of place, particularly comments which are spaced to match the code.
Re:Reasons to love PYTHON! (Score:2)
The bad think about having brackets as syntax and whitespace as just formatting is that it is redundant, and you can produce things that look wrong but are wrong but look right if you don't have something automatically formatting.
Many programming languages lean toward the first factor outweighing the second. Python leans the other way. It isn't objectively one way or the other; which factor is a bigger factor in usability varies from person to person, and group to group.
Re:Reasons to love PYTHON! (Score:2)
Perhaps. But we're really not discussing redundancy in a programming language, we are talking about redundant information in source code. There certainly is the point of view that any redundancy in source code is a "design flaw" (the theory that advocates that code should speak for itself and comments should not be used, as well as the theory beyond Python's whitespace handling, is an example of that.)
Convention is not a feature of the programming language, it is a feature of programming style (similar to conventions) that is irrelevant to the computer processing the source code but intended as an aid to the human reader. To a certain degree (certainly, where it comes to indentation and related formatting conventions) such convention can, in fact, be automatically imposed on code not written to the convention by automated tools. It is no more a language feature than syntax highlighting done by an editor is a feature of the language.
Since the convention is imposed on code for human readability and can be changed without changing the meaning of the code (just as syntax highlighting can be), I disagree. Indeed, the convention is entirely irrelevant to the design of the language, not a flaw in its design.
More accurately, "it is common for people to use a whitespace arrangement that suits their personal tastes and those of their group to show how structure nests in most modern languages."
If its not "real" but convention the relation of whitespace to structure is not part of the language, any more than a conventional arrangement of comments to indicate function preconditions and return types is. If its not part of the language, it clearly can't be a flaw in the language.
No, its not the correct choice. It is a valid choice, and it aims to implement one subjective ideal of programming languages. Personally, I think that if you are going to use that ideal, though, it would be better to enforce a strict and consistent standard at the language level (e.g., "each new block level is indented by four spaces from the previous level") rather than "whatever mix of space and tabs you prefer, but each tab will be treated as if it were 8 spaces", so I wouldn't even say Python has a particularly well-chosen approach even given the guiding principal it has chosen, much less the one-true-correct choice.
Re:Reasons to love PYTHON! (Score:2)
Re:Reasons to love PYTHON! (Score:2)
Re:Reasons to love PYTHON! (Score:2)
For any machine-assisted use in general (yes, indentation is easy to use with a human brain, that's why almost everyone does it even in languages that don't enforce it). Here is an example: in an editor I use, when I close a block in a language that is similar to C syntax, it automatically flashes me for
The editor has no clue that you are ending a block in Python merely because you back-tabbed. You could just be adding a blank line.
Please understand that I don't dislike Python. I'm just pointing out my annoyance with white space as a syntax element.
Re:Reasons to love PYTHON! (Score:2)
Re:Reasons to love PYTHON! (Score:2)
I'm suspicious that you like it because it allows you to quickly check whether your indentation matches your braces That's why *I* like it, at least. Except when I'm writing Python, of course.;-)
Re:Why choose? (Score:2)
Re:Why choose? (Score:2)
Re:Why choose? (Score:2)