GO vs Python

Chris Angelico rosuav at gmail.com
Mon Aug 25 05:48:06 EDT 2014


On Mon, Aug 25, 2014 at 6:01 PM, Rustom Mody <rustompmody at gmail.com> wrote:
> On Monday, August 25, 2014 9:11:39 AM UTC+5:30, Chris Angelico wrote:
>
>> Sure. And your reduction of AWS bills sounds great. Just make sure you
>> don't consume the entire extra coder's time doing things that Python
>> would have done for you. Go's character model is inferior to Python
>> 3's (or at least, it was last time I checked - stuff might have
>> changed since then), so you may find yourself doing a lot of
>> unnecessary work to make sure your code works correctly. Do be sure to
>> test everything thoroughly, with characters from all over Unicode.
>
> Heh! You make it sound that the character model is the most important thing
> in choosing a language!
> There are people using Fortran -- with not intention of finding
> an alternative.

Heh. Well, in some ways, it is. When you advise someone on how to
choose a car, do you say "Make sure you get one with wheels"? No. You
assume it. There are far more important aspects to a programming
language, but most of them are fairly obvious (and often universal).
Also, if someone's trying to decide between C (manual memory
management, compiled, detaily) and Python (garbage collected, high
level), he'll know the issues. I'm referring here to something that
might be a surprise way down the track.

Let's take a concrete example. You want to build a database-backed
dynamic web site. You could use PHP and MySQL, and a few years ago
that would be your only option if you want cheap web hosting. Or you
could use Python and PostgreSQL, tying in with Passenger to manage
stuff under Apache. Or you could write an entire HTTP server in Python
(using http.server or BaseHTTPServer, perhaps), putting it on a
dedicated IP or port. Or you could probably craft something horrendous
out of bash scripts, massive pipelines, and some command-line tool
that binds to a port (I know you can use /dev/tcp/hostname/port to
connect, not sure how you'd listen). If someone asks you for advice,
what aspects of each would you highlight? Obvious stuff doesn't need
to be mentioned (like "PHP uses braces, if you hate braces then use
Python", and "doing it all with bash pipelines is Just Plain Dumb"),
and what you need to say is stuff like "Doing it with http.server will
limit you to one CPU core" and "Doing it with PHP means you don't get
Unicode support".

So yes, I think it was the most important thing to mention, because
it's something that isn't obvious to a lot of people. You test your
code with stuff you can type, and it works fine. Other people use
non-ASCII characters, and nearly everything works, but there are just
these occasional glitches (because your code's working with UTF-8
bytes, and every once in a while it counts things differently or
something). Working with bytes instead of characters is one of the
most subtle problems to infect a program, because 99%+ of it works
fine. And properly fixing it is a huge job. That's why it's worth
saying, even if character model isn't actually the one most important
feature of a programming language.

ChrisA



More information about the Python-list mailing list