Fork me on GitHub
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? 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

awesome 8
❤️ 10
👍 9

That looks quite interesting! FYI: I tried launching it using 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/
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
./ 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.


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


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

although for your problem you could use graph algos


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


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


it seems like jepson should have some way to do that


i just see someone else already suggested it


I’m not even sure where to begin looking


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


@him This might just be a topological sort? This library can calculate it for you:


topological sorting is 1. Great 2. Not complicated enough to pull in a library for and both include the same topo function at the top which does the sorting


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


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


> 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.


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


depending on what you are doing or might be of interest

👍 3

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.


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).


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.


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


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.


oh that’s clever!


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]
   [(== 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))


whooaaaa! nice!