Fork me on GitHub
#beginners
<
2017-09-05
>
seancorfield02:09:52

@grierson I'd say that if your function has an "obvious" and fairly straightforward property that holds across all inputs and outputs, then it's a good candidate for :fn, as long you plan to have explicit process (or code) to perform stest/check on that function (since instrument does not check :fn specs).

seancorfield02:09:40

If the property is complex or has some non-obvious exceptions to it, then I'd put it in several unit tests instead (and perhaps still have some generative property testing in place as well).

seancorfield02:09:26

But as @eggsyntax said, having :args alone can be very valuable -- both for documentation and development/testing with instrumentation in place.

juanjo.lenero03:09:21

Can someone tell me why the first form works but the commented one doesn’t?

juanjo.lenero03:09:37

(ns interop.seed
  (:import [com.github.javafaker.Faker]))

(com.github.javafaker.Faker.)
;; (Faker.)

juanjo.lenero04:09:19

I thought :import [com.github.javafaker.Faker] would allow me to use the Faker class without its prefix.

alexmiller04:09:44

you want (:import [com.github.javafaker Faker])

alexmiller04:09:59

or (:import com.github.javafaker.Faker)

juanjo.lenero04:09:23

Didn’t know about that, thanks, it worked.

seancorfield05:09:01

Hey @alexmiller On a stylistic issue, I always seem to see :import with a list, not a vector, but :require with a vector instead. Any historic reason for that?

didibus04:09:08

Like Stu says in the article, using list instead of vector on :import is the most contentious, I prefer vector, visually, I find it easier to parse.

jumar05:09:52

@seancorfield not sure if it helps, but I've found some info in https://stuartsierra.com/2016/clojure-how-to-ns.html

seancorfield06:09:46

@jumar I remember reading that and wondering how canonical it was... it's fairly recent and Stuart is fairly authoritative 🙂

alexmiller11:09:38

I will tell you that Rich read Stuart's post and disagreed with the import bit. :)

seancorfield17:09:35

Good to know, thanks. Also good to hear a few people saying they use vectors instead of lists in :import. I might switch now since the difference has always bothered me although I understand Stuart's reasoning.

alexmiller11:09:24

I always just use vectors in both always so I don't have to think about it. But opinions vary.

simon15:09:00

Hi guys, pardon my novice! Can I use Datomic(which I will need to build capacity on) as my primary datastore or I might need to incorporate it with RDBMS(which am familiar with) like MySQL, and do I use them together(of which I read is a possibility). Or is it like a bridge like druid provides? And why?! Also where does a library like Onyx and manifold come into play. BTW, I intend on building a fault tolerant, high traffic(hopefully 🙂 ), low latency REST based engine with re-frame on the front.

eggsyntax20:09:42

@ is correct that Datomic works on top of a backend — but I worry that might give the wrong impression. With the exception of basic DB admin (installing, configuring, etc), the backend is essentially invisible — all your interactions are with Datomic. For example, I’ve been working full-time on a large, Datomic-backed project for about a year, which is backed with a SQL DB, and I’ve never once written or looked at a SQL statement while working on the project.

hmaurer20:09:12

@eggsyntax @simon ah yes, I should have specified. Datomic makes very few assumptions about the storage backend. Basically it only requires it to act as a key/value store with the ability to compare & swap (afaik).

hmaurer20:09:53

It does not use any SQL-specific (or Dynamo-specific) features

simon00:09:15

Thanks guys. Much appreciated!

didibus04:09:42

Onyx and manifold are probably not necessary for what you describe. Manifold is just a wrapper around different concurrency primitives, so you can use them together. Onyx is a distributed computing platform for data-processing.

didibus05:09:24

@simon For your use case, you probably want Pedestal, or Liberator, or Compojure, or Yada for your REST backend. You should check out Riemann for monitoring, and logback/tools.logging or timbre for logging. Bolt or Buddy for security. Diehard and Again or Safely for retries, circuit breaking, rate limits.

itaied16:09:46

Is there a left-to-right variation of comp? Something like (pipe (partial map inc) (partial filter even?)) instead of (comp (partial filter even?) (partial map inc))?

ghadi16:09:29

why do you need that @itaied ?

hmaurer16:09:34

@simon Hi! Datomic does not handle persistence, so you will need some form of backend for that

hmaurer16:09:52

Options are a SQL backend (mysql, postgres, …), DynamoDB, and a few others

hmaurer16:09:27

@simon regarding Onyx, there are one or two episodes of the Cognicast talking about it

hmaurer16:09:20

Don’t go too crazy on Onyx etc if you are new to Clojure though. Make sure you map out your requirements and keep it simple stupid at first

itaied16:09:53

@ghadi I find it more readable

hmaurer16:09:02

I am new to Clojure myself and haven’t tried Onyx yet, but I do know distributed systems are hard, and from what you are saying I suspect you won’t need it

itaied16:09:55

and also, like ->>, I think that omitting the partial at every step makes it much easier to write and read

itaied16:09:04

(->> val (map inc) (filter even?)) is much easier than (comp (partial filter even?) (partial map inc)), but it doesn't return a function

ghadi16:09:18

you can use transducers

ghadi16:09:02

(transduce (comp (filter even?) (map inc)) ....)

ghadi16:09:34

it will appear to compose the opposite way, but once you look into transducers you'll see it's not

itaied16:09:43

ok I'll take a look at that

dimovich16:09:22

is there some example e-shop projects in Clojure?

dimovich16:09:56

or, broadly speaking what would a good e-shop framework be at this time? not necessarily Clojure related

eggsyntax20:09:09

@dimovich for the most part, the Clojure/script community has chosen small composable libraries rather than large frameworks. But for a substantial web app, I’d personally suggest looking at Luminus as a good way to get started: (http://www.luminusweb.net/

genec20:09:23

@dimovich There is also a book by the Luminous author "Web Dev with Clojure, 2nd ed" that I found to be a very good introduction