This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-27
Channels
- # bangalore-clj (1)
- # beginners (187)
- # braveandtrue (52)
- # calva (7)
- # cider (17)
- # cljs-dev (14)
- # clojure (27)
- # clojure-austin (4)
- # clojure-dev (11)
- # clojure-finland (4)
- # clojure-italy (5)
- # clojure-nl (1)
- # clojure-russia (22)
- # clojure-spec (9)
- # clojure-uk (27)
- # clojurescript (91)
- # datomic (40)
- # duct (4)
- # emacs (14)
- # figwheel-main (36)
- # fulcro (11)
- # hoplon (10)
- # immutant (9)
- # instaparse (4)
- # java (1)
- # jobs (2)
- # off-topic (28)
- # pedestal (1)
- # reagent (15)
- # reitit (7)
- # remote-jobs (6)
- # ring-swagger (3)
- # shadow-cljs (28)
- # slack-help (1)
- # spacemacs (4)
- # specter (1)
- # sql (3)
- # testing (3)
- # tools-deps (24)
Hi @seancorfield! I've used and really liked NightCode in the past, but now it involves mandatory parinfer, which is a problem. @sekao's Lightmod is also super exciting for me, but same problem. In this semester's case it'll be people with some programming experience, but my ideal environment would also work for total beginners. And I don't want to count on any experience with fancy setup or sysadmin stuff, etc.
Interesting. What's the problem with parinfer? It seems like one of the better solutions to the paren-balancing/indenting problem.
@seancorfield Parinfer adds and deletes brackets where users haven't typed or intended to delete them, which can be super confusing to beginners (and even non-beginners like me -- I can't work in it at all). Typing skills are maybe the one solid foundation for newcomers in a bewildering new world, and when you mess with that in baffling ways, and make it so users can't even type and have text behave as it does in every other editor, it can pull the rug out from under them and undermine all confidence. I think the best solution to the paren-balancing/indenting problem is one we've had for decades in many lisp environments: syntax-aware re-indentation upon command. Rainbow parens etc are also nice. But everything that messes with basic typing in unexpected ways creates more problems than it solves. This is true for beginners in my experience (I've been teaching beginners lisp for over 25 years) and also for anyone, like me, who often types/copies/pastes bits of code out of order, which paredit makes impossible and parinfer makes into a circus.
Have you tried atom/protorepl? There's some special sauce in its implementation. Never seems to get in the way. I just tried the vscode parinfer one and it just get's in my way. Be sure to look for the buttery smooth atom one before giving up on parinfer
I'm so used to editors that auto-complete (
, [
, {
, etc that I guess it seems natural to me... But I can also see how an editor inserting characters is "magic" for beginners. No one seems to want to solve the editor problem without auto-completion tho'...
then its on the command line so you can leave cursive/emacs/calva for self exploration and another day?
how can i call from the clientside to the server side for information, like, a database query or something
@seancorfield, I agree that auto-completion of (
, [
, {
, etc. is not that big of a deal. But with parinfer, you add or delete a space and brackets appear or disappear, possibly on different lines, changing the structure of your code. This "messes with typing" in a more extreme and unexpected way than autocompletion, which I agree is pretty easy to understand and deal with. For me and my students (some of whom used Nightcode last semester because of installation issues with other tools) parinfer often produces bizarre and disconcerting results.
@seancorfield, on "No one seems to want to solve the editor problem without auto-completion tho'..." -- I think it is solved admirably well by every system that provides syntax-aware re-indentation, of which there are many. Some that I've used in Clojure are Gorilla REPL and Counterclockwise, and Clooj (long dead, I think) and older versions of Nightcode, etc. The gap right now is a well-maintained, current system that provides this solution along with beginner-friendly installation. From my recent surveys Gorilla REPL comes the closest, but I don't know if there's something new. I see some Jupyter-based approaches that look great in terms of installation and ease of use, but unless I'm missing it they provide no syntax-aware indentation.
Thanks @dpsutton but I do need something that allows file editing. The leap to Emacs is a leap too far in terms of installation, setup, and learning curve. I follow and occasionally try Cursive, but again it's a big leap for beginners and is overkill with respect to our needs (which are pretty much just editing with syntax-aware re-indentation and a REPL). I don't remember having looked into calva and I don't know much about Visual Studio... Thanks for that lead, which I'll check out.
@its.ramzi via http
@its.ramzi I think you should slow down and learn some fundamentals
I've written an app before, where Ajax called JSP, and JSP called Java, and Java with Hibernate wrote to Postgres
So without the JSP layer here I'm confused about how an Ajax call is supposed to reach Clojure.
JSP is just part of the server. Same as Clojure.
Well, using "ajax" is a bit of an umbrella term.
The client code in the browser makes an HTTP request to a server and the server takes that HTTP request and processes it and sends back an HTTP response, which the client then deals with.
And that's the same regardless of client or server technology.
how can i go from a fresh Reagent checkout, to having an input cause a server side print out?
Reagent is purely cljs / client side so your question doesn't really make sense to me.
But the server side is not Reagent.
@its.ramzi that server is just for development
Sure, you can use Jetty in production.
But I think you need to be clear about how HTTP request/response works in the big picture.
There's nothing different about cljs/clj development compared to, say, JS / JSP / Java development in that respect.
Hi, I am trying to copy content to clipboard when a list item is clicked. I found a solution in javascript, which i tried to convert to clojurescript and failed.
var copyText = document.getElementById("myInput");
/* Select the text field */
copyText.select();
/* Copy the text inside the text field */
document.execCommand("Copy");
when i try to do something similar in clojurescipt it fails
app:emoji-search-clojurescript.core=> (.getElementById js/document "emoji-title-100")
#object[HTMLParagraphElement [object HTMLParagraphElement]]
app:emoji-search-clojurescript.core=> (.select (.getElementById js/document "emoji-title-100"))
#object[TypeError TypeError: document.getElementById(...).select is not a function]
How do i select the value and then copy it to clipboard.@seancorfield can you help me go from a fresh Reagent checkout to getting a server side print out?
app:emoji-search-clojurescript.core=> (js/select (.getElementById js/document "emoji-title-100"))
#object[ReferenceError ReferenceError: select is not defined]
@its.ramzi I have no idea how to explain it to you beyond what I've already said.
I think you might be better off starting with a simple server side console app and ignoring the whole client side stuff for now.
Learn how to write a simple Clojure console program that interacts with a database. Then learn how to extend that to a Ring web app that produces HTML pages on the server. Then look at how to connect a Reagent front end to a REST API on the back end.
@prabhath6 Maybe ask in #clojurescript since you're dealing with specifically front end stuff?
I have many JDKs installed, and my default currently is JDK 11ea...I installed leiningen using homebrew, and when I try to run lein repl
, I get the following error messahe
Exception in thread "Thread-1" java.io.IOException: Cannot run program "/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home" (in directory "<elided>/testproj"): error=13, Permission denied at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128) at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
I tried changing the JDK to 1.8 (of course, that didn't work either), and I tried running lein with sudo, and no luck
I had also installed the clojure
executable using homebrew, and running that starts up a REPL without any problem
$ /usr/libexec/java_home -V Matching Java Virtual Machines (3): 11, x86_64: "Java SE 11-ea" /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home 9, x86_64: "Java SE 9-ea" /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home 1.8.0_112, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home
So these are installed in directories owned by root, of course (not sure why this would be a problem though):
$ ls -ld /Library/Java/JavaVirtualMachines/ drwxr-xr-x 5 root wheel 160 Aug 27 11:16 /Library/Java/JavaVirtualMachines/
@timmyjose What do you get when you run java -version
?
I'm on 1.8, I heard (correct me if I'm wrong) that 1.9 and later aren't seamlessly working yet.
@timmyjose I guess the easiest path forward would be to set java .18 as the default from the Java Control Panel?
If that doesn't work I'd suggest trying this:
https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L287-L289
in your ~/.lein/profiles.clj
@its.ramzi Lots of web frameworks in other languages make it all work as by magic and don't really require you to understand what really happens. Clojure is a bit different in that its typical set of libraries for web development really just offer a very thin layer of Clojure data structures on top of HTTP concepts. Which means you really need to understand how HTTP works to be successful there; that's a bit of up-front work, but knowing HTTP will serve you well in any kind of web project.
@tap I have tried with both 1.8 and 9 and 11ea ... the problem seems to be a weird permission problem for lein
when it tries to spawn a process
@gaverhae I set the default to 1.8/9/11ea and tried it just in case, but no luck... this seems to be some weird permission error when lein
tries to spawn a process ... maybe some other folks on macOS have seen this issue before? I tried reinstalling lein as well, but no dice
Okay, never mind... after rebooting the machine, it appears to be working now... no bloody idea why! 😛
And one more thing - I joined a company where the main language used is Clojure. As such, I wanted to start learning it on my own before joining. I have a decade of (mostly) Java under my belt, and have some experience with Common Lisp. As such, could anyone recommend a good book/resource to learn it today? A few years back, I had played around a bit with Clojure, and I didn't particularly like Emerick or Holloway's style
@timmyjose I highly recommend The Joy of Clojure, covers most of what you need to know including some more advanced topics
@its.ramzi let folks know if you get stuck on any of these: http://clojure-doc.org/articles/tutorials/basic_web_development.html https://devcenter.heroku.com/articles/clojure-web-application https://medium.com/@divyum/building-a-simple-http-server-in-clojure-b8c80fa5035e https://practicalli.github.io/clojure-webapps/ https://github.com/ring-clojure/ring/wiki/Getting-Started https://github.com/magomimmo/modern-cljs
is there a way to express infinity? specifically, i'm looking for a more declarative way to express (or (nil? prev-best) (< (get cur "executionOrder") (get prev-best "executionOrder")))
as in the value?
user=> ##Inf
##Inf
see also ##-Inf
user=> (= (/ 1.0 0.0) ##Inf)
true
I usually use Long/MAX_VALUE (which is definitely not infinity) because I try to avoid floating point
@noisesmith thank you. not sure why i couldn't find that in the docs 🙂
One reason is that it wasn't in many of the docs on Monday. It is now documented in a few places, such as:
http://jafingerhut.github.io/cheatsheet/clojuredocs/cheatsheet-tiptip-cdocs-summary.html
if you create an infinity in the repl, that reader literal is what it shows you
ah - looks like it was introduced in 1.9?
does this look incomplete to anyone else? https://github.com/prabhasp/slickgrid-cljs
I’m having some trouble testing routes in an app that uses compojure-api. One of the handlers is asynchronous and returns a channel. The server runs fine, but when running tests the async handler produces the following exception:
ERROR No implementation of method: :render of protocol: #'compojure.response/Renderable found for class: clojure.core.async.impl.channels.ManyToManyChannel
java.lang.IllegalArgumentException: No implementation of method: :render of protocol: #'compojure.response/Renderable found for class: clojure.core.async.impl.channels.ManyToManyChannel
Since i’m using lein-ring to run the server and build the uberjar and it works fine under those conditions, I assume I’ve missed some bit of configuration in the tests. If anyone could point me in the direction of some docs (or a solution!) it’d be much appreciated. I can’t find anything that looks relevant on the repos for compojure-api or ring
there is a source file somewhere that extends the Renderable protocol to a channel, and I bet that source file is loaded in the machinery that lein-ring generates, but not otherwise, so when run outside of lein ring (when testing) you get that error. so if you look through the compojure sources and find that file, and make sure to require that namespace in your tests, I suspect it will work
@its.ramzi Not sure. You should familiarize yourself with those too, though, regardless. As having a good understanding of the many options available to you for backend dev is important.
This example, based on luminus, might be closer to what you're looking for though https://github.com/yogthos/pg-feed-demo
@john, that looks to be just what I need, but all of the installation instructions are seeming daunting right now. I wish I had some other devs to task with this, but they're on other things. I need to talk to the manager to pull resources, but he hasn't been in in weeks.
In the meanwhile, I am looking into Slickgrid, and thinking about how Slickgrid will play with Clojurescript.
I don't normally advertise services for cognitect or any other companies for that matter, but if you've already landed the contract, you have a budget and you're in a time crunch, I'd definitely recommend reaching out to cognitect to help get you up and running. Or maybe solicit some support from an independent contractor in #remote-jobs. Most Clojurists get by fine learning from here on slack and online resources. But I'm not sure if that works with your timeline.
That can either be really easier or really hard, depending on what aspects you're familiar with. Certain aspects of a migration like that would probably be difficult for most people.
Like, I don't know rails and I'd be way slower to figure out how to migrate a rails system over to a ring/clojure one
@pablore I do not know, but I would recommend asking in the #clojure or maybe even #clojure-dev channel, as there may be others watching there who know.
@andy.fingerhut ok, thanks
I would guess that 'feeding' a PersistentQueue into a transducer should present no problem, but whether you can feed the output of the transducer into a PersistentQueue in such a way that it is created, without also creating an intermediate sequence, may also be something you wanted an answer to.
@john it says The first step is to create a schema for the app, and set the connection URL in the profiles.clj. Where is profiles.clj? If I have to make it, where do I put it?
fwiw it looks like the options for getting around the Renderable error i was receiving are to provide an extension of the compojure.response.Renderable
protocol for testing purposes, or to call the handler with respond
and raise
callbacks in the test code. Compojure-api provides implementations of compojure.response.Sendable
for channels and aleph deferreds, but does not provide implementations for Renderable (which makes sense i think since it looks like Sendable is supposed to be for async while Renderable is for sync…). When using lein-ring you can tell the plugin to treat the handler as async which has it start a server with the :async?
option set to true and I assume that makes it pass all requests with respond
and raise
, which makes compojure use the Sendable protocol, which is why the server ran fine while my test that used the handler with only a request argument (thus triggering the Renderable protocol) failed.
@its.ramzi Hmm. Maybe you learn better with videos. Try this YT playlist: https://www.youtube.com/watch?v=uuuTvfommgU&list=PLa41JFHSDvx3e09-g-X3pjRuaHhDUiKDf
You need a basic baseline of understanding (what's a project.clj file?) to even start with some of these tutorials. And hearing folks talk about it in videos, socially, can sometimes shed a lot more anecdotal light on the subject that you'd get by hunting through texts.
This looks hopeful. https://github.com/karimarttila/clojure/tree/master/clj-ring-cljs-reagent-demo
lein new clj-ring-cljs-reagent-demo asdf Failed to resolve version for clj-ring-cljs-reagent-demo:lein-template:jar:RELEASE: Could not find metadata clj-ring-cljs-reagent-demo:lein-template/maven-metadata.xml in local (/home/dev-user/.m2/repository)
@clarkenciel common trick on ring-cps testing is to create the respond
and raise
as (promise)
and deref with timeout.
@its.ramzi lein new
does not search github
It searches clojars. clj-ring-cljs-reagent-demo is not on clojars. You have to git clone ...
that repo to work with its example material
Or download the zip directly: https://github.com/karimarttila/clojure/archive/master.zip
this isn't a template. it's a guide. https://github.com/karimarttila/clojure/tree/master/clj-ring-cljs-reagent-demo/simple-frontend#creating-the-project
it uses a template. @its.ramzi just read through it. It explains how to get started
When I try running SIMPLESERVER_CONFIG_FILE=resources/simpleserver.properties lein with-profile +log-dev ring server-headless
it says Error encountered performing task 'ring' with profile(s): 'base,system,user,provided,dev,log-dev' Task not found
in leiningen, new tasks are created by plugins
so to run lein ring ...
you need the lein-ring
plugin (or something else that provides it) in your project.clj
@its.ramzi which is in the project.clj from that guide: https://github.com/karimarttila/clojure/blob/master/clj-ring-cljs-reagent-demo/simple-server/project.clj#L31
I had a joda-time object and it would crash during encoding. So I had to add an encoder to convert that joda-time to a string. But now I got rid of the encoder and it still works.
did you leave your repl or process running? the encoders are a global stateful thing
I quit my app and restarted it but I have a feeling it deals with something like that
unless it's a question of compiled stuff that lein clean
would take care of, that should have reset the state of the encoders
i think there's a namespace in that if included anywhere side effects things like this
this ns extends clj-time joda instants to work as clojure instants https://github.com/clj-time/clj-time/blob/master/src/clj_time/instant.clj
and I wouldn't be surprised if cheshire could work with that
yeah, I bet that's what's doing it
Previously cheshire was going through the map and when it saw a jodatime it yelled and said it didn't know what to do with it. So I added the encoder and everything went dandy. So whats happening now that I got rid of the encoder?
I have a function here (fn [{:strs [variable operator value]}] (operator variable value))
that i'm swapping into an existing list ("to-be-replaced" {"variable" 1 "operator" + "value" 0})
when i quote
the function, it works
when i syntax quote
the function, i get a huge error about the call to clojure.core/fn
not conforming to spec
the binding construct here being the map deconstruction?
fn is a binding construct in that it establishes a binding of the argument names to the arguments in the scope of the body
so when you syntax quote you are not getting (fn [{:strs [variable operator value]}] (operator variable value))
but instead you are getting (clojure.core/fn [{:strs [whatever/variable whatever/operator whatever/value]}] (whatever/operator whatever/variable value))
where the namespace whatever is whatever namespace *ns*
is bound to when the syntax quoted form is read by the reader
i see.
When should I prefer "evaluating selected forms" (seen in editor plugins) vs "instarepl"/"eval whole file on save"? (figwheel/shadow-cljs)
thank you @hiredman
since '
works, maybe that's all i need
nice, that did it!
~'foo
introduces the possibility of hygiene problems, so if possible it's good to use foo#
instead
but I guess that doesn't help in a keys destructure