Fork me on GitHub
#beginners
<
2017-05-27
>
Drew Verlee01:05:48

i’m not seeing a way to do this which doesn’t involve a branch statment to check if the value is negative or not.

Drew Verlee01:05:44

hmm apparently this has been written about …

lilactown14:05:35

luminus vs. pedestal - thoughts?

lmergen15:05:38

hey guys, i’m trying to understand how exactly to use java interop with Enums — specifically, I’m trying to use the java.text.Normalizer.Form enum… if I have already imported the java.text.Normalizer, how can I import that ? I thought that using java.text.Normalizer.Form/NFD would’ve done the trick, but it generates a ClassNotFoundException… any suggestions ?

vitruvia15:05:48

I realize from my latest exercises that many functions in clojure are implemented recursively. Isn't recursion slow?

lmergen15:05:52

nvm, figured out it apparently was Normalizer$Form/NFD 🙂

matan15:05:52

can one set a dependency of a latest version of a library, rather than a named version of it, in leiningen's project.clj? e.g. for having dev-mode stuff like criterium always current

john15:05:55

@vitruvia more often then not, you should see recursion implemented with recur, which is tail-call optimized.

vitruvia15:05:41

but does that make it faster than an iterative alternative or a memoization?

noisesmith15:05:44

a call to recur turns into a loop

noisesmith15:05:48

it is iterative

noisesmith15:05:08

(loop [x 1] (if (< x 10) (recur (inc x)) x)) is effectively for(x = 0; x < 10; x++){};x;

noisesmith15:05:33

on a byte code level it should be nearly identical

john16:05:24

@matan I don't believe so, but in general options like that (wildcards, globbing, implicit imports) are frowned upon in Clojure.

john16:05:48

@matan you can get similar things done though with https://github.com/xsc/lein-ancient using lein ancient upgrade

john16:05:41

Note that :only/:exclude compose with the :dependencies/:plugins/:all options - to e.g. only upgrade SNAPSHOTs of plugins you'd use:

$ lein ancient upgrade :plugins :only snapshots

john16:05:07

@lilactown Pedestal is more of a kind of framework. Not in a project template kind of way, but in that it has a number of new ideas that it provides, such as interceptors. Luminus is much more of a collection of libraries framework. It's like an opinionated collection of libraries that make up a stack that you might have assembled yourself, had you searched for the best combination of libs. You don't have to build your stack that way, but Yogthos has done a lot of that legwork for you and wrapped it up into a nice package.

john16:05:22

Luminus has been out for a while now though, so it might provide a number of tricks of its own, but that's the original design difference between the two, IIRC

john16:05:32

It's probably possible to rip out a number of pieces of Luminus and cram Pedestal in there, if you really wanted to.

noisesmith16:05:15

more likely, put parts of luminus into pedestal?

john16:05:57

doesn't Luminus bring in ring/compojure? I'd imagine there's a way to replace those bits with pedestal bits, in principle

noisesmith17:05:46

@john I don't think pedestal uses ring

john17:05:00

Might not be a good idea with respect to the other libs in the stack.

noisesmith17:05:01

it's its own beast

john17:05:39

It actually does use a bit of ring, I believe. But yeah, bolting pedestal into luminus' framework might be non-trivial

john17:05:44

I moreless bring up the idea to contrast the differences between the two. Might not be a good idea.

noisesmith17:05:32

oh, it does actually pull in ring-core when I make a new pedestal-app clone

john17:05:11

Guess they didn't want to reinvent what they didn't need to.

noisesmith17:05:50

also using ring means they can use all the libs implemented as ring middleware

john17:05:20

Oh, I meant doesn't Luminus bring in ring/compojure, above, sorry. fixed.

noisesmith17:05:17

yes, luminus is based on ring and compojure

noisesmith17:05:28

I was surprised pedestal was doing it too haha

lepistane17:05:03

question in general about frontend lets say i have users that arent supposed to see some options if they are not logged in should i just hide those in css (display: none) (and prevent action from being made if not logged in) then when they do login change css or something else?

noisesmith17:05:38

is this a question of things being pretty, or securing data they shouldn't be able to access?

noisesmith17:05:50

if it's an appearance thing, sure, use display:none

noisesmith17:05:00

but don't even send the apropriate data if it's about security

lepistane17:05:47

basically i'd have functon that 'draws' interface for logged out user and same function for logged in with added options

noisesmith17:05:12

for my app, we don't even send the cljs code until someone logs in - that keeps it simple

noisesmith17:05:28

prevents leaking implementation details or accidental data via the code

lepistane17:05:51

i am forced to do it like this

lepistane17:05:08

if it was up to me i'd do it like you did

lepistane17:05:15

thank you very much

lilactown19:05:30

@john thanks for the breakdown!