POV-Ray : Newsgroups : povray.off-topic : All bow to the mighty Python Server Time
4 Sep 2024 23:22:12 EDT (-0400)
  All bow to the mighty Python (Message 15 to 24 of 84)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Warp
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 07:27:20
Message: <4bcee117@news.povray.org>
Gilles Tran <gil### [at] gmailcom> wrote:
> Same experience here. I guess that's because it's easier to miss a semicolon 
> or a brace in PHP than a whitespace in Python. I had to program in Python 
> for a few days last year. At first I had the same WTF reaction as Warp about 
> indentation but I found it much less error-prone in that respect than PHP. I 
> like PHP, but its unability to cope with missing stuff is a time sink, as it 
> outputs anything from a blank page to hebrew (unexpected 
> T_PAAMAYIM_NEKUDOTAYIM).

  If you keep having that problem with PHP, just use a smart editor which
autoindents your code. If the autoindentation goes haywire, you know that
you are missing some semicolon or brace.

-- 
                                                          - Warp


Post a reply to this message

From: Warp
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 07:29:42
Message: <4bcee1a6@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> Warp wrote:
> >   Also autoindentation of Python code is a physical impossibility.

> No it's not.

  Exactly how does the editor know where a block starts and where it ends,
unless it's *already* indented? How can you talk about autoindentation, if
it requires for the code to be already properly indented to begin with?

  Clearly your definition of "autoindentation" is not the same as mine.

>   Replacing indentation in python once the dedents have been 
> lost is problematic. But that's like complaining if you delete all the 
> closing braces in C then you can't figure out where to put them back.

  No, it's not. Why not? Because whitespaces at the beginning of lines are
a lot easier to lose than braces.

-- 
                                                          - Warp


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 08:42:44
Message: <4bcef2c4@news.povray.org>
Darren New wrote:
> Warp wrote:
>>   Also autoindentation of Python code is a physical impossibility.
> 
> No it's not.   Replacing indentation in python once the dedents have been
> lost is problematic. But that's like complaining if you delete all the
> closing braces in C then you can't figure out where to put them back.
> 
> But making all the indents a consistent amount?  Pretty easy.

Also, many text editors automatically indent one more level after a line 
finishing with a colon. I'd call that "autoindentation".


Post a reply to this message

From: Invisible
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 08:50:20
Message: <4bcef48c@news.povray.org>
>> Actually it's pretty logical. You might argue that requiring the 
>> programmer to manually type a semicolon at the end of each line when 
>> it's obvious that each line is a seperate statement is illogical.
> 
>   You don't type a semicolon at the end of each line. You type it at the
> end of each statement. There may be more than one statement in a line, or
> a statement may be split into several lines, and for example function
> definitions are not ended with a semicolon.

Sure. But in reality, almost everybody writes one statement per line. 
Sometimes you might put several on a line, but usually it's just one.

(Again, I can't comment on Python, but in Haskell you *can* in fact 
still put multiple statements on a line, or spread one statement over 
several lines. It's really not stopping you from doing that.)

>   Anyways, semicolons are seldom lost when you post a response to an online
> blog post.

Granted.

>> The only real problem with using whitespace is that it tends to get 
>> mangled in emails, forum posts, etc.
> 
>   Some editors also might convert spaces at the beginning of lines to tabs
> (or the other way around) if you are not careful with the settings. This
> doesn't really matter with normal programming languages.

I have never seen any text editor ever that converts spaces to tabs - 
although I've seen loads that convert tabs to spaces. Which is really 
fun when editing Makefiles, since they have this braindead idea of 
having tab characters as part of the required syntax. :-P *That* is idiotic.

>> And to think that I do all my programming with an editor which doesn't 
>> give me syntax hilighting *or* automatic indentation...
> 
>   Why?

Becuase no editor in existence can syntax hilight Haskell?

> Try some editor which is able to color your code, use it for a few
> weeks, and you'll never switch back.

I use a text editor which does support syntax hililghting, auto-indent 
and a bunch of other things for XML, CSS, PostScript, TeX, JavaScript 
and more. It just doesn't support Haskell, that's all. While it's nice 
to have syntax hilighting and so on, it's hardly essential. I don't 
really miss it all that much.

>   It naturally depends on the specific language, but with some languages
> syntax highlighting and autoindentation actually help to catch typos as
> you are writing your code.

Sure. If you type "fro" instead of "for", it doesn't show up in bold. If 
you're using an IDE rather than a mere text editor, it may even show you 
mistyped identifiers. I get that.

> For example, if emacs starts autoindenting in
> a completely crazy way, I immediately know that there's a typo somewhere
> (maybe a missing curly bracket or semicolon).

You're saying "if it indents wrong, you've missed a delimiter". I'm 
saying "if you indent it right, that's your delimiters". In a language 
that uses whitespace delimiters, it's much harder to miss one in the 
first place. (I will admit that it's very occasionally non-intuitive, 
and just sometimes you'll see code that doesn't compile because of an 
obscure spacing issue. But it's quite rare.)

>> (Then again, I've yet to see an editor with auto-indent which actually 
>> indents stuff the way that *I* want it to, rather than the way the guy 
>> who wrote the editor wants it to.)
> 
>   In many advanced editors you can configure how the autoindentation works.
> For example emacs has quite a lot of configuration options. (Of course that
> doesn't mean it's *easy* to configure.)

As you probably remember, I've never had much luck with either Emacs or Vi.

(Besides, Emacs isn't a text editor, it's an operating system! :-P )

>   It's just really handy when a line is wrongly indented, I just press tab
> (regardless of where the cursor is on that line currently, and regardless
> of whether the line was indented too much or too little), and emacs indents
> it just like I want.

That does actually sound quite nice. I've never seen an editor which can 
actually do that.


Post a reply to this message

From: Warp
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 09:26:22
Message: <4bcefcfd@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> >> And to think that I do all my programming with an editor which doesn't 
> >> give me syntax hilighting *or* automatic indentation...
> > 
> >   Why?

> Becuase no editor in existence can syntax hilight Haskell?

  I don't think that's true. http://www.haskell.org/haskell-mode/

> > Try some editor which is able to color your code, use it for a few
> > weeks, and you'll never switch back.

> I use a text editor which does support syntax hililghting, auto-indent 
> and a bunch of other things for XML, CSS, PostScript, TeX, JavaScript 
> and more. It just doesn't support Haskell, that's all. While it's nice 
> to have syntax hilighting and so on, it's hardly essential. I don't 
> really miss it all that much.

  Maybe it's because you program mostly in Haskell and not those other
languages?

> > For example, if emacs starts autoindenting in
> > a completely crazy way, I immediately know that there's a typo somewhere
> > (maybe a missing curly bracket or semicolon).

> You're saying "if it indents wrong, you've missed a delimiter". I'm 
> saying "if you indent it right, that's your delimiters".

  Indenting is easier when the editor does it for you.

-- 
                                                          - Warp


Post a reply to this message

From: Warp
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 09:27:29
Message: <4bcefd41@news.povray.org>
Nicolas Alvarez <nic### [at] gmailcom> wrote:
> Also, many text editors automatically indent one more level after a line 
> finishing with a colon. I'd call that "autoindentation".

  If that's the only situation where it can, I wouldn't call it that.

-- 
                                                          - Warp


Post a reply to this message

From: Invisible
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 09:36:20
Message: <4bceff54$1@news.povray.org>
>>>   Why?
> 
>> Becuase no editor in existence can syntax hilight Haskell?
> 
>   I don't think that's true. http://www.haskell.org/haskell-mode/

So... that's Emacs then?

Perhaps I should rephrase my statement... uh... No easily usable editor 
in existance can syntax hilight Haskell. How about that?

>   Maybe it's because you program mostly in Haskell and not those other
> languages?

More likely it's because Haskell is the kind of language which is quite 
easy to work with even without hilighting and other frills.

>> You're saying "if it indents wrong, you've missed a delimiter". I'm 
>> saying "if you indent it right, that's your delimiters".
> 
>   Indenting is easier when the editor does it for you.

Well, maybe. Besides, my editor does some of the work for me; each line 
is indented the same amount as the previous one, which is what you want 
the majority of time. If for some reason I'm forced to use Notepad, I 
really *really* miss this!


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 09:41:29
Message: <4bcf0089@news.povray.org>
Warp wrote:
> Nicolas Alvarez <nic### [at] gmailcom> wrote:
>> Also, many text editors automatically indent one more level after a line
>> finishing with a colon. I'd call that "autoindentation".
> 
>   If that's the only situation where it can, I wouldn't call it that.

Where *else* would you need to increase the indentation?


Post a reply to this message

From: Warp
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 10:01:17
Message: <4bcf052d@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> More likely it's because Haskell is the kind of language which is quite 
> easy to work with even without hilighting and other frills.

  At least if you remember the five million standard library function
names by heart and hence can easily distinguish between standard library
calls and other function calls... (a task made easier by the fact that the
names are usually short, non-descriptive, and lack any kind of standard
naming convention or namespace).

-- 
                                                          - Warp


Post a reply to this message

From: Warp
Subject: Re: All bow to the mighty Python
Date: 21 Apr 2010 10:03:27
Message: <4bcf05af@news.povray.org>
Nicolas Alvarez <nic### [at] gmailcom> wrote:
> Warp wrote:
> > Nicolas Alvarez <nic### [at] gmailcom> wrote:
> >> Also, many text editors automatically indent one more level after a line
> >> finishing with a colon. I'd call that "autoindentation".
> > 
> >   If that's the only situation where it can, I wouldn't call it that.

> Where *else* would you need to increase the indentation?

  There are many situations where you need to re-indent code, either deeper
or shallower (and not always every line the same amount). And not only when
you want to end a code block in Python.

-- 
                                                          - Warp


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.