Fork me on GitHub
#off-topic
<
2021-01-11
>
Felipe Reigosa12:01:19

Hey guys, I should have shared this here a long time ago. I'm building a visual programming language/game entirely in clojure, what do you think? https://mockmechanics.com/ Using it I built a working piano, a combination lock, a bubble sort machine, even tetris, all without any code, you can see these machines and more on my YouTube channel. Here's the latest thing I was able to build inside it without using any code, a punched cards programmable 3d printer. Follow me on twitter if you want to keep up with what I'm doing next https://twitter.com/MockMechanics

awesome 8
❤️ 10
👍 9
Stefan13:01:48

That looks quite interesting! FYI: I tried launching it using run.sh and both java11 and java14 and I immediately got:

2021-01-11 14:05:48.884 java[20675:254676] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/Foundation/Foundation-1677.201/Foundation/Misc.subproj/NSUndoManager.m:363
2021-01-11 14:05:48.886 java[20675:254676] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff2fe1db57 __exceptionPreprocess + 250
	1   libobjc.A.dylib                     0x00007fff68ca95bf objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff2fe46d08 +[NSException raise:format:arguments:] + 88
	3   Foundation                          0x00007fff32538ead -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
	4   Foundation                          0x00007fff324755fe +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 440
	5   AppKit                              0x00007fff2d00265c -[NSApplication run] + 864
	6   libglfw.dylib                       0x000000010b6f2a85 libglfw.dylib + 68229
	7   libglfw.dylib                       0x000000010b6ec416 libglfw.dylib + 42006
	8   ???                                 0x0000000114071330 0x0 + 4630975280
	9   ???                                 0x000000011406b6d0 0x0 + 4630951632
)
libc++abi.dylib: terminating with uncaught exception of type NSException
./run.sh: line 3: 20675 Abort trap: 6           java -jar --illegal-access=deny program.jar

Felipe Reigosa13:01:45

Thanks! Yeah, I know about that, macOs doesn't like me calling opengl stuff outside the main thread, I'll fix it soon, just didn't have the time yet.

👍 4
Idan Melamed13:01:34

Looks amazing!

Felipe Reigosa13:01:28

Thanks Idan, it's still early days, not sure where I'm going with this, maybe a minecraft like game, we'll see.

telekid19:01:37

Does anyone know of any tools that allow you to enumerate the ordering states created by a set of asynchronous processes and some causality statements? e.g.

a causes b
a causes c
b causes d
c caused d

results in

a -> b -> c -> d -> d
a -> c -> b -> d -> d
...

clyfe19:01:09

end state, start state, state transitions sounds like a finite state machine (FSM) to me there are a number of FSM tools in clj that do various things; google "clojure fsm"

👍 3
clyfe19:01:02

although for your problem you could use graph algos

clyfe19:01:58

weary of state explosion, with nodes greater than 5 .. depending on edges

telekid19:01:29

totally – I’m actually translating a sequence diagram into an FSM and want to make sure that the FSM correctly accounts for all possible event orderings implied by the diagram

phronmophobic20:01:57

it seems like jepson should have some way to do that https://github.com/jepsen-io/jepsen

phronmophobic20:01:34

i just see someone else already suggested it

telekid19:01:51

I’m not even sure where to begin looking

telekid19:01:11

my goal is to help me ensure I’m accounting for all ordering possibilities when thinking through changes to a distributed system

borkdude19:01:00

@him This might just be a topological sort? This library can calculate it for you: https://github.com/stuartsierra/dependency

hiredman19:01:57

topological sorting is 1. Great 2. Not complicated enough to pull in a library for https://gist.github.com/hiredman/71b71e4e07e7666fe1b9def9a476c765#file-lrun-clj-L1-L10 and https://gist.github.com/hiredman/075b45eaeb01e4b526ce6f8854685487#file-ur-component-clj-L1-L10 both include the same topo function at the top which does the sorting

hiredman19:01:19

I guess "requires a DAG" should go on the list somewhere

hiredman19:01:23

I bet with some tinkering you could tweak that function to instead of returning a single ordering, return a set of all the possible orderings

telekid19:01:57

> I bet with some tinkering you could tweak that function to instead of returning a single ordering, return a set of all the possible orderings Yeah was just gonna say, toposort misses on that requirement. But good idea, I’ll run with that.

telekid19:01:42

I feel like I want 1% of the Bloom programming language 🙃

hiredman19:01:51

depending on what you are doing https://github.com/jepsen-io/elle or https://github.com/jepsen-io/knossos might be of interest

👍 3
andy.fingerhut20:01:12

I don't know a library that already does this (maybe one of the ones suggested already does), but in terms of graph theory terminology you are asking to enumerate all possible topological sorted orders of an input graph.

andy.fingerhut20:01:08

Finding one such topological sorted order is easy to do in linear time. Enumerating all possible ones can probably be done in linear time in the length of the output, but for N nodes the number of such topological orders can be as large as N! (for 0 edges/constraints).

telekid21:01:44

Thanks @andy.fingerhut, I hadn’t considered that. Fortunately for me, N is small (~5), but still big enough (given N!) that mentally tracking possibilities is impossible.

telekid21:01:18

I guess this is one reason why designing correct distributed systems is hard…

andy.fingerhut21:01:31

For N small enough, a perfectly quick hack approach is to generate all N! permutations, and remove any that violate one of the causality constraints.

telekid21:01:53

oh that’s clever!

clyfe22:01:27

My fist core logic program cc @him

(use 'clojure.core.logic)

(defne arco [x y]
  ([:a :b])
  ([:a :c])
  ([:c :d])
  ([:b :e])
  ([:c :e])
  ([:d :e]))

(defn patho [l]
  (conde
   [(== l [:e])]
   [(fresh [d x y]
      (firsto l x)
      (resto l d)
      (firsto d y)
      (arco x y)
      (patho d))]))

(run* [q]
  (firsto q :a)
  (patho q))
;; => ((:a :b :e) (:a :c :e) (:a :c :d :e))

telekid22:01:14

whooaaaa! nice!