This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-08
Channels
- # atlanta-clojurians (1)
- # beginners (116)
- # cider (70)
- # cljs-dev (11)
- # cljsrn (2)
- # clojure (218)
- # clojure-italy (7)
- # clojure-nl (14)
- # clojure-nlp (11)
- # clojure-spec (8)
- # clojure-uk (113)
- # clojurescript (86)
- # core-async (14)
- # cursive (24)
- # datomic (64)
- # duct (1)
- # emacs (3)
- # fulcro (20)
- # graphql (10)
- # jobs-rus (1)
- # london-clojurians (1)
- # luminus (1)
- # nyc (1)
- # off-topic (24)
- # onyx (1)
- # parinfer (1)
- # pedestal (14)
- # portkey (11)
- # re-frame (36)
- # reagent (9)
- # reitit (5)
- # ring (1)
- # shadow-cljs (197)
- # spacemacs (21)
- # specter (22)
- # sql (15)
- # tools-deps (5)
I do have to say... the people helping out in here for us Clojure newbs are refreshing. Not a judgmental comment anywhere that I've seen, and everyone has been so patient and willing to walk beginners through questions. It is a stark contrast from what I've been used to where asking a question could get your head ripped off... (for example.. the Arch community is notorious for this... at least from what I've seen..).... anyway... kudos to the more experienced Clojure devs in here!! š
I got banned from arch irc channel before even saying anything :rolling_on_the_floor_laughing:
haha.. doesn't surprise me. I've been running arch for about 4 years now... and have never even tried to interact with their community. Great distro (imo)... but yeah... not even worth trying to be a part of the community.
@ryan.russell011 The Clojure community has always had the guidance to be polite, respectful, and welcoming ā that comes down from Rich Hickey himself, as well as reinforced by all the Cognitect (formerly Relevance) and Clojure/core folks. The conferences have had a Code of Conduct for several years ā and this Slack also has a Code of Conduct ā so thereās a culture of treating people decently. And we also deliberately set up a separate #beginners channel here for folks new to Clojure and those folks who opt-in to help them (itās why thereās nearly 13K people in #clojure and only 4.5K here). Thereās also a #programming-beginners channel for folks who are new to programming as a whole.
Besides, how can we take over the world if we donāt encourage more people to use Clojure? šŗļø
How many of you started with Clojure (or other functional-first lang) after feeling burnt-out on imperative? :thinking_face:
I actually got some Haskell experience first. After that, when I went back to Java, I noticed Java felt clunky and I actually noticed how verbose it was. I still feel like it is a good language, but it has its purpose and I felt like most the time it just wasn't needed for most the things I was doing. I then started looking into Scala, but it also felt too Java-like... Clojure has a simple elegant-ness that I am very much enjoying and I am hoping to one day be proficient with it lol.. and hopefully be able to contribute to this channel as a person that can answer questions!
My arc is a bit unusual I think⦠I did some Lisp and other FP stuff at university but my professional career was assembler, COBOL, C, C++, Java, ColdFusion(!), Groovy, Scala, and finally Clojure (starting in 2010). So it was more returning to my roots. But, yeah, I was pretty tired of OOP and dealing with the boilerplate associated with that sort of approach.
Question: how do you require
relative namespaces?
āProgramming Clojureā goes through first imports and mentions
> If you see the first 10 Fibonacci numbers as listed here, you have successfully installed the book samples.
But doesnāt mention anything about how to install them..
"install" is a weird term for namespaces - clojure looks up code that's required via the classpath
either it's in a jar which is on CP, or there's a directory on the CP with your code in a nested folder relative to the namespace definition
it's the places a jvm looks for things, a start-time parameter
if you use leiningen, it's leiningen's job to set classpath for you
in the repl, (System/getProperty "java.class.path")
it can be set from command line and not just env though, use getProperty
but if you are using a tool, it manages that for you
its config decides where source files should be
to get more specific I need to know more about your toolchain - leiningen project, boot? raw command line calling java?
OK, the default with lein is for source to be under a src
directory
foo.bar ns would be in src/foo/bar.clj
if lein starts clojure, that's where it wants your source
regardless of repl, run, or build
but there's a config in project.clj that can be modified
Hi guys, As you can imagine, I am a beginner. I am trying to take up Clojure. Managed to convince my boss to let me work on a web service + frontend in Clj/Cljs (Compojure, re-frame). It is a small project and I haven't messed up much so far. I am not a hugely talented programmer like many people here so some of the stuff I mess up because I don't have good understanding. I am just an average programmer (So, you will never find me at Google or Facebook.) I would like to get engaged with any open source project that can use some man hours. Testing, documenting, it doesn't matter. Can you suggest a project been done by decent human beings (Not 200 IQ assholes) which can use some help from a beginner like me? I can probably put in five or six hours a week, and I would like to contribute in any way I can. I think I would learn better and faster that way too.
one that immediately comes to mind is the app that displays the logs for this Slack: https://github.com/clojureverse/clojurians-log-app
http://clojure.org is always looking for help as well https://github.com/clojure/clojure-site
Okay, thanks a lot! Iāve been literally playing with cd
ing for 30 minutes trying to figure out how to import those files š
@kyselyradek yes, it works just like a path in your shell - it controls which places you get code from
one advantage to that method of doing things is it means you can use code that is inside a zip file (a jar is a zip with a special set of contents), or even directly from a URL
and it won't want to load things just because they are in the current directory (which I guess is a kind of security feature)
quick question... is the caret before Currency
doing actual type checking? or is just metadata to describe what currency
should be (without actually type checking)?
(defrecord Currency [divisor sym desc])
(defrecord Money [amount ^Currency currency]
type hints are not type checks
they are an assistance to the compiler
with records they are not needed
I think he is just saying ordinarily they aren't needed... which doesn't mean you can't have them
the compiler doesn't throw errors for nonsense type hints in most cases, and I guess there might be a case where the compiler could make better numeric code if it knows something about what's in Currency...
I found this somewhat helpful: https://kotka.de/blog/2012/06/Did_you_know_IX.html
and this: https://www.quora.com/When-should-I-use-type-hinting-to-make-Clojure-statically-typed (don't let the title mislead you... the first response clarifies a poorly written question here)
so.. here is the whole record from the book
(defrecord Money [amount ^Currency currency]
java.lang.Comparable
(compareTo [m1 m2]
(validate-same-currency m1 m2)
(compare (:amount m1) (:amount m2))))
I am assuming the type hint is used here because of the interop with java.lang.Comparable
@noisesmith but is that type hint telling the compiler what's in Currency?
well that code isn't even using currency so there's not enough there to really say - the definition of Currency is what would tell it what's expected to be in there
well he posted Money before too and that was empty
so...
I'm assuming clojure applied is building up to something interesting where there's a point to the type hint, I'd have to double check it's been ages and there's parts I only skimmed
obviously there is more... I was just curious as the the functionality of the ^
lol... the actual code is pg 8 in the Clojure Applied book
just so you know, this falls under the metadata syntaxes, see here: https://clojure.org/reference/metadata
@noisesmith so in general you don't need type hints for defrecords because the clojure compiler already knows about its methods?
right, and the way defrecords and protocol methods dispatch it doesn't need the same kind of expensive reflection it needs to use on classes and interface methods from native java
Is it necessary to clear ~/.m2/
old (deprecated) dependencies? And How ?
you can safely delete anything in m2 as long as you only install by normal methods
it's a cache, you'll just need to wait for the stuff to download again
if you use mvn or lein etc. to install something local by hand, it will be missing until you do that again, for obvious reasons
@noisesmith I see, thanks
I don't know of a way to figure out which versions your projects use or not, but deleting the whole thing is a thing people do
@duminda you can use :rename to give update a name that doesn't clash with clojure
or use a db library that has been updated since the clojure.core/update function came out :P
@noisesmith: "or use a db library that has been updated since the clojure.core/update function came out :P" Any suggestion?
I am learning about providing support for inserting Clojure maps into JSON columns in a postgres db. An article explain that, its as easy as extending a protocol. It provides an example
(extend-protocol jdbc/ISQLValue
clojure.lang.IPersistentMap
(sql-value [value]
(doto (PGobject.)
(.setType "json")
(.setValue (json/write-str value)))))
I have a few question that I am going to try and articulate.@duminda honeysql and hugsql were both kept up to date last I checked - at least more active than korma
The protocol is implemented by someone and in that example listed, it is being called by the JDBC driver?
clojure.java.JDBC is invoking that protocol method on its argument
by extending that method to map, that tells clojure.java.jdbc what to do when it sees a map
1. Unhandled org.sqlite.SQLiteException
[SQLITE_ERROR] SQL error or missing database (incomplete input)
Why it report missing database?
incomplete input = SQL error methinks
is there a reason your query vector is 2 strings instead of one?
I think you need to mention a database in the configuration [db] and that database must be already created ... here is sample configuration (def mysql-db {:dbtype "mysql" :dbname "clojure_test" :user "clojure_test" :password "clojure_test"})
maybe (sql/query ["" ""']) is happy with 2 strings or however-many, after i have read the docs it seems like that would work. check out: https://en.wikibooks.org/wiki/Clojure_Programming/Examples/JDBC_Examples
Is there a way to undo evaluation of all the forms in a file? Sort of like un-intern defs and stuff
@ackerleytng You can (remove-ns (.getName *ns*))
Oh nice, thanks! And then restart for anything in that namespace?
nice. thanks!
Without restarting the repl?
@ackerleytng You can do this, maybe this is what youāre looking for? (require :reload '[my.thing :as thing])
Itās not quite what you asked for, and it sometimes leaves things hanging around that you want to get rid of, but itās useful in a lot of cases.
Thereās also https://github.com/clojure/tools.namespace but I havenāt used it personally.
I'm not sure why but c.t.n.r/refresh tends to break things in our project but I've never been able to figure out why
:error-while-loading c.b.c-m-a-test
#error {
:cause "namespace 'c.b.c-m-a' not found"
:via
[{:type clojure.lang.Compiler$CompilerException
:message "java.lang.Exception: namespace 'c.b.c-m-a' not found, compiling:(c/b/c_m_a_test.clj:1:1)"
:at [clojure.core$throw_if invokeStatic "core.clj" 5807]}
{:type java.lang.Exception
:message "namespace 'c.b.c-m-a' not found"
:at [clojure.core$apply invokeStatic "core.clj" 659]}]
:trace
[[clojure.core$apply invokeStatic "core.clj" 659]
[clojure.core$load_libs invokeStatic "core.clj" 5925]
seems like it might have something you could use, though.
hmm i was looking for a workflow tip sort of, to avoid having to restart the repl
In that case (require :reload '[some.ns :as s])
might be your best bet. It reloads the namespace and redefines any functions you have changed in the underlying source (but not anything defined with defonce
, and I think also not any protocol handlers). That's not quite what you originally asked for, so maybe that's not what you wanted, but that was as close as I could come, and I hope it's useful.
Is there a test coverage tool that supports boot? I can only find Cloverage, which apparently only supports lein
I couldn't find one when I looked, would like to help out with that project sometime. Thinking of https://github.com/cloverage/cloverage/issues/211 and boot support would be nice too
Many Leiningen plugins can be run directly from Boot, and creating a boot-*
version of most lein-*
plugins isn't too hard... take a look at http://corfield.org/blog/2017/11/17/boot-localrepo/ for my path through that with lein-localrepo
...
And since the blog post doesn't link to the repo https://github.com/seancorfield/boot-localrepo