136 points · by tosh · 3y ago · 71 comments
Differences:
* Actually Portable Perl runs on more operating systems, StaticPerl runs on Linux i386 (requiring i686 or newer processor), Linux amd64 and FreeBSD with Linux emulation.
* Actually Portable Perl has more of the standard Perl modules and C extensions bundled. StaticPerl contains only a few modules, simplified, with documentation and non-Linux support removed. StaticPerl is unlikely to work with existing Perl scripts with many use calls, but it is useful to write new Perl scripts from scratch, and these scripts will work with both StaticPerl and regular Perl.
* Actually Portable Perl executable programs are larger (5 MB minimum, StaticPerl is ~1 MB) because they are compiled for amd64 rather than i386, and they contain more Perl and C code.
* The first time an Actually Portable Perl executable program is run, it modifies a few bytes at the beginning of the program file (except on Windows). Thus these programs don't work on read-only filesystems unless they have been run on a read-write filesystem first. StaticPerl doesn't have this limitation.
There is a kernel patch to add APE (Actually Portable Executable) support to Linux removing the need for the the apeloader or assimilating. I'm not sure what the status is on that.
I'm thinking of serving content on 127.0.0.2. There is no need for a high performance server like nginx, but serving files and having some CGI capability would be a plus.
I'd be interested in suggestions for the HTTP server part and maybe an example for how do serve an index.pl file that reads payload files packaged in the APPerl binary (ex: .js, .jpg)
Then, I would create a custom build of APPerl using Perl::Dist::APPerl 's apperlm and modifying the apperl-project.json to pack in the script, CPAN modules, cgi files, and the static resources into a APPerl binary. When bundled into APPerl, the script can read the files embedded in APPerl from the /zip path.
Perl::Dist::APPerl (with tutorial on building apps): https://metacpan.org/pod/Perl::Dist::APPerl
MHFS's APPerl packaging config: https://github.com/G4Vi/MHFS/blob/master/apperl/apperl-proje...
https://www.oreilly.com/library/view/learning-perl-6/9781491...
Wrong. Perlers still cheer for it.
But for some reasons it hasn't wide spread adoption yet. We hope to use it some day in production.
When I was first learning to program and picked up Perl 5 (I was interested in Web programming, so... that was the thing to learn at the time) and then later read some books (yes, kids, we used to read books) on Java and C++, I wondered how the hell anyone could make sense of them. And hacking up early Javascript snippets (you know, for image rollovers, the only thing anyone used it for for the first few years) was so painful. It's just words! There's nothing to indicate what anything is! The examples in the books were so hard to read.
The answer, of course, was "they use syntax highlighting", but I'd not made that discovery yet.
Lol, you find bash readable? With all its weird ad-hoc constructs? I don’t pretend Perl looks pretty but at least its constructs seem to be consciously designed and do not look bolted on.
At my work place we still maintain a huge web application written in Perl 5. Most of the time if we are in trouble it‘s due to bad architectural designs that are not specific to Perl as a language or ecosystem. Only rarely I stumble over issues like implicit returns, or context sensitive sub routines. Also I hate Perl 5 allowing circular includes. The worst offenders among in-house modules are Perl modules written in a Java-esque style which mostly would have benefitted well from using native Perl features instead of trying to mimick Java programs.
> Lol, you find bash readable?
Note, they didn't say it was readable, just more readable.
Compared to that, bash is really anemic.
Python took Perl's money a bit when it came to scripting, Ruby – clearly influenced a lot by Perl – made big grounds in web apps, once they outgrew CGIs, and of course then we collectively got Javascript Stockholm syndrome.
But seriously, they're all good dogs. We all revel in the Narcicissm of Small Differences, but in the end it wouldn't really matter if we used Perl instead of Python or any other algol-ish imperative OO language with some functional bits.
It's linked from the page, but thought I'd point out if you're curious what went into making APPerl, check out the blogpost (self-plug): https://computoid.com/posts/Perl-is-Actually-Portable.html
Unix and Windows in the same binary?? Sacrilege! Haven't we still laws against witchcraft?
But the fact is: it gets shit done. It’s pretty good at dealing with strings and byte sequences, and even more importantly, it’s always fucking installed,
The “best” software helps you nothing if you’re machine isn’t running it.
Ugh. Close to half the bugs I’ve chased in Perl in the last 10 years are encode/decode string bugs (or more specifically, the lack of doing encode/decode where necessary). After just one ‘downgrade_utf8()’ use, you get sick of Perl pretty fast.
Basically try using it outside of the anglosphere in the world of Unicode and support falls apart. Sure is excellent if you need to do something like extract a bunch of 1980s database files encoded in LATIN-1 though!
Or, y'know, a bunch of 2010s database files encoded in latin1. Fun fact: Did you know that MySQL 5.7 is still a supported version in 2022?
Even then, I’d rather choose Python.
Perl has had strong unicode support since Perl v5.12 (~2010).
references: 1. http://xahlee.info/perl/perl_unicode.html 2. https://stackoverflow.com/a/6163129/12458
> If you think pythons package management is not disastrous enough, maybe.
Huh? I've used PAR::Packer with great success since 2005.
> If you do not (need to) consider Windows, maybe.
Microsoft used to ship Perl scripts to work with COM and WMI with their NT4 and Windows 2000 resource kits. Perl works *extremely* well with Windows.
I mean, there are lots of reasons to choose Python over Perl, but IMHO, these are not those reasons.
I use Perl as a better-bash. If I was writing a modern website, a large application, or any ML related work...I'd choose Python. But for complex system administration, I'm picking Perl. YMMV
A com file is different from a typical dos/Windows exe, which requires a specific file header. Each exe begins with the two bytes MZ followed by specific information on page sizes etc. and there is no way around.
The challenge a program like APP has is that it should be recognized by all operating systems, so to Linux it should look like an ELF executable, on Windows like a windows executable, etc.
Now if you take this APP perl.com file and load it with Linux, Linux will read the ELF header and be happy. If you load it into Windows, it will see the .com ending and thus just put the code into memory, jump to address 0100h and start executing. The program then can ignore the elf header. And if you open it with some (unzip) Programm such a Programm will look at the end of the file, where it will find a zip file header info and will think it's an zip archive. (Zip files have the header at the end mostly for historic reasons, as all information was only available once compression was done, but as you span multiple disks you can't reach the front anymore)
In the end it is a trick to make it look like different kind of file, depending on who looks at it.
An interesting effort and article from around 2001: https://www.foo.be/docs/tpj/issues/vol5_3/tpj0503-0003.html
And an old Perlmonks discussion on a 850kb Perl: https://www.perlmonks.org/?node_id=222465
There is a newer github project as well -- it did work for a simple project with core modules for me: https://github.com/bentxt/microperl-standalone
Shame there isn't a portable windowing toolkit you could use with this. I'm pretty sure it's not possible to get the Qt or GTK bindings to work across all platforms from a single install, even if you are using the toolkit's widgets instead of trying to use the platform native widgets.
However, the libc has grown a lot over the last year (Cosmo has a pthreads API now!) -- the updated libc enabled a quick experimental port of Python 3.11.0rc1 back in August (https://github.com/ahgamut/cpython/tree/cosmo_py311), so I would expect that a newer version of PHP can be ported similarly. Let's see....
(note it's an experimental port, I just put it together).
After stumbling upon Gautham's APE Python port (https://ahgamut.github.io/2021/07/13/ape-python/) [...]Does this support musl?