A Perl toolchain for building micro-services at scale
engineering.semantics3.com
engineering.semantics3.com
The real-time support is awesome; setting up Websockets is stupidly simple; coding non-blocking services is, I think, easier (at least more concise) than in Node.js (though it uses a similar callback model); testing is just perfect (Mojo has a user agent and DOM support, so you can write super concise tests for web services); building multiple outputs (like HTML for humans and JSON for API) for the same routes is excellent. So far, none of the frameworks I've looked at has been as concise or as...neat, I think might be the right word. So many things about it have me saying, "Now, why didn't someone think of that earlier?"
It's pretty tightly focused on just doing a few things really well, so it's not like a Rails, or even Django, experience...you have to make your own decisions about what ORM to use (or not to use an ORM), front end (though because it is agnostic about front end, you can use whatever you like pretty readily...so, React/Redux, Angular, whatever), and even nitty gritty stuff like authentication and accounts and such. I occasionally find myself wishing it had a little more batteries included, but mostly I like that it doesn't take days of doc/code spelunking to grasp the whole system.
Anyway, I'm not a Perl fanatic, though I like the language OK; especially in recent versions. So many little warts have gone away in recent years. But, the web service ecosystem in Perl is surprisingly strong and modern, given how unpopular it seems to have been in recent years. It's been a while since I really dug into what goes into building a new Perl system, and a lot of cool stuff has been completely off my radar. Mojolicious, in particular, is one of those things.
Well, there's a lot of helper modules[1] on CPAN (somewhat different than the ones linked in the article), so that may alleviate that concern a little bit.
Mojolicious is bar-non one of my favorite Perl technologies. :)
1: https://metacpan.org/search?size=20&q=mojox&search_type=modu...
But, I agree...Mojolicious is a lot of fun.
do you have something to recommend ?
used Rose::DB in the past, then I discovered SQLAlchemy and it's difficult to look back...
DBIx::Class
Kavorka / Function::Parameters / Method::Signatures (take your pick)
Moose / Moo (or use Moops and get Kavorka above built in!)
Mojolicious
Notable mention: Path::Tiny (and Try::Tiny, but everyone should know that one).
It's taken me awhile to find the happy medium where I'm not sticking too much in DBIC ResultSet methods, but being able to define complex search methods that chain is awesome:
my $rs = Schema->resultset("Foo")->unprocessed->rows(100)->order_by([-desc=>'time']);
$rs = $rs->for_user($user) if $user;
$rs = $rs->recent_entries; # Limit to the last week
Makes my life much better, and makes it so much easier to change me schema as needed.Love DBIx::Class.. but it's not a good/perfect fit for Mojolicious by a long way.. it's blocking by nature and thus doesn't play too nicely if your aiming to write a non-blocking mojo app. reply
I think my question is: Is there an SQL ORM in any language that is non-blocking during queries, without the programmer having to wrap it in some sort of promise/callback/whatever? I really have no idea about ORMs, so I don't know anything about the state of the art. I'm trying to imagine what such a creature would look like...it seems like if your queries are going to potentially make you wait for any amount of time, you'd need to account for that at the caller side, even if things happen on the ORM side.
We investigated a lot of other options (go & python specifically) when building new projects, but found that perl was the best solution. It's flexibility allowed us to develop a custom and durable solution that surpassed our expectations.
We ran into some environment/portability issues and resorted to using docker, carton, and gitlab CI to solve these problems. It is incredible how reliable and easy it became to modify and deploy code to a variety of systems (new or old).
Not obsolete - can affirm. All of the Oh By[1] back end is written in perl, circa 2016. We use apache + mod_perl and are very happy with this environment ... just like we were in 1998.
[1] https://0x.co
I've continued to be productive by writing applications, microservices, and websites in Perl. Though these days it seems few people care to hear about the details as it isn't the flavour of the day.
Mojolicious is cool, although I've usually stuck with Dancer instead (which is itself a clone of Ruby's sinatra).
Module growth is strong, and accelerating.
Not quite the hallmarks of something going the way of COBOL.
Note also that Fortran is also in heavy use in various science fields. Rumors of its impending death have also been greatly exaggerated.
Yeah, sure, hire a Ruby/Python programmer ... and try to trick them about the language they're going to be using by being vague about it in the job posting and initial conversations until they got really interested?
Been there, done that. It was a stopgap measure that sort of worked and it wasn't that much fun.
Hire for good programmers, and they'll be good Perl programmers if they need to be.
I've taken some steps to do a re-implementation in node, but the perl version "just works" with very little fuss, under fairly heavy load, and is pretty easy to debug when I need to.
This is very much a microservice: tailored PXE environments as a service based upon a database, and the booting mac address as a key. A programmatic/database-based backend to a PXE server. It allows us to boot effectively anything that is bootable by modern hardware, from Linux, Windows, SmartOS/OpenSolaris, through FreeDOS, and other more esoteric systems. A number of our customers use this as a configuration tech underneath their own orchestration layers.
All Perl based, and using as modern techniques as possible.
We stopped using system Perl many years ago. Red Hat seems to like to ship not merely obsolete versions, but versions actually past their end-of-life, so that they are not really supported upstream anymore. They have a similar issue with Python and other languages. So, reluctantly, about a decade ago, we started building our own toolchain. First with Perl, then adding in Python, Julia, R, Octave, and other analytics codes. Our analytics tools use all of these as part of our SIOS rambooted appliances (http://scalableinformatics.com/fastpath), so we needed the updated toolchain. We are looking at Rust as well for future work, and have looked at incorporating Go, but we don't have any Go code developed/planned as of yet.
From there it is simple to call custom tools to build and deploy services in Perl.
My favorite feature about Perl is that version 5.x is compatible with each release and our code has worked without issue for over a decade.
I recently integrated some Go code into part of my module and wrote a post about how to compile it as part of the build process here : http://www.tysonmaly.com/programming/go/using-go-perl-makefi...
I believe what's even more impressive in the Perl ecosystem is CPAN testers.
When you upload a module to CPAN, lots of neat things happen. Of particular interest is all of the testing that gets done. For example:
http://www.cpantesters.org/distro/M/Message-Inform.html
As you can see, that's a pretty wide swath of OS and Perl versions.
This is an example of a failure report: http://www.cpantesters.org/cpan/report/e93a7034-cf3f-11e5-96...
This is an powerful resource. I've had random people approach me with suggested fixes to test failures on CPAN in the past. It's amazing!
I believe the Perl community is serious about testing and reliability in ways that few others are. For example, the default module installation command ($ cpan <module name> or $ cpanm <module name>) will NOT install if there are failures in any of the tests.
By modern standards, Perl5 has some silly characteristics, no doubt. But as others have said, the community is rock solid, and more lively than ever:
That said, I hate working with references in the Perl debugger, and, I would be lynched at most worksites, at least in Sacramento, if I suggested a Perl back end. ...Which is too bad - Java/ORM, "COBOL-fingers", bondage and discipline forever...
REFERENCE$HASH
Or something like that, it's been a while. I'm spoiled by the Javascript debuggers built into Chrome & Firefox, although I'm not sure about the Node.js debugger.
Is there a shell (either graphical, or "Borland Turbo Debugger for DOS" style) for perl -d ?
(even the "view locals" command in gdb for C presents data more quickly than the built in perl debugger)
ddiederi@lomin:~/t$ cat p1 #!/usr/bin/perl
my $a = 'hi'; $a = { hi => 'there' }; print "Done\n"; ddiederi@lomin:~/t$ perl -d p1
Loading DB routines from perl5db.pl version 1.49 Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(p1:3): my $a = 'hi';
DB<1> n
main::(p1:4): $a = { hi => 'there' }; DB<1> x $a
0 'hi' DB<2> n
main::(p1:5): print "Done\n"; DB<2> x $a
0 HASH(0x29e6eb8) 'hi' => 'there'
DB<3> n
DoneDebugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program
termination,
h q, h R or h o to get additional info.
DB<3> exit
ddiederi@lomin:~/t$The post's equally relevant to a monolithic setup as well. In such a setup, a code artifact (as mentioned in the post) will probably just be a script or a library (now I include a service too).
A toolset like this is a good-to-have for a monolith but a pre-requisite for micro-services (if you want to reuse code as much as possible i.e.), I feel.
The post has been written from a micro-services angle because that's what the setup is like here at Semantics3.
So I'm always interested in the more specific approaches to communication and storing data when it comes to microservice architecture, which might be an idea for a sequel article ;)
And, when you get right down to it, a huge chunk of web dev falls into that category.
https://media.ccc.de/v/31c3_-_6243_-_en_-_saal_1_-_201412292...
See http://blogs.perl.org/users/joel_berger/2015/12/response-to-... for one response and some discussion in the comments.
And upgrading that might risk incompatible system services, which is why sysadmins usually have way fewer problems adding something like Perl or Python. Isolated language environments (cf. perlbrew) are a nice solution to this, at least until you happen upon a particular paranoid admin.
Once you're used to Perl's testing tools, anything else feels chaotic and poorly thought-out.
(Of course, these are still only arguments for SOA and there's no clear differentiation between SOA and microservices, because there is none.)
But, small pieces inter-operating is very UNIX-y, and excellent for all sorts of tasks. I think the difference between microservices and SOA may just be the direction it's coming from. Microservice architectures are coming from the Open Source web and cloud culture; SOA came from enterprise and government and finance. But, the over-arching concepts, I think are the same. (I'm definitely not an expert on either, however. Just my gut feeling.)
Do you have trouble hiring qualified perl devs?