workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
Thanks guys, I'll take a look - I have to run to a meeting, bbs
2017-11-02T02:40:53.000149
Else
clojurians
clojure
For this toy example I'm wondering if I can just modify a framebuffer directly and blit it to the screen
2017-11-02T02:41:21.000149
Else
clojurians
clojure
for the browser just use some Canvas wrapper or WebGL wrapper or interop
2017-11-02T02:42:06.000137
Tessie
clojurians
clojure
I think you can do that stuff with GLSL, accessing framebuffer that is. Been a while since I last did any GPU level coding :slightly_smiling_face:
2017-11-02T02:42:44.000045
Cecilia
clojurians
clojure
<@Cecilia> yeah, getting to shaders through the browser may help, don’t need to write the interop yourself since there’s stuff in the browser already :slightly_smiling_face:
2017-11-02T03:08:05.000174
Brande
clojurians
clojure
Quil might be the best option here
2017-11-02T03:08:44.000028
Brande
clojurians
clojure
if the idea was to learn the language while doing something graphical
2017-11-02T03:09:09.000225
Brande
clojurians
clojure
too much to ask for to “go write some JNI” while learning Clojure the language :slightly_smiling_face:
2017-11-02T03:09:31.000052
Brande
clojurians
clojure
results in “wtf” moments
2017-11-02T03:09:50.000100
Brande
clojurians
clojure
on other GPU related, but not graphics, Dragan Djuric has done great work on getting the compute side of GPU’s available to Clojure with <http://uncomplicate.org/>
2017-11-02T03:11:32.000033
Brande
clojurians
clojure
totally unrelated to graphics though
2017-11-02T03:11:42.000149
Brande
clojurians
clojure
I'd like to parse clojure source file. What's the good way to do this? Using `clojure.tools.reader/read-string` gives me only the first namespace form: ``` (r/read-string (slurp "src/clojure_repl_experiments/experiments.clj")) ;;=&gt; (ns clojure-repl-experiments.experiments (:require [clojure.set :as set] [criterium.core :as c] [seesaw.core :as see])) ``` What I'd like to get is the list of all forms in that source file
2017-11-02T04:03:55.000197
Terra
clojurians
clojure
you wouldn't happen to mean <https://feierabendprojekte.wordpress.com/2017/04/13/a-parable/> would you?
2017-11-02T05:31:58.000245
Evan
clojurians
clojure
You could just use a loop to read the whole file. What's the context?
2017-11-02T05:44:07.000386
Georgann
clojurians
clojure
<@Terra> because of clojure's evaluation model it's not generally possible to read a whole namespace w/o compiling each form as you go
2017-11-02T05:47:11.000218
Kareen
clojurians
clojure
altho since 1.9.0-alpha&lt;something&gt; (or by using tools.reader) there's ways to make this work, but it's still tricky
2017-11-02T05:47:57.000226
Kareen
clojurians
clojure
<@Georgann> let's say I want to analyze which clojure functions are called in that code
2017-11-02T05:53:59.000297
Terra
clojurians
clojure
take a look at <https://github.com/clojure/tools.analyzer.jvm>
2017-11-02T05:57:11.000433
Kareen
clojurians
clojure
will do, thanks!
2017-11-02T05:58:37.000255
Terra
clojurians
clojure
You guys might appreciate this <https://cacm.acm.org/magazines/2017/10/221326-a-large-scale-study-of-programming-languages-and-code-quality-in-github/fulltext>
2017-11-02T08:43:24.000090
Candice
clojurians
clojure
that's odd. their data suggests typescript is more likely to contain bugs than unadorned js.
2017-11-02T09:58:14.000786
Arlean
clojurians
clojure
Yeah, real data has a way of messing up 'intuition' and theorizing...
2017-11-02T10:31:52.000118
Lanora
clojurians
clojure
IIRC, the .ts extensions would also match C++ projects as they are Qt translation files
2017-11-02T10:39:57.000112
Danuta
clojurians
clojure
there was a long twitter thread with critique about that study, but I’m failing to find it now
2017-11-02T10:40:26.000106
Danuta
clojurians
clojure
yeah, I have my issues with a study like this too. It misses lots of context
2017-11-02T10:41:40.000334
Carter
clojurians
clojure
for example, I’m working on TS project at the moment, and we ran into an issue that was not TS’s fault, but the JS library that did not have a type file.
2017-11-02T10:42:19.000864
Carter
clojurians
clojure
and because I commit often, I committed the buggy code, but fixed it later, before the PR was made. So in a study like this, that would appear as a bug.
2017-11-02T10:42:53.000465
Carter
clojurians
clojure
while it misses the context
2017-11-02T10:42:59.000732
Carter
clojurians
clojure
Especially for languages that compile to JS, it won’t catch the edge cases when you try to interact with JS libraries
2017-11-02T10:43:49.000036
Carter
clojurians
clojure
yes! this is it. Thanks!
2017-11-02T10:45:35.000005
Deloras
clojurians
clojure
glad i could help :slightly_smiling_face:
2017-11-02T10:45:53.000572
Evan
clojurians
clojure
Of course there are issues with it - any such study is going to have issues. But at least it is actual _data_ and not just sitting around making goofy claims
2017-11-02T10:46:05.000057
Lanora
clojurians
clojure
agreed, it’s better than just claiming things based on anecdotes
2017-11-02T10:46:30.000620
Danuta
clojurians
clojure
what would be a good/easy way to disable logging when running tests?
2017-11-02T10:47:14.000512
Krystina
clojurians
clojure
(using leiningen)
2017-11-02T10:47:25.000008
Krystina
clojurians
clojure
well also setting the level to WARN is enough (probably better)
2017-11-02T10:47:45.000267
Krystina
clojurians
clojure
in Python for example pytest captures all the logs during tests and only display the relevant logs in case of failure
2017-11-02T10:48:07.000573
Krystina
clojurians
clojure
<@Krystina> depends how you're logging, logback supports a logback_test.xml for example.
2017-11-02T10:48:09.000478
Jodie
clojurians
clojure
which is quite handy
2017-11-02T10:48:09.000511
Krystina
clojurians
clojure
just using tools.logging at the moment
2017-11-02T10:48:30.000631
Krystina
clojurians
clojure
I'm not sure what that uses by default
2017-11-02T10:49:30.000161
Jodie
clojurians
clojure
<@Else> take a look at <https://github.com/oakes/play-clj>, it's got bindings to OpenGL etc through libgdx. I've been using it for making arcade games.
2017-11-02T10:51:01.000789
Bibi
clojurians
clojure
<@Krystina> apparently the fallback is java.util.logging if nothing else is found :slightly_smiling_face: so you'll have to figure out how to configure that for testing.
2017-11-02T10:52:19.000651
Jodie
clojurians
clojure
well in theory I just need `(.setLevel (Logger/getRootLogger) Level/WARN)`
2017-11-02T10:54:30.000342
Krystina
clojurians
clojure
the only question is where to hook that up
2017-11-02T10:54:37.000027
Krystina
clojurians
clojure
there are hooks in clojure.test
2017-11-02T10:54:46.000808
Jodie
clojurians
clojure
I have something like this for `lein run`
2017-11-02T10:54:51.000604
Krystina
clojurians
clojure
mm not sure I find anything useful there
2017-11-02T10:56:50.000541
Krystina
clojurians
clojure
unless I make a fixture for each test namespace that does that?
2017-11-02T10:57:00.000324
Krystina
clojurians
clojure
which is not very convenient
2017-11-02T10:57:10.000135
Krystina
clojurians
clojure
I'm trying to recreate an aot behavior I've accidentally seen before, I'd like to capture a couple of environment variables at build time, so I can use version data automatically. I'm on 1.9.0-beta3, perhaps aot capture changed a bit? I've just got ```(def DESCRIBE (System/getenv "GIT_DESCRIBE"))``` in a file that's in the :aot lein config for the uberjar profile (and is being aot compiled, going by the output. That value is interpreted at runtime, though
2017-11-02T11:16:22.000538
Felecia
clojurians
clojure
whoops, dropped this: )
2017-11-02T11:17:00.000427
Felecia
clojurians
clojure
Top-level `def`s are run at namespace _load_ time (so, essentially, runtime).
2017-11-02T11:18:56.000601
Daniell
clojurians
clojure
<@Daniell> correct me if I'm wrong, but if you AOT, doesn't that make the load time earlier? (which is why you shouldn't `(launch-missiles)` at the top level)
2017-11-02T11:22:23.000838
Jodie
clojurians
clojure
it certainly does sometimes, because it's been a pretty common confusing deployment issue. that's where I've encountered it in the past
2017-11-02T11:23:28.000560
Felecia
clojurians
clojure
It loads namespaces for AOT and for running -- so it will execute _both_ times: ```(! 510)-&gt; lein uberjar Compiling aotit.core I'm a top-level form Created /Users/sean/clojure/aotit/target/uberjar/aotit-0.1.0-SNAPSHOT.jar Created /Users/sean/clojure/aotit/target/uberjar/aotit-0.1.0-SNAPSHOT-standalone.jar Thu Nov 02 08:28:52 (sean)-(jobs:0)-(~/clojure/aotit) (! 511)-&gt; java -jar target/uberjar/aotit-0.1.0-SNAPSHOT-standalone.jar I'm a top-level form Hello, World! ```
2017-11-02T11:29:52.000495
Daniell
clojurians
clojure
That's with `(def foo (println "I'm a top-level form"))`
2017-11-02T11:30:11.000459
Daniell
clojurians
clojure
oh interesting, I thought it stored the "result" in some way. Cool.
2017-11-02T11:30:27.000460
Jodie
clojurians
clojure
Am i misunderstanding `spec?` It should return whether something is a spec, correct?
2017-11-02T12:53:44.000284
Babette
clojurians
clojure
2nd arg to `s/valid?` should be a spec
2017-11-02T12:57:20.000783
Lorenza
clojurians
clojure
so: `(s/valid? ::first-name "mgrbyte") -&gt; true`
2017-11-02T12:57:42.000297
Lorenza
clojurians
clojure
`(s/spec? ::first-name) -&gt; true`
2017-11-02T12:57:53.000416
Lorenza
clojurians
clojure
I get `(s/spec? ::first-name) -&gt; nil`
2017-11-02T12:58:48.000396
Babette
clojurians
clojure
on 1.9.0-beta2
2017-11-02T12:59:12.000115
Babette
clojurians
clojure
ignore me, I'm wrong
2017-11-02T12:59:48.000127
Lorenza
clojurians
clojure
`string?` returns a spec-predicate, not a spec i think
2017-11-02T13:00:05.000505
Lorenza
clojurians
clojure
from <https://clojure.org/guides/spec>: Any existing Clojure function that takes a single argument and returns a truthy value is a valid predicate spec
2017-11-02T13:00:53.000104
Babette
clojurians
clojure
`string?` is a predicate, `(s/spec string?)` is a spec that conforms to the `string?` predicate
2017-11-02T13:01:04.000622
Aldo
clojurians
clojure
specs and predicates are interchangeable in lots of places but not all
2017-11-02T13:01:53.000105
Aldo
clojurians
clojure
and ::first-name is a keyword, not a spec
2017-11-02T13:02:42.000340
Aldo
clojurians
clojure
ah. `(s/spec? (s/spec int?))` returns an obj
2017-11-02T13:02:56.000698
Babette
clojurians
clojure
you can use keywords that represent spec definitions in lots of places that you can use specs and predicates, but not all (and specifically it seems not in s/spec?)
2017-11-02T13:03:39.000629
Aldo
clojurians
clojure
you can get the spec object from the registry using (s/get-spec ::first-name)
2017-11-02T13:04:18.000364
Aldo
clojurians
clojure
so (s/spec? (s/get-spec ::first-name)) should return true
2017-11-02T13:04:31.000112
Aldo
clojurians
clojure
or... truthy
2017-11-02T13:04:35.000261
Aldo
clojurians
clojure
got it
2017-11-02T13:04:46.000023
Babette
clojurians
clojure
thx for the insight
2017-11-02T13:05:07.000012
Babette
clojurians
clojure
no worries
2017-11-02T13:05:34.000004
Aldo
clojurians
clojure
I'm hitting an anti-pattern often, and wonder if there is a better approach... I write a function, `fn-a`, that takes a map of parameters and does nothing with them but pass on to `fn-b`. It could be written as `(defn fn-a [options] (fn-b options) ...)` But, I want to supply useful arglist info, so I write `(defn fn-a [{:keys [param1 params2 params3] :as options}] (fn-b options) ...)`
2017-11-02T14:00:03.000396
Katelin
clojurians
clojure
But, later, fn-b gains a few more parameters. My code continues to work, but my arglist is out of date.
2017-11-02T14:00:43.000179
Katelin
clojurians
clojure
I'd love some way to declare that arglist info should be taken from another function.
2017-11-02T14:01:07.000017
Katelin
clojurians
clojure
sounds like a job for spec, or prismatic/schema
2017-11-02T14:02:23.000598
Margaret
clojurians
clojure
also, as Rich Hickey eloquently argues, it's good to have an open information model - specify the keys you need, but it should be OK if other things end up in there too
2017-11-02T14:03:12.000144
Margaret
clojurians
clojure
<@Margaret> How? I see how I could use them for checking, but I'm looking for arglist as documentation.
2017-11-02T14:03:23.000368
Katelin
clojurians
clojure
the fact that the check passed in dev mode (even if turned off in prod) is more useful than pure documentation that isn't executable
2017-11-02T14:03:56.000365
Margaret
clojurians
clojure
if all you need is documentation, we have doc strings too
2017-11-02T14:04:09.000446
Margaret
clojurians
clojure
I can write (defn foo [{:keys [a b c d]}] ...) and pass it an empty map - clojure doesn't care
2017-11-02T14:04:52.000204
Margaret
clojurians
clojure
the a b c d there isn't any more informative than text in the doc string would be, nor is it more enforcible
2017-11-02T14:05:10.000385
Margaret
clojurians
clojure
That just begs the issue. I would still see the doc string of fn-a. But, really, the caller of fn-a needs to know the parameters of fn-b in order to effectively use the fn-a wrapper.
2017-11-02T14:05:32.000189
Katelin
clojurians
clojure
which is why an executable validation that can optionally be turned off is more useful
2017-11-02T14:06:03.000616
Margaret
clojurians
clojure
I'm not lookinf for enforcement in the question, I'm looking for, if you will, enlightenment.
2017-11-02T14:06:06.000159
Katelin
clojurians
clojure
why would a name that isn't enforced in an arg map be more enlightening than a string that isn't enforced in a doc string?
2017-11-02T14:06:32.000236
Margaret
clojurians
clojure
When I'm writing code in emacs, I want to do a quick `C-c d d` to see what parameters to type.
2017-11-02T14:06:43.000172
Katelin
clojurians
clojure
But, that forces me to keep the doc-string or the parameters of fn-a in lockstep with fn-b.
2017-11-02T14:07:09.000483
Katelin
clojurians
clojure
sounds like an emacs problem - a doc string can give you a lot more nuance and information than names in a destructure can
2017-11-02T14:07:09.000654
Margaret
clojurians
clojure
and an optional validation verifies that the code you are using actually works that way
2017-11-02T14:07:34.000167
Margaret
clojurians
clojure
When, really, fn-a's mandate is, rightly "take whatever I get and pass it to fn-b, because I have no right to care"
2017-11-02T14:07:48.000023
Katelin
clojurians
clojure
I would much rather spend one second when I'm typing my code, rather than one minute later, when a runtime check finds a problem. (and that's even assuming that someone did the unlikely task of writing a run-time checker for misspelled parameters in a map).
2017-11-02T14:10:20.000428
Katelin
clojurians
clojure
spec and prismatic/schema can both warn you about such things, and can be turned off in production
2017-11-02T14:10:59.000465
Margaret
clojurians
clojure
Spec can, but not naturally. As you pointed out above "specify the keys you need, but it should be OK if other things end up in there too".
2017-11-02T14:11:52.000288
Katelin