Fork me on GitHub
#clojure-uk
<
2016-09-09
>
mccraigmccraig08:09:48

so i had an itch - building a system of objects. i don't like component, i don't like mount, yoyo & bounce have some nice ideas. i scratched it - https://github.com/employeerepublic/deferst . i think i need a better name

dominicm08:09:46

@mccraigmccraig I'd be interested to know your problems with each of those libraries.

mccraigmccraig08:09:17

component - lifecycle protocols everywhere, unnecessary uninitialised state

mccraigmccraig09:09:45

mount - never used it, but found the var based state concept icky

reborg09:09:11

the first markdown framework that I know of 🙂

korny09:09:05

m|r|n|n|g

reborg09:09:45

mccraigmccraig for people like me not into types, "deferred-state monad transformer” turns me right away, maybe put it at the bottom? Because the examples are not so mind bending after all.

korny09:09:28

Hmm, I want to add some type checking for a pet project, started reaching for Schema, and realised I should try out specs. What’s the best place to look for an overview? (slightly embarrassed that I haven’t really looked at it so far)

mccraigmccraig09:09:18

yeah, good idea @reborg - it's definitely not necessary to know the implementation details

dominicm09:09:24

@mccraigmccraig Not sure I understand what you mean by this: > unnecessary uninitialised state

mccraigmccraig09:09:42

@dominicm your Lifecycle instances have complex state - [new, start-request, started, stop-requested, stopped]... which is unnecessary - there's no reason all component initialisation can't be entirely hidden

dominicm09:09:46

@mccraigmccraig I've not interacted with those states, is it a pattern of some kind? All I have is my start and stop.

mccraigmccraig09:09:52

@dominicm right, the states implied by start/stop in a multi-threaded environment are [new, start-request, started, stop-requested, stopped]

mccraigmccraig09:09:25

@dominicm but the lifecycle protocol instance profusion was the principal thing i didn't like about component, rather than the unnecessary state

dominicm09:09:35

@mccraigmccraig I'm not fully grasping that multi-threaded condition on the component starts. I think I'm being a bit dim. Is this helpful if you're trying to start the same instance of a component multiple times in different threads? Why would you do that anyway?

mccraigmccraig09:09:11

@dominicm ignoring the threading (it's been a while since i used component, my memory is hazy) ... components have [new, started, stopped] states, and that's unnecessary... your component instance has to manage the transition from new to started, when really all you want to do is just create the object not create a component instance and then create the object later when that is started

mccraigmccraig09:09:32

but if your reduce the states to [existing] then you don't need a lifecycle anymore... just a pair of functions to create/destroy the object and you can get rid of all those useless lifecycle records

dominicm09:09:17

Ah, I understand the new state now. Yes, that's a bit of a fiddle, niling out dependency fields on initialization.

dominicm09:09:27

@mccraigmccraig I understand your design decisions now, very intriguing. I find it interesting that you decided to marry config into the library in this way.

mccraigmccraig10:09:39

@dominicm i didn't set out to do that with the config - it just flowed from deciding to use the state monad (which represents a composable computation on some state), since when you run a state monad instance you start it off with some initial state - config in this case

dominicm10:09:36

@mccraigmccraig I just remembered https://github.com/juxt/pull which you might find useful for pulling values out of the config.

benedek10:09:45

sry for being destructive but really enjoying doing mainly aws lambdas in clj/cljs nowadays partly because i don’t even need to think about components (tried mount too, preferred it over componets)

dominicm10:09:29

@benedek Do you AOT your entire codebase for AWS Lambda?

benedek10:09:14

to avoid start up penalty when new lambda instances are spawn you mean?

benedek10:09:37

yup, but we are experimenting to go with cljs/node.js lambdas if the function is directly linked to webUI

benedek10:09:45

to avoid the start up penalty

dominicm10:09:53

@benedek Did you have (m)any problems with AOT?

glenjamin10:09:05

i’ve been talking to a former colleague of mine who’s using clojure on lambda

benedek10:09:23

aot: not really

glenjamin10:09:25

and he’s saying their stats show they do very little multithreading in practice

glenjamin10:09:40

so it seems like cljs should be a much better fit

glenjamin10:09:23

and not just for runtime, they reckon they can knock minutes off their build/deploy cycle too

dominicm10:09:25

@benedek Awesome! I'm somewhat debating over whether it's only worth using AOT for the java shim it provides. Apparently aot does (launch-nuclear-missiles) if it's a top-level form.

benedek10:09:29

@glenjamin any specifics? i mean it should depend on how those lambdas are written, or?

glenjamin10:09:39

it’ll depend on the jobs they’re doing

glenjamin10:09:45

it’s part of an ETL-style pipeline

glenjamin10:09:57

so it’s pretty much data in, do some twiddling, data out

benedek10:09:06

sidenote if we are talking about lambdas, this is hilarious: https://github.com/microapps/recursive-lambda

benedek10:09:52

we do use some futures in some lambdas (jvm clj). they seem to be working ok. but have not done any proper benchmarking tbh

reborg10:09:19

benedek how aws lambda avoid the components mumbo jumbo? Sorry I’m late on the lambda party. Any doc to get me started?

benedek10:09:33

i guess you could do core.async too, have not tried so far

agile_geek10:09:51

Morning. Watched a fascinating talk on Mob Programming by Woody Zuil at Agile NE. Amazing experience report wrapped up in technique talk.

benedek10:09:04

@reborg you basically provide one, pure function for aws to run

benedek10:09:57

no components make sense (as far as i understand) in this context

benedek10:09:30

doc: hm… I guess you can start reading official aws lambdas in java documentation (or node.js if you are more interested in cljs) if you want to clj specifics I would check out https://github.com/uswitch/lambada for jvm clj and https://github.com/nervous-systems/cljs-lambda for cljs

glenjamin10:09:45

if you need to connect to some remote stateful service you might still want something componenty

glenjamin10:09:16

the aforementioned ETL system read from kinesis and wrote to redshift - which required making a JDBC connection

benedek10:09:18

@glenjamin that is true. although why would you when you can’t really keep it ‘running’ across lambda invocations?

glenjamin10:09:33

mostly for dev purposes

glenjamin10:09:50

and i think you can maintain DB connections across multiple invocations if you want to

benedek10:09:06

you mean you still use a db component in dev but not in lambda prod?

glenjamin10:09:20

i’d use it in both, but it would provide more utility in dev

benedek10:09:23

@glenjamin sounds interesting, any pointers how?

glenjamin10:09:43

lambda invocations sometimes re-use the running JVM / process AIUI

glenjamin10:09:55

so anything memoised / singleton etc should still be around

benedek10:09:10

yup but you can’t or should not expect this to happen as far as i understand

glenjamin10:09:25

yeah, memoising DB connection should be a good one though

benedek10:09:31

but you are right if your code can handle something not there it should just work...

glenjamin10:09:35

speedup when hot, but semantically the same

benedek10:09:45

btw in dev we just tend to run the lambda code without the lambda wrapper. so just as plain clj or cljs code. mostly from the repl anyway. and then have a DEV qualifier on the freshest lambda version (usually qualifier is moved to that version by the build server) to test locally with

benedek10:09:22

or some dev environment if not locally. so REPL driven dev is pretty easy with lambdas too

thomas14:09:44

Almost Clojure O’Clock… clj

jonpither16:09:36

@benedek this Lambdas stuff would make a great talk at LDN clojurians..

otfrom16:09:12

that is the sound of an organiser speaking

jonpither16:09:03

Can I autovolunteer people?

benedek16:09:07

why not? specially if I can mention how to do monolith with chaining lambdas ;) see the link above from today ;)

jonpither16:09:21

nice one - youre autovolunteered

benedek16:09:26

I think you just did :)