News for hackers. Stuff that matters.
Re:Snek: An experimental system for writing generative art s... by MooMooMilkParty on Sunday June 11, 2017 @01:51PM (#14532924)
I've used his differential-line repo to make some wall art for my apartment, it's some beautiful stuff:

http://imgur.com/a/BoKdy

Repo at: https://github.com/inconvergent/differential-line

Re:Snek: An experimental system for writing generative art s... by inconvergent on Sunday June 11, 2017 @01:17PM (#14532772)
Hi, I'm the author of the repo.

If you want to read about the "framework", rather than look at the code: http://inconvergent.net/snek-is-not-an-acronym/ .

Re:Snek: An experimental system for writing generative art s... by dang on Sunday June 11, 2017 @02:35PM (#14533107)
Since that link gives more background, we've changed to it from https://github.com/inconvergent/snek. Thanks!
Re:Snek: An experimental system for writing generative art s... by dri_ft on Sunday June 11, 2017 @01:50PM (#14532921)
Great! I like the other stuff on your website too.
Re:Snek: An experimental system for writing generative art s... by inconvergent on Sunday June 11, 2017 @01:59PM (#14532966)
i'm glad to hear it!
Re:Snek: An experimental system for writing generative art s... by octref on Sunday June 11, 2017 @12:33PM (#14532588)
The author also wrote On Generative Algorithms[0] which is a very inspiring overview for many types of generative art.

[0]: http://inconvergent.net/generative/

Re:Snek: An experimental system for writing generative art s... by qubex on Sunday June 11, 2017 @10:50AM (#14532132)
I follow this guy's (@inconvergent) generative art on twitter and I highly recommend it as it is awesome: organic and yet clearly procedural.
Re:Snek: An experimental system for writing generative art s... by pka on Sunday June 11, 2017 @04:20PM (#14533576)
So if I'm understanding this correctly, you are generating a data structure describing geometry manipulations which can then be applied to a distinct geometry "instance?" If so, isn't this just a free monad?

Also, what are the advantages of this approach over simple function composition operating on immutable data structures/geometries?

Re:Snek: An experimental system for writing generative art s... by inconvergent on Sunday June 11, 2017 @04:45PM (#14533703)
i don't know what a free monad is.

not sure if there are any advantages. this is an experiment i'm working on because i find it interesting. separating the data structure from the instructions that attempt to manipulate it has the advantage of making it easier to deal with the state [the state is not changed inside (with-snek ...)]. basically it's a kind of map-reduce. i'm sure you can achieve this in multiple other ways as well.

one of the reasons i'm interested in this particular pattern is described further here: http://inconvergent.net/a-method-for-mistakes/.

Re:Snek: An experimental system for writing generative art s... by pka on Sunday June 11, 2017 @07:30PM (#14534383)
It's indeed very interesting!

What I meant is that it might be simpler to just have pure functions operating on immutable data structures, which you could then compose in whichever you want. I.e. you could have a function collapse-vertices that takes some geometry and produces some new geometry (without altering the initial one!), which you could then compose with some other pure function, like produce-random-vertices, and so on, much like a Unix pipe.

A free monad is just a formalization of the command/interpreter pattern in a purely functional context (i.e. most useful in languages like Haskell or Clojure).

Re:Snek: An experimental system for writing generative art s... by inconvergent on Sunday June 11, 2017 @11:05PM (#14535002)
I'm not sure about how you would efficiently do this. (I'm not experienced with pure functional programming.) cloning the entire structure for every applied function sounds like it will be slow? is that not what you will have to do in practice?

i basically want the alterations to change the data structure, and i want them to do it according to a particular priority eventually. atm there is no priority ordering.

i can already make (almost) arbitrary functions, but you have to register them ahead of time, and they have to follow a particular pattern: http://inconvergent.net/arbitrary-alterations/. this is so that i can control the order in which they are applied, eventually.

Re:Snek: An experimental system for writing generative art s... by pka on Monday June 12, 2017 @07:55AM (#14536515)
> cloning the entire structure for every applied function sounds like it will be slow? is that not what you will have to do in practice?

In short, no - as an example, when an element is added to an immutable map, a big part of the newly produced map is structurally shared with the old one (check out [0].)

As for the ordering, you could have a list of geometry -> geometry functions. You could then take the initial geometry and apply the list of functions in order, or a permutation of it, or drop some functions, or apply some others multiple times, and so on.

But anyway, it's just an idea - thinking in terms of atomic geometry transformations instead of alternations may or may not be easier in more complex scenarios, I don't know :)

[0] http://hypirion.com/musings/understanding-persistent-vector-...

Re:Snek: An experimental system for writing generative art s... by inconvergent on Monday June 12, 2017 @08:23AM (#14536686)
this link looks interesting, thanks.
Re:Snek: An experimental system for writing generative art s... by platz on Sunday June 11, 2017 @11:52PM (#14535132)
Something doesnt necessarily have to be a free monad to be an internal dsl / interpreter. especially if you arent being strict about adhering to monadic rewrite laws.
Re:Snek: An experimental system for writing generative art s... by kowdermeister on Sunday June 11, 2017 @01:28PM (#14532809)
I find the description confusing: "snek is a simple data structure for working with vertices and edges"

If I hear data structure lisp code is not on my mind, so it's rather an API or a drawing library?

What am I manipulating exactly?

    ; context start
   (with-snek (snk)
What's in `snk`? Sorry, I never used lisp before

Do you plan to write an API documentation?

Re:Snek: An experimental system for writing generative art s... by aerique on Sunday June 11, 2017 @03:12PM (#14533270)
If I hear data structure lisp code is not on my mind, so it's rather an API or a drawing library?

Most Lisps, especially Common Lisp which inconvergent is using, have plenty of data structures: http://www.lispworks.com/documentation/lw70/CLHS/Front/Conte...

Common Lisp doesn't have a nice literal structure for hash tables/maps/dicts but that is easily mended with a macro.

"(with-snek (snk) ..." is a macro which abstracts away lower level tedious boilerplate. It hands you "snk" on a platter so you can manipulate it.

Common Lisp itself also comes with some of these macros: http://www.lispworks.com/documentation/lw70/CLHS/Front/X_Alp...

"with-open-file" (skip to the examples) is a nice one since it takes care of opening and closing the file for you so you can write your block of code inside of it and be sure the file gets opened and closed properly:

    (with-open-file (f "/path/to/file" :direction :output :if-exists :supersede)
      ... your code writing to "f" comes here ...
      )
Re:Snek: An experimental system for writing generative art s... by inconvergent on Sunday June 11, 2017 @01:41PM (#14532875)
you manipulate a data structure that contains vertices and edges. there is more about it here http://inconvergent.net/snek-is-not-an-acronym/.

snk is an instance of snek, so it contains a realisation of the structure and its current state.

Re:Snek: An experimental system for writing generative art s... by pje on Sunday June 11, 2017 @03:06PM (#14533243)
so...snk is a graph?
Re:Snek: An experimental system for writing generative art s... by Retra on Sunday June 11, 2017 @10:16PM (#14534873)
Most data structures are graphs. This one just happens to be "self-aware" enough to use graph terminology.
Re:Snek: An experimental system for writing generative art s... by inconvergent on Sunday June 11, 2017 @03:10PM (#14533265)
yes, it is.