About Duct, Fulcro and other Templates for Web Developement - which one to use and when?

I was going through this post here https://purelyfunctional.tv/issues/purelyfunctional-tv-newsletter-279-clojure-web-frameworks/ about web development in Clojure.

I was wondering what’s the difference between a

  1. Server Side Frameworks e.g. Duct

  2. Front-Back end Framework e.g. Fulcro

And what are the best use cases for either one. For example, if one is to reproduce all the projects mentioned here in this forum https://www.phptpoint.com/projects/php-project-list/ in Clojure, which framework is a better one to start with?

Would Duct also support development of SPA and MPA?

Would Duct or Fulcro integrate well with Datomic?

Or is it better to use the more conventional templates like Chestnut or Luminus ?

I’m not quite able to grasp which is the best use case of each of these templates.

1 Like

For context, I am new to Clojure. Recently I’ve been studying Duct and Fulcro.

if you’re unsure or unclear where to begin, the (likely) quickest way to get started is to go with a template like Luminus, which does a lot for you out-of-the-box. That said, I am really enjoying learning how to architect a SPA client and API server using Duct and Fulcro together.

You are correct: Duct is a server-side, backend framework, and Fulcro is primarily a client-side, frontend framework.

Here is an example application built using Duct and Fulcro. This is also a demo of Walkable, which is a tool for talking to SQL databases from Clojure. Walkable is built using Pathom, which is a tool that helps map Fulcro graph queries (EQL) to data sources such as databases, APIs, GraphQL tools like Prisma, etc.

Fulcro is used to build SPA (single page applications) (I am not sure what MPA refers to). Fulcro uses ClojureScript, which compiles to Javascript which runs in the browser.

Fulcro would work fine with a server written in Duct, or anything else (Clojure or not). As a client-side framework, Fulcro is not meant to talk directly to a backend component like Datomic (which is a database).

Fulcro has a free, comprehensive book. Recently the main developer of Fulcro communicated his intent to update the book to de-emphasize some of the server-side bits of Fulcro.

Duct can be used to build server-side backends. Here is a video explaining the concepts behind Duct. Duct can work with Datomic or any other database. Duct uses Clojure, which runs on the server on the JVM (Java Virtual Machine). Duct can be used to build an API server for a SPA, or be used to build a server for anything else.

Duct already has lots of modules, and you can also build your own.

6 Likes

Hi @adamfeldman

Thanks for pointing out the combination of fulcro+duct+walkable !

I didn’t realize that these could be used together :slight_smile:

So, in terms of analogy

  • Duct is more like Rails / Django
  • Fulcro is more like Angular

Would you say this is accurate?

However, I’d really just like to focus on the re-frame based UI setup since it makes it easier to move to re-natal for react-native applications.

Also, what I meant by saying MPA is a traditional Multi Page Application :slight_smile:

Fulcro is a react-js wrapper library that also handles state management and has a builtin way of handling network requests. It’s in the same category with apollo-client, facebook relay.

Fulcro can work with a Rest-full backend nicely, but the entire architecture is designed to work with a Graph-like backend like EQL or GraphQl. If you go with EQL backend then it works really well with Datomic since fulcro’s queries map pretty closely to datomic pull syntax (the recommended approach for backend is using https://wilkerlucio.github.io/pathom/).

A typical fulcro backend is just a “/api” endpoint that receives a graph-query.

If you’re building a SPA fulcro is a great choice.

If you want to build a traditional web-app then duct, https://github.com/coast-framework/coast, luminus are better choices since there designed for that.

7 Likes

My (limited) understanding is that you can use re-natal with Fulcro, but it does take some work. Despite the similar names, re-natal is not directly tied to re-frame. There are re-natal wrappers available that make it easier to use with tools such as re-frame, as well as with Om Next (which is a framework that Fulcro evolved from).

Thank you for this, the analogy comparing Fulco to Apollo and Relay is very helpful to me.

1 Like

Haven’t built any react-native apps. Not sure about the re-natal stuff and what it brings to the table.

https://clojurians-log.clojureverse.org/fulcro/2018-06-20
Looking at the GitHub - wilkerlucio/multi-timer seems pretty nice and straightforward to get working.

1 Like

I resonate more with Duct’s philosophy of data-driven architecture, where you can easily plug / unplug different parts of your system. For the moment I’ve rolled my own tiny duct-like backend framework that I use for most of my projects and keep adding stuff as needed, but eventually will migrate to Duct anyway :slight_smile: .

For the frontend re-frame + Sente seem to be a good combination.

2 Likes

Check this out: https://github.com/magnetcoop/hydrogen-ce

Based on the duct platform.

1 Like

Thanks guys, this thread continues to be really informative about web development in clojure :slight_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.