Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
True, but I think it’s cleaner when you’re actually calling the function to not have to send a hashref. Small thing, of course, but I figure you write a function once, but call it many times. I’d rather the function call be cleaner/simpler than the function definition for that reason. Sent from my iPhone > On Jan 3, 2020, at 5:29 AM, Holger Glaess wrote: > > hi > > > you can do by array > > sub m4 > { >my ( $self,$args ) = @_; > > # $args contains > # $args->{'bla'} = blub > # $args->['do'} = whatever > } > > > as call ( example ) > > $obj->m4 ({ bla => blub , do => whatever }); > > holger > > > >> Am 02.01.20 um 21:40 schrieb danieljb...@icloud.com: >> What if you want named parameters? (i.e. sending a hash as your >> argument) >> >> sub m4 >> { >> my $self = shift; >> my %args = @_; >> >> # and then optionally >> my ($arg1, $arg2, $arg3) = @args{qw/arg1 arg2 arg3/}; >> >> # or you can just use $args{arg1}, etc... >> } >> >> >>> On Thu, Jan 02, 2020 at 09:12:42PM +0100, Marc Espie wrote: >>> sub f >>> { >>>my ($arg1, $arg2) = @_; >>> >>>... code >>> >>> } >>> >>> - three styles of parameter grab for methods: >>> >>> >>> sub m1 >>> { >>>my $self = shift; >>> } >>> >>> No other parameter. >>> >>> sub m2 >>> { >>>my ($self, $p1, $p2) = @_; >>> } >>> >>> when getting all parameters (no check on the number usually) >>> >>> >>> sub m3 >>> { >>>my $self = shift; >>>... >>>do_something_with(@_); >>> } >>> >>> for functions with unlimited parameters after the first one >
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
> you can do by array Both of them are borring once you used the signatures but they are still experimental. Also: if you don't mind a new dependency: Function::Paramaters is so much convenient. regards marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
hi you can do by array sub m4 { my ( $self,$args ) = @_; # $args contains # $args->{'bla'} = blub # $args->['do'} = whatever } as call ( example ) $obj->m4 ({ bla => blub , do => whatever }); holger Am 02.01.20 um 21:40 schrieb danieljb...@icloud.com: What if you want named parameters? (i.e. sending a hash as your argument) sub m4 { my $self = shift; my %args = @_; # and then optionally my ($arg1, $arg2, $arg3) = @args{qw/arg1 arg2 arg3/}; # or you can just use $args{arg1}, etc... } On Thu, Jan 02, 2020 at 09:12:42PM +0100, Marc Espie wrote: sub f { my ($arg1, $arg2) = @_; ... code } - three styles of parameter grab for methods: sub m1 { my $self = shift; } No other parameter. sub m2 { my ($self, $p1, $p2) = @_; } when getting all parameters (no check on the number usually) sub m3 { my $self = shift; ... do_something_with(@_); } for functions with unlimited parameters after the first one
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On 3/1/20 8:31 pm, Marc Chantreux wrote: >> Any modern mailreader can easily tag messages as thread, so it's trivial to >> avoid a given thread, as long as people don't fuck around with the >> In-Reply-To info. > > i have to admit this isn't an argument: if most of the people don't read > it, we should have the ability to save bandwidth by setting up a temp > list or adding a + alias. i add this in my todolist. No rush… + suffix sounds a cleaner solution than hash tags. (looking at you groups.io!) -- Stuart Longland (aka Redhatter, VK4MSL) I haven't lost my mind... ...it's backed up on a tape somewhere.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
> Any modern mailreader can easily tag messages as thread, so it's trivial to > avoid a given thread, as long as people don't fuck around with the > In-Reply-To info. i have to admit this isn't an argument: if most of the people don't read it, we should have the ability to save bandwidth by setting up a temp list or adding a + alias. i add this in my todolist. regards marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
> Yes well, my point is if you want to make a piece of code > incomprehensible, I don't think there is a language that will stop you. indeed. but i now realize the counterpart is not true because everyone has something different in mind when it comes to readability. last example was yesterday: i wrote this in raku: my %final_pairs = @*ARGFILES.words.hash i asked for code review for the python counterpart and we got: import sys def words(): for s in sys.argv[1:]: with open(s) as fh: for l in fh.readlines(): for w in l.split(): yield(w) w = words() final_pairs = { k : v for k,v in zip(w,w) } i don't need the perl version but it would something like: my %final_pairs = grep length, map { split /\S+/ } map { chomp; $_ } <>; for me, readability score is: raku, perl, python but someone gives arguments: * there is no reason a list could be considered as a hash by order of appearance * there is nothing more unreadable than implicity (split on what? what is $_?, <> iters on what?) i strongly disagree but this is a valid opinion. i know that many people struggle with side effects for example so $x++ is convenience for the one of us that are used to iteration but it's hell for lot of newcommers. > It's a choice of the writer to write code that's hard to understand. > Perl is a very expressive language, and can be used to write very clean > and maintainable code. that's it. and some of us hate expressivity because it means: learn how the langage behave when it's preferable to describe the same patterns again and again ... > I think the "there's no right way" mantra helps: it allows you the > latitude to choose the style that makes the most sense for the problem > being solved. yes ... but "it could be a default way because experience shown its convenience or ability to solve the most common problem" (which is what perl and raku do, i guess), is something that can be loved or hated. regards marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Thu, Jan 02, 2020 at 11:52:03PM +0100, Marc Chantreux wrote: > > You have something like 3 lines of perl to play with ;) > > is there a todo list somewhere ? More or less in my head, with lots of subprojects progressing at any given time. - I want to retire PackageLocator and have more correct packagerepository lists... Update.pm is somewhat hackish; - the virtual file system (Vstat.pm) is too simple and somewhat broken; - there are still a few bugs in dependency handling; - pkg_info should probably be cleaned up at some point - there is some complicated work to speed up pkg addition by going through a kind of "proxy", exactly like pkg_add-over-ssh works... this part is not perl, though. - pkg_create handling of dependencies completely misses @tag currently - lib-depends-check is a complete mess and doesn't work with subdirectories - the tests in regress/usr.sbin/pkg_add are woefully inadequate. - dpb doesn't support running tests, and it's intended to take on portroach capabilities at some point. - it should have a "disconnected mode" with just ssh and no nfs. Quite possible now that we have rsync in base. - I'd like to integrate proot a bit more... the way proot is engineered to prefer hardlinks over copy was intended to make it possible to "quickly" create a separate chroot for each build (it's somewhat linked to the previous point, as both require precise accounting of packages). there are more, but those are the ones coming up at the top of my head.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Fri, Jan 03, 2020 at 09:43:21AM +1000, Stuart Longland wrote: > On 3/1/20 8:50 am, Marc Chantreux wrote: > >> Like this thread, or worse? > > * long doesn't mean endless > > * sharing points of view is never sterile (yours is inspired by other > > ones, right?) > > I would say it's been highly educational. > > Granted, this did not get off to a good start with the "let's replace > Perl with Lua" debate, but it has piqued my interest in what the Raku > team are up to. > > It's pointed out style(9) which I'm having a read of now. Having gotten > familiar with the Linux kernel coding style and the coding style used in > OpenThread, it's helpful sometimes to look at how others do it, as > sometimes you can learn something that ultimately makes your life easier. > > There's a valid point about whether this is the appropriate forum for > this. Question is, if not here, then where? Any modern mailreader can easily tag messages as thread, so it's trivial to avoid a given thread, as long as people don't fuck around with the In-Reply-To info.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On 2/1/20 9:43 pm, Marc Chantreux wrote: > arf ... i just tried to explain were this "linenoise" bullshit came from > just in the answer i gave to frank Yes well, my point is if you want to make a piece of code incomprehensible, I don't think there is a language that will stop you. I had a colleague who used to argue "that code was hard to write, it should be hard to read too!" -- completely forgetting the poor sod that had to come behind him and maintain his code. It's a choice of the writer to write code that's hard to understand. Perl is a very expressive language, and can be used to write very clean and maintainable code. I think the "there's no right way" mantra helps: it allows you the latitude to choose the style that makes the most sense for the problem being solved. -- Stuart Longland (aka Redhatter, VK4MSL) I haven't lost my mind... ...it's backed up on a tape somewhere.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On 2020-01-02 16:52, Marc Chantreux wrote: You have something like 3 lines of perl to play with ;) is there a todo list somewhere ? find /usr/src -name '*.pm' | xargs grep XXX Shows some promising results. Edgar regards marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On 2/1/20 8:48 pm, Marc Espie wrote: >> I've seen some pretty ugly Python code too. > Not to beat a dead horse, but most of the python configury stuff, > including scons, is pretty shitty. Lots of really bad pseudo-OO stuf > (hey let's use that cool feature just because we can) Yeah, you won't get any disagreement from me on that front. I prefer make (usually I use the GNU dialect, but that's just borne out of what I normally have to support), and maybe CMake for more complex stuff. scons, waf, and others… seem to cause more problems than they solve. -- Stuart Longland (aka Redhatter, VK4MSL) I haven't lost my mind... ...it's backed up on a tape somewhere.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On 3/1/20 8:50 am, Marc Chantreux wrote: >> Like this thread, or worse? > * long doesn't mean endless > * sharing points of view is never sterile (yours is inspired by other > ones, right?) I would say it's been highly educational. Granted, this did not get off to a good start with the "let's replace Perl with Lua" debate, but it has piqued my interest in what the Raku team are up to. It's pointed out style(9) which I'm having a read of now. Having gotten familiar with the Linux kernel coding style and the coding style used in OpenThread, it's helpful sometimes to look at how others do it, as sometimes you can learn something that ultimately makes your life easier. There's a valid point about whether this is the appropriate forum for this. Question is, if not here, then where? -- Stuart Longland (aka Redhatter, VK4MSL) I haven't lost my mind... ...it's backed up on a tape somewhere.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
> You have something like 3 lines of perl to play with ;) is there a todo list somewhere ? regards marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Thu, Jan 02, 2020 at 02:16:52PM -0500, Daniel Jakots wrote: > On Thu, 2 Jan 2020 19:49:28 +0100, Marc Chantreux > > some endless sterile debates > Like this thread, or worse? * long doesn't mean endless * sharing points of view is never sterile (yours is inspired by other ones, right?) so i think this thread is neither sterile nor endless but maybe it's not the good channel: please let us know if there is a better place than misc@ for that. regards. marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Thu, Jan 02, 2020 at 04:10:43PM -0500, Paul Wisehart wrote: > On Thu, Jan 02, 2020 at 09:12:42PM +0100, Marc Espie wrote: > > > > Here are my current guidelines for OpenBSD perl tools. > > > > Can you eleborate in greater detail? > Not really, just go read the code and ask questions. You have something like 3 lines of perl to play with ;)
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Thu, Jan 02, 2020 at 09:12:42PM +0100, Marc Espie wrote: > > Here are my current guidelines for OpenBSD perl tools. > Can you eleborate in greater detail?
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Thu, Jan 02, 2020 at 02:40:25PM -0600, danieljb...@icloud.com wrote: > What if you want named parameters? (i.e. sending a hash as your > argument) > > sub m4 > { > my $self = shift; > my %args = @_; > > # and then optionally > my ($arg1, $arg2, $arg3) = @args{qw/arg1 arg2 arg3/}; > > # or you can just use $args{arg1}, etc... > } Such cases are a refactoring waiting to happen. If your parameters get complicated enough that you want to name them, these's usually an object hiding in there :)
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
What if you want named parameters? (i.e. sending a hash as your argument) sub m4 { my $self = shift; my %args = @_; # and then optionally my ($arg1, $arg2, $arg3) = @args{qw/arg1 arg2 arg3/}; # or you can just use $args{arg1}, etc... } On Thu, Jan 02, 2020 at 09:12:42PM +0100, Marc Espie wrote: > sub f > { > my ($arg1, $arg2) = @_; > > ... code > > } > > - three styles of parameter grab for methods: > > > sub m1 > { > my $self = shift; > } > > No other parameter. > > sub m2 > { > my ($self, $p1, $p2) = @_; > } > > when getting all parameters (no check on the number usually) > > > sub m3 > { > my $self = shift; > ... > do_something_with(@_); > } > > for functions with unlimited parameters after the first one
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Thu, Jan 02, 2020 at 03:24:41PM -0500, Chris Bennett wrote: > mod_perl, from reading the mailing list, looks like it will die off > before long. Lack of developers and funding and interest given all the > newer replacements. Don't even think about using mod_perl these days. Fast-cgi is the way to go. Even if you use something else but Dancer, I'd urge you to read the documentation, it has a whole fucking manpage about Dancer::Deployment
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
I don't speak Python, but from what I've read, it has some serious encoding problems compared to Perl. This is a real problem in today's world of multiple encodings. Apparently the guy writing about this is pretty hated for bringing up this serious flaw. If the problem is true, he has examples, then it needs to get fixed. Perl also has problems, but screwing up encodings is pretty fundamental. mod_perl, from reading the mailing list, looks like it will die off before long. Lack of developers and funding and interest given all the newer replacements. Remove Perl? No way. Perl is very Unixy. Perl is full of automagically. C isn't. I think they make for a good combo. Think this way -> use C Think other way-> use Perl Think really screwball -> use both OK, enough of my BS, but this is an interesting thread. I do think discussing many languages that can be used is relevant to both misc@ and ports@ Bye Y'all, Chris Bennett
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Thu, Jan 02, 2020 at 07:49:28PM +0100, Marc Chantreux wrote: > On Thu, Jan 02, 2020 at 10:42:54AM -0600, danieljb...@icloud.com wrote: > > I don't understand why people say that perl's flexibility is a negative. > > because sometimes, flexibility permit some endless sterile debates about > the coding style. Well, OpenBSD has got style(9). I have some specific adaptations for perl, because a lot of the rules are for C. Here are my current guidelines for OpenBSD perl tools. In general, things are written following style(9) adapted for perl. Specifically, - named sub *are* functions. So sub f { my ($arg1, $arg2) = @_; ... code } - three styles of parameter grab for methods: sub m1 { my $self = shift; } No other parameter. sub m2 { my ($self, $p1, $p2) = @_; } when getting all parameters (no check on the number usually) sub m3 { my $self = shift; ... do_something_with(@_); } for functions with unlimited parameters after the first one (dubious whether this changes anything for performance reasons) - wantarray should *only* be used for optimization purposes (yes/no answer instead of full list). Doing otherwise utterly complicates matters. - I almost never put extra parentheses, and use the "4 space indent" rule for continuing statements. - chained index lookups should ditch the extra -> . prefer $self->{a}{b} to $self->{a}->{b} - don't put quotes around indices unless absolutely necessary (keywords) and don't use keywords for keys. - anonymous subs are part of the code: So: my $s = sub { my $self = shift; ... }; Note a full indent because the inside looks like code. - modern perl prefered, so $value //= something; prefered over $value = something if !defined $value; - autovivification welcome. push @{$self->{list}}, value; is perfectly fine without defining $self->{list} first. Note that if (@{$self->{list} > 0) *won't* autovivify list, so it can be used for "does the list exist and is not empty" instead of if (exists $self->{list} - I should probably normalize towards banning implicit return ? - should I prefer "always refs" over explicit % / @ ? There is a slight legibility problem: my @l; is more readable than my $l; (this is a list) and my $l = []; takes slightly more memory. - most things unless explicitly being debugged should set $DB::inhibit_exit = 1 right afer a fork and before an exec. And I have some further general rules, learnt from past mistakes. The perl package tools follow some stylistic and practical guidelines - all new development should be object-oriented. Have a package under either OpenBSD or DPB, and pass operations to a constructed object (generally name the constructor new unless you have better options) if you need to keep state, or to the class name proper. Examples: my $pkgpath = DPB::PkgPath->new('devel/quirks'): say "Normalized version is ", $pkgpath->fullpkgpath; $state->errsay(OpenBSD::Temp->last_error); older code sometimes does not respect that. It hasn't been converted because it's currently not worth it. But there have been many instances where I've actually regretted not doing things that way sooner. The object itself is usually called "$self" unless there are reasons not to. Since there are no access control restrictions in perl, most often internal methods are just prefixed with _. Stylistically, methods without parameters don't need parameters, so I don't write them, prefer $object->foo to $object->foo() It makes it less cumbersome to chain methods, e.g., $object->foo->bar(whatever); - in the interest of chaining methods, stuff that tweaks an object should return the object itself, so that $self->set_foo(1)->set_bar(2)->run will actually work - a lot of code creates "unique" objects. The pattern is to have a %cache hash in the package, and have the normal constructor do things under the radar, calling create as needed. create won't normally be used by client code. - a lot of code creates "just in time objects". Error.pm containt the OpenBSD::Auto class, that can be used to create jit values, it contains one single construct, cache, that is used like so: OpenBSD::Auto::cache(solver, sub { require OpenBSD::Dependencies; return OpenBSD::Dependencies->new(shift); }); so that the first call to $self->solver(x) will instantiate $self->{solver} to the required object. And that call and all subsequent calls will return the same object. - there are way less files than classes. Things are organized in a "put a whole set of related things together in the same file". Full OO also means you don't need to use Foo; from the start, you can require Foo; dynamically, thus loading it later. This does speed up the startup of tools significantly. - in general, singletons are frowned upon. We still have a few (list ?), mainly as cached values in specific packages. There
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Thu, 2 Jan 2020 19:49:28 +0100, Marc Chantreux wrote: > some endless sterile debates Like this thread, or worse?
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Thu, Jan 02, 2020 at 10:42:54AM -0600, danieljb...@icloud.com wrote: > I don't understand why people say that perl's flexibility is a negative. because sometimes, flexibility permit some endless sterile debates about the coding style. marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
> I will always lean towards idiot-proofing the code. :)) fair enough. regards marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
I don't understand why people say that perl's flexibility is a negative. Bad code is a negative. You can have bad or inconsistent code even in a language like python that has very rigid syntax. As long as you know perl well, you should be able to read any well-written perl code. To me, both of those examples are equally readable, though, I'd lean more towards a multiline approach with the second: my %user = ( login => 'mc', shell => 'bin/zsh', ); On Thu, Jan 02, 2020 at 04:22:08PM +0100, Marc Chantreux wrote: > hello, > > > > my %user = qw( > > > login mc > > > shell /bin/zsh > > > ); > > > print $user{login}; > > > my %user = ( login => 'mc', shell => 'bin/zsh'); > > is way more readable in that case, I think, > > and it does showcase what a *smart* quoting system can do. > > well ... i prefer the way i wrote because i love to: > > * remove useless symbols > * read columns > > but yes: the drawback of perl is: there are so many ways to do > it so every project needs a clear coding style. > > regards > marc >
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Thu, Jan 02, 2020 at 04:22:08PM +0100, Marc Chantreux wrote: > hello, > > > > my %user = qw( > > > login mc > > > shell /bin/zsh > > > ); > > > print $user{login}; > > > my %user = ( login => 'mc', shell => 'bin/zsh'); > > is way more readable in that case, I think, > > and it does showcase what a *smart* quoting system can do. > > well ... i prefer the way i wrote because i love to: > > * remove useless symbols > * read columns Well, => and , allow to figure out errors in odd/even hashes easily. I will always lean towards idiot-proofing the code.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
hello, > > my %user = qw( > > login mc > > shell /bin/zsh > > ); > > print $user{login}; > my %user = ( login => 'mc', shell => 'bin/zsh'); > is way more readable in that case, I think, > and it does showcase what a *smart* quoting system can do. well ... i prefer the way i wrote because i love to: * remove useless symbols * read columns but yes: the drawback of perl is: there are so many ways to do it so every project needs a clear coding style. regards marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Thu, Jan 02, 2020 at 12:40:51PM +0100, Marc Chantreux wrote: > the quoting system > > # qw( for a list of barewords ) > my %user = qw( > login mc > shell /bin/zsh > ); > print $user{login}; I wouldn't write it that way my %user = ( login => 'mc', shell => 'bin/zsh'); is way more readable in that case, I think, and it does showcase what a *smart* quoting system can do.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
> Not sure about anyone else, but comparing the Python vs Perl example you > gave above, I would still say Python is the nicer-looking language. i was just saying that there is no need for yield in perl. now i can show you tons of examples to demonstrate perl code is not only more "unixish" but easier to: * write * read * modularize (__init__.py always made me smile) when you have to manipulate text files or large datastructures, python is far behind perl. i won't try to convince you but to illustrate what is said before. see this code: use v5.20; while (<>) { chomp; # trim and print lines only when not empty say s/ ^ \s+# triml | \s+ $ # trimr //rx if /\S/; } this is *hell* for a unix newbie: * regexps is a concept that windows programmers (so python ones too) try to avoid (pretending it's hard to understand and read) * ARGV ... what is a "filter" anyway? i don't want to read about the unix litterature to write my code. to be fair: if you just write a web application or a datascience script were datasources are from binary formats or databases and libraries are available, you just don't need those tools and run away is probably the good strategy (python *is* indeed easier to learn when you have simple things to code). if you believe in text streams and simple formats in a unix land (which i do), or if you need to solve complex problems, learn those concepts and be familiar with them is worth it. another "line noise" bullshit comes from sigils and i have to admit i though sigils made my script looks "not professional" when i was younger (having a php background). But when you understand the way sigils works, it appears that it is very informative and useful: * they always give clues about the structures you're working with * they permit some very useful shortcuts as example: hash slices is something i always miss in python. use v5.20; my %user; my @names = qw( uid gecos home shell ); my @cols = qw( 0 3 56 ); @user{@names} = map { chomp; (split /:/)[@cols] } `getent passwd mc`; printf '%s is the default shell for %s' , @user{qw( uid shell )}; sure, python is evolving in the good direction (see PEPs 448, 449, 572 ...) but so many things are missing to be confortable comparing to perl (sometimes little ones but so convenient). some examples that comes to my mind: the quoting system # qw( for a list of barewords ) my %user = qw( login mc shell /bin/zsh ); print $user{login}; # q() and qq() to replace '' and "" when it's complicated my $comment = qq{ with qq() you can choose your delimiter like in sed so you can't get it wrong or unreadable even if you have "" in mind } yada to spot an unimplemented section (https://perldoc.perl.org/perlsyn.html#The-Ellipsis-Statement)), the //g modifier with the \G anchor (so you can iterate in a string with regexp matching), ... so many other ones. and python people don't get those are very useful features. when i asked for fair help, the anwsers were often flooded in tons of messages like: * you don't need this * you shouldn't program with this * perl is dead So even the community is anoying and i don't want this logo++ to be unfairly compared to perl anymore but as i said: i don't want to reboot a 2 decades sterile feed: * since 3.4 python became bearable (so much saner than php or js) and a good tool for teaching OO. * both python and perl are langages from the last millenium with lot of issues that are fixed in raku. so that's the spot i switched to. cheers marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
hello Stuart, > Heh, I've heard Perl described as executable line noise, and for sure, > it will let you write code like that. arf ... i just tried to explain were this "linenoise" bullshit came from just in the answer i gave to frank regards marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Thu, Jan 02, 2020 at 07:34:22PM +1000, Stuart Longland wrote: > On 2/1/20 12:30 am, Marc Chantreux wrote: > > * the python community was unfair comparing the langages (using ugly > > perl code and nice python counterparts). instead of taking time to > > explain all the biases, perl community repetedly asserted that the > > authors of those article were incompetents and gone away. > > Heh, I've heard Perl described as executable line noise, and for sure, > it will let you write code like that. > > But so does C. There's even a contest for doing exactly that. > > I've seen some pretty ugly Python code too. Not to beat a dead horse, but most of the python configury stuff, including scons, is pretty shitty. Lots of really bad pseudo-OO stuf (hey let's use that cool feature just because we can) I hate when I have to fix python configure... it looks like a bunch of complete beginners set up to reinvent a square wheel. python is definitely my #1 most-hated language when fixing configure in ports. Yes, it beats autoconf and libtool by a large margin.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On 2/1/20 12:30 am, Marc Chantreux wrote: > * the python community was unfair comparing the langages (using ugly > perl code and nice python counterparts). instead of taking time to > explain all the biases, perl community repetedly asserted that the > authors of those article were incompetents and gone away. Heh, I've heard Perl described as executable line noise, and for sure, it will let you write code like that. But so does C. There's even a contest for doing exactly that. I've seen some pretty ugly Python code too. If you set out to write ugly code, you will get ugly code, doesn't matter what the language is. If you set out to write a thing of beauty, it can be that thing of beauty. It's more a factor of the programmer involved and their skill, rather than any fault of the language in most cases. -- Stuart Longland (aka Redhatter, VK4MSL) I haven't lost my mind... ...it's backed up on a tape somewhere.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On 1/1/20 9:08 pm, Marc Espie wrote: > On Tue, Dec 31, 2019 at 10:36:15PM +0100, Anders Andersson wrote: >> Of course its age is showing in some areas but in my experience, those >> things are actually still worked on, and have been fixed without major >> incompatibilities (python3 anyone?). > The only thing that's really missing in perl is proper thread support. > Don't know if that's going to happen. To be fair, Python and NodeJS are pretty terrible at threading too. Python has the Global Interpreter Lock. NodeJS has worker threads, but they're pretty limited in what they can do IIRC compared to the main thread. Depending on what you're doing, this can matter a lot, or very little. -- Stuart Longland (aka Redhatter, VK4MSL) I haven't lost my mind... ...it's backed up on a tape somewhere.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Wed, Jan 01, 2020 at 03:30:44PM +0100, Marc Chantreux wrote: why is this ? return is the perl yield. the only difference is that the "exhausted" situation is on your own. so basically: def count_from(x): while True: yield x x = x + 1 naturals = count_from(0) print(next(naturals)) print(next(naturals)) print(next(naturals)) print(next(naturals)) is written in perl use experimental 'signatures'; use feature 'say'; sub count_from ($x) { sub { $x++ } } sub NEXT ($generator) { $generator->() } my $naturals = count_from 0; say NEXT $naturals; say NEXT $naturals; say NEXT $naturals; say NEXT $naturals; * perl were about unix culture, mailing lists and so on: they setup a confortable cocoon to work together and this cocoon became an echo chamber when the other communities started to use third party services like stack overflow. https://github.com/drathier/stack-overflow-import * the python community was unfair comparing the langages (using ugly perl code and nice python counterparts). instead of taking time to explain all the biases, perl community repetedly asserted that the authors of those article were incompetents and gone away. Not sure about anyone else, but comparing the Python vs Perl example you gave above, I would still say Python is the nicer-looking language.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
> Did you ever look at the suite of modules from John Syracusa (DB::Rose and > the like) ? fairly clean and nice. I had this under my radar but no one around be wanted to test anything else but DBIxC so i never took time to read the code or use it. regards marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Wed, Jan 01, 2020 at 04:44:48PM +0100, Marc Chantreux wrote: > > I still thing DBIx::Class is overkill. The DB::Rose stuff was way simpler > > and I would have preferred for it to win. > > Well... i liked the simplicity until i had some cases like having 2 > different DBs with the same model: piece of cake with DBIxC and > impossible with ActiveRecord (AFAIR). Oh, I'm not talking ActiveRecord. Did you ever look at the suite of modules from John Syracusa (DB::Rose and the like) ? fairly clean and nice.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
hello, > > what do you mean by this? prototypes are here for decades and signatures > > are experimental and i guess it will be core in some releases. > Stuff like > $o->method { code } ooohh right! this is a thing i also missed with perl (fixed in raku). > > Template toolkit is still by far the best template toolkit i know. > > i really thing the only thing where perl was not a precursor in web dev > > is plack (which is inspired by wsgi which is inspired by rack ... i > > don't know if there is another ancestor). > That's the big issue. Too much choice in the ecosystem, with some of it not > clearly enough explained... and no simple integration with js libraries for > ajax at first. > Yeah, I mean mason. At some point long ago, it was about the only > game in town for perl. yes! the eperl competitor. i remember that. > > ActiveRecord was easier than DBIx::Class for simple situations. that's > > one of the reasons of the popularity of RoR (also the Ruby syntax). > > I still thing DBIx::Class is overkill. The DB::Rose stuff was way simpler > and I would have preferred for it to win. Well... i liked the simplicity until i had some cases like having 2 different DBs with the same model: piece of cake with DBIxC and impossible with ActiveRecord (AFAIR). regards marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Wed, Jan 01, 2020 at 03:43:38PM +0100, Marc Chantreux wrote: > hello, > > > The only thing that's really missing in perl is proper thread support. > > Don't know if that's going to happen. > > seems ... complicated ... Tell me about it. The only existing thread support was so clunky it got thoroughly deprecated. It was really bad back in userland pthread days, because you couldn't even build perl binaries depending on threaded libraries (all-or-nothing -pthread flag) such as frozenbubble. > > I have a wish-list of things that are not that likely to happen, I would > > like to be able to use prototypes on methods, for instance. > > what do you mean by this? prototypes are here for decades and signatures > are experimental and i guess it will be core in some releases. You can't mix oo lookup and prototypes. Stuff like $o->method { code } for instance. you have to use the clunkier $o->method(sub { code }); > > Perl also missed a turn for web development. I think Catalyst was a huge > > mistake (hey, you've got *choices* everywhere. Let's confuse everyone), > > perl had CGI.pm, maypole, mod_perl, catalyst, jifty, dancer, mojolicious ... > Template toolkit is still by far the best template toolkit i know. > i really thing the only thing where perl was not a precursor in web dev > is plack (which is inspired by wsgi which is inspired by rack ... i > don't know if there is another ancestor). That's the big issue. Too much choice in the ecosystem, with some of it not clearly enough explained... and no simple integration with js libraries for ajax at first. > you mean mason ? mason is the php of perl: don't organize your code: > write a single page with everything in it ... it was a terrible thing > to maintain (see the code of request tracker...). Yeah, I mean mason. At some point long ago, it was about the only game in town for perl. > > Dancer was a few years too late to the party. > > sinatra (from ruby) was the source of inspiration of Dancer which, > AFAIK, appears years before flask and bottle. > ActiveRecord was easier than DBIx::Class for simple situations. that's > one of the reasons of the popularity of RoR (also the Ruby syntax). I still thing DBIx::Class is overkill. The DB::Rose stuff was way simpler and I would have preferred for it to win.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
hello, > The only thing that's really missing in perl is proper thread support. > Don't know if that's going to happen. just to be sure: are you aware of the MCE module? https://metacpan.org/pod/distribution/MCE/lib/MCE.pod regards marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
BTW. Also tcl has coroutines since a while: https://www.tcl.tk/man/tcl8.6/TclCmd/coroutine.htm Rodrigo.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
hello, > The only thing that's really missing in perl is proper thread support. > Don't know if that's going to happen. seems ... complicated ... > I have a wish-list of things that are not that likely to happen, I would > like to be able to use prototypes on methods, for instance. what do you mean by this? prototypes are here for decades and signatures are experimental and i guess it will be core in some releases. also, thanks to pluggable keywords, some very powerful modules exists like https://metacpan.org/pod/Function::Parameters > Perl also missed a turn for web development. I think Catalyst was a huge > mistake (hey, you've got *choices* everywhere. Let's confuse everyone), perl had CGI.pm, maypole, mod_perl, catalyst, jifty, dancer, mojolicious ... Template toolkit is still by far the best template toolkit i know. i really thing the only thing where perl was not a precursor in web dev is plack (which is inspired by wsgi which is inspired by rack ... i don't know if there is another ancestor). > so a lot of people didn't transition from Meson to another perl module, but > instead switched to ruby-on-rails or something like that. you mean mason ? mason is the php of perl: don't organize your code: write a single page with everything in it ... it was a terrible thing to maintain (see the code of request tracker...). > Dancer was a few years too late to the party. sinatra (from ruby) was the source of inspiration of Dancer which, AFAIK, appears years before flask and bottle. ActiveRecord was easier than DBIx::Class for simple situations. that's one of the reasons of the popularity of RoR (also the Ruby syntax). regards marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
hello, as intro: i would like to make clear that i'm not promoting perl (my go to langage for scripting is now raku by far) but as i was a member of the perl community more than 20 years, i have some opinions about it. > felt like a random hack, especially compared to ruby. The only thing I > really miss from python is "yield". why is this ? return is the perl yield. the only difference is that the "exhausted" situation is on your own. so basically: def count_from(x): while True: yield x x = x + 1 naturals = count_from(0) print(next(naturals)) print(next(naturals)) print(next(naturals)) print(next(naturals)) is written in perl use experimental 'signatures'; use feature 'say'; sub count_from ($x) { sub { $x++ } } sub NEXT ($generator) { $generator->() } my $naturals = count_from 0; say NEXT $naturals; say NEXT $naturals; say NEXT $naturals; say NEXT $naturals; there are complete modules on CPAN based on this. Perlude provide keywords stolen from haskell to make things more like shell scripting so the equivalent of grep root "$@" | sed 100q is use Perlude; now {print} take 100, filter { /root/ } sub{ // () }; Perlude is available on CPAN: https://metacpan.org/pod/distribution/perlude/lib/Perlude.pod > and ruby in parallel and ruby was definitely the winner there. I have > absolutely no idea why python even gained the popularity it has, it my opinion: python gained popularity during the dark ages of internet when most of the people (including developpers and IT people) were using windows and teach themselves how to use a computer or worse: learned from java schools. so python won because: * they took care about windows users * the langage is designed to provide simple solutions for simple cases which please most of the users (they don't need to maintain large codebases) * the default behaviors of the langage were the same than the langages learned in the java schools (POO, ...). the most obvious example is the "flatten values by default": * it became the center of the stupidest talk ever https://media.ccc.de/v/31c3_-_6243_-_en_-_saal_1_-_201412292200_-_the_perl_jam_exploiting_a_20_year-old_vulnerability_-_netanel_rubin * thanks to javascript, (with the rest operator and the destructuring syntax) they now all get the point and even python dpeople now have access to those features and like this. https://youtu.be/ggbi4SelOAo?t=955 so perl didn't fit the needs of the internet bubble * perl were about unix culture, mailing lists and so on: they setup a confortable cocoon to work together and this cocoon became an echo chamber when the other communities started to use third party services like stack overflow. * something i call "the 'hello world' pride": when perl programmers were just putting new modules on CPAN to get the job done, python ones were creating tools and projet sites and so on with a logo "powered by python". this has an impact on the myth of "perl is dying" * the python community was unfair comparing the langages (using ugly perl code and nice python counterparts). instead of taking time to explain all the biases, perl community repetedly asserted that the authors of those article were incompetents and gone away. * same situation regarding the constant FUD from the other dynamic langages perl people didn't realised how unixish perl is: * it's sad to realize that even linux users of nowaday are not confortable with the basics of awk, sed and so on ... and perl is born by improving the concepts of those langages and putting them together in one tool. it means that learning perl is easy for unix users: not for the rest of us. combined to the "DWIM" moto, perl has some unexpected behavior because it implies you should *know* what you should mean (which implies a unix culture). the most obvious exemple for me is the fact that <> iterates by default on ARGV, not on STDIN: ARGV is what you need to know when you want to write a filter but it's way too magic when you don't know the unix philosophy. * when perl gained popularity (the realm of CGIs), lot of aweful scripts were written by newbies both in perl and unix. the result was terrible and gave perl a very bad reputation. regards marc
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Tue, Dec 31, 2019 at 10:36:15PM +0100, Anders Andersson wrote: > Of course its age is showing in some areas but in my experience, those > things are actually still worked on, and have been fixed without major > incompatibilities (python3 anyone?). The only thing that's really missing in perl is proper thread support. Don't know if that's going to happen. Its garbage collector is also slightly peculiar... I remember looking really hard for a leak because a file handle in an anonymous sub wouldn't be properly collected (the one from pkg_add's progressmeter, actually) I have a wish-list of things that are not that likely to happen, I would like to be able to use prototypes on methods, for instance. > I remember a few years ago when I was briefly researching a > replacement for perl for my personal projects and I tried out python3 > and ruby in parallel and ruby was definitely the winner there. I have > absolutely no idea why python even gained the popularity it has, it > felt like a random hack, especially compared to ruby. The only thing I > really miss from python is "yield". Yeah, native coroutine support without a hack would be a blast. Even C++ is getting that for its next main revision. The popularity of python is partly explained by them catering more to teaching needs. As far as I know, there is no equivalent of the python notebooks. Stuff like jupyter means you don't even have to install complicated arcane stuff to learn python. Cool for the young pups. Perl also missed a turn for web development. I think Catalyst was a huge mistake (hey, you've got *choices* everywhere. Let's confuse everyone), so a lot of people didn't transition from Meson to another perl module, but instead switched to ruby-on-rails or something like that. Dancer was a few years too late to the party.
Re: perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Tue, Dec 31, 2019 at 4:30 PM Marc Chantreux wrote: > > On Tue, Dec 31, 2019 at 06:57:02AM -0600, Daniel Boyd wrote: > > As one of the few remaining people out there who considers perl to be > > their favorite language—starting to wonder if it’s just me and Larry > > Wall at this point—I’d like to say that perl should stay in base on > > its merits, all the perl-based system tools notwithstanding. > > one of the few remaining people ? is it so ? i really wonder ... > > Perl bashing is around the IT crowd for 20 decades and yet, when i > compare with other dynamic langages: > > * perl is the only one who gives me the conciseness and spirit of unix > tools combined to the power of a dynamic langage (the only close one > is ruby, the next level is raku, the others look like jokes to me). > so as openbsd people seems to be confortable with this unix culture, > i'm inclined to think that perl is popular here. > * CPAN is the best ecosystem to share code (metacpan is just awesome > compared to the other package sites, tooling is very good as well) > * the popularity of perl around me don't reflect the "perl is dead" moto > we heard since so many years (yes: there is a decline but it's in > flavor of compiled langages. the only one who switched to python > made this choice for money reason) > > both perl and openbsd popularities are underestimated just because > they still prefer mailing lists over stackoverflow (or other web > services who try to buzz with some charts) and don't care that much > about marketing. but still: i will be curious to know the perl > popularity in the openbsd community. Don't know if anyone cares because I'm not an OpenBSD dev (maybe some day I'll find something useful to hack on), but perl is definitely my go-to language. I agree with the "conciseness and spirit of unix tools", it is something that I have thought about but have never been able to formulate. Of course its age is showing in some areas but in my experience, those things are actually still worked on, and have been fixed without major incompatibilities (python3 anyone?). I remember a few years ago when I was briefly researching a replacement for perl for my personal projects and I tried out python3 and ruby in parallel and ruby was definitely the winner there. I have absolutely no idea why python even gained the popularity it has, it felt like a random hack, especially compared to ruby. The only thing I really miss from python is "yield".
perl popularity inside openbsd community? (Re: Suggestion: Replace Perl ...)
On Tue, Dec 31, 2019 at 06:57:02AM -0600, Daniel Boyd wrote: > As one of the few remaining people out there who considers perl to be > their favorite language—starting to wonder if it’s just me and Larry > Wall at this point—I’d like to say that perl should stay in base on > its merits, all the perl-based system tools notwithstanding. one of the few remaining people ? is it so ? i really wonder ... Perl bashing is around the IT crowd for 20 decades and yet, when i compare with other dynamic langages: * perl is the only one who gives me the conciseness and spirit of unix tools combined to the power of a dynamic langage (the only close one is ruby, the next level is raku, the others look like jokes to me). so as openbsd people seems to be confortable with this unix culture, i'm inclined to think that perl is popular here. * CPAN is the best ecosystem to share code (metacpan is just awesome compared to the other package sites, tooling is very good as well) * the popularity of perl around me don't reflect the "perl is dead" moto we heard since so many years (yes: there is a decline but it's in flavor of compiled langages. the only one who switched to python made this choice for money reason) both perl and openbsd popularities are underestimated just because they still prefer mailing lists over stackoverflow (or other web services who try to buzz with some charts) and don't care that much about marketing. but still: i will be curious to know the perl popularity in the openbsd community. regards. marc