Clojure and Clojurescript for the client side

Hey there,

i am currently making a kinda like roadmap for learning programming, thanks to your help.
And i am currently at the point of picking a language for parts i gonna need on the client side (desktop application and/or web frontend). I have looked on several languages and currently i like the syntax of clojure, so it came to my mind, if i can use Elixir in the backend, Clojure for client desktop GUIs, client agents… and clojurescript for the web frontend.

Clojure is a backend language too, but Elixir is my way to go for this part.
Knowing more languages is also important to me, so learning elixir and clojure(script) would fit this right away.
I just want to know if this construct makes sense at all:
Backend: Elixir
Client: Clojure
(Web)Frontend: Clojurescript

I appreciate your help as always!

1 Like

:wave:

What platforms are you targeting for your client apps?

I’d probably go with the languages native to the platforms like swift for ios/macos, c# for windows, kotlin/java for android, js for browser …

I’ve had the same thought regarding Clojurescript for the browser; Clojure is a well-designed language and I think there are a lot of shared values between Elixir and Clojure communities. Clojure was an early influence on the design of Elixir. Clojurescript has some mature and well performing frameworks like Re-frame and Om Next. Figwheel is a delightful development experience.

I’m not sure about using Clojure for “native” clients though. Clojure’s startup time is really quite poor compared to many other options. Honestly before I did this I’d look into using Clojurescript with React Native.

Mainly for windows and browsers.
I hate to admin it, but i just really am not comfortable with the c# syntax now.
I don’t know why, but something keeps me away everytime i start reading tutorials and getting into it. The same with pure Java. That’s why i was hoping for something else building Native GUIs.

Just the startup time? So every morning opening the program you mean?
Personally… I could easily live with that as an end user.
When i open Discord it takes like 20 seconds to complete. I know this is something else, but i am willing to wait for this program to load. It’s Elixir in the background there too i think…

If you choose clojure and clojurescript you can feel stuck after some time. Can you get help from experienced clojure programmer? Because stackoverflow is not beginner friendly as here :grinning:. If i were you i focus javascript and elixir. Yes hearing good things about clojure and clojurescript from experienced developers nice. But beginner and experienced developers problems are totally different.

No, i have no Clojure programmer whom i can ask for help.
But is this really necessary for learning though?

Yes that makes alot difference. Because you will spend hours for simple problems instead of 5 minute to ask your friend.

I wouldn’t recommend Clojure to anyone who isn’t already throughly familiar with the JVM ecosystem and its quirks.

If you want to learn to program with something “Clojure-like” then have a look at Racket - the experience will be much less frustrating.

Once you know/understand Racket it should be relatively easy to use JavaScript/ESNext in a Scheme-y way.

See also:

3 Likes

Thanks for this.
Okay, thanks, never heard of Racket before tbh. I will take a long on this.
Racket can do native GUIs on Windows and speak with Elixir?
Can it also work in the frontend for Webgui?

I’ve dabbled quite a bit with Clojure and Clojurescript after that post! The best way to get extremely quickly responses to beginner questions is to join the Clojurians Slack channel, especially the #beginners and #programmingbeginners channels. It’s probably the most beginner friendly and mature slack experience I’ve ever had, much much better than StackOverflow. There’s also the Clojure Reddit and Clojureverse forum, which are also friendly and high quality.

That said, there are still Java/JavaScirpt bits showing through occasionally when doing Clojure/ClojureScript. However, you don’t have to write in Java/JavaScript, just know enough of the syntax to figure out the documentation.

If you’re looking to do “native” GUIs, have a look at the Seesaw library for Clojure. I’m on a terribly slow mobile connection so I can’t give you a link, but it should be easy to Google.

For web apps, start with Reagent first. Do ask around on the Clojurians slack as you’ll get very good answers in all your questions.

Are you pleased with it, though? Or would you recommend trying something else first, like Racket ?

Racket is a great language environment to learn scheme with, not a great language for frontend web development. As far as I know it has no established framework at all so you’d be using FFI calls to Javascript libraries. This is a stark contrast to Om/Reagent which have established communities and production websites at established companies using them. Racket’s Javascript compilers look like toy projects to me but I’m not that familiar with them.

Hmm, sounds like Racket is basically a language for University usage and no “Real World” language.
Is it this was or just the case for Web development and not for native Client programming itself?
Just curios and i want to make the right decision futurewise. Thanks!

… them main reason being:

picking a language for parts i gonna need

is a very common approach to how many people choose a programming language - but that also somehow means that learning the programming language is “more important” than learning “to program”.

E. W. Dijkstra: To the Budget Council concerning Haskell

Racket was designed for “(programming) language oriented programming” which is why it is used to create the How to Design Programs 2e languages.

It can be used for Web Applications and GUI programming (though I don’t think it quite compares to “native”; even the best Clojure on Windows solutions I’d classify as “quasi-native”).

The idea being: learn to program first, worry about “the syntax” of the other more task targeted programming languages that follow later. The HtDP languages were designed to be the best “learn to program” languages.

I didn’t mean to imply that the community wasn’t helpful. It’s just the type of problems you would encounter as a total beginner could be off-putting. Some anecdotal observations:

  • While usually experienced Java programmers feel happier when moving into Clojure, others like experienced Ruby programmers do not.
  • Clojure is infamous for it’s befuddling (JVM-based) stack traces (though that may have improved by now).

For web apps, start with Reagent first.

I know that Reagent is well-represented but I was under the impression that re-frame specifically was the more recommended approach. I’m also not sure how easy it is to understand Reagent/re-frame if you don’t already know React beforehand via JavaScript.

2 Likes

The Frontend world is full of pain and frustration. Each day there is a new shiny tool, that get obsolete the very next week. Each day there is a breaking change, and You need to rewrite all.

With the Backend You deal with servers…

You can already do a lot with Phoenix, using Eex templates, a little bit of javascript and You could target any web devices. It’s SO 2000, but it works :slight_smile:

Separate Frontend/Backend requires a lot of work… Use the server as an API or GRAPHQL, change authentication mechanism, learn Frontend tools, framework, building tools etc.

I would first learn how to manage Backend well. If You want to treat all at the same time, it might be overwhelming, and with webassembly in the corner… I guess we will need to learn new tools.

do native GUIs on Windows

You seem to be focused on Windows. Wouldn’t “real world” considerations then simply dictate to learn C#, ASP.NET MVC, JavaScript, Angular and Windows UI?

i want to make the right decision futurewise

What future? On the one hand you are trying to cover the entire spectrum of Desktop GUI applications and Web applications with SPA frontends while on the other hand you seem to restrict yourself to “Windows”.

You may need to identify your priorities and goals more clearly.

While “Racket” may come across as having “no real world” relevance, it’s designed to be the best way to learn how to program - and there are people who are using it every day for “real world tasks” and would rather use Racket than any other language (like for example Python - which is “popular”).

1 Like

I’d suggest waiting a few more days with that. There’s a lot of anticipation for the Scenic framework that’s going to be presented on the upcoming Elixir Conf US.

Re-frame adds state management on top of Reagent, ala Redux with React Redux. It does more than that, but that is the primary thing that it does. It is the recommend approach for building large client-side applications. It is not necessarily the best choice for everyone to use for their first app though. If you are already familiar with functional languages and state management frameworks and React then sure, pick up Re-Frame first, but don’t feel like you have to.

1 Like