This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-19
Channels
- # aws (4)
- # aws-lambda (2)
- # beginners (67)
- # boot (38)
- # cider (32)
- # cljs-dev (12)
- # cljsrn (2)
- # clojars (2)
- # clojure (190)
- # clojure-chicago (1)
- # clojure-dusseldorf (2)
- # clojure-germany (1)
- # clojure-greece (3)
- # clojure-italy (5)
- # clojure-russia (6)
- # clojure-spec (47)
- # clojure-uk (10)
- # clojurescript (59)
- # cursive (9)
- # data-science (14)
- # datomic (24)
- # devops (16)
- # emacs (8)
- # fulcro (25)
- # graphql (30)
- # hoplon (123)
- # juxt (15)
- # lambdaisland (2)
- # leiningen (4)
- # luminus (6)
- # lumo (9)
- # off-topic (11)
- # om (7)
- # onyx (8)
- # re-frame (14)
- # reagent (5)
- # ring-swagger (5)
- # shadow-cljs (46)
- # spacemacs (41)
- # specter (8)
- # testing (8)
- # unrepl (31)
- # yada (18)
I see Phil is quite the evangelist for that position -- running counter to many others in the Clojure community, including Rich š
(and that is from three years ago -- with no action taken in Kibit I believe? š )
More because of laziness than anything else š
and 5.5 years ago
Ah yes, the last comment -- yours -- came two years after the previous one!
that Kibit warning is actually what introduced me to the notion that when
might be preferable to an if
with no else clause, because the codebases I was working on never used when
Interesting. I'd always used when
for a single branch, instead of if
, and until today (yesterday?) I'd never heard the argument that there was any connection between when
and side-effects.
Maybe I just followed the lead of the code in clojure.core
?
I learned Clojure on a job where the prevailing style was a little different than what Iāve seen in the wild. Tools like Kibit, Eastwood, clj-format, etc. are very valuable for discovering ābetterā practices. Iāve learned a ton from static analysis tools in other langs too.
Very true in java also, hooking up some code analysis to my hobby project just got a higher priority.
Question: How do I invoke a java method when I have it's hame as a clojure symbol ? 1. I have java class Foo 2. I do (:members (clojure.reflect/reflect Foo)) -- I get a list of members. 3. I do (:name (first (:members (clojure.reflect/reflect Foo))))) -- I now have the name of one of the functions, as a clojure symbol. 4. How do I invoke this? 5. Normally, I would do (.memberFunc Foo ... ) -- but right now, I have a var in clojure, whose value is memberFunc -- how do I invoke it ?
G'day! I've been trying to pull a text file from S3 using clojure.core/slurp
, passing in a URL that contains a username & password element (e.g.
). It looks like slurp
drops the username and password though, as I'm getting back 401s.
Hitting the same URL from the command line (via wget
) works fine, so it's not an issue with the URL. Any pointers?
@deactivateduser10790: java problem š
Sigh. Java can be so lame at times. Given some of the simple solutions described there, that donāt add new dependencies, is it worth submitting a patch for slurp?
@deactivateduser10790 for anything more serious including authentication you should use something like https://github.com/dakrone/clj-http
Thanks. Yeah Iām well aware of clj-http (I use it elsewhere), but in this case preferred slurpās flexibility around supporting local file paths or URLs.
Planck 2.8.1
ClojureScript 1.9.946
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Exit: Control+D or :cljs/quit or exit or quit
Results: Stored in vars *1, *2, *3, an exception in *e
cljs.user=> (require '[planck.core :refer [slurp]])
nil
cljs.user=> (slurp "")
Is there a way I can connect to a running JAR. Is socket server repl the way to do it? I want to run a JAR and then connect to it using a REPL and then be able to redefine some function or debug something in the function
Hi, some one know good stack for work with reactive (choreography) architecture in clojure?
@xtreak29, yes the socket server is built for that. Also check out https://github.com/Unrepl/unravel
@pesterhazy Thanks :thumbsup:
this is a sanity check, as something is not working as expected: (.field-name SomeClass) should also work if field-name is a field name of a Superclass of Someclass right ?
Mostly web
Can you tell me about your expriences ? I think, I am going to create my own company. In four weeks. But I am scared. I have strong abstract background. But less practice.
@U3JJH3URY well the question is a bit vague š are you afraid of starting a company, or just of choosing Clojure for it?
Clojure is unique. But I can choose a lot of platform and technologies for my company. Quick answer is: I am not sure what Iāll be faced with clojure ? Itās a rabbit hole. I think I need real world expriences for that choice. What is your opinion ? What are your expriences ?
Migrating to Clojure was a tremendous success for us, after migrating to it from Node.js we gained huge and predictable productivity and quality, resulting in much more focus on business and a competitivity advantage. Some of our customers once told us "wow, you guys must gave at least 12 developers", when there was only 2 of us.
@U3JJH3URY For us, most of the benefits came from REPL based development, access to Datomic, and general expressivity of the language.
One thing I have not experienced yet is hiring, but I take it as a good sign, as I have not needed to hire at all. Most of the feedback I got from more experienced Clojure CTOs was that the hiring situation is pretty good, as you don't need to hire a lot of people, the candidates you get tend to be skilled, and Clojure provides a good argument for retention. So I would not worry too much about that.
I don't think that Clojure is the best choice for any startup though. Here are some ideas to help you decide:
Omg. So cool. But. What about hiring ? I am living in Turkey and I think, Iāll be all alone for a long time. Maybe a few small projects. Just waiting and lookin for clojure developer. And also, what about your library selections ? Your company relay on community based libraries, right ?
1. Clojure shines for making custom solutions, not for following conventions. Only use Clojure if you have enough 'architectural initiative'.
@U3JJH3URY see my previous comment. Also, don't count on hiring experienced Clojure, just plan on teaching them on the job. It will be fine, Clojure is easy to learn.
2. The more difficult the technical problems you solve, the more likely Clojure is to be relevant. (Modern web apps with non-trivial UX count as hard problems)
Re libraries, mostly Datomic, http-kit, Ring, compojure, prismatic/schema, manifold, and scope-capture for tooling (disclaimer: I'm the author of that last one). If I had to start over though, I'd probably change to use Yada, Aleph, and Lacinia.
maybe @U0509NKGK or @U052E4LPH will want to pitch in š
what val said š https://www.infoq.com/presentations/Clojure-powered-Startups is relevant for you, @U3JJH3URY. itās 5 years old, and (like much of Clojure thatās 5 years old) totally relevant.
These are gold informations for me. So do you guys have anything to tell me under any other topics ? Like Dev-Ops, Design Patterns ?
I've found "Web Development with Clojure" to be very instructive for practical matters, although I disagree with the author about several technological choices.
Me too. OMG. I am sure you have another opinions about that book. Also I have. But I agree with you.
What are the most valueable libraries in this very moment ? What do you think guys ? What is your companiesā selection on every type (Db, Auth, etcā¦)
how would you run clojure app with nginx ? (proxy_pass and supervisor)
same as Java I guess? There must be a lot of material for Java out there
ok, cool
@qqq @rauh Hmm, so Reflector
is bad... Alright, there you go
(let [s "String"
m 'getBytes]
(eval `(. ~s ~m)))
š@aisamu: I don't have the names upfront, I have to query the JVM to get the names š // I guess this can be done at macro expansion time, but I'd prefer to avoid amcros if possible.
@qqq You definitely want to avoid macros there... I should have put more š 's at the end!
using reflection is a much better solution if you actually need this, which you shouldn't
(r/reflect Stream$StreamCanBuildFrom)
{:bases #{scala.collection.generic.GenTraversableFactory$GenericCanBuildFrom}, :flags #{:public}, :members #{#clojure.reflect.Constructor{:name scala.collection.immutable.Stream$StreamCanBuildFrom, :declaring-class scala.collection.immutable.Stream$StreamCanBuildFrom, :parameter-types [], :exception-types [], :flags #{:public}}}}
How do I call the constructor on the above? Please give me the exact line, as I have been getting errors.@qqq don't think you're going to get a good answer to that. Scala mucks with Java types a lot. Probably better to write this interop code in Java, or to call Clojure from Scala.
The latter probably being the cleanest way. Clojure's java API is much cleaner than Scala's
Iām starting a new Luminus project this morning, it comes with a lot of great stuff out of the box but I donāt want to write all my CREATE TABLE
statements by hand
Luminus uses migratus, I believe
but I donāt think it reverse-engineers your db/model for you
Donāt be afraid of writing them by hand. Less can go wrong if you do semi manual dB management
right, migratus doesnāt quite have what I want. It will generate an empty .up.sql
and .down.sql
for me but doesnāt have a dsl for column definitions etc.
Auto migrators always do something wrong it seems
Best system I've had with devs and DBAs is one where you have a base DB via a .sql text file, then incremental changes via commented .sql files, all named via a incrementing number.
Kindof like git for a DB.
there's also ragtime & joplin @maxfurman, but they don't have column def dsls either - but then they aren't tied to sql stores either, so column def dsls don't make much sense in their context
I always cheat: use a GUI SQL tool to lay out my db schema, then select āCopy CREATE TABLE Scriptā¦ā or whatever.
DB diffing tools are also really nice for that
MS SQL had a "export diff as script" that was super helpful
Also console logs that capture your changes real-time as you edit columns/tables in the GUI.
and if you're working with MS SQL in production, the red gate tools are worthwhile. for data diffing and schema diffing
The big thing is at some point you need to take the changes to prod, and as a former DBA I really really hate using tools for that. So much can go wrong.
I guess Iām surprised the clj community hasnāt come up with a lib that matches what you get from rails or django
I'd more say that some of us consider what those frameworks do to be "the wrong way" š
Though there are projects like http://sqlkorma.com
though I prefer HugSQL myself.
Dropping a bunch of indicies and FKs and then re-adding them may be fine for smaller databases, but I've seen SQL servers crash on stuff like that when you get 100M+ rows in a table. In those places you need surgical edits that are sympathetic to the underlying server design.
so even if I wanted to add it (not sure if I want an ORM), I couldnāt use it in the migrations anyway
I've used this homegrown minimalist migration framework: https://gist.github.com/pesterhazy/9f7c0a7a9edd002759779c1732e0ac43
PostgreSQL only ^^
Yeah, as far as the ORM stuff goes HugSQL is pretty awesome. SQL is a powerful tool, leverage it don't hide it behind a DSL. And no need for a ORM when you have hashmaps
(what was that thing from Rich's talk? ORM = OMG š )
@pesterhazy Not quite what Iām looking for - I want to write my migrations in clj code and not write any sql
@tbaldridge but Iām lazyyyy
@maxfurman honestly I'd reconsider the approach - SQL is the root DSL for this
@maxfurman https://github.com/jkk/honeysql check out HoneySQL
)) I never scroll to this section ) thŃn, sorry for noise )
But SQL gives you power š the more you understand your datastore the more you can leverage.
Sorry, we want you to be healthy š
writing code in a db-independent fashion is ultimately a fool's errant
"we want to be able to switch out the db" is understandable but usually overengineering
honeySQL is nice when you want to generate queries from data... though there were some limitations when i last tried it
i've never worked on a bigger-than-trivial project which didn't come to depend on particular features of the underlying db, making switching out the db an arduous task
In our project, we are using HugSQL. Itās a library to generate clojure functions from raw sql queries.
With yesql and its analogies, you may face a situation when you need some extra syntax that was not designed to be used with data structures.
what is the default method/library for solving systems of equations or sets of constraints?
I have several dimensions: some are defined scalars, some are defined ranges, and I need to solve for possible (say int ranges) combinations of undefined dimensions.
it is sort of knapsack problem, but I don't need to solve for the most optimal values; rather I'd like to get range of viable solutions
@misha I'd go for core.logic
or maybe loco https://github.com/aengelberg/loco
or maybe it's just stable. A lot of Clojure libs that work fine don't get a lot of new contributions because they're simple and don't have a lot of bugs.
Ah sorry didnt get that :)
[off topic] given that we are in lisp, why libs such as loco
introduce their own symbols rather then reusing clojure's or
, and
, let
, range
, etc?
It's a pain to code that way, you have to remove the syms from the namespace via :exclude, and then quote everything clj/and
. It's not hard, but it is a pain.
I was thinking about quoting entire expression, and butcher it with macros under the hood.
(def model
[($in :x 1 6)
($in :y 3 7)
($= ($+ :x :y) 10)])
=> (solutions model)
would become something like
(def model
'(let [x (range 1 6)
y (range 3 7)]
(= (+ x y) 10)))
yeah, I see that, thanks, @dpsutton should have mentioned I need it to run on clients too
thatās built into the JDK: http://docs.oracle.com/javase/8/docs/api/java/util/jar/package-frame.html
is there anything builtin for updating values across entire map?
(update-vals {:a 1 :b 2} (partial + 3)) ;;=> {:a 4, :b 5}
@misha I bet Specter offers something...
...otherwise I'd probably do (reduce-kv (fn [m k v] (assoc m k (+ 3 v))) {} {:a 1 :b 2})
I can think of a way with zipmap
, juxt
, and map
but I think reduce-kv
is much cleaner... š
@misha map-vals
is in most utility libraries. My go-to one for this is medley, which is very light.
anyone else encountered broken leiningen plugins with 2.8 release? Eastwood and bikeshed fail for me now
yep, this is a known issue https://github.com/technomancy/leiningen/issues/2328
@seancorfield agree. @dominicm thanks
I still can't get over the (ugly) upper case names š
I think it tends to be sort of all or nothing: either you use it all over the place, or don't use it at all
but you tend to see use-cases for specter that arenāt obvious at first when you start using it
@yedi what kind of merge do you want?
Iām lacking imagination and have no idea how spread would help you merge maps
so instead of something like this
(merge props
{:key1 somethign
:key2 something-else})
you'd have
{:key1 something
:key2 something-else
#...props}
assoc
(assoc props :key1 somethign :key2 somthing-else)
my main issue i think is just the extra indentation of having the (merge)
or (assoc)
call
(assoc
props
:thing1 something
:thing2 something-else)
any decent editor should indent like that as long as the first arg is on the next line
could it be a macro or reader literal instead of an operator?
#spread[props :thing1 somethign :thing2 something2]
canāt use {} because of reader rules, but it looks decent
you could even name it #ā¦
if you really want to
@ghadi it seems like a syntax request to me really
@yedi or just (def ⦠assoc)
and call it a day?
oh, reader macros mean you can define that but not call it directly, too bad
anyone experienced using kafka? Iām setting it up and wondering what the experience is using java APIs vs wrappers like franzy https://github.com/ymilky/franzy
Have seen success with clj-kafka for 0.8 version of Kafka (https://github.com/pingles/clj-kafka) and with gregor for current versions of Kafka (https://github.com/weftio/gregor)
I have had decent luck with a very thin clj-kafka wrapper for the basics plus raw interop whenever I need a non-default option, YMMV
haha, those bugs are fun
still bitter about using a library whose api was implemented in terms of proxy and thus shadowed my this
in method definitions
I think that is the only anaphoric macro in core :)