
123

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
> bugprone.
I'm pretty sure you underestimate the hold of matlab notation over
matlab users.
Sure this:
''=~('(?{'.(')@.)@_*([]@!@/)(@)@@),@(@@+@)'
^'][)@]`}`]()`@.@]@%[`}%[@`@!#@%[').',"})')
scares the crap out of everybody except hardcore perl hackers, but try
weening them off JAPHs.

Dimitri Maziuk
Programmer/sysadmin
BioMagResBank, UWMadison  http://www.bmrb.wisc.edu_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


 Original Message 
> From: Dimitri Maziuk < [hidden email]>
> To: [hidden email]
> 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
>> bugprone.
>
> I'm pretty sure you underestimate the hold of matlab notation over
> matlab users.
>
> Sure this:
> ''=~('(?{'.(')@.)@_*([]@!@/)(@)@@),@(@@+@)'
> ^'][)@]`}`]()`@.@]@%[`}%[@`@!#@%[').',"})')
> scares the crap out of everybody except hardcore perl hackers, but try
> weening them off JAPHs.
>
> 
> Dimitri Maziuk
> Programmer/sysadmin
> BioMagResBank, UWMadison  http://www.bmrb.wisc.edu>
>
> _______________________________________________
> Helpoctave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/helpoctave>
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:
"
sergei@amdam2:~/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 nonzero number of whitespaces
15 bar" # followed by 'bar' with trailing quote
16 x;
17
18 warn "\$&=$&";
19
20
sergei@amdam2:~/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.
sergei@amdam2:~/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/NonProgrammer%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.
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


 Original Message 
> From: Sergei Steshenko < [hidden email]>
> To: Dimitri Maziuk < [hidden email]>; " [hidden email]" < [hidden email]>
> Cc:
> Sent: Thursday, November 22, 2012 2:02 AM
> Subject: Re: Octave's and Matlab's limitations
>
>
>
>
>
>
>
>  Original Message 
>> From: Dimitri Maziuk < [hidden email]>
>> To: [hidden email]
>> 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
>>> bugprone.
>>
>> I'm pretty sure you underestimate the hold of matlab notation over
>> matlab users.
>>
>> Sure this:
>> ''=~('(?{'.(')@.)@_*([]@!@/)(@)@@),@(@@+@)'
>> ^'][)@]`}`]()`@.@]@%[`}%[@`@!#@%[').',"})')
>> scares the crap out of everybody except hardcore perl hackers, but try
>> weening them off JAPHs.
>>
>> 
>> Dimitri Maziuk
>> Programmer/sysadmin
>> BioMagResBank, UWMadison  http://www.bmrb.wisc.edu>>
>>
>> _______________________________________________
>> Helpoctave mailing list
>> [hidden email]
>> https://mailman.cae.wisc.edu/listinfo/helpoctave>>
>
> 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:
>
> "
> sergei@amdam2:~/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 nonzero number of whitespaces
> 15 bar" # followed by 'bar' with trailing quote
> 16 x;
> 17
> 18 warn "\$&=$&";
> 19
> 20
> sergei@amdam2:~/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.
> sergei@amdam2:~/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/NonProgrammer%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.
>
> _______________________________________________
> Helpoctave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/helpoctaveI 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/NonProgrammer%27s_Tutorial_for_Python_3/Print_version#Printing I see: https://en.wikibooks.org/wiki/NonProgrammer%27s_Tutorial_for_Python_3/Print_version#6._Decisions .
The piece contains a simple code snippet:
"
sergei@amdam2:~/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)
sergei@amdam2:~/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 selfbuilt Python2.7.3:
"
sergei@amdam2:~/junk> /mnt/sdb8/sergei/AFSWD_debug/20121021/Python2.7.3/binsh/python print_example.py
Number? 34
('The absolute value of', 34, 'is', 34)
sergei@amdam2:~/junk> /mnt/sdb8/sergei/AFSWD_debug/20121021/Python2.7.3/binsh/python print_example.py
Number? 1
('The absolute value of', 1, 'is', 1)
sergei@amdam2:~/junk>
"
 the output looks quite differently.
Now with much older Python coming with the OS:
"
sergei@amdam2:~/junk> python print_example.py
Number? 34
('The absolute value of', 34, 'is', 34)
sergei@amdam2:~/junk> python print_example.py
Number? 1
('The absolute value of', 1, 'is', 1)
sergei@amdam2:~/junk>
".
Now with "shebang" notation:
"
sergei@amdam2:~/junk> cat n print_example.py
1 #!/mnt/sdb8/sergei/AFSWD_debug/20121021/Python2.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)
sergei@amdam2:~/junk> ./print_example.py
Number? 34
('The absolute value of', 34, 'is', 34)
sergei@amdam2:~/junk>
".
So, is it a bug or a feature or an outdated tutorial ?
Regards,
Sergei.
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


>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
>bugprone.
I think that the winning feature of Octave is the index notation and the
ease to access submatrices with a readable and intuitive syntax. That
is, what is known as the Matlab index notation. Are there any other
languages that allow such indexing power and clarity?

Francesco Potortì (ricercatore) Voice: +39.050.315.3058 (op.2111)
ISTI  Area della ricerca CNR Mobile: +39.348.8283.107
via G. Moruzzi 1, I56124 Pisa Skype: wnlabisti
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


On 22 Nov 2012, at 10:49, Francesco Potortì 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
>> bugprone.
>
> I think that the winning feature of Octave is the index notation and the
> ease to access submatrices with a readable and intuitive syntax. That
> is, what is known as the Matlab index notation. Are there any other
> languages that allow such indexing power and clarity?
I'd say Fortran 2003, but I think all of Jordi's objections (plus MANY more) would apply
to that language as well, furthermore most compilers are lagging behind in implementation of
the full standard.
These languages are specifically designed to facilitate handling arrays of numbers,
if that's want you want they are both amazingly powerful and convenient.
c.
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


On 22 November 2012 04:49, Francesco Potortì < [hidden email]> 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
>>bugprone.
>
> I think that the winning feature of Octave is the index notation and the
> ease to access submatrices with a readable and intuitive syntax. That
> is, what is known as the Matlab index notation. Are there any other
> languages that allow such indexing power and clarity?
Numpy's indexing is essentially the same except it's 0based to
conform to general Python usage. Numpy can't extend the Python
language beyond what Python itself allows, though, so things like [A;
B] to concatenate matrices in Octave become np.vertcat([A, B]) or
something like that, can't exactly remember. I don't think this is a
huge loss, however.
There is nothing all that magical about Octave indexing.
 Jordi G. H.
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


>Numpy's indexing is essentially the same except it's 0based to
>conform to general Python usage. Numpy can't extend the Python
>language beyond what Python itself allows, though, so things like [A;
>B] to concatenate matrices in Octave become np.vertcat([A, B]) or
>something like that, can't exactly remember. I don't think this is a
>huge loss, however.
I think it is. Being able to catenate and mix ways of indexing id a
huge plus from my point of view.
>There is nothing all that magical about Octave indexing.
I see. But again, is there another language (preferably an interpreted
one) that allows things like
A([1:2:97 98 99],[1:end1]) = (B > C);
or
A(A > 0) += 128;
?

Francesco Potortì (ricercatore) Voice: +39.050.315.3058 (op.2111)
ISTI  Area della ricerca CNR Mobile: +39.348.8283.107
via G. Moruzzi 1, I56124 Pisa Skype: wnlabisti
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


On 22 November 2012 08:51, Francesco Potortì < [hidden email]> wrote:
> I see. But again, is there another language (preferably an interpreted
> one) that allows things like
>
> A([1:2:97 98 99],[1:end1]) = (B > C);
>
> or
>
> A(A > 0) += 128;
>
> ?
Julia:
http://julialang.org/We'll have to wait some time for it to pick up while we all rewrite
all of our numerical routines for it, though.
 Jordi G. H.
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


In reply to this post by Jordi Gutiérrez Hermoso2
>On 22 November 2012 08:51, Francesco Potortì < [hidden email]> wrote:
>> I see. But again, is there another language (preferably an interpreted
>> one) that allows things like
>>
>> A([1:2:97 98 99],[1:end1]) = (B > C);
>>
>> or
>>
>> A(A > 0) += 128;
>>
>> ?
>
>Julia:
>
> http://julialang.org/>
>We'll have to wait some time for it to pick up while we all rewrite
>all of our numerical routines for it, though.
Nice. We'll see :)

Francesco Potortì (ricercatore) Voice: +39.050.315.3058 (op.2111)
ISTI  Area della ricerca CNR Mobile: +39.348.8283.107
via G. Moruzzi 1, I56124 Pisa Skype: wnlabisti
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


In reply to this post by Jordi Gutiérrez Hermoso2
El Dijous, 22 de novembre de 2012, a les 08:56:35, Jordi Gutiérrez Hermoso va
escriure:
> On 22 November 2012 08:51, Francesco Potortì < [hidden email]> wrote:
> > I see. But again, is there another language (preferably an interpreted
> > one) that allows things like
> >
> > A([1:2:97 98 99],[1:end1]) = (B > C);
> >
> > or
> >
> > A(A > 0) += 128;
> >
> > ?
>
> Julia:
>
> http://julialang.org/>
> We'll have to wait some time for it to pick up while we all rewrite
> all of our numerical routines for it, though.
>
>  Jordi G. H.
> _______________________________________________
> Helpoctave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/helpoctaveDo you know if Julia is faster than Octave both using JIT?
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


On 22 November 2012 09:15, Salva Ardid < [hidden email]> wrote:
> El Dijous, 22 de novembre de 2012, a les 08:56:35, Jordi Gutiérrez Hermoso va
> escriure:
>
>> On 22 November 2012 08:51, Francesco Potortì < [hidden email]> wrote:
>> > I see. But again, is there another language (preferably an interpreted
>> > one) that allows things like
>> >
>> > A([1:2:97 98 99],[1:end1]) = (B > C);
>> >
>> > or
>> >
>> > A(A > 0) += 128;
>> >
>> > ?
>>
>> Julia:
>>
>> http://julialang.org/>>
>> We'll have to wait some time for it to pick up while we all rewrite
>> all of our numerical routines for it, though.
> Do you know if Julia is faster than Octave both using JIT?
Octave's JIT compiler still doesn't compile a lot of things. For the
basic loops that Octave's JIT compiler catches, it seems to be
comparable to Julia. They're both using LLVM.
A complication is that automatically parallelising Octave loops seems
like it's going to be a lot more difficult, since Octave's source is
supremely nonthread safe. Julia already seems to be built with
parallelism in mind. This is usually where the greater speedups can be
seen nowadays.
 Jordi G. H.
 Jordi G. H.
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


see inline.
On Thu, Nov 22, 2012 at 6:49 AM, Francesco Potortì < [hidden email]> 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
>>bugprone.
>
> I think that the winning feature of Octave is the index notation and the
> ease to access submatrices with a readable and intuitive syntax. That
> is, what is known as the Matlab index notation. Are there any other
> languages that allow such indexing power and clarity?
R is close:
mat < matrix(1:16, nrow=4, ncol=4)
mat[1:2,1:2] is the upper 2x2 diagonal block
mat[ , 3:4] is the 4x2 matrix which consists of the last two
cols (note the empty first argument meaning "all of"
and so on. And remember that this comes from S, which was invented 10
years before matlab came into existence.
So the "matlab index notation" should really be called the "S index notation".
Kjetil

"If you want a picture of the future  imagine a boot stamping on the
human face  forever."
George Orwell (1984)
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


>> I think that the winning feature of Octave is the index notation and the
>> ease to access submatrices with a readable and intuitive syntax. That
>> is, what is known as the Matlab index notation. Are there any other
>> languages that allow such indexing power and clarity?
>
>R is close:
> mat < matrix(1:16, nrow=4, ncol=4)
> mat[1:2,1:2] is the upper 2x2 diagonal block
>mat[ , 3:4] is the 4x2 matrix which consists of the last two
>cols (note the empty first argument meaning "all of"
>and so on. And remember that this comes from S, which was invented 10
>years before matlab came into existence.
>So the "matlab index notation" should really be called the "S index notation".
Can S (or R) do something like the following?
A([1:2:97 98 99], 1:end1) = 0;

Francesco Potortì (ricercatore) Voice: +39.050.315.3058 (op.2111)
ISTI  Area della ricerca CNR Mobile: +39.348.8283.107
via G. Moruzzi 1, I56124 Pisa Skype: wnlabisti
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


>> Can S (or R) do something like the following?
>>
>> A([1:2:97 98 99], 1:end1) = 0;
>>
>Of course. An example:
>
>A=matrix(rnorm(100*100),100,100)
>A[c(seq(1,97,2),98,99),c(1:(nrow(A)1))]<0
Well, this is done using functions, it is not a feature of the language
itself. It definitely makes sense to speak of the Matlab indexing
notation, which is a more powerful evolution of the S notation and, in
my opinion, is the killing feature of Matlab/Octave (and apparently of Julia).

Francesco Potortì (ricercatore) Voice: +39.050.315.3058 (op.2111)
ISTI  Area della ricerca CNR Mobile: +39.348.8283.107
via G. Moruzzi 1, I56124 Pisa Skype: wnlabisti
(entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


Am 22.11.2012 17:01, schrieb Francesco Potortì:
> Well, this is done using functions, it is not a feature of the
> language itself. It definitely makes sense to speak of the Matlab
> indexing notation, which is a more powerful evolution of the S
> notation and, in my opinion, is the killing feature of Matlab/Octave
> (and apparently of Julia).
Python has partially the concise syntax you are looking for
A[A>0] += 128
A[1:98:2]
is perfectly valid for numpy arrays, for something like
1:2:97 98 99
I see no syntactic sugar only something like range(1,98,2) + [98, 99], while easier subscripting can be done with the colon syntax of course.
As I am not the perfect numpy/scipy coder maybe someone knows better and I am wrong here.
Btw I am someone who likes having domain specific languages and not one general purpose language to rule them all, that is my reason to use environments like octave, scilab, maxima, they just feel more natural, but that is a very personal point of view of course.
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


see inline.
On Thu, Nov 22, 2012 at 1:01 PM, Francesco Potortì < [hidden email]> wrote:
>>> Can S (or R) do something like the following?
>>>
>>> A([1:2:97 98 99], 1:end1) = 0;
>>>
>>Of course. An example:
>>
>>A=matrix(rnorm(100*100),100,100)
>>A[c(seq(1,97,2),98,99),c(1:(nrow(A)1))]<0
>
> Well, this is done using functions, it is not a feature of the language
> itself.
R is a functional language, the language itself is built from
functions, not from syntax as in nonfunctional languages. So to say
"Well, this is done using functions, it is not a feature of the
language itself. " doesn't really makes sense for R. The point is
that this has been a part of the language from befor matlab even
existed. It might be that matlab's version is marginally more
expressive (really shorter, or marginally more readable), but then in
R, as a functional language, it is possible to extend
the syntax by user functions, even extending this syntax to new kinds
of objects, simply by defining new replacements functions. So R's
version is probably more adaptive, flexible than matlab's.
Kjetil
It definitely makes sense to speak of the Matlab indexing
> notation, which is a more powerful evolution of the S notation and, in
> my opinion, is the killing feature of Matlab/Octave (and apparently of Julia).
>
> 
> Francesco Potortì (ricercatore) Voice: +39.050.315.3058 (op.2111)
> ISTI  Area della ricerca CNR Mobile: +39.348.8283.107
> via G. Moruzzi 1, I56124 Pisa Skype: wnlabisti
> (entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it
"If you want a picture of the future  imagine a boot stamping on the
human face  forever."
George Orwell (1984)
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


On 11/21/2012 6:45 PM, Sergei Steshenko wrote:
>
>> I like Perl, and I do not write it this way. The example you gave is unfair in
>> several respects:
Yes, and quite deliberately, too. ;) My point was that to someone who
hasn't touched math since Scientific Computing 201 and matlab  never
(we did it in C), e.g. "A([1:2:97 98 99],[1:end1]) = (B > C);" quoted
downthread looks no different from obfuscated perl.
I do spell things out and never use "$_" either (when I have to write perl).
...
> 3 print("The absolute value of", n, "is", n)
> Number? 1 The absolute value of 1 is 1
vs
> ('The absolute value of', 1, 'is', 1)
> So, is it a bug or a feature or an outdated tutorial ?
Yes.
Apparently fixed it in 3.0 (I use OS python) and can be enabled in some
2.x versions by "import __future__" (that's the "outdated" part).
Basically, print is not a function in 2.x, it's a statement, so () after
"print" mean something else. In this context they're confusing (and
possibly ambiguous)  that's the bug part:
 ("foo", "bar") defines a tuple (pair) of strings. Tuple is printed in
brackets to show you it's a tuple (that's the "feature" part),
 comma after print's argument means "don't print newline",
 brackets also used as you'd expect: to group expressions.
So
print("abs of %d is %d" % (n, n)),
and
print("abs of", n, "is", n),
mean two different things.
Like I said, python's not great. But whitespace forces people format
their code in a more readable shape and if you ever watched cpan try to
download and build perl 5.678 because you wanted GD graphs  and on a
nonGNU platform where it fails at 'cc != gcc'  you get to appreciate
"batteries included" standard library. If only they had manifest typing...
Dima
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave


 Original Message 
> From: Francesco Potortì < [hidden email]>
> To: Sergei Steshenko < [hidden email]>
> Cc: " [hidden email]" < [hidden email]>; c. < [hidden email]>; Jake < [hidden email]>
> Sent: Thursday, November 22, 2012 11:49 AM
> Subject: Re: Octave's and Matlab's limitations
>
>>T hough 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
>> bugprone.
>
> I think that the winning feature of Octave is the index notation and the
> ease to access submatrices with a readable and intuitive syntax. That
> is, what is known as the Matlab index notation. Are there any other
> languages that allow such indexing power and clarity?
>
> 
> Francesco Potortì (ricercatore) Voice: +39.050.315.3058 (op.2111)
> ISTI  Area della ricerca CNR Mobile: +39.348.8283.107
> via G. Moruzzi 1, I56124 Pisa Skype: wnlabisti
> (entrance 20, 1st floor, room C71) Web: http://fly.isti.cnr.it>
"Are there any other languages that allow such indexing power and clarity?"  this is kinda "narrow" question.
The root cause/problem is that typical languages have predefined syntax and just _some_ syntactic freedom is given through operator overloading, e.g. in C++ one can access hash values as
some_hash["some_key"]
even though originally [...] construct is meant for _numeric_ array index expressions.
A language which tries to resolve this problem _drastically_ is OCaml (maybe there are others, I simply don't know). Specifically, OCaml has 'camlp4' and 'camlp5' (start from http://en.wikipedia.org/wiki/Camlp4 ).
I once came across an implementation of Python style (i.e. using whitespaces do denote code blocks) for OCaml. OCaml community didn't become fascinated with it, but it's a different matter.
The main point is that one can implement practically _any_ syntax he/she likes.
Also, error messages are issued in terms of line numbers of the code with modified syntax, so debugging is easy  even though the thing is ultimately translated into "pure" OCaml.
Regards,
Sergei.
_______________________________________________
Helpoctave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/helpoctave

123
