help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Octave's and Matlab's limitations


From: Sergei Steshenko
Subject: Re: Octave's and Matlab's limitations
Date: Wed, 21 Nov 2012 16:45:36 -0800 (PST)






----- Original Message -----
> From: Sergei Steshenko <address@hidden>
> To: Dimitri Maziuk <address@hidden>; "address@hidden" <address@hidden>
> Cc: 
> Sent: Thursday, November 22, 2012 2:02 AM
> Subject: Re: Octave's and Matlab's limitations
> 
> 
> 
> 
> 
> 
> 
> ----- Original Message -----
>>  From: Dimitri Maziuk <address@hidden>
>>  To: address@hidden
>>  Cc: 
>>  Sent: Thursday, November 22, 2012 1:18 AM
>>  Subject: Re: Octave's and Matlab's limitations
>> 
>>  On 11/21/2012 05:08 PM, Sergei Steshenko wrote:
>> 
>>>   Though I agree with you that typically more than one language is
>>>   necessary, there is _nothing_ Matlab/Octave can do and other language
>>>   can't with the same ease or even easier and more elegantly and 
> less
>>>   bug-prone.
>> 
>>  I'm pretty sure you underestimate the hold of matlab notation over
>>  matlab users.
>> 
>>  Sure this:
>>  ''=~('(?{'.('-)@.)@_*(address@hidden@/)(@)@-@),@(@@+@)'
>>  ^'][)@]`}`]()address@hidden@address@hidden@address@hidden@%[').',"})')
>>  scares the crap out of everybody except hardcore perl hackers, but try
>>  weening them off JAPHs.
>> 
>>  -- 
>>  Dimitri Maziuk
>>  Programmer/sysadmin
>>  BioMagResBank, UW-Madison -- http://www.bmrb.wisc.edu
>> 
>> 
>>  _______________________________________________
>>  Help-octave mailing list
>>address@hidden
>>  https://mailman.cae.wisc.edu/listinfo/help-octave
>> 
> 
> I like Perl, and I do not write it this way. The example you gave is unfair 
> in 
> several respects:
> 
> 1) it's a regular expression, which is a language in itself;
> 
> 2) when regular expressions are written in other languages, the typically 
> look 
> even worse - because other languages demand from you escaping, say, quotes. 
> Please see this:
> 
> "
> address@hidden:~/junk> cat -n re_example.pl
>      1  #!/usr/bin/perl -w
>      2
>      3  use strict;
>      4  use warnings;
>      5
>      6  my $s = '"foo bar"';
>      7  warn "\$s=$s";
>      8  $s =~ m|"foo|; # the double quote is _not_ escaped
>      9  warn "\$&=$&";
>     10
>     11
>     12  $s =~ m|
>     13         "foo # I want 'foo' with leading quote
>     14         \s+  # followed by non-zero number of whitespaces
>     15         bar" # followed by 'bar' with trailing quote
>     16         |x;
>     17
>     18  warn "\$&=$&";
>     19
>     20
> address@hidden:~/junk> ./re_example.pl
> $s="foo bar" at ./re_example.pl line 7.
> $&="foo at ./re_example.pl line 9.
> $&="foo bar" at ./re_example.pl line 18.
> address@hidden:~/junk>  
> "
> 
> and try to write it in other languages - most likely you'll have to escape 
> '"'. I remember how _awfully_ regular expressions look in Java, for 
> example.
> 
> 3) Perl has _extended_ regular expressions, so one can comment their parts - 
> see 
> and example on lines #12..16.
> 
> 
> So, poor readability of Perl programs is the result of bad programmers 
> writing 
> it.
> 
> Also, have a look at http://perldoc.perl.org/English.html -> 
> http://perldoc.perl.org/perlvar.html , e.g.:
> 
> 
> 
>     * $PROCESS_ID 
>     * $PID 
>     * $$ 
> 
> ...
>     * $PROGRAM_NAME 
>     * $0 
> 
> 
> , etc.
> 
> 
> 
> So, you can either grab examples from Perl obfuscating contests or learn how 
> to 
> write readable code in Perl - with the 'English' pragma it's even 
> easier; your variables and subroutines names is your choice - Perl doesn't 
> force you.
> 
> ...
> 
> In 
> https://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3/Print_version#Printing
> one can see:
> 
> 
> print("Halt!")
> user_input = input("Who goes there? ")
> print("You may pass, " + user_input)
> 
> - to me is _less_ readable than Perl.
> 
> The parenthesis is a drag; the necessity to use '+' for explicit 
> concatenation is a drag.
> 
> If you read about Python forced indentation, people complain that absence of 
> code blocks syntactic markers (like {...} in Perl/"C") make code 
> refactoring error prone. I even saw an application temporarily adding some 
> kind 
> of markers to Python code in order to make refactoring easier.
> 
> Finally, true closures were introduced only in Python 3 - about 15 years 
> later 
> than in Perl, so Python kinda catches up ...
> 
> 
> Regards,
>   Sergei.
> 
> 
> 
> 
> I found completely unreadable piece of Python code too.
> 
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave



I openly admit I am mostly clueless in Python, so I first look into tutorials 
and then try the code from them. In already mentioned 
https://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3/Print_version#Printing
 I see: 
https://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_3/Print_version#6._Decisions
 .

The piece contains a simple code snippet:

"
address@hidden:~/junk> cat -n print_example.py
     1  n = int(input("Number? "))
     2  if n < 0:
     3     print("The absolute value of", n, "is", -n)
     4  else:
     5     print("The absolute value of", n, "is", n)
address@hidden:~/junk>        
"

and predicts the following output:

Number? -34 The absolute value of -34 is 34 
Number? 1 The absolute value of 1 is 1
.

The predicted output looks normal to me - no quotes, no parenthesis, no commas.




So, I'm trying the code first with self-built Python-2.7.3:

"
address@hidden:~/junk> 
/mnt/sdb8/sergei/AFSWD_debug/20121021/Python-2.7.3/binsh/python print_example.py
Number? -34
('The absolute value of', -34, 'is', 34)
address@hidden:~/junk> 
/mnt/sdb8/sergei/AFSWD_debug/20121021/Python-2.7.3/binsh/python print_example.py
Number? 1
('The absolute value of', 1, 'is', 1)
address@hidden:~/junk> 
"

- the output looks quite differently.



Now with much older Python coming with the OS:

"
address@hidden:~/junk> python print_example.py
Number? -34
('The absolute value of', -34, 'is', 34)
address@hidden:~/junk> python print_example.py
Number? 1
('The absolute value of', 1, 'is', 1)
address@hidden:~/junk> 
".

Now with "she-bang" notation:

"
address@hidden:~/junk> cat -n print_example.py
1  #!/mnt/sdb8/sergei/AFSWD_debug/20121021/Python-2.7.3/binsh/python
2
3  n = int(input("Number? "))
4  if n < 0:
5     print("The absolute value of", n, "is", -n)
6  else:
7     print("The absolute value of", n, "is", n)
address@hidden:~/junk> ./print_example.py
Number? -34
('The absolute value of', -34, 'is', 34)
address@hidden:~/junk> 
".

So, is it a bug or a feature or an outdated tutorial ?
Regards,
  Sergei.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]