This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-01
Channels
- # announcements (3)
- # beginners (59)
- # calva (23)
- # cider (58)
- # clojure (125)
- # clojure-dev (18)
- # clojure-dusseldorf (1)
- # clojure-europe (21)
- # clojure-germany (1)
- # clojure-hamburg (1)
- # clojure-italy (13)
- # clojure-nl (29)
- # clojure-poland (3)
- # clojure-spec (61)
- # clojure-uk (74)
- # clojurescript (12)
- # core-async (6)
- # cursive (4)
- # data-science (7)
- # datomic (14)
- # defnpodcast (1)
- # events (4)
- # fulcro (72)
- # juxt (36)
- # kaocha (3)
- # nginx (3)
- # off-topic (14)
- # pathom (5)
- # ring-swagger (68)
- # shadow-cljs (25)
- # spacemacs (8)
- # sql (42)
- # tools-deps (8)
- # vim (6)
newb here w/ an aot question. i'm compiling a (defrecord Foo ...)
producing a jar containing the Foo.class
then depending upon that jar from a java project
i can successfully load Foo.class
(ie, Class.forName("Foo")
) dynamically from the java project
but attempting to compile/`javac` statically against Foo (ie, import Foo
from java), i get a compile error that the symbol can't be found
javap Foo.class
shows nothing suspicious. maybe something obvious, but i'm banging my head here..
Is there a package? I can’t remember for sure, but I think Java disallows using the default package.
java doesn't disallow it, it's just discouraged
maybe post the full compilation error?
https://stackoverflow.com/questions/283816/how-to-access-java-classes-in-the-default-package
it seems clear it’s properly set for the java
command (since you’re able to access it via reflection), but it could be improperly set for the javac
command
this yields a successful compile/javac:
import com.example.*;
class Bar { public static void main(String[] args) throws Exception { System.out.println("hello"); } }
this doesn't:
import com.example.Foo;
class Bar { public static void main(String[] args) throws Exception { System.out.println("hello"); } }
this compiles and runs w/o exception:
import com.example.*;
class Bar { public static void main(String[] args) throws Exception { System.out.println("hello"); Class.forName("com.example.Foo"); } }
Like I said, the last one is mostly irrelevant. It says nothing about the compilation.
and...
$ javap com/example/Foo.class
Compiled from "model.clj"
public final class com.example.Foo implements clojure.lang.IRecord,clojure.lang.IHashEq...
a javac
/ static compile finds import com.example.Foo
and doesn't like it b/c com.example
is a class
...this explains why the .forName("")
worked and not the static compile
...okay so i do have a (:gen-class)
on the (ns com.example)
so perhaps a slightly or much less common sitch?
after many years of java coding i did not realize you couldn't safely have a package and class w/ the same name
...
com/example.class
com/example/Foo.class
...
^bad for javac apparentlyremoving the (:gen-class)
fixes the issue
i guess the lesson is don't :gen-class
ns's containing defrecord
's?
Hey guys, I asked thi sin disc but none seems to know what's going on. I'm getting:
SEVERE: Error creating DB connection for {:classname "com.mysql.jdbc.Driver", :subprotocol "mysql", :subname "//<ip>:3306/proj_dev", :user "root", :password "A<censored>"}
java.sql.SQLException: No suitable driver found for jdbc:mysql://<ip>:3306/proj_dev
for migratus when running lein migratus migrate
the db is completely empty, first time trying to migrate anything
With this in project.clj
:migratus
{:store :database
:migration-dir "migrations"
:db {:classname "com.mysql.jdbc.Driver"
:subprotocol "mysql"
:subname "//<ip>:3306/proj_dev"
:user "root"
:password "*"}})
I'm not sure what I'm doing wrong
I have connected to the server with MySQL WorkbenchHi every one, I wrote this utility as an alternative to with-redefs
such that the redefinition is done only on that thread and not others (ie, the global definition remains the same and redefinitions are per-thread). This is a fork from @gfredericks’s original solution https://gist.github.com/gfredericks/7143494.
Would appreciate if you could check it out to suggest improvements/corrections: https://gist.github.com/mourjo/c7fc03e59eb96f8a342dfcabd350a927
cc @h0bbit
Hmm. Has anyone else noticed a really slow startup times with lein repl
when using JDK12?
My REPL timeouts almost always with JDK12, maybe 1 out of 10 succeeds to connect. With JDK10 it works normally
there was a performance regression regaring user.clj that 1.10.1-beta1 addressed: https://dev.clojure.org/jira/browse/CLJ-2484
hi all, i'm looking for a good API client HTTP project for reading the source code and design as muster
do you have any example in the clojure
ecosystem and lib in the opensource word? like it could be dunno, any library with rest-client
Anyone using nginx-clojure and got it running with openjdk 10+? Project doesn't really seem maintained anymore.
I use nginx-clojure but i think it doesn’t handle java versions above 8 right now. I don’t think there’s much active development happening but it’s been stable for us.
Or perhaps someone can advise a better deployment method these days, with high performance?
Real time bidding, just want to squeeze out as much performance as possible, and nginx-clojure had decent benchmarks.
most of the time aleph or jetty is good enough. Not sure nginx-clojure performs better at all
You're probably right, the difference isn't extreme https://github.com/ptaoussanis/clojure-web-server-benchmarks/tree/master/results/60k-non-keepalive#60k-non-keepalive
Hey guys, I just downloaded clojure via the installer for windows (it downloaded as powershell module). I need help getting it started.
Please ask in #clj-on-windows for help...
aleph also scores better than openresty (same models as nginx-clojure I think) on other benchmarks, anyway I bet the kind of platform you're building will likely not have a bottleneck at this level
Anybody have experiences to share using Akka with Clojure? I found a couple of small wrapper projects which look inactive. My main concern would be around the requirement that actor classes be serializable, so I'd think you would have to be cautious about typical Clojurisms like grabbing state in a closure.
I was trying to point some of my users at the Clojure documentation to show all the options for spit
, and hit a brick wall. The spit
doc string does not list them, https://clojuredocs.org/clojure.core/spit and even if they are resourceful enough to look up the entry for writer
that does not list them. I basically would need to teach them how to bring up a REPL and spelunk through the source code in order to get a definitive list. And they are mostly not software developers. This seems… unfortunate?
jira welcome, I don't think there is one I'm aware of
OK, I created one. I forgot that I even had an account on the JIRA. Thanks! Hopefully it was formatted correctly and sufficiently informative.
Wow, that was fast! 😄
easier to do it now before I forget about it :)
I'm looking for a way to manage state reactively, where the crucial thing is that invalidations are eager and computing the new value is lazy (ie. on deref)
I was thinking an agent with for each chunk of state I care about, that eagerly invalidate their listeners. but how can I override the deref behavior?
does this match the semantics of a cache at all? with core.cache you can easily get custom access / lookup behaviors
(while storing the cache itself in an atom, agent, whatever's apropriate)
hm, I wasn't thinking of it in terms of a cache at all. it's not a typical cache, but perhaps I could (ab)use hundreds of 1-element caches for this.
the use case is a large reactive system, containing many hundreds of entities and links between them, but where only a handful of entities are "live" at any given time.
if the invalidations are eager, the views for the few things that are live will know they need to rerender. meanwhile, the rest of the world might be invalid but that's harmless.
hmm, sounds a lot like what react does under the hood actually
not dissimilar in principle.
what's the difference between "hundereds of 1-element caches" and "a cache with an index"
depends on whether invalidation happens at the entry level or the cache level, I guess. I'm reading the core.cache docs now.
I guess you'd need it loop it through - the cache forcing function would need to look up its data sources in the cache and invalidate it's descendents? now that I think about it you probably want a proper reactive system and not hacking it direclty out of cache / agent building blocks(?)
well, I mentioned agents because that's what it felt like when I was vaguely thinking about it last night. but I think there's a bunch of extra bookkeeping to do that pushes me to use a default implementation. I'll probably end up building each reactive block out of a handful of refs I transact over, I guess.
there's a whole book about this btw https://www.amazon.com/Clojure-Reactive-Programming-Asynchronous-Applications/dp/1783986662
it uses rxjava iirc
it uses rxjava, futures, and core.async in various examples
react, if I understand, doesn't actually use caches(so avoids figuring out cache invalidation), but diffs the virtual dom to determine what needs doing
yeah, by extension you could use it to turn data dependency in a data flow app into smart invalidations, but that's still a stretch I think
for my purposes, the wiring of dependencies is explicit, so I don't need to infer it. I just want to avoid having to unwire and rewire things as the user navigates.
anyway, I'm just building a prototype, so I'll just hack something together and not sweat it too hard for this first POC.
assign method implementations that all throw unimplementederror?
afterwards I realise I don't want that implementation to include hash maps, so I change that to a clojure.lang.Sequential
how do I disassociate Seqable
so that calling a Foo method on a hash map falls back to the default Object
implementation?
@qythium the extension of the method is stored with the protocol implementation (iirc in the var itself or its metadata) and can in theory be removed, I don't know if there's anything that would be portable though
@qythium this should be enough info for a short term hack, but no promises it would work with the next clojure release
(ins)user=> IFoo
{:on user.IFoo, :on-interface user.IFoo, :sigs {:frob {:name frob, :arglists ([this]), :doc nil}}, :var #'user/IFoo, :method-map {:frob :frob}, :method-builders {#'user/frob #object[user$eval145$fn__146 0x42f33b5d "user$eval145$fn__146@42f33b5d"]}}
(ins)user=> (extend Object IFoo {:frob (fn [x] [:obj x])})
nil
(ins)user=> IFoo
{:on user.IFoo, :on-interface user.IFoo, :sigs {:frob {:name frob, :arglists ([this]), :doc nil}}, :var #'user/IFoo, :method-map {:frob :frob}, :method-builders {#'user/frob #object[user$eval145$fn__146 0x42f33b5d "user$eval145$fn__146@42f33b5d"]}, :impls {java.lang.Object {:frob #object[user$eval162$fn__163 0x3e14c16d "user$eval162$fn__163@3e14c16d"]}}}
usually protocol / interface / multimethod changes are the one reason I do an unconditional repl restart, and I try to work on my design in such a way that those would change extremely rarely (which makes sense, as they are all meant to be top level entry points for other code)
tried doing (def Foo (update Foo :impls #(dissoc % clojure.lang.Seqable)))
, but that didn't work
guess I'll just have to restart the repl.. had lots of "testing data" state built up from evaluating commented forms which I didn't want to lose, but that's probably another sign of general sloppiness
I'd suspect alter-var-root
rather than def/update to be the right path, if anything worked
protocol choices get baked into per-call-site caches so it's probably difficult to do this fully without restarting your repl
Hello, I’m having some issues working with mutable Java arrays and can’t find what is going on.
This code is supposed to return 5
but returns 0
(let [m (to-array [0 0 0])
_ (for [i (range 3)]
(aset m i 5))
x (aget m 2)]
x)
;; => 0
Now, when I eval it one form at a time it correctly returns 5
(def m (to-array [0 0 0]))
;; => #'user/m
(for [i (range 3)]
(aset m i 5))
;; => (5 5 5)
(aget m 2)
;; => 5
Maybe I’m missing something obvious :thinking_face:classic laziness. for
returns a lazy collection and is not a good choice for performing side effects like mutating an array. What you are seeing is that nothing is realizing the collection so no work is ever done. the result is that the original array contains 0s rather than 5s
> if the invalidations are eager, the views for the few things that are live will know they need to rerender. meanwhile, the rest of the world might be invalid but that's harmless.
@braden.shepherdson isn't this how some CLJS view libs work? E.g see Reagent (`reaction` and ratom
), Rum (reactive components and derived atoms), hoplon+javelin, etc.
hey guys, whats the cleanest way to append something to the end of a vector within a thread last macro
Are there any compelling reasons to prefer the loop
and recur
pattern over recursive function calls?
@yedicould be the case for as->
instead of ->>
@yedi I don't understand why you say your first example doesn't work, this works for me:
(let [c [1 2], v 3] (->> v (conj c)))
=> [1 2 3]
Oh, v is the vector not the value. Never mind.
@yedi ->> and as-> are written so they can be nested inside ->
you can use -> at the top level, and use ->> / as-> for parts of the pipeline inside that need to use the tread-last behavior
user=> (-> [] (conj [:a 0]) (->> (into {})))
{:a 0}