Fork me on GitHub

@rplevy The dependency hell problem you mentioned was never solved in the Java world, where things get even hairier because uberjars are sometimes used as dependencies, and now you need to resort to class relocation.


@rplevy Thank God we are spared this since in Clojure our dependencies are non AOT, source-only.

👍 4

There's even a utility called Mr Anderson which will copy the source into your own namespaces to prevent version conflicts

👍 12

The Maven's shade plugin has more options to include/exclude dependencies than Boot/Leiningen.

👍 4

Which leads me to plug in the new build tool I released today: Meyvn.


It uses the Shade plugin.


Oh I saw that on Twitter. That name is gonna be confusing in speech


One idea: Having a standalone executable is cool. And it might be how I would actually use the tool day to day. But you could also have a pure clj -m meyvn.core deploy, for instance, for folks that don't want to mess around with the system's path.


ah, I see you can pretty much accomplish that under the hood


Also should add more information about what that plugin sends home


I looked into what info it sent home


It sends home the Group id.


It says that in the README, but I could publish the code.


The presentation video teaches you how to spell the name! 😜


Basically, pronounce it Mayvn.


BTW, the capsule project makes some claims about better conflict resolution, but I haven't the chance yet to verify those claims.


But if it is true, then it could be incorporared in Meyvn.


This is the rationale of Meyvn, leveraging Maven and its practices.


ok. i just remember reading your readme. it said you might reach out to them to offer (require?) the commercial version. it struck me that it might be interpreted that companies might lose access to this tool without the upgrade


Nope. It's open source. And I want to be able to continue to write open source software. So I'm going to reach out to companies and offer them a commercial license. It's up to them if they want it or not.


yeah. but it's dual licensed. just any worry about build tooling can cause people to worry. was just thinking if you made the language clearer, like "I might reach out to you to offer more services but you can always use the free community version".


but this looks like a nice complement to the clj tooling


Sure, that's a good advice. I'm going to to take it, too. Thank you.


looks good to me!


Awesome. Thanks.


if you do (count (range 1e8) are the items of the seq being garbage collected as they are counted?


@danielsz that section could be better further up, or at least mentioning that there are metrics collected further up. Also, calling out explicitly what is reported would be good.


And it looks like these metrics get sent to, not you directly?


Yes, private pastes to


@lockdown- yes, or the items can be garbage collected as long as you don't hold on to the head of the collection. See the difference:

clj -J-Xmx128m
user=> (let [r (range 1e8)] (count r) r)
OutOfMemoryError GC overhead limit exceeded
user=> (count (range 1e8))

👍 4

Also, if you do want to count ranges, if you pass a long as the argument to (range) it's counted in O(1) instead of O(n), because LongRange implements Counted.

user=> (time (count (range 1e8)))
"Elapsed time: 5691.129185 msecs"
user=> (type 1e8)
user=> (time (count (range (long 1e8))))
"Elapsed time: 0.041133 msecs"


neat head-holding demo using clj -J-Xmx128m!


the new tool makes things so much easier


I've been trying to figure out specs but I can't find any info on a certain case: How do I validate hashmaps where keys aren't keywords? I have to expect hashes that have strings for keys (like "@language"). How can I create specs to validate this case? Example: { "@language" "en", :type "Entry", :attachments [] }


The JSON parser can convert it to a keyword :@language and I can hack around it like this:

(def language (keyword (str *ns*) "@language"))
(s/def language string?)
But if I try to use it like (s/valid? language my-map) I get an error "Unable to resolve spec: :user/@language"


s/def takes keywords not symbols


common mistake, and the other way around with s/fdef


it's a bit sad that spec doesn't guard against this, given that it ... validates things


that's not the case


>k must be namespaced keyword or resolvable symbol


i give it a resolvable symbol


the symbol resolves to a namespaced keyword


and from the error it's clear that it's trying to look that up


odd, never seen that used


i have to hack it like this because i can't just type ::@language that gives a syntax error


it's really weird because it acts like it registered the spec alright, yet it fails to resolve the keyword it accepted for registration


ah yeah, you're right


I feel really stuck here. I don't know how to use string keys in specs, and I can't seem to use keywords.


seems like a bug


very much so, sadly


user> (def foo ::asdf)
user> (s/def foo string?)
user> (s/valid? foo "asdf")
Exception Unable to resolve spec: :user/asdf  clojure.spec.alpha/reg-resolve! (alpha.clj:69)
user> (s/valid? ::asdf "asdf")
Exception Unable to resolve spec: :user/asdf  clojure.spec.alpha/reg-resolve! (alpha.clj:69)
user> (s/get-spec ::asdf)
user> (s/get-spec foo)


not sure I see the link with string keys?


you can use map-of, but yeah s/keys is a keywords only thing


The map comes in in JSON and the parser converts the keys to keywords. I guess I could tell it to keep the keys strings if that'd make spec work but I guess it wouldn't.


if the parser converts to keywords you're good to go normally


The problem is, as outlined above, that some of the keys contain the sign @


which apparently murders the spec macros


I thought you could make get by with eval, but no


If you know of a way please tell me


actually it works


(eval `(s/def ~(keyword "user" "@asdf") string?))


it's horrible but heh


with ns it would be something like

(eval `(s/def ~(keyword (str *ns*) "@asdf") string?))

💯 4
👍 4
❤️ 4

@alexmiller should that be filed as a bug (docstring or lib bug)? Since s/def docstring states :

Given a namespace-qualified keyword or resolvable symbol k, and a
  spec, spec-name, predicate or regex-op makes an entry in the
  registry mapping k to the spec


You just saved the day


user=> (def context (keyword (str *ns*) "@context"))
user=> (eval `(s/def ~context string?))
user=> (s/explain (s/keys :req [context]) {context "asd"})


should libraries list a org.clojure/clojure dependency? should it be in the :provided profile?

👍 4

Am I the last one to give up on ordering my code bottom to top so I do not have to be forever declaring subroutines? The Pascal nature of Clojure beats another top-downer into submission? Scroll to the bottom to find the big picture? #justsayin


I write code top-down, why not organize it caller over callee? It’s OK, I will live. Nice callback to when Pascal went toe-to-toe with C for micro primacy.


there is a hackernews thread where rich discusses this. if I remember the gist of it is he wants things to work the same way in the repl and in files


Thanks! That is a great insight into his thinking. I thought there was something about Java that necessitated the declares. The repl rationale is odd, though. Who writes more than a tweet at the repl? I never use the REPL that way, been Lisping for twenty years. Thx again.

Russ Olsen20:06:11

I don't have a cool video, but I write a lot of stuff at the repl too. But who am I to argue with someone else who remember Pascal.

😁 4

I guess it's worth emphasizing that there's a style where you eval forms from a text editor directly into the repl when doing those sorts of things, it's simpler to keep in your head that what you're doing is very close to what actually happens in production


Yes, and right at the start of that video we discover that what people mean by REPL is “dynamic development”. But once we recast it that way and I am actually working in a text editor with REPL evaluation a keychord away, it is no longer relevant that lower level subroutines must be defined before higher. And this brings us to the compilation units Rich mentioned. I have a 90kloc Lisp program that builds as one compilation unit thanks to that feature being offered by AllegroCL. Most Lispers use ASDF, which is unbearable for me to use precisely because it lacks that skill.


Might I add that dynamic development began with BASIC (trying to top my Pascal reference.)


Heh-heh — was toggle switch programming dynamic? Missed that one.


> it is no longer relevant that lower level subroutines must be defined before higher. I'm not sure how this relates to the things before it


Rich’s rationale for the ordering of function definitions is that that is how Lispers work, entering forms sequentially at a REPL, building up the dynamic environment bottom to top. Of course it would be a hard way to start each day, so we have source files. Once we have source files, we can have main at the top and sub-sub-sub down at the botton out of the way. If we had a source file treated as a compilation unit.


The video was making a pitch to folks accustomed to compiling the whole thing before being to able to witness the smallest change, with these same folks not accustomed to interrogating a running application.


is your argument basically that "only the dynamic environment part of this is important, and that doesn't preclude compiling whole files"?


Not sure I follow your last. Of course we must deal with whole file compilation when re-booting our apps. Indeed, that is the nit I am picking: I have to sprinkle declares all over because CLJ does not even recognize a single file as a compilation unit. It treats a source file as if I were sitting literally at a repl typing in each form one by one. But as Rich said, hey, use declare. Full circle. 🙂 Me, I am going to just re-order my source the Pascal way.


I was trying to understand your argument; maybe you were trying to make a distinction between using a repl to introduce new code vs using a repl to interrogate a program?


I am getting a kick out of the fact that every guess you make at what I am saying makes me first understand your guess before I can comment. I detect a slippery slope! 🙂


oh well ¯\(ツ)


But here are my points. No, “the Lisp Way” does not justify a single source file being ordered callee first. Second, I doubt a single source file being treated as a compilation unit gets into craziness. And we already have requires, so there would be no need for CUs to cover anything more.


but what do you think of the "works the same way as the repl" attribute? that it's not valuable enough to justify the awkwardness?


Third, I started this because I found messing with declares annoying. So, fourth, I am now ordering my code callee first. Life is good! 🙂


Again, nobody sits at a repl writing interesting code. Why, when we have Cider? And as you noted, that is not like typing source into a command line of a REPL.


Oh, I do not merely eval unless I am learning syntax, debugging, mebbe testing a chunk of code But if I am building a complex function that will call a few that call a few, I type in all the source and eval a snippet, generally as a clojure test.


so when you referenced cider you meant that you use it for things like running tests, and documentation, and whatnot?


how many units of compilation is (def f (fn [] (def g (def h)) (def i (fn []))))? In either the functions case or the vars case


(or would you say some aspect of that should be prohibited?)


I think six?


I've confused myself now, though...


I'm pretty sure the answer is two, but then I have to refine my understanding of this.


I suppose what I actually care about is what ends up being a Java class since that means the compiler emits a chunk of bytecode for it. I'm not sure if that strictly makes that the compilation unit. If so, then it's actually a different concern from what Kenny is talking about.


if I had to bet five dollars on it, I would predict that rich would say the compilation unit is a single top level form i.e., for my example it would be just one

👍 4

In Lisp-land anyway a compilation unit decides what things are visible to the compiler during one compilation. The Lisp standard says that a source file is a compilation unit, so caller and callee can appear in any order in one source file. AllegroCL lets me stipulate that an entire collection of source files is one compilation unit, so it will not consider a callee undefined until it finishes compiling all 80kloc across dozens of files. So multiple CUs in one expression is different. 🙂


this seems highly relevant to that question: So this doesn't compile: (do (defn foo [] (inc bar)) (def bar 12)) What does that say about whether it's one or many compilation units?


I'm not sure. I wouldn't have expected that to compile.


Oh, he just says it: "Clojure, like many Lisps before it, does not have a strong notion of a compilation unit."


"Strong" semantically speaking. Practically the answer is "top level forms," which doesn't seem to map to how the compiler emits bytecode at all.


Now that I've had some coffee (I'm on a bizarre sleep schedule, which today amounted to 4-5 hours this morning)... I think the answer to, "What does that say about whether it's one or many compilation units?" is that while do is obviously a special form the first var that snippet creates calls a symbol that's not interned until after it. do blocks are obviously meant to be sequentially executed, but that post on the "Gilardi Scenario" makes it seem something like that snippet should work regardless. I must not be understanding the issue.


Err, I guess the difference is the example in that post is still in the correct order inside the do block. I may still not be so lucid...

Philip Hale16:06:20

I had a problem in JS-land last week where different settings of webpack caused the production build to fail (but not the development build) because an ES6 fn wasn't hoisted as normal. Moving the fn declarations around fixed it. Now I don't know what to think...


@phil672 Reminds me of when code that ran fine with the tooling that comes with lein mies then failed when I tried building with figwheel. Then someone spanked me for not figuring out why. Tough crowd. Where would I begin?


Hi everyone, there used to be a log of the slack channel ( but the last entry is ~ April 17. Is this a known issue or is there a reason it no longer captures recent dates?


maybe someone forgot to pay =)


sounds plausible


hmm yeah that’s odd. i imagine there’s a job supposed to be running somewhere that scrapes these


how are the bots going to learn clojure best practices if they don't have recent slack archives to read? 🙂


It is a known issue, IIRC someone is working on restoring/improving the data feed but I forget what the status is on that.

👍 4

i understand they have the logs but haven't fixed up the display of them yet. i could be mistaken


hmm, clicking that link i get: > Relay is shutting down


@spieden the relay thing was a bit of a diversion. the rest of the thread is the real context.


got it, thanks


Discussion of Slack/alternatives belongs in #community-development just FYI.


sorry i meant to link to the thread rather than to that specific posting. the point wasn’t meant to be about slack alternatives, its about the work being done to fix the logging front end