This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aatree (1)
- # admin-announcements (7)
- # announcements (3)
- # beginners (125)
- # boot (164)
- # braid-chat (8)
- # cider (26)
- # cljsrn (37)
- # clojars (3)
- # clojure (162)
- # clojure-argentina (1)
- # clojure-art (2)
- # clojure-berlin (5)
- # clojure-czech (3)
- # clojure-ireland (1)
- # clojure-miami (1)
- # clojure-norway (9)
- # clojure-russia (47)
- # clojurebridge (1)
- # clojurescript (151)
- # community-development (1)
- # conf-proposals (80)
- # core-async (15)
- # core-matrix (1)
- # cursive (66)
- # datomic (26)
- # emacs (17)
- # events (10)
- # funcool (59)
- # hoplon (43)
- # incanter (2)
- # jobs (10)
- # ldnclj (8)
- # lein-figwheel (18)
- # luminus (1)
- # off-topic (19)
- # om (144)
- # onyx (167)
- # overtone (9)
- # parinfer (12)
- # pedestal (1)
- # proton (158)
- # re-frame (139)
- # reagent (48)
- # test-check (19)
- # testing (43)
Has anyone ever felt like they will never be able to jump out of the beginning knowing the syntax into actually using Clojure? That’s where I am and have been, it’s frustrating!
@joshua.d.horwitz: yes- that's pretty common for me, in fact. i was reading about clojure off and on probably for about a year before i wrote any code
and i struggled a lot with the reading- coming largely from the C-style languages, though i had some lisp and scheme long long ago
the absence of syntax- like the absence of an else signal in an if statement- was very difficult to get my brain around for reading, much less writing
my suggestion would be- open a repl, and just start by typing something like (println (str "hello" "world"))
@joshua.d.horwitz: Yeah, it can be a big shift from just "playing with Clojure" to actually "programming with Clojure". There’s a lot to get your head around in terms of the mindset for building things in a functional style.
@joshua.d.horwitz: What have you worked your way through in terms of exercises? Clojure Koans? 4clojure?
I’ve made it through almost all of the Clojure Koans and up to about 100 in 4clojure
But to be honest, I really didn’t understand what I was doing and had to look up hints
I’ve been doing Clojure in production for five years and I still have to look stuff up all the time
if you like puzzles and games you could set yourself a task of encoding the rules of a game that you like in clojure
While 4clojure has some interesting problems, you can write great software while being unable to solve much of it
@joshua.d.horwitz: I found the http://purelyfunctional.tv courses were a huge change from playing to writing real utilities
What helped me get over that initial hump was to take some code I had at work and rewrite it in Clojure several different ways.
If you normally program on the JVM, you can always try those Clojure versions out in situ as a replacement for your original work code.
I never really felt comfortable with clojure until I learned the basics of paredit, tbqh
The ability to edit my code as sexps gave me the ability to easily experiment with different forms until I could develop my own aesthetic
Yeah, I hadn't thought of that... Seeing code-as-forms rather than code-as-a-string-of-characters does help with some internalization of Clojure's "way of thinking"...
I've gotten so used to editing with s-expressions that I tend to forget I'm doing more than "editing text". I've even got to the point where
paredit-convolute-sexpr seems fairly natural (on the few occasions I need it).
So @joshua.d.horwitz what sort of projects would you like to try to tackle with Clojure to get into really "using" it?
I’m not sure, I’d love any guidance or help, or any good open source projects, I have a tough time focusing lol
I think you're going to need to give us something in order to make recommendations! 😸
reductions is an interesting function, too, if you want each step along the way — https://clojuredocs.org/clojure.core/reductions
@seancorfield: I’m going to try and think of something! I was thinking of making a website or something along those lines, where family can go to see updated info about my daughter
anyone seen this error before? I can't figure it out 😞
Exception in thread "main" java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonParser.setCurrentValue(Ljava/lang/Object;)V, compiling:(core.clj:210:1)
@clojuregeek: check your lein deps :tree to see if there are multiple versions of jackson
yeah. a lot of services depend on jackson under the hood. try using :exclude in the dep that points to the older jackson
i did that.. and a few other things, I'm just going to try a different solution because i need this done. Thanks for the debugging help
@clojuregeek: I would try to explicitly include the version you need in your project.clj and exclude everywhere else it is used
What’s an HTTP server library that’d be idiomatic Clojure of something that express does with Node.js?
@kamuela: What parts of express are you thinking of? If you mean an entire framework, the closest thing I'm aware of is http://www.luminusweb.net/
Lots of good docs on that site that should help you ask more specific questions if it's not exactly what you need.
shaun-mahood: something that would expose me to HTTP requests and let me work with them
Ok, then you could also look at Compojure https://github.com/weavejester/compojure
It's about as close to standard as things get as far as I can tell, and I've seen it recommended a couple of times as a great way to see what idiomatic Clojure code looks like
@kamuela compojure is definitely easy to get up and running with, the code style is familiar for people coming from other platforms, and it's likely the most commonly used routing library. definitely worth starting with. that said, something that distinguishes clojure from other languages is the ability to take what's called a "data driven" approach- define what you can in data, rather than in code. The pedestal web framework takes this approach: https://github.com/pedestal/pedestal. So, where compojure uses macros to define routes, pedestal uses a data structure. Where ring- the web processing library underneath compojure- uses functions wrapping functions for middleware- pedestal defines middleware in a data structure. It can be a harder concept to grok, coming from other languages, but can lead to more power when one has mastered it In any event- good luck!
@jonahbenton: Testament to the strength of this community that you immediately tried to get me to change my mind
I think both are excellent options and really should give Pedestal a try one of these days
@kamuela heh, not trying to change minds, just pointing out another guidepost in the learning process. have fun!
the function i defined in sql when called in clojure will return a list containing a hashmap
i’m wondering if it’s possible to just get the hashmap? or is the list there for multiple values from a query
@krchia yes, the existence of the list represents the possibility that multiple rows may be returned from a query. and each row is a hashmap where keys are columns and values are row elements. so if you have a query that will always return one row, just take (first) of the list
ah geez, in the middle of asking i realized that i hadn’t considered the possibility that queries might return more than 1 result..
hi i’m trying to figure out what’s the biggest length that a encrypted password will be
(defn big [num] (loop [x num max 0] (let [encrypt-count (count (encrypt-password (random-string 20)))] (cond (= x 0) encrypt-count (> encrypt-count max) (recur (- x 1) encrypt-count) :else (recur (- x 1) max)))))
honestly, most hashers always have the same length output no reason to do a loop
@krchia yeah, hashing will produce the same length data, no matter what the input; encryption will produce encrypted text in blocks of fixed size
where the number of blocks will correspond to the length of the source. so just encrypt any string that is the maximum length password- that's the maximum length encrypted version
shouldn't even be neccessary to use a max length pass - all the commonly used hashers output a constant length digest (IE sha-256 outputs a 256 bit digest no matter what)
true - although most of the time when people say they're "encrypting" a password it's a misnomer
so yea - constant length, which depends only on the hash function you're using
user=> (hashers/encrypt "111") "bcrypt+sha512$a80d3246e31344e0d9720455473b6f40$12$be9630434562ef5d7f029a5ebf71f479d85a6f6a2f968f9b" user=> (hashers/encrypt "111") "bcrypt+sha512$01e85c69303b2a727052c6cd619b69ee$12$952a5feb253c506bd592d89f3d7dc93cd40f242f81a8ef41"
worthanot0.server> (encrypt-password "111") "bcrypt+blake2b-512$38926065266c68dba599d48e2d6f1ad5$12$cb93f46b437b5651f9dc4880cb8dfe76725f90a4f12721be" worthanot0.server> (encrypt-password "111") "pbkdf2+blake2b-512$75b178d2fe9e8c582887d8b9$50000$81f5b68911a37ae47af52cd45d6d41fdee26640b7afba360d201d346161ce537002ae409ac80537e3b3fc061ee120b16889358e7a3a8124e0967fc5e95023ac7" worthanot0.server> (encrypt-password "111") "bcrypt+blake2b-512$26c43be256d419042903901569177e4e$12$18b9e413404225e9377b1610634cc13b4cfe091cf695cc64"
I think Clojure for JVM is straightforward but I'm actually still confused by how this builds for JS
@kamuela buddy is only for JVM, it uses the JVM library bouncycastle under the hood
pretty much everything i've seem about clojurescript suggests that it's a pain to compile multiple separate js files - if I want to make a non-SPA app, would the suggested approach be to have separate clojurescript apps which are routed to by something like nginx?
for instance - If I want a static landing page, with links to a couple pages which serve clojurescript, do I need to serve the static parts of the website and each page containing clojurescript separately?
I managed to get multiple js files pretty easily with Boot, maybe you could try that?
pretty compelling usecase for boot if it makes it easy. I might just be looking at lein the wrong way though
does boot have the equivalent of lein plugins? I've been using them pretty heavily
It does, they are called tasks I think. This example project sets up automatic clojurescript reloading, like figwheel