Fork me on GitHub
#clojure
<
2018-06-17
>
pooboy06:06:40

How to use cryptography in clojure

slipset06:06:25

Depending on what you need, there is https://github.com/macourtney/clj-crypto

👍 4
slipset06:06:50

Somewhat not actively maintained, but it did solve my problems some time ago…

valerauko10:06:46

buddy's pretty solid

alvina12:06:56

hello i have heard clojure over elixer or vice versa

alvina12:06:41

but i figure out that elixir is a lisp {:if, [], [{:!, [], [true]}, [do: {{:., [], [{:aliases__, [], [:IO]}, :puts]}, [], ["this should never be printed"]}]]}

alvina12:06:41

is there any thing possible like clojurescript on javascript

alvina12:06:40

clojureErlang on elixir

alvina12:06:49

or we can name it clojurE

alvina13:06:56

as rich said making language is easy

alvina13:06:07

making something like phonix, crdts should be harder than making clojureE

valerauko13:06:25

could someone help me with logging in aleph?

yonatanel12:06:16

I use a combination of timbre related packages to make aleph talk. Check these out:

[com.fzakaria/slf4j-timbre "0.3.7"]
[com.taoensso/timbre "4.10.0"]
[timbre-ns-pattern-level "0.1.2"]
[ring-logger-timbre "0.7.6"]
[yonatane/timbre-json "0.1.2"]
Plus something similar to this configuration:
(timbre/merge-config!
    {:output-fn yonatane.timbre-json/output-fn
     :middleware [(timbre-ns-pattern-level/middleware {:all :debug
                                                       "org.apache.kafka.*" :info
                                                       "org.mongodb.*" :info
                                                       "io.netty.*" :info})]})

valerauko13:06:53

thanks! in the end i went with the default logger

valerauko13:06:20

i didn't have logback's config file on the classpath which made it log everything

valerauko13:06:32

i'll try timbre in my next project!

valerauko13:06:46

is there a way to make it work with the ring-logger lib?

alvina14:06:09

i have seen that, you have implement this from grounds up

alvina14:06:15

i am talking about

alvina14:06:40

using elixir macro expantion

cmal15:06:43

Hi, why this java interop not compile in clojure?

> (java.util.List/of 1)
CompilerException java.lang.IllegalArgumentException: No matching method: of, compiling:(*cider-repl clj-demo*:149:16) 
the java doc is here:

tcrawley15:06:18

@cmal what version of Java are you using? I believe that method was introduced in Java 9

cmal15:06:21

Thanks! I've been using java 10, but maybe cider-jack-in starts lein in java 8. Thanks for reminding me of that!

dpsutton15:06:36

Cider just calls lein. It will do whatever Java gets invoked from there unless the path for you emacs doesn't include your different versions of java

manas_marthi16:06:37

@kulminaator How about doing a performance comparison between timbre and Log4j-2. Log4j2 claims superior performance over log4j. Not sure how it compares with timbre.

lilactown16:06:51

wow I had no idea how deeply ingrained the @ macro is

lilactown16:06:47

you can’t even use a symbol with @ in it AFAICT

sundarj16:06:23

@lilactown it's a reader macro; it happens at read time:

=> (read-string "@a")
(clojure.core/deref a)

sundarj16:06:24

also @ isn't allowed in symbols according to the edn spec: https://github.com/edn-format/edn#symbols

cmal16:06:46

Changed to java 10. These still not work:

(List/of 0) ;; => [0]
(List/of 1 2 3) ;; => Method
   java.util.List.of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/List;
   must be InterfaceMethodref constant
(List/of (Integer. 1)) ;; =>  Method java.util.List.of(Ljava/lang/Object;)Ljava/util/List; must
   be InterfaceMethodref constant
(List/of "s") ;; =>    Method java.util.List.of(Ljava/lang/Object;)Ljava/util/List; must
   be InterfaceMethodref constant

cmal16:06:22

maybe, I've just read this. Not quite understand this. Thanks.

ajoberstar17:06:54

Yeah, the one I linked to looks to be a duplicate of that one.

cmal17:06:35

:thumbsup:

jcr17:06:19

Wait, do you need to sign CA to contribute to the site too?! Oh come on, you gotta be kidding me!

bronsa08:06:14

contributing to the website uses github PRs instead of Jira issues

marlenefdez17:06:01

Hi everyone, part of my code requires me to write a function that returns a list of 26 empty lists. Right now I have (conj [] (repeat 26 [])) which I think is returning a list of sequences of list...is there a straightforward way to create a list of empty lists and have the code look that simple and clean?

mfikes17:06:51

@marlenefdez I would just (repeat 26 ())

mfikes18:06:53

If you want vectors, (vec (repeat 26 []))

marlenefdez18:06:11

@mfikes perfect, thank you!

imetallica18:06:04

Hi folks, question: is clojure a good fit for soft real time systems?

imetallica18:06:35

Better yet: is the JVM a good option. I know I could use Erlang, but we have settle on using Clojurescript on frontend.

gklijs20:06:13

I know from experience near real time alerting is very good possible on the JVM. But I don't really understand your question. It seems to be about back end, but then you mention Clojurescript.

imetallica20:06:48

We are evaluating between Clojure/Elixir for the backend. My question is: is Clojure viable for soft realtime systems? Is using Immutant together with Wildfly a good choice for building clustered apps, or should we go the Elixir/Erlang, or another Clojure stack path?

gklijs21:06:29

Not sure what would be the best way to run Clojure. But I don't see any reason it wouldn't be viable.

manas_marthi21:06:00

Elixir/Erlang is meant for fault tolerant systems not real time systems

manas_marthi21:06:26

you can use native compilation of erlang to speed up.. but general advise is not useful. you will have to figure out your load, response time, throughput requirements and see if elixir or clojure would suit the requirement.

manas_marthi21:06:43

There is a book on how to make clojure code run faster and comparable to java code.

imetallica21:06:25

Elixir/Erlang is meant for fault tolerant and soft realtime systems @U7ANZ2MTK. 🙂

manas_marthi21:06:46

There are many issues to be considered, how many concurrent users you have

manas_marthi21:06:52

what is the response time required

manas_marthi21:06:02

how cpu intensive your tasks are etc..

imetallica21:06:03

Low latency is a must.

imetallica21:06:19

And it's all about IO.

manas_marthi21:06:29

In summary only you can answer the question by doing a proof of concept..

imetallica21:06:32

Yeah, but I wanted to have a direction for Clojure, because in Erlang the path is more straightforward.

manas_marthi21:06:01

Use clojure for your app with proper tuning as I mentioned earlier, and if there are any cpu intensive parts, write them in java.. Use Java9 AOT compilation to generate native code..

manas_marthi21:06:33

That's one path I can think of

imetallica21:06:27

So, I can use Java 9 with lein directly now? I tried a few months ago and I was having issues with Leiningen loading the classpath.

manas_marthi21:06:04

no idea about the issues, but if lein doenot work try boot

imetallica21:06:16

Will give a shot, thanks. 🙂 Will try Immutant and Wildfly for clustering as well.

manas_marthi21:06:31

Elixir is 7 years old. Clojure has a history of 10 years and it works on JVM. There are a large number of java libraries and clojure libraries

manas_marthi21:06:39

do you have enough elixir libraries

manas_marthi21:06:56

for your use case?

imetallica21:06:21

Elixir is 6 years old and yes, I do.

manas_marthi21:06:33

just looked it up in wikipedia

manas_marthi21:06:46

corrected my statement above

manas_marthi21:06:37

books: Clojure: High Performance JVM Programming by Akhil Wali, Shantanu Kumar, Eduardo Díaz Clojure High Performance Programming - Second Edition: by Shantanu Kumar

imetallica21:06:40

Thanks for the references, I'll take a look at them

tbaldridge23:06:16

Soft real-time on the JVM is pretty much the same as any GC’d app. You need to define your goals, keep heap sizes small, and reduce allocations. All of that is very possible on the JVM. You also need to try the two GC implementations available.

tbaldridge23:06:45

And realize that the JVM blows Erlang away in terms of raw performance

imetallica00:06:45

Yes, but @U07TDTQNL does clojure offer a way to achieve this without deviating from the "clojure way of doing things"?

tbaldridge00:06:35

Sure, as much as Erlang does. Maybe even more so

tbaldridge00:06:17

The JVM supports zero copy networking for example, where packets are never copied out of the network buffers.

tbaldridge00:06:03

Pedestal has some code that does that, it reads HTTP data directly from packets, allowing for zero copy http services.

imetallica00:06:45

Right, I'm not that familiar with Pedestal though, when I started using Clojure at my current job (a few months ago), I went straight into Luminus. I might investigate it. My point here is: Erlang makes almost effortless building low latency software, and since that's my background I'm trying to figure out how to achieve this in Clojure, since it's a requirement for my project. What I need is low latency and it's quite hard to find good stacks that take this in consideration on the JVM (maybe I'm missing something?). I'll give a shot at pedestal though.

tbaldridge00:06:49

But a lot of this depends on what it is that you are building

tbaldridge00:06:42

Low latency isn’t really the same as real-time though

tbaldridge00:06:29

And it depends on what the Latency is measured as. Is it acceptance of a message, durability, or something else

tbaldridge00:06:03

And in my experience this stuff isn’t super easy in Erlang either. Messages get dropped, processed crash, mailboxes backup and system have unexpected bottlenecks.

imetallica00:06:59

Well, when you talk about distributed Erlang yeah, that's an issue. When we speak about reliability it also comes with how you deal with the overall architecture of your system, not only with your stack. But when we talk about moving data from this websocket, handle some rules via pattern matching, and broadcasting it to channels, receveing on the other point via pubsub, Erlang is the king. My point is: the behaviour of Erlang's GC is more predictable than JVMs', which means I can care less about erradic jumps on latency.

mpenet11:06:48

with erlang unless you know very well how it works, and it takes a while, you're likely to shoot yourself in the foot in one way or another. If you know the model well it can be very powerful tho.

mpenet11:06:53

then in terms performance or long as we're talking network io latencies are prolly quite similar, both vms are heavily optimised

mpenet11:06:15

ex last time I check http servers written in erlang vs java where in the same ballpark in terms of performance

ikitommi14:06:36

not sure how much that counts, but in Techempower Web Framework Benchmarks Clojure seems to give much better perf than elixir/erlang. Might just be about configuration.

mpenet14:06:33

There was an article where raw nginx and erlang were compared and had similar numbers. Very often benchmarks lie anyway, ex lua frameworks where 99% of the work is actually c, or the same for clojure/java. In this case both vms have very different caracterisics, that should drive the decision, not "x is faster" imho, there's no number crunching involved ;)

imetallica21:06:01

These techempower benchmarks are quite unrealistic, imho.

☝️ 4