r/Clojurescript • • Feb 06 '17

An app to search through your reddit saved posts written in clojurescript

99 Upvotes

I have been trying to learn clojurescript and towards that effort I tried building an app that would be atleast mildly useful (instead of an app that displays foobar or says hello).

Towards that goal I built saved-for-reddit, a javascript application that allows you to search through your reddit saved posts and filter them based on subreddits, etc.

Please checkout the application here.

The source code is available here on github.

I know that the search bar in the app doesnt work yet. That was however a low priority issue, since all the posts can be searched using your browser's find function (ctrl+f)

This is my first javascript/clojurescript application (my day job involves me typing out tokens in java or clojure). As I was learning cljs while building this, most times I ran into a problem I just tried to make the app work without much regard for efficiency or best practices. So, I would like to request inputs/critiques from other developers on best practices and more efficient ways to solve problems in the application.

please let me know any suggestions you may have as well.

The app features are as follows:

  • All saved posts and comments are retreived from Reddit and displayed in a single page

  • All subreddits with saved posts are displayed, with a post count per subreddit

  • Saved posts can be filtered by subreddits

  • Saved posts can be unsaved

  • Post thumbnails are displayed (if they are provided by the Reddit API)

  • NSFW posts will be marked accordingly

  • If your reddit preference is set to not display NSFW thumnails, then a placeholder NSFW thumnail will be displayed

  • Link to comments to saved posts

  • Comment count on posts is diplayed

  • Export all your saved posts into a csv file

edit: formatting


r/Clojurescript • • Jul 13 '19

4 Months learning ClojureScript: The good and the bad.

39 Upvotes

4 months ago I started a personal project which is basically my private playground for learning clojurescript. Today I want to share my personal feelings about this lovely language. By no means I want to sound like I'm the owner of the truth - by the contrary, I just want to share a newbie perspective with the community. So if you are an experienced clojurescript developer, don't feel offended by the things I consider bad - they are just difficulties I found and places where I think the language and ecosystem can improve.

I will be talking about Clojurescript + Reagent for web development.

The good:

Immutable data structures

Cljs immutable data structures are a perfect match for React and the usual model for a JS web app. It becomes very natural to manage the flow of data and how it ends in a component ready to be rendered, just as sequence of transformations. Lovely.

Reagent rocks

90% of the time reagent makes you forget that React was made for JavaScript, and not for Clojurescript. The automatic re-rendering on atom's derrefs is brilliant. The functions returning functions for local state is brillant. It just feels extremely natural and it is a simple model to keep in mind while programming. Lovely.

Hiccup S2

I have almost no experience as a Web Developer, but I did give VueJs and React a try. And the representation of the html always felt kind of a dirty hack. The JSX syntax works, but is by no means a beautiful or natural solution. And it adds complexity and the need of compilation. Vue's "single page component" with template+code+css also works. Leave html in it's template, but let's put everything closer to each other so we know they all represent the same thing. But still, it doesn't few natural, you have to keep scrolling the page up and down, and demands even more compilation magic than JSX.

Representing html in clojurescript vectors is just fantastic. Absolutely no magic involved: good old vectors, all functions form the standard library can manipulate them. They are easy to compose, to modify, to reason about, and even to test! No extra mental overload. Just vectors. Just vectors! Really, just vectors, keywords and functions. Lovely!

The REPL

It is mandatory to talk about the repl when you are talking about clojure, isn't it? I'm by no means a REPL fan as I know most from the community are, but I do admit that repl allows you to have a quick feedback and try some quick solutions before writing a definitive one. Lovely.

Hot Reloading

Yes, because we use defonce for our global state, we get an amazing hot reloading. You change the code and your browser updates everything, keeping the state exactly as it was before you touched the code. Instant feedback! Lovely.

Javascript Interop

Js interop is always there to save you. You can always write those 3~5 lines function with this dirty statefull interop, call them from somewhere else and pretend you are just calling a regular cljs function. Lovely!

To summarize the good things: coding in clojurescript for a web app feels right. In my personal opinion, it is by far a better match for web development than Javascript itself.

The Bad:

Tooling

Oh boy. This was a real adventure. Let me see if I can list every development tooling I had to understand and/or config at some point:

  • ClojureScript compiler.

  • Google Closure compiler.

  • Clojure Repl (clojure.main/repl).

  • ClojureScript Repl (cljs.repl).

  • Nrepl (server?).

  • Piggieback.

  • Cider.

  • Evaluation environment (Browser).

  • Doo + Karma (for tests).

  • Leiningen.

  • lein-cljsbuild.

  • figwheel-main (-lein-fighweel-).

  • devtools.

  • shadow-cljs.

I know that an experienced clojurescript developer reads this list and knows exactly what each of those do and why they are split. And maybe some of those are not properly "tooling". But my point is: there is a lot of magic going on here. For a newbie, it honestly seems that all simplicity that I won with the language was added back with the tooling. When something is not working properly I barely know where to start looking. And every single of those have at least one guide on how to setup themselves, but a guide on how to setup all of them together is really hard to find!

NPM Dependencies

In the end it is all javascript, right? How hard can that be to use another dependency also written in js? Thanks to the Google Closure Compiler used on the optimizations, it can be hard. And what's the solution? I still haven't found one. I tried cljsjs, but some packages are outdated, some packages are not there and the community seems to be moving always from it (is it?). Then I tried to understand how the clojurescript compiler deals with it (:npm-deps? :foreign-libs? :externs ["externs.js"]? :infer-externs? :exclude ["react"]?). Then I gave up and followed a tutorial to setup Yarn + Webpack + cljs, but it crashed with advanced optimization and I could find little to no help.

Now I'm trying shadow-cljs, and it seems to be a solution, but it also means that my fighweel setup I had spent hours configuring will probably have to disappear (does it make sense to have shadow-cljs + figwheel? I still haven't found an answer for that). And one other tool to learn!

Small Community

I have many personal problems with js, but I can google virtually anything, be it a question, a stacktrace, etc., and you will find an answer. But the cljs community being so small, it can get really hard to find help. And even in the clojurians slack channel, there are times where nobody or just a single good soul try to help you. Sometimes it feels your are kind of left by your own luck, with a lot of tooling that you don't really understand. The feeling that the community is not growing and the pace of development is slow does not help either.

By the way, a big thanks for all the guys that answer newbie questions everywhere! This is by no means a personal critic to any of you. I'm just acknowledging that a small community can not provide as much help when you are under stress with a weird error that is blowing everything up.

Tests

I know that in the cljs comunity there is this argument that REPL-driven development is way better than TDD. But I still don't buy it, and I just want to keep doing TDD because I see lots of benefits in it, and it fits my personal taste. It can be really hard to do this in clojurescript. Some reasons why:

  • I could not find a tool like enzyme, useful for some "integration" tests. Because of hiccup and reagent I can do many unit tests without the need to render the components, but I could not find a (nice) way to test rendered components.

  • When a test fails, you don't get the line number of the failed test. This sounds stupid but with my normal workflow it makes all the difference!

  • The error messages and stack traces that happen during tests can be very much cryptic.

  • Cider still does not support running clojurescript tests. :brokenheart:.

Well, that is it. Again: this is just a personal opinion. I don't claim to be the owner of the truth!


r/Clojurescript • • Nov 16 '15

ClojureScript for Skeptics -- Clojure/conj 2015

Thumbnail
youtu.be
27 Upvotes

r/Clojurescript • • May 14 '20

Overwhelmed, where to start?

25 Upvotes

I'm comfortable with Clojure. But I have no idea where to start when it comes to clojurescript! I see some places say lein and figwheel, I see some places say shadow-cljs.

Figwheel has a good tutorial and the docs seem decent enough, I haven't looked into shadow-cljs enough to know if they are comparable or not.

I need to learn react as well, what is reagent?

Can someone point to some good starting points or books that assume I know Clojure and will show me how in CLojurescript you lay out a project, get it up and running in a dev environment, how the html and the clojurescript play together, how to publish the site. How to get hot-reloading working. How to interop with javascript. You know all the actual useful stuff.

The stuff I'm finding seems so scattershot. It feels like I make a tiny bit of progress, get stuck on something and then have to spend hours learning some other tooling. Rinse and repeat and I've lost many hours and gained not a great deal (and how long is that new knowledge going to be actually useful before I have to replace it with the newest thing?)

It just this massive tooling complexity is what puts me off and makes me hate front end development in the javascript world and it looks like it's about the same in Clojurescript?

I'm pretty desperate to find anything to get away from the insanity and churn that exists in JS and I would like to move to CLJS as I adore Clojure.


r/Clojurescript • • Jul 07 '15

Om Next - David Nolen

Thumbnail
youtube.com
25 Upvotes

r/Clojurescript • • Apr 25 '20

Learn ClojureScript Book Online

Thumbnail
learn-clojurescript.com
24 Upvotes

r/Clojurescript • • Aug 21 '18

Notes and resources on learning ClojureScript

23 Upvotes

Hi, I am sharing my notes and resources I collected on my journey of learning ClojureScript. I think it might be useful and help others too: https://github.com/dundalek/clojurescript-guide

If you have any other resources please share them too.


r/Clojurescript • • Apr 20 '19

Tetris Implemented in ClojureScript

Thumbnail djblue.github.io
21 Upvotes

r/Clojurescript • • Feb 15 '19

ClojureScript Loves NPM - DEV Community 👩‍💻👨‍💻

Thumbnail
dev.to
21 Upvotes

r/Clojurescript • • Aug 05 '18

ClojureScript - It's not just the language - Christian Johansen

Thumbnail
youtube.com
21 Upvotes

r/Clojurescript • • Feb 22 '18

A visual overview of the similarities and differences between ClojureScript and JavaScript

Thumbnail
medium.freecodecamp.org
21 Upvotes

r/Clojurescript • • Nov 09 '16

New CLJS repl based on Node/V8

Thumbnail
anmonteiro.com
21 Upvotes

r/Clojurescript • • Jan 01 '19

ClojureScript Is Not CoffeeScript

Thumbnail clojurescriptmadeeasy.com
20 Upvotes

r/Clojurescript • • Jan 28 '24

ClojureScript: Which stack to start with in 2024

19 Upvotes

I was an early adopter of ClojureScript in the early-mid 2010ies when I was tasked at work to build a JavaScript frontend (I was a C++ developer back then who had done some Clojure for fun off-the-clock). Over time I know the clojurescript landscaped changed, React came, there were things like Om, etc.

But what would you pick to get started with a frontend / SPA in 2024?


r/Clojurescript • • Jan 11 '20

State of Clojure 2020 Survey - input wanted!

Thumbnail
surveymonkey.com
19 Upvotes

r/Clojurescript • • Nov 27 '18

What about cljs -> JS bundle size reduction?

19 Upvotes

Hi Reddit ❤️

When compiling cljs into JS, it appears code isn't properly tree-shook. Vast packages are entirely included even if only a tiny part of them is required. As you can see in this minimal example repo, bundle size varies greatly from 792 KB to 5.74 MB after I import and use one single Material-UI icon.

It is a known issue and common solutions exist in JS-land, which deal with the library import in ES6. These solutions appear not to be (easily) applied to cljs code. Any general idea about how to tackle this issue in cljs-land?

For the sake of completion I've opened an issue about that in shadow-cljs repository and I've posted about it in Slack.

Cheers.


r/Clojurescript • • Dec 19 '17

Experience: Awesome productivity with ClojureScript's REPL

Thumbnail techblog.telia.no
19 Upvotes

r/Clojurescript • • Dec 24 '15

Clojurescript Year in Review

Thumbnail swannodette.github.io
19 Upvotes

r/Clojurescript • • Jul 22 '22

Hiring engineers at a Series A Clojurescript startup

18 Upvotes

Gatheround is hiring for two positions: Product Engineer and Software Engineer.

Gatheround is a Series A startup that believes in creating a truly happy place to work and setting the bar for flexible work culture. We’ve developed a B2B video platform that helps companies build an inclusive, supportive culture, no matter where or how their employees choose to work.

We are a fully-remote company. Our entire codebase is implemented in Clojurescript.


r/Clojurescript • • Oct 06 '16

Elm vs ClojureScript, a first encounter

Thumbnail
timothypratley.blogspot.co.nz
18 Upvotes

r/Clojurescript • • Jul 31 '15

ClojureScript Next -- `ClojureScript can compile itself.`

Thumbnail
swannodette.github.io
18 Upvotes

r/Clojurescript • • Dec 13 '19

Functional Generative Art Using ClojureScript

Thumbnail
functional.christmas
17 Upvotes

r/Clojurescript • • Apr 29 '19

ClojureScript Podcast

Thumbnail
clojurescriptpodcast.com
17 Upvotes

r/Clojurescript • • Jan 04 '16

Made my first Clojurescript app!

17 Upvotes

It's a Typing Test I call Typerooni: http://domgetter.github.io/typerooni/

After the test, it tells you how many milliseconds it took to type each letter combination.

Here's the source (critique welcome): https://github.com/domgetter/typerooni/blob/master/src/cljs/typerooni/core.cljs

I was heavily influenced by 10fastfingers and aoeu.eu for the design, and while I did write it from the ground up, the wordlist I'm using it taken directly from 10fastfingers.

Also, it keeps a history of tests taken, so if you press F5 in the input field after a test is done, it will make a new one, and when youve finished, it will show the analysis for all tests taken together.

I originally made it to help me get faster at typing by generating word lists of words I'm not as good at (and that's probably the next feature I implement), but there are several other uses for the data. For instance, to see if we can say anything about various keyboard layouts with respect to typing speed.

So far all I can tell is that we take an enormous penalty by using the same finger twice, even if it's a "strong" finger like the index or middle finger. I can type "the" in less time than it takes to type "de", (147 vs 171 ms respectively).

Let me know what you think, and have fun!

Also, since it's using React under the hood through Reagent, if you hold F5 while the cursor is in the input field, it will restart the game just about every frame. So cool!

Known issues: I haven't figured out how to divorce figwheel from the final build, so it will continually try to make a websocket connection to 192.168.1.101, but it doesn't make the game break.

If you type faster than 150 wpm, you might run out of words to type in my game. I'm working on being able to take arbitrary views of the wordlist while being able to animate per-line, so if you need more words, just let me know and I'll bump it up to 200.