r/Clojure • • Jan 08 '22

Introducing Kit Framework

https://yogthos.net/posts/2022-01-08-IntroducingKit.html
93 Upvotes

20 comments sorted by

17

u/lilactown Jan 08 '22

Kit looks great! I think that prebuilt modules + generators is exactly the type of tooling I've wanted when developing applications in Clojure, and have enjoyed using similar tools with Elixir + Phoenix.

A question I have after reading the blog post: how does versioning of modules work? Examples:

  • There's a security problem in an auth module I'm using, and I need to upgrade my service. What's the right way to upgrade the module?

  • I just installed a module and there's a bug in the latest version in the way it merged my config. I revert the changes, can I also try an earlier version of the module?

  • I have been using a module that hasn't been updated in awhile. I'd like to use a newer version of a library that it installed; what's the right way to override what the module is doing?

Very excited about this, I think that it will help a lot of people by easing evolving a code base over time in the same way luminus helped with boot strapping a new one.

8

u/yogthos Jan 08 '22

Hi, glad you like the approach so far.

And it's a good question about versioning. Currently, it's not in scope, but could definitely be added later. Module config is a map, so it would be a matter of adding a new key there. Then when modules are installed, they write to the install log in the project. So the modules could write out the version that was last installed.

Then there could be a concept if migrations in the modules potentially. So, a module could look at the installed version and figure out what needs updating based on that.

Thanks for the suggestion, I'll add it in to the roadmap. :)

3

u/lilactown Jan 08 '22

It's likely you've thought of this, but what if modules were consumed as libs and included in a consumers deps.edn, and then kit could use whatever is on the class path?

You could keep the explicit module config in kit.edn if you like, or even allow walking the class path to find all available modules.

4

u/yogthos Jan 08 '22

There is already a set of libraries for stuff that can be abstracted that way, and those can be included via deps.edn. However, the point of a module is to add functionality directly into assets controlled by the user. For example, if we add support of ClojureScript or HTML, we'd add HTML template files, package.json, etc.

5

u/kinleyd Jan 09 '22

This looks very interesting! I'm going to set aside some time for an exploratory project. Thank you, yogthos, et al.

4

u/yogthos Jan 09 '22

Thanks, hopefully this makes Clojure web dev a bit more accessible :)

3

u/TheLastSock Jan 08 '22 edited Jan 08 '22

Did you mean to say "back building"? Or "back breaking" Maybe just "ingenuity "?

Love the idea here, is there a reason you feel we shouldn't make websockets the default? Or does it try to not make an assumptions there?

3

u/yogthos Jan 08 '22

Oh haha yeah that's a typo there, and the framework tries to make as little assumptions as possible. So, the defaults are just a sample route, so it's up to the user to add websockets or other functionality if they want.

2

u/TheLastSock Jan 08 '22

Thanks, for the reply.

2

u/ertucetin Jan 09 '22

Are you still going to maintain Luminus?

3

u/yogthos Jan 09 '22

In the foreseeable future I plan to keep libraries up to date, but I'm probably not going to make any more design changes going forward. And if anybody is interested in taking over Luminus definitely give me a shout. :)

2

u/[deleted] Apr 19 '22

hey, thanks for sharing this! i saw the talk scheduled on clojureverse, i'm excited to check it out.

i've been playing with kit and reading integrant source code, trying to figure out why it is that i have to call integrants (reset) when i make changes to a controller function. i remember i didn't have to do this with luminus, but it seems like this is a step backwards with REPL-driven-dev as a work flow, constantly having to switch files to user.clj to run (reset) when i update something.

is it an artifact of using tools.deps instead of leiningen? i'm probably missing something basic about how clojure works -- still somewhat new myself.

3

u/yogthos Apr 19 '22

Hi, having to call reset is an artifact of the way Integrant manages stateful components. All the components live in a system map, and calling reset causes this map to be refreshed. You don't actually have to switch files in order to call reset though, you can just call (user/reset) from any namespace or directly in the REPL.

4

u/sunng Jan 09 '22

Congratulations for this release!

The kit approach is just similar to spring/spring-boot in java. The integrant edn acts like spring configuration class or the classic xml files, while kit modules are like spring-boot starters. It's nice to see clojure community borrows different design ideas from others. The diversity will be helpful to a broader audience of clojure.

3

u/[deleted] Jan 09 '22

Looking forward to using this. I've always had that exact issue talked about in the blog, where I have to think ahead if I want cljs, shadow, etc when I really just want to start small then add features as my app grows.

1

u/Kobleren Jan 08 '22

(kit/sync-modules) 2022-01-08 22:50:43,895 [main] DEBUG org.eclipse.jgit.util.FS - readpipe [git, --version],/usr/bin 2022-01-08 22:50:43,906 [main] DEBUG org.eclipse.jgit.util.FS - readpipe may return 'git version 2.33.1' 2022-01-08 22:50:43,907 [main] DEBUG org.eclipse.jgit.util.FS - remaining output: 2022-01-08 22:50:43,908 [main] DEBUG org.eclipse.jgit.util.FS - readpipe [git, config, --system, --edit],/usr/bin 2022-01-08 22:50:43,910 [main] DEBUG org.eclipse.jgit.util.FS - readpipe may return '/etc/gitconfig' 2022-01-08 22:50:43,910 [main] DEBUG org.eclipse.jgit.util.FS - remaining output: failed to clone module: [email protected]:kit-clj/modules.git cause: [email protected]:kit-clj/modules.git: invalid privatekey: [B@40d8e4f6nil

4

u/[deleted] Jan 09 '22

Have a look here: https://github.com/kit-clj/kit/issues/4

The (current) solution is to use a key in PEM format, e.g.

ssh-keygen -t rsa -m PEM

0

u/[deleted] Jan 09 '22

[deleted]

6

u/yogthos Jan 09 '22

I think Kit modules could do similar stuff to Phoenix or Rails. The goal of modules is to automate the whole patching together process. For example, if you add ClojureScript support, it'll generate new routes, add HTML template files, configure shadow-cljs, and so on with a single command from the REPL.

3

u/lordmyd May 14 '22

Agreed. Whilst I applaud Dmitri's work I just tried working with Kit and for every route which accessed a database I had to destructure query-fn from path-params then pass it to every HugSQL call, some of which were several layers deep. Clojure needs a web framework supported by the whole community, not by a dedicated team of 3 or 4 devs. The typical Clojure bunch-o-libs approach also prevents the ecosystem growing around a framework.