Re: [OT] Choosing a scripting language. - Mailing list pgsql-general
From | Marco Colombo |
---|---|
Subject | Re: [OT] Choosing a scripting language. |
Date | |
Msg-id | Pine.LNX.4.44.0310281230400.25502-100000@Megathlon.ESI Whole thread Raw |
In response to | Re: [OT] Choosing a scripting language. ("scott.marlowe" <scott.marlowe@ihs.com>) |
Responses |
Re: [OT] Choosing a scripting language.
|
List | pgsql-general |
On Mon, 27 Oct 2003, scott.marlowe wrote: > On Sat, 25 Oct 2003, Marco Colombo wrote: > > > On Fri, 24 Oct 2003, scott.marlowe wrote: > > > On Fri, 24 Oct 2003, Scott Chapman wrote: > > [...] > > > > I also love the indentation to > > > > differentiate code blocks rather than the junk I'd been used to seeing in > > > > Perl and previous languages. > > > > > > Sorry, that was the one big turnoff for me in Python. Indentation is > > > simple to me, I do it linux kernel style, and don't even have to pay > > > attention to it anymore, it's just automatic for me. I guess I'm just > > > used to doing it the old fashioned way. > > > > I don't get it. If you already indent code, what's the problem with > > Python? Python _requires_ correct indentation, > > No, it RELIES on it. I.e. code blocks are marked out by how you indent. > I.e. it doesn't look for block markers, then make sure indentation is > right, it uses the indentation to show it where code blocks are. > > The fact that tabs are parsed as 8 spaces by Python, when many editors are > set to render them as 4 or 6 makes it quite possible to have a file that > looks like it should run but doesn't. I'll take good old {} anyday. > > Just do a google search for "python whitespace tabs" and you'll get about > 7820 results back... (most are totally unrelated BTW - like string.strip() manual) Only broken editors display ascii 09 (hardware tab, HT) as 4 or 6 spaces. Any serious editor can tell the difference between a HT and "softtabs" (what happens when you hit the 'TAB' key). Even vi. People may be used to broken editors, it's their problem. I think everybody wants his code to be correctly displayed by cat, more, less, type, notepad, _insert your favorite text viewer_, any printing system (from cat file > /dev/lp, to text2ps converters) WITHOUT having to learn how to change the standard meaning of HT. HT being considered 8 spaces is not an issue. > > so it's a problem only > > to beginners who don't like indenting (and forces them in doing > > the Right Thing). If indentation is automatic for you, you're already > > doing it the Python way. > > Not exactly. I still prefer being able to do simple: > > if (something) do one thing; constructs ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Oh, now I see your problem. You have never actually used python. B-) I used to agree with you, just writing a few small scripts (expecially learing GTK and converting C examples from the GTK tutorial to python on the fly) made me change my mind. You'll hardly need "dirty tricks" like the one you're showing below (which I do use in PHP/C/...). Python code is very clean. And BTW: x = 4 if x > 3: print "Yes!!" it's a perfectly valid python program. > Or put in debug lines that ARE NOT indented so they're easier to see: > function test(var1){ > # delete this test var when testing is done > $test_var = "set"; > start of code... > } > > without worrying about the parser complaining about white space. > > Indentation is for ME, not the parser. Having it count as the block > marker just feels wrong to me. I'm not even sure I can explain why > completely, but my above points are just one small part of it. > > I agree with you on using the right tool for the job. Except Perl. > The more I use other languages, the less I want to use Perl. Maybe it was > a bad experience as a junior developer long ago with it or something :-) Once I've even wrote a small python program which produces a perl script and runs it. The combination of 2 tools sometimes it's better than one tool only. B-) Sometimes what I need is just "awk on steroids". While Perl is more than just that, I find that it's perfect for me in replacing awk. Just read 'man perlrun': Perl is very strong in supporting commandline processing. Try and do the same in any other language, with less keystrokes: find / -print0 | perl -ln0e 'print if -p' (process a \0 separated list of filenames, filter only named pipes, output a \n separated list of filenames). .TM. -- ____/ ____/ / / / / Marco Colombo ___/ ___ / / Technical Manager / / / ESI s.r.l. _____/ _____/ _/ Colombo@ESI.it
pgsql-general by date: