Fork me on GitHub

I try this socket setting and it won't connect. its the lein repl, which i have started already.


You can't connect Chlorine to an nREPL server, only a Socket REPL.


nREPL and socket REPL have a lot in common in their names, but are not the same thing.


You can tell Leiningen to start a Socket REPL. I have this profile in my ~/.lein/profiles.clj file

:socket {:jvm-opts ["-Dclojure.server.lein={:port 55555 :accept clojure.core.server/repl}"]}


(`profiles.clj` is a hash map of profiles)


Then you can start Leiningen with that profile added:

lein with-profile +socket repl
and that will start a REPL, with an nREPL Server (which is default Leiningen behavior), but also a Socket REPL on port 55555.

👍 4

Then you can connect Chlorine to that Socket REPL


thats on my todo list


That's what I use when I'm working on a Leiningen-based project, so I can continue using Chlorine as normal.


Seems better now. two questions though: when I make and edit, i always get a 'failed to refresh' message, is this just something to get used to ? and shouldnt one of the outputs eval to even ?


Which right paren matches up with the left paren just before the cond in that code?


That is where the cond expression ends.


Re: failed to refresh. Make sure your Settings for the Chlorine package look like this...


Well, you can have the console position be right (like you seem to have it set now).


The important one is the last one. Make sure refresh on save is off and change the refresh mode to simple


@paulgureghian @andy.fingerhut is right -- your parens are messed up. Your cond ends with the ) after "even" and then your function contains two more expressions -- the (= (rem n 2) 1) expression and finally the "odd" expression -- so your function always returns "odd" because that's the last expression in your function.


If you install Parinfer it will help you balance your parens better.


Hey! I was just reading some cheshire-code and got somewhat confused. The function generate-string in the core-ns has typehints ^String on its argument-vector. What is the rationale there? The function is explicitly for json-stringifying arbitrary clojure-objects, so why typehint it as String?


I see, that makes sense


Regarding Clojurescript and Javascript, doesn't hot reloading in Javascript work as good as in Clojurescript (Year 2019?). Aka when you change some code the state remains the same (if you use something like React + Redux?). I haven't done any javascript since the jquery days.


I know that Clojurescript had support for this before javascript through figwheel.


I find the difference is in whats idiomatic. Yes, with the right javascript code using the right datastructurescoded in the right way it can work. But in cljs that way is much more idiomatic. Any code you are depending on has been built around the proceeds of time constructs... because thats the only way in cljs. In javascript it feels like fighting. In cljs it feels like flow. Just my opinion, of course. Javascript fans may disagree.


The thing I'm curious about is whether it pans out in JavaScript if you don't have immutable data nor a single app state atom. I would imagine that things could get out of hand if references to mutable data end up spread throughout your app while you are trying to update it, but I'm only speculating and am honestly curious. Perhaps this is what @UKH2HDSQH is referring to: Things can work with extra discipline.


I'm not a great js programmer, but when I have done react and redux and state management, I'm always accidentally breaking it. Like, whoops, that code mutated the state in place, not created and returned a new state. And it doesnt throw an error. It just subtley misbehaves. And then I'm trying to find the needle in a haystack. In cljs, for me, it just seems to work by default.


I wonder if this is the strange kind of stuff James Long was referring to in this tweet Seems that if mutable stuff is part of the game, things can get wonky fast.


would I get some more responses if I asked this question on Clojureverse? This is really interesting. 🙂


I also think that hotloading in cljs has improved over the last few years. I use figwheel and have found some issues have been resolved and the error reporting has definitely improved. Perhaps cljs hotloading is more mature? I don't have enough experience with the js side to say. Im using figwheel all the time.


hi, is it possible to run shadow-cljs on a server and access the web page via a browser on another computer? I read about setting :http somewhere, but couldn't really get it to work. would be great for experimenting


not sure exactly with shadow-cljs, but the idea is bind the websocket listener (server side) to (all interfaces) not (localhost)


I'll try that out, thank you!


this shouldn't require any configuration? you just start the shadow-cljs process regularly and then access it via the IP. eg.


This feels somewhat insane to me, with nested anonymous functions and all ... is there a more straightforward way of doing this? (I'm http/getting some json-serialized sql-dates here)

(let [parsed-response (->> (:body response)
 (.parse js/JSON)
 (map #(js->clj % :keywordize-keys true))
 (map #(update-in % [:datum] (fn [dstr] (js/Date. dstr)))))] ...)


#(update-in % [:datum] js/Date.) might work, it doesnt look to bad to me as is. You could make the inner anon a named fn (defn parse-date [dstr] (js/Date. dstr))


you can also have only one map, and thread the functions together in the map fn:

(->> ...
    (map #(-> %
              (js->clj :keywordize-keys true)
              (update :datum (fn [s] (js/Date. s))))


can you use the multiline code block? It's three backticks, code, then three backticks to close it


Also I have the following nooby-problem: the code uses re-frame, which pulls in reagent which pulls in hiccup - so I assumed I should be able to require hiccup in the repl, but "no such namespace, could not locate", and indeed, finding and grepping on the project were quite pointless

Ahmed Hassan14:07:40

Hiccup is Clojure library.


@d.eltzner reagent doesn’t use the hiccup library, but instead implements it’s own parser for hiccup-like forms


hey guys


how is it going?


is there a way to make use of websockets with datomic?


Datomic Cloud


probably a better question for #datomic but AFAIK no


If some owner of a small startup asked you to develop a Clojure app for demo purposes, would you do it ?


Demo to show to potential clients

Sam Ferrell21:07:19

am I being paid by this startup owner to create said demo


No. not for the demo, maybe after the potential client signs a contract and gets his deliverables

Pick Feky21:07:38

maybe prototype with partnership contract before making it.


If an app is written in Python and I want to deploy said app to Heroku, do I need a Python runtime or can I opt for a Clojure runtime ?


I don't know any ways that a Clojure runtime will be able to do much with Python source code, nor compiled .pyc files, unless you have a very special Clojure or Java library that does something useful with them.


Someone has done work recently to make calls out from a JVM into a Python runtime, in order to take advantage of more Python libraries from a Clojure program, but it is pretty new stuff, and I don't know of its limitations. I am pretty sure it requires both appropriate Clojure and Python installations on the machine where it runs.

Ville Vuorinen22:07:21

guys. Whats wrong with this?


@ville What error do you get?

Ville Vuorinen22:07:27

Caused by: java.lang.ClassNotFoundException:

Ville Vuorinen22:07:54

do I need some libs or something


How are you running that code?


And that code is in src/test/core.clj ?

Ville Vuorinen22:07:05

and I added to project.clj :main test.core)


Compare your project.clj to this

(! 619)-> cat project.clj 
(defproject test "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url ""
  :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
            :url ""}
  :dependencies [[org.clojure/clojure "1.10.0"]]
  :main test.core
  :target-path "target/%s"
  :profiles {:uberjar {:aot :all}})

Mon Jul 01 15:14:09
(! 620)-> cat src/test/core.clj 
(ns test.core
  (:require [ :as io]))

(defn -main
  "I don't do a whole lot ... yet."
  [& args]
  (println "Hello, World!"))

Mon Jul 01 15:14:17
(! 621)-> lein run
Hello, World!

Mon Jul 01 15:14:24
(! 622)-> 


(that was just auto-generated with lein new app test -- and then I edited project.clj to have the exact same :main as you said and core.clj to remove the (:gen-class) and add the (:require ,,,) you had)


Just noticed that the first line (ns test.core) has a right paren that ends the ns form. You should remove that, and put the right paren that ends the ns form later.

👍 4

You already have a right paren at the end of your second line that will match the (ns if you delete the one at the end of your first line.


Oh, good catch!


So Clojure was reading it as

(ns test.core) ; complete and valid

(:require [ :as io]) ; tries to resolve  as a symbol and fails


The parentheses (almost) become invisible after a while, so we often don't even check them, without an editor to help us.


I think the creator of magit made a package that makes them actually invisible


And with that indentation, I didn't notice things don't match.


@ville What editor are you using? You might want to add something that tracks parens and indentation/structure -- something like parinfer.

Ville Vuorinen22:07:29

I used vscode with clojure plugin

Ville Vuorinen22:07:01

I’m not sure if my repl integration works as intended.


I'd recommend Calva if you're using VS Code. There's also a #calva-dev channel if you need help with it.

calva 8
Ville Vuorinen22:07:15

it works now, thanks guys.

calva 4