1. 4

    I blog at petecorey.com. Lately I’ve been writing about Elixir, Bitcoin, and music. Over the years I’ve written quite a bit about the various technologies I’ve worked with (Node.js, GraphQL, etc…) and anything else that interests me.

    1. 3

      I really enjoy your writing, Pete!

      1. 1

        Thanks!

    1. 4

      Aside from some client work, I’m working on building a Bitcoin full node entirely in Elixir. It’s entirely for learning purposes (my own), and I’m documenting my progress along the way. Fun stuff.

      1. 2

        This is awesome! I’ve actually been tinkering with the idea of hosting a DF instance elsewhere and playing remotely. Anything to keep my laptop from burning my legs. You read my mind!

        1. 2

          This is neat. While I’m less keen on the APL-like languages, I’ve often felt Forth-like languages would also be quite useful for creating music.

          Maybe, in my infinite (not) time, I’ll try to create an example stack-based language for music… Maybe…

            1. 2

              You should. I could see things like chord substitutions lending themselves really well to a stack-based language.

            1. 3

              This problem (test assertion not running) is a general problem in most testing frameworks which require you to call a ‘fail’ (directly or indirectly) as the only way to signal a problem. Sometimes you fail to call fail.

              Perl produced a test system called TAP (Test Anything Protocol) - now ported to other environments: https://testanything.org/

              This uses an approach where:

              • both positive (ok) and negative (not ok) assertions are reported
              • the test begins with a statement of the total number of assertions expected (you can finish with this too)
              • a test whose number of assertions doesn’t match the plan (too many or too few) has failed

              There is a small piece of extra work (when you add a test, you have to increase the planned number), but this is minor and the approach guards against tests failing to run for any reason (if your test fails so drastically that it can’t even emit a plan, the test harness will/should report that).

              (Here’s one perl API to emit TAP: http://perldoc.perl.org/Test/More.html)

              1. 1

                Interesting. Yeah, I’ve experienced this when testing asynchronous code. Jest, for example, lets you set your expected number of assertions up front, per test, which is nice.

                I guess I just wasn’t expecting this to come up during a totally synchronous test. And obvious that was a dangerous assumption to make.

                Thanks for the links!

              1. 2

                Another excellent Elixir article! Your Bitcoin network client posts have been very helpful to me in using Elixir practically as well.

                1. 1

                  Thanks! That’s always encouraging to hear.

                1. 5

                  The author mentions that ASCII-friendly APL successors (see J) “are all ugly far beyond the possibility of public success.” While I don’t necessarily agree, I feel like ligature fonts would be a perfect fit for a language like J. It could be used to map verbs onto their APL equivalents, and just make things look a bit more cohesive.

                  1. 7

                    J is beautiful and, in terms of semantics, is even more elegant than APL. The notation is its primary drawback, to me, for two reasons: there is no longer a one-to-one mapping of action to symbol (because some symbols are digraphs or semi-trigraphs); and because the symbols used already have well-known meanings, causing cognitive burden when switching between the J and the everywhere-else meaning.

                    Also:

                    This is the Game of Life in APL

                    I love APL but I swear if all you read is pop-CS articles about APL you’d think it’s Life: The Language

                    1. 3

                      Would you have some recommendation of array language snippets that are more representative of the things people end up writing?

                      As someone extremely tired of seeing fibonacci examples for functional languages, I’m very interested in knowing what real APL looks like

                      1. 2

                        The Co-dfns compiler (https://github.com/Co-dfns/Co-dfns) is an APL-to-C++ compiler written in APL.

                        GNU APL has a pretty nice community page at https://www.gnu.org/software/apl/Community.html where they list some APL projects (some written in APL and others in other languages).

                        J has an extensive standard library and a complete relational database written in J, all at https://jsoftware.com

                        Array languages get the most use today in finance, I believe. The K language from Kx Systems (and the Q query language strongly related to it) are widely used there and have a free-as-in-beer version available with some documentation.

                        (I don’t remember who said it, but the statement “every time you buy stock you’re using K” is probably a reasonably true statement.)

                    1. 11

                      Can you tell me why your blog requires javascript to display the content? It’s extremely frustrating, it’s all there but post the initial blip the site just turns white with only the header remaining visible.

                      https://i.imgur.com/mQHB3N0.png

                      1. 2

                        Fixed.

                        1. 2

                          Works fine with FF’s reader view mode even with javascript blocked. He has a bit of javascript that loads typekit and toggles opacity on success. As to why?

                          1. 2

                            Looks like there’s an “opacity: 0” in the CSS.

                            1. 1

                              so i just have to disable css too? :)

                          1. 2

                            One question I’ve been puzzling over since your previous post: where does the “forkness” of ‘+/ % #’ lie? I’m probably being the fish asking what water is, but I’m used to languages having a well defined evaluation model with precedence. Like expanding inner expressions first, or applying operators from left to right. How does the ‘mean’ construction above know to pass its input to both ‘+/’ and ‘#’? Is it just hardcoded into a few operations (akin to Common Lisp special forms)? Or is there a way to construct hooks out of arbitrary operators?

                            1. 2

                              Or is there a way to construct hooks out of arbitrary operators?

                              Any three verbs in a row are a (monadic) fork (there are also dyadic forks). Adverbs (e.g. /) are evaluated before verbs (e.g. %), so a verb is produced by the verb-adverb +/ and thus you get three verbs (plus-over, divide, tally) in a row and thus a fork.

                              There’s no hard coding of it:

                                  plus =: +
                                  over =: /
                                  plusover =: plus over
                                  divide =: %
                                  tally =: #
                                  average =: plusover divide tally
                                  average i.4
                              1.5
                              
                              1. 2

                                Like @lorddimwit mentioned, any three verbs in a row form a fork. Forks and hooks do have well defined evaluation models. It’s spelled out pretty well on this page.

                                In the case of mean, we’re looking at a “monadic fork” (a fork that takes a single argument). The evaluation model for monadic forks looks like this:

                                (V0 V1 V2) Ny  is  (V0 Ny) V1 (V2 Ny)
                                

                                Subbing V0, V1, and V2 for +/, %, and # gives us:

                                (+/ Ny) % (# Ny)
                                

                                Where Ny is your argument.

                              1. 4

                                Great article! Clear, concise, and with code snippets. I noticed you have a small error near the bottom:

                                out of the box with Elixir and Elixir.

                                Did you mean /Erlang/ and Elixir?

                                1. 2

                                  Whoops, good catch. The fix should be rolling out soon. Thanks for the kind words!

                                1. 1

                                  Interesting stuff! I’d love to hear more about how Pony’s correctness affects the need for supervision trees. Is there no supervision hierarchy at all in a normal Pony app?

                                  1. 3

                                    (Caveat: I’m still not immersed in all of Pony & its best practices)

                                    No, not really. Actors don’t crash, so the fault-tolerance reasons for supervisor trees do not apply. However, another use for supervisors is to coordinate application startup (of course) but also application shutdown, both in a deterministic manner. In those cases, the nearest related-a-little-bit feature in the DisposableActor interface in the standard library https://stdlib.ponylang.org/builtin-DisposableActor/ … but it does not provide any you-shutdown-before-that-other-actor coordination that a supervisor tree can.

                                  1. 13

                                    This one feels like he forgot to keep going. The explanation of hooks and forks is fairly lucid and useful, but he forgets to justify or even mention the apparent thesis: how the qualities that lead to J being extremely difficult to read actually lead (allegedly) to some other level upon which it’s easier to understand than otherwise.

                                    1. 6

                                      Author of OP here. Did you continue reading past the newsletter signup block? I should probably make that less conspicuous. If you read to the bottom and still feel like I left you hanging, I apologize for not being clear. My goal was to explain that verbs and hooks can be read linearly as sentences, rather than having to consciously consider argument routing through each of the hook/verb’s verbs.

                                      1. 3

                                        I read until the paragraph after tacit, and I agree with /u/zdsmith here. If your goal was to explore hooks and forks, perhaps it would have been better to title the article something different.

                                        1. 1

                                          Wow, yeah. I didn’t know there was more article. My eye immediately stops when it hits that kind of thing. My apologies for jumping the gun, though yes, as you say, it may also be a lesson in growth hacking :)