Looking For Recommendation for Web Framework

Hello, all -

I have been wanting to build a website for awhile, and have been fumbling with this attempt with Web Frameworks in Haskell. The problems I experienced in Haskell were that the more comprehensive frameworks available (Yesod & Snap, for those who are familiar with Haskell) use some rather complex techniques which continue to befuddle me (Transformative Monads and TemplateHaskell), and the more understandable packages (e.g. Scotty) are incomplete (e.g. No good auth system).

That being said, the website is to do an online radio station, and since I’ve figured out how to use liquidsoap (written in OCaml), and wanting to expand some of its capabilities to suit my purposes anyway, I’ve decided to look into what OCaml has, and it appears I’m coming across the same concern here: Opium appears to be simple to understand (and very similar to Scotty on Haskell) but is also very basic (e.g. missing an auth system) and OcsigenServer/Eliom appear to be rather comprehensive but also rather complex. The bigger concern I have with OcsigenServer/Eliom is that it seems to compile a lot to JavaScript, and my hope is to minimize usage of JavaScript.

That being said, I have two questions:

  1. Can OcsigenServer/Eliom be used to create a site without/with minimal use of JavaScript?

  2. Are there any other web frameworks written in OCaml that’s more comprehensive than Opium but simpler than OcsigenServer/Eliom?

Thanks!

You can use just TyXML which doesn’t generally place any Javascript in your output.

Not aware of anything more comprehensive than Opium. More comprehensive in what way?

I use TyXML + Opium for Logarion, where I’m avoiding Javascript like the plague. :smirk:

Hi, there. Thank you for the information. When I mean “more comprehensive”, I mean additional features beyond simple HTML/CSS/JS serving. Additional features I’d be looking for are an authentication/authorization system, session management and potentially database manipulation (I figured I could use other libs for that, but sometimes the web frameworks have a special lib they already have integrated and strongly recommend be used). I’m sure other features would be desired by others, but the authentication feature is really the big thing I’m looking for. I’m kind of an amateur hobbyist programmer and am not really up to speed on Session Management and authentication and security, so it’d be nice to have something that does that for me so I can focus on the website itself. If not, then I have to learn about that stuff and write it myself, but I’d prefer not to.

I believe Opium provides some interface for the HTTP auth requests, but it doesn’t provide any handlers obviously. It’s up to the programmer to pick one of the multiple ways to handle authentication.

So you’d have to start with something hard-coded or using a simple file or something and then, as you progress, pick a library that can do something more sophisticated, based on your application’s target environment.

1 Like

You can use Eliom/Ocsigen without javascript. If you look at the taxonomy of services, you can see that there is the App service, with all the client-server fancyness, and other services such as Html which only serve regular HTML webpages.
For the rest, you don’t have to use all the syntax extensions and things like that. Using only the server part is fine.

As far as I know, there isn’t really something intermediary. There are some pieces such as session, dispatch and webmachine, but they don’t do as much.

1 Like

It looks like they have a Middleware example for Opium, now that I’m looking in the repo beyond the readme. There was a BasicAuth option for Scotty in Haskell as well. I’m not sure that’s the way I want to go, as some pages I want to show differently if someone is logged in (e.g. Navbar shows a log in button if not logged in, user name/handle if they are, and allowing the client to still access basic information on a page) instead of just redirecting to a 401 page. The example makes me think I need to learn more about authentication and sessions to possibly make this option work still. It does appear to be a possibility, though. Thanks!

Thanks, Drup, for the information. One additional follow-up question: It appears on ocsigen.org that OcsigenServer and Eliom are two different packages, and yet all the examples and tutorials for OcsigenServer seem to be implemented using Eliom calls. Are these two separate and distinct packages, or do you need to use Eliom with OcsigenServer?

Thanks.

ocsigenserver is just the raw server, much like cohttp. It doesn’t provide a nice API. Eliom does, and has a dependency on ocsigenserver.

Got it. Thanks for the info!!