Fork me on GitHub
#beginners
<
2018-09-23
>
seancorfield01:09:12

@hoopes As a bit of a follow up to the discussion earlier about JVM-based web servers: it's common for them to handle each new request in a separate thread automatically. They typically have a pool of threads and if no threads are available, incoming requests will stall until a thread is available (so it is important to tune threads if you're dealing with really high traffic). When folks talk about async in the Clojure world tho', they generally mean something a bit different (since the basic web servers are already multi-threaded and handle concurrent requests out-of-the-box). Pretty much all Clojure web apps are built with Ring, which is a nice abstraction over HTTP requests and responses. Ring -- and other similar libraries -- have the concept of both synchronous and asynchronous requests -- and the latter is what most folks will think of when you talk about "async" in the context of web servers. With a synchronous request, the request comes in, is processed, and a response is sent back to the client -- and the handler functions for such requests take just one argument: the Ring request hash map. With an asynchronous request, the handler functions have three arguments: the Ring request hash map, a response function to be called with a successful result and a raise function to be called with a failure (as in "raising an exception"). /cc @azzurite

stardiviner04:09:17

Library pandoc has some namespaces like pandoc.core, pandoc.pre pandoc.post.compress pandoc.post.env pandoc.post.json pandoc.render etc. I want to apropos search all pandoc related namespaces. like (apropos "pandoc.*"). How to do this?

alexmiller14:09:53

Not supported...

vincent.cantin06:09:35

What is the meaning of the convention of ending function’s names with a *?

henrik06:09:47

@vincent.cantin Usually they pop up when you need a wrapper around the actual main function. For example, you have a function that does something, call it something*. Then you want to memoize it, so you (def something (memoize something*)).

henrik06:09:47

@vincent.cantin Usually they pop up when you need a wrapper around the actual main function. For example, you have a function that does something, call it something*. Then you want to memoize it, so you (def something (memoize something*)).

vincent.cantin06:09:37

I see, thank you.

stardiviner07:09:13

@vincent.cantin No, the * is not literal, the meaning is like in regexp or wildchar etc.

vincent.cantin18:09:37

yeah, that was not related, sorry.

vale08:09:54

i don't think he was reacting to your question

stardiviner08:09:50

Aha, misunderstand. 😂

borblytams14:09:01

what are your opinions what are the easyiest fastest and most fun ways to learn the language, to have a solid and gounded knowledge?

coinedtalk16:09:30

<Http://codingame.com> and the book "Clojure for the Brave and True", or "programming clojure" if you already know enough about programming in general

rmprescott12:09:06

1. How do you learn best? 2. What is your current programming background? 3. what is your end-game goal?

rmprescott12:09:36

There are many alternatives

mfikes14:09:18

@borblytams Doing the problems at http://www.4clojure.com meets a lot of those criteria

borblytams14:09:37

actually i tried, but not really understood, and i can just solve some problems

mfikes14:09:12

You probably also want to pick up a book on the language

orestis16:09:24

I’ve used advent of code (see resulting blog post here: https://orestis.gr/25-days-of-clojure/ ) to get some fun problems.

dpsutton17:09:49

using depstar, i can create a jar file easily. But I'm not sure I understand how to set the main entry point? I'm very new to the java side of clojure. Does anyone know offhand how to do this? I used clj -A:new app test/newapp to use sean's extremely nice template system. Then clj -A:depstar -m hf.depstar.uberjar test.jar. The only ns in this project has (:gen-class) on it so it should have a java class there I'm just not sure of that final part of how to mark this as the entry point

dpsutton17:09:10

java -jar test.jar yields "Error: Invalid or corrupt jarfile test.jar"

alexmiller17:09:00

The default main is defined by the manifest, which is just a file at META-INF/MANIFEST.MF

seancorfield19:09:30

It looks like depstar excludes any local META-INF folder from the JAR. I created src/META-INF/MANIFEST.MF containing Main-Class: clojure.main and the uberjar that depstar built didn't contain it. Is that right @ghadi? Depstar excludes any META-INF it finds on the classpath? /cc @dpsutton

seancorfield20:09:24

OK, you can add one manually:

jar ufm myuber.jar mymanifest
where mymanifest contains just
Main-Class: clojure.main
or whatever main namespace you'd prefer. I'll add that to issue #5 (and suggest the README be updated to include that information!).

alexmiller17:09:07

perhaps you could just build and include it manually?

alexmiller17:09:57

I think you just need a Main-Class: path.to.class

dpsutton17:09:59

Thanks Alex.

lilactown18:09:27

kind of a weird problem: I’m trying to get the line number and position of a key and value in a data structure when it’s pretty printed

lilactown18:09:57

is there a clever way to do this?

alexmiller18:09:11

I think there are only clever ways to do this :)

lilactown18:09:44

I’m just afraid I’m going to have to parse the string myself

lilactown18:09:02

I started off with a naive approach to get the line number by replacing the value at the path with a special keyword, but that can affect the line width which in turn can cause the line to break/not break when pprinting

alexmiller18:09:02

it seems like the best time to discover this is when you’re printing. I can’t think of any kind of printer that currently tracks that though

lilactown18:09:39

🤔 good point. maybe I can copy + extend pprint’s code to track it

lilactown18:09:23

oof, the source for pprint is very complex

alexmiller19:09:33

a lot of that stuff was ported from common lisp and is hard to track

alexmiller19:09:42

there are other printers like fipp and zprint

lilactown20:09:03

thanks, I’ll take a look at those!

seancorfield18:09:41

@dpsutton I thought with Depstar you could just specify the main namespace at runtime but I also get that "Error: Invalid or corrupt jarfile test.jar" -- just following the README doesn't seem to work. @ghadi What are we both missing here?

seancorfield18:09:45

@dpsutton Looks like we're not the only ones to run into this https://github.com/healthfinch/depstar/issues/5

dpsutton18:09:18

yeah i saw that but unfortunately there was no action and no even explanation of circumstances of how they ran into the issue 😞

seancorfield18:09:40

I just added a full repro example.

ghadi19:09:53

@seancorfield depstar doesn't do any AOT, nor let you specify a main class

ghadi19:09:17

java -jar only works if you've specified a main class

seancorfield19:09:19

@ghadi so how do you use the uberjar? When you say "uberjar" people have expectations 😄

seancorfield19:09:46

I don't want or need AOT by the way. The clojure.main class is in there and that's what I'd use.

juanmp19:09:00

What is the best method to stylise websites made with re-frame? is it with css or how does it work?

juanmp19:09:01

Or any other advice to make websites more beautiful with re-frame/clojurescript for a beginner like me is highly appreciated

dpsutton19:09:52

jmp it's very easy to toss bootstrap and font awesome to get a structure going. these have some reusable components that can help you quickly create a styled webapp. if you're going to do webapps for a while and design is a focus it would be worth your time to pursue css and design more deeply but these are great starting points

juanmp20:09:09

Awesome @dpsutton! thanks! Is CSS needed for deeper control over the visual design?

dpsutton20:09:34

It's the language of design on the front end

juanmp20:09:51

But does it make sense to do it within clojure using something like the one you linked or is it most common to keep the css part and the cljs part separate as much as possible? I’m just wondering how to structure my project when it comes to visuals/logic

lilactown20:09:41

it really depends on how complex your app is and what you (or your team) is comfortable with

lilactown20:09:05

IMO I think CSS-in-JS is really excellent, but I also work on a huuuuge application with lots of devs. so being able to easily isolate and import/export styles is a big deal for my project

lilactown20:09:48

for general web dev, plain CSS is just fine and garden can help write that without having to context switch from Clojure

dpsutton20:09:32

And while you're learning css it may be better to stay vanilla without garden

seancorfield20:09:12

FWIW, at work we use plain CSS in separate files, and HTML templates with Selmer rather than Hiccup, so that our front end folks and, in particular, our UI/UX designer, can work with our web app's visuals.

seancorfield20:09:53

We used Hiccup for a couple of things and we couldn't get any support from the front end folks since they work with CSS, JS, and HTML.

seancorfield20:09:28

So, yes, I'd agree with @dpsutton here and recommend keeping your CSS external and learning it standalone rather than trying to learn CSS via something like Garden.

juanmp20:09:50

Right. That makes total sense to me then 🙂

juanmp20:09:42

Thank you so much guys! I’ll make sure to come back with more question ;D

azzurite21:09:25

lein does some release stuff, but you can't increment version in dev-> merge into master -> tag master -> go back and increment version on dev branch, right?

veix.q523:09:44

rich hickey opposes pattern matching, what is the alternative? how does one parse input and capture it in a parameter? what am i missing?

noisesmith23:09:43

what is that snippet supposed to do?

veix.q523:09:39

it is supposed to be the specification for the kind of messages a custom repl understands