LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Perl or Python ? (https://www.linuxquestions.org/questions/programming-9/perl-or-python-828635/)

Sergei Steshenko 08-29-2010 09:58 AM

Quote:

Originally Posted by ghostdog74 (Post 4081225)
that's hell ugly, but that's your business and i don't care.
...

Indentation of 'break' in the URL above looks hell ugly to me.

Sergei Steshenko 08-29-2010 10:21 AM

Quote:

Originally Posted by ghostdog74 (Post 4081225)
... I am only saying some ways "beat around the bush" (not obvious) to get to the solution, while some is straight to the point (and the best way). ...

People often ask questions in this forum not reading any documentation at all. I.e. the core problem is not obvious/non-obvious, it is not knowing any way at all.

ghostdog74 08-29-2010 08:11 PM

Quote:

Originally Posted by Sergei Steshenko (Post 4081461)
People often ask questions in this forum not reading any documentation at all. I.e. the core problem is not obvious/non-obvious, it is not knowing any way at all.

the core problem is, you, actually, for not understanding the whole point of our "discussion". this is last post of mine having to deal with this topic in this thread.

TIMTOWTDI is good since you can have more choice, BUT will lead to inconsistencies and sometimes problems that can be solved in the most obvious way become messy and obfuscated. This will happen in any language that follows this philosophy, not just Perl.

Sergei Steshenko 08-29-2010 08:46 PM

Quote:

Originally Posted by ghostdog74 (Post 4081823)
...
TIMTOWTDI is good since you can have more choice, BUT will lead to inconsistencies and sometimes problems that can be solved in the most obvious way become messy and obfuscated. This will happen in any language that follows this philosophy, not just Perl.

But Python does have this philosophy too, for example:

http://www.ibiblio.org/g2swap/byteof.../for-loop.html
http://floppsie.comp.glam.ac.uk/Glam...ipting/19.html

- both 'for' and 'while' loops exist, though conceptually only 'while' loop is necessary.

ghostdog74 08-29-2010 09:31 PM

Quote:

Originally Posted by Sergei Steshenko (Post 4081839)
But Python does have this philosophy too,

yes and not just Python. Every other languages as well. However, Python philosophy encourages this:

There should be one-- and preferably only one --obvious way to do it..
Read it carefully. If you don't understand English, look up the dictionary or thesaurus.



Quote:

- both 'for' and 'while' loops exist, though conceptually only 'while' loop is necessary.
That is true for every other languages that support these 2 kinds of loops. So what's really your argument here? Do you want to say that long time ago, the functions of these 2 loops should be merged? And that programming languages should remove all for loops and let programmers use while loops only ? for and while loops have been in existence for many generations and its not the argument here of whether or not we should do away with one and use just the other.

Let me fill you in if you are still clueless.
Can you please look at my argument again on why Perl encourages inconsistencies. See post #17. I can find you some more in perlsyn: different ways to write for loops in Perl

Code:

for ($i = 1; $i < 10; $i++){ }
 for (@ary) { s/foo/bar/ }
 for my $elem (@elements)
 foreach $item

Now, in Python, the consistent(obvious) way to write a for loop has always been

Code:

for ( ... ) in ( ... ):

My illustrations support my point that TIMTOWTDI is good sometimes, as you can see from the Perl's different for loop syntaxes that programmers can have choices. But because of this, code is inconsistent. Lastly, its not just Perl , but any other languages with TIMTOWTDI philosophy will encounter this "issue". You may disagree for all i care, but that's how it is


Its just one of my observation with regard to "TIMTOWTDI" after using Perl and Python for so many years. You don't have to really get so heat up with me about this.

Now, can we stop?

Sergei Steshenko 08-29-2010 09:52 PM

Quote:

Originally Posted by ghostdog74 (Post 4081864)
yes and not just Python. Every other languages as well. However, Python philosophy encourages this:

There should be one-- and preferably only one --obvious way to do it..
Read it carefully. If you don't understand English, look up the dictionary or thesaurus.
...

I hopefully understand English. I just know that the word "obvious" means different things to different people.
...
Look into C++ 'boost' library - IIRC they've implemented FOREACH a-la Perl - because people like it. I.e. people like to be able not to deal with numeric index while iterating over array.

At all, look at other than Perl/Python languages - and then you will see that Perl simply borrowed a lot of ideas from them. For example, 'maxima' has a notion of current expression/variable:

Code:

__ is the input expression currently being evaluated. That is, while an input expression expr is being evaluated, __ is expr.
...
_ is the most recent input expression (e.g., %i1, %i2, %i3, ...).
...
% is the output expression (e.g., %o1, %o2, %o3, ...) most recently computed by Maxima, whether or not it was displayed.
...
 %%

    In compound statements, namely block, lambda, or (s_1, ..., s_n), %% is the value of the previous statement.

, so Perl's $_ and loops (not)based on it are so minor :). Or, let me put it another way - after 'maxima' (which in its term is heavily based on LISP and is implemented in it) what Perl does looks so obvious.


All times are GMT -5. The time now is 05:33 PM.