Fork me on GitHub
#beginners
<
2016-07-03
>
mfikes00:07:07

@polymeris: Clojure Applied talks a lot about defining your own constructors that call ->Thing and this post also encourages the same: https://stuartsierra.com/2015/05/17/clojure-record-constructors

mfikes00:07:11

Also, Stuart points out in follow up on that post that mucking with ->Thing itself would be relying on implementation details.

polymeris00:07:39

Thanks, @mfikes, for the pointer. Guess I'll just use thing as my constructor.

lewix02:07:38

what are the best resources for web development in clojure

val_waeselynck16:07:11

@lewix: The Luminus framework (http://www.luminusweb.net/) and the book by his author Web Development in Clojure (https://pragprog.com/book/dswdcloj2/web-development-with-clojure-second-edition) are great places to start

lewix18:07:12

@val_waeselynck: I'm surprised that's the only book about web development out there

val_waeselynck18:07:40

@lewix: that's because there's not much to web development in Clojure. I think many web frameworks in other languages need to make up for deficiencies in the language's standard library and features set. Because Clojure is data-oriented, has declarative syntax, and good constructs for declaring / communicating between components, web concepts translate naturally into the language without much need for new technology.

val_waeselynck18:07:21

Basically, web development in Clojure is an HTTP-mapping layer + app development in Clojure

lewix18:07:13

val_waeselynck: just looking for a screencast from A to Z about web development in clojure is not a walk in the park as opposed to rails/node.js/django/C#...

lewix18:07:12

val_waeselynck: What you say may be true but I believe that the community doesn't invest as much in learning ressources

val_waeselynck18:07:43

@lewix: I agree about learning resources. Also, because of the emphasis of the community on simplicity over ease, you will tend not to find many out-of-the-box solutions. AFAICT people tend to choose Clojure to optimize their asymptotic speed, oftentimes at the expense of their startup speed.

val_waeselynck18:07:10

Having said that:

val_waeselynck18:07:28

1) lein new luminus <myapp> is quite a good quickstart

val_waeselynck18:07:04

2) Don't forget you have a REPL! You can learn very fast thanks to interactive programming.

seancorfield18:07:26

Yeah, the main thing I wanted with web apps in Clojure was the ability to have convention-based controller namespaces found and loaded, rather than declarative routes. So I ported the lightweight MVC framework I wrote in 2009 from another language to Clojure, and that’s what we use at work for some of our stuff.

seancorfield18:07:49

It’s basically Ring / Jetty / Selmer / Cheshire and my dynamic routes-to-namespaces logic.

lewix18:07:43

They way I usually learn is a mix of both reading , looking at screencast , and doing. Clojure/clojurescript has some books, not enough good and long enough screencast to refer to. It adds to the learning curve to always wonder if you're doing things right, and you can't refer to best practices. (my two cents)

seancorfield18:07:00

The CFML version is one of the two most popular MVC frameworks used in CFML.

seancorfield18:07:08

I’ll be interested to see what Arachne brings to the table but it sounds like it’s going to be so modular and general purpose (and data-configuration-driven) that I have a hard time believing it will be truly simple.

val_waeselynck18:07:59

@seancorfield: yeah seems to me it's the Pedestal story repeating itself

val_waeselynck18:07:38

(supported it all the same, I'd love to see a solution for web development that's both robust and accessible)

seancorfield18:07:41

@lewix: I agree with you on the lack of screencasts (although I personally don’t like them, I know many people find them one of the best ways to learn "how to").

seancorfield18:07:50

@val_waeselynck: Oh, totally, yes, having a great web framework that’s easy for new folks to stand up decent-sized apps will be a big boost for Clojure. But I’m no fan of Rails / Grails (or ColdBox in CFML) or any of the "big" frameworks.

lewix18:07:56

People learn differently @seancorfield. i found screencast a way to speed up my learning experience or get it started. Books usually reinforce it, and take me to the next level

val_waeselynck18:07:10

@seancorfield: I think there a fundamental opposition between simplicity and accessibility so I'm not too optimistic... But I have known Clojure to break such kind of tradeoffs 🙂 so looking forward to what's gonna come out.

lewix18:07:17

In rails/django there's a bunch of course where you see an app being built from A to Z. I wish clojure had more of those

lewix18:07:51

I'm not talking about 10min videos . I'm talking about 7-10hours courses

lewix19:07:49

Also, It doesn't have to be a framework.

val_waeselynck19:07:50

@lewix oh I see. Interesting. I never use that kind of resource indeed.

val_waeselynck19:07:11

@lewix: I also think that in the Clojure web community, a lot of the attention is focused on very cutting-edge paradigms like Om/Next etc. Definitely too early stage for that kind of resource.

lewix19:07:13

I guess but won't it always make clojure a language for other languages to get inspiration from rather than a to go to language?

akiva19:07:19

I don’t think so. And I mean that I don’t think Clojure’s popularity will be predicated on the presence of in-depth screencasts. Clojure’s still young, all things considered, and tends to demote all-encompassing frameworks so no one really wants to create a 7-10 hour screencast for a framework or paradigm that might six months down the road be relegated.

lewix19:07:37

akiva: I was referring to the fact that clojure focus is geared towards cutting/edge. Javascript probably move faster than clojure yet the learning resources are abundant - I don't think that's an excuse

val_waeselynck19:07:08

Also, people won't adopt Clojure because it's comfortable for web development, for which there are established (and quite good) alternatives. I believe language becomes mainstream when it's the first to solve a problem that's becoming popular, and classical Rails-like web development isn't a good candidate problem IMHO. Sophisticated single-page-app development might be.

val_waeselynck19:07:19

If I were to plan Clojure's strategy for taking over the world (which I'm not), I'd be looking for such a new problem domain.

val_waeselynck19:07:44

@lewix: in any case it's a good thing of you to report this kind of difficulty.

akiva19:07:57

JavaScript is older and more widely used, @lewix, and there are plenty of accepted paradigms already in place. Remember, Clojure is still a 1.x language. ClojureScript is even younger. Also, Clojure presents a programming paradigm that is foreign for many and difficult to adapt to for others whereas JavaScript, although technically prototypical, can be fully coded in a familiar way to OO. I agree with @val_waeselynck that simply resolving what’s already solved by other languages isn’t Clojure’s way ‘in’ so to speak.

lewix19:07:44

akiva: ok. what about elixir then, go ahead and google elixir screencast or learning materials.

akiva19:07:02

Clojure isn’t Elixir. Maybe their community is different. Just because language A is supported in a certain way that is amenable to you doesn’t mean language B must follow suit. Clojure promotes learning-by-doing which is why we have the Koans and whatnot. There are tons of learning materials for Clojure such as Clojure for the Brave and True and Living Clojure. Maybe Clojure people prefer to read than they do watch screencasts.

lewix19:07:06

I think that you miss the point. As I stated above I do both, and for your information I read both brave and true and living clojure.

akiva19:07:45

Maybe you should restate your point.

lewix19:07:05

I know a losing battle when I see one. I'll step back

val_waeselynck19:07:05

@lewix again, I'm not sure I can tell what you're looking for, but it seems to me that there are screencasts on youtube

akiva19:07:23

I don’t see a battle but okay.

val_waeselynck19:07:26

There's also video courses from Eric Normand

lewix19:07:39

val_waeselynck: I subscribed and watched 90% of it

lewix19:07:59

val_waeselynck: there's also lambda island

val_waeselynck19:07:23

@lewix by the way, I was thinking of learning a bit of Django one of these days, do you have such a screencast to recommend ?

akiva19:07:25

I watched a bit of http://www.parens-of-the-dead.com which I thought was quite good although probably too fast for someone new to Clojure.

lewix19:07:55

val_waeselynck: I did more rails than django a long time ago. However, I heard that https://godjango.com/series/building-a-product/ is good

seancorfield19:07:48

I find it interesting that the "state of the union" survey for Clojure has shown web development as the number one thing people do with the language . . . and yet there are still so few resources on "best practice" for web development and no "mainstream" ways to build web apps, beyond assembling a collection of your "favorite" libraries.

seancorfield19:07:18

And there are certainly a myriad ways to assemble libraries and build web apps with Clojure!

val_waeselynck21:07:37

@seancorfield: we chose Clojure and Datomic for my startup because we needed the 'superpowers' that go with it, the things these technologies let you do that have no equivalent in mainstream languages... we're still pioneering here, so i guess it's no wonder the best practices aren't established yet

montanonic21:07:41

Is there a more concise way to remove one level of structure than (mapcat identity coll)?

montanonic21:07:06

ah, sweet; ty

val_waeselynck21:07:06

Also cat if you're using it in a transducer

montanonic22:07:26

can something like (juxt (take-nth 2) (comp (drop 1) (take-nth 2))) be sensibly wielded? Or do I need to use partial on the inner arguments to prevent them from becoming transducers for this to work?

montanonic22:07:22

The goal: split an collection into two sub-collections with alternating elements. I've already solved it using partition 2 and then transposing, but I thought juxt would be a more elegant and clear way to express things

montanonic23:07:40

(juxt 
     (partial take-nth 2) 
     (comp (partial take-nth 2) (partial drop 1)))
Is working for now, but, all the partials hurt my soul

mfikes23:07:05

@montanonic: The only simplifications coming to mind are anonymous function literals (in lieu of partial), and rest:

(juxt #(take-nth 2 %) (comp #(take-nth 2 %) rest))

montanonic23:07:33

Is there any style-consensus on using anonymous literals vs partial?

montanonic23:07:02

Being used to currying, partial just seems much too long a name for such a common thing to do, especially in an otherwise succinct language.

mfikes23:07:41

If I had to guess, anonymous function literals appear to be more popular.

montanonic23:07:08

good to know; thank you

montanonic23:07:33

As an advocate of piping, I changed it further to

(juxt
     #(take-nth 2 %)
     #(->> % rest (take-nth 2)))