Re: Larry Wall Talks, Perl and Lua (Was: Programming is hard, let's go scripting)

Hi Velu,

Thanks for those links. I will read them.

Well, one of the biggest advantages of perl is that there are more ways to do something, however this can be one of the biggest disadvantages sometimes, and this something I don't like when I need to read someone elses code.

For example, I admit I use the old and not recommended way of defining file handles like

open(IN, "file");
instead of the recommended way:
open(my $in, "<", "file");

and I use to die() or warn() only if necessary.

I don't like the map() function and I also use even grep() very rarely, so I prefer using other constructs even if they need writing more code.

Some of the things that will be in perl 6 seem to be nice (but who knows after how many years will appear that perl), however there are other things I don't like.

Perl 6 will have subroutines with the same name and different signatures, and maybe its system will be more complex than the one in C# or Java, however I don't know if it will be so clear.

I also don't know why the commenting style used by most programming languages with /* ... */ was not good, and it was chosen #[ ... ].

Well, maybe the perl style is more flexible, because maybe it will also work #< ... > and #{ ... }, but what if the code we want to comment contain ), }, ] and >? Will it work? And in fact this is not such a big issue, but I've seen that other languages which are much poorer like PHP have more success because theyr coding style is very closed to one used in other successful languages. Perl seems to want to make everything as different as possible, making it harder to learn and understand.

If someone knows Java, he could learn C# easier, or vice-versa, but he won't learn perl as easy. And this is true when we speak about other higher level programs, like some perl libraries. Java/.net/PHP programmers prefer SOAP services for example, while the perl programmers usually don't bother to make a good support for SOAP because they consider XML RPC or other systems better. SOAP works fine in perl also, but only if the SOAP client is made in perl and the SOAP server is also made in perl, because it uses a different XML format than .net or Java, and well, the web services were invented exactly for making different programming languages collaborate easier.

Perl 6 will be a language similar to perl 5, but it will actually be a totally different language and even the perl 5 programmers would need to start learning it. I also don't know how compatible will be the tens of thousand modules on CPAN with it...

Perl 6 could have a strict programming style or not, it could be strongly typed or not, it could be functional or object oriented, it could have some compatibility with perl 5 features, and how knows how many other options, so I think that there will be much many ways to do it in perl 6 than in perl 5. A program in perl 6 could look very similar to one in C#, another one could look similar to a Javascript code, while another could be very similar with perl 5, not to mention that Larry Wall also tells that in fact perl 6 will allow programming in more languages somehow like .net does (although some big guys like Guido van Rossum have some doubts).

Until then... I find it pretty hard to create multi threading applications in perl, create binary executables that doesn't allow others to see the code, create portable applications that require a native GUI (like SWT does for example)...

I think these improvements are more important than changing from $array[1] to @array[1] or eliminating the params from conditional or looping statements, or including new functions like say().

Octavian

----- Original Message ----- From: "Veli-Pekka Tätilä" <vtatila@xxxxxxxxxxxxxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Saturday, March 29, 2008 12:36 AM
Subject: Re: Larry Wall Talks, Perl and Lua (Was: Programming is hard, let's go scripting)


Octavian Rasnita wrote:
Read a nice article by Larry Wall at:
http://www.perl.com/pub/a/2007/12/06/soto-11.html
Hi Octavian,
And thanks for the post. I really like Larry's talks written down, even,
really smart, whitty and still serious talk, I'd say. Another Perl
article I like by him is this one about natural language principles:

http://www.wall.org/~larry/natural.html

I'm also beginning to like Lua very much based on this free Lua book:

http://www.lua.org/pil/

Dolphin chose it as their screen reader scripting language introduced in
CSUN I've heard and it will be properly publicized in the upcoming
V9.02. Very speech friendly and extremely minimalist, yet it is about as
flexible as Perl is in terms of functional programming and
object-orientation.

I learned about the Lua screen reader API, yet to be finalized, in an
experimental Dolphin course on using Lua in addition to the mapping
system they have, somewhat similar to WindowEye's set files.

Finally, to demonstrate, I decided to do the same task in Lua and Perl,
namely sorting BibTeX references by their citation key. The Perl version
is more functional, briefer and probably more idiomatic, but that's how
I code Perl. the Lua version, in turn, using a different strategy, is
much cleaner and maintainable by default. It doesn't have map or split,
though I've coded map from  scratch easily experimentally. And now the
code:

Perl version:

use strict; use warnings;
@ARGV == 2 or die "usage: inFile outFile\n";
($/, my %entries) = "";
open my $in, shift or die "Cannot read file: $^E\n";
/^@\w+\{(.+),/ and $entries{$1} = $_ for <$in>;
open my $out, ">", shift or die "Cannot write file: $^E\n";
print $out $entries{$_} for sort keys %entries

Lua version:

require "strict"
if not # arg == 2 then error "Usage: inFile outFile" end
local entries, sortedEntries, thisEntry = { }, { },  ""
for line in io.lines( arg[1] ) do
  local ref = string.match(line, "@%w+%s*%{(%w+)")
   if ref then thisEntry = ref end
   if not entries[thisEntry] then entries[thisEntry] = { } end
   table.insert(entries[thisEntry], line)
end
for entry in pairs(entries) do table.insert(sortedEntries, entry) end
table.sort(sortedEntries)
local outFile = io.open( arg[2], "w")
for _, entry in ipairs(sortedEntries) do
  for _, line in ipairs(entries[entry] ) do outFile:write(line, "\n")
end
end

Of course, you could do the Lua version in Perl. And since Perl has
proper arrays where as Lua arrays are just fast indexed hashes with int
keys, the PErl version might be more natural. Also, Perl autovivifies
arrays on indexing ($f{bar}[5] creates the hash and creates the array in
it), avoiding yet another if.

The key difference is not so much on what is possible but what the
coding culture says. The perl version is natural in Perl and the LUa
version is natural in Lua. Both are equally valid. The lua version is
easier to understand, though, and Lua is about as speech friendly as
Ruby is at best. The same is not true of Perl, though it seems to me
Perl 6 will rectify this partly.

I think the Lua object system is just plain clean and simple. The same
minimalism as in Perl but using only meta tables, not language magic
like @ISA and bless or library magic, such as overload.pm.

Finally, as for funny LArry quotes that make a good fortune file, here's
a list for you:

http://en.wikiquote.org/wiki/Larry_Wall

--
With kind regards Veli-Pekka Tätilä (vtatila@xxxxxxxxxxxxxxxxxxxx)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila
__________
View the list's information and change your settings at
http://www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at http://www.freelists.org/list/programmingblind

Other related posts: