This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-21
Channels
- # beginners (38)
- # boot (88)
- # cljs-dev (142)
- # cljsrn (2)
- # clojars (1)
- # clojure (107)
- # clojure-berlin (2)
- # clojure-italy (8)
- # clojure-russia (76)
- # clojure-spec (325)
- # clojure-taiwan (3)
- # clojure-uk (28)
- # clojurescript (80)
- # clojurewest (2)
- # core-async (36)
- # core-logic (1)
- # cursive (21)
- # datomic (16)
- # dirac (18)
- # docs (2)
- # emacs (1)
- # euroclojure (3)
- # garden (3)
- # gsoc (2)
- # hoplon (3)
- # immutant (4)
- # jobs-discuss (16)
- # lein-figwheel (5)
- # liberator (17)
- # lumo (19)
- # off-topic (2)
- # om (20)
- # onyx (28)
- # pedestal (50)
- # planck (4)
- # re-frame (5)
- # reagent (3)
- # ring-swagger (13)
- # spacemacs (1)
- # specter (43)
- # testing (3)
- # timbre (3)
- # uncomplicate (1)
- # vim (2)
- # yada (4)
Always got to qualify statements of "x is faster than y"....apply vs not apply doesn't really matter in the face of something like (assoc {} :a 42)
A lot of stuff we do in Clojure is orders of magnitude more expensive than apply
thanks for the perspective
apply was optimized in 1.9 and is often much faster now btw
But not faster than not using it :)
@devn you mean like this: (defn evil-first [coll] (if (= (count coll) 1) (first coll) (throw "not exactly 1 item in coll")))
Your periodic reminder regarding fast and slow code: 1) Unless you've proven that a certain piece of code is the bottleneck, optimize for readability, not speed. 2) If your code "goes over the wire" you've lost and the only thing to optimize is how many times you're going over the wire. 3) this might not apply if you're writing a library where use cases are unknown or if you're the creator of Clojure.
@slipset: what do you mean by “goes over the wire?” Haven’t heard that turn of phrase before.
This is now a superstupid question, but: I have a clojure hashmap and want to have it in json format. Using cheshire.core generate-string, it is all in string then naturally and all quotes are escaped. How can I get a better json representation without the escaped quotes?
@camdenclark for frontend, I mean contacting the server, for your server contacting e.g. a database. Going over the wire then means accessing the network.
I see, that’s what I thought but wanted to make sure.
@leena ... What do you mean by 'better json representation?' To me it looks like JSON needs the double quotes around its keys. If you write a json string "{\"FOO\":\"bar\"}" to a file, the escape backslashes are gone...
My use case is pretty daft as well 🙂 Playing with REPL, and just want to get the json copied from there
@leena ahh. You could easily write it to a file (spit "myfile.json" "{\"FOO\":\"bar\"}")
and then copy it from there..
Can anyone explain the presence of/usage of 'edn' in clojure ? How to use them? When to use them? Basically, what are they?
hey just curious, anyone out there using Clojure right now for API / service bus work? if so, ping me!
Whats the most performant/idiomatic way of join a sequence of sub-sequences?
((1 2 3) (4 5 6)) => (1 2 3 4 5 6)
?
mapcat
where you return the element?
Okay, ill try benchmarking these methods, both seem more expressive.
Very true, in this instance, laziness is not required, dealing with small sizes of coll, but ran often.
Anyone have any insight into progress being made on a statically compiled CLJ program? I'm imaginign it would be implemented underneath in golang, so I already have an extension
.cljg
In my environment - I need stand-alone that aren't too large. I was imaginging that one could create a clojure-go program that would compile into a static binary.
any ideas - any google search topics? I did a little searching, but... Maybe it's an intractable idea?@caryfitzhugh If you're willing to package your app like an old-style java app (i.e. deal with setting up the classpath outside of your application in some shell script in the deployment environment), you can have a rather small jar.
Still requires java I believe?
When I am making docker containers there is the desire to keep them teeny tiny. Hence my desire to static compile it...
if not, you could create two layers to your docker container. One with the base java layer, one with your dependencies layer, and then deploy your clojure app on top of that
the way your build task would end up, you'd have the java container, and then whenever your project dependencies changed, your dependency layer would get rebuild, and then you'd have an application layer that would change often (but shouldn't be very large, seeing as it's just your resources and clj files)
There are a number of approaches, but to sell it to the team, putting the jre on the machines is probably a non starter. Or downloading to a client machine. Oh well. Maybe I will win the lottery and have a year to implement. :P
good luck. tbh, the boot script or leiningen task for what I described shouldn't really take more than a day or two if you have some familiarity with docker
Me doing it isn't the problem. I can do it. Yes, exactly. The external dependency is the kicker.
Because people have a tool with no dependencies. So it is hard to sell another tool which does have one
Even if you could compile Clojure to Go, I doubt it will be fast. There's a lot of stuff required by a functional language that Go just simply doesn't have.
I could imagine something like that really stressing Go's virtual dispatch and GC past the limits for which it was designed.
I made a small JDK 9 linked-module app that gutted clojure.core a bit -- runs as a static executable, 45MB
But I really have to question your problem constraints @caryfitzhugh
Hence my favorite saying: "You say X is faster than the JVM? Is it parallel, GC'd, dynamically JIT'd, dynamically typed, capable of handling tens of GB of data? If not...it's apples to oranges..."
I like go for the most part, but it doesn't do dynamic load, which is nearly necessary for Clojure
No tool has 0 dependencies -- at least a container is a way of encapsulating them properly
Not saying it would be golang. Just exploring trying to combat an objection people will bring up. Dropping a go binary on a 5mb alpine image is pretty lightweight. And downloading a go binary to a user's machine is light. Just wondering about any progress or not in that arena.
Maybe give people the benefit of the doubt with respect to their prejudice. Most appropriate tool for the job should be the one employed. If that's clojure, great
If you had everything Clojure offers in a go binary it wouldn't be 5mb
the reason go binaries can be so small is that they don't contain a lot of logic. Start adding in persistent structures and that gets pretty big pretty quick
memory and HDDs are cheap...my time is not
I personally enjoy light containers... But 250MB and 5MB are in the same order of magnitude for me.
https://www.tensorflow.org/api_docs/java/reference/org/tensorflow/package-summary <-- apparenlty tensorflow now supports java. anyone working on a clj library for it?
@caryfitzhugh what about a minimized cljs app and a small js runtime?
that’s probably less work and more results than most alternatives if you want something relatively lightweight with clojure features
there’s also a great tiny language called pixie that is its own vm and is not compatible with clojure, but very similar
it’s about the size of bash
it's fine - not trying to boil the ocean. 🙂 I may take a look at pixie though. I'm working in a group that wants to do micro-services and really likes their minimal images - while I agree on the ideas of developer time, etc. I'm not the one that needs convincing... 😛 thanks for the comments.
yeah- pixie is very simple, has immutable data structures, it is probably right up your alley (except not nearly as much library support unless you start doing host interop with your OS libs…)
immutable FTW 🙂
is there a way to do bitwise operations on bigints?
also it prints out a pretty fractal in ascii when you compile it
@greg_arcara looks like no https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/BigInt.java
@noisesmith thanks, just wanted to verify I wasn't missing something
it has a toBigInteger method to make biginteger, which does have bitwise methods http://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html
thanks
the source for the conversion makes it look like the conversion is super cheap - I guess the bigint class must exist for hash and eq reasons
yes, I think I read that it's for hash and eq reasons
Pixie is also in the 16MB range last I checked, and if you run a significant program it can easily hit 100-200MB of memory usage.
@tbaldridge btw, why Pixie, but one more Clojure like ClojureScript or Clojure CLR?
A lot of pixie was a deep-dive into how far we could leverage immutable data in a custom VM. Turns out it's really hard, (due to quite a few things that would take too long to go into here). So from the start the idea was that I wanted to be able to warp Clojure semantics where it was advantageous to the JIT.
I see, but does it makes sense to have it just on top of Python runtime?
@tbaldridge - I'm interested to know more about why that's hard. Is there a blog post or something about that somewhere?
So the problem is this: Tracing jits work best on straight-line code where one branch of an if is almost always taken, or where the type in a given position is almost always the same.
with that in mind, look at something like this: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentHashMap.java#L551
and realize that assoc on a PHM node is polymorphic, so you end up with something like 5-6 conditional jumps per assoc, where each and every one of them are true or false based on the number of items in the assoc.
So it turns out the type of JIT that works best for that sort of work....looks a lot like HotSpot.
Interesting, thanks for explaining! I don't have much background on JITs (and hadn't heard of a tracing JIT until just now), but I see what you mean about conditionals making things difficult.
I think Clojure on top of the PythonVM is possible, and I've done some work in that area, but I just don't have time (or energy) for the work anymore.
Is there a way to automatically shut down a repl that hasn't had any input or output for some period of time?
sounds like a fun weekend hack nrepl plugin
in my project.clj
I have :repositories [["private" {:url "s3://..."}]]
and I have a checkouts
folder with a sym link to a dependency which I develop locally
but when I lein repl
, it tries to load my local dep from the "private"
repo...
how can I force it to look in checkouts
?