The Perl Foundation will now be known as The Perl and Raku Foundation
news.perlfoundation.org
news.perlfoundation.org
People used to read programming books. I learned both Perl and C from books; for me Perl wasn’t any harder. Yes, the syntax is unique — but you learned to read weirder things, C++ certainly isn’t any more intuitive in a vacuum.
But of course, few people read books anymore, so where do people learn languages? I guess universities and blog posts. (And increasingly YouTube videos, which have even less content density.)
Universities only teach old versions of Java. Blog posts are limited in size. Sad conclusion: any language that has more than a blog post’s worth of differences to Java 1.x will find it hard to reach very broad adoption.
It seems all classes of content from video, to blog posts and books suffer from various con-people publishing lots of crap with catchy titles and ordinary people just loose hope browsing through them. In such environment the cost of time spent on a crappy video or blog article is negligible, but if one buys books that are badly written or auto generated one can waste hours and hours before one realises.
So I can't blame today's wannabe programmers for choosing videos and blog articles instead.
Ok, but you can get most of Perl5 from 25 year old books at this point. (Wasn't the version number changed to 5 for a book anyway? or was that Perl4?). A little modernization help might be nice, use bytes vs use chars?, less emphasis on mod_perl which doesn't seem widely used anymore, maybe some coverage of Moose, etc. But if you got the basics from a old book, you'd be fine to learn the rest.
On the topic of new languages, I just started somewhere where they use Rust, and read the O'Reilly Rust book and seem to have done ok; lots of style comments on my first diff, and I'm slower than in other languages I already knew, but otherwise seems fine.
I forget what book I read to pick up Erlang; may have been Joe's or the O'Reilly; but that's an older language... It was public for ten years prior to me picking it up, and private for 15ish before then.
But the mechanics of the sigil thing never confused me. Either because it was explained to me very well, or possibly -- Larry Wall is a linguist, after all -- because there's an analogy to grammatical cases, which English largely doesn't have anymore, but my native language does.
The sigil depends on what you want to get out of the expression, not what you put in. So @foo would name the whole array, while $foo[2] would name a single element from it.
> If you just need to go one level in you can do either $foo[2] or $foo->[2] depending on your whims. It's kind of madness.
You misremember, but I don't blame you, it's a very unorthodox rule. These are very different expressions.
$foo[2] accesses the second (third depending on how you count) element of @foo. @foo is a "value array", whenever possible, I tended to use those because I found them more convenient and intuitive.
For programmers coming from JavaScript or Python, and people building more complex data structures, using a reference array might be more intuitive. Those are stored in scalar variables, like $foo, but to disambiguate with the syntax for accessing @foo, you have to explicitly dereference it with $foo->[2].
my @foo = (1,2);
$foo[1]; #2
my $foo_r = \@foo
$foo_r->[1]; #2
my @bar = (1,2,$foo_r);
$bar[2]->[1]; #2
Re the sigils, you're right, I would just add, $ is for scalar and a scalar iirc can be /either/ a value or a reference, that's why $foo_r and $foo[1] above both start with $. That's what I found unhelpful, it would have been nice to have a distinct sigil for refs (but presumably Larry was out of available symbols at that point!).Best exemplified by Lingua Romana Perligata:
https://metacpan.org/dist/Lingua-Romana-Perligata/view/lib/L...
my first paid software gig was writing perl and i still use it for text processing quick jobs and such but the truth is it’s just a weird language full of bizarre conventions that is a bad choice for building large systems. better languages replaced it
Raku on the other hand is easy to learn. Of course it is so easy to learn that knowing another language, any other language, can make it more difficult to fully grasp. That is because Raku is strangely consistent.
Most languages have a set of syntaxes for different actions. Raku has a set of features, and the syntax mostly just falls out from that.
When someone who knows another language tries to learn Raku they naturally translate what they already know to Raku features. That will only get you a surface level understanding of the language. No other language is really comparable.
Raku also has a new view of regexes. In Raku a regex is just a DSL for matching text. So rather than bolt on feature after feature like other languages have done it allows you to embed regular Raku code for situations where that is easier. You can also combine them using grammars (a type of class) to get a full parser out of several parts.
In fact the grammar feature in Raku is the only one that is powerful enough to parse Raku easily. Part of that has to do with the ability to mutate the language.
It has been said that the best way to solve a programming problem is to create a language in which solving the problem is easy. Raku, using that ability, allows you to do that easily.
No apology needed, I'm sure even Perl realizes it was a little stagnant while the rest of the industry zoomed by.
I used Perl in the mid 90's, so I suspect I'm ~20 years older than you. ;) Back then it was a jack-of-all-trades language, good at parsing logs or text files, pinched hit for php if you needed add scripting to websites, etc.
Over time, javascript improved, python gathered mind-share, and perl still worked but wasn't keeping up with new libraries.
I'd like to see Raku do well, although I doubt I'll use it professionally - seeing as how I've got around ~8 years left until I retire.
I have been frustrated by framework walkthroughs that fail to explain the expected prior knowledge. Recently I've been using Laravel, and something as simple as "You need to include the following 'use' statements" would have saved me tens of minutes several times over by now. They just launch into code, with no context. I fear they know that if they make the content long, no one will read it.
I'm left frustrated by the experience and I suspect long term anyone that cannot be bothered learning half a page of content isnt going to make anything long lasting anyway.
I've not found colleagues who learned Java or C# first have had trouble learning Perl. When they've learned "modern" Perl with Moose/Moo, they've been happy with it.
You could literally start at the top, work your way down and learn all of the useful functions and data structures.
wtf?
That's like going back to the 1600s and learn astronomy.
I think Perl's decline started 15-20 years ago, as that's when Perl 6 was "coming soon", and people didn't bother learning Perl 5 because of that. I can't remember ever seeing an interesting article about programming in Perl, either here or on Twitter.
Reminds me of the Osborne Effect. https://en.wikipedia.org/wiki/Osborne_effect
also, i think there's a lot of very old and rotted code out there now that is probably very confusing to try to learn from.
These days information is so much more readily available for free, but it feels so often I have to resort to reading StackOverflow, shitty YouTube videos, and even shittier OFFICIAL documentation from developers who obviously don't care about technical writing. Machine Learning is especially bad about this.
But using Perl in the real world was much more difficult. Posting to Perl Mongers about a simple question of some block was often met with equally difficult answers. Many Perl scripts used at my past work places were written by very well versed Perl developers, using every possible shortcut to make the code smaller (and more confusing).
what makes perl hard is to learn all of it and deal with code that uses features that you haven't learned yet.
perl is like english. easy to get started with, but the more you learn the more complex and more difficult it gets
I used it recently to generate reports from analytics and it felt good. If there are remote jobs calling for Perl, send them my way.
Plenty jobs for Perl developers.
But once you get over that, it's a great language. First-class regex, -pine options. A lot to love about it.
At my $work, most of our code is in Perl, roughly a half-million lines of it dating back to the mid-1990s.
There's no point in rewriting it in something else, since the cost in resources to do that would outweigh the potential salary savings by hiring cheaper programmers who know Python or C# or whatever. (My experience with some other companies is that they want to move away from Perl because Perl programmers are more expensive, not because it's a worse language.)
Likewise, there's no point in starting new projects in another language since we'd then have to hire people people competent in both of those languages.
My experience is that people who turn their nose up at "old" tech like Perl are not worth hiring. If they don't care to learn about the technology you are using, then they won't care to learn about your industry or your company's business logic.
Maybe because I knew C and some bash and awk, Perl wasn't alien to me at all.
Coming from a Pascal and Java background, it was a breath of fresh air. Programming was actually fun.
Yeah, either the language gives you magic variables, or you make your own one's in the programs you write. Programming isn't sorcery. Somebody has to write the code for features a language doesn't give you. That the is whole problem in essence, the more minimal your syntax goes, the more code you will write for features the language doesn't give you.
Good part about the Perl magic variables is at least they are documented.
There's genuinely nothing I enjoy more at work than deciphering, debugging, documenting, and ultimately refactoring Perl code. Even if I'm improving it to extinction e.g. turning parts of a legacy stack into a service with an API, ready for a replacement in some other language to be swapped in.
The problem with Perl isn't that it's old. It's bad in ways that other old languages aren't. Consider all the people who like C but not Perl, even though C is older.
The new releases usually come with bug fixes, speed-ups, additions to the core language, optional syntax features, etc.
The only way one gets to use an "old" interpreter is if they're stuck on an old OS release (i.e. RHEL?) and/or they don't build their own version and use the "system" Perl.
I build my containers and put Perl right in them. Makes the container a little chubbier but no outside dependencies.
Most shops don't have the budgets for total rewrites, or even partial and gradual rewrites.
The way old things die, is that new projects don't get started in those languages. To that end, Perl is something of the past already. It is still a very useful technology for a lot of Unixy work on adhoc tasks. But I doubt people learn Perl the way, they learn Python these days. Older people(including me), call upon Perl for lots of work even till date. This is similar to how people continue to use vim/emacs despite things like vscode. There is always going to be a audience for these tools. But the crowd moves on.
The Perl interpreter has been regular updated and improved. There's a new release of Perl every six months, and the libraries on CPAN provide access to various other kinds of technology and tooling.
And there's only one implementation. Doesn't seem very healthy.
Perl doesn't seem to have anyone making this kind of effort? You're stuck with the tech from decades ago.
This is a good thing, because it means that we don't have to worry about a program running on one implementation vs another.
Also, one of the things that Perl is great for (unlike many other scripting languages) is backwards compatibility. A program written in the 1990s for Perl 5.004 will probably run with minimal modifications on Perl v5.36.
That's the same for almost all languages though? Which major languages aren't open source or are owned by a company?
So?
> And there's only one implementation. Doesn't seem very healthy.
LOL, okay, this is just hunting for complaints. I could list a half dozen languages that don't have multiple implementations (Rust, Java, Scala, C#, PHP, Go) and yet I've never seen anyone raise that as a concern.
That's because you're misinformed! These languages all have multiple implementations (Scala's is just multiple backends), so yeah people don't complain about it.
But hey, why not, I'll give you that one (tbh, I knew including Java on that list was a bit of a stretch).
Care to try with any of the others?
Wanna try to convince me, next, that HHVM qualifies as a reimplementation of PHP despite no one outside of Facebook using it?
But you know what, no, I have a different question: Why does this actually matter? You've positioned this as some sort of objective downside to Perl without explaining why anyone should care. So why don't we start there, rather than my taking your objection as being somehow relevant.
Please, explain to me: Why should I care that Perl (like so many other languages) only has one real implementation?
Because it fosters innovation. Perl isn't innovating as an implementation. Why's that bad? Because you don't get better performance or capabilities, and you're spending more to run it, and spending more to manage it.
> Care to try with any of the others?
For example Mono is a full clean-room implementation of .NET including C#.
> tbh, I knew including Java on that list was a bit of a stretch
Sure. Sure.
It is true it doesn't have a JIT, though.
Which bit was wrong? It has a basic bytecode VM - isn't that the 90s era interpreter tech I was talking about?
> It also uses reference counting, it does not have a GC.
Reference counting is GC.
Neither has any plans to move off it. The opposite, actually.
Like them, there's likely dozens of others. Dozens, I say!
One of the main reasons I chose Perl is it's commitment to not introducing breaking changes.
https://hn.algolia.com/?dateRange=all&page=0&prefix=false&qu...
At $work, we're sticking with Perl [reasons elsewhere in this thread]. But if we were going start projects in other languages, it would probably be Python or Node.
For personal projects, I'm more interested in Rust than Raku.
That is, if python isn't using external dependencies.
If you are writing an app for decades long usage, node is probably a bad choice.
Perl, python, will be around... well, I dunno, decades more at least.
But perl? As someone else said, the code you write now, will work 30 years from now. That's its thing, its happy smile.
Imagine, just imagine writing code that doesn't vanish 2 months after you leave a place. Imagine code your great grandkids might tough.
It doesn't help that most of the times, Perl fails with a very confusing error message that can leave you scratching your head. And it seems all the Perl wisdom has gradually vanished with very few answers to your questions. It wasn't a bad language for its time, but with the number of alternatives, I just don't see a valid reason to use it.
[1]: https://stackoverflow.com/questions/4625408/where-can-i-find...
Surprisingly, I timed the parser part and it took only 0.06 seconds to process a 2500 line file. Yes, perl is 30x slower than C, but computers are so fast that performance (for my needs) doesn't matter too much.
To be fair, it is only the subset of verilog that one would typically synthesize (so no events and forks/joins, no timing annotation, etc). Doing the whole language would make the code larger but not much slower.
The backend of my network programming challenge[0] is all Perl daemons, including the web API, the solution checker, leaderboard calculation, and new problem announcement mailing. (The frontend is Next.js, but it's not using any server-side JavaScript, it's delivered as a static site).
Perl is good because it is very quick to write. Common idioms are very terse, first-class support for regexes is a superpower, and the TIMTOWTDI philosophy ("there is more than one way to do it" - polar opposite to Python) means you can often find a quick and succinct way to make most small code changes you want to make.
I am personally looking to move away from Perl for new projects for the following reasons:
1. Perl doesn't have sensible support for multi-threading.
There's "use threads", which is quite heavyweight because (as I understand it) every time you make a new thread with "use threads" it creates a memcpy() of the entire interpreter.
There's "use forks", which is the same as "use threads" except it uses fork() so that the "copy" is less expensive (because Linux gives us copy-on-write). "use forks" is still bad because inter-thread communication still involves serialising your data and passing it over a pipe, and you don't necessarily notice where you're doing it.
Then there's Coro[1], which is actually very very good, for what it is. Coro allows you to write code in a straight-line synchronous style, but allows you to cede control to other threads when you need to wait for a result to become available. Coro calls itself "the only read threads in Perl", but it's still not real threads in Perl because it still doesn't let you take advantage of more than 1 CPU. In my experience Coro also interacts poorly with XS (i.e. native code) modules that aren't reentrant, and it's difficult to predict when you might be using such a module, and sometimes your Perl scripts will segfault or leak memory through no obvious fault of your own. But Coro is a really neat hack.
If you actually want to make use of multiple CPUs, the best option (IMO) is to fork() manually and keep inter-process communication to a minimum.
2. Further than multi-threading, Perl doesn't even have sensible support for async/await style concurrency.
The closest thing to async/await style concurrency is AnyEvent[2]. AnyEvent is quite good, and I think is the best way to write asynchronous code in Perl. But it still doesn't hold a candle to basically any modern programming language, because you still have the "callback hell" style of passing closures as an argument to anything that has to be asynchronous. This is extremely annoying and results in enormous, complicated, and error-prone refactors if you ever have to change a component deep in your stack from synchronous to asynchronous. For example, if you are moving away from a hash table "database" to an actual RDBMS, and you don't want your database queries blocking your entire application, this is extremely painful, because everything that lives higher up the stack needs to be rewritten in "callback hell" style. See "What color is your function?" for more on this.[3]
3. Lots of things that should be caught statically don't actually cause problems until runtime.
This is mainly because Perl is dynamically typed and isn't compiled, but it is annoying, and avoidable in other languages.
What language am I moving to? I don't know yet. Probably Go. I don't like how opinionated Go is about a lot of things that Perl doesn't give a shit about, but it is at least quite small.
I don't like Rust because it seems overly bloated (the recommended way to parse command-line arguments - "clap" - involves downloading 140 megabytes of dependencies off crates.io, which just seems unreasonable), although the borrow checker is a very interesting idea.
I'm also interested in Zig, but I think the Zig community is possibly too small at the moment, and not being fully memory-safe seems overly risky. But I haven't written enough Zig yet to know whether or not I like it.
[1] https://metacpan.org/pod/Coro
[2] https://metacpan.org/pod/AnyEvent
[3] https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...
Where do you get that from? https://lib.rs/crates/clap states that the code itself is 1MB, and the maximal amount of dependency code is 7mb, with all optional features enabled.
EDIT: A blank "cargo new" project plus a clap dependency weighs 143 megabytes, not 400. Maybe the 400 megabyte project had another dependency as well, I can't remember. I've edited the comment to say 140 instead of 400.
$ cargo build
Updating crates.io index
Downloaded clap v3.2.23
Downloaded textwrap v0.16.0
Downloaded proc-macro2 v1.0.47
Downloaded clap_lex v0.2.4
Downloaded hashbrown v0.12.3
Downloaded clap_derive v3.2.18
Downloaded once_cell v1.16.0
Downloaded libc v0.2.137
Downloaded os_str_bytes v6.3.1
Downloaded unicode-ident v1.0.5
Downloaded syn v1.0.103
Downloaded 11 crates (1.4 MB) in 3.71s
Compiling proc-macro2 v1.0.47
Compiling version_check v0.9.4
Compiling unicode-ident v1.0.5
Compiling quote v1.0.21
Compiling syn v1.0.103
Compiling autocfg v1.1.0
Compiling libc v0.2.137
Compiling os_str_bytes v6.3.1
Compiling heck v0.4.0
Compiling hashbrown v0.12.3
Compiling textwrap v0.16.0
Compiling strsim v0.10.0
Compiling termcolor v1.1.3
Compiling once_cell v1.16.0
Compiling bitflags v1.3.2
Compiling clap_lex v0.2.4
Compiling proc-macro-error-attr v1.0.4
Compiling proc-macro-error v1.0.4
Compiling indexmap v1.9.1
Compiling atty v0.2.14
Compiling clap_derive v3.2.18
Compiling clap v3.2.23
Compiling clapdemo v0.1.0 (/home/jes/clapdemo)
Finished dev [unoptimized + debuginfo] target(s) in 36.61s
$ du -h | tail -n1
143MAs anyone who is used to languages like C or C++ knows, debuginfo tends to be huge. It's not surprising that your "target" directory (where both the intermediate and final objects are stored) is that big.
> Downloaded 11 crates (1.4 MB) in 3.71s
Here, you see that 11 of your dependencies together (including clap) were a download of only 1.4 megabytes.
And you won't see these 1.4 megabytes in your "du" output, since the downloaded crates are stored in ~/.cargo instead of within your project directory.
Actually this is surprising to me. All it does is parse command-line arguments. I am surprised that this creates 143 million bytes of information.
I accept that I was wrong to say this data is "downloaded" off crates.io, since it is in fact created locally.
> 11 of your dependencies together (including clap)
This is obviously a matter of taste, but to me, this is too many. In the event that sensible command line parsing is not part of the core language, it could at least only be a single dependency.
1. Unoptimized builds tend to be excessively large. LLVM's opt binary (citing this because it's something I have easy access to) is 30x larger on an unoptimized build than an optimized build. [I think Rust is even worse than C++ at the unoptimized/optimized size ratio]
2. Debugging information is also excessively large. It's not counted in the above statistics I gave because I use split debug information (which keeps it out of the final executable for easier linking), but you're looking at debug information being a significant fraction of code size--maybe half of the total binary size could be debug information.
3. Because you include the build directory, you're carrying two copies of everything, minimum--both the .o files and the executable they link into.
For a rough comparison of LLVM, the llvm source directory I have is 1.5G, the optimized release build I have is 15G (of which 1.7G is the actual binary executables), and the unoptimized debug build I have is 86G. Of course LLVM is unusual in producing a very large number of statically linked executables.
4. One of the dependencies inside clap is the procedural macros stuff (specifically, quote/syn crates), which basically requires building your own copy of the Rust parser. If you drop that dependency, the build directory sizes should be far, far smaller.
clap = { version = "3.2", features = ["derive"] } $ du -h | tail -n1
=>
$ du -shI've never thought so. With Coro's rouse_cb/rouse_wait, you can use almost every callback-style methods in async/await manner.
You only get to appreciate that once you invest a fair bit of time writing Perl code. In the heyday of Perl, a lot of people got there because frankly there few other options. Today, there are lots of scripting language options that are arguable easier to pick up so far fewer people reach Perl Nirvana.
I do have to say I miss how Perl modules have sensible names that at least try to describe what they generally do.
Also, that's where Perl seem to have got its syntax from, so if you ever do have to dig into Perl code, it won't be as difficult:
http://www.wellho.net/mouth/3902_Shell-Grep-Sed-Awk-Perl-Pyt...
However, using Python's re module for regular expression matching results in far more readable code than any of the predecessors, particularly as expressions get more complex.
The deeper issue is .. maybe not. I never have any interesting data lying around in text files, it's all in SQL databases or behind JSON APIs or maybe in XML or even Excel files. So if one doesn't need sed/awk/grep/etc, then they are never going to reach for perl.
Not sure which parts of Perl syntax you find off putting, but I could guess.
1. Sigils: Why is this bad? Perl has symbols do represent lists(@), associative arrays(%), scalars($). This is actually more readable than Python's approach where there is no symbol to indicate things. The only place where symbol pollution gets out of hand is where you need nested structures. But even there having explicit indication of what's what is better than leaving programmer guessing. Note how this is a program design problem, than a problem with the language itself. To me the only time I deal with this when I'm parsing XMLs and JSONs. Nothing much can be done there because XMLs and JSONs themselves are nested structures.
2. Regular expressions: How else would you represent regular expressions? Do you want Java style
string.matchAtStart('x')
.matchAtEnd('.')
.dontMatchImmediatelyStart(...)
.noAlphaNumericChars(...)
.exceptChars(...)
...
...
See how verbose this gets and very hard to read, it's really the equivalent attempting to do math in words than symbols.3. References: There are places where you are better of passing a reference to some data, than passing the data itself, for obvious performance and efficiency reasons.
4. Quote words, expressions: Very useful for rapid scripting, and adding data without having it to massage it to a program's syntax.
5. Text utilities: Like chomp, tr, grep. Make it very easy for Unixy work. Why are these even issues?
Perl also contains your regular list manipulation utilities, and OO features. Overall very useful. Not sure where this 'hard to read syntax' thing comes from.
>>However, learning simpler Unix tools - i.e. grep, sed and awk - is worth the trouble, as those are very useful tools for command line tasks, and work with pipes.
There are lots of limitation with those tools, you can't do work with several files. You don't get error handling. You are stuck with a paradigm of working on line/block at a time. You can't do other stuff like make Rest API calls. You can't do XML/JSON stuff, the list goes endless because they are not by definition regular programming languages. In fact Perl exists to address these limitations.
>>However, using Python's re module for regular expression matching results in far more readable code than any of the predecessors, particularly as expressions get more complex.
No Python got famous, because its users never worked with messy early internet work. Like having to deal with multiple data formats, log files, API responses, database work with no standard data exchange formats. Perl lost a lot of its utility when JSON and XMLs became ubiquitous.
And yeah Python was never big in Unix world either. Its main use was for developing web apps(Django, Twisted Matrix etc).
For that even today Python is bad at anything which has non trivial data work.
Problems related to bad programming, programming practices, bad program design, syntax bloat etc etc. Today exist with Python too. Python 3.x series is really how we do Perl stuff the Python way.
You know how people in languages without grammatical gender (like English) complain about grammatical gender when they encounter them in other languages (like most other Indo-European languages)? It's the same basic thing: if you come from an environment where it's not present, it seems unnecessarily fussy to have to specify it all the time.
> 2. Regular expressions: How else would you represent regular expressions?
Actually, my big problem with Perl is its use of regexes. It's not that the regex syntax is bad (and Perl actually tends to let you make regexes more readable than other languages). It's that Perl code tends to be written so that basic string operations are all replaced with regexes, so figuring out what you're actually doing becomes somewhat annoying. "if !key.startswith("TARGET")" is much easier to read than "if $key !~ m/^TARGET/"
> For that even today Python is bad at anything which has non trivial data work.
Honestly, I've found that Python does a better job than any other language I've used at doing the basic drudgery of getting data from one format to another--I've even used it to get JSON-like dumping of binary formats!
a = re.compile(r"""\d + # the integral part
\. # the decimal point
\d \* # some fractional digits""", re.VERBOSE)
Also, the Python re basic functions - match, search, fullmatch, finditer - return match objects which are not so bad to process, and the other functions - findall, split, sub, subn - are well-documented and easy to interpret. The pattern being used is also clearly separate from the functions that use it, making it easier to understand.In contrast, Perl regex tutorials are a bit more complex... such as:
https://perldoc.perl.org/perlre
Basically, it seems you can get the same functionality with Python but with a less steep learning curve, and it's easier to read and maintain than Perl.
It's been a long time since I last programmed in Perl, but as I recall the confusing part was that for instance a list might use @ or $ depending on what you're doing with it, and the same for associative arrays, which might use % or $ depending on what you're doing with it; the same variable might use different sigils in different parts of your code, instead of staying with the same sigil for its whole lifetime.
$ means a scalar (number, string, reference)
@ means an array/list
% means a hash (also known in other languages as a map, associative array, etc)
A list item and hash keys and values are all scalars. So the array is @foo, but the items are $foo[0], etc. References get a bit ugly if you need to access a whole container whose reference is stored in another container, and also if references are used gratiutously: I've worked in code where no arrays or hashes were used, only ArrayRefs and HashRefs, ugh.
No I think its easier to read. But I prefer verbosity over cleverness.
https://perlmaven.com/open-and-read-from-files
https://stackoverflow.com/questions/1045792/how-can-i-list-a...
I simply cannot remember that stuff, and frankly it's too much hassle. I want to make one call to a simple, built-in function to load a text file, and similarly for looping over the files in a directory. I find Bash plus other Linux tools to be easier than Perl, even though most everything else is easier in Perl.
And if you really wanna deal with files and directories, IO::File and IO::Dir are easier interfaces to work with and there's plenty of other helper modules out there. I'd never use the base primitives as described in that article.
Mix in File::Find or equivalent and Perl is incredible for file handling.
There's a profound difference: PHP 6 was never released (it was abandoned before its official release), but Perl 6 was released under the "Perl 6" name (https://developers.slashdot.org/story/15/12/26/0354235/perl-... is one reference, you have to use the web archive to look further since the release history became somewhat hidden after the rename).
In 2000-ish, they announced Perl 6 with great fanfare. People started working on something called "Parrot" which was supposed to be awesome in every way. Quickly it came out that Larry Wall was going to do a serious redesign of the language. It wouldn't just be Perl 5 on a VM, but have a significantly different syntax.
A lot of people then became very reticent to start new big projects. Because Perl 5 was evidently about to be dead, and Perl 6 was some new incompatible thing, so why spend all this effort on writing code now that'll probably need rewriting later? Python suddenly became more interesting.
It turned out that project management was lacking. Perl 6 attracted lots of theorists and fans of experimentation and few people interested in getting out something usable in a timely manner. Multiple VMs and varieties came and went. It took until 2015 until something was released. By then, Perl was already moribund.
It quickly became even more clear than Perl 6 and Perl 5 were different things entirely. Perl 6 didn't share the architecture of the Perl 5 interpreter, so XS wasn't a thing, and XS was a huge part of many prominent modules which meant that a lot of the Perl 5 CPAN modules would be a lot of work to port. The fact that Perl 6 was presenting itself as the successor while Perl 5 still existed and was being worked on didn't help.
In the end Perl 6 was renamed to Raku to make this more explicit -- it's not Perl 5's direct successor, but a new language built from a similar philosophy but otherwise an entirely new creation. But I think by then it was already too late, it'd have been better to do the renaming way before 2015.
The 15 year long development cycle also didn't help -- it created all sorts of confusion and uncertainty about the future. Meanwhile, the upcoming Perl 6 project just wasn't suitable for almost anything other than working on the interpreter itself, and that excluded a lot of Perl programmers who were used to writing in Perl, and not working with the actual guts of the interpreter.
I do think before Python there was no real alternative. We tried C for web development but it was a huge pain. The Python CGI module changed everything for us (Reading about it in the German iX magazine)
That said, having had to deal with perl professionally a few times in the last 10 years, the biggest drawbacks I find in it for larger-scale projects are:
- A lot of people are perl programmers, not programmers. I'm not tied to any language, believe in using the best tool for a job, and believe in using a language I'm not a big fan of if that makes it easier for a wider team. A lot of perl programmers I met don't feel the same and (wrongly, IMHO) think perl is the best language for every use case out there.
- It's lacking in instrumentation when compared to other languages and VMs. It's more challenging to debug production problems with perl than with, say, C (and that should say a lot...)
- There's no reliable way to limit resource usage of programs, which can be very bad when running on servers. Even worse if your perl code shares the server with other code. I think that's one of the reasons new Percona Toolkit tools are written in Go and not perl (but I could be wrong). It can be dangerous to run some perl scripts on a database server, for example. I suppose cgroups/containers/etc can help there, but only in a circuit-breaker way: I don't think there's an easy way for one to write perl code that can keep its resource usage under a predefined limit and still continue to work when the limit is reached.
- Kind of like lisp, a lot of the power in perl also means that if a team is not tight and some coding standards are agreed upon, you end up with multiple custom languages sharing a codebase. Something like python takes care of this because there's usually a single way to do something. That also makes it more boring from a programming language perspective (to some people, to any extent) but as engineers our role is not to do cool, fun, and interesting things; we need to solve problems in a reliable and predictable way. Think of the people who carry a pager and will be waken up when there's a problem involving your code, even if that's you (your 3 AM self will thank your 2 PM self for not being clever with the hacks, trust me).
That said, I'm happy the ecosystem seems healthy, I'm glad we have languages like perl that let you take a 25 year old script and run it today without changes. And reading all the people on this thread that work on perl, if it works for you and you get to make a living off of the language you love: cheers to you, and I'm sure there'll be job openings for perl programmers for at least another 2 to 3 decades.
Perl not only makes it the syntax difficult with all the absurdities (special variables, so many prefixes $,@,%, terse function names, tens of ways to do one thing), it also makes it impossible to Google. Imagine spending your whole afternoon trying to dig what "($fc) = /^(.)/" does; a maintainer's nightmare. I am not that old but from a little searching, it seems to me Perl always had a bad reputation, and for good reasons.
Why are you maintaining Perl code without knowing any Perl though? This syntax is obvious to anyone who went through the trouble of following the basic tutorial.
It's a language you need to learn before using it. It's unfamiliar, but not unreadable.
> It's an active struggle to make Perl code readable and it not turning into a mess
Are you speaking from experience? I don't find that to be the case.
I don't understand Haskell, but that's because I never bothered to learn it. Should I say it's a crap language just because I do not understand the basic bits right off the bat?
There are good reasons to dislike Perl (I have my own good reasons, having worked with Perl professionally for close to 10 years), but the syntax is really not one of its real problems.
The issue with that is that it's a core part of the language's syntax so how are you going to search for something like that? It's a bit like trying to search what the `Obj foo{3};` means in C++, nothing in the text is a keyword, so it will vary from one program to the next and therefore won't be searchable.
/^(.)/ is a regex match with a capture group. Perhaps this produces a list or tuple like ("a") if the buffer starts with "a", and that becomes the value of $fc.
So that is to say, maybe ($x, $y, $z) = /(\d+)-(\d+)-(\d+)/ breaks down a string like 123-334-559 such that $x gets "123", $b gets "334" and $z gets "559".
I did a very small amount of Perl 4 programming in the mid-to-late 1990s.
($fc) = /^(.)/
We're doing a regexp match, capturing the first character of a string. This is an usage of the implicit $_ magic variable. The () in the regexp means we want to capture this part, and the "." matches any character. ^ is the start of the string.We're doing ($fc) rather than $fc because regular expression matches work differently depending on context. In array context they return a list of matches. In scalar context they return a match count. So the ($fc) forces an array context to return the actual match.
So, TL;DR in a more traditional language this would be:
firstChar = left(someString, 1)
And actually in Perl you could do: $fc = substr($var, 0, 1);
as well, which would be far more understandable to a less Perl-inclined person, but with regexes being such a core part of the language they tend to show up for purposes users of other languages may not expect.This is indeed a pretty good demonstration of some of Perl's quirkiness. If you like it, it's nice and flexible, if you don't, then it's annoying as hell.
Got it, so all languages should look kinda similar so you don't actually have to learn them to grok the code.
Let me guess, you also dislike Lisp, Smalltalk, and Haskell?