This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-20
Channels
- # aleph (2)
- # announcements (4)
- # aws (3)
- # beginners (141)
- # calva (9)
- # clj-kondo (1)
- # clojure (3)
- # clojure-boston (2)
- # clojure-brasil (1)
- # clojure-houston (1)
- # clojure-italy (4)
- # clojuredesign-podcast (1)
- # clojurescript (22)
- # cursive (2)
- # data-science (1)
- # emacs (26)
- # fulcro (22)
- # juxt (1)
- # off-topic (28)
- # onyx (3)
- # pedestal (4)
- # reagent (10)
- # reitit (6)
- # shadow-cljs (9)
- # spacemacs (2)
- # tools-deps (29)
- # yada (1)
how do i import a library. im trying to import hiccup to use the html function, but no matter what i do it doesnt see the function
@its.ramzi You have Hiccup as a dependency in your project? You restarted the REPL after you added that dependency? How are you requiring the Hiccup namespace?
(ns betterdiscourse.core (:require [reagent.core :as reagent] [clojure.browser.dom :as dom] [hiccup.core] ))
And what error exactly are you seeing?
No such namespace: hiccup.core, could not locate hiccup/core.cljs, hiccup/core.cljc, or JavaScript source providing "hiccup.core" in file <cljs repl>
You don't need to put Hiccup anywhere if you put the dependency in correctly.
:dependencies [[org.clojure/clojure "1.8.0"] [org.clojure/clojurescript "1.9.946"] [reagent "0.7.0"] [jayq "2.5.5"] [hiccup "1.0.5"] ]
seanc@DESKTOP-QU2UJ1N:~/clojure$ clj -Sdeps '{:deps {hiccup {:mvn/version "RELEASE"}}}'
Downloading: hiccup/hiccup/maven-metadata.xml from
Downloading: hiccup/hiccup/2.0.0-alpha2/hiccup-2.0.0-alpha2.pom from
Downloading: hiccup/hiccup/2.0.0-alpha2/hiccup-2.0.0-alpha2.jar from
Clojure 1.10.0
user=> (require '[hiccup.core :as h])
nil
user=>
No such namespace: hiccup.core, could not locate hiccup/core.cljs, hiccup/core.cljc, or JavaScript source providing "hiccup.core" at line 1 <cljs repl> 1 (require '[hiccup.core :as h]) ^---
I know nothing about Figwheel. If you're using lein
, you need to start a new lein repl
after you added the dependency.
seanc@DESKTOP-QU2UJ1N:~/clojure$ lein update-in :dependencies conj '[hiccup "RELEASE"]' -- repl
nREPL server started on port 61574 on host 127.0.0.1 -
WARNING: cat already refers to: #'clojure.core/cat in namespace: net.cgrand.regex, being replaced by: #'net.cgrand.regex/cat
REPL-y 0.3.7, nREPL
Clojure 1.8.0
OpenJDK 64-Bit Server VM 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=> (require '[hiccup.core :as h])
nil
user=>
If that works and your project doesn't, then either you didn't specify the dependency correctly or you didn't restart your repl.
C:\Users\Ramzi\Desktop\betterdiscourse>lein update-in :dependencies conj '[hiccup "RELEASE"]' -- repl java.lang.RuntimeException: EOF while reading at clojure.lang.Util.runtimeException (Util.java:221) clojure.lang.LispReader.readDelimitedList (LispReader.java:1204) clojure.lang.LispReader$VectorReader.invoke (LispReader.java:1150) clojure.lang.LispReader.read (LispReader.java:263) clojure.lang.LispReader.read (LispReader.java:200)
Windows... OK, so you're running into cmd
's weird quoting behavior...
Regardless, you have something wrong in your project.clj
and/or you're not restarting your REPL properly.
also - hiccup is a clj only dep afaik, it won't work in a figwheel cljs repl
I don't have lein
installed on this Windows machine to do the equivalent to the above -- but it would have the same result I showed.
there's no cljs code here, if you are using things via figwheel hiccup won't be available https://github.com/weavejester/hiccup/tree/master/src/hiccup - it's not a frontend dep
what are you trying to do? @noisesmith identified why hiccup won't be an available tool for you in cljs but there are plenty of options there for you
i want to, then, from a clean reagent template, get the hiccup library imported into my project, such that it is in the "java" layer of my reagent program, and that i can make an ajax call to it, to get values from the hiccup library residing in the "java" layer
regent does its own rendering, it doesn't use hiccup
but I'd start with making the thing work on the clj / jvm side, before trying to access it from the cljs / browser side
a variable is an abstract concept in cs, an atom is a mutable container
when you use def
that creates a var (which might be want you mean by variable)
an atom has extra rules for how it can be changed, that make it safer to use from multiple threads
vars are for mutating as you write new code, atoms are for mutating in your app via code
If you need Hiccup-like functionality in cljs, there's at least one lib: https://github.com/teropa/hiccups
ompiling build :dev to "resources/public/js/app.js" from ["src/cljs"]... Failed to compile build :dev from ["src/cljs"] in 0.566 seconds. ---- Could not Analyze src/cljs/betterdiscourse/core.cljs line:1 column:1 ---- Only :refer-clojure, :require, :require-macros, :use, :use-macros, and :import libspecs supported. Got [clojure.browser.dom :as dom] instead. at line 1 src\cljs\betterdiscourse\core.cljs 1 (ns betterdiscourse.core ^--- Only :refer-clojure, :require, :require-macros, :use, :use-macros, and :import libspecs supported. Got [clojure.browser.dom :as dom] instead. at line 1 src\cljs\betterdiscourse\core.cljs 2 (:require 3 [reagent.core :as reagent]) 4 [clojure.browser.dom :as dom] ---- Analysis Error : Please see src/cljs/betterdiscourse/core.cljs ----
(ns betterdiscourse.core (:require [reagent.core :as reagent]) [clojure.browser.dom :as dom] (:require-macros [hiccups.core :as hiccups :refer [html]]) (:require [hiccups.runtime :as hiccupsrt])) (hiccups/defhtml my-template [] [:div [:a {:href "https://github.com/weavejester/hiccup"} "Hiccup"]])
@its.ramzi line 3, the ) is too soon
after your last require, I don't know what's on line 6
oh yeah, multiple :require is bad
This is why it's important to use an editor setup that manages your parens for you...
the paren is balanced, it's just in the wrong position
(ns betterdiscourse.core
(:require [reagent.core :as reagent]
[clojure.browser.dom :as dom]
[hiccups.runtime :as hiccupsrt])
(:require-macros [hiccups.core :as hiccups :refer [html]]))
@noisesmith Right, but parinfer would fix the parens to match the indentation 🙂
oh man, I wasn't thinking of parinfer - I kind of block it out due to past trauma
one coworker who never indented things properly, and another that blindly checked in the way parinfer moved the parens
Parinfer is far and away the best choice for beginners in a lot of people's opinion 🙂 Because of exactly this.
Orly? OMG! Sorry 😞
hah - if everyone had used it, or no-one, it would have worked out
or if we had proper code review even...
@its.ramzi You had .runtime
and :refer
in your code.
I can get resizing working on one node, but not on multiple nodes. Can someone help me?
why clojurian
instead of clojurist
?
hi ppl, i need help with this: { “errors”: “(not (map? a-clojure.lang.PersistentVector))” }
usually with ring, the return value from a handler has to be a String (which becomes the body of the response), or a stream (which becomes the streaming body) or a hash-map (which should have a valid :status
field, and probably a :body
which can be string, stream etc.)
there's no ring conversion of a vector as far as I know
to return the string representation of clojure data you can use pr-str, clojure.data.json, or transit, for a few possibilities
but the stream itself is just going to end up being bytes
I created a simple api rest, where I only pass a value and this api should return it, however this does not happen.
This isn't directly a Clojure question, but I'm taking a series of online classes (How to Code - Simple & Complex Data) and they use Racket. Is this going to be a solid enough prerequisite to start diving into Clojure without being too lost?
I found this playlist about learning Clojure on YouTube: https://www.youtube.com/watch?v=9A9qsaZZefw&list=PLAC43CFB134E85266
I'm alright on finding learning materials, I'm just not sure if what I'm already taking is enough of a prerequisite or if it'd be better to go farther into functional programming before actually starting to learn Clojure.
@reecemcmillin https://www.youtube.com/watch?v=0if71HOyVjY this is a good video for Functional languages in general
Hey, I joined because the boot
website brought me here. I wanted to talk about boot a little bit from a beginners perspective, it sounds very interesting but most people seem to be using leiningen as it's more tried and tested?
For instance I was able to to type something like lein new figwheel <name-of-project> -- --reagent
and it was perfect. Does boot have something like this? Or is it a lot more manual and built for more experienced devs?
@ashley Hi and welcome! Leiningen has been around the longest and so it is much more popular than Boot -- it's lein
that you'll typically find in books and tutorials. Boot is certainly well-established and very powerful but it's just not as widely used.
Most of the templates out there for new projects are designed for Leiningen, but boot
does have a new
option and can generate new projects using Leiningen templates.
Thank you for welcoming me! I can see that. I've got the jist of using leiningen and was simply wondering if, lets say someone like you was to start a new project, would you use boot or lein? Is one more 'modern' than the other?
But if the template produces a Leiningen-based project (which I bet the figwheel
one does), then even if you generate it via boot/new
, it'll still be a Leiningen project.
ah okay!
well with me being a beginner and enjoying the look of figwheel and such, without a boot template for figwheel it'd be an inconvenience to my studies at this point I think!
I guess you could say I'm a sucker for boot's website, it looked nice and modern and something I should be excited about 🙂
To complicate matters, Cognitect have produced a new set of tooling for running Clojure programs https://clojure.org/guides/getting_started and a lot of people are starting to use that now -- and there's a new
task for that CLI tooling that also generates new projects from Leiningen (and Boot) templates.
If you use lein new app myapp
, you'll get a lein
project. If you use boot -d boot/new new -t app -n myapp
, you'll get a boot
project. If you do the equivalent with clj-new
, you'll get a CLI/`deps.edn` project. The built-in templates generate projects based on the tool itself. But there are a lot more Leiningen templates out there than Boot templates (and I don't know if there are any CLI templates yet).
this space seems pretty clouded then ><
At work, we started with Leiningen back in 2011 -- it was the only option -- but switched to Boot in 2015 and we were very happy with that (at first). Last year we switched everything over to the newer CLI/`deps.edn` tool chain.
I tend to steer new Clojure developers to Cognitect's CLI/`deps.edn` because that's the most "modern" approach and it's "simple" -- there's a lot less magic -- whereas Leiningen is very widely used and it is "easy". Boot is somewhere in the middle -- very powerful, still some magic, not as popular.
Im struggling to find much information about CLI/deps.edn from your link - is CLI/deps.edn
like an official clojure method of starting new projects?
the bottom of that page recommends lein or boot so?
It's "official" in the sense that it is produced and supported by the Clojure/core team (essentially, Cognitect).
lein
is going to be the easiest option when you are learning since it's the oldest and most widely used in tutorials/books. I think also learning the clj
/ deps.edn
tooling from Cognitect is important since more and more projects are going in that direction these days.
I can understand why purely because its the first one they encounter. To give some context, I come from C++ and Haskell backgrounds and I'm coming up to my 5th year of uni and getting my masters. I wanted to do my final year project in clojure as I feel like I could get more done in clojure than Haskell, and I just don't feel like C++
my uni doesn't teach functional programming (or git.. or linux..) so I wanted to give them a screw you and write a program they can't read haha
I did exactly this for my final!! hahah
The official docs for clj
/ deps.edn
sort of assume you're going to make a new project manually -- but there is https://github.com/seancorfield/clj-new (created from boot-new
, which in turn I created from lein-new
, so there's a lot of common code and concepts).
also I've been seeing more and more businesses interested in clojure, and as someone who enjoys Haskell and functional programming I wanted to learn clojure to. From what I've done I love it
ah wow!
Given your exposure to Haskell, you'll find the functional approach of Clojure easy to pick up. But the workflow will be very different -- no type system, no compile step. Clojure focuses on the REPL, not just as a command-line tool to try out code -- like most languages -- but as the core way to build your applications, interactively, with your editor connected, evaluating code as you go.
I've done some work already on Hackerrank, unfortunately that means that I haven't had the experience of setting up my own project though!
I love the language
@deleted-user Nice comparison -- the new CLI / deps.edn
is growing really fast!
I just want to do something with it. I actually tried to contribute to braid.chat, but I could only do a little bit ebcause of my limited knowledge of reagent and server-client apps
The cljs stuff is a whole 'nother ball of stuff to learn...
It looks exciting, I'm wondering why I haven't even heard of it yet though haha
My background was in C++ BTW 🙂
I didn't realize it was taught at uni much these days?
If you do decide to take CLI / deps.edn
for a spin, a lot of people are using a variant of https://github.com/seancorfield/dot-clojure/ for their ~/.clojure/deps.edn
file to get up and running quickly with a lot of tooling.
Well, I wouldn't count my uni as educational to be honest. I haven't done anything to do with networks over 5 years nor have we covered working with any gui libraries
im very disappointed with it
When I went through uni, we used Pascal to solve a lot of math problems, and we did a lot of comp sci theory. We didn't touch networks at all, nor GUI stuff. But that was a long time ago 😐
@seancorfield so if I put that in .clojure/deps.edn
that acts as a default file I can use when I start a new projecto r something?
Yup, once you have clj
installed per the http://clojure.org instructions (assuming you're on macOS or Linux?), replacing the default installed ~/.clojure/deps.edn
with the one from my repo gives you a nice jump start.
The only reason I feel annoyed as.. to be honest.. I don't know anything? I'm not lying when I say this, we didn't see a single lecturer type a line of code in our 4th year. They could have not been programmers and we wouldn't know as they just showed powerpoints
yeah I'm on arch 🙂
Ouch! At least most of our lecturers did programming stuff too.
I had an amazing lecturer in my first year! He kind of set me off on functional programming as I wanted something harder. But he stopped teaching so yeah 😞 I have him on whatsapp though haha! Anyway back to the topic at hand. I admit you're winning me over with clj, its so hard making a decision though! I know in the end I probably want to learn them all but I'm trying to decide which to learn first. Like I know lein is widely used, but I feel like if I work somewhere, the project will already be set up and I can handle that. I just want to learn one of the more modern ones like boot or clj for personal projects you know? Something that'll make life easier while also helping me bond with my tooling better. Build tools have always been a little difficult for me, I struggled with CMake a lot at first 😞
For me, the nice thing about clj
/ deps.edn
is that it's very simple and close to the metal. It fetches dependencies, it builds a classpath, it runs Clojure code. That's it. You can understand each part of what it is doing. Each tool for the CLI (https://github.com/clojure/tools.deps.alpha/wiki/Tools) tends to do just one job and also focuses on simplicity.
okay, and what about boot then? You said it's powerful, but does that also mean its difficult?
By contrast, lein
is easy because it hides a lot of complexity/machinery and it bundles a lot of tooling "out of the box".
Yeah, Boot is somewhere in the middle. I still really like it's approach -- tasks as functions -- and it has a very neat feature in "pods" so you can run multiple processes with their own dependencies in the same JVM.
I honestly am thinking of boot for now because it looks very well documented from what I've seen of it
I come from an era where learning the basics was considered critical before you learned much of the rest of it. There are arguments in favor of both approaches.
My only concern with starting off with Boot would be that it's rather niche compared to both lein
and clj
/ deps.edn
so it might be harder to get answers online if you run into problems (there's a #boot channel here tho' that's going to be a good place to ask questions).
I don't actually see the boot channel here though weirdly enough
Ah I had to click your link
thank you
It can be a bit hard to navigate around all the channels -- we have hundreds now -- and folks are only added to about half a dozen when they join.
There's a #leiningen channel (and #lein-figwheel too if you continue with figwheel
). Then there's #tools-deps for the CLI / deps.edn
stuff (since it's most based on the clojure.tools.deps
Contrib library).
I feel like for everything I want to learn right now I should try it with figwheel. When I worked on braid.chat figwheel was so nice
You can ask in #slack-help if you need assistance finding your way around the Clojurians space.
There are also #figwheel and #figwheel-main channels (sorry, I don't know which is appropriate for what sort of questions).
don't worry about it! Thank you for everything. I'll do some more research and have a look at some examples. Like I said though figwheel and reagent are what I'm aiming to work with right now so my first task will be looking into setting those up
It's nearly 11pm where you are? Europe?
the UK 🙂
Oh, I'm an ex-pat. Born and raised in Northern Ireland, moved to California 20 years ago.
I went to Surrey university.
So you may well want to join #clojure-uk -- they're a great bunch of folks who will be on your timezone!
would love to move to cali haha