Re: Clojure as first language

2020-09-28 Thread Gary Trakhman
o those. I know Python does. > > Thanks again > > On Mon, Sep 28, 2020 at 7:40 PM Gary Trakhman > wrote: > >> Clojure is a fine language to learn on, but there are going to be some >> complex details along the way. I think there are 2 approaches >> to entry into pro

Re: Clojure as first language

2020-09-28 Thread Gary Trakhman
Clojure is a fine language to learn on, but there are going to be some complex details along the way. I think there are 2 approaches to entry into programming that you might consider. You can start with the basic fundamentals of computation and work up into software engineering. For that, clojure

Re: GraalVM's native-image incompatible with Clojure's eval?

2018-11-26 Thread Gary Trakhman
Yes, eval will generate classes in a dynamic classloader, load them, then call methods on the newly formed class/object except for too-simple-to-be-interesting cases. On Mon, Nov 26, 2018 at 11:43 AM Khalid Jebbari wrote: > Hi, > > I was doing a small experiment with Clojure and GraalVM and ende

Re: Ask Community: Feedback/Suggestion Needed about the Code Nirvana Specification

2018-11-09 Thread Gary Trakhman
Have you evaluated Phabricator? I think it's trying to do all of SDLC in one tool as well, more or less successfully. Our team spends a lot of time fighting its limitations. On Fri, Nov 9, 2018 at 1:18 AM Piyush Katariya wrote: > Hello Clojurians, > > Could you please have a look at the speci

Re: [ANN] com.walmartlabs/cond-let 1.0.0

2018-10-04 Thread Gary Trakhman
r wrote: > >> See https://funcool.github.io/cats/latest/#mlet for something closer to >> home, in the monadic vein. >> >> >> On Thu, Oct 4, 2018 at 4:10 PM Gary Trakhman wrote: >> > These are all just sugar over monadic bind, right? >>> >>&g

Re: [ANN] com.walmartlabs/cond-let 1.0.0

2018-10-04 Thread Gary Trakhman
These are all just sugar over monadic bind, right? Here's one way to do it in the ocaml alternate universe: https://github.com/janestreet/ppx_let#syntactic-forms-and-actual-rewriting But it can be made to work for async or options or whatever, too. We can put the async helpers in the same bucket

Re: How define alias for .indexOf? (def somealias .indexOf) does not work.

2018-07-20 Thread Gary Trakhman
Ah, this came in with 1.5: https://dev.clojure.org/jira/browse/CLJ-910?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel On Fri, Jul 20, 2018 at 12:38 PM Gary Trakhman wrote: > > The memfn docstring says it can be type hinted to avoid reflection. Any > reason why it wo

Re: How define alias for .indexOf? (def somealias .indexOf) does not work.

2018-07-20 Thread Gary Trakhman
> The memfn docstring says it can be type hinted to avoid reflection. Any reason why it would still be slower then wrapping it in a type hinted function? Neat, I didn't know that! Since each memfn creates a new function, it's the same thing as writing it out manually, unlike say 'partial', which i

Re: OK idea to replace conj and cons with "prepend" and "append" macros that have consistent behavior and return same types as args?

2018-07-20 Thread Gary Trakhman
@Gary Johnson, your post is otherwise great, but I think a little confusing for this point: > , I would advise you to use the "into" function that I demonstrated at the beginning of this email if you wish to teach a unified API for appending and prepending to each of Clojure's four main data struct

Re: How define alias for .indexOf? (def somealias .indexOf) does not work.

2018-07-19 Thread Gary Trakhman
memfn will do this for you https://clojuredocs.org/clojure.core/memfn But it's usually the wrong thing. Wrt reflection-perf/warnings, you'd be better off with an anonymous function and typehint most of the time. On Thu, Jul 19, 2018 at 1:33 PM Christian Seberino wrote: > How define alias for

Re: OK idea to replace conj and cons with "prepend" and "append" macros that have consistent behavior and return same types as args?

2018-07-18 Thread Gary Trakhman
Well, actually, concat returns a seq, not a list. For all practical purposes, it looks like a list, but it isn't one. Practically, the difference is laziness, which is a whole thing on its own. Also the count operation is linear when lists just keep track of their length, and can do it in constant

Re: OK idea to replace conj and cons with "prepend" and "append" macros that have consistent behavior and return same types as args?

2018-07-18 Thread Gary Trakhman
Concat does the job except for keeping the input collection type. It will seq anything you throw at it. There's a general trade-off here. When I started working in ocaml recently I was taken aback that the List.map call we used constantly would have to build the new list backwards in linear time,

Re: OK idea to replace conj and cons with "prepend" and "append" macros that have consistent behavior and return same types as args?

2018-07-17 Thread Gary Trakhman
Data to most people means tabular or relational data and not complex, compound data, and EDN is a funny case, since it is not the concrete representation. What about print-dup, and print-method? Is that subtlety inherent to the elegance? How often do you really need complex, immutable keys? What

Re: OK idea to replace conj and cons with "prepend" and "append" macros that have consistent behavior and return same types as args?

2018-07-17 Thread Gary Trakhman
On Tue, Jul 17, 2018 at 1:35 PM Alex Miller wrote: > You can talk about Clojure operations from a type perspective, but I think > when you do so, you are largely missing the point of Clojure. > > Having used Clojure for a very long while, I will have to respectfully disagree with this one. Cloju

Re: OK idea to replace conj and cons with "prepend" and "append" macros that have consistent behavior and return same types as args?

2018-07-17 Thread Gary Trakhman
about computational complexity before they can add something to the right side of a list. On Tue, Jul 17, 2018 at 1:07 PM Alex Miller wrote: > > On Tuesday, July 17, 2018 at 11:06:51 AM UTC-5, Gary Trakhman wrote: >> >> It's pretty hard in clojure to keep track of a data structure

Re: OK idea to replace conj and cons with "prepend" and "append" macros that have consistent behavior and return same types as args?

2018-07-17 Thread Gary Trakhman
It's pretty hard in clojure to keep track of a data structure and ensure some function introduced later in the middle of a data path doesn't seq it along the way. You get some discipline around this, but it adds to the learning curve. I wouldn't say polymorphism is better or easier than being str

Re: What is the minimal Emacs config for practical Clojure development?

2018-07-05 Thread Gary Trakhman
I'm not sure the desires for lightweight clojure-emacs integration and any CLJS integration are yet sympathetic. Figwheel is a pretty complex piece of software. For example, see my issue that has been languishing for almost a year and hints at greater problems with the compiler integration: https:

Re: Anyone spent time with Kawa Scheme?

2018-04-04 Thread Gary Trakhman
If you're looking for fast CLI utilities, ocaml can be a good fit, or grenchman for loading clojure code, in this particular case (written in ocaml): https://github.com/technomancy/grenchman You don't really need persistent data structures for those use-cases, do you? But it does have seqs and as

Re: Why does the `def-` not exist?

2018-02-26 Thread Gary Trakhman
If you're an emacs user, have you considered Yasnippet? It shouldn't be too hard to add to this: https://github.com/mpenet/clojure-snippets/tree/master/snippets/clojure-mode . Personally, I just don't use private defs at all. Inevitably, you'll have to var-hack them during testing, so at some poi

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2018-01-24 Thread Gary Trakhman
artup times are to blame on Java. I > understand that Clojure does a lot of extra stuff at startup that a plain > Java main method would not, but those extra things Clojure does are slow, > because of the way the JVM handles them, where as they are quite fast on V8 > or other JavaScript

Re: [ANN] Git Deps for Clojure!

2018-01-05 Thread Gary Trakhman
ving a single version for each dep. Is there some existing design thought along these lines that I've missed? On Fri, Jan 5, 2018 at 2:39 PM Alex Miller wrote: > On Fri, Jan 5, 2018 at 1:20 PM, Gary Trakhman > wrote: > >> Congrats on the release! It's exciting to see

Re: [ANN] Git Deps for Clojure!

2018-01-05 Thread Gary Trakhman
Congrats on the release! It's exciting to see this vision move forward. Wondering if the logical next step is the npm style of trees of duplicate transitive git deps. In general, how is this going to work for transitive deps? On Fri, Jan 5, 2018 at 1:49 PM Alex Miller wrote: > Pleased to announ

Re: sorting a list based on the order of its items in another list

2017-12-12 Thread Gary Trakhman
How about (filter (set small-list) big-list) ? On Dec 12, 2017 8:25 AM, "Deyan Yotsov" wrote: > Hello, > > I have one list of potentially up to 2 million strings: big-list. > > Then I have another list, small-list, the elements of which are a subset > of the elements of big-list. > > I want to s

Re: Am I being stupid regarding how much memory I use?

2017-11-12 Thread Gary Trakhman
I don't know about MySQL specifics, but I did a similar job on top of postgresql and relied on its built in temporary tables, indexes and spill-to-disk functionality, the dataset/computation in question was already blowing up a Ruby process. There's no need to reinvent it in clojure if the database

Re: Q: How to find out how much Clojure you use

2017-10-25 Thread Gary Trakhman
Grimoire has a usage heatmap, I think it just might be over a few projects: https://www.conj.io/heatmap On Oct 26, 2017 7:40 AM, "Erik Assum" wrote: > Eric Normand did some research on this some time ago: > > http://www.lispcast.com/100-most-used-clojure-expressions > > Erik. > -- > i farta > >

Re: About determinism of async

2017-10-11 Thread Gary Trakhman
This will non-deterministically output either >> => [:x' :x''] >> >> or >> >> => [:x' :y'] >> >> But again as I said, you can employ partition-all separately as a >> "collecting" mechanism before doing the

Re: Updating repeated nested structures?

2017-10-10 Thread Gary Trakhman
I wrote a terrible terrible function once to help with this while bored in jury duty, called flipartial, in the style of core's 'let's expand/optimize out the most common arities': (defn flipartial "A combo of partial/flip, makes it easier to fake-curry non-data-last functions. In general, only

Re: About determinism of async

2017-10-10 Thread Gary Trakhman
ould that be deterministic? Or any other function? > > > tiistai 10. lokakuuta 2017 17.33.22 UTC+3 Gary Trakhman kirjoitti: > >> I think a core assumption is that all writes can yield control at any >> time to other worker go processes. I wouldn't rely on the consecutive

Re: About determinism of async

2017-10-10 Thread Gary Trakhman
I think a core assumption is that all writes can yield control at any time to other worker go processes. I wouldn't rely on the consecutive behavior even if it were true, nondeterminism is a good assumption with core.async. If you need that particular guarantee, consider a call to partition? On T

Re: [core.spec] Stricter map validations?

2017-10-03 Thread Gary Trakhman
I don't disagree that there might be a security use-case, and regardless of how realistic it is businesses need people to tick boxes (that doesn't seem like something core should worry about?), but what is the actual security risk of an unspec'd map value, or things being referenced and unused? Th

Re: Is it wrong that I'm thinking about this?

2017-09-19 Thread Gary Trakhman
I think there's the spec is a 'side-band' system (well except we want to the compiler to know about it for macros) design constraint, but additionally, I think it's worth thinking about: Defn right now is primitive enough to be fast and powerful enough for large programs. There are many general a

Re: What am I doing wrong

2017-09-06 Thread Gary Trakhman
The second to last apply argument doesn't spread args like the last slot. - terseness from phone On Sep 6, 2017 8:11 AM, "Cecil Westerhof" wrote: I have: (def digits (apply str (map char (inclusive-range (int \0) (int \9) and this gives: "0123456789" I also have: (def

Re: core.async got in a bad state?

2017-08-29 Thread Gary Trakhman
Hm, I came across a similar ordering invariant (No code called by a go block should ever call the blocking variants of core.async functions) while wrapping an imperative API, and I thought it might be useful to use vars/binding to enforce it. Has this or other approaches been considered in core.as

Re: Is Clojure victim of Spec ?

2017-08-18 Thread Gary Trakhman
I consider Clojure 1.9-alpha16 reasonably stable and not significantly more full-featured than 1.8. Is there any risk to using it, or any harm from staying on 1.8? In the past, conversations have come up about clojure's relative stability in alpha versions compared to people's perceptions of vers

Re: Clojure rookie vs parsing

2017-08-15 Thread Gary Trakhman
I enjoyed working with clj-antlr recently, it's a wrapper over a java library, but gives you a fast feedback loop with an interpreter instead of generated java code. The 'clojurey' part is that the output is a nested sequence, from there it's really effective to use tree zippers and core.match to

Re: beginning to learn Clojure after imperative programming my whole life

2017-08-09 Thread Gary Trakhman
Hi Andy! Honestly, there's something very lovable and addictive about working in Clojure and lisp in general, but I would caution against trying to use it as a silver bullet, and generalizing it to improving general 'problem-solving' skills might be a bridge too far. I think what lisp does do is

Re: "GC overhead limit exceeded": Deceptive message?

2017-08-08 Thread Gary Trakhman
@Nathan the top-level (def requirement-seq ..) is probably the thing holding on to all the objects. Try removing the def and calling (last (sequence (comp ..))) and see if it returns? The purpose of a lazy sequence is to allow processing to happen one item or chunk at a time, if there are still p

Re: Unnamed Types - What Am I Doing Wrong?

2017-07-25 Thread Gary Trakhman
Maps with named keys work much better than vectors/lists for heterogenuous data. I've recently taken up OCaml as a very well-typed language, and it's basically analogous to records vs tuples tradeoffs there. Clojure.spec can help at a larger scale. You can do the same encapsulation as Java by wr

Re: If Clojure is to blame for the majority of the startup time, why doesn't ClojureScript proportionally slow down the JavaScript startup time also?

2017-07-14 Thread Gary Trakhman
My mental model explains most of this away due to the different load patterns of java vs v8. In JVM clojure, functions are essentially 1:1 with classes, so in a functional language and standard lib, that's a lot of classes. Java will eagerly classload your entire app and deps before doing any wor

Re: Getting Symbol objects instead of java.lang.Class objects when using reflect/reflect

2017-06-26 Thread Gary Trakhman
Is this what you're looking for? user=> (resolve 'java.lang.String) java.lang.String user=> (type (resolve 'java.lang.String)) java.lang.Class On Mon, Jun 26, 2017 at 1:34 PM Manas Marthi wrote: > Hi, > I have a jar files with more than 200 DTO classes. Some have only > primitive data type

Re: pmap: transducer & chunking

2017-05-26 Thread Gary Trakhman
Have you looked into core.async's 'pipeline' function for parallelism? That was my first question when I saw this post. I'm not sure why there's a need for pmap. On Fri, May 26, 2017 at 12:29 PM Timothy Dean wrote: > You can also get an indication this way, I think: > > user=> (defn f [x] (Thre

Re: Beginner: let with Java object

2017-05-26 Thread Gary Trakhman
There shouldn't be a difference, I would suspect a typo in your file. The error 'ClassCastException java.awt.image.BufferedImage cannot be cast to clojure.lang.IFn tutorial.core/-main (core.clj:11)' would lead me to look for things like '(img)' where the object ends up in call position of the s-e

Re: Clojure resume tips?

2017-03-23 Thread Gary Trakhman
I'd put examples of interesting (hard, nontrivial) projects you worked on during your time, not just keywords. The function of the resume is to motivate someone to look deeper instead of throwing it out. The function of the top of the resume is to hook someone to read the rest of it. What's spec

Re: Handling dependency conflicts

2017-03-13 Thread Gary Trakhman
MrAnderson is one possible answer to the question, it's used in CIDER: https://github.com/benedekfazekas/mranderson On Mon, Mar 13, 2017 at 4:13 PM wrote: > Hello All, > > > I have a general inquiry regarding conflicting dependencies in > Clojure projects and how they affect applications at

Re: why doesn't java.lang.ArithmeticException have Exception as a parent?

2017-03-07 Thread Gary Trakhman
Turns out ancestors works on the class, not the instance: > (ancestors ArithmeticException) #{java.lang.Throwable java.io.Serializable java.lang.Exception java.lang.RuntimeException java.lang.Object} > (ancestors (new ArithmeticException)) nil On Tue, Mar 7, 2017 at 7:05 PM wrote: > This gives

Re: Prgram uses a lot of swap

2017-02-27 Thread Gary Trakhman
I've had great luck with the G1 garbage collector when running lots of JVMs on a single (linux) box. It's different from the default by actually freeing memory back to the OS on a full collection, this would result in lower total memory use thus lower swapping when multiple JVMs are running. The

Re: How can I re-order rows in a table (hiccup)?

2017-02-24 Thread Gary Trakhman
Generally it's easier to sort the data before it gets put into hiccup table formatting. Is there any reason not to? On Feb 24, 2017 5:41 PM, "John Gabriele" wrote: > I'm using hiccup, and I'd like to build a table, but then have the option > to re-order it (sort its rows by a column of my choosi

Re: [ANN] core.async 0.3.426

2017-02-22 Thread Gary Trakhman
Thank you so much for getting around to ASYNC-138+32, it was a usability issue between idiomatic clojure code and async code, would show up almost immediately in new projects, the workaround raised questions during code-reviews, etc. On Wed, Feb 22, 2017 at 1:47 PM Alex Miller wrote: > core.asyn

Re: Apparently nondeterministic compilation failure

2017-01-23 Thread Gary Trakhman
I've seen non-determinism across machines with regard to multiple namespaces being searched to AOT with the clojure-maven plugin (only noticed because it resulted in an error). The workaround was to specify a single entry point namespace to clojure-maven and let the clojure compiler sort out namesp

Re: maven-shade-plugin issues with Clojure core (or any clj) AOT compilation

2016-12-28 Thread Gary Trakhman
My workaround in a multi-module maven shaded java project with a clojure module was to strip out CLJ files in the top-level build (shipped with clojure.core jar). I had also stripped CLJ files from my project artifact, but AOT compiles classfiles from all referenced namespaces, so I attempted to s

Re: Errors

2016-12-05 Thread Gary Trakhman
I think it has been rehashed often and core is very conservative about changes, but the current latest and greatest for improving many kinds of errors is going to be clojure.spec, which runs parallel to the actual execution path, so as not to effect things like performance or old code that depends

Re: def partial vs let partial

2016-12-01 Thread Gary Trakhman
Sum-partial-def gets the original + definition because it is evaluated first, if you want late binding, try (partial reduce (var +)). On Dec 1, 2016 4:05 PM, "Matthew Hamrick" wrote: > I'm confused by the following code. > Could someone explain to me why the def-ed partial has different behavior

Re: Design pattern question: how to decouple data layer from application layer in Luminus service?

2016-11-18 Thread Gary Trakhman
It's dirty and not thread-safe, but you can always replace any clojure function (caveat: that's not direct-linked (only clojure.core 1.8+)) temporarily during testing with with-redefs. Instead of mocking out the functions, you might consider mocking out the database, or the data inside the databas

Re: comp and partial vs ->>

2016-10-27 Thread Gary Trakhman
Comp does its work at run-time, so you have to call functions that return functions. Threading macros do their work at compile-time, so your form literally compiles to this: > (clojure.walk/macroexpand-all '(->> (str/split s #"(?<=[a-z])(?=[A-Z])") (map str/lower-case) (int

Re: Possible ClojureScript compiler issue...

2016-10-18 Thread Gary Trakhman
lem can happen. :-( If there was a way to so "ignore the transit > extensions", that would change things though. > > -John > > On Tue, Oct 18, 2016 at 7:36 AM, Gary Trakhman > wrote: > > If you're parsing raw json streams/strings, I think transit clai

Re: Possible ClojureScript compiler issue...

2016-10-18 Thread Gary Trakhman
If you're parsing raw json streams/strings, I think transit claims to be a 30x perf improvement over js/JSON.parse+js->clj: http://swannodette.github.io/2014/07/26/transit-clojurescript On Tue, Oct 18, 2016 at 6:41 AM Matching Socks wrote: > A reliable "implements?" would be better than a fast-a

Re: AOT classes with clj files on classpath causing ClassNotFoundException

2016-10-12 Thread Gary Trakhman
It's possible to do a mixed AOT (your code) non-aot (third-party code) setup, but it's a huge pain. The particular issue you're seeing is probably the result of multiple versions of a class existing across jars and classloaders. Unfortunately there is no consistent way to get this right, but the

Re: clojure.core/bean throws when passed an empty list

2016-10-04 Thread Gary Trakhman
This is an existing bug: http://dev.clojure.org/jira/browse/CLJ-978?page=com.atlassian.jira.plugin.system.issuetabpanels:changehistory-tabpanel It's relatively easy to write a workaround if needed. On Tue, Oct 4, 2016 at 7:59 AM Divyansh Prakash wrote: > Is this desired behaviour? > > user=> (b

Re: Why is this not considered to be in a go block?

2016-08-26 Thread Gary Trakhman
I wouldn't expect it to work in a `for` comprehension, because that's combining laziness (which uses function thunks under the hood) with the async state machines. In general, you shouldn't do side-effects in a `for`, though I'd be surprised if you couldn't take at the input. This works (let [ch

Re: Two suggestions re: core.spec, `ns`, and clojure 1.9alpha11

2016-08-25 Thread Gary Trakhman
Over the years I've kind of started agreeing with what Brian's saying. Much as I love/know clojure and the philosophy that bears its fruit, I think spec's sideband error-handling is a great low-risk opportunity to build in some 'easy'. My team is moving from rails towards elixir after having serio

Re: ref strange behavior

2016-08-23 Thread Gary Trakhman
On Tue, Aug 23, 2016 at 10:59 AM Sergei Koledov wrote: > Thank you! I know about Java's thread pools, but I want to do my job in > clojure-idiomatic way and possibly less using java interop. > > I think many of the use-cases for refs/agents are supplanted by core.async. In this case, the 'pipeli

Re: zipmap behaviour

2016-07-29 Thread Gary Trakhman
n exception or logs a > warning with my logging library of choice, or conjoin the values in a list > or set, etc. > > > > On Friday, 29 July 2016 17:56:20 UTC+1, Gary Trakhman wrote: > >> Distinct on the input values wouldn't solve your problems, as the entries >&

Re: zipmap behaviour

2016-07-29 Thread Gary Trakhman
Distinct on the input values wouldn't solve your problems, as the entries are indeed distinct even with repeated keys. Calling 'distinct' on the input keys is about the same cost as building up a map, since it internally uses a set that is backed by a map ;-), but you seem to be more concerned abo

Re: Running a certain function of your project

2016-07-14 Thread Gary Trakhman
Boot and inlein are both more suitable for one-off scripts. On Thu, Jul 14, 2016 at 5:16 PM Cecil Westerhof wrote: > In my project I have some functions I use when calling ‘lein repl’ in the > project directory. Would it be pos

Re: lein repl and own functions

2016-07-14 Thread Gary Trakhman
One way to abuse lein repl, which may get you what you want for a loose 'lein repl' but is sure to cause some problem down the line is to add a project.clj in your home directory. When you call `lein repl` it'll recurse from current working directory through parent dirs until it finds a project.clj

Re: [ANN] Nightcode 2: Total Rewrite

2016-07-13 Thread Gary Trakhman
Pretty cool! On Ubuntu, I was unable to run the jar, it couldn't find the main sekao...core class, although on inspection it was there just fine. I was able to run it from a git checkout with `boot run`, however I additionally found out I needed to `sudo apt-get install openjfx` On Wed, Jul 13,

Re: [ANN] Tufte, simple profiling and performance monitoring for Clojure/Script

2016-07-11 Thread Gary Trakhman
Wonderful, used it today on some core.async code. It helped me tune GC/buffer-sizes/parallelism and the metrics are a useful communication tool across a team that's less familliar with clojure. On Mon, Jul 11, 2016 at 9:45 AM Peter Taoussanis wrote: > On Clojars, and GitHub at: https://github.c

Re: lazy-cat's memoization obscuring runtime exceptions

2016-06-13 Thread Gary Trakhman
Ah, sorry I missed that the first time around. There's something similar going on with lazy-seq. user=> (defn the-seq #_=> ([] (the-seq 2)) #_=> ([a] (cons (* a a) (lazy-seq (the-seq (* a a)) user=> (def s (the-seq)) #'user/s user=> (take 100 s) ArithmeticException integer overflow

Re: lazy-cat's memoization obscuring runtime exceptions

2016-06-13 Thread Gary Trakhman
What's surprising about this? Maybe you want the promoting *' variant: > (def expexp (lazy-cat [2] (map #(*' % %) expexp))) #'sandbox21201/expexp > (take 100 expexp) Execution Timed Out! Seems like it's a big number :-) On Mon, Jun 13, 2016 at 4:27 PM Sebastian Oberhoff < oberhoff.sebast...@gm

Re: why is it so annoying to run clojure code

2016-06-09 Thread Gary Trakhman
Why hasn't anyone mentioned Boot, which provides shebang-style execution and deps for you? https://github.com/boot-clj/boot/wiki/Scripts On Thu, Jun 9, 2016 at 12:48 PM James Reeves wrote: > You can run Clojure directly, but often you don't just need Clojure, but > other libraries as well. The "

Re: Is there an apply-able new?

2016-05-27 Thread Gary Trakhman
gtrak/interop/blob/master/src/interop/core.clj On Fri, May 27, 2016 at 1:25 PM Gary Trakhman wrote: > Yes, you'll have to use the reflection API to create a class dynamically. > > https://docs.oracle.com/javase/tutorial/reflect/member/ctorInstance.html > > On Fri, May 27, 201

Re: Is there an apply-able new?

2016-05-27 Thread Gary Trakhman
Yes, you'll have to use the reflection API to create a class dynamically. https://docs.oracle.com/javase/tutorial/reflect/member/ctorInstance.html On Fri, May 27, 2016 at 1:24 PM hiskennyness wrote: > qooxdoo lets us supply oft-used widget parameters to the constructor. For > example, a button

Re: Avoiding nested ifs...

2016-05-26 Thread Gary Trakhman
ulling it apart down the line and actually doing the work on known good inputs. On Thu, May 26, 2016 at 11:39 AM John Szakmeister wrote: > On Thu, May 26, 2016 at 10:55 AM, Gary Trakhman > wrote: > > I think the idiomatic way to handle this in clojure is to do all your > &g

Re: Avoiding nested ifs...

2016-05-26 Thread Gary Trakhman
I think the idiomatic way to handle this in clojure is to do all your validation upfront on a single descriptive data structure, perhaps in a single function, then bail early. That has the added advantage of being able to report multiple errors, instead of just the first, and is well supported by

Re: clojure.spec

2016-05-25 Thread Gary Trakhman
It seems like the :req impls should go further to disallow trash input, it's not immediately clear that they only allow namespaced keywords. For example: > (s/valid? (s/keys :req ["a"]) {:a 5}) true > (s/valid? (s/keys :req [5]) {:a 5}) true What ends up happening in practice, is (filter keyword?

Re: [ANN] Clojure 1.9.0-alpha1

2016-05-25 Thread Gary Trakhman
It would be helpful to make clojure.spec available as a lib for 1.8. I have opted to backport clojure.spec (a 30-second copy/paste job) into our application running on 1.8 for an easy transition, and maybe others would be more comfortable bringing in a lib until 1.9 is further along. That would a

Re: clojure.spec

2016-05-25 Thread Gary Trakhman
I answered my own question in the specific case, this seems to work: (defn to-int [x] (try (Long/parseLong x) (catch Exception _ nil))) (s/def ::intable (s/conformer to-int)) (s/conform (s/cat :ints ::intable) ["5"]) > {:ints 5} On Wed, May 25, 2016 at 8:36 AM

Re: clojure.spec

2016-05-25 Thread Gary Trakhman
Is there a public way to get the registry's spec at a keyword? I can envision other libs being built around the spec registry, and I'm trying to write a small one (coercions) to see if I can use spec for this use-case. Is that non-sanctioned kind of thing going forward? The likely candidate seems

Re: [ANN] Clojure 1.9.0-alpha1

2016-05-24 Thread Gary Trakhman
The inevitable question: is there a release schedule for 1.9 yet? I would love to start writing greenfield spec code ASAP, knowing that would help me communicate tradeoffs. On Tue, May 24, 2016 at 1:05 PM Alex Miller wrote: > You know how you always see the typo right after you hit send? > > - L

Re: defmulti is a defonce?

2016-04-01 Thread Gary Trakhman
I usually work around this by putting the dispatch in a separate def and referencing the var within defmulti. (defmulti my-multi #'my-dispatch) It's barely slower for the extra var dereference and very convenient for development. On Fri, Apr 1, 2016 at 12:10 PM hiskennyness wrote: > I just kil

Re: Question about how lazy sequences are held/released/garbage collected

2016-04-01 Thread Gary Trakhman
I think this is an example of locals-clearing at work: https://groups.google.com/forum/#!topic/clojure/FLrtjyYJdRU My guess is that the compiler clears the references 'at the point of last reference', but in this case s2 has no last reference. On Fri, Apr 1, 2016 at 9:07 AM John Jacobsen wrote:

Re: Running Clojure apps using less memory.

2016-03-28 Thread Gary Trakhman
I always work in a single process, REPL and server, there's no need to separate them out generally. You might have better luck with the G1 collector, in addition to JVM tuning. The G1 has the useful property of giving memory back to the OS when a GC is performed. Use the command-line flag: -XX:+U

Re: Scripting with Clojure / "slow" boot time

2016-02-10 Thread Gary Trakhman
Personally, I've recently fought machine-specific AOT breakage issues by forcing maven-clojure-plugin to only compile a single entry-point namespace, making compilation order deterministic again. Arguably, it should have worked in any order but this specific issue was hard to track down. In any c

Re: Java Interop for a static method call that returns an ArrayList

2016-02-10 Thread Gary Trakhman
(map (fn [u] (.getName u)) (DAO/getUsers)) ? You'll need to write a getter since name is private. On Wed, Feb 10, 2016 at 8:44 AM Adrian Cooley wrote: > Hi, > > I have a Java class that has a static method call that returns a Java > Array List of users as follows: > > public final class DAO { >

Re: Java API type hint question

2016-01-26 Thread Gary Trakhman
Just because no else has said it yet, clojure vectors, lists and seqs all implement the read part of the interface java.util.List, and your java API should most likely be refactored to use the List interface instead of ArrayList if it isn't already. If that's the case, and it's not trying to mutat

Re: [ANN] Clojure 1.8.0-RC3

2015-12-10 Thread Gary Trakhman
We've been using it on our development branch without a hitch since Dec 2. On Thu, Dec 10, 2015 at 2:32 AM Michael Blume wrote: > No issues here. > > On Tue, Dec 8, 2015 at 5:39 PM James Elliott wrote: > >> I’ve been working with it for a few days and have seen no issues yet. >> >> >> On Wednes

Re: Practical ways to deal with 'bag-of-properties' syndrome, AKA dynamic typing?

2015-11-30 Thread Gary Trakhman
I spend most of my time on application code, I think the tradeoffs are different when shipping public libraries. Obviously, I would prefer my libs to be more slow-moving, more well-documented, more generally useful and well-defined. I want my application code to be quick to change and develop fir

Re: A call for an idiomatic rendering of Clojure EDN in info/error messages

2015-11-13 Thread Gary Trakhman
A pair of curly brackets with a single value isn't part of the grammar either, and I think reads better than _ On Nov 13, 2015 8:47 AM, "Colin Yates" wrote: > Really, I don’t mind - I would just like consistency :-) > > One argument for the right delimiter of some sort is that it is > unambiguous

Re: Cryptic crashes in Leiningen

2015-11-09 Thread Gary Trakhman
te > to recursive dependencies): > > :dependencies [[org.clojure/clojure "1.7.0"] > [org.clojure/tools.reader "0.10.0"] ; Or perhaps > 1.0.0-alpha1 > [afterglow "0.1.4" :exclusions [org.clojure/tools.reader]]] > >

Re: Cryptic crashes in Leiningen

2015-11-08 Thread Gary Trakhman
Just a guess, since your project has many dependencies, and I have little time right now, but I had a recent issue with tools.reader <=0.9.2 and the ExceptionInfo class. The maven artifacts for tools.reader bundled .class files, and triggered this bug: http://dev.clojure.org/jira/browse/CLJ-1639

Re: is there a community "best practice" for including your co-workers libraries?

2015-10-16 Thread Gary Trakhman
I've used Nexus and Archiva, and I feel nexus is a better experience: https://maven.apache.org/repository-management.html There is a stopgap solution involving s3 that might be easier to set up: https://github.com/technomancy/s3-wagon-private On Fri, Oct 16, 2015 at 5:17 PM Lawrence Krubner wrot

Re: [ANN] Clojure 1.8.0-beta1

2015-10-13 Thread Gary Trakhman
Since upgrading our maven-based project, I'm seeing a new warning: Reflection warning, clojure/pprint/pretty_writer.clj:419:12 - call to method write can't be resolved (target class is unknown). Once I connect with cider, I check *warn-on-reflection* and it is false. On Tue, Oct 13, 2015 at 11:44

Re: Towards Greater Code Reuse

2015-10-02 Thread Gary Trakhman
There are a lot of strategies to deal with the coupling of reuse. I find that using pure functions makes it easy to split off responsibilities after the fact and add multiple entry points (the hard thing becomes naming those functions). Eventually a new 'essence' of the abstraction will show itse

Re: 'seq' performance for 'empty?' compared to 'count'. And where's !=?

2015-10-01 Thread Gary Trakhman
Count is going to be slow for seqs or cons's, but I think a generalized function could be implemented via protocol, falling back to seq. Things that extend https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Counted.java are going to have a fast 'count' method. On Thu, Oct 1, 2015

Re: can I use varargs in a multimethod?

2015-09-30 Thread Gary Trakhman
It works for me, for '(intent {} "yes" :yes "WAT")' I get the error: IllegalArgumentException No method in multimethod 'intent' for dispatch value: WAT clojure.lang.MultiFn.getFn (MultiFn.java:156) You're probably being bitten by a different issue. It's impossible to redefine the dispatch funct

Re: safety and reusability of clojure.lang.RT, Compiler and co. in multi-classloader environment

2015-09-28 Thread Gary Trakhman
Here is another interesting read about how they solved it in immutant: http://immutant.org/news/2012/05/18/runtime-isolation/ On Mon, Sep 28, 2015 at 6:54 PM Stephen Gilardi wrote: > I haven’t seen discussion of isolating some of the RT data structures > while sharing others and the executable p

Re: Using metadata to specify how calls to a macro should be indented

2015-09-22 Thread Gary Trakhman
Sometimes more than 0% when I'm doing something small in clojurescript, can't be bothered with the setup, and browser refresh is good enough :-). On Tue, Sep 22, 2015 at 4:02 PM Fluid Dynamics wrote: > On Tuesday, September 22, 2015 at 6:31:34 AM UTC-4, Phillip Lord wrote: >> >> ... The interesti

Re: Beginning Clojure Development

2015-09-09 Thread Gary Trakhman
In my opinion the best book for the 'fine details' of the language is going to be http://www.joyofclojure.com/ . It's not usually recommended as the introductory text, for that you might be better off with clojure programming: http://www.clojurebook.com/ or 'programming clojure': https://pragprog

Re: confusion about some paragraph in book "clojure programming" By Chas Emerick, Brian Carper, Christophe Grand 2012

2015-07-22 Thread Gary Trakhman
I am looking at the definition of fn and I can't see where let is used inside the function definition: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L4335 I think they're saying the binding forms are equivalent in power (destructuring), not implementation. On Wed, Jul 22

Re: [ANN] Clojure 1.7.0 is now available

2015-06-30 Thread Gary Trakhman
You'll have to bump instaparse versions: https://github.com/clojure-emacs/refactor-nrepl/issues/53 On Tue, Jun 30, 2015 at 12:57 PM Robert Beaupre wrote: > Is anyone else getting the following error with 1.7.0 when running lein > repl? All I did was change from 1.6.0 to 1.7.0. > > #error { > >

  1   2   3   4   5   >