Fork me on GitHub

Is this style guide ( the authoritative style guide for Clojure right now? Are there any competitors? I am trying to create contributor guidelines for an open source project and I want to make sure I am giving contributors the right guidance.

🙂 4

It is certainly the best known one. Plenty of Clojure developers will have points of disagreement on at least some of them, so there isn't any kind of unanimity of opinion on them.


I am not aware of any other Clojure style guides.


Thanks so much!


didn't know about this one, agree with all of it, wish everything followed it tbh


they should add "use set instead of into #{} " as that one annoys me a bit too haha


@U5LPUJ7AP A good reason for preferring into #{} over set is that the former supports transducers: (into #{} xf coll)


yes, that usecase is valid to me, for sure. but if you're not using a transducer... 😕


Consistency would suggest using into #{} for all cases where you produce sets from collections, so it covers both the transducer and the non-transducer case.


(That said, I use set for the non-transducer case sometimes)


Under the hood set and into #{} are almost identical: both reduce with conj into a new set (unless the input coll is already a set, which is an optimization in set).


makes sense. on a related note, good style would dictate that you don't use ->> with just two arguments (for what?), yet when I use map I tend to prefer to use ->> anyway, just because that's how map is used most of the time and it's more consistent I guess? bit easier to read


Yeah, I sometimes use -> or ->> with just two expressions because I find the pipeline ordering easier to read than the nested function calls, but it depends very much on what those two expressions are.


If the wrapping function is simple -- taking a single argument and having a relatively short name itself -- then (wrapper (map ,,,)) is fairly readable. Otherwise (->> (map ,,,) (wrapper-with-a-long-name :and :additional :arguments)) is more readable when split across two lines.


I'm designing a clojure application that has to, among other things, manage linux ipsets / iptables. Only root can do that, apparently. What are the best practices for things like that? I could run the whole app as root, but that feels wrong (because you should minimize the amount and complexity of code running as root). I could call e.g. "sudo ipset" from my app, but that would either spam the system logs endlessly or I'd have to kill logging in sudo altogether. I could write a small wrapper to do setuid + exec ipset, but then I'll have to leave clojure land for that. Is there some standard solution / pattern for situations like that?


@jason358 The approach that Apple takes on macOS is to have dedicated processes with elevated permissions, and use some kind of inter-process RPC for doing the work. Perhaps might be applicable to your problem.


yeah, it's a variant of the wrapper thing (in my case exec with args + slurp stdout is a good enough RPC, I suppose)


I guess if you want to make it more “official” you could wrap it in its own persistent process.


Hi there, My nephew, 19 yrs old CS student moved in during pandemic and I'd like to teach him some important stuff that will help him in his career. Any suggestions regarding an online course he might take? I was thinking about The Hardware/Software Interface as a low-level dive, also was considering SICP, How to Design Programs, etc etc. Would like to hear other opinions about - what would you have taught to this kid next few months?


What are his interests and motivation for doing CS in the first place?

💯 12

SICP is amazing but not from a career point of view. Maybe get him started on some cool open source projects?

eccentric J17:04:30

I feel like it's a missed opportunity to just assign him some books. What's your nephew interested in? What's their current experience level? How do they learn best? Would they prefer to learn from writing practical projects or learning academic concepts?

Phil Shapiro17:04:48

I took the SICP course when I was 19, and it had a lasting, positive effect on my (25+ year) career as a software engineer. I agree that it’s not a book that will train you to write commercial software, though. Maybe both the book and the open source, for the applied side of things.

eccentric J17:04:10

Unfortunately due to the situation the board where I work decided to let go our recent FE intern. I decided I didn't want them to leave empty handed so I started working on which creates unit tests to teach RamdaJS and functional programming concepts.


I definitely recommend something that is project based. when I used to interview lots of new grads, applicants with “here’s this thing I built” definitely stood out. it’s also a great way to quickly gain a lot of practical experience. any project that they’re passionate about can work, but if they don’t have something in mind, I would recommend building a 2d game without using a game engine like unity/unreal. it’s fun and you learn a ton. I had friend ask a similar question and compiled this list of self-learning resources from around the internet:

✔️ 4

Thank you guys for your replies. @UBHTL6AF3 I’m not sure he knows the answer to the question, hopefully he’ll figure it out sooner. @UJRDALZA5 And it’s a long one as well. @UQL85PT29 Yeah, SICP has provided me with clarity I had never dreamed of before. Invaluable resource. @U8WFYMFRU @U7RJTCH6J Gifted to him learning C++ programming through building games (In the first semester, the uni decided to introduce kids to programming with c++), but I don’t see much enthusiasm from his side. Anyway, I decided to settle down and try course, to give him an idea what can be done using current “bleeding-edge” tech, and realization that he also is capable of doing it.

eccentric J18:04:10 got me thinking if there are any FP languages great for game dev?


I wanna say ? With the caveat that its browser based things only. IMHO, its Functional Reactive approach and emitting the whole of HTML, CSS and JS from one lang helps in thinking about UI and Graphics as a single entity. Purely my thoughts though! 😄

👍 4

And it has great perf


Also maybe with Rust, if we wanna look at Rust more from an FP lens than imperative. :thinking_face:

Vincent Cantin00:04:53

I would say that Clojure is a good candidate as a language, but the runtime and some “core functions” may need some modification to use less memory allocation/de-allocation. The Arcadia project is pointing to this direction.


I don't think Elm or Clojure are particularly well suited to game dev, but i am welcome to being proved wrong