Fork me on GitHub
#off-topic
<
2019-11-19
>
jaihindhreddy07:11:21

Protocols and multimethods do have "global" semantics, making them appropriate only when creating abstractions IMHO. You can make the namespace(s) with said abstractions private limiting the scope to "an organization" or a subsystem but in their essential nature, they are global. Passing fns in for local stuff is better.

jaihindhreddy08:11:36

Did anyone build an generative testing system, that tests fns only if the code changed (via the form itself, or via deps)? If I were to store a value which indicates the exact version of the function that has been tested, what would that include. I'm thinking a hash of the form itself, and a map of the deps.edn coords of the libraries the function depends on. Am I right here? Or is this totally wrong because I'm using the artifacts (deps.edn coords) and not talking about the code itself?

Alex Miller (Clojure team)13:11:15

I have and maybe some day I’ll finish and actually release it. It’s based on stripping white space and hashing. There are some interesting choices when dealing with macro expansion (whether to expand, and what to do about gensyms, which are not repeatable)

💯 8
dominicm22:11:29

I'd read a half baked poc

4
jaihindhreddy11:11:24

100% me too. But Alex Miller might not want to release unbaked stuff, so to speak.

jaihindhreddy11:11:25

Eventually, I'm hoping something like this (the sha calc. part) ends up in a blessed lib like tools.deps, and that combined with something like sgepigon/piggy enhanced with requirement/provision checking as well, backed by codeq will just put the Clojure ecosystem light years ahead of pretty much everyone else in dep. management (barring experimental stuff like Unison ofc.)

jaihindhreddy08:11:05

Perhaps a better thing would be, assuming (in a recursive sense), I have a hash for each of the dependencies my fn uses (maybe other fns, values or macros), I can just take all those hashes, assoc-in the form of my fn/macro in that map, and hash that. I can't really think of where that would bottom out though considering Java Interop. Because if there was no Java Interop. It could eventually bottom out to the Clojure version (which could be treated specially) Considering Java(script) Interop makes it extremely hard for my brain 🤯 If anyone has done something like this (in other language ecosystems, even), would love pointers to explore that...

sb13:11:48

Did you see that? https://plasma-umass.org/doppio-demo/ .. Clojure in browser. JVM written in JS, is that possible with CLJS too? What do you think? (not so new project)

sb13:11:39

sorry for this need an installed openjdk8

borkdude13:11:35

Wow. clj-kondo uberjar seems to work with java -jar

👍 4
borkdude13:11:49

> sorry for this need an installed openjdk8 why

borkdude13:11:15

This also worked:

/home $ clojure                                                                 
Please be patient; this command may need to download resources from the network.
Clojure 1.7.0                                                                   
user=> (+ 1 2 3)                                                                
6                 

sb13:11:54

They said.. need to install on the server openjdk.. if not .. that is cool (I need to test)

sb13:11:20

@U04V15CAJ what do you think, we can create similar solution with clojurescript (Im not advanced CLJS developer) or what is the limitation?

borkdude13:11:59

I'm not entirely sure what you want to create. Something like: https://clojurescript.io/ or http://app.klipse.tech/

sb13:11:45

Yes, I know. Just run Clojure.. without openjdk dependency, eg http://ish.app.

borkdude13:11:56

You can already use self-hosted CLJS for this. E.g. https://apps.apple.com/us/app/replete/id1013465639?ls=1 is doing this.

sb13:11:04

Yes, I installed. Just Im thinking about run from CLJS part the CLJ part too and connect. Maybe that is a strange idea.. so not just macros

sb13:11:20

Like graalvm images

❤️ 4
sb13:11:35

Maybe that is impossible, and the best is the graalvm. Just Im thinking about..

borkdude13:11:49

ah right. I'm not sure if doppio is fast enough for that, it seems more like an educational project? GraalVM polyglot might give you that ability: https://nextjournal.com/kommen/clojure-berlin-prosemirror-transforms-with-graalvm-and-clojure

sb14:11:10

I check it. Thanks!

sb14:11:16

Yes, Doppio very slow.

sb14:11:20

I would like to test later .. create a fake layerFS (Alpine image) with openjdk and that compile into binary.. to any kind of architecture, like recovery shell programs. In this case without Java you can run clojure on any kind of architecture. (I work on IoT things)

sb14:11:58

I use now graalvm images as possible.

borkdude14:11:06

If you want some kind of evaluation of Clojure expressions in GraalVM native there is also https://github.com/borkdude/sci/ For example this project is created with it: https://github.com/borkdude/babashka

👍 4
sb16:11:54

Yes, I totally forget you solved at sci that kind of problem

lilactown18:11:46

does anyone know of good resources for building an app that works over a mesh network?

lilactown18:11:56

all of my googling is trying to sell me crap so far

lilactown18:11:43

I basically am interested in exploring an app that communicates device->device via bluetooth or other ad-hoc methods

hiredman18:11:01

you could start by playing with local ip multicast communication, no hardware or drivers are needed and you'll be able to broadcast data to others on the same local network

hiredman18:11:36

which is what a lot of local network service discovery things are built on

lilactown18:11:24

I am interested in communication between devices that aren’t necessarily connected to the same LAN

lilactown18:11:39

true device to device communication

hiredman18:11:17

the annoying thing with that is an ip stack is seen as a standard thing exposed in a standard way pretty much everywhere, the same is not true of bluetooth and access to bt radios

hiredman18:11:49

so you will need to start by figuring out the bluetooth stack for your given environment / device

lilactown18:11:56

I have two use cases I’m interested in right now: 1. where a network needs to be established between devices that is in a degraded connectivity area. think: a large gymnasium where the wi-fi is super spotty 2. an app that works based on proximity of it’s users, without needing to share information with a master server

robertfw19:11:55

Gotenna is something I've been looking at, it's an encrypted mesh network over radio. They provide a radio device that connects to your own device over bluetooth. They have an SDK for developing your own apps. I was going to get a set for music festivals, and had poked around the SDK stuff as a curiousity. https://gotenna.com/pages/sdk

lilactown19:11:40

this looks cool! thanks!

hiredman18:11:45

and I am not sure if bluetooth has a true peer to peer mode, I vaguely recall maybe a new standard for it in the last few years that lots of low power devices use

lilactown18:11:27

I know that there are apps that have solved this problem multiple times. I wonder what they had to build to enable this kind of ad-hoc message passing

lilactown18:11:18

the thing that immediately come to mind is this app: https://scuttlebutt.nz/

hiredman18:11:27

most apps build their mesh as an overlay over the existing ip network

hiredman18:11:49

the same stuff that runs filesharing networks

hiredman18:11:03

scuttlebutt uses udp broadcasts on the local network

lilactown18:11:50

hmm interesting. I thought it was truly device to device. disappointing

hiredman18:11:51

incidentally watching all the udp broadcasts on your home network can be really interesting. most set top boxes broadcast stuff, lots of home automation stuff does

hiredman18:11:45

there are adhoc wifi modes, so in theory if you work over udp broadcast, you work over that

hiredman18:11:01

although udp broadcast over wifi is kind of a bummer

hiredman18:11:40

there is an entire http like thing for doing device discovery over udp

hiredman18:11:59

which competes to some degree with mdns

yiorgos18:11:33

Is this real? In the german Amazon, Programming Clojure paperback is cheaper to buy it new than used, also is cheaper than the kindle edition.

rakyi21:11:10

@lilactown we used this simulator at the university https://www.nsnam.org/docs/manual/html/python.html There’s some academic resaerch on mesh networks, competing protocols, etc. And a few successful apps, their names escaping me now. But I think they use them in the HK protests, for example.

rakyi21:11:02

Probably not very helpful, if your are looking for something more akin to a readymade SDK.

lilactown21:11:20

I hadn’t seen the bluetooth one. thanks!

lilactown21:11:50

the HK protests were what originally brought it to mind

Leandro71321:11:45

on daily programming, which is preferable? λx.z + λy.z or λxy.z keeping in mind the latter is more complex to implement ....

andy.fingerhut22:11:59

I am not sure I understand the question. Is the first thing intended to mean "write two functions, each taking one input value, each returning a value, and then add their results together after both of them return", and the second is intended to mean "write a function with two parameters, which internally does the same work as the two independent functions of the first approach, then add their results and return that"? If so, I don't understand why the second would be more complex to implement.

andy.fingerhut22:11:16

And if I have misinterpreted your question, then I don't know what is intended.

Leandro71308:11:36

yes, you understand well, that's exactly what i mean

Leandro71308:11:12

i say the 2nd is more complex because the 1st option simply takes as input an item (number, string, whatever) and the 2nd option takes as input a group of items. and that in practice (input as group) is a bit more difficult to implement

andy.fingerhut12:11:13

You could write a function that takes a single input and returns the desired value, call it f-on-one, then write (defn f-on-many [coll] (reduce + (map f-on-one coll))), couldn't you? I don't see f-on-many as complex at all, if there is no interaction between the calls of f-on-one on each element.

Leandro71312:11:24

agreed, the complexity difference is trivial

Leandro71312:11:33

but which option should be preferred?

Leandro71312:11:22

would do you prefer the 2nd for readability?

andy.fingerhut12:11:53

Why not implement both, and let the caller decide which they want?

andy.fingerhut12:11:36

Or, if you implement only the first, then most Clojure programmers can bang out the second in a minute or so, if they want it.

Leandro71312:11:45

yea, understood

Leandro71312:11:17

my question was more theorical, than a given real problem. i just was wandering about best practices

andy.fingerhut12:11:05

I think it is generally considered a bad idea to make a single function that takes either one element, or a collection, and if given a collection it behaves like f-on-many, but if not given a collection it behaves like f-on-one.

andy.fingerhut12:11:32

Because then you disallow a collection as a single element of another collection.

andy.fingerhut12:11:35

To me, it seems that if f-on-many is really only doing what is shown in the definition above, then I would provide f-on-one, and let the caller write f-on-many if they want.

andy.fingerhut12:11:02

Unless for some reason f-on-one was almost never what the caller wanted, and they really always wanted f-on-many

Leandro71313:11:56

ok. very gentle for your explanation thanks