Clojure in production: what do we use in real-world services?

Andrey Fadeev
11 Aug 202319:02

Summary

TLDRこのビデオでは、プロダクションで使用するClojure言語のライブラリについて議論しています。開発者Andréは、言語を始めた初心者が何を使えば良いか、また何を避けるべきかを解説します。10年間開発を経験し、JavaからClojureに移行したAndréは、言語と関数型プログラミングを楽しんでいると語ります。プロジェクトの作成方法や依存性の管理、コンポーネント管理、設定、HTTPサーバーの立ち上げ方、HTTPリクエスト、リレーショナルデータベースとの連携、スキーマとバリデーション、その他有用なライブラリやツールについて詳述。特に推奨するものや避けるべきライブラリを紹介し、プロダクションコードでのライブラリ選択のガイドラインを提供しています。

Takeaways

  • 👨‍💻 スクリプトの分析: 今回のビデオはClojure言語のライブラリ選択について議論し、初心者向けに役立つ情報を提供している。
  • 🔧 開発ツールの推奨: ビデオでは、プロダクションで使用するツールとして`boot`は推奨されず、代わりに`deps.edn`を使用することが推奨されている。
  • 📚 プロジェクト管理: 小規模プロジェクトでは自前でプロジェクトを管理することも可能だが、大規模プロジェクトではライブラリを使用して管理することが推奨されている。
  • 🚫 マウントライブラリの非推奨: 開発者がグローバルな状態を直接使用し、関数プログラミングの概念を損なうため、マウントライブラリは推奨されていない。
  • 🔄 コンポーネント管理: `component`ライブラリや`integrand`ライブラリを使用して、システムのコンポーネントを管理することが推奨されている。
  • 📝 設定管理: `configurator`ライブラリは推奨されておらず、`IRL`ライブラリがシンプルで効果的な設定管理ツールとして紹介されている。
  • 🌐 HTTPサーバーの選択: `JT`をベースに`ring`や`pedestal`を使用し、HTTPルーティングには`bidi`、`composure`、`pedestal`などのライブラリが挙げられている。
  • 🚫 HTTP Kitの非推奨: モニタリングツールとの統合が困難なため、HTTP Kitの使用は推奨されていない。
  • 🔗 HTTPリクエスト: `clj-http`ライブラリが推奨されており、Java 11以上であればJavaの組み込みHTTPクライアントも選択肢として挙げられている。
  • 🗃️ データベース操作: `next-jdbc`と`HikariCP`が推奨されており、SQLの記述には`honeysql`と`hugsql`という2つのアプローチが紹介されている。
  • 📑 スキーマとバリデーション: `schema`ライブラリ、`clojure.spec`、`malli`という3つのバリデーションライブラリが挙げられており、それぞれ異なるアプローチを持っている。
  • 🛠️ 他の一般的なライブラリ: `core.cache`、`core.memoize`、`cheshire`、`claypoole`などがプロダクションコードで一般的に使用されている。
  • 🛑 追加ツール: `clj-kondo`、`cljfmt`、`babashka`などのツールがプロダクションサービスで一般的に使用されていると紹介されている。

Q & A

  • ビデオの主な目的は何ですか?

    -ビデオの主な目的は、プロダクションで使用するべきライブラリについて議論し、言語を始めたばかりの開発者に対して、使用すべきものと使用しないようにするものを知らせることで、彼らのクロジャー言語の旅を助けることです。

  • クロジャー言語での開発を始めたばかりの人たちに何を勧めますか?

    -クロジャー言語での開発を始めたばかりの人たちには、最初はフレームワークを組み合わせずに必要なライブラリを組み合わせてプロジェクトを構築することを勧めます。これは学習曲線が異なるかもしれませんが、すべてのパーツがどのように機能するかを理解するのに役立ちます。

  • クロジャー言語のプロジェクトを作成し、依存関係を管理するのにどのツールを使用することが推奨されますか?

    -クロジャー言語のプロジェクトを作成し、依存関係を管理するためには、LanternとClojureのdeps.ednという2つのソリッドなオプションがあります。最近はClojureのdeps.ednを試して良い結果を得ており、新しいプロジェクトにはこれを標準として使用する予定です。

  • ビデオではどのライブラリを使用してシステムのコンポーネントを管理することが推奨されますか?

    -ビデオでは、コンポーネントライブラリまたはIntegrandライブラリを使用してシステムのコンポーネントを管理することが推奨されています。特にIntegrandは最近試し始めており、良い結果を得ています。

  • ビデオでは設定管理ライブラリとしてどのライブラリを使用することが推奨されますか?

    -ビデオでは設定管理ライブラリとして、configuratorは推奨されませんが、envやAndroidライブラリの上にちょっとしたラッパーを提供するIRLライブラリが推奨されています。

  • ビデオではHTTPサーバーを立ち上げるときどのライブラリを使用することが推奨されますか?

    -ビデオではHTTPサーバーを立ち上げるとき、Jettyをベースとして使用し、その上にringやpedestalなどのライブラリを組み合わせて使用することが推奨されています。

  • ビデオではHTTPリクエストを行うためにどのライブラリを使用することが推奨されますか?

    -ビデオではHTTPリクエストを行うためには、clj-httpライブラリを使用することが推奨されています。これはApache HTTPクライアントをバックエンドとして使用しており、多くの機能を提供しています。

  • ビデオではリレーショナルデータベースと連携する際にどのライブラリを使用することが推奨されますか?

    -ビデオではリレーショナルデータベースと連携する際には、HikariCPを使用した接続プールやhoneysqlとhugsqlという2つのライブラリを使用することが推奨されています。

  • ビデオではスキーマとバリデーションのためにどのライブラリを使用することが推奨されますか?

    -ビデオではスキーマとバリデーションのためには、schemaライブラリ、clojure.spec、そしてMalliライブラリが挙げられますが、特にMalliライブラリは非常に良いフィードバックを得ていると聞きます。

  • ビデオではプロダクションコードで一般的に使用される他のライブラリには何がありますか?

    -ビデオではプロダクションコードで一般的に使用される他のライブラリとして、core.cache、core.memoize、cheshire、claypoolなどが挙げられますが、特にclaypoolは並列処理を行うための良い選択肢です。

  • ビデオではプロダクションサービスで使用される追加ツールには何がありますか?

    -ビデオではプロダクションサービスで使用される追加ツールとして、clj-fmt(コードフォーマッター)、clj-kondo(リンター)、そしてbabashka(スクリプトをクロジャー言語で書けるツール)が挙げられます。

Outlines

00:00

😀 プロダクションコードにおけるライブラリ選択について

ビデオでは、プログラミング言語Clojureのライブラリ選択について議論します。Andreは10年間の開発経験を持ち、JavaからClojureに移行し、関数型プログラミングを楽しんでいます。プロダクションでのライブラリの選択は非常に重要で、初心者にとっては選択肢が多すぎてどのライブラリが良いかわかりません。Andreは自分が経験を通じて得た知識を共有し、初心者がどのライブラリを使うべきかを知るためのガイドラインを提供します。また、ウェブフレームワークは避けるべきで、必要なライブラリを組み合わせてプロジェクトを構築することが推奨されています。

05:02

🛠️ プロジェクトの作成と依存関係管理

プロダクションコードで依存関係を管理する方法として、Leiningenとtools.ednの2つのオプションが提案されています。Leiningenは以前のプロジェクトでよく使われていましたが、tools.ednは新しいプロジェクトで標準となっています。Clojureのエコシステムの一部であるtools.ednは今後ますます使われることが予想されます。また、Bootは推奨されません。

10:02

🔌 システムコンポーネントの管理

実際のアプリケーションでは、HTTPサーバー、データベース接続プール、Kafkaコンシューマーなど、多くのシステムコンポーネントを管理する必要があります。小さなプロジェクトでは自分で管理することも可能ですが、大きなプロジェクトではライブラリに任せることが推奨されています。Mountはグローバルな状態を許可するため推奨されませんが、componentライブラリやintegrandライブラリは良い選択肢です。

15:05

⚙️ 設定管理

設定管理については、configuratorライブラリは推奨されませんが、core.typedとAndroidライブラリ、特にIRLライブラリが推奨されています。IRLは機能と複雑性のバランスが良く、環境変数を明示的に扱うことができます。

🌐 HTTPサーバーの設定

HTTPサーバーの設定について、JTをベースにringやpedestalなどのライブラリを組み合わせて使用することが一般的です。HTTPルーティングには多くのライブラリがあり、比較のためのマトリックスも存在します。また、HTTP kitはモニタリングツールとの互換性の問題があるため推奨されません。

📚 リレーショナルデータベースとの連携

リレーショナルデータベースとの連携については、next.jdbcが標準となっています。HikariCPが接続プールとしてよく使われています。SQLクエリの作成にはHoney SQLとHugSQLという2つのアプローチがあります。Honey SQLではクロージャーのマップを使ってSQLを定義し、HugSQLではSQLファイルをプロジェクトに配置し、クエリを関数として扱うことができます。

📝 スキーマとバリデーション

スキーマとバリデーションについては、schemaライブラリ、clojure.spec、およびMaliという3つのオプションがあります。schemaはシンプルで使いやすい一方、clojure.specは学習曲線が高く、Maliは非常に良いフィードバックを得ています。

🛠️ その他のプロダクションコードで使われるライブラリ

プロダクションコードで使われるライブラリとして、core.cacheとcore.memoize、cheshire、Claypoolなどが挙げられます。cheshireは機能は豊富ですが、過剰なエンジニアリングを招くことがあるため注意が必要です。Claypoolは並列処理のための優れたライブラリです。

🛠️ 追加のプロダクションツール

プロダクションサービスで使われるツールとして、cljfmt(コードフォーマッター)、clj-kondo(リンター)、およびbabashka(スクリプト言語)があります。これらのツールはネイティブイメージとして利用でき、高速なスタートアップが可能です。特にbabashkaはCIパイプラインのスクリプトを書き換える際に非常に便利です。

Mindmap

Keywords

💡クロージャー言語

クロージャー言語はLisp系のプログラミング言語で、関数型プログラミングをサポートしています。ビデオでは、開発者がクロージャー言語を使い始めた背景とその利点を紹介しており、言語の柔軟性と関数型プログラミングの楽しさを称賛しています。

💡ライブラリ

ライブラリとは、ソフトウェア開発において再利用可能なコードの集合体であり、特定のタスクを実行するのに必要な機能を提供します。ビデオでは、クロージャー言語でプロダクションコードを書く際に使用するライブラリを選ぶ重要性が強調されており、様々なライブラリの選定基準が説明されています。

💡プロダクションコード

プロダクションコードとは、実際のビジネスやサービスで使用されるソフトウェアコードのことを指します。ビデオでは、プロダクション環境で使用されるライブラリやツールについて詳しく説明しており、その選択がシステムの信頼性と保守性に影響を与えると指摘しています。

💡依存性管理

依存性管理とは、ソフトウェア開発において必要な外部ライブラリやモジュールを管理するプロセスです。ビデオでは、Leiningenとbootというツールを使用して依存性を管理し、新しいプロジェクトではdeps.ednが標準になる可能性があると述べています。

💡コンポーネント管理

コンポーネント管理は、ソフトウェアアーキテクチャにおいて、システムの各部分を管理し、開始と停止のロジックを制御するプロセスです。ビデオでは、Mountライブラリに対して批判的な意見を示し、componentとintegrandというライブラリを推奨しています。

💡設定管理

設定管理とは、アプリケーションの実行に必要な設定値を管理するプロセスです。ビデオでは、configuratorライブラリに対して批判を示し、envとAndroidライブラリ、そしてIRLライブラリを推奨しています。IRLはシンプルで明示的な設定管理を行うことができると評価されています。

💡HTTPサーバー

HTTPサーバーとは、HTTPプロトコルに基づいてクライアントからのリクエストに応答するソフトウェアです。ビデオでは、JTとring、pedestalといったライブラリを使用してHTTPサーバーを構築し、ルーティングにはcompojureやpedestalが推奨されています。

💡HTTPクライアント

HTTPクライアントとは、HTTPリクエストを送信し、サーバーからのレスポンスを受信するソフトウェアです。ビデオでは、clj-httpライブラリを使用してHTTPリクエストを行う方法が推奨されており、Java 11以上であれば組み込みのJava HTTPクライアントも選択肢として挙げられています。

💡データベース

データベースとは、データの保管や管理を行うシステムであり、多くのアプリケーションにとって重要なコンポーネントです。ビデオでは、HikariCPという接続プールライブラリと、honeysqlやHugSQLというSQLクエリライブラリについて紹介しています。

💡スキーマと検証

スキーマと検証とは、データの構造と整合性を保証するプロセスを指します。ビデオでは、schemaライブラリ、clojure.spec、そしてMaliというライブラリについて紹介しており、これらを使用してデータの検証とスキーマ定義を行うことができます。

💡並列処理

並列処理とは、複数のタスクを同時に実行するプロセスです。ビデオでは、Claypoolライブラリを使用してJavaの実行フレームワークをラップし、スレッドプールを通じて並列処理を行う方法が紹介されています。これはCPUに負荷がかからないタスクに適しています。

💡開発ツール

開発ツールとは、ソフトウェア開発のプロセスを支援するツール群です。ビデオでは、clj-fmtというコードフォーマッターやclj-kondoというリンター、そしてBabashkaというスクリプト言語としてクロージャー言語を使用するツールが紹介されており、これらのツールが開発効率を向上させると説明されています。

Highlights

Andre discusses libraries used in production for Clojure, aiming to guide beginners.

Started as a Java developer, Andre switched to Clojure due to enjoyment of functional programming.

Recommends starting with combining libraries instead of using web frameworks for learning purposes.

For project creation and dependency management, recommends using either lein or clj.

Notes a trend decline for lein in favor of clj, suggesting clj will be the new standard.

Advises against using boot in 2023, suggesting it's not worth the time to learn or try.

For managing components in a system, recommends against mount due to global state issues.

Suggests using component or integrand library for better component management.

Warns against using configurator for configuration due to unnecessary complexity.

Recommends the IRL library for configuration due to its balance of features and simplicity.

For HTTP servers, recommends using Jetty as a base with Ring or Pedestal on top.

Advises against using HTTP kit due to lack of monitoring tool support.

Recommends clj-http for HTTP requests or Java's built-in HTTP client for Java 11+.

For relational databases, suggests using nextjdbc for connection pools and HikariCP as an option.

Recommends honey SQL and hugSQL for writing and manipulating SQL queries.

Presents schema, clojure.spec, and Mali as options for schemas and validation.

Advises caution when using core.async to avoid over-engineering.

Highly recommends Claypool for running tasks in parallel with thread pools.

clj-fmt and clj-kondo are recommended for code formatting and linting.

Babashka is highlighted as a tool for writing scripts in Clojure, beneficial for CI pipelines.

Transcripts

play00:00

hi it's Andre here the idea for today's

play00:02

video is just to discuss which libraries

play00:05

we use in production enclosure so if

play00:08

you're just starting with the language

play00:09

you know what you should use or what you

play00:12

shouldn't

play00:13

I've been a developer for 10 years I

play00:16

started as a Java developer and after

play00:18

that I switched to closure because I

play00:20

really enjoyed the language and the

play00:22

functional programming I mean in general

play00:24

so after that it's been almost seven

play00:28

years now when I'm doing the closure

play00:30

full time and I gained some experience

play00:35

with that so I just want to share with

play00:37

you I think this kind of videos will be

play00:40

really useful for beginners and who just

play00:43

starting their

play00:45

closure journey and it definitely would

play00:49

be really useful for me when I started

play00:51

because the selection of libraries is

play00:55

really white and you don't really know

play00:57

which is a good choice and which is not

play01:00

and I would like to see this kind of

play01:03

video when I started just to have some

play01:06

guidance which libraries I should pick

play01:09

in my project

play01:12

so the before we start

play01:15

let's mention one thing so I know there

play01:19

are projects uh in the closure ecosystem

play01:21

that's supposed to be web Frameworks uh

play01:26

but I highly recommend if you're just

play01:29

starting uh first time try to combine

play01:32

some libraries

play01:33

which you need and build it from the

play01:37

scratch

play01:38

so yeah the learning curve will be

play01:42

different and you'll spend a bit more

play01:44

time but it's really useful uh knowledge

play01:48

at least to know how all these pieces

play01:50

works together if you enjoy the

play01:52

framework later that's fine

play01:55

but if we're talking about production

play01:57

code to be honest I never seen these

play02:00

Frameworks were used in real production

play02:03

code it was always some kind of

play02:05

combination of libraries

play02:08

that evolves with microsources as they

play02:11

as they need

play02:13

[Music]

play02:15

right so how do we even create the

play02:18

project and how we manage the

play02:20

dependencies that we need in my opinion

play02:22

there are two solid options one is

play02:24

landingen and one is depths dot EDM

play02:28

until recently all our projects were

play02:31

managed by leningen but we started

play02:35

experimenting with depths.edm we have

play02:39

some good results and I think uh for

play02:42

their new projects

play02:44

depths.edm will be our new standard

play02:48

so there is nothing wrong to use

play02:51

learning game it works just fine no

play02:54

complaints the only thing to mention is

play02:58

according to the closure state survey

play03:01

the trend for the learning game is

play03:04

actually going down compared to the

play03:07

devs.edn that's going up and considering

play03:10

that depths.edm is actually a part of

play03:13

the closure it makes sense to try that

play03:17

or and at least like make yourself

play03:21

familiar with depths.edn so you won't be

play03:25

surprised if you see more and more

play03:27

projects using that in future

play03:30

so

play03:32

it was also a time when it was more like

play03:37

Lanigan versus boot but in 2023 I highly

play03:43

don't recommend spend your time

play03:45

learning or trying boot

play03:49

so to recap if you're planning to if

play03:53

you're using learning game already or

play03:55

you don't and you don't want to spend

play03:57

time rewriting it to depths.edn that's

play03:59

totally fine that will work uh work as

play04:03

expected uh you won't have any problems

play04:06

but for the new projects and services uh

play04:10

I would consider depths.edm

play04:13

[Music]

play04:16

moving on and the next topic is how we

play04:19

managing components in our system so in

play04:22

real world applications we have a bunch

play04:24

of parts of the system of the service

play04:26

that we should worry about

play04:28

it usually will have some kind of HTTP

play04:32

server then we have database connection

play04:34

pools and we have Kafka consumers and

play04:38

other processes that should be started

play04:40

and also different types of caches and

play04:43

the list can go on and on and we need

play04:46

some some way to manage that start and

play04:50

stop logic so we don't have to care

play04:52

about the order and dependencies

play04:55

so the first thing you can think about

play04:58

is uh to do it yourself so just in main

play05:01

function you can Define what to start in

play05:04

which order and that's totally fine for

play05:07

small projects for bigger projects you

play05:10

just don't don't want to mess with that

play05:12

too much and you just want to rely on

play05:15

some kind of library that will do it for

play05:17

you so it will just add a bit of

play05:20

structure to your application and it

play05:22

will be easier for everyone to

play05:24

understand how exactly dependency Works

play05:27

inside your servers so let's start with

play05:31

one that I don't really recommend and

play05:33

it's Mount the biggest problem I see

play05:36

with this library is actually that it

play05:40

allows the developers to write a quite

play05:43

bad code from my opinion so the state

play05:46

like this components are basically

play05:50

Global so nothing is preventing

play05:53

developers to

play05:56

directly use that state inside somewhere

play06:00

inside their functions and it basically

play06:04

just ruins the entire concept of

play06:07

functional programming when you have a

play06:09

function and everything you need to pass

play06:11

to that function is defined by the

play06:14

arguments so that's my biggest problem

play06:16

with this library and I don't really

play06:19

recommend it plus I never seen it used

play06:22

in production

play06:24

um

play06:24

uh where I worked so

play06:28

moving on to good options from my point

play06:31

of view and they are component library

play06:33

or the integrand library so we are using

play06:37

mostly component everywhere we are

play06:40

starting experimenting with the

play06:42

integrand but there is not much update

play06:45

yet so my recommendation will be just to

play06:49

check both compare them and select what

play06:53

you like but it feels like both are

play06:56

solid choices so you won't do a mistake

play06:58

if you pick one of those

play07:00

[Music]

play07:04

cool the next topic should be a quick

play07:07

one let's talk about the configuration

play07:09

so if you're thinking about a library

play07:12

called configurator I highly don't

play07:14

recommend to use that because it adds a

play07:17

lot of unnecessary features the syntax

play07:19

is uh verbose it adds more complexity

play07:22

than the value from my point of view so

play07:24

if you have a something small you don't

play07:27

have too many properties to pass using

play07:30

the system get and function is totally

play07:33

okay I've seen that in production the

play07:35

other option is the Android library that

play07:37

will give you a bit of a wrap on top of

play07:40

that with some extra features but I

play07:43

think the most solid Choice really is

play07:45

the IRL Library it's a good balance

play07:48

between features and

play07:50

their complexity so it's really explicit

play07:55

you just have your dot EDM file with

play07:58

your configuration and you see all the

play08:00

placeholders where you put

play08:02

put your environment variables so yeah

play08:06

highly recommend and a big plus for that

play08:08

Library

play08:09

[Music]

play08:13

cool let's talk about what we use to

play08:17

spin up the HTTP servers inside our

play08:20

services

play08:21

so in all the places I worked we just

play08:24

use JT as the base and on top of that

play08:28

sometimes we had ring sometimes we had

play08:30

pedestal uh if we took talking about the

play08:34

HTTP routing there are a huge list of

play08:37

libraries available and to mention some

play08:39

they are BD rated

play08:43

composure and pedestal

play08:45

and I don't have

play08:47

um

play08:48

good recommendation here just go and try

play08:51

some of those and find what you like the

play08:55

most also in the video docs there is a

play08:59

good Matrix comparing all other

play09:02

libraries and you can see all the

play09:04

features and what's different so that

play09:07

could be really useful

play09:10

the one thing I should say is if you're

play09:13

using a stack something like ring on top

play09:16

of JT with the ring JT adapter and you

play09:19

use composure on top of that

play09:21

don't be afraid it's not amateur code

play09:24

I've seen that in a lot of production

play09:27

code as well so you're totally fine

play09:30

uh

play09:32

one more Library I should mention is

play09:35

HTTP kit and it was quite popular but

play09:40

I don't really recommend using that and

play09:43

there is a reason for that

play09:44

so the project itself is interesting and

play09:48

it has like the HTTP server pod and the

play09:51

HTTP client part so you basically have

play09:54

one library to do both

play09:56

the problem is that it's not really

play09:58

widely used so if you

play10:02

at some point would like to integrate uh

play10:06

some monitoring tool inside your servers

play10:10

something like that supports Java Auto

play10:13

instrumentation datadoc agent neuralic

play10:17

agent or even the open Telemetry Java

play10:20

agent you'll be in trouble because HTTP

play10:23

is not supported so you won't see your

play10:26

incoming requests and you won't see the

play10:30

distributed traces for your outgoing

play10:32

HTTP requests so you will have to do

play10:35

manual instrumentation or migrate away

play10:38

from the HTTP kit and I'm just saying

play10:41

that because I was just doing this

play10:43

migration not long ago

play10:46

[Music]

play10:49

in addition to the HTTP service let's

play10:52

talk about the HTTP requests because

play10:53

usually we have to do some HTTP requests

play10:56

in our services and we need to pick a

play10:58

library for that a good choice for that

play11:00

will be a clj HTTP which is using Apache

play11:04

HTTP Library under the hood it has a lot

play11:07

of features and we use it almost in all

play11:10

services in production

play11:12

but if you are on Java 11 or higher

play11:17

potentially you want to use

play11:19

the built-in Java HTTP client which

play11:24

seems to be good starting from java 11.

play11:27

and there are a couple libraries that

play11:30

are wrappers of this Java API enclosure

play11:34

unfortunately I haven't touched them too

play11:37

much so I won't give you any suggestions

play11:40

which one to use so explore on your own

play11:44

but anyway if you pick the clj HTTP and

play11:48

you don't mind extra dependencies for

play11:50

this Apache HTTP client you'll be

play11:52

totally fine

play11:54

[Music]

play11:58

so the next one is working with the

play12:01

relational databases and that should be

play12:04

a quick one as well so uh the the

play12:08

standard for the gdpc library now is the

play12:11

next gdbc uh for the uh connection pools

play12:16

in most of places uh we were using the

play12:19

Hikari CP works fine and we have no

play12:22

problems with that

play12:24

moving to the writing the SQL queries

play12:27

itself

play12:28

I would consider two different libraries

play12:32

with two slightly different approaches

play12:34

one is called honey SQL and the other

play12:38

one is hog SQL so the honeysql the ID is

play12:43

that you write your SQL

play12:46

and use the closure maps to Define your

play12:50

SQL queries

play12:52

the benefit of that is that when you

play12:55

define your SQL query as the closure

play12:57

structure it basically has accessed all

play12:59

the functions to manipulate the data so

play13:02

you can add conditions and change your

play13:05

query with with the code

play13:09

there the other one I mentioned is hugs

play13:12

equal and we use that a lot right now uh

play13:15

the ID is different you basically have

play13:18

your plain dot SQL files in your project

play13:20

and then you define queries or update

play13:25

insert delete statements in that files

play13:27

and on top of each section you will have

play13:31

a small metadata as a comment with the

play13:34

name and then inside your closure code

play13:36

with that Library you can literally use

play13:38

that name as a function and then you

play13:41

have some API to call or execute this

play13:44

SQL statements so as I said these two

play13:50

libraries were used more mostly in

play13:52

production I worked and it was kind of

play13:56

like 50 50.

play13:58

I don't have one recommendation so just

play14:03

go compare those Library yourself and

play14:07

select what what you like most

play14:13

cool the next topic is schemas and

play14:16

validation and I have here three options

play14:19

for you so first one is the schema

play14:22

library and old classic uh still good

play14:25

choice really fast to learn and easy to

play14:29

use

play14:30

second option is closure spec and the

play14:35

good thing about that is is part of

play14:37

closure so that means no extra

play14:39

dependencies

play14:41

but from my experience it has a bit of a

play14:45

learning curve but yeah eventually it

play14:48

will do the job for you

play14:49

so and the final one

play14:52

the library called Mali I haven't used

play14:55

it

play14:56

use it much but heard really fantastic

play15:00

feedback

play15:01

so that should be a good choice of a

play15:04

library

play15:05

as well by the way

play15:08

consider subscribing to the channel

play15:10

because I'm planning the loan with me

play15:13

video where I'll take a look into the

play15:15

Mali Library

play15:17

[Music]

play15:21

cool in this section let's talk about

play15:24

some other libraries that are commonly

play15:25

used in the production code so the first

play15:29

two uh code.cash and core dot memoize

play15:32

good choices if you want

play15:35

extend the functionality for your

play15:38

memoise functions or you want some type

play15:40

of a cache inside your application

play15:43

second one is chorusing and it's really

play15:46

interesting topic so the library itself

play15:49

is great and it's just like a

play15:51

masterpiece but if you're thinking to

play15:53

use that just think twice if you really

play15:56

need it because it's really easy to over

play15:59

engineer and use this Library where it's

play16:02

actually not required so be really

play16:06

careful

play16:07

and the final one which has uh final one

play16:11

that I really recommend is the Claypool

play16:13

library and if you want some cheap

play16:17

option to run your tasks in parallel

play16:20

that's a perfect library for you so it

play16:24

will be a wrapper around

play16:26

Java execution framework when you have

play16:29

access to different thread pools and the

play16:33

syntax is similar to like map and pmap

play16:37

functions that you have enclosure the

play16:39

only difference that you will be able to

play16:40

pass your thread pool as an argument to

play16:43

that function so your pmap will be

play16:46

executed on a thread pool and it will it

play16:50

is really useful if you have something

play16:51

like a hundred of requests to spin we

play16:55

all know that

play16:56

core function the pmap is not suitable

play17:00

for that cases it's only for the CPU

play17:02

intensive task so keep that in mind

play17:08

cool we almost did it so the final topic

play17:11

will be some additional tools that are

play17:14

commonly used in the Production Services

play17:16

first one is clj fmt which is their code

play17:20

formatter and it's quite important to

play17:22

keep your code consistently formatted

play17:26

across multiple projects

play17:29

second one is cljconda which is the

play17:32

linta that we usually use

play17:35

and a good thing about those two tools I

play17:40

mentioned is that they are available as

play17:42

native images so the startup is really

play17:45

fast and you won't spend extra time

play17:49

waiting for this task to complete

play17:52

and the final one which actually should

play17:55

be a separate video but I'll mention it

play17:58

here is the babashka which is a tool

play18:02

that allows you to write your scripts in

play18:05

closure

play18:06

so we use it quite extensively right now

play18:09

and we are rewriting the entire

play18:13

CI pipelines and all the scripts used in

play18:18

CI in babashka and are really happy with

play18:21

the results

play18:23

it's really good that you don't have to

play18:25

touch your Bosch scripts again

play18:28

thumbs up

play18:29

[Music]

play18:33

thanks for watching I hope you found the

play18:35

content useful and I gave you some

play18:37

insights into the production closure

play18:39

code

play18:40

if you enjoyed the video please give me

play18:43

a thumbs up also if you are interested

play18:45

in more closure content subscribe to the

play18:47

channel so you don't miss the next video

play18:50

have a lovely day and see you in the

play18:52

next one

play18:54

foreign

play19:00

[Music]

Rate This

5.0 / 5 (0 votes)

Related Tags
クロジャー言語プロダクションライブラリ開発者フレームワーク依存性管理HTTPサーバーデータベース並列処理コードフォーマットCIツール
Do you need a summary in English?