This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-30
Channels
- # announcements (1)
- # beginners (94)
- # calva (12)
- # cider (5)
- # cljdoc (4)
- # cljs-dev (4)
- # clojure (170)
- # clojure-austin (2)
- # clojure-dev (45)
- # clojure-germany (53)
- # clojure-italy (20)
- # clojure-nl (6)
- # clojure-spec (25)
- # clojure-uk (242)
- # clojurescript (161)
- # cursive (16)
- # data-science (3)
- # datomic (20)
- # defnpodcast (6)
- # emacs (40)
- # events (1)
- # fulcro (80)
- # funcool (46)
- # jobs (1)
- # leiningen (23)
- # liberator (2)
- # lumo (43)
- # mount (3)
- # off-topic (21)
- # onyx (1)
- # pedestal (15)
- # re-frame (23)
- # reitit (4)
- # schema (1)
- # sfcljs (1)
- # shadow-cljs (167)
- # spacemacs (1)
- # tools-deps (21)
- # yada (2)
Morning.
Bore da pawb
morning
morning!
@agile_geek what do you think burned you out about it?
See my rant from last year! http://devcycle.co.uk/clojure-is-the-devil/
There were other factors I will not discuss in open channels.
interesting
there's an element of the idioms thing that I def sympathise with
did pro clojure on and off for 3+ years and continually felt dumb or like I didn't get it because of diff coding styles etc... but because it's a simple language in terms of its core you can at least read it and mentally parse it quite fast
but stuff like use of protocols or records or OO constructs still throws me all the time in other peoples' clojure (for example)
there's a bunch of other examples of stuff I don't do & others do (& vice versa)
E_DYNLANG is the thing that bums me out most... comprehending the correct shape of deeply nested structures and errors coming from changes in shape not being consistently propagated across the codebase
tests help, particularly with regressions, but static checking would help a lot more
I think plumatic/schema etc are good tools for that at an interface between systems level
and debugging data structures imo is def less painful than debugging objects
but yeah there's some things that are just hard
schema helps for sure - it's too little, too late though, and while i think i would still choose clojure again were i starting this project tomorrow (trivial JVM lib integration is what swings it) it does mean that clojure is definitely not my ideal language. were there another plausible, functional, persistent-ds, jvm+js targeted lisp with decent static checking i would prefer that
that's quite a specific wish list 🙂
but I know what you mean
however all things considered it's still an impressively well thought-out lang
credit where credit is due
absolutely - i'm only down on clojure because it's so close to ideal... most other langs i don't care about enough to criticize
I know what you mean 🙂
Morning
Quick question - anyone in here done the whole HTTP Upload -> S3 without__ a temp file on the disk?
I think that it can be done using Amazonica, but I am struggling to find a crib / example to work from... (My Google-Fu has been WEAK of late)
(defn build-s3-write-request [s3-bucket s3-key content-bytes]
{:bucket-name s3-bucket
:key s3-key
:input-stream (ByteArrayInputStream. content-bytes)
:metadata {:content-length (count content-bytes)
:content-type "binary/octet-stream"}})
(defn write-s3 [content]
(let [req (build-s3-write-request "bucket" "key" (nippy/freeze content))]
(s3/put-object req))
Of course if you're not serialising using nippy you might need a bit more in there before you can just wrap it in a ByteArrayInputStream
, but it shouldn't be too much
To get it back we have
(defn read-input-stream [input-stream]
(with-open [outputStream (ByteArrayOutputStream.)]
(io/copy input-stream outputStream)
(.toByteArray outputStream)))
(defn get-s3 [bucket key]
(-> (s3/get-object s3-bucket s3-key)
(:input-stream)
(read-input-stream)
(nippy/thaw)))
If you want the definitions for the namespaces I can give 'em, but it should be reasonably clear 🙂
It's a serialisation/deserialisation library by taoensso (also did the timbre logging lib and I'm sure some others)
What we were working with there was a map full of a load of java-time instances (Hurrah for no more joda-time and crappy Java time stuff now we're Java 8+), which aren't immediately serialisable to JSON with cheshire, and we didn't want to store as strings and keep having to parse and write them
So we just serialise the whole map to write to S3, and deserialise it on read from there
If you had something that was just JSON serialisable or whatever, I'm not sure what changes you'd need to make. The content-type
would probably want to be application/json
, but I think you'd still need to provide/read an input-stream, so you'd need to convert the map to a string and then get the string into a bytestream somehow (The Java classes might Just Do It if they're given a string, I can't recall)
I did once
but the code is in a place I can't see it any more
there's a way to do it with amazonica iirc
I think you want to use this - https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/s3/model/PutObjectRequest.html#PutObjectRequest-java.lang.String-java.lang.String-java.io.InputStream-com.amazonaws.services.s3.model.ObjectMetadata-
that looks familiar
nah me neither
is amazonica the one that's super dense & basically the tests are the docs?
@maleghast i went with the tempfile for s3 uploads - iirc i had to implement less to get it to work without blocking my threads
and on what your accountability model is (some people need external accountability like a gym buddy or trainer, some can do it themselves, some can only do it if they’re NOT supposed to do it)
I remember reading an article about why MOOCs have not turned out to revolutionise education: they have a huge dropout rate, something like 90%
I did a 2 day Clojure course with Stuart Sierra before I’d written a single line of Clojure. I found it extremely useful. If you’re not doing it for the certification I think there are really good courses out there
Hi Hugo. Was this an in-person course or something online?
It was in person. Back in Australia before a functional programming conference. I have no idea if he still does them
That must have been pretty awesome. I'm not jealous in the slightest 😉
Do you remember what sort of things he covered?
I was the language from the complete basics. I think we made it as far as macros in two days
I think I'd never look for certifications on a CV really
the only time I'd think "okay, that's good" is an AWS cert for a platform engineer
just because for some reason platform folks are v variable in quality
(well, no more than software engineers)
but maybe it's that the pool is smaller
(and in terms of personal experience, I’ve done internal company trainings in a giant corp, and certification with external company (inviqa iirc) and also (human) language courses, and in each case I found that I self-teach faster and more effectively, but benefit hugely from dense reference-like resources. Thus, I agree with “read a book”, if that includes “and play/write your own test code at the same time”)
Some of the workshops that get put on with conferences have looked interesting, though I’ve never been to any. For example - https://craft-conf.com/2018/workshops
https://www.youtube.com/watch?v=qJ_hplxTYJw also TEDx talk yay 😄
and certs are very industry-specific; apparently if you want to do security they’re worth the money. Cisco used to be worth it as well, I don’t know about these days.
Thanks All, specifically @carr0t @mccraigmccraig @alex.lynham @firthh and @jasonbell for S3-based input... I had to do a conference call and then I was head-first in some research and then lunch and finally I remembered that I asked a question in here...
@mccraigmccraig - When you went with tempfile on the disk in order to no block any threads, did you have a separate app / worker pushing the files to S3?
I;ve not found any training courses I've done to be hugely useful, but I think I've possibly not done them early enough
Normally I seem to pick something up, we work or I experiment with it for a few months on and off, then I/someone goes on a training course to see if we're missing everything/if we're doing it right
I've had little bits of training here and there that I found very helpful, but I know what you mean @carr0t
Which means often you're sat there for 95% of the course wishing they'd get onto more meaty stuff
And yet at the same time there's other people there who are new to the (whatever), who are asking "Why are we doing X? What does Y mean?", and it often isn't covered so well in the course
@maleghast just looked it up - yes, we're using a manifold.deferred/future
to do the transfer, which uses a separate thread
Even the Cisco courses I did, and sysadmin cert ones, were "enter these commands", but no real explanation of what the commands were for and why you were entering them. Which was fine for me, as I'd been doing net/sys adminning for a while, but meant that I didn't get as much out of it as I would have liked, and ended up helping other people understand what it all meant
@mccraigmccraig - Thanks, that's a paradigm I grok - I have a similar approach to doing database inserts off the back of async API calls.
it's not my favourite @maleghast - it's one of a very few places in our app where we aren't properly non-blocking, but doing it properly would be too much work for something that doesn't happen that often, so a thread it is
training courses are often good (I've helped teach some and learned clojure from Stu Halloway many moons ago, and having him to ask questions was really useful)
certification is a different thing. Sometimes even the "useless" ones are handy as they can be used as a filter by some bits of the org that aren't as clueful, but can help you get into a team that does have a clue
some of the scrum trainers will actually give you some good info in addition to the bit you need for the certification
Yeah, I found doing the Juxt Advanced Clojure with @malcolmsparks and @jonpither last year was really helpful.
I was 2 years from having done any "Clojure for money" and it really helped me get back into the swing of things, and pick up on some new (to me) ideas.
one of my questions to Stu H (after being frustrated by common lisp, emacs lisp and scheme) was "will map and reduce be the way to actually write production code that is suitably performant" and his answer was "yes"
is a horseshoe just a (partial reduce +)
?
@alex.lynham that use of partial really hurts me given the arities +
takes. 😉
haha I partially (see what I did there) wanted to troll
the 'joke' also I guess wouldn't work with (reduce + <horse?>)
I overreached with this one I think
it was tenuous at best
quite an achievement... do we finally talk about Clojure... do we somehow manage to get back to other things in no time.
wait hang on, I was thinking of sigma, not omega
ignore me
I don't have a lousy syntax joke about the end of a set
so... game, set and match to @lady3janepl and me?
if you have some reference data in a file that you use, what is your preferred way to make it available in your application?
say a csv file that you turn into a lookup table that gets used by lots of other functions
@otfrom depends on how it's going to get used - all yapster's bulk imports get turned into records in a bunch of append-only import tables, basically a direct representation of the import source data in a common scannable format
after that those import tables get joined with the tables from the live database and used to generate changes
mostly I'm trying to avoid doing it in a def as if I get a problem with the file, it will blow up during compilation
so no need to put it into a database, and again it is a batch process so I only need it in memory for the script to run
memoize it ?
but at least then if it goes bang it happens at run time rather than compile time (and my exceptions would be easier to read and the ns would actually load)
delay
is more appropriate than memoize
here i think
either way don't do it at compile time
pretty sure the JNI is trying to be "clever" about how it manages file resources and not doing it very well
it's been long time... is this helpful @otfrom http://www.kfu.com/~nsayer/Java/jni-filedesc.html ?
@guy 'cos you are adding a nil value to an empty list, giving you a list with one nil element
@mccraigmccraig the resource handling looks to be pretty buried in the library. It is doing some kind of reference counting. I'm just gonna run it single threaded
@guy squintily
from the docs
Added in 1.0
conj[oin]. Returns a new collection with the xs
'added'. (conj nil item) returns (item). The 'addition' may
happen at different 'places' depending on the concrete type.
@guy 'cos it's always been that way since way before clojure was a twinkle in rh's eye
the java that implements conj is here: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L667-L670
static public IPersistentCollection conj(IPersistentCollection coll, Object x){
if(coll == null)
return new PersistentList(x);
return coll.cons(x);
}
some history here: https://lispcast.com/nil-punning/
@lady3janepl except that an empty list doesn't equal nil
(= nil '())
false
(but then if you have a more than one whatever-type implements the protocol, it’s not possible to fluently cast between nil and “empty type X”. I’m guessing that’s why there’s no equivalency in Clojure - at the base level things just aren’t lists anymore?)
nil
represents an abstract concept of nothing. what happens if you conj
1 to nothing? well, conj
returns a collection, so it must be a collection containing 1
, hence (1)
. similarly if you do (map inc nil)
; map returns a sequence - what's the sequence equivalent of nothing? an empty sequence, hence ()
nil
not being the same as ()
is one of the differences Clojure has from other lisps, documented here: https://clojure.org/reference/lisps