Fork me on GitHub
#off-topic
<
2020-06-19
>
sb07:06:47

Hi, maybe somebody know that: how store data/process like smalltalk, like “os” image, .. so you can stop the process and restart, or pause.. I read about and very interesting (“Smalltalk’s principal claim to fame is its image-based approach to software creation. An image is a snapshot of memory that contains all the objects in your running application or system. It encapsulates the entire execution state of your program. An image can be saved to disk, and execution can later be resumed exactly from where you left off!“) . what is the main solution behind this? save the process data dynamically to bytecode? how to encapsulate the state?

☝️ 1
jsn12:06:15

@sb Well, a running process can be largely described by 1) a set of memory address ranges visible to it + their content, 2) the state of CPUs (~ content of their registers), and 3) a set of external OS resources (files, sockets, etc) in use by it. (1) and (2) can be relatively trivially dumped to disk, and, with some OS support, restored from that dump. (3) can be less simple, but there are some tricks that can sometimes help. Some variants of this approach use virtual machine memory / state instead of CPU memory / state.

sb12:06:06

@jason358 thanks, the answer.. yes, totally new for me.. store state of a running process. really interesting! I think, I try out the easier way 1+2..

jsn12:06:49

There are some libraries / utilities for linux that can handle freezing/unfreezing a process, to some extent, I think

jsn12:06:39

Doing it by hand is a lot of low-level work, can be tricky

sb12:06:46

I would like to try out on microcontrollers, totally create via C/C++.

sb12:06:31

Yes, I see. But sounds interesting.. store a state, maybe transfer, simulate etc..

p-himik12:06:40

Before I saw you mention microcontrollers, I wanted to suggest lxc snapshot.

👍 2
jsn12:06:43

Yes, perhaps the state is much simpler on microcontrollers

sb12:06:26

Yes, much much easier, if you create eg. a simple stack based virtual machine...

souenzzo12:06:36

IDEA: A https://ipfs.io / libp2p lib to clojure that (ipfs/ref {:some "value"}) ;; => #ipfs"<CID block ID>" (ipfs/deref #ipfs"<CID block ID>") ;;=> {:some "value"}

👍 1
borkdude12:06:02

@jjttjj I notice that clojars displays the coordinates they way you suggested: https://clojars.org/com.clojure-goes-fast/clj-java-decompiler

jjttjj13:06:38

Yeah, I think I noticed I subconsciously started to look for the clojars link on a readme more often since I started using tools deps due to this

adam15:06:53

I feel so clean after fixing +60 issues reported by clj-kondo in my small codebase 😎

clj-kondo 5
p-himik15:06:23

Just don't run it on the code of the libraries that you use. :)

adam15:06:35

I invoke it from these:

alias t="cd $PROJECT_HOME"
alias tls="clear && t && clj-kondo --lint src"
alias tlt="clear && t && clj-kondo --lint test"

naomarik15:06:57

And I feel so good removing my old cobbled dev and build config consisting of a frankenstein combo of lein/boot from the days of yore to deps.edn. Shrunk my compiled JS file by 30kb due to shadow-cljs build report and uberjar from 120M to 76M. Full compilation in 50 secs down from 3 mins.

adam15:06:46

Nice. I am not there yet. I still depend on quite a few lein plugins.

borkdude15:06:24

I actually want to do the same.

naomarik15:06:28

I'd highly recommend depstar for uberjar, nothing else completely worked for me.

👍 2
naomarik15:06:04

seancorfield's fork

seancorfield16:06:11

@naomarik Thanks for the kind words! 🙂

Renato Alencar16:06:56

Hi everyone, as Clojure is described as tool for professionals, I would like to hear from you, who work no software companies, consulting, etc. About software engineering practices, do you gather requirements? Design docs? And things like this.

sveri17:06:17

Hi, I have some code that converts yaml to edn. Now, there are several libraries for clj and cljs, but I have not found one for both. As I convert yaml to edn in clj and cljs I would like to use the same code to make sure it returns the same edn on front and backend. 1. Does someone know a library for both clj and cljs that I have just not found? 2. If not, is there a way to run cljs/javascript in the jvm (like nashorn did) or 3. run clj code in the frontend?

borkdude17:06:46

@sveri why use JS on the backend if you can run your clj yaml lib there?

sveri17:06:56

@borkdude Because I want to make sure it generates the same output as the javascript one. The only way to be sure, is to use the same code for the conversion, everything else leaves the possibility for differences.

borkdude17:06:34

@sveri why must it be identical? for comparison? or other?

hiredman17:06:42

(because yaml is a nightmare)

👆 1
sveri17:06:22

I agree, but it's what a lot of people use for swagger / openapi.

sveri17:06:45

I derive business logic from that, validation for instance, and that should be the same. To be more specific, I have an openapi specification that I can "test" on frontend side and which is then later used to generate backend code.

phronmophobic17:06:02

it’s much easier to run js on the backend than to run a clj library wrapping a java library on the frontend

borkdude17:06:03

well, all clj yaml libs I know are based on SnakeYML. Good luck finding a JS lib that does exactly the same

sveri17:06:45

@smith.adriane I am fine with that, but I only know about Nashorn, which is deprecated IIRC.

sveri17:06:59

Hm, I could execute shell code.

borkdude17:06:01

@sveri the successor to nashorn is GraalJS I think

phronmophobic17:06:17

I’ve used https://github.com/marianoguerra/clj-rhino before, but it’s been a while

sveri17:06:16

@borkdude Thanks, I have a look at it.

sveri18:06:05

Thats exactly what I have been looking for 🙂

lilactown20:06:13

I have a scheduling problem. I have a floor layout of rooms that need to be scheduled to optimize social distancing. Constraints are things like, "I don't want to schedule a room for this hour that was scheduled for the previous hour," "never schedule two rooms next to each other." Ideally, I could also maximize distance between rooms and optimize for ease of exit/entry.

porkostomus23:06:57

I remember a talk where Mark and Alex Engelberg discussed the 12 nurses problem (maybe it was "Solving problems declaratively"?) where he wrapped a Java constraint library, maybe it could give some inspiration?

lilactown20:06:34

where would I start researching for solving this type of problem? any good resources on it?

borkdude20:06:28

it sounds a lot like Rich Hickey's twofer Tuesday problem 🙂

lilactown20:06:04

lol I had the same thought

alexmiller20:06:07

sounds like a logic constraint problem

hiredman20:06:14

rules engines get used for that sort of thing, so you might ask in #clara

lilactown21:06:35

clara and something like core.logic feel very low level. I can't think of an efficient way to apply them yet

lilactown21:06:58

the output I need is a schedule that I can use to allow people to sign up for rooms at various times of day

phronmophobic21:06:53

you can probably use the interval scheduling algorithm from wikipedia to find schedules that satisfy your constraints and then assign weights to other attributes (eg. penalizing scheduling rooms next to each other) to sort results by desirability (eg. desirability= kDistanceWeight*distance_between_rooms_sum - kCooldownWeight*time_since_last_meeting_sum)

borkdude21:06:10

it also reminds me of this d3 animation where each dot has a certain force field to it, pushing away other dots.

hiredman21:06:35

given a set of rooms and a set of meetings, find schedules that satisfy some set of rules is also a different problem from having a list of potential meeting slots and filtering out the ones that fail some rules.

hiredman21:06:33

the first problem is a super set of the second, so if your problem is actually the second then you are a good way there because you have the easier problem to solve

sveri22:06:15

While rules could be used to solve the problem, resolving these will not lead by definition to the optimal solution. It's more like a, these are the rules, this is the input, so this is the outcome.