Fork me on GitHub
#beginners
<
2016-12-07
>
gary01:12:28

Understanding destructuring and all of its many forms is an essential thing to get familiar with from the very beginning

Lone Ranger01:12:53

Clojure is so magic. I'm trying to wrap my head around how clojure can do argument destructuring if it's not even possible in java.

Lone Ranger01:12:22

I'm just going to go ahead and assume it's a pretty efficient operation

gary02:12:26

@goomba Even if Clojure didn't have it you would be able to write the destructure function yourself and then write a macro for let and fn that wraps the args in your destructure function

gary02:12:34

Another advantage to Clojure (and lisps in general) is that you can extend it

Lone Ranger02:12:55

@gary: if that doesn't get you hot under the collar I don't know what does.

Lone Ranger02:12:41

(probably says a lot about my love life but I'll save that for #off-topic lol)

seancorfield02:12:17

@goomba If it's any help, most folks I know who do Clojure for any length of time tend to fall in love with the language šŸ™‚

gary02:12:20

I remember seeing a blog post about someone implementing Clojure in Thai using macros

gary02:12:34

For some reason I can't seem to find it

Alex Miller (Clojure team)03:12:30

destructuring is actually pretty straightforward to think about

shaun-mahood03:12:32

Clojure west talk too, right?

Alex Miller (Clojure team)03:12:52

just imagine rewriting destructuring as a let, and thatā€™s pretty much what it does

shaun-mahood03:12:53

Such a cool project

gary03:12:41

My gf is still harassing me about writing a library like that except it would be Clojure in long English

gary03:12:17

def would be "define" etc

gary03:12:44

It shouldn't be that difficult since there aren't a ton of Clojure functions that are abbreviations

kyle_schmidt13:12:10

I have an endpoint at '/messagesā€™ that executes a sql query. This endpoint has worked within the past couple of days but today I am receiving this error:

IllegalArgumentException db-spec mount.core.DerefableState@54afee5f is missing a required parameter  clojure.java.jdbc/get-connection (jdbc.clj:309)
The google responses for this error are a little vague to me and would appreciate some help if anyone has come across this in the past?

dominicm14:12:29

@kyle_schmidt is mount started? Seems that your mount usage is a bit wonky

gdeer8117:12:59

@alexmiller @shaun-mahood thanks for helping me find that project, it does exactly what I was going to do āœ…

Lone Ranger18:12:10

question about the clojure beginner preconference workshop

Lone Ranger18:12:42

personally feel like biggest challenge in taking clojure from small projects to production (and more importantly convincing my company to do so) is setting up the architecture and best practices for incorporating database, web api, and biz logic. Obviously the nuances are important. Does the intro to clojure workshop cover that sort of thing or is it more about writing in Clojure in general?

Alex Miller (Clojure team)19:12:38

I assume you're asking about the workshop prior to the conj

Alex Miller (Clojure team)19:12:02

That workshop is primarily about the syntax and features of Clojure

Alex Miller (Clojure team)20:12:21

We've considered doing something that is more architecture / project based too, but it's problematic in some ways

seancorfield20:12:37

@goomba I think one of the challenges with that ā€œarchitecture and best practicesā€ piece is that it changes a lot over time (and itā€™s also often very tied to your system / company / project).

seancorfield20:12:10

I find, after five and a half years of production Clojure, that Iā€™m constantly learning new and better ways to structure my applications.

Alex Miller (Clojure team)20:12:16

In particular, we worry a little about picking some set of libs and "endorsing" them as Cognitect as "the" way to make Clojure apps

seancorfield20:12:44

Yes, that is definitely a concern once you move beyond the Contrib suite of libraries.

Alex Miller (Clojure team)20:12:07

I at least don't think that does or should exist

Lone Ranger20:12:41

I think he means "the" way (should not exist)

seancorfield20:12:44

Or ā€œtheā€ way to make apps?

Alex Miller (Clojure team)20:12:43

That = a single way to make apps

Alex Miller (Clojure team)20:12:41

There are many answers and many kinds of apps and we should always be open to something new too

Lone Ranger20:12:08

I think maybe what I'm looking for (hopefully) is a little more basic, like how to use lein to manage dependencies, how to set up your project.clj file, those sorts of things

Lone Ranger20:12:40

I'm looking for a more of "this does that" than a "this is what you should do"

Alex Miller (Clojure team)20:12:52

Some of that actually is in the intro workshop

seancorfield20:12:49

And some of that is covered in the community docs? http://clojure-doc.org

seancorfield20:12:57

@goomba One of the things we found, as our projects grew in complexity, was that Leiningenā€™s declarative approach was a bit too restrictive and we switched to Boot (about a year ago). There are many, many upsides to that choice but there is also a big downside: with Boot, your build file is ā€œjust Clojure codeā€ so there really are very few proscribed ways of dealing with projects.

seancorfield20:12:04

On the topic of dependencies, we have a central version.properties file that specifies the versions of any library that we use in more than one project, and then each project has a deps.edn file containing just the list of (production) dependencies for that project. Our build files read both and replace the version from deps.edn with the one from version.properties as needed (we usually put a dummy ā€x.y.zā€ version placeholder in the deps.edn file to signify that it is always overridden).

Lone Ranger20:12:28

Interesting. I'll look into that. Hell I wouldn't even mind a 'hand-tooled' approach, as long as I know what I'm doing. Coming from a Python shop we don't really have any build tools anyway, everything is more or less hand-tooled

seancorfield20:12:59

That way we can assemble artifacts in any way we want from a number of projects, by sucking in all the deps.edn files and concatenating the dependencies from each.

Lone Ranger20:12:04

Problem is I have no idea what I'm doing yet šŸ˜›

seancorfield20:12:19

Yeah, and it took us a good long while to evolve that approach.

Lone Ranger20:12:50

Adding in ClojureScript seems to take the complexity up a notch due the nature or requiring various cross-compilations

seancorfield20:12:08

Even with the web apps weā€™ve built, weā€™ve taken several approaches over the years and weā€™re still constantly evolving our own in-house ā€œbest practicesā€.

Lone Ranger20:12:16

Ah, maybe Clojure "devops" is the word I'm looking for

seancorfield20:12:17

If youā€™re interested in reading a bit more about the capabilities of Boot and how we use it, check out some of my blog posts http://seancorfield.github.io/blog/archives/

Lone Ranger20:12:24

To make this transition I need to make sure developers can just focus on developing, shouldn't have to worry as much about their code not working because I didn't set up the project right

Lone Ranger20:12:32

beautiful @seancorfield , thank you!

seancorfield20:12:17

We actually keep boot itself under version control in our repo and have a shell script wrapper tailored for our environment (also under version control).

mlev22:12:04

I'm working through the book "Web Development with Clojure, 2nd Ed", and when I try to run (mount/start #'guestbook.db.core/db) in the nREPL, I get the following error: 'ClassCastException mount.core.DerefableState cannot be cast to clojure.lang.IFn guestbook.db.core/eval30818/fn--30819 (core.clj:8)' Does anyone know what the issue might be? I also had an issue connecting to the nREPL server on port 7000 using "lein repl :connect 7000", so I went with "lein repl" instead, which then worked and connected properly.

mlev22:12:54

This is for a Luminus Web App.

seancorfield22:12:00

If you did lein repl, it just started up a new REPL, it didnā€™t connect to your running app (just FYI).

seancorfield22:12:06

That ClassCastException indicates you are trying to call something that is not a function (instead itā€™s a DerefableState object.

gdeer8122:12:25

@mlev what happens if you run (mount/start #'guestbook.config/env)

seancorfield22:12:18

There is a #luminus channel BTW, in case folks here canā€™t help (Iā€™ve never used Luminus so my help here will be rather generic).

gdeer8122:12:28

this is a problem that can be solved generically, the mount library is trying to use a state object as function

gdeer8122:12:17

the mount/start doesn't specify the valid args, it's just [& args] so it will accept anything and then blow up at runtime

gdeer8122:12:02

so it might be wanting some context and then the db var, who knows

mlev22:12:49

@seancorfield , thanks I posted to that channel as well šŸ™‚ Maybe it is a more simple issue to start off with. If lein repl does not start it from the same directory at the app, how can I start a repl connected to the app?

mlev22:12:59

The books says >When the application starts in development mode, it automatically runs the nREPL server on port 7000. We can connect to this REPL and inspect the running application as follows lein repl :connect 7000

seancorfield22:12:48

Sorry, I donā€™t have the book so I donā€™t know what itā€™s asking you to do...

mlev22:12:51

This is the connection error message: >onnecting to nREPL at ......:7000 ConnectException Connection refused: connect java.net.DualStackPlainSocketImpl.connect0 (DualStackPlainSocketImpl.java:-2) java.net.DualStackPlainSocketImpl.socketConnect (DualStackPlainSocketImpl.java:79) java.net.AbstractPlainSocketImpl.doConnect (AbstractPlainSocketImpl.java:350) java.net.AbstractPlainSocketImpl.connectToAddress (AbstractPlainSocketImpl.java:206) java.net.AbstractPlainSocketImpl.connect (AbstractPlainSocketImpl.java:188) java.net.PlainSocketImpl.connect (PlainSocketImpl.java:172) java.net.SocksSocketImpl.connect (SocksSocketImpl.java:392) java.net.Socket.connect (Socket.java:589) java.net.Socket.connect (Socket.java:538) java.net.Socket.<init> (Socket.java:434) java.net.Socket.<init> (Socket.java:211) clojure.tools.nrepl/connect (nrepl.clj:184) Bye for now!>

mlev22:12:23

@gdeer81, I think I need to connect to the repl before I can try running (mount/start #'guestbook.config/env)

gdeer8122:12:56

Is your firewall blocking port 7000?

shaun-mahood22:12:15

@mlev: Have you started the application? You will probably have to do something like lein run to get it started.

mlev22:12:16

@shaun-mahood , when I run "lein run" I get: >"2016-12-07 17:25:40,528 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider read config from resource: "config.edn" read config from file: ".lein-env" 2016-12-07 17:25:41,077 [main] INFO guestbook.env - -=[guestbook started successfully using the development profile]=- 2016-12-07 17:25:41,171 [main] INFO luminus.http-server - starting HTTP server on port 3000 2016-12-07 17:25:41,233 [main] INFO org.xnio - XNIO version 3.3.6.Final 2016-12-07 17:25:41,437 [main] INFO org.projectodd.wunderboss.web.Web - Registered web context / 2016-12-07 17:25:41,437 [main] INFO luminus.repl-server - starting nREPL server on port 7000 2016-12-07 17:25:41,452 [main] INFO guestbook.core - #'guestbook.config/env started 2016-12-07 17:25:41,468 [main] INFO guestbook.core - #'guestbook.handler/init-app started 2016-12-07 17:25:41,468 [main] INFO guestbook.core - #'guestbook.core/http-server started 2016-12-07 17:25:41,468 [main] INFO guestbook.core - #'guestbook.core/repl-server started"

mlev22:12:40

but it doesn't give me another command prompt line.

gdeer8122:12:10

Yeah port 3000 is fine but your laptop is blocking port 7000

gdeer8122:12:32

You could open up another terminal and connect to the running repl now 'lein repl connect localhost 3000'

bcbradley22:12:24

if i give reducers/fold core/concat as a combiner, it would simply return things out of order right?

mlev22:12:49

@gdeer81, thanks, that is good to know. I tried lein repl connect localhost 3000 but the result was unknown subcommand connect.

mlev22:12:38

I did that with lein run running in the other command prompt window.

seancorfield22:12:58

@mlev he meant lein repl :connect localhost:7000 I think

seancorfield22:12:08

(based on what lein help repl shows)

seancorfield22:12:35

You could also try lein repl :connect 127.0.0.1:7000

seancorfield22:12:32

(I know some peopleā€™s laptops have some network setup that prevents access via localhost but allows it via 127.0.0.1)

mlev22:12:57

@seancorfield , lein repl :connect 127.0.0.1:7000 worked perfectly. Thanks for all your help everyone!

ryanlabouve23:12:09

Howdy everyone! I'm a totally new Clojure. I'm coming from a javascript (ember) and ruby (ruby on rails) background. Looking for an ambitious intro to language and ecosystem. Any suggestions for the best resource to start with to give me an ambitious trip through clojureland? Looking at: Joy of Clojure, Clojure for the Brave and True, and Living Clojure... didn't know if there was a canonical best first serious step?

Lone Ranger23:12:44

hey @ryanlabouve šŸ™‚ I'm in the same proverbial boat

ryanlabouve23:12:20

Any resource in particular stick out to you so far? šŸ™‚

gdeer8123:12:25

I'm reading Clojure for the brave and true and it is pretty beginner friendly

Lone Ranger23:12:36

2nded for Clojure for the Brave and True

Lone Ranger23:12:05

it does a pretty good breadth/depth, light on 'ecosystem' though

ryanlabouve23:12:12

Are you both already emacs'ers?

Alex Miller (Clojure team)23:12:35

Iā€™d start with either Brave and True or Living Clojure first

Alex Miller (Clojure team)23:12:01

and either Joy of Clojure or Clojure Applied second

Alex Miller (Clojure team)23:12:18

(I am a co-author of the latter, so bias noted :)

ryanlabouve23:12:49

HA! Thanks for the disclosure šŸ˜› No shame in being proud of your work though šŸ˜„

Alex Miller (Clojure team)23:12:25

I recommend all the other books too :)

Lone Ranger23:12:25

any suggestions on a light weight web framework for clojure apps?

Lone Ranger23:12:52

would love something a la Flask (Python)

Lone Ranger23:12:13

trying to get Clojure in on some microservices action šŸ˜„

Alex Miller (Clojure team)23:12:36

there is not one canonical answer in Clojure

Lone Ranger23:12:57

lol I don't need a canonical answer just any answer šŸ˜›

Alex Miller (Clojure team)23:12:14

many things are built on top of Ring (which is almost too light be a ā€œframeworkā€)

Lone Ranger23:12:26

I'm good with that

Alex Miller (Clojure team)23:12:27

Luminus is a set of libraries glued together in a template

Alex Miller (Clojure team)23:12:45

The Web Dev with Clojure book uses this

Alex Miller (Clojure team)23:12:10

there are alternatives to Ring as well like Pedestal or Yada

mlev23:12:29

Living Clojure will teach you more fundamentals of the language, Clojure for the Brave and True will have you work on more application-style beginner work, based on my experience with them.

noisesmith23:12:37

yeah, Luminus is probably the "safest" option for a newcomer, in terms of using tools that are well documented, and other people are actively maintaining

mlev23:12:46

Web Dev with Clojure, make sure you get the 2nd edition, not the first, though.

mlev23:12:44

If you find yourself buying multiple books, you may want to consider https://www.safaribooksonline.com/pricing/

mlev23:12:09

You can get a monthly membership, and it gives you access to all of the latest books, which includes most of the latest Clojure dev books.

gdeer8123:12:57

And don't forget @ericnormand has some excellent training resources

Lone Ranger23:12:09

just something that can serve up APIs is all I really need

Lone Ranger23:12:33

thank you all for the suggestions šŸ™‚