Fork me on GitHub
#clojure
<
2019-10-19
>
Arto Kalishian06:10:43

Yesterday I had a thought, what if Clojure was built on Erlang VM instead of JVM. Wrote that on http://Duck.com and figured out someone already made Clojerl 🙂 It was interesting. Now that the activity is very low on this channel I wonder if many already moved to Clojerl 😄

tschady15:10:52

might also checkout LFE from co-inventor of Erlang: https://github.com/rvirding/lfe

❤️ 4
Arto Kalishian11:10:11

Wow. Thanks for sharing

benzap15:10:39

@arto.eg I would find it difficult to move to the Erlang VM, since I feel like there's a wealth of libraries to choose from within the JVM ecosystem. What sort of benefits would switching to the Erlang VM entail? I've always been interested in Erlang and Elixir, but I haven't found a reason to really embrace it.

Arto Kalishian15:10:05

Not moving.. more like using it for specific use cases where scalability is needed.. if you can write clojure anyway why not leverage that on erlang. Their library ecosystem is not on par with Java but it's still huge.

schmee15:10:16

you’re talking about some pretty crazy scale if you’re out-scaling the JVM itself

benzap16:10:30

With reader conditionals, I wonder if some of the more popular clojure(script) libraries could be ported to clojerl. That would definitely give me reason to consider trying it out some more in hobby projects.

benzap16:10:28

That actually begs the question on whether there are any clojure libraries that have used reader conditionals to work between clojure, clojurescript, clojerl and clojureCLR

benzap16:10:00

and do clojerl and clojureCLR even have a standard key to produce the necessary reader conditionals?

benzap16:10:15

ie. :clj --> <clojure JVM> :cljs --> <clojurescript>, ? --> <clojure erlang>, ? --> <clojure CLR>

Alex Miller (Clojure team)17:10:58

There are lots of libs that work between clj and cljs

Alex Miller (Clojure team)17:10:08

There is a constant defined for clr and it’s supported there, but I don’t remember what it is

Alex Miller (Clojure team)17:10:20

Clojerl could pick their own

Alex Miller (Clojure team)17:10:54

:default can also be used for stuff that’s the same across

tstirrat18:10:39

i'm trying to write a zip function that would be similar to python's zip

tstirrat18:10:56

i've found how (map vector coll1 coll2 ...) will give the proper zip behavior

tstirrat18:10:11

but i'm having trouble figuring out how to write a new function that is multiarity in the same way

tstirrat18:10:33

i'm also a bit unclear on what a transducer is

tstirrat18:10:14

why does ((map vector) coll1 coll2 coll3) throw Wrong number of args (3) passed to: clojure.core/map/fn--5847?

seancorfield19:10:40

@U0M21EATB Most transducers only accept one collection argument. I think you'll need to use the sequence transducer to map over multiple collections...?

seancorfield19:10:41

(sequence (map vector) coll1 coll2 coll3)

seancorfield19:10:44

user=> (def coll1 (range 10))
#'user/coll1
user=> (def coll2 (range 20 30))
#'user/coll2
user=> (def coll3 [:a :b :c :d :e :f :g :h :i :j])
#'user/coll3
user=> (sequence (map vector) coll1 coll2 coll3)
([0 20 :a] [1 21 :b] [2 22 :c] [3 23 :d] [4 24 :e] [5 25 :f] [6 26 :g] [7 27 :h] [8 28 :i] [9 29 :j])
user=> 

tstirrat19:10:41

Hmm. I'll have to chew on that one. Thanks!

tstirrat18:10:00

i can also move this over to #beginners if that'd be a better place for it

nmkip18:10:28

has anyone read Elements of Clojure?

seancorfield19:10:37

@juan.ignacio848 Yup, it's a good book. You have questions about some of its recommendations?

nmkip19:10:25

Nope. I haven't bought it yet. I wanted to check if it was worth it

nmkip19:10:14

I heard / read somewhere it was a good book

seancorfield19:10:08

I would recommend it highly, yes. It has a lot of great advice and philosophy in it about programming in general, as well as Clojure-specific stuff.

4
nmkip19:10:36

Great! I'll buy it then

dominicm20:10:54

What's the value position of di frameworks for clojure over doing it manually by argument passing?

borkdude20:10:57

can you name a di framework? do you mean something like component?

seancorfield20:10:40

The only DI in Component is the automated assembly / start / stop process. Then you're just passing a system/environment data structure around (and it's up to you how much you pass down the call chain).

seancorfield20:10:18

But, yeah, in a complex system, that assembly / start / stop process could be a lot of work to maintain manually and get it correct in all cases.

dominicm20:10:52

How complex is complex? Do you mean Rich Hickey complex?

seancorfield20:10:38

A dozen or so pieces, all with their own start/stop lifecycle?

seancorfield20:10:59

Even half a dozen pieces is probably worth it to use Component.

seancorfield20:10:54

Web app depends on Core app + Web Server; Web Server depends on Config; Core app depends on Database, Caches, etc; Database depends on Config; Caches depends on Config maybe...

seancorfield20:10:32

I think we have 35 Components in our systems at work (although not all apps/service use all 35).

dominicm20:10:55

35 across all services? e.g. if you had 7 services, you'd have 7 web servers?

dominicm20:10:49

your described layout is actually fairly simple:

(let [config (aero/read-config "config.edn")
      db (hikari/start-pool (:db config))
      cache (cache/fifo-cache-factory (:cache config))
      core (myapp/core db cache)
      handler (myapp.http/handler core)
      http (jetty/run-server handler (:http config))]
  (fn stop!
    []
    (.close http)
    (myapp/close-core core)
    (hikari/close-datasource db)))
I was thinking through the value proposition, and realized it's quite hard to articulate.

seancorfield20:10:55

Those services would mostly reuse a generic WebServer Component.

dominicm20:10:39

@seancorfield but how did you count 35? through how many defrecords you have, or how many keys you have in system maps?

seancorfield20:10:52

component/Lifecycle references.

seancorfield20:10:01

So that doesn't count the app-level combinations of reusable components, just the actual components themselves.

dominicm20:10:19

Yeah. It doesn't reflect the size of the systems, just how many resuable pieces you have to put into those systems.

seancorfield20:10:53

That said, we have 70K lines of production Clojure (and 20K lines of tests) so it's a "fairly big" system. Broken into about 30 subprojects, of which a dozen are top-level apps/services.

dominicm21:10:39

@seancorfield I've worked on many applications that size or larger. Most of them could have their system reduced to something like the above.

seancorfield21:10:37

I wouldn't want to manage our dependencies and start/stop lifecycle code manually at this point. @hiredman would probably have more to say about our component model -- he uses it in a far more fine-grained way than I do, for the most part.

hiredman21:10:08

Yeah, you could do it all via manually passing arguments and ensuring things are started in the right order, but using component gives you the benefits of the argument passing style (vs global rederences) while automating everything

hiredman21:10:24

People often react badly to component because "oh, it's DI and that is terrible" but component really is just using topological sorting to determine what order to call things in. https://gist.github.com/hiredman/075b45eaeb01e4b526ce6f8854685487 is a minimal reproduction of everything component does

hiredman21:10:08

One potential advantage of component over the hand wired together approach is in component you build your system as a dependency graph which is a data structure, which means you do things like take the defined system and manipulate it for doing things like running tests

hiredman21:10:01

In general, I would say component is going to more beneficial the more you decompose dependencies. For example I like to make each ring handler a component so for each one I can make independent decisions about what dependencies they have

dominicm07:10:30

I've done this, but have got loads of resistance to "boilerplate".