Fork me on GitHub
#clojure
<
2018-08-28
>
fabrao01:08:18

Anyone worked with serverless project?

alexlynham08:08:27

what do you need to know?

fabrao14:08:16

Sorry about late response @U79NZHC6A, what platform did you use?

fabrao16:08:46

about the cost, do you have to use heartbeat to beeing lambda functions up?

fabrao16:08:20

I researching if it worth using AWS with this heartbeat because the performance

fabrao16:08:41

scalability ...

alexlynham19:08:00

I just suck up the cold start penalty and use nodejs rather than JVM clojure

alexlynham19:08:10

JVM cold starts are brutal

alexlynham19:08:17

nodejs ones are pretty short

alexlynham19:08:30

but having to keep lambdas warm greatly increases yr cost

alexlynham19:08:57

for my stuff I’m using cljs, at work we’re a python shop and even python feels substantially slower than node

alexlynham19:08:04

but I’m not sure if that’s my imagination

Ivan11:08:55

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?

mauricio.szabo16:08:56

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

mauricio.szabo16:08:41

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")

Ivan16:08:47

cool, I'll look it up

mauricio.szabo18:08:08

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)

mpenet11:08:21

you can use assertions, via assert, or spec/assert, or pre/post conditions on the fn

mpenet11:08:42

they all are toggleable via jvm flags

wekempf12:08:45

@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.

wekempf12:08:29

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.

manutter5112:08:47

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.

Ivan12:08:16

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 😉

👍 1
joel13:08:39

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 ?

joel13:08:25

writing this I realize it may be environ that interferes 😞

joel13:08:42

I thought that :env key was standard leiningen

Tom13:08:41

I have a valid point to make: clojure is awesome

denik14:08:48

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.

urbanslug14:08:39

is there a way to skip the :mvn/version section in deps.edn?

urbanslug14:08:50

like have that somehow be a default

ghadi14:08:24

not within the existing tools. But deps.edn is pure data, so you can always generate it

Ben Hammond14:08:14

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

Ben Hammond14:08:01

I have picked up a general superstition against using it But would like to understand more of the issues

urbanslug14:08:43

ummm have you done pattern matching.

Ben Hammond14:08:06

not sure what you mean

ghadi14:08:46

case is the fastest kind of multibranch dispatch you can do, but you need constants on the left hand side

ghadi14:08:08

what's the superstition you allude to?

urbanslug14:08:36

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

urbanslug14:08:02

that is psuedocode but it literally what I think ghadi meant

urbanslug14:08:24

if you would ever want to do something like that

urbanslug14:08:30

sorry idk about a blogpost

Ben Hammond14:08:43

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

Ben Hammond14:08:00

I would use condp in that situation

urbanslug14:08:47

well in case you would

case x
w return w
y return y
z return z
x

urbanslug14:08:29

well I didn't know about the types making things complicated

dpsutton14:08:36

that looks like identity to me

urbanslug14:08:32

hahah it's an example

urbanslug14:08:41

you could be dispatching different functions

urbanslug14:08:49

but you can also use umm records

Ben Hammond15:08:13

it's great when the keys are ints

Ben Hammond15:08:20

and its great when the keys are keywords

Ben Hammond15:08:39

(but so are plain old maps, and introspectable to boot)

Ben Hammond15:08:02

still untangling the hash-code logic around the mixed case statement

urbanslug15:08:23

I also don't know about case internals but I use with keywords

urbanslug15:08:28

like some kind of record syntax

urbanslug14:08:10

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"}}
}

ghadi14:08:30

deps should be a single map {:deps {reagent {} re-frame {} ...}}

ghadi14:08:03

keys are the lib names, values are corresponding coords

urbanslug14:08:13

It makes sense now

markbastian15:08:53

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.

bmaddy15:08:16

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.

bronsa15:08:22

there's no reason not to use it now that it's there

bronsa15:08:28

the discussion was just about regretting adding it in the first place

bronsa15:08:36

but it's not going anywhere and it's not problematic

idiomancy15:08:38

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

markbastian15:08:35

ah, so the best practice is to mark the def/defn as private and not use defn-?

seancorfield15:08:48

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.

idiomancy15:08:06

you gettin paid to rep Bing? 😆

seancorfield15:08:25

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...

idiomancy23:08:09

oh yeah, that makes sense. google is getting kind of scummy

idiomancy23:08:21

not that MS is much better :thinking_face:

seancorfield23:08:17

I'm liking MS more and more these days. Lots of innovation. And with WSL now, Windows 10 is a nice developer environment.

seancorfield15:08:06

No, use defn- rather than defn ^:private -- for concision.

seancorfield15:08:23

(according to bbatsov's community style guide)

idiomancy15:08:06

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 😆

seancorfield15:08:18

But, in general, private functions don't add much really. You can still call them.

markbastian15:08:23

happy to be corrected

1
bronsa15:08:38

@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

seancorfield15:08:12

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.

seancorfield15:08:23

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).

markbastian15:08:59

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.

markbastian15:08:15

And if they're pure, why hide them?

👍 1
alexmiller15:08:41

To convey intent

dpsutton15:08:50

"use these functions to manipulate it"

markbastian15:08:51

Again, just speaking aloud, but I see.

markbastian15:08:55

Thanks for the info. I definitely misunderstood the prior conversation.

idiomancy15:08:19

good ask though!

alexmiller15:08:44

defn- is part of the api, it’s not going away, if it’s what you need then use it

markbastian15:08:37

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.

bmaddy15:08:58

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.

markbastian15:08:34

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.

denik16:08:26

hmm wondering whether dev on onyx will continue

john18:08:31

I haven't heard of a transducer graph thing in clojure/script. Sounds super cool though

john18:08:13

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

Akka16:08:35

hi,how to add dependencies local jar in lein-project?

Akka16:08:39

I can’t find a way to add him

the2bears16:08:20

@hacker.kill07 have you installed the local jar into a local maven repo?

Akka16:08:54

I did not do this

Akka16:08:20

let me try it.

Akka16:08:40

thanks

👍 1
leblowl20:08:32

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

noisesmith20:08:46

using clojure.main, socket repl? nrepl?

leblowl21:08:50

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

hiredman21:08:11

it is odd at all

hiredman21:08:19

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

noisesmith21:08:27

you might find your profiling data easier to interpret without the nrepl stuff (eg. a clojure.main repl without the network server and middleware)

hiredman21:08:30

basically your environment is likely so full of confounding factors that your observations are not useful

leblowl21:08:31

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.

noisesmith21:08:28

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

hiredman21:08:35

the way memory is used in the jvm doesn't seem to match the intuitions people show u p with

hiredman21:08:21

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

hiredman21:08:01

jvm defaults to a max heap of 1gig in most situations these days if you don't give it an explicit max heap

hiredman21:08:58

if you want it to assume it has less memory to work with, tell it that using -Xmx

leblowl21:08:55

Thanks for the insights

tbaldridge23:08:34

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.

mauricio.szabo16:08:44

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...

tbaldridge23:08:53

The JVM is really optimized for servers

noisesmith23:08:21

"memory released to os ..." - what, was this a language developed by an OS company or something :D

😁 2