Fork me on GitHub
#clojure
<
2018-08-17
>
euccastro00:08:56

just curious: what is the rationale for this entry in the clojure style guide?: https://github.com/bbatsov/clojure-style-guide#nil-punning

andy.fingerhut00:08:49

As opposed to using an expression like (not (empty? maybe-empty-sequence)) ?

andy.fingerhut00:08:49

I believe because seq is the standard/idiomatic way in Clojure to determine whether a sequence is empty or not, and if not, to get back a thing that you can do first or rest on.

andy.fingerhut00:08:38

Also, simply for a small bit of efficiency's sake, empty? is defined as (not (seq x)), so (not (empty? x)) would be slightly less efficient than (seq x)

andy.fingerhut00:08:37

If you use seq for that purpose, other people familiar with Clojure will know what that means and be accustomed to it used for that purpose.

euccastro00:08:58

why have an empty? at all, then? is (if (empty? x) ...) preferred over (if-not (seq x) ...)?

euccastro01:08:46

(I'm not arguing btw, just trying to understand)

mfikes01:08:13

Perhaps empty? makes for a good predicate. You could then debate (filter seq coll) vs. (remove empty? coll). 🙂

mfikes01:08:43

Maybe the answer is simply relevant to your example. (if (empty? x) ...) is easy to grok quickly.

noisesmith01:08:59

also worth mentioning is not-empty - nil (falsey) like seq for empty input, otherwise preserving the type of the input

mfikes02:08:22

Nice. I had never noticed that empty and not-empty share the “type preservation” aspect.

ilikeOPHeroines02:08:16

Hey guys, I am a CS student going through SICP. I was wondering if anyone had any advice when approaching these problems to get the most ouf ot hte book.

ilikeOPHeroines02:08:49

Like is it ok that sometimes when I design procedures, I find myself writing down on a piece of paper how certain tests will compute? Or is that defeating the purpose of thinking abstractly?

noisesmith02:08:07

working on paper is great

noisesmith02:08:18

it's even a helpful way to refine abstractions

ilikeOPHeroines02:08:36

thats good, sometimes i feel like to myself that i should be 'smart' enough to have it in all my head

noisesmith02:08:28

I assume you're using the "translation" that someone did of SICP to clojure? http://www.sicpdistilled.com/

dpsutton02:08:28

the typography and visuals are really great in this version

noisesmith02:08:03

scheme is pretty cool until you need libraries for modern stuff :D

dpsutton02:08:47

agreed. you were studying the scheme shell right?

noisesmith02:08:34

I had some fun playing with it; haven't looked at it since I started my new job

noisesmith02:08:14

but scsh is a pretty cool dsl for shell scripts, it can do piping etc. inside scheme code via the magic of macros

ilikeOPHeroines03:08:41

No i was doing the original SICp

ilikeOPHeroines03:08:48

Is this one for clojure as good?

ilikeOPHeroines03:08:58

I am learning clojure through 4Clojure right now

dpsutton03:08:51

i would stay in scheme. learn to enjoy the language. and then get paid to write lisp in clojure

ilikeOPHeroines03:08:36

that's the goal 🙂

ilikeOPHeroines03:08:22

do you think it'd be bad to do both at the same time? if they're both fun lol

dpsutton03:08:16

never a problem with learning. but i find when i do two things at once often i will neglect one and only focus on the other

ilikeOPHeroines03:08:12

guess ill give it a go! i just hope its as well written as SICP is

emccue04:08:40

what are the differences between clojure.spec and prismatic schema

noisesmith16:08:27

the biggest is that schema defaults to a closed set of keys (extra keys are an error unless you specify they are allowed) while spec defaults open

noisesmith16:08:55

in schema the description of the data looks like the data, in spec it's a regex describing the data

emccue04:08:06

Specifically I want to make sure a db entry in mongo matches a certain shape

felipebarros04:08:56

If I'm not mistaken, I once saw somebody mention, probably here on Clojurians, a list of Rich Hickey's talks in some sort of order. Not only the fantastic list in https://github.com/tallesl/Rich-Hickey-fanclub but it had like a path to watching/reading the contents. If somebody remembers something like this, I would love a link.

felipebarros06:08:30

Thanks! I don't think it was that particular piece, but it seems really nice, so I'll try it out.

felipebarros06:08:18

Also realized that since the videos on Rich Hickey Fanclub are organized chronologically, and there aren't that many, I can probably set up a schedule to watch them all in reverse chronological order and see where that takes me.

sundarj06:08:08

sounds good!

dottedmag07:08:29

Has anyone seen a serialization/persistence library for Clojure that takes advantage of structural sharing? What I'm looking for is a way to easily serialize [state1 state2 state3 ....], where each new state is a change from a previous one, and deserialize it back, with the following properties: 1) serialization does not store thousands of copies of similar data; 2) deserialization does not cause RAM to be filled with lots of copies; 3) it's cheaper than doing a full diff operation on serialization; 3) it's not a one-time thing: new states added to the end of the list can be also efficiently stored in a subsequent serialization.

dottedmag07:08:13

Probably it has to be built in the language, or at least implemented in Java: basically what I'm looking for is a way to serialize underlying structure of persistent data structures to disk, and then keep a marker "this node is in durable storage at key X" on all internal nodes when they are deserialized.

gklijs10:08:15

But for the whole state of the program, or only an explicit given part? So you can of want to serialize everething in memory?

gklijs10:08:14

Otherwise you could make some macro I guess, with you use with some atom and ‘file-ref’ which when the collection is used for the first time tries to get it from a file based on the ‘file-ref’ and when the collection is updated, always overwrite the file in .edn.

dottedmag10:08:29

Only for a specific data structure.

dottedmag10:08:00

EDN won't cut it: I'm talking about gigabytes of data if not deduplicated properly, changing every 100ms or so.

dottedmag10:08:04

Every change is small, but the changes are applied on a sizable data, so naively storing every snapshot in .edn is out of question.

dottedmag10:08:06

A good mental model for a task is a rich text document with the full history: you don't want to keep every revision after every keystroke, but you also don't want to recreate historic states by reverse-applying changes.

Alex Miller (Clojure team)12:08:57

Clojure data structures support Java serialization. I can’t remember if they just use serialization defaults or something different. If default, Java serialization does what you’re asking for (persists the object graph)

Alex Miller (Clojure team)12:08:34

I guess that’s only useful to you if you were pushing them on a stream that retained the cached objects, which you’re probably not

Alex Miller (Clojure team)12:08:21

You really want the equivalent of git

dottedmag13:08:53

A subset of git, with a single ref and immutable history, yes.

dottedmag13:08:51

Clojure already has everything in memory. Maybe I'll try to hack something and serialize its internal structure of Persistent* types.

dottedmag13:08:27

Then deserialization can keep a WeakMap of object -> storage key, and that can be used to persist only a diff in subsequent operations.

gklijs13:08:16

Maybe with redis then, it’s fast, just not sure if you serialize you can do what you want with it, and when a single collection becomes to big it’s still difficult.

euccastro13:08:27

transit claims to do caching of "repeated elements". I don't know if it goes all down to caching repeated structure across different elements? > Transit also supports compression via caching of repeated elements, e.g., map keys, that can significantly reduce payload size and decoding time, as well as memory in the resulting application representation. https://github.com/cognitect/transit-format#rationale

euccastro13:08:07

I see, thanks!

Chris11:08:15

Anyone know of any good tools for combining calls to test/check and then giving a report/summary on them?

andrewtropin15:08:26

I found a library better than clojure.spec: https://github.com/HealthSamurai/matcho Just kidding, but it's a pretty useful and easy to use lib, which helpful for writing tests and validation code. Our team uses it in production for 2 years. Idea more similar to prismatic/schema than clojure.spec, but with different focus. Originally it relies on open-world assumption, but latest release also supports strict matching (to prevent exposing of sensetive information and similar cases). Will be glad to hear a feedback on the lib and documentation from you. Star the repo if you think we are moving in the right direction, it motivates to make our open source projects better.

lwhorton16:08:40

with the tools/deps repl, how can I use an alias and ignore the main opts? clj -Amyalias --repl doesn’t seem to override my deps.edn :main-opts ['-m' 'my-namespace'] config

lwhorton16:08:49

disregard, was thinking of it wrong. i want -R:my-alias -r to just bring in the deps of an alias, then launch a repl

ilikeOPHeroines17:08:03

I'm having a difficult time getting Lein to self-install on windows. It keeps saying 'REquest aborted, could not create secure ssl/tls channel"

ilikeOPHeroines17:08:08

This is what worked for me if anyone runs in to this issue : https://github.com/technomancy/leiningen/pull/2405

emccue18:08:32

Anybody got lacinia glue code for something other than pedestal? I don't have an issue with pedestal but i am stuck on windows for now

hiredman18:08:33

I've seen you ask this question in #graphql and I want to know, what does being on windows have to do with pedestal?

hiredman18:08:26

last I checked (admittedly a long time ago) pedestal was a jvm library without any kind of native code or anthing

emccue18:08:32

look under supported platforms

emccue18:08:18

ill feel like an idiot if it just works and i never tried it

emccue18:08:56

but the documentation says that it isnt supported

hiredman18:08:32

isn't supported may just mean none of the developers uses windows so they don't want to be answering questions about running lein on windows