Re: [dev] What is bad with Python

From: Silvan Jegen <s.jegen_AT_gmail.com>
Date: Wed, 5 Mar 2014 09:29:11 +0100

On Tue, Mar 4, 2014 at 10:34 PM, Szabolcs Nagy <nsz_AT_port70.net> wrote:
> * Silvan Jegen <s.jegen_AT_gmail.com> [2014-03-04 21:30:47 +0100]:
>> On Tue, Mar 04, 2014 at 08:56:18PM +0100, Szabolcs Nagy wrote:
>> > dont expect fast opengl access from go) and you cannot really
>> > use it for quick scripting tasks
>>
>> Why should Go not be suited for quick scripting tasks? I use Go to parse
>> text files, reformat them and/or sending them to restful services. It
>> really works quite well.
>
> eg i have various awk, lua and sh scripts on my router
> to do things, if there is some bug in them i can log in
> to the router and fix them right there or try them on
> another host

I wouldn't use Go (nor Python) on stuff I can reasonably do with awk
or sh either. For a little more involved stuff like processing
JSON/XML files a language like Go fits the bill very nicely though.

> i don't need a cross compiler toolchain for this or
> complicated setup for deploying different binaries
> to different systems

True. You do need the interpreter though which you have to install for
each architecture as well. Instead of the interpreter you could
install the Go toolchain and you wouldn't have to worry about binary
compatibility either.


> (not to mention that a statically linked go executable
> would not even fit on the target and the compiler would
> pedantically complain about unused package imports or
> other issues that does not matter in a single-use script)

You are right in that forcing you to adhere to the engineering
practice Go enforces can be annoying in one-off scripts. I do think
however that this is a very minor issue since deleting an unused line
of code is not really a lot of effort.

As for binary size, it really is not an issue when you work on amd64
servers or desktop computers. On ARM it can be, I assume (though Go
seems to work on the Raspberry Pi reasonably well).


> for me scripting means that you can write one-liners to
> a command prompt or edit a single text file with iterative
> updates and don't need development tools to execute it

I think I my definition of scripting differs somewhat from yours. I
wouldn't write one-liners in either Python or Go for example (I would
use awk, sed and shell).

Iterative updates you get with Go as well since compilation is so
fast. Actually, you can get more 'script-like' behaviour by just
executing 'go run file.go' (running a go script that processes xml and
has a compiled size of 2.6MB that way takes a little less than 1.1
seconds for building and executing which should be quick enough for
iterative development).


> maybe go has a better http library than other languages,
> so you can easily automate such tasks, but that does not
> make it a scripting language imo

I see where you are coming from but Go fits my scripting use cases
just fine. The fact that Go compiles to machine code while giving you
a lot of conveniences that are prevalent in scripting languages
(automatic memory management and type inference when wanted) blurs the
line between scripting/non-scripting language in the best ways.
Received on Wed Mar 05 2014 - 09:29:11 CET

This archive was generated by hypermail 2.3.0 : Wed Mar 05 2014 - 09:36:14 CET