Fork me on GitHub
#beginners
<
2017-08-22
>
nbardy14:08:45

Is there a clojure core function to check if a collection is a subset of another?

nbardy14:08:26

Something to do (every? (into #{} coll) sub-col))

noisesmith15:08:33

This fails if coll contains nil or false.

noisesmith15:08:40

#(= (set/intersection coll %) %)

dpsutton14:08:57

my only thought is my route composition is off but i don't know how to do it differently i guess

nbardy14:08:51

Perfect. Thanks.

dpsutton15:08:01

figured it out. if you want to serve some json, don't forget to wrap your payload in the response function

emilaasa19:08:34

Hello! I'm just starting out with Clojure, following along with the http://braveclojure.com tutorial. I've mostly used vim as my editor before (10+ years), and never written any lisp at all, nor have I tried Emacs for more than a few minutes. Manually setting up all the vim plugins and config seems a bit daunting and distracting from my actual goal of learning some Clojure. Any advice as to how to get up and running smoothly?

donaldball19:08:19

Some would advise using a beginner-oriented editor while you’re learning. This seems like a decent list: https://cb.codes/what-editor-ide-to-use-for-clojure/

schmee19:08:44

@emilaasa I’m using Vim with https://github.com/bhurlow/vim-parinfer and it’s all I need

donaldball19:08:56

It seems like there’s a #vim-fireplace room here and they might be helpful in guiding you

schmee19:08:56

no need for any other editors

schmee19:08:11

I’ve been coding clojure for 3+ years, never needed fireplace

akiroz19:08:38

@emilaasa Also a vim user here~ 🙂 Here's the plugins I'm using now:

guns/vim-clojure-static
kien/rainbow_parentheses.vim
tpope/vim-classpath
tpope/vim-fireplace

akiroz19:08:29

I use di( to move things around in vim

schmee19:08:51

oh right, https://github.com/tpope/vim-surround is an absolute must as well

schmee19:08:00

forgot that it’s not built into vim 😄

schmee19:08:35

but seriously, you can go far without any plugins at all

emilaasa19:08:57

yeah it's how I'm starting out now atleast

akiroz19:08:19

I can't write clojure without rainbow parens now..... lol

dpsutton19:08:57

paredit for me. i don't type closing parens and i get structural editing. it's a necessity

emilaasa19:08:05

I've attempted to first perfectly configure my vim for the language I've wanted to learn a few times in my life. Usually ended up learning more about how to totally demolish a .vimrc than any actual programming.

schmee19:08:19

haha yeah that is the risk 🙂

schmee19:08:28

better to just get on with it, and add stuff as you go

akiroz19:08:04

completely opposite here~ I only type & delete parans in pairs 😄

emilaasa19:08:40

Yep I think I will do that, atleast I know there is some pretty big quality of life things I should sort out eventually, namely repl connection, something with balancing parens (?) and editing s-expressions

dpsutton19:08:02

I don't type closing because they are inserted for me when i enter a pair. I kill inside of a sexp so i maintain the invariant of balanced parens

dpsutton19:08:26

or kill at an opening one

dpsutton19:08:54

i can't imagine writing a lisp without some type of structural editing capability. also, emacs has a show matching paren that is invaluable to me

seancorfield19:08:02

I use ProtoREPL (Atom) and Parinfer -- hated Parinfer at first but forced myself to get used to it and now I absolutely love it! Also have the lisp-paredit package installed for structural stuff and indentation.

emilaasa19:08:23

This is just too cool 😃

emilaasa19:08:40

Anyone worked thru a book or tutorial that they can recommend? I'll probably run thru the basics, and then try rewriting a small web service (Java Servlet API) in Clojure as a practice project at work, if that narrows down the preferences at all

jennifer19:08:58

i like using Atom as well, but i'm coming from JS/front end land, so it's what i know. i've been working through Living Clojure by Carin Meier and really like it. it's workbook-like rather than a reference.

emilaasa19:08:32

Thanks for the tip jennifer! I usually like the workbook approach better as well

emilaasa19:08:41

I'll check it out

seancorfield19:08:58

@emilaasa What have you looked at so far? Clojure from the Ground Up? Clojure for the Brave and True?

emilaasa19:08:31

Yeah I'm about an hour into Clojure for the brave

seancorfield19:08:54

Yeah, I've heard good things about Living Clojure.

jennifer19:08:08

Brave and True is where i started and it was good for getting on the ground running.

seancorfield19:08:28

I'd expect the Clojure Cookbook and Clojure Applied to be good follow-on books, if you like stuff focused on real-world problems and solutions.

emilaasa20:08:00

It's what my boss likes anyway 😃

jennifer20:08:08

Clojure Programming was recommended to me as the follow up, so i've got that as well.

alexmiller20:08:14

I’ll add a totally unbiased plug for Programming Clojure, 3rd edition, which is available in beta (but with all of the text available as of about an hour ago)

alexmiller20:08:38

but also I recommend all of those books listed too

emilaasa20:08:00

Hmm something fishy about that totally unbiased plug

emilaasa20:08:15

But that is impossible since it's totally unbiased

dpsutton20:08:56

to second Alex's recommendation, I've bought that for myself and a coworker at my former company. really excellent book.

emilaasa20:08:33

Well an author that shows up in the #beginners slack channel is alright in my book, ordering now 🙂

dpsutton20:08:04

it brushes up against a good bit of java, some of the more bedrock classes, which is extremely helpful for people like me who do not know the java ecosystem

seancorfield20:08:10

My first Clojure book was The Joy of Clojure but I wouldn't recommend that unless you already have some FP and some Lisp background. My second book was Clojure Programming (Emerick et al).

emilaasa20:08:35

I've only done Haskell and done my best to keep the companys JS code as functional as possible 🙂

emilaasa20:08:02

I'm not sure the javascript experience helped much tho to be fair

emilaasa20:08:24

It did however want to make me jump out the window a few times

seancorfield20:08:39

JS always makes me want to jump our of a window 😞

seancorfield20:08:18

Overall, re: Clojure books, there's a lot of good ones out there and only a few duds so you mostly can't go wrong with whatever anyone recommends.

jennifer20:08:29

in the reverse, the stuff i've learned in clojure has made picking up the changes in ES6 smoother.

emilaasa20:08:37

sounds great I'll get a few and see

seancorfield20:08:34

I have a couple of sample chapters from the original Programming Clojure book and it looked fine but at the time it was using an outdated version of Clojure so I picked (several) others. Now it's been updated and a third edition is coming out, that's going to be one of the most up-to-date books.

seancorfield20:08:00

I bought Clojure in Action early on and it was written for Clojure 1.2 but not released until 1.3 was out so a lot of it was broken by that, unfortunately (I pleaded with Manning to have the author update it before release but they pushed it to market anyway).

emilaasa20:08:42

Thanks everyone by the way for being super helpful! These first hours in #beginners can really make a difference for how you feel about a language/community and you all are making it feel great! 😃

alexmiller20:08:46

PC 2nd ed was written against Clojure 1.3, but newest is targeted at 1.9

alexmiller20:08:19

btw, I am currently seeking a few reviewers for Programming Clojure! having some beginner(-ish) people would be great

alexmiller20:08:00

ping me in dm if you’re interested (free copy of the ebook included). heck, I’ll even send you a physical copy at my expense if the publisher doesn’t (can’t remember right now)

seancorfield20:08:08

I think PC 1st ed was written against 1.1 wasn't it @alexmiller ?

seancorfield20:08:21

(almost prehistory in Clojure terms now 🙂 )

seancorfield20:08:09

I just looked at Clojure in Action 2nd Ed (which I also have) and that was written against 1.6 so it doesn't cover some important recent features.

alexmiller20:08:11

I want to say it was 1.0 actually

seancorfield20:08:11

Before protocols? I'm trying to remember what was added in 1.1... Hard to believe how much the language has moved on since then -- but also incredible how stable and backward-compatible it has remained.

seancorfield20:08:09

For folks new to Clojure like @emilaasa I'll say: don't be afraid to try the very latest alpha features when learning Clojure (`clojure.spec` is incredible in 1.9 Alpha 17!) -- ever since my company adopted Clojure, we've been going to production on Alpha versions with huge success (our first Clojure launch used 1.3 Alpha 7 or Alpha 8 -- and we've been on 1.9 Alpha 17 in production for a while now!).

emilaasa20:08:31

Last alpha I put in prod was angular 2

emilaasa20:08:35

many regrets haha

seancorfield20:08:43

Clojure != JavaScript 🙂

ghadi20:08:46

alpha in clojure world is very different

ghadi20:08:40

some aspects of clojure have been marked alpha for multiple years

ghadi20:08:55

i wonder what's the oldest feature still marked alpha?

emilaasa20:08:44

Slow language churn feels like a good sign to me.

emilaasa20:08:39

One of my favorite newish languages is Elm which is notoriously slow to implement anything, very deliberate and thought through.

alexmiller20:08:05

almost nothing (other than the new spec) is still marked alpha

alexmiller20:08:14

yes, that and clojure.reflect

seancorfield21:08:31

Is clojure.reflect consciously marked as alpha because it might change, or because it was never fully fleshed out in the first place and never got worked on again?

alexmiller21:08:28

the alpha tag was consciously not removed from clojure.reflect in 1.6 (when we removed it in most other places) because it is still subject to change

alexmiller21:08:44

so yes, that is deliberate

alexmiller21:08:08

I’m not sure anyone ever actually uses it :) one of the reflectors is actually broken in JDK 8 and no one has ever mentioned it

alexmiller21:08:41

will be fixed when we remove support for jdk 6 and update asm next

dpsutton20:08:29

match but not sure if that's part of the sphere we are talking about now

alexmiller20:08:44

nah, just talking about core

alexmiller20:08:30

*compiler-options* is also marked as alpha, but I don’t think for any good reason

ghadi20:08:26

i feel like reducers, except for fold & cat, should be deprecated

seancorfield21:08:26

It would be nice to have some form of (parallel) fold in core -- I had hoped we'd see that with transducers (but haven't thought that through to see whether it's even a sane hope). The reducers library feels like a bit of a dead end now: it appeared, never seemed to get much traction, and mostly feels overtaken by transducers. /cc @alexmiller

alexmiller21:08:27

I would say that reducers is effectively deprecated (but does still have unique utility). there are no plans to (ever) remove the namespace.

seancorfield21:08:53

Always accretion... 🙂

alexmiller21:08:18

and I expect that eventually the ideas of fold will evolve into something - it’s an important use case and will only grow more so

didibus22:08:04

Since this is #beginner, I'd say reducers are easier to grok then transducers, so lazy-sequence -> reducers -> transducers is a good small increment steps to learning

alexmiller22:08:02

I find transducers to be easier to both use and implement actually :)

seancorfield22:08:38

I agree on "use". Not sure I agree on "implement". I'm still a little hazy on when/how the zero-arity version is invoked.

grounded_sage22:08:26

hey does anyone know how to show docs in the Proto-repl?

grounded_sage22:08:12

I’m about to go to a job interview and haven’t used clojure for a while. I’m planning on using it for the code challenges… never done this before so I’m kinda freaking out haha.

seancorfield22:08:43

(when you're on a symbol and have a REPL running)

grounded_sage22:08:07

do I have to be in REPL? not file?

seancorfield22:08:17

In the file, but have a REPL running.

seancorfield22:08:29

It uses the REPL to run the code to look up the docs.

grounded_sage22:08:37

I was missing the comma

seancorfield22:08:12

If you bring up the command palette (cmd-shift-p on a mac, can't remember on windows) you can just type documentation and see all the keymappings

grounded_sage22:08:39

cool I think I should be alright now. I was planning on using Racket but I think I’ll be more confident with Clojure

seancorfield22:08:05

So cmd-opt-d works on a mac as well, and ctl-, d should also work

grounded_sage22:08:19

I was just doing ctrl-alt d without comma and it was deleting up to that point

seancorfield22:08:37

If in doubt, start from the command palette and it'll show the keyboard shortcuts.

seancorfield22:08:56

And BTW there's a #protorepl channel, if you're not already a member @grounded_sage

grounded_sage22:08:07

Cheers. Yea I started using Atom because I wanted to use Parinfer. Was using Spacemacs before hand. Proto repl is definitely cool. Still unsure whether switching to Atom was best decision. Time will tell I guess

grounded_sage22:08:28

I've been doing a lot of Elm and Elixir recently. Miss the lisp repl

seancorfield22:08:51

I used Emacs way back (in the 17.x/18.x days) then found my way back to it after getting into Clojure and used it heavily again for a couple of years. I switched completely to ProtoREPL after Conj last year and I do not regret that change.

hmaurer21:08:33

You think ProtoREPL is on par with CIDER? I am wondering which-one I should try out

seancorfield21:08:13

It depends entirely on how much of CIDER's rich functionality you are used to in your daily workflow.

seancorfield21:08:55

Your choice is more likely to depend on whether you prefer Emacs or Atom as your core editor.

seancorfield21:08:09

One feature of CIDER that I missed at first with ProtoREPL was the ability to have multiple REPLs open but I've adjusted my workflow to where that's no longer an issue.

didibus22:08:44

I get people who are behind emacs, but if there was one and only one thing that I believe hurts Clojure adoption with beginners, its emacs. I wonder how much emacs has hurt lisps over the years even in terms of widespread adoption. If the language won't be familiar, at the very least having the editor be familiar would be nice. Proto-repl I think is leading the way in that direction.

bfabry22:08:13

fwiw, Cursive supports paredit and parinfer, is a lot more stable/mature than atom, almost as feature-complete as emacs for clojure dev, and is quite newbie friendly

seancorfield23:08:21

@bfabry I think the deciding factor there is whether you want an IDE (IntelliJ/Cursive) or an editor (Atom/ProtoREPL).

seancorfield23:08:47

I could never grow to like IntelliJ back when I was using IDEs -- I tried a lot of different versions and just don't like the UI. I used Eclipse in preference (although I never really liked Eclipse either). For a while, with Clojure, I used Eclipse/CCW.

bfabry23:08:53

I find that distinction pretty hard to grasp

bfabry23:08:09

emacs usually runs in some sort of project mode, ditto vim, ditto lighttable

noisesmith23:08:26

I’ve never used a “project mode” in vim fwiw

noisesmith23:08:39

(and it’s my main editor)

bfabry23:08:58

are you sure? if you opened a ruby project and you had one of the "normal" ruby plugins you were

noisesmith23:08:09

I don’t open projects

noisesmith23:08:11

I open files

bfabry23:08:10

shrug fair enough I guess. though I definitely open files in cursive

bfabry23:08:48

I used vim exclusively as a ruby developer for like... 6 years? and I don't really feel much difference between it and emacs for clojure or cursive for clojure

noisesmith23:08:25

sure - but I don’t have anything in vim that even knows what a “project” is - it could be that many vim or emacs users are using the right extensions to have an IDE, but I don’t think it’s universal.

bfabry23:08:10

cwd in vim was pretty much my equivalent to project. not everyone uses it that way, though it's certainly very common

noisesmith23:08:18

if cwd is a project, ed is an ide

bfabry23:08:28

well my whole point was that I don't think the distinction is meaningful...