This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-28
Channels
- # bangalore-clj (1)
- # beginners (67)
- # braveandtrue (179)
- # cider (28)
- # cljdoc (1)
- # clojure (132)
- # clojure-conj (3)
- # clojure-dev (1)
- # clojure-finland (6)
- # clojure-nl (2)
- # clojure-russia (6)
- # clojure-spec (19)
- # clojure-uk (62)
- # clojurescript (90)
- # clojutre (5)
- # component (2)
- # cursive (30)
- # data-science (1)
- # datomic (42)
- # duct (9)
- # emacs (1)
- # figwheel-main (158)
- # fulcro (57)
- # funcool (3)
- # hoplon (1)
- # jobs (17)
- # mount (38)
- # off-topic (15)
- # re-frame (53)
- # remote-jobs (2)
- # schema (11)
- # shadow-cljs (299)
- # spacemacs (25)
- # specter (2)
- # tools-deps (54)
- # vim (11)
- # yada (6)
hello
what do you need to know?
Sorry about late response @U79NZHC6A, what platform did you use?
I just suck up the cold start penalty and use nodejs rather than JVM clojure
JVM cold starts are brutal
nodejs ones are pretty short
but having to keep lambdas warm greatly increases yr cost
for my stuff I’m using cljs, at work we’re a python shop and even python feels substantially slower than node
but I’m not sure if that’s my imagination
Hello 👋 Maybe this is not the best place to ask this. This is also not intended to be a troll question. Any pointers to existing documentation/articles/talks or even hints on what to search would be appreciated. I do not expect lengthy answers, but mostly pointers. I am looking into types. I have some familiarity with the F# type system. I do understand most of what Rich is saying on his talks (especially the Effective programs talk). What is my (current) main concern in the debate of whether types should be used is wether people that do not use types go through the burden of verifying the contents of the parameters in every function. ie, if something like the following is common and if not how is such "verification" achieved?
(defn my-function [param1 param2 etc]
verify param1 ; is a number and not null
do-useful-stuff)
I do get the "checks like that only happen on the edges of the program and internally nothing like that takes place", but is this your answer?If you still want some points, I for once use Schemas to check for type and constraints only in development. I found out that eases legibility in multiple cases, and avoids some bugs
Also, I use prismatic-schema to coerce input messages (so I can receive a JSON and forget about "missing fields", or "a string that I need to transform on DateTime")
Also, you can use (schema.core/explain <some-symbol-here>)
and you'll know what's the shape of data you're expecting (great for tests and understanding context while you're exploring code)
@ivan.kanak_clojurians http://martintrojer.github.io/clojure/2016/06/14/some-thoughts-on-clojurespec I agree with this view point. Assertions/specs are not equivalent to types (and the inverse is true as well). There's benefit to both. But that's not to say you need either, or that one is better than the other without any given context.
Put in another way: types are compile time checks, assertions are runtime checks. Both can help to write more robust code, but both have their costs as well.
I don’t typically verify that fn params are the right “type” unless there’s a significant likelihood that they’ll come in as wrong ones. Typically that means checking for not-nil, but it could be other constraints. So far I haven’t missed type checking, and on the rare occasions that I find a bug that type checking would have caught, it’s easy enough to add an appropriate check.
Thanks for your opinions. I also found this related post on types, on martintrojer's blog https://martintrojer.github.io/beyond-clojure/2016/04/19/beyond-clojure-prelude If any other has more to add, I'd be glad to look into 😉
Hello, I am currently working with specs and I'm trying to activate the check-asserts feature for my unit tests. I've tried putting a :clojure.spec.check-assert "true" entry into the :env map of the :dev profile but I get the following message Warning: environ key clojure.spec.check-asserts has been corrected to :clojure-spec-check-asserts
that obviously leads to check-asserts not being activated. Would anyone have any pointer as to how I should proceed ?
is there an equivalent of Karsten Schmidt’s [rstream-graph](https://github.com/thi-ng/umbrella/blob/master/packages/rstream-graph/README.md) in clojure? Basically looking for a graph with state and transducers in the nodes that can reactively subscribe to each other. I’m aware of plumatic’s graph but not sure how that would work with transducers.
not within the existing tools. But deps.edn is pure data, so you can always generate it
does anyone know of a good blog post discussing suitable use cases for https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/case
I have picked up a general superstition against using it But would like to understand more of the issues
not sure what you mean
case is the fastest kind of multibranch dispatch you can do, but you need constants on the left hand side
say idk if you would have a couple of
if (= x y ) return y
elif (= x w) return w
elif (= x z) return z
else return x
Here’s nice deep-dive into case
https://www.youtube.com/watch?v=_f3WeoDSN-I&list=PL-izX-5c9Z5TRqH7uVhWMq3ZJxR8PmExb
it has a complex implementation based on whether the keys are all ints, all keywords or a mixture and attempts to compact the key ranges
I would use condp
in that situation
it's great when the keys are ints
and its great when the keys are keywords
(but so are plain old maps, and introspectable to boot)
still untangling the hash-code logic around the mixed case statement
trying to come up with a deps.edn but I can't figure out how to list multiple deps. I have the below but it fails because it's not a valid map.
{:deps
{reagent {:mvn/version "0.8.0"}}
{re-frame {:mvn/version "0.10.5"}}
{day8.re-frame/http-fx "0.1.6"}
{secretary {:mvn/version "1.2.3"}}
{com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}}
{proto-repl {:mvn/version "0.3.1"}}
{devcards {:mvn/version "0.2.5"}}
{binaryage/devtools {:mvn/version "0.9.10"}}
{day8.re-frame/re-frame-10x {:mvn/version "0.3.3-react16"}}
{day8.re-frame/tracing {:mvn/version "0.5.1"}}
{day8.re-frame/tracing-stubs {:mvn/version "0.5.1"}}
{day8.re-frame/tracing {:mvn/version "0.5.1"}}
}
I think I read somewhere either here or in the google groups that defn- is something to be generally avoided and is sometimes considered a regret in the core api. Am I remembering this right? If so, is there a discussion of this somewhere? I personally don't use it, but I'm having a discussion with some fellow devs and wanted to get my facts straight.
I remember someone mentioning this also. I think it was a response to a question about if there will be a corresponding def-
. They said defn-
was generally considered a bad idea. I don't remember the reasoning though.
I hadn't heard that it was to be avoided, I think they just regretted the inconsistency in the api. like, there's no defmacro- or defmulti- etc, because you can just do defmacro ^:private. I think they regretted that they exposed defn- as a "convenience" form, because in hindsight, that's not the job of the language design
ah, so the best practice is to mark the def/defn as private and not use defn-?
Bing doesn't turn up much but I did find a thread on Reddit that said defn-
was an inconsistency and because there were so many def
forms, adding a private version with -
would have added a lot of new forms.
So many folks use "Google" as a verb that I need to be careful to avoid saying that 🙂 I stopped using Google (and almost all of its infrastructure) years ago...
I'm liking MS more and more these days. Lots of innovation. And with WSL now, Windows 10 is a nice developer environment.
No, use defn-
rather than defn ^:private
-- for concision.
(according to bbatsov's community style guide)
yeah, there's zero concern about the usage of defn-, just as a feature of language design its irrelevant. I'm afraid your coworkers are right @markbastian 😆
But, in general, private functions don't add much really. You can still call them.
@markbastian there's literally no difference between defn-
and defn ^:private
so there's no reason to use the longer form to the short one
Some folks think you should avoid private functions -- put implementation details in a separate namespace; others think defn-
is fine for functions that aren't part of a namespace's API.
I like that Joker (lint) tells me a private function is unused (and can therefore be removed), but I don't tend to write many private functions in my application code (just in libraries).
I've generally found that making functions private from an implementation standpoint when using external Clojure code never aids me in understand that API and on the rare occasion that I need to use the function I wish it were public.
To convey intent
Again, just speaking aloud, but I see.
Thanks for the info. I definitely misunderstood the prior conversation.
defn- is part of the api, it’s not going away, if it’s what you need then use it
Oh, I wasn't suggesting anything like that. I was just under the impression from a prior statement that there was something regrettable about it (can't remember what, though). And it was in relation to not having def- now that @bmaddy reminds me.
and I should probably clarify my comment, I remember reading about a little regret that defn-
was added, not that it should be avoided now.
I also just learned something interesting from my coworkers that not everyone on the channel might also know. You can invoke private functions by var quoting them. So, (#' my-private-fn x)
can be used when you do need to spelunk the guts of an existing library to understand its implementation. This has been my #1 issue with private functions.
I was wondering if it'd be possible to build an optimization thing that walked an ast, built a call graph and then "transducify" any functions that can automatically be turned into transducers
@hacker.kill07 have you installed the local jar into a local maven repo?
@the2bears that’s ok
Not super scientific findings, but I thought this was pretty weird and maybe someone has a good explanation at first glance. But I opened up VisualVM to try to track down some issue and I noticed every time I evaluate something in the repl, the used heap grows by at least ~60mb. I can type 1
and enter
in the REPL and the heap grows by that size. Doesn't that seem pretty odd? I think 60mb is pretty big
using clojure.main, socket repl? nrepl?
nREPL server started on port 33819 on host 127.0.0.1 -
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.9.0
Java HotSpot(TM) 64-Bit Server VM 10.0.2+13
nrepl, reply, and whatever nrepl middleware you may or may not be running are complex bits of software, and the heap jumping by 60mb doesn't mean much if the gc hasn't run
you might find your profiling data easier to interpret without the nrepl stuff (eg. a clojure.main repl without the network server and middleware)
basically your environment is likely so full of confounding factors that your observations are not useful
Yea I just think that's interesting, curious about how that can be optimized. If GC is slow you can rack up quite a bit of used heap pretty quickly in the REPL.
I wouldn't spend my time optimizing dev tooling - if you find it too heavy there are lighter alternatives and none of that stack should be present when deployed
the way memory is used in the jvm doesn't seem to match the intuitions people show u p with
if you tell the jvm it has a max heap of N, you should assume it won't gc until it has used most of N
jvm defaults to a max heap of 1gig in most situations these days if you don't give it an explicit max heap
Always surprises me how hungry the jvm is for memory. Wrote some C# code for the first time in awhile the other day. The full GUI app used 16MB of ram and memory was released back to the OS after about 60 Sec of idle time.
I found out that OpenJ9 (IBM's JVM) uses significantly less memory (I use it for development). But still is way more than other solutions...
The JVM is really optimized for servers
"memory released to os ..." - what, was this a language developed by an OS company or something :D