Fork me on GitHub
#clojure-uk
<
2020-03-09
>
fmjrey07:03:38

Google confirms Microformats are still a recommended metadata format for content https://news.ycombinator.com/item?id=22521666

dharrigan07:03:01

Good Morning!

marcus08:03:30

Moaning! (I hate Mondays šŸ˜)

mattford08:03:33

Spent the weekend in bottomless frustration as my should-be-parallel code (fold) wasn't. Turns out I forgot to cast my sequence to a vector. Are types so bad....

šŸ˜„ 4
mattford08:03:13

And mornin'

Ben Hammond09:03:40

Clojure metadata; the only times I've ever used it, I've gone back later and eliminated it. I haven't working on language tooling; where I appreciate that it is invaluable Has anyone found metadata useful in a non-tooling context

Ben Hammond09:03:57

I guess the clue is in the name 'meta'

mccraigmccraig09:03:58

one place so far @ben.hammond - in a cljs app, to decorate objects received over the wire from a clj backend with caching-related info

Ben Hammond09:03:08

and what the meta nature of the data bring

Ben Hammond09:03:19

rather than just assoc'ing the decorations

mccraigmccraig09:03:42

two things really: [1] schema is shared between front-end and back-end and putting client-only cache-info on lots of schemas seemed weird, and [2 i didn't want the cache-info getting sent to the backend and therefore having to be stripped somewhere before objects get saved to the db. both could be achieved through other means, but metadata was an easy solution

Wes Hall09:03:38

@ben.hammond Iā€™ve used it a few times for very typical ā€œmetadataā€ stuff. Requesting user id, database response time. That kind of thing. Iā€™ve also found myself abusing it one or twice and moved stuff back to regular data as you describe.

guy09:03:50

I think Iā€™ve seen it used for aws meta data stuff

guy09:03:13

More or lesss what Wes said tho

guy09:03:25

Morning all

mccraigmccraig09:03:29

obvs the killer use-case is where you want to preserve equality semantics

šŸ’Æ 4
Ben Hammond09:03:32

yeah I suppose. I'm suspicious that comparator/equality is such an important part that I would usually want to control it explicitly

Ben Hammond09:03:45

rather than side-step with meta

mccraigmccraig10:03:27

it gets painful when you have nested objects with keys which you want to discount from equality, or if you need to use objects with sets or as keys in maps

šŸ‘ 4
Ben Hammond09:03:37

yeah you have to abuse it in order to find outt what its not good for

rickmoynihan10:03:54

I personally think metadata is a great clojure feature; though itā€™s certainly one that needs to be used with care, as by itā€™s very nature itā€™s hidden and somewhat opaque. Main use is definitely tooling; but itā€™s super useful in other contexts too. e.g. Iā€™ve written a few DSLs over the years that would generate functions which would hold metadata on the forms for debugging/error messages etc ā€” i.e. they would capture data at compile time; for runtime. Also integrant makes quite good use of it; for a similar purpose. Capturing and storing the configuration of the configured system; in particular the dependency information, so that it can shutdown the system in the right order. Other use cases are adding metadata to vars etc; for programmatically identifying code blocks etcā€¦ e.g. type hints, unit tests etc. Personally Iā€™ve found those kind of usages, along with the tooling and language level to be the best ones. It makes implementing the sort of things that would be hard or time consuming to do in other languages a breeze.

fmjrey10:03:18

I've used meta for some graph algo, can't remember the details but was super useful for hacking something out

folcon12:03:28

Mornā€™, Iā€™ve used metadata a bit for describing things about data, (which basically sounds like what it says on the tin). Itā€™s been ok, there are some warts about the process I donā€™t like, but in general it seems to work fine for what I want it to do.

rickmoynihan13:03:59

One of the problems using metadata is itā€™s quite easy to blow it away if you canā€™t see it or forget it might be thereā€¦ e.g. if someone wrote code that works like {:new-key (:old-key m)} rather than using clojure.set/rename-keys etc.

folcon13:03:23

Oh yea, that is definitely one of the issues =)ā€¦

folcon13:03:56

That reminds me, have of the people using cryogen for blogging, anyone figured out any nice approaches for managing snippets? Do you create project at the bottom level and kick off a repl there then prototype stuff in? Do it entirely externally and then copy/paste snippets into the md file and tinker with klipse? Something else?

practicalli-johnny14:03:06

Snippets for articles are always taken from exernal projects (working and tested), with the full project code available in a GitHub repository and a link in the blog to that repository. Its ensures that people have all the details. I havent use klipse yet in cryogen.

3Jane11:03:15

you can load gists and libraries in klipse via data-gist-id and data-external-libs and other attributes

3Jane11:03:35

I've always taken code I developed elsewhere first, so I've not had a problem with testing it

3Jane11:03:39

I'd need to look at the code to see if the extra attributes are even supported šŸ™‚

3Jane11:03:01

but yeah, in general I tend to write code or whatever externally, and then paste it into the post

3Jane11:03:40

another thing I've used was http://www.gravizo.com/

3Jane11:03:46

similar problem: have to write code externally, then paste into the article

folcon15:03:55

Thanks =)ā€¦

dominicm14:03:03

With asciidoc you can include segments of another file using tags.

fmjrey17:03:26

fyi looking up asciidoc with clojure landed me there: https://github.com/Olical/blog

dominicm18:03:03

We use is a lot at JUXT

Wes Hall17:03:07

Haha! Just saw somebody on twitter (jokingly) describe a monad as, "the thing languages like Java use the semicolon operator to represent!".... Dear purists, I know, but that's quite funny.

mccraigmccraig19:03:57

is it accurate though - i have sometimes thought of them as generalising the binding-form init-expr relationship in a clojure let, but i don't get how they are equivalent to a java ; ?

Wes Hall19:03:46

@U0524B4UW It's not accurate at all. At the very very loosest level, in the sense of "do this, then do this, then do this", there is the most tenuous of associations, but this, combined with the idea of describing ; as an "operator", made me laugh šŸ™‚

mccraigmccraig19:03:44

ha, i guess in haskell, with it's pervasive laziness, you don't really get any guarantees that anything will happen in any particular order, unless you sequence operations with a monad, so maybe that's what they are trying to get at

rickmoynihan10:03:44

The semi-colon thing is quite a common trope Iā€™ve heard mentioned a few times. Here itā€™s just framed in a humorous antagonistic way but Iā€™ve seen it meant sincerely too. I think it can also be quite an effective lie on the way to understanding monads, in that: 1. It points to the semi-colon as being a bit like an operator; which is a perspective most people wonā€™t have considered. 2. It points to the monad as being like the thing between the steps; the thing that bindā€™s them together. 3. It illustrates that things can be composed/sequenced together. 4. You can then point to other things which can in principle being composed in the same wayā€¦ errorā€™s, state, maybe etc. Obviously itā€™s at best only a half truth; and doesnā€™t point to the laws that govern their use.

rickmoynihan10:03:45

Itā€™s certainly a much better analogy than monads are like šŸŒÆ šŸ˜

mccraigmccraig10:03:20

you take a chicken burrito, you bind the ecosystem, now you have a beef burrito - you are bind, the ecosystem is a monadic function, just another monoid in the category of endofunctors šŸ“šŸŒÆ->:man-facepalming::partly_sunny_rain:šŸšœ->šŸ®šŸŒÆ

3Jane11:03:09

i think this points exactly to what annoys me about monads, thanks for the mental shortcut šŸ˜„

rickmoynihan11:03:46

care to elaborate on what annoys you about them?

3Jane11:03:32

From where I'm sitting, they're an extremely elaborate way to achieve something other languages do out of the box.

3Jane11:03:12

(Possibly the fault of the source I used to learn Haskell; I'm at the stage where I can write something that works, but I don't see the benefits of the components that make the language the way it is)

3Jane11:03:09

Some languages grab you, some don't. The more I write Haskell, the more it feels like sitting on something extremely prickly and itchy: the discomfort is not great, but so annoying you want to run away screaming. The things I do like about it are pattern matching and a more expressive type system. At some point I'm gonna try ocaml, but at the moment I have other things to do.

rickmoynihan11:03:32

@U82DUDVMH To some degree thatā€™s fair ā€” however it also kind of misses point in that: 1. They provide an abstraction across things those other languages treat as different, and kind of unknowingly did. 2. Haskell was designed to be pure wrt side effects; lazily evaluated, and strongly typed. Early versions wouldnā€™t even let you make side effects at all. Given that Haskell was and still is really a CS research project, it was an unsolved problem for a long time on how to ā€œfire the missilesā€ or do anything other than make your cpu hotter. Monads provided a novel solution to the problem of doing useful things when youā€™ve purposefully tied your hands behind your back with the constraints of laziness, strong types, and purity; along with being an elegant abstraction applicable to other things too. Haskellā€™s motto is avoid success at all costsā€¦ I think theyā€™re kind of failing to deliver on that promise; but it perhaps describes why you donā€™t like it šŸ™‚

mccraigmccraig11:03:37

i haven't written any real haskell - but i have found the monad pattern useful for structuring some code in clojure and it keeps popping up as a way of thinking about some problems

rickmoynihan11:03:46

I think Ocaml is a little more pragmatic and are more willing to consider the costs of their principles than in Haskell.

rickmoynihan11:03:35

Yeah monads can definitely be useful outside of haskell

3Jane11:03:54

Personal tastes can't be fair.

3Jane11:03:59

It does not apply as a category.

3Jane11:03:34

I'm not interested in evaluating Haskell as "which language is objectively the best" because I think this kind of categorising tools is stupid

šŸ‘ 4
3Jane11:03:06

I strongly appreciate what monads do for Haskell

rickmoynihan11:03:54

Haskell certainly doesnā€™t consider itself objectively the bestā€¦ Some of their vocal users do; but the designers definitely donā€™t.

3Jane11:03:55

I also appreciate purity as a way of thinking about your functions, helping you split the problem into subproblems, and keeping things easy to mentally digest

rickmoynihan11:03:47

Haskell has been amazing as a language research project

3Jane11:03:52

I also appreciate the problem with concurrency, and having to instruct your program that "this instruction comes after that, but for everything else it's a free-for-all"

3Jane11:03:14

yep šŸ™‚ and monads are great in terms of formally explaining / defining language structure

3Jane11:03:30

rather than defining grammar by fiat

3Jane11:03:26

I found the ; analogy funny and apt, and that's about it šŸ™‚

rickmoynihan11:03:17

> I also appreciate the problem with concurrency I think thatā€™s an area Haskell hoped to make a meaningful improvement on; and has to some degree failed to do so. They hoped that laziness/purity and the rich type information etc would allow smart compilers to parallelise work automatically; but they then found that whilst itā€™s ridiculously easy to apply any evaluation ordering; itā€™s impossibly hard to automate the parallelisation of code and make it faster. Hopefully one day theyā€™ll solve this one; but it seems progress has been a lot slower than expected.

šŸ‘ 4