Skip to content
November 1, 2013 / dantti

Cutelyst a Qt web framework

Do you recall that “Qt everywhere” branding?

Well that’s one of the things I really like in Qt, being able to deploy everywhere with minimal to zero changes in source code. But sometimes your application needs a web interface some sort of web backend or web admin, and when that happens it breaks that slogan (AFAIK)…

I got in contact with web languages (not HTML) only when at university, ColdFusion and PHP where the first ones, and while PHP was sort of cool because it has a syntax close to C, I never really like it. I’m not a web designer nor know how to do pretty websites, but in today’s world building web apps is inevitable.

So years ago I learned about RubyOnRails, and people where talking all the good stuff about it, it’s was the framework of the hype, although I knew Ruby wasn’t the fastest scripted language my need didn’t demand that, so I got a book, read it cover to cover and happily started my web app, a week latter I got a complex problem with an apparently impossible solution. It seemed that RoR makes easy things stupidly easy and complex things impossible…

The I met Catalyst a Perl framework, got exited again, but I knew nothing about Perl so I read more 3 books and was started to love the language, I still do, but last weekend when trying to resurrect and old Catalyst application I got an error which I had no idea how to fix, on IRC I was told the problem could be that I mixed CPAN packages with distro packages, not very convinced I realized the bigger problem I was actually facing, I’m not fluent in Perl, well no matter how many books you read about a language you only get fluency in it after speaking it almost everyday, this applies to computing languages too of course.

So if 99% of the time (or less now with QML) I’m programming C++ it means that I know a lot more about how to debug it than with Perl, so Cutelyst! Writting web apps in Qt/C++ will be much more efficient to me and hopefully to you too.

I share lots of the Catalyst API and design ideas, tho the implementation is of course completely different. Also for the sake of HTML templating I plan to create a Grantlee View plugin.

You can take a look at the proof of concept:

https://gitorious.org/cutelyst

Have fun.

About these ads

20 Comments

Leave a Comment
  1. gallaecio / Nov 1 2013 20:14

    This is the third time I hear about a Qt-based web framework. Just in case you did not heared about them, you might find them interesting, even if just to study them to evolve your own project:

    http://code.google.com/p/qdjango/

    https://github.com/vinipsmaker/tufao

    Also, I would like you to read this email I sent, as it might apply to your project as well: https://groups.google.com/forum/#!topic/qdjango/vi4MiJyg3aM

    • dantti / Nov 2 2013 08:58

      Hmmm ok, you can notice the AFAIK on the text since I didn’t know about them.
      Of course I’ll take a look, but considering that Django (not qdjango) is the framework which made me hate Python, on a company that I used to work some smart guy decided to use it while it was very new project, that mess changed API everyday and the only reliable documentation was the source code. Also the design is quite different from Perl Catalyst, Tufao OTOH is interesting, but I think what we can share is mostly some interesting bits like HTTP parsing, tho Cutelyst will also offer a FastCGI engine.

      • Diederik van der Boor / Nov 3 2013 11:06

        Sounds like a long time ago, as Django is now mature, documented and has very stable API’s. Strange to hate a programming language over an alpha product.. :-/

      • dantti / Nov 4 2013 06:31

        Well it was the product that introduced me to the language, which I dislike even without the project :P

  2. Lars / Nov 2 2013 03:37

    Have you considered some of the other c++ web frameworks ?
    like http://www.webtoolkit.eu/wt/ which is very much inspired by Qt

    .. there is also others more mvc inspired ones if that is to your like.

    • dantti / Nov 2 2013 09:00

      Yes, but I don’t like the idea of writting HTML with functions.

      • Pau Garcia i Quiles / Nov 2 2013 22:03

        You don’t need to write HTML with functions, just use WText to write whatever you want.

        I do like the idea of Wt taking care of browser differences, bugs and tricks. These days there is a lot more than one can think to writing a webapp.

  3. Denis Steckelmacher / Nov 2 2013 07:34

    Hi,

    If writing web applications in C++ and using a Qt-like approach interests you, you may want to have a look at WebToolkit (webtoolkit.eu). It is a C++ web framework licensed under the GPL (and a commercial license if you don’t want GPL) that is very powerful. It takes some time to get used to it and to how it works (for instance, your whole application is made of widgets, that you modify and combine exactly as you do with Qt, and templates are only one of the multiple available widgets, see WTemplateWidget), but many complex things are possible.

    With Wt, you don’t have to write any Javascript to support complex AJAX interactions. When an event occurs on the client, your server application is notified and you can modify all the widgets you want (you can change the text of a button, of a field, of a template, etc). When you are done, Wt sends to the client the difference between the old application state and the new one, and the client page is updated. When the client doesn’t support Javascript, Wt still works : instead of sending the differences to the client (that updates its DOM tree using them), Wt sends a complete new version of the web page, and no Javascript is needed.

    Wt comes with a somewhat nice ORM, the Wt ORM. It supports SQLite, MySQL and PostreSQL I think. I don’t have much experience with this ORM as I needed to mix Qt code and Wt code, and the Wt ORM doesn’t integrate well with Qt. I developed QtORM (https://github.com/steckdenis/qtorm), that you may find interesting. I use this ORM in production, but it may lack features and is currently not documented.

    • dantti / Nov 2 2013 09:04

      Yes, I know about it, the first problem is writting html with functions, I just dislike that, it also doesn’t seem to be as flexibe as Perl Catalyst is. Second is indeed the license, I want something that is LGPL that I can just link against.
      If you look at Perl Catalyst you will understand why the design ideas are very different.
      And BTW there is a ORM that supports Qt I just don’t recall the naming but might help you.

  4. rqx / Nov 2 2013 13:44

    This is great, exactly what I’m looking for right now for a hobby project and what we’d have needed 1 year ago at my company. But I think it might be useful for new devices we start building (we just switched from pure C++ to Qt/C++ as standard).
    I’ll try it :)

  5. Christian Gmeiner / Nov 3 2013 08:42

    I am using cppcms (http://cppcms.com/wikipp/en/page/main) for a bigger embedded configuration interface – something like a router html interface – as it is C++ it is quite easy to make use of qt.
    I will give cutelyst a try :)

  6. Paul Dann / Nov 7 2013 12:48

    I’d be curious to hear what the problem was that you encountered with Ruby on Rails?

    • dantti / Nov 7 2013 15:00

      Well before I even start to read a book about it I heard people saying Ruby was slow, but since the app didn’t need to be blazing fast I ignored this and started reading the book. The problem I had might not be valid today but iirc I needed a simple multiselection list which just turned out to be a mess to handle, I really enjoyed the language but it was slow indeed and at that time the lack of managing more than one db connection was also something that would be a problem to me.

      • Paul Dann / Nov 8 2013 06:41

        Ruby isn’t as slow as all that nowadays, although it is naturally slower than some other languages; that’s the price of its flexibility. I’ve found that caching usually makes a huge difference in web apps, and I like the speed with which it’s possible to throw something together in Ruby. Conversely, I also enjoy the slower-and-more-careful approach of writing C++ for projects that require more care and efficiency. Rails is geared toward horizontal scaling, and does it very well.

        You might have been after this: http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-select_tag

        Not looking to say you should have used Rails or whatever; mostly to expand my own horizons: I’ve never needed multiple database connections; could you share that usecase?

      • dantti / Nov 8 2013 09:37

        Well it’s been more than 5 years since I touched it so it might have become faster (although I haven’t seem news about this).

        Also I don’t think it’s slow at all to write C++ apps, it all depends on how familiar you are with the language and the toolkit, I for example love Perl Catalyst design but I’m not efficient in writing/debugging Perl apps.

        And I disagree about a framework being designed for scalability, the way that you design your app tells how well can you scale in multiple servers which isn’t related to speed or framework.

        There are lots of interesting stuff to do with multiple databases, for instance you could deploy several instances of your application to multiple clients each with it’s own db, but manage the user accounts into a single db (maybe LDAP would be better). There are also some apps where I work that need to fetch data for several different applications where each of them has it’s own db..

      • Paul Dann / Nov 8 2013 09:59

        Yeah fair enough: Rails isn’t aimed at that kind of design; it is so-called “opinionated” software. From the Ruby world, though, Sinatra comes in a little lower-level, and would probably suit that kind of usecase more.

        When I say it’s slower to write C++ apps, I’m thinking mainly about the thinking required by (for instance) strong typing, worrying about overflows, resource handling, etc… Don’t get me wrong, though: I love Qt/C++, and those things also have great benefits. It’ll be really interesting to see C++ in this kind of web framework league.

  7. Yannick Kiekens / Nov 8 2013 08:54

    Nice project!
    It sounds like this will do what i wanted for a while. (Qt + webstuff)
    Some sort of README would be great

    • dantti / Nov 8 2013 09:19

      Sure, I’m planning a 0.1 release probably next week, but first I need to make most basic stuff start working…

  8. Scorp1us / Feb 28 2014 13:19

    What about QMLWeb? QML apps in QML in a browser!

    • dantti / Apr 18 2014 11:28

      The idea is cool but this is a bit heavy thing, also I’m interested in having more control for html stuff

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: