Threads for fogleman

  1. 1

    Very cool! How many SDF evaluations per second are you achieving? In my own SDF/CSG experiments, I’m finding it hard to get more than a few hundred pixels per second in most scenes, and part of that is needing many extra SDF evaluations for shadows.

    1. 1

      Greatly depends on the SDF, of course.

      For the CSG example, looks like I’m getting 13.7M per second (with 16 worker threads).

      1. 1

        If you compute on the GPU you’ll get millions/s. I tried to do a simple pure Python SDF evalutator with autodiff but gave up after seeing the performance at first run. There is hope with XAL, thought.

      1. 8

        I saw SAT solvers as academically interesting but didn’t think that they have many practical uses outside of other academic applications. … I have to say that modern SAT solvers are fast, neat and criminally underused by the industry.

        Echoing a good comment on reddit: The author didn’t list any practical applications!!! How can you then say they are criminally underused?

        The only one I know of is writing versioned dependency solver for a package manager (in the style of Debian’s apt). However, very few people need to write such code.

        What are some other practical applications? I think they are all quite specialized and don’t come up in day-to-day programming. Happy to be proven wrong.


        EDIT: I googled and I found some interesting use cases, but they’re indeed specialized. Not something I’ve done or seen my coworkers do:

        https://www.quora.com/What-are-the-industrial-applications-of-all-SAT-solvers

        http://www.carstensinz.de/talks/RISC-2005.pdf

        I can think of a certain scheduling algorithm that might have used a SAT solver, but without details I can’t be sure.

        1. 5

          They see some use in formal methods for model checking. The Alloy Analyzer converts Alloy specs to SAT problems, which is one of the reasons its such a fast solver.

          There’s also this talk on analyzing floor plans.

          1. 4

            A previous submission on SAT/SMT might help you answer that.

            1. 4

              I’ve used Z3 to verify that a certain optimized bitvector operation is equivalent to the obvious implementation of the intended calculation.

              Just typed up the two variants as functions in the SMT language with the bitvector primitives and asked Z3 for the satisfiability of f(x) != g(x) and rejoiced when it said “unsatisfiable.”

              1. 1

                Hm this is interesting. Does this code happen to be open source?

                1. 7

                  I’ll just post it here. :)

                  (define-sort Word () (_ BitVec 64))
                  (define-fun zero () Word  (_ bv0 64))
                  
                  ;; Signed addition can wrap if the signs of x and y are the same.
                  ;; If both are positive and x + y < x, then overflow happened.
                  ;; If both are negative and x + y > x, then underflow happened.
                  (define-fun
                      add-overflow-basic
                      ((x Word) (y Word)) Bool
                      (or (and (bvslt x zero)
                               (bvslt y zero)
                               (bvsgt (bvadd x y) x))
                          (and (bvsgt x zero)
                               (bvsgt y zero)
                               (bvslt (bvadd x y) x))))
                  
                  ;; Here is a clever way to calculate the same truth value,
                  ;; from _Hacker's Delight_, section 2.13.
                  (define-fun
                      add-overflow-clever
                      ((x Word) (y Word)) Bool
                      (bvslt (bvand (bvxor (bvadd x y) x)
                                    (bvxor (bvadd x y) y))
                             zero))
                  
                  (set-option :pp.bv-literals false)
                  
                  (declare-const x Word)
                  (declare-const y Word)
                  
                  (assert (not (= (add-overflow-basic x y)
                                  (add-overflow-clever x y))))
                  
                  (check-sat)
                  
                  1. 2

                    Here’s you an example of SMT solvers used for stuff like that. I added some more stuff in comments. You might also like some examples of Why3 code which is translated for use with multiple solvers. Why3 is main way people in verification community use solvers that I’m aware. WhyML is a nice, intermediate language.

                2. 3

                  Keiran King and @raph compiled a SAT solver to WebAssembly to use for the “auto-complete” feature of Phil, a tool for making crossword puzzles (source).

                  1. 2

                    I found this library (and its docs) interesting. They go over some practical examples.

                    https://developers.google.com/optimization/cp/

                    1. 1

                      This looks like it’s about linear programming, not SAT solving. They’re related for sure but one reason it would be nice to see some specific examples is to understand where each one is applicable!

                    2. 2

                      I have personally used them when writing code to plan purchases from suppliers for industrial processes and to deal with shipping finished products out using the “best” carrier.

                    1. 13

                      Prelude: I worked myself into a state where I needed a two-hour break after about twenty minutes of keyboarding. Two keyboards with different layouts on different desks, changing between them every few minutes, a terrible project, and some ungood stress out of the office. But as luck would have it, that office was in a… well, not in a hospital, but on campus, so got to see a real specialist quickly. A friend in his department just brought me along. He spoke cluefully and I’ve followed his advice in the decades since. In brief: “Pay attention to your body. Learn what hurts and stop doing that. Don’t let anyone at you with a knife.” It’s served me well. I admit to a certain arrogance about it.

                      A colleague and I bought and tested about 10-15 keyboards, including some very expensive specials, and the ones we ended up using weren’t the most expensive one, which probably would get you into trouble with the bookkeepers if you were to try it. Arrogance helps.

                      I currently use an 88-key unlabelled WASD with dampening o-rings. Because it keeps me from moving my hands much while I type, and keeps me from looking at the keyboard, and I like the feeling of the keys. You should ignore the first sentence in this paragraph and focus on the second, because the brand name isn’t important, how your body reacts is vastly important. Does it feel okay? Then okay. Not? Then change.

                      The same applies to your chair and desk, because your body is one. The shoulders are tightly connected to your hands. (The chair comes first, btw. You get a chair for sitting on, then a desk that suits your body on that chair. http://rant.gulbrandsen.priv.no/arnt/ideal-office has more speechifying about chairs and stuff. I speechify too much.)

                      1. 4

                        This reminds me that when I was younger, I spent a lot of time behind my computer sitting on a plain old stool and I remember it was much more comfortable than the more traditional big and heavy armchair I currently use at my daily job. I think not having a backrest forces me to keep my back in a straight and comfortable position.

                        1. 3

                          I use synergy to share a single keyboard and mouse across computer systems. It works fine, and it can deal with Macs, Linux and Windows. You can even cut-n-paste across the systems as well (text only though).

                          1. 1

                            Have they fixed the bugs I ran across when I tried that?

                            1. 1

                              I haven’t encountered those issues, but the Mac is the server, and the Linux system is the client. I don’t know if that makes any difference.

                              Also, I think I started using it post 2011, so maybe those bugs don’t exist in the version I’m using.

                          2. 2

                            A stressful job plays a larger role than you might think. I speak from experience. About 10 years ago, I had really bad pain typing - for months. I quit my job, moved somewhere else, got a new job and the pain went away. It still flares up from time to time if I overdo it, but goes away quickly.

                          1. 5

                            I thought the float sorting was interesting. Here’s how Go handles NaN and Inf:

                            https://golang.org/pkg/sort/#Float64s

                            https://play.golang.org/p/3gd_LwQtBa7

                            1. 9

                              I’m currently working on a GUI app using Go, and in the process I realized that this is one of the coolest use cases for the “single binary output” feature. No dependencies, no libraries to be installed. Everything that’s needed to run the app on the desktop is contained in that one single binary. The Go runtime, the accompanying dependencies, everything. Coming from the Python world, this is so refreshing.

                              1. 8

                                Aren’t you just describing static linking? This is an ubiquitous feature among compiled languages.

                                1. 11

                                  “Coming from the Python world” :)

                                2. 2

                                  What kind of GUI? OpenGL?

                                  1. 4

                                    Yep, at the moment I’m playing around with https://github.com/golang-ui/nuklear .

                                    There’s https://github.com/andlabs/ui as well which is really native, but it hasn’t been under development for a year now so not sure what the status there is.

                                    1. 2

                                      That’s pretty cool. I’ve used go-qml before and while it’s not particularly lightweight, it’s a pretty interesting framework.

                                  2. 1

                                    I didn’t care much for go when I first started using it, but it made the whole deployment pipeline soooo much easier. It’s crazy how much that helps and just sweeps so much stuff under the rug – if you had asked be beforehand, I would have said that the language itself would trump pretty much everything.

                                  1. 2

                                    For the iMeme project I see it has a Windows version and a Mac version but when I checked GitHub I only saw the objective C code. Did you use objective C (and maybe Cocotron?) for the Windows version or some form of compiled Python with wxWidgets.

                                    1. 2

                                      Yeah, sorry, that’s confusing. Totally separate codebase: https://github.com/fogleman/pyMeme

                                    1. 16

                                      I revamped my website to better highlight my side projects and wanted to share it with you all. Hopefully you will find something interesting or inspirational! Let me know what you think.

                                      1. 2

                                        Lots of great stuff, thanks for sharing! Would love to hear some of the stories or deeper tech details behind projects like Star Rocket and Graph Layout.

                                        1. 3

                                          Glad you mentioned that. The lack of deeper content is one thing that bothers me about this, but it’s hard for me to know what people are interested in reading about.

                                          1. 6

                                            I hear this a lot - I would say go deep! You will consistently be surprised at how much people revel in the nitty gritty technical details.

                                            1. 3

                                              i’m always interested in reading about graph layout!

                                              1. 2

                                                It might be nice to have someone interview you so you don’t have to think about what content to write up. I’ve tweeted to one possible venue to that effect: https://twitter.com/briankung/status/869923696458256384

                                            2. 2

                                              Well done, looks really nice. Better yet, it’s inspirational and makes me want to pick up some forgotten side projects again.

                                              (Not to mention, either update my own site or just scrap it.)

                                            1. 4

                                              This is really cool. I didn’t know about fauxgl. Pure, no C required GL sounds really great for making Go only applications.

                                              1. 1

                                                Thanks! I wrote fauxgl mostly as a learning exercise, but I’m finding it very handy to have in my “toolbox.”

                                              1. 6

                                                Basically people love Go except for the fact that it lacks Generics

                                                1. 10

                                                  People who fill out surveys on the Go blog love Go. Not quite the same :P

                                                  1. 4

                                                    I hope the Go creators remain stalwart and don’t allow public opinion to sway their design decisions.

                                                    1. 2

                                                      I’d like to see the standard library evolve to allow more user-focused applications such as GUI and Android programming but otherwise I agree, the language itself is great.

                                                    2. 4

                                                      What’s interesting is golang has generics; they’re only for special blessed types though.

                                                      The best argument I’ve heard for generics in the language is it allows a more functional style for things like filter and map. Today these boil down to type specific functions or functions that mix interface{}, type assertions and for loops.

                                                      Really generics only add ergonomics, and when done poorly create amazing quagmires. I understand why the designers want to avoid user accessible generics.

                                                      If done simply though, much like how the slice/map or make/copy/delete functions work today, it would be a powerful addition to the language, but like others have noted I would not hold my breathe for it.

                                                      1. 5

                                                        Interesting. When I think about generics in Go, I don’t think about being able to write map or filter. Writing out the for loops to do the equivalent doesn’t irk me that much, and it’s pretty easy to get right.

                                                        The place where I miss generics the most is the ability to build reusable data structures. Some data structures are hard to get right, and those tend to be precisely the same data structures that one builds when you care about performance. This makes interface{} a double bummer, since you lose both type safety and you take a perf hit.

                                                        There are some interesting data structures that use interface{}, but by convention, generally end up retaining type safety. The new context package is one such example. But there are other examples that suffer the problems above.

                                                        With all that said, building these types of data structures feels pretty rare to me at $work, or at least, the data structures we need don’t have to be generic. So it ends up not being a huge problem. But it does happen from time to time.

                                                        I basically agree with your comment but thought I’d just add my two cents as well. :-)

                                                      2. 6

                                                        I suspect that when you ask people what Go is lacking, that’s the first thing that comes to mind whether you think it’s a real issue or not.

                                                        1. 2

                                                          I like Go just fine without ‘em, but then again I don’t use it for everything.

                                                        1. 16

                                                          This is my latest side project.

                                                          The core is written in Go and is cross platform and open source: https://github.com/fogleman/primitive

                                                          It got a lot of good feedback, so I thought I’d try putting a GUI on it and selling it in the app store. It only took me a couple weeks to do the GUI, website, etc. so it was worth the effort. It’s written in Objective-C and launches a Go binary to do the heavy lifting (communicating over stdin/stdout). A better approach might be to compile the Go code to a shared library and directly link it into the app, but I hadn’t considered that approach until someone mentioned it recently.

                                                          Sales have been really good since launching, but that’s mainly due to being on the front page of HN. It remains to be seen how well it will do over time, but people seem to like it.

                                                          Thanks for reading!

                                                          1. 8

                                                            Any particular reason for the lol TLD? I thought this was going to be a joke before I clicked.

                                                            1. 8

                                                              It was available and I figured it’s memorable at least.

                                                          1. 4

                                                            I got a little confused and was expecting this instead: https://en.wikipedia.org/wiki/Gorillas(videogame)