Can you use Clojure for mobile, backend, frontend, scripts, desktop and embedded development?

Volodymyr Kozieiev – Clojure(Script) tutorials
11 Oct 202204:30

Summary

TLDRクロージャーはホストされたプログラミング言語で、他の言語の環境で実行されます。最も人気のある実装はJavaバイトコードにコンパイルし、Java仮想マシン上で動作します。また、ClojureScriptはJavaScriptにコンパイルします。バックエンドでは不変データ構造と並行性サポートにより、大量のデータ処理や同時接続に適しており、Nubankのようなデジタルバンクで使用されています。フロントエンドではClojureScriptとReactを組み合わせてUIを構築し、モバイル開発ではClojureScript + ReactNativeが利用可能です。スクリプト作成にはBabashkaというネイティブインタープリターが利用でき、デスクトップ開発にはJava UIキットやClojureScript + ReactとElectronが選択肢です。しかし、選択肢が多くなりすぎて欠点もあります。新しいUIフレームワークであるHumble UIも開発中です。

Takeaways

  • 📚 Clojureはホストされたプログラミング言語で、他の言語の環境で実行されます。
  • 🔗 Clojureの最も人気のある実装はClojureコードをJavaバイトコードに変換し、Java仮想マシン上で実行します。
  • 🌐 ClojureScriptはClojureコードをJavaScriptにコンパイルする別の人気の実装です。
  • 🚫 Clojureはすべてのソフトウェア開発分野で使用できるわけではありませんが、特定の分野では非常に優れています。
  • 💼 バックエンド分野ではClojureが非常に適しており、不変データ構造と組み込みの並行性サポートがリアルタイムでの接続と大量のデータ処理に適しています。
  • 🏦 ナンバンクはClojureを重度に使用し、Clojureを開発するCognitect社を買収した例です。
  • 🌐 ClojureScriptはフロントエンド開発にも適しており、Reactを介して使用できます。
  • 🛍️ ウクライナ最大のインターネットショップの一つであるカスタはClojureScriptとReactを使用しています。
  • 📱 ClojureScript + ReactNativeを使用してモバイル開発も可能ですが、フロントエンドやバックエンドほど人気ではありません。
  • 📂 Clojureはスクリプト言語としても使用でき、Babashkaというツールを使用してJVMの遅い起動時間を回避できます。
  • 🖥️ デスクトップ開発ではClojure + JavaFXやClojure + Swingを使用することができますが、選択肢が多くあります。
  • 🌐 ClojureScript + ReactとElectronを使用してWeb-UIを作成し、デスクトップアプリケーションを開発することもできます。
  • 🔧 Clojureは組み込み分野ではあまり聞かれていませんが、他の分野では多くの選択肢があります。
  • 📱 ClojureDartは新しいClojureのバージョンで、Dartに言語を移植し、Flutterフレームワークを使用してネイティブのモバイルおよびデスクトップUIを開発することを目指しています。

Q & A

  • クロージャー言語はどのような種類のプログラミング言語ですか?

    -クロージャー言語はホストされたプログラミング言語で、他の言語の環境で実行されます。

  • クロージャー言語の最も人気のある実装は何ですか?

    -最も人気のあるクロージャーの実装は、クロージャーコードをJavaバイトコードに変換し、Java仮想マシン上で実行します。

  • ClojureScriptはどのような言語ですか?

    -ClojureScriptはクロージャー言語の1つで、クロージャーコードをJavaScriptにコンパイルします。

  • クロージャー言語を学ぶと、すべてのソフトウェア開発分野で使用できますか?

    -すべての分野で使用できるわけではありませんが、クロージャーが優れた分野では1つの言語で済む場合があります。

  • クロージャー言語はバックエンド開発においてどのように適しているのですか?

    -JVM上で実行し、不変データ構造と組み込みの同時実行サポートを持っており、同時接続と大量のデータ処理に適しています。

  • クロージャー言語が使用されている有名な企業はありますか?

    -ラテンアメリカのデジタルバンクであるNubankがクロージャーを使用しており、2020年にクロージャーを開発しているCognitect社を買収しました。

  • ClojureScriptはフロントエンド開発においてどのように役立ちますか?

    -ClojureScriptはReactを介してフロントエンドを構築する際に使用され、Reagentというラッパーライブラリを通じて使用できます。

  • クロージャー言語はモバイル開発に適しているでしょうか?

    -ClojureScript + ReactNativeというスタックを使用してモバイル開発が可能ですが、フロントエンドやバックエンドほど人気ではありません。

  • スク립ト作成にはクロージャー言語を使用できますか?

    -Bashで書くことができるものはクロージャーで書くことができますが、JVMクロージャーを使用する場合は起動時間が長いという問題があります。

  • Babashkaは何であり、どのように役立つのですか?

    -Babashkaはネイティブクロージャーインタープリタで、十分なクロージャーサブセットを実装し、ファイルシステムやコマンドライン引数、JSONなどの事前パッケージ化されたライブラリを提供しています。

  • デスクトップ開発においてクロージャー言語を使用する場合、どのようなアプローチがありますか?

    -JVMクロージャーを使用する場合、JavaのUIキットを直接使用するか、より慣用的なラッパーライブラリを使用することができます。

  • クロージャー言語の新しいバージョンであるClojureDartとは何ですか?

    -ClojureDartはクロージャー言語をDartに移植したもので、Flutterフレームワークを使用してネイティブのモバイルとデスクトップUIを作成することが主な目的です。

  • クロージャー言語は組み込みシステム開発には適しているでしょうか?

    -組み込みシステム開発においてクロージャー言語が使用されている例は聞いたことがありませんが、他の分野では多様な選択肢があります。

  • クロージャー言語を学ぶことでどのような利点がありますか?

    -クロージャー言語を学ぶことで、バックエンド開発、スク립ト作成、モバイル開発など、様々なタスクで異なるクロージャーのバリエーションを使用することができます。

Outlines

00:00

😀 Clojureのホスト言語としての機能と多様な応用分野

Clojureはホスト言語として動作し、他の言語の環境で実行されるプログラミング言語です。最も人気のある実装はJava仮想マシン上で動作するJavaバイトコードにコンパイルされ、ClojureScriptはJavaScriptにコンパイルされます。Clojureはバックエンド開発に適しており、不変データ構造と組み込みの並行性サポートにより、同時に多数の接続を処理し、大量のデータを扱うことができます。例えば、ラテンアメリカのデジタルバンクであるNubankはClojureを積極的に採用し、Clojureを開発するCognitect社を買収しました。フロントエンドではClojureScriptがReactと組み合わせて使用されており、Reagentというラッパーライブラリを通じてUIコンポーネントを記述できます。モバイル開発においてもClojureScript + ReactNativeを使用して開発が可能です。スクリプティング分野では、Bashスクリプトと同様にClojureを使用できますが、JVM Clojureでは起動時間が長いため、BabashkaというネイティブClojureインタープリタを使用することが推奨されています。デスクトップ開発ではJava UIキットを使用するか、ClojureScript + ReactをElectronでラップすることができます。しかし、これらの方法には欠点があり、どの方法も支配的ではありません。

Mindmap

Keywords

💡ホストされたプログラミング言語

ホストされたプログラミング言語とは、他の言語の環境内で動作するプログラミング言語のことです。このビデオでは、Clojureがその一例として挙げられており、Java Virtual Machine上で動作するJavaバイトコードにコンパイルされるなど、他の言語の環境で実行されるという特徴が強調されています。

💡Clojure

ClojureはJVM上で動作し、イミュータブルデータ構造と組み込みの並行性サポートを持つ関数型プログラミング言語です。ビデオでは、Clojureがバックエンド開発やフロントエンド開発など、ソフトウェア開発の様々な分野で使用されている例を紹介しており、その柔軟性と強力さを説明しています。

💡Javaバイトコード

JavaバイトコードはJavaコンパイラによって生成され、Java Virtual Machine上で実行される中間コードです。ビデオでは、ClojureがJavaバイトコードにコンパイルされることで、Javaの環境で動作するアプリケーションを開発することができると説明されています。

💡ClojureScript

ClojureScriptはClojureのコンパイラで、ClojureのコードをJavaScriptに変換します。ビデオでは、ClojureScriptを使用してウェブフロントエンドの開発が可能であると紹介されており、Reactと組み合わせて使用される例も説明されています。

💡Nubank

Nubankはラテンアメリカのデジタル銀行で、Clojureを使用して開発されたアプリケーションの代表例です。ビデオでは、NubankがClojureを重用し、Clojureを開発しているCognitect会社を買収したというエピソードも紹介されており、Clojureの実用性を強調しています。

💡Reagent

ReagentはClojureScriptのラッパーライブラリで、Reactと組み合わせて使用されます。ビデオでは、Reagentを使用してUIコンポーネントを純粋関数として記述し、Clojureデータ構造を返す方法が説明されています。

💡ReactNative

ReactNativeはモバイルアプリケーション開発のためのフレームワークで、JavaScriptを使用してiOSおよびAndroidアプリを開発できます。ビデオでは、ClojureScriptとReactNativeを組み合わせてモバイル開発を行う方法が紹介されています。

💡Babashka

BabashkaはネイティブClojureインタープリタで、ファイルシステムやコマンドライン引数、JSONなどのプリパックされたライブラリを備えています。ビデオでは、Babashkaを使用してClojureスクリプトをJVMなしで実行することができると説明されています。

💡デスクトップ開発

デスクトップ開発とは、コンピュータのデスクトップ環境で動作するアプリケーションを開発するプロセスです。ビデオでは、ClojureScriptとReactをElectronでラップしたり、MicrosoftのReact Native for Windows/macOSと組み合わせてデスクトップアプリケーションを開発する方法が紹介されています。

💡Humble UI

Humble UIはNiki Tonskyによって開発された新しいClojureのUIフレームワークで、ClojureのUI開発の問題を解決することを目的としています。ビデオでは、Humble UIがClojureのUI開発に提供する新しいオプションとして紹介されています。

💡ClojureDart

ClojureDartはClojure言語をDartに移植したもので、Flutterフレームワークを使用してネイティブのモバイルおよびデスクトップUIを作成することが可能です。ビデオでは、ClojureDartが提供する新しいモバイルおよびデスクトップ開発オプションとして触れられています。

Highlights

Clojure is a hosted programming language that runs in an environment of another language.

The most popular Clojure implementation compiles code into Java bytecode for the JVM.

ClojureScript is an alternative that compiles Clojure code into JavaScript.

Clojure can be used in various areas of software development where it has proven to be effective.

Backend development is a strong suit for Clojure due to its concurrency support and data processing capabilities.

Nubank, a Latin American digital bank, heavily utilizes Clojure and even acquired its developing company, Cognitect.

ClojureScript is well-suited for frontend development, especially when used with React via the Reagent library.

Kasta, a major Ukrainian internet-shop, uses ClojureScript with React for its frontend.

ClojureScript + ReactNative is a viable stack for mobile development, though not as popular as frontend or backend.

Status company has a blockchain-based mobile messenger written in ClojureScript with ReactNative.

Clojure can be used for scripting, offering an alternative to Bash with similar syntax and ease of use.

Babashka is a native Clojure interpreter that allows for faster script execution without JVM startup time.

Desktop development with Clojure can be achieved using Java UI kits or ClojureScript with frameworks like React.

ClojureScript + Microsoft’s React-Native for Windows or macOS is an option for desktop app development.

Humble UI is a new UI library for Clojure, addressing some of the UI challenges faced in desktop development.

ClojureDart is an emerging port of Clojure to Dart, aiming to leverage the Flutter framework for native UI development.

While Clojure has its niches, it is not always the most convenient choice for every situation.

Fullstack developers can utilize different flavors of Clojure across various tasks, showcasing its versatility.

Transcripts

play00:00

Hi!

play00:01

Clojure is a hosted programming language.

play00:02

This means what you wrote in Clojure will run in an environment of another language.

play00:07

The most popular implementation of Clojure turns Clojure code into Java bytecode that

play00:11

runs on Java Virtual Machine.

play00:13

Another popular implementation is ClojureScript.

play00:15

And its compiler turns your Clojure code into JavaScript.

play00:18

And there are a lot of other implementations.

play00:20

If you can run Clojure where Java or JavaScript runs, can you learn Clojure and conveniently

play00:25

use it in ALL areas of software development?

play00:27

Well, no.

play00:28

There is no silver bullet.

play00:29

But can Clojure be the only language YOU need?

play00:32

Yes, if you write software in areas where Clojure proved to be good.

play00:35

Let’s discuss some software development areas.

play00:38

Backend, here Clojure fits perfectly.

play00:41

Running on JVM, with its immutable data structures and built-in concurrency support, Clojure

play00:46

is very good at dealing with simultaneous connections and processing big amounts of

play00:51

data.

play00:52

One of the main examples of a production Clojure backend is a Nubank.

play00:55

It is a Latin American digital bank that used Clojure so heavily, that in 2020 they decided

play01:01

to acquire the Cognitect company that develops Clojure.

play01:05

On job boards, you can find backend Clojure roles in advertising or sports data processing.

play01:11

FrontEnd is also an area where Clojure fits, particularly ClojureScript.

play01:15

If you don’t know the difference - watch this video.

play01:17

The most popular approach for building frontend with ClojureScript is using React.

play01:23

You can use it via a wrapper library called Reagent and describe UI components as pure

play01:28

functions returning Clojure data structures.

play01:31

One of the biggest Ukrainian internet-shops Kasta uses ClojureScript with React.

play01:37

Mobile development is also possible with Clojure.

play01:39

The stack you can use here is ClojureScript + ReactNative.

play01:42

Though it is not as popular as frontend or backend.

play01:45

I did a quick search on job boards and didn’t find Clojure mobile positions published now.

play01:50

But they exist.

play01:51

For example Status company where I met Clojure for the first time and worked for a few years

play01:55

has a mature blockchain-based mobile messenger written in ClojureScript with ReactNative.

play02:02

Another area where you can use Clojure is scripting.

play02:04

Whatever you write in Bash, you can write in Clojure and without switching your brain

play02:08

context to another syntax.

play02:10

But If you will write the scripts with JVM Clojure there will be an issue - long startup

play02:14

time.

play02:15

Instead, you can use a tool called Babashka.

play02:17

It is a native Clojure interpreter that implements a sufficient subset of Clojure and goes with

play02:22

a bunch of prepacked libs to work with the filesystem, command line arguments, json.

play02:27

All these packed in a standalone binary, that you can deploy anywhere and run Clojure without

play02:32

JVM.

play02:33

On my local machine, I use babashka script that generates folder structure for the new

play02:36

blogpost and new video project when I start preparing them.

play02:39

With desktop development, the situation is more complicated than with all mentioned before.

play02:44

There are different approaches to creating interfaces.

play02:47

If you decide to use JVM Clojure, you can use one of Java UI kits.

play02:51

Either directly, or via more idiomatic wrapper libraries.

play02:54

You can use Clojure + JavaFX like the guys from Defold.

play02:58

They wrote an editor for their game engine this way.

play03:00

Or you can use Clojure + Swing, like in this tool (beat-link-trigger).

play03:03

Unfortunately, I have no idea what it is for but will leave a link in the description.

play03:08

You can create web-UI with ClojureScript + React and wrap it in Electron.

play03:12

One more approach - to write an app in ClojureScript + Microsoft’s version of react-native for

play03:17

windows or macOS.

play03:19

Or you can try to write an ipad-compatible app with standard React-Native and run it

play03:23

on Mac using apple’s project Catalyst :)

play03:26

So you can see, there are really a lot of choices but none of them dominates, which

play03:30

means they all have flaws.

play03:32

You can read a good article from Niki Tonsky where Clojure UI problems are discussed.

play03:36

Also to address the problems Niki Tonsky started the development of a new UI for Clojure, called

play03:41

Humble UI.

play03:42

So now we have one more option :)

play03:43

Ah, and there is also a new version of Clojure in active development - ClojureDart.

play03:48

It is a port of Clojure language to Dart with the primary goal of using Flutter framework

play03:53

and getting a native mobile and desktop UI.

play03:55

So one more option, yes :)

play03:57

As for embedded, I haven’t heard about Clojure in this area, sorry.

play04:01

BTW, If you know companies that do interesting products in Clojure - frontends, desktop,

play04:06

mobile - tell about them in the comments, I’m really interested and I believe other

play04:10

viewers are too.

play04:11

As you can see, there are situations when Clojure is not very convenient.

play04:15

But there are plenty of situations where it is.

play04:16

And if you are, for example, fullstack developer who occasionally writes scripts, you can use

play04:21

different flavors of Clojure in all your tasks.

play04:24

Isn’t it cool?)

play04:25

Subscribe to not miss the next videos!

play04:27

Thanks for watching!

play04:28

See you!

Rate This

5.0 / 5 (0 votes)

Related Tags
Clojure言語JVMClojureScriptReactモバイル開発スクリプトBabashkaデスクトップUIHumble UIFlutter
Do you need a summary in English?