monx663 has asked for the wisdom of the Perl Monks concerning the following question:

Hello people

There is a CMS/web application framework currently operational which is stable and tried and tested over many years and various production installations.
The idea is to start using this CMS/Web app framework, as a hub for mobile applications running in Android or iOS. The keywords RESTful and JSON, immediately become relevant.

However, the web framework was written over a decade ago and as a result, many of the HTML UI elements it uses are outdated and make its pages look like a a blast from the past! The framework was written in Perl and despite being outdated (UI wise) was designed along the lines of the MVC paradigm and is extremely modular and configurable.

And here is the question... The CMS is currently being renovated and it has already implemented functionality for AJAX and JSON, in order to have certain pages that communicate with the server asynchronously, using jQuery.

When it comes to the stage of having the CMS act as a mobile app hub, will the apps running on Android or iOS be expecting to communicate with the "hub" in JSON over RESTful URLs? Also, since some front end frameworks offer functionality to populate HTML form elements using JSON data, should our framework make JSON the standard method of data interchange between server and client? ("client" being a mobile app or a web browser)


Thanks for any pointers and replies.
  • Comment on Web application framework and Smartphone apps

Replies are listed 'Best First'.
Re: Web application framework and Smartphone apps
by Corion (Patriarch) on Apr 06, 2021 at 07:11 UTC

    I'm not a big fan of using "fat" client-side Javascript to implement what would otherwise be static content.

    For something more "app-like" (a weather information app), I had great success with using Perl to prepare the JSON and then Javascript to implement a Progressive Web App on the client side to render the JSON into something interactive.

    I've given a presentation about this and the code is online as Weather::MOSMIX and https://github.com/Corion/PWA-WeatherClient for the client-side Javascript.

      Thanks for the input, Corion.

      As an Android user, who's a seasoned web systems developer, I'm sick and tired of being asked to download apps from whatever app store, to do things that are easily done by visiting a responsive web site.
      There are times that an app is needed, as I have recently found out with a mini web app I wrote for tracking a mobile device using the browsers' geolocation api and feeding the positions to our server via AJAX and JSON.
      Despite my attempts for power management and permissions to the mobiles' Firefox, my "tracker" web app kept going to sleep when the screen of the phone went off, or the browser went to running as a background app.
      Apps seem to make better use of the device than a browser app does.
      I am actually all for abolishing app stores and pushing users to apps developed in the browser, either with frameworks like React and AngularJS or by ensuring that web sites cater for every client, using well defined and corporation neutral technologies.

Re: Web application framework and Smartphone apps
by bliako (Abbot) on Apr 05, 2021 at 21:50 UTC
    will the apps running on Android or iOS be expecting to communicate with the "hub" in JSON over RESTful URLs?

    If JSON is a standard for REST I don't know, but both ends *can be made* to communicate with anything you want. JSON is convenient (except that you must url-encode it and you send binary data only as base64-et-al). Surely Perl backend can convert a JSON to a Perl data structure very easily. And vice versa. The client-app will coerce you to using a library for converting that JSON to objects (for example Gson) but you don't have to as you can have it converted to polymorphic hashtables. So, yes JSON is convenient on both sides. And an app, from personal experience, gains greatly by RESTing with JSON. I found Retrofit library useful for communicating with a server. If you are programming the app, your biggest problem will be placing all data requests using asynchronous logic. And that leads you to RxJava (for example). And that's some learning curve. Alternatively, you have a WebView component. Basically a browser inside your app, just a shortcut with lots of deadends.

      Thanks, Bliako.

      I don't much care about what will be used for handling the RESTful communication on the client side.
      I am primarily concerned with adding "base class" functionality to my systems' packages, that will help all relevant web objects to be used by smartphone apps as easily as they are by web browsers. Regarding JSON and Perl, I have already implemented base class functionality that gives objects the ability to JSON serialize themselves using the Mojolicious JSON functions.

        Do you see this "base class" functionality as exclusively producing JSON which is then either 1) sent straight to REST clients or 2) passed into an HTML-producing layer like: Templates+JSON=HTML to be sent to html clients (browser)?

Re: Web application framework and Smartphone apps
by Bod (Parson) on Apr 05, 2021 at 21:52 UTC

    JSON is usually a good choice for client/server communication. Just because the client is a mobile device makes little difference. It also has good support from Perl in the form of the core JSON module and also the faster JSON::XS. JSON has good support in other langauges too which will be needed at the client end.

        Nonetheless, JSON is a standard, and Perl has full support for it as do most other languages today. Hand it a string, get a data structure. Hand it a data structure, get a string. Treat the conversion process as a black box.