6 ms·
> Python is the best language in the world for interacting with the web, and I'm going to show you why. I disagree. I didn't need to read it, but I did, and I
by benatkin 15y ago
> Python is the best language in the world for interacting with the web, and I'm going to show you why.
I disagree. I didn't need to read it, but I did, and I still feel that way.
The statement says language, but the actual points made are about the libraries and the community (i. e. the ecosystem).
I think the ruby ecosystem is actually better, for a few reasons:
* Deep integration with JavaScript (ExecJS and TheRubyRacer are way ahead of what is available in Python, Perl, and PHP)
* Many different excellent choices for talking to HTTP APIs, including the highly innovative Faraday
* A top-notch JVM implementation (JRuby has had more traction than Jython over the last five years)
* Lots of good auth libraries: OAuth (for authenticating with a plethora of outside services), Devise (pre-built auth with confirmation emails, password resets), and OAuth2 provider (server) implementations
* Ruby has evented programming too. Goliath is pretty good.
Python is great but I take issue with saying that it's the best web dev language out there.
- pyre 15y agoIt also depends on what you need to do with the web. Perl is currently the best language for interacting with Unicode, for example. If you web needs include Unicode, you might have trouble with Ruby or Python, unless you're willing to accept half-ass, partial, or just plain wrong Unicode implementations.
- ashrust 15y agoI agree, I love Python but I've spent untold hours dealing with its unicode issues.
- codygman 15y agoEverything unencoded is unicode in 3 isn't it?
- lloeki 15y agoStrings are unicode. Bytes are encoded data. With Python 2 strings you have to be proactive about it and - always use u"" unless you know what you're doing - segregate non-unicode data to boundaries by decode()ing early and encode()ing late, or you're guaranteed to shoot yourself in the foot sooner or later but if you do it it's quite smooth sailing. Also, #/usr/bin/env python # -*- encoding: utf-8 -*- helps a lot. All that just brings you closer to Python 3 anyway and really helps when using 2to3.
- ashrust 15y agoAgreed, however I've run in to compatibility issues with 3 a few times and so resolved to stick w/ 2, deal with the text parsing issues myself, keep the libraries I like and leave the ops team alone.
- petercooper 15y agoRuby's character encoding and Unicode support is pretty strong. I'm intrigued how you think it's half-ass, partial or just plain wrong (Really! If there's something really borked with it, it's in my interest to know :-)). Every string has full encoding support and it's baked right in to the language.
- pyre 15y agotchrist's OSCON Unicode talks: http://98.245.80.27/tcpc/OSCON2011/index.html http://98.245.80.27/tcpc/OSCON2011/index.html Specifically the third talk: http://98.245.80.27/tcpc/OSCON2011/gbu.html http://98.245.80.27/tcpc/OSCON2011/gbu.html http://98.245.80.27/tcpc/OSCON2011/gbu.pdf http://98.245.80.27/tcpc/OSCON2011/gbu.pdf Excerpts: Its String functions like upcase or capitalize won’t even look at anything but ASCII. It’s completely missing a whole lot of critical Unicode functionality: casemapping & -folding grapheme support normalization collation text segmentation, &c &c &c. Every Ruby string carries around its encoding, instead of sanely unifying into Unicode internally like nearly everything else does. Also: > baked right in to the language is not synonymous with "intelligently implemented" Note that I wasn't implying that "half-ass," "partial," and "just plain wrong" necessarily all apply to Python and/or Ruby's implementations. Some may apply to some areas while others may not, and really this extends outside of just Python and Ruby, but I'm trying to stay in context here.
- petercooper 15y agoThis is interesting stuff - thanks for sharing, I'll be checking it out. The upcase/downcase stuff definitely checks out so far :-)
- minikomi 15y agoAs someone building websites using ruby & dealing with Japanese, I have to agree.. incompatible character encodings: UTF-8 and ASCII-8BIT gets pretty tiresome! Using 1.9.2 at least you have .force_encoding ... feels pretty wrong but sometimes it's just needed to get the job done..
- kreek 15y agorequire 'net/http' Net::HTTP.get_print 'www.gun.io', '/' That's it! In only two lines of ruby, you can grab a whole webpage and print it to the screen. Awesome! - and it's in the standard lib ;) I agree, when I left PHPland I chose Ruby over Python because the (web) community was larger, there were just more books, blogs, screencasts, etc for Ruby/Rails. There seems to be more ideas generated out of the Ruby community, I'd add Sinatra and HAML to the list above, like Rails they've both been ported to other languages. OF course Heroku was Ruby first and it's so good that my PHP/Java/Python friends jumped for joy when their language became supported.
- anthonyb 15y agourllib is in Python's standard library: import urllib the_page = urllib.urlopen("http://www.gun.io/") print ''.join( the_page.readlines() ) I could jam it all into one line, but in Python we prefer readable code ;) ;) The Python community also tends to be quieter than those raving Ruby fanbois - if you'd said appeared to be larger, then I would have agreed with you...
- elithrar 15y agoPythonistas should look at the "Requests"[1] lib for Python mentioned here on HN[2] a few days ago, too. [1]: http://docs.python-requests.org/en/latest/ http://docs.python-requests.org/en/latest/ [2]: http://news.ycombinator.com/item?id=3094695 http://news.ycombinator.com/item?id=3094695
- pjscott 15y agoThere's still room for improvement in both of them, too. If you want to have a lot of connections open, you have to choose between lots of threads with blocking I/O, or using event-driven I/O, or using some kind of magical light-weight cooperatively multitasked greenlet/fiber thing. As Erlang and Haskell show, it's totally possible to combine an event-driven I/O subsystem with lightweight user-space preemptive multithreading that supports a huge number of threads, takes advantage of multiple cores, and doesn't need to worry about blocking-vs-nonblocking magic. I would love to see that in a more mainstream language.
- anacrolix 15y agoI agree. Concurrency is a huge problem with mainstream languages.
- draegtun 15y agoDeep integration with JavaScript (ExecJS and TheRubyRacer are way ahead of what is available in Python, Perl, and PHP) There are a lot of libraries to check out on each language before you can make that claim! Here for example are just some of the Javascript libraries on CPAN: * JavaScript (SpiderMonkey) - https://metacpan.org/module/JavaScript https://metacpan.org/module/JavaScript * JavaScript::SpiderMonkey - https://metacpan.org/module/JavaScript::SpiderMonkey https://metacpan.org/module/JavaScript::SpiderMonkey * JavaScript::V8 - https://metacpan.org/module/JavaScript::V8 https://metacpan.org/module/JavaScript::V8 * JE (Pure Perl JS engine)- https://metacpan.org/module/JE https://metacpan.org/module/JE * JSPL (SpiderMonkey) - https://metacpan.org/module/JSPL https://metacpan.org/module/JSPL
- Dalves 15y agoI wouldn't count the need for a good JVM implementation as a plus mark in a Ruby vs Python comparison. Jython is used when you need to interact with Java libs, not because the C implementation of Python language is slower than the JVM one. The same does not apply for Ruby, you use JRuby because it's better than CRuby. If you want to compare speed you'd be up against pypy.
- bad_user 15y agoYour statement sounds like sour grapes to me. When a language has multiple viable implementations, it means the language has a good specification. It also means that it doesn't depend too much on platform-specific characteristics. It means it is more portable. Python is both blessed and cursed with a couple of problems ... its behavior is sometimes related to the CPython implementation (e.g. reference counting, __del__), and also some libraries are too big and important to live without them. One such library is NumPy. Currently you cannot talk about an alternative Python implementation if you don't have NumPy running on it, and that's a fact. I'm a Python developer in my day job and I never used Pypy for anything. I only played with it and became frustrated that libraries I relied upon don't work on it. Btw, if you're a fan of Pypy, checkout http://rubini.us/ http://rubini.us/
- jamesgeck0 15y agoWeb developer here; I live without NumPy all the time. :)
- ubernostrum 15y agoMy cranky old age is going to show here, but... Python or Perl, all the way. Both have a long history of "standard" modules for common cases and well-maintained (if not "standard") modules for alternative approaches to the common cases, or for the uncommon cases. More importantly, both languages have a well-established culture of boringness. This is a quality I actively look for, because it tells me someone wrote code to solve a problem, not because it was the hip thing to do.