Fork me on GitHub
#clojure
<
2018-01-28
>
qqq00:01:00

I use cider eval buffer, which appears to auto set the ns

noisesmith00:01:37

usually, the code in the buffer itself sets the ns, when you use load-file or load-string that change is not propagated back to the containing repl though

misha09:01:52

is https://clojurians-log.clojureverse.org - "dead"? the latest page for #clojure is 2017-11-16.html harold

misha09:01:54

@noisesmith as per @alexmiller, there is better way to get from sym to qualified keyword:

(keyword `foo/bar-baz)
The only downside is – 2-fold "api", instead of just 1-fold sym->kw macro call. Requires more attention.

laujensen13:01:15

I have an immutant app, which has many handlers responding to web requests. These pull out some data, generate some html and store some stuff in datomic. When it hands off to the browser, nothing is left hanging in memory. And still, once per day, sometimes twice, the entire system crashes due to the GC spinning out of control. What am I looking for?

noisesmith13:01:58

> When it hands off to the browser, nothing is left hanging in memory. do you have proof of this?

noisesmith13:01:04

doesn't datomic implicitly use a local cache so that you'd have to make new dbs and let the old be gc'd or else the other facts are sticking around in memory?

laujensen13:01:27

datomic does keep a local cache, but Im not sure its enough to shred a 4gb heap. I hope not

noisesmith13:01:10

anyway, the easiest way to answer your question is attach a profiler agent to the app, then look at the resulting file in a profiler

noisesmith13:01:37

you can probably find a decent answer well before generating a 4gig+ memory dump

noisesmith13:01:11

there's also hprof which iirc both yourkit and visualvm can load up

laujensen13:01:41

I have VVM attached now, we'll see what happens

laujensen13:01:38

Immediately after accessing a few backend pages there's a huge pile-up in the heap, and GC'ing manually does not resolve. That indicates heads are being kept intentionally, and that might very well be datomic

laujensen13:01:27

Confirmed from the heap-dump. Datomic caches 2gb of string-data as soon as its taken into use

noisesmith13:01:00

wow - maybe 4gb is just too small for an app using datomic then?

laujensen13:01:23

Thats what Im trying to work out

laujensen13:01:59

From their own configs they use objectCacheMax thats about 10% of the JVMs xmx, meaning mine is about 200mb too high. But this is fiddling and guesswork

taylor14:01:00

this page is 404 on http://clojuredocs.org (but other 1.9 functions aren’t) https://clojuredocs.org/clojure.core/swap-vals!

sundarj14:01:33

if you search for it, it is there, but the url is broken

taylor14:01:44

it does show in search results, you just can’t get to the page

tbaldridge14:01:20

@laujensen that's pretty normal looking to me. Datomic (by default) uses 1/2 of your heap as a cache

tbaldridge14:01:41

if you're seeing a lot of garbage it may be due to cache churn, in which case you need to look into the size of your data compared to the size of your heap. How many datoms are in your DB and how many are your queries looking at, and how big are the values?

tbaldridge14:01:05

If you notice, your heap usage pretty much sits right at 2GB, which is 1/2 of a 4GB heap.

tbaldridge14:01:47

And there's several layers of caching in Datomic, I've haven't seen large caches hurt performance any, except when it comes to GC times.

laujensen15:01:58

@tbaldridge, thanks for weighing in. We've had a length discussion in #datomic with stuart and I think we've got an overview of what needs to be done

laujensen15:01:12

Do we have a fast hashing algorithm in clojure, preferably not prone to collisions?

matan15:01:19

Hey, is that latest clojure book out of beta yet?

matan15:01:07

On the same note, I think I asked it before in the beginners channel ― does anyone have outstanding experience tutoring team members with clojure, if they have had little programming experience before (e.g. data scientists not hard core programmers)

matan15:01:07

I am somewhat reticent passing on clojure to some people, because of the heavy stumbling upon on Java classes and Java concepts that creep up a lot, specifically the weakly usable error messages that refer to java classes of clojure constructs

laujensen16:01:04

@matan, Ive struggled quite a lot with that. It looks to be very individual. If the person is smart and persistent, he'll figure it out, despite the "error messages". If not, it'll be an uphill battle. Java experience is a big plus, more so than fp it seems.

matan16:01:12

You kind of confirm my concerns. Our smart people over here have enough layers of challenges stacked to keep their neurons busy, learning Java through cryptic error messages about Java classes would be a waste of their attention 😉

matan16:01:51

@laujensen I appreicate the candor feedback!

laujensen16:01:53

Probably. On the other hand. Anyone who can dechiper "NO TRACE (:0) is worth investing in 🙂

matan16:01:28

😉 investing != wasting their attention on learning these things

qqq16:01:28

I've written maybe a total of < 1000 lines of Java in my entire life -- all of it as part of some undergrad course -- and I found Java to be no problem in debugging Clojure errors.

matan16:01:48

@qqq you must be special

qqq16:01:02

No, I think the most important thing is getting into a good repl workflow.

qqq16:01:14

Then, upon getting an error, having a nice IDE (like cider) which lets you view the stack framesi

matan16:01:28

That's cumbersome for the average guy/gal

qqq16:01:33

Either that, or binary search the sexps, to get smaller sexps that produce the errolr.

matan16:01:48

And this even more

qqq16:01:04

Is debugging easier in other langauges?

matan16:01:20

I think clojure is home for a portion of the general population who have higher IQ or something

qqq16:01:21

In C++, every 'try new thing = wait minutes for templates to compile', clojure repl instant feedback = godsend

robert-stuttaford16:01:46

@matan, are you hoping that we’ll convince you to use Clojure despite the friction Java stacktraces produce? 🙂 how can we help you?

matan16:01:52

C++ compiles very quickly nowadays, this is simply not a relevant statement in 2018

laujensen16:01:28

We're not discussing if Clojure is > than C++. Its a matter of assessing the amount of training and HR difficulties that follow using Clojure

matan16:01:45

@robert-stuttaford this is no platonic thread of conversation. The resource from @sundarjfor example might tilt the scales

laujensen16:01:47

And thats broken into two parts. Finding people / Training people.

robert-stuttaford16:01:14

you appear to be interested in having Clojure be used by data scientists, which leads me to think that you’ve had a look at the tools that are built for data scientists and found them wanting 🙂

qqq16:01:16

@matan @laujensen: have either of you used cider + lispy ? you hit C-x C-e, get an error, then you hit a key or two to move to a sub exp, then you hit C-x C-e again ... repeat a f3ewtimes, and BAM, bug is obvious

laujensen16:01:50

@qqq, I use cider every day - And do occasionally hit problems with cryptic error messages that require some manual detective work

matan16:01:55

@qqq I'm not used to emacs, as per cider

matan16:01:21

Have used lighttable (please don't expell me from this room for admitting that)

robert-stuttaford16:01:25

so, the java straces are annoying, but i don’t think they’re a good enough reason to ditch the language entirely. i suppose it depends on what you’ll have your target audience doing.

qqq16:01:48

@laujensen: occasionally, I too get weird stack traces, espeically ones of he form "no stack trace found, enable this flag on your JVM to avoid omitting strck traces" -- but besides those, most have been obvious once I drill down to the precise sexp causing the issue

robert-stuttaford16:01:17

i can tell you that i’ve taught clojure to >10 people, with an even mix of OO-scarred-veterans and shiny-new-people, and the latter cohort has a far better time of it in my experience. so much to unlearn as a veteran.

qqq16:01:45

the other thing is this -- assuming that this employee is going to work 40 hrs / weeks 50 weeks / year alteast 2 years, that's 4000 hours ; it's not a bad investment to have them spend 1% of that time, a single 40 hr week, mastering clojure tool chain

matan16:01:05

@robert-stuttaford couldn't agree more, OO fixates one's mind too much. That's a +1 for teaching clojure to data scientists

matan16:01:43

toolchain investment - yes cryptic error Java learning - not investment but ongoing time waste

robert-stuttaford16:01:53

one of my shiny-new-people is our sole data scientist 🙂 his first database is Datomic. he’s learned SQL only so that we can derive data from Datomic to there to connect to the BI universe

matan16:01:32

@robert-stuttaford thanks for sharing that 🙂

matan16:01:40

I wonder what programming languages or data environments did this individual as a case in point previously use? 🙂

matan16:01:56

emacs then?

matan16:01:49

I think cursive isn't really maintained or something, do you actually use it?

robert-stuttaford16:01:15

i know several folks who do. i did the emacs thing

matan16:01:34

What's the investment for someone who used few different IDE in their lifetime getting used to emacs? asking about myself now..

qqq16:01:36

@sundarj: thanks for sharing that debugging article, the (def n 24) is f***ing brilliant yet so obvious; I've been doing far less pleasant hacks to make things work

matan16:01:14

debugging article?

qqq16:01:35

see @sundarj’s previous link

matan16:01:47

right, looked at the wrong one before

robert-stuttaford16:01:43

cursive’s twitter acct is active. @cfleming - is cursive still on the go? 🙂

robert-stuttaford16:01:15

emacs was 2 very hard weeks followed by 5 years of bliss

matan16:01:33

two weeks?! how come

qqq16:01:19

@matan: there's #emacs; they may be more helpful with emacs setup

matan16:01:35

sounds painful have to say

matan16:01:43

so much to learn to use it?

laujensen16:01:03

Emacs is the birthplace of all good code. Its best not to resist

matan16:01:31

@laujensen come on, two weeks, what's so complicated there?

matan16:01:55

Your allusion to the borg withstanding.. 🙂

qqq16:01:12

This sounds more appropriate for #offtopic or #emacs

laujensen16:01:17

@matan I didnt spend 2 weeks on Emacs, maybe 4 hours.

laujensen16:01:20

Then 10 years of bliss

matan16:01:08

That sounds more like it... I would like to think there's nothing that twisted there to consume more than that for getting acclimated with resolve

laujensen16:01:59

The resources available today for setting up emacs/cider make it quite easy

matan16:01:00

So, emacs plus cider, and repl workflows, as the ultimate productivity toolchain in life? 🙂

laujensen16:01:32

Yeah, we built SabreCMS from 0 to public launch in 7 months or so. Beating our closest competition by about 11 years

matan16:01:48

All existing CMS that I know deserve being beaten by 11 years lol 🙂

laujensen16:01:42

Thats true. But a 2 man start-up surpassing systems like Webflow with 100+ million dollars in investments is quite a feat none the less

matan16:01:47

I think this raises the question ― do you have spare capacity? 🙂

matan16:01:51

@seancorfield care to repost that lecture link? looks like just what's helpful

matan16:01:15

Sorry coming back here later

matan16:01:43

Cannot express how helpful it's been for the open question asked

robert-stuttaford16:01:03

@matan two weeks because i was also learning Clj, and unlearning OO and learning Mac keyboard.

matan17:01:40

Unlearning Java style OO is hard, and then you learn clojure protocols at some stage lol

matan17:01:15

Just one last, any of the books you guys know geared towards the non-OO programmer or even naive programming learner, rather than playing out like a Java antidote?

matan17:01:24

A book that doesn't assume you'll be surprised that code is data and stuff?

sundarj17:01:20

clojure for the brave and true is pretty beginner-orientated

matan17:01:12

despite its pompous name? 🙂

matan17:01:49

likewise any book of beginner algorithm exercises suited to clojure?

sundarj17:01:03

haha, it's a very fantastical book

sundarj17:01:23

i found it fun though

sundarj18:01:02

for algorithms, i think the typical answer would be http://www.4clojure.com / https://clojurecademy.com

robert-stuttaford18:01:06

@matan also http://clojurekoans.com is great - an experiential approach to learning the syntax and the semantics

seancorfield18:01:08

@matan Living Clojure by Carin Meier is another good intro book.

matan14:01:20

Thanks! I like the "training plan" premise of it 🙂

qqq18:01:04

... or pick a small webapp, and start implementing it in clojure, and ask for help when you run into particular problems

qqq19:01:06

The standard way to attach meta data is via ^{...}. Is there a way to attach meta data to defn and fn 's ?

sundarj19:01:05

(defn ^{:a 2} foo {:b 3} ([]) {:c 4})
#'boot.user/foo
(select-keys (meta (var foo)) [:a :b :c])
{:a 2, :b 3, :c 4}

qqq19:01:34

wtf ... there's 3 ways to specify it? 🙂

cfleming21:01:15

@matan @robert-stuttaford Yep, Cursive is still actively developed

arrdem22:01:41

Random brainfiring - Given a spec and a structure which conforms to that spec, is there a tool like clojure.walk that'll let you recursively visit the structure's substructures as pairs (spec, substructure) according to the part of the spec that the substructure conforms to?

pablore14:02:48

Take a look at the speclj lib that implement lenses for clojure.spec