Re^2: Perl Contempt in My Workplace
by marto (Cardinal) on May 05, 2021 at 11:28 UTC
|
"Recently I tried to use JQuery/Datatables and even found several CPAN modules for it, tried to use these and failed. After I've failed in perl, I succeeded with NodeJS on that, I got what I needed. I had confirmation on my table that other language's ecosystem is more current."
All you have to do is send a JSON response for Datatables to read, you don't need 'Datatables' module to do that. JSON::PP is core. For what it's worth putting together a Datatables heavy application took almost no effort using Mojolicious::Lite for handling everything.
Update: Added JSON::PP is core.
| [reply] |
|
| [reply] |
|
I'd never used Datatables before, the first page you linked to highlights what can be used as a data source, it's not a perl specific thing. Expecting programmers to write code isn't unreasonable. Adding needless dependencies is a dangerous thing, as NodeJS developers found out to their peril.
Update: "...but this means I need to do all my heavy-lifting myself, whereas I want be standing on shoulders of giants. " that's why JSON::PP is core, you just return the data (from database query or other munging) in JSON format. A more polished end to end process is why this is also part of modern web frameworks like Mojolicious, and why they're such fun to work with, e.g. $c->render( json => { data => $griddata, cols => \@cols } );
| [reply] [d/l] |
|
|
|
For data heavy applications (especially using databases), you will always have to do a lot of heavy lifting yourself.
As soon as your data goes above a certain threshold for size and/or complexity, a "standard" data handling module (in any programming language) will probably not cut the mustard. Sooner or later you'll end up writing your own SQL statements, throw in some caching and adapt the whole thing to your exact requirements anyway.
For DataTables this is especially true. First of all, the JS part has tons of options and tons of plugins. So, a completely generic backend would have to replicate everything, potentially making it a big mess of spagetti code that moves at the speed of a glacier.
And secondly, if you use paging or scrolling in DataTables, especially in combination with filters and JOINs over multiple tables, this will just not work with some SQL statement thrown together by a generic module. It'll bog down the server and bore the user to death. Scrolling in particular can generate multiple requests per second, so you'd better optimize the heck out of your backend.
Edit: I do have some more or less generic modules for DataTable based listing of any old PostgreSQL table, but it's tightly integrated in my PageCamel framework, so it probably wont be any use to you. But just in case you're interested to see how i did it, it's in the ListAndEdit webserver module.
perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'
| [reply] [d/l] |
|
|
|
|
Re^2: Perl Contempt in My Workplace
by choroba (Cardinal) on May 05, 2021 at 13:38 UTC
|
> Recently I tried to use JQuery/Datatables and even found several CPAN modules for it, tried to use these and failed. After I've failed in perl, I succeeded with NodeJS on that, I got what I needed. I had confirmation on my table that other language's ecosystem is more current.
Whose magic wand's going to fix that? If you find a library is missing, you are the best candidate to fill the gap!
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
| [reply] [d/l] |
|
So I found that the library was missing (not exactly missing - there were CPAN modules which haven't fulfilled my needs)
but I found what I needed in nodejs ecosystem http://www.npmjs.com/
But I see your point about creating such a module myself and uploading it to CPAN. And ~10 years ago it was the approach which I probably have choose, because all other libraries are here on CPAN.
Perl have lost critical mass of its users, who will fill the gaps on missing modules, unfortunately for me and for other perl users.
| [reply] |
|
"who will fill the gaps on missing modules"
Various 'Datatables' modules exist on cpan, you didn't say which ones you tried and how they failed. Luckily, you don't need a perl module to return the data required for datatables, as has been made clear to you, the perl core modules achieve this without issue.
| [reply] |
|
|
|
|
|
Re^2: Perl Contempt in My Workplace
by bliako (Monsignor) on May 07, 2021 at 20:02 UTC
|
| [reply] |
|
| [reply] |
Re^2: Perl Contempt in My Workplace
by 1nickt (Canon) on May 05, 2021 at 14:40 UTC
|
I've been using DataTables for years and have never found a use-case where a module would have helped. You prepare your data and send it to the front end as JSON. All the heavy lifting in that application is in writing the JS and particularly the CSS. You make a good point but this is a bad example.
The way forward always starts with a minimal test.
| [reply] |
|
...ok,
so probably I should have posted my question here and you could have helped me back then. That's good. :)
Perlmonks is a very strong point of Perl community.
Still, I do not think of my example as "bad example". see: I tried different CPAN modules, but these haven't fulfilled me.
I honestly searched both Perl @ cpan+perlmonks+google and searched nodejs @ npmjs+stackoverflow+google and found better solution in nodejs land.
I am a bad searcher? probably. should I improve my google-fu? probably.
However I still think this is not a bad example in a sense that this is a real-life example.
I am some poor user who found some solution outside of perl for some reasons....
I do not think that I am alone with such experience
| [reply] |
|
I don't think you are a bad searcher ... I just think Perl devs maybe get their hands dirtier than JS devs? For reference, see my repo at https://github.com/1nickt/ContactMyReps. I am genuinely interested in where you think that a module would have helped in that case. Which part of my Perl code is replaced by your node solution?
Thanks!
The way forward always starts with a minimal test.
| [reply] |
|
Re^2: Perl Contempt in My Workplace
by Anonymous Monk on May 07, 2021 at 18:16 UTC
|
I think that the proper thing to have done would have been to write a new CPAN module that's "exactly what you needed," then share it. Nevertheless, it's impossible for every language to be everything to everybody. That's why we invented – and, very regularly use – more than one programming tool. Why try to "re-create gprolog in perl when you've already got gprolog? Why dumpster-dive into "WebASM" if your only motivation for doing so is to say that you have done it? There's utterly no point.
rust recently appeared as a brand-new language because a group of engineers realized that they were facing a brand-new use case that other languages didn't yet cover. So it goes. Perl is a venerable tool in a society of tool-builders.
| [reply] |
|
| [reply] |