Mojolicious + Database + CRUD? What is Mojolicious for without these?

1,716 views
Skip to first unread message

antigoon

unread,
Oct 31, 2011, 11:51:34 AM10/31/11
to Mojolicious
I'm curious about a couple of things a) Is there a Mojolicious + MySQL
+ CRUD tutorial --I've Googled quite a bit with no success-- and if
not b) what exactly do people use Mojolicious for?

Maybe I should back up first...

I've been looking for a perl platform to build a little LAMP app on.
I'm not a web developer, but I am a professional SW developer and I
have a certain amount of experience with web/cgi/lamp/javascript. I've
looked at Catalyst and it's powerful but to me it has the flaw of
taking all the negatives of perl (a million ways to do anything)
without really benefitting from perl's positives. (Plus it needs
mod_perl or fastCGI. The former you'll never get on an ISP and the
latter you may or may not be able to configure.) I tried CakePHP and
it's ok, but it's PHP. I've tried Ruby on Rails and I think that if I
ever figure it out, I would really like it.

So then I came to Mojolicious. Oh how simple the tuturials make it
look, oh how slick the website! *This* was going to be my perl
platform. But then I noticed that it seemed to be missing some
fundamental things. Can some more experienced Mojoliciers tell me why
I'm wrong?

***Note: at this point I should state categorically that this is not a
troll. I'm not looking to offend anyone or to start an argument. I'm
really just curious about what Mojolicious is for.***

I wanted to make a very simple LAMP app using a platform that would
automate all the database accesses and all the CRUD. i.e. If I make a
class called 'person' with 3 attributes, I want the platform to create
a 'people' database table with three attributes, and web forms that
allow a person to be easily created, modified, and destroyed. That way
I could concentrate on the real algorithms behind the website, not
spend hours grinding away at HTML forms and SQL queries. Sure I might
need to customize later, but at least I'd have something working right
from the very start. That's what cakePHP or Ruby on Rails provides.

I'm sure I can add some of this with the various standard perl
libraries to do these things, but I'm just surprised that there isn't
any example, FAQ, anything that might guide a person. Mojolicious
seems to have none of that. Ok that's fine it's not for me; diff'rent
strokes for diff'rent folks. But WHO is mojolicious for? What sort of
web developer wants super-easy ways to do some things (e.g. parsing
URL paths and parameters) but then wants to roll their own for large
numbers of others (e.g. databases, CRUD)?

Which leads me back to my original questions. a) Is there a
Mojolicious + MySQL + CRUD tutorial, and if not b) what exactly do
people use Mojolicious for?

Regards,
Steve

Joe Landman

unread,
Oct 31, 2011, 12:20:03 PM10/31/11
to mojol...@googlegroups.com
On 10/31/2011 11:51 AM, antigoon wrote:

> Which leads me back to my original questions. a) Is there a
> Mojolicious + MySQL + CRUD tutorial, and if not b) what exactly do
> people use Mojolicious for?

I can't answer "a". I can point you to a few things:

https://gist.github.com/261811

http://search.cpan.org/~bduggan/Mojolicious-Plugin-Toto-0.08/lib/Mojolicious/Plugin/Toto.pm

As for "b": We use it (now effectively to replace Catalyst), as a very
light weight, very easy to deploy web framework that simply does not get
in the way. We don't do a great deal of database work (extremely little
actually), so this is less of a concern for us.

I like Catalyst. It is a very good framework. Its just a monstrosity
to deploy and I was forever in a dependency and deployment hell. A
significant number of the dependencies never really worked correctly
(*WWW::Mechanize*), which caused me all sorts of headaches on
installation and testing.

Contrast to Mojolicious (I really like the ::Lite version BTW). No
dependency hell. Everything "just works". I can start working right away.

Basically we are using it now for a command and control system for our
storage and storage clusters. It is used internally in one of our
diskless system control tools (to write PXE boot scripts on the fly).
Planning on using it for a quote configurator tool as well (where we
will need DB access, but I am looking at MongoDB and other similar less
SQLly DBs anyway). Still need something akin to CRUD there, but we can
either roll our own little one, or reuse a simple one from somewhere else.

We don't need big massive object frameworks. Just something simple,
that works, that we can deploy, test, etc. Mojolicious is this. After
~6 years of wrestling with Catalyst, as much as I liked it, it wasn't it.


--
Joseph Landman, Ph.D
Founder and CEO
Scalable Informatics Inc.
email: lan...@scalableinformatics.com
web : http://scalableinformatics.com
http://scalableinformatics.com/sicluster
phone: +1 734 786 8423 x121
fax : +1 866 888 3112
cell : +1 734 612 4615

Glen Hinkle

unread,
Nov 1, 2011, 12:36:54 PM11/1/11
to Mojolicious
"I want the platform to create a 'people' database table with three
attributes, and web forms that allow a person to be easily created,
modified, and destroyed"

This is a matter of the tools built on top of the platform, rather
than the platform itself. Ruby's Rails distributes these sort of
tools and touts them as the hotness, but in practicality, they don't
provide much value.

Early on in Mojolicious, I set about creating such a tool, and then
stopped as I realized that they provide very little use.

Let's say you have a tool that creates your CRUD interface and
boilerplate. It looks great, because look at all the work it saved
you from doing! In reality, it's saved you nothing. When you
customize your app, you're going to have to re-organize and/or re-
write every piece of code/HTML. Guaranteed. These tools are a red
herring - they're simply not going to save you any time at all.

For example: You create a resource. Oh, but you need to verify the
data. Except, how you verify depends on the nature of your data.
That's ok, you can just take out the boilerplate and put your own code
in. Except, it ties in with the way it stores data in the database.
That's ok, you can replace that with your own code. Except, that ties
in with the way you've chosen to display your data. That's ok, you
can replace the templates with your own code. Except, you need to
show your templates in a specific way so that it makes sense. That's
ok, you can replace...

In the end, boilerplate templates limit you more than save you time.

What really saves you time is the ease of Mojolicious' syntax. It's
so simple as to eliminate the need for maintaining boilerplate.

It's ok if you don't believe me. Attempt to create boilerplate on any
platform, and you'll see how useless it is after the 3rd web app,
wherein maintaining the boilerplate was more effort than creating the
app itself. If it's not, you don't actually want a custom web app,
you want a CMS.

If you still want something to get started with, here is some
boilerplate for a Lite app that took 30 seconds: https://gist.github.com/1331018.
The same can be done for a full Mojolicious app.

Anything more would make too many assumptions about your application.
Even what I've gisted will need to be customized significantly
depending on how you deploy your app, how it's used, the nature of
your data, what your visitors expect...

lenz

unread,
Nov 1, 2011, 6:09:41 PM11/1/11
to mojol...@googlegroups.com
hi steve,

On Tue, Nov 1, 2011 at 4:51 AM, antigoon <stephen....@gmail.com> wrote:
> I'm curious about a couple of things a) Is there a Mojolicious + MySQL
> + CRUD tutorial --I've Googled quite a bit with no success-- and if
> not b) what exactly do people use Mojolicious for?

i think most of us are here because we did many years of web
development and are tired of someone trying to generate anything for
us that is much more as the bare minimum. the reason is that we only
want the bare minimum and that excludes any ready-made scaffolding for
CRUD or other stuff. the big issue with code generation is also that
it may work with SQL to some extend but my code runs on CouchDB,
others prefer Mongo or Riak and for some things SQLite is the thing -
we are way past the "one thing fits all" stage.

this may make your problem seem harder that it should be but trust me,
i whipped up a CRUD based site on CouchDB in ~1hour _excatly_ how i
need it for this project - including all the code around it that i
would have needed to write anyway.

to get you started have a look at bootstrap
(https://twitter.github.com/bootstrap) and have a look at the tag
helpers man page
(https://metacpan.org/module/Mojolicious::Plugin::TagHelpers) - that
is (in my view) a good combination and an easy to use starting point
to get something up and running in no time. also, have a look at the
various authentication plugins that suite your database as you may
need some sort of authenticated users section.

i prototype many ideas with mojolicious and normally have a basic
first draft after a days work - this is way faster than anything a
code generater could do (i tried many of them including the ones you
mentioned) for me and i end up with something i don't have to rewrite
to actually use it.

cheers
lenz

--
twitter: @norbu09
current project: iWantMyName.com

Armishev, Sergey

unread,
Nov 2, 2011, 11:05:00 AM11/2/11
to mojol...@googlegroups.com
Glen,
When you talk about web application (not web pages) you need to have data model both on server and on client. Could you tell me how I suppose to use Mojolicious/Perl to create single codebase for data models for both sides? Now I need to create "People" model in Perl, "People" model in JavaScript. Then have "People" translated into JSON. On the client side I create JavaScript "People". To verify fields for "People" I need Javascript code on client, Perl code on server. And when "People" changed... Node.js solves this problem by running JavaScript on server. And GWT (Google Web Toolkit) allows you to create Java based data models that compiles into JavaScript.

Regards
-Sergey

--
You received this message because you are subscribed to the Google Groups "Mojolicious" group.
To post to this group, send email to mojol...@googlegroups.com.
To unsubscribe from this group, send email to mojolicious...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/mojolicious?hl=en.


_____________________________________________________
This electronic message and any files transmitted with it contains
information from iDirect, which may be privileged, proprietary
and/or confidential. It is intended solely for the use of the individual
or entity to whom they are addressed. If you are not the original
recipient or the person responsible for delivering the email to the
intended recipient, be advised that you have received this email
in error, and that any use, dissemination, forwarding, printing, or
copying of this email is strictly prohibited. If you received this email
in error, please delete it and immediately notify the sender.
_____________________________________________________

antigoon

unread,
Nov 3, 2011, 3:07:29 PM11/3/11
to Mojolicious
Very interesting responses Joe, Glen and Lenz.
I'll read a few more tutorials and give Mojolicious a try.

I think that Joe and Glen you're ultimately right about the
autogenerated code not being worth it. My only counter-argument is
that as somebody who does only occasional web development, it's really
nice to have real working CRUD right from the get-go, allowing
incremental black box testing from the get-go. But it's true that it
would certainly all be rewritten over time. And perhaps a massive
framework that provides all these services that only benefit you in
your first week of development is not infrastructure well spent.

Now it's time for my usual pattern: I'll read just enough tutorials to
not quite know enough to get started and get started on my project
anyway.

Thanks for answering my question seriously and not taking it as a
troll too. I appreciate it.

Steve


On Nov 1, 6:09 pm, lenz <norb...@googlemail.com> wrote:
> hi steve,
>

Glen Hinkle

unread,
Nov 4, 2011, 1:23:20 PM11/4/11
to Mojolicious
Make sure to check out http://mojocasts.com, and start with the first
one. That will get you most of the way there.

John Stoffel

unread,
Nov 4, 2011, 3:07:16 PM11/4/11
to mojol...@googlegroups.com

Glen> Make sure to check out http://mojocasts.com, and start with the first
Glen> one. That will get you most of the way there.

They're nice, but do you have the source available? Also, are
planning on doing one with Mysql backends and searches and joins?
Just one quick example would help a ton!

Thanks,
John

henq

unread,
Jan 14, 2012, 8:51:43 PM1/14/12
to mojol...@googlegroups.com
Antigon, I have exact the same considerations for months now. 
And while I agree with the other posters that code generation is of diminished value if your app reaches a certain size or complexity, I sure would like to have a 'Mojo-endorsed' way of dealing with crud. If for no other reason as to to have default way of handling validation, pagination, dirty-detection and so on in the efficient mojo spirit...

But recently I am getting more and more intrigued by the following setup for database based webapps:
- fat client made with a javascript framework like ExtJS/Sencha or Backbone or Knockout or similar 
- mojolicious backend that serves JSON data en takes care of navigation. (bit does not generate 'pages')

(intro reading and on rails (sorry:-))

~henq

Reply all
Reply to author
Forward
0 new messages