<div dir="ltr"><div dir="ltr"><div>Hi Brent,</div><br><div class="gmail_quote"><div dir="ltr">On Sun, Dec 16, 2018 at 10:26 PM Brent Yorgey <<a href="mailto:byorgey@gmail.com">byorgey@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I'm not aware of any *functional* block-based languages.  If you know of any, please let me know!<br></div></div></blockquote><div><br></div><div>I don't suggest you use this with your son, but if you're curious, a few years ago, Stefan Jacholke used Blockly to build a block-based front-end for CodeWorld, as part of Haskell.org's Summer of Haskell (in one of the years that <a href="http://haskell.org">haskell.org</a> was not chosen for Google Summer of Code).  It's still available at <a href="http://code.world/blocks">http://code.world/blocks</a>.  An interesting example is <a href="https://code.world/blocks#PIHIp7uCWam2t0iuN9w8zXA">https://code.world/blocks#PIHIp7uCWam2t0iuN9w8zXA</a></div><div><br></div><div>That said, though, it's not in great shape.  There's quite a lot of code involved, including a significant amount of development on a <a href="https://github.com/stefan-j/blockly">custom fork</a> of yet another <a href="https://github.com/awmorp/blockly">custom fork</a> of Blockly.  It's also <a href="https://github.com/google/codeworld/issues?q=is%3Aopen+is%3Aissue+label%3Afunblocks+label%3Abug">a bit buggy</a>.  This should be viewed as a proof of concept, from which we learned quite a bit about the task.</div><div><br></div><div>Some of the lessons we learned:</div><div><ol><li>Type inference in the client is a big deal.  One should pay attention from the beginning to maintaining a correct incremental version of type inference, which should probably be based on something like Erdi's compositional variant of Hindley-Milner.  Retrofitting the client-side implementation to CodeWorld Blocks led to a demoralizing game of whack-a-mole with consistency bugs, which was ultimately abandoned before we won.</li><li>Assuming a new version were again based on Blockly, it would be important to coordinate changes to Blockly with the upstream repository.  While this is a challenging cross-team coordination problem made worse by the lack of engineering resources for the core Blockly project, forking Blockly is even more challenging in the long run.</li><li>The usability of Blockly's configuration panels is quite poor indeed; enough so that I found it nearly impossible to teach the portions of CodeWorld Blocks that needed them.  This includes lists and user-defined functions.  One would need to come up with a better approach to this, to have hope of success.  Adding buttons and controls onto the block itself would be much more promising.</li><li>Blockly-based languages desperately need a more compelling compatibility story.  Making a backward-incompatible change in a text-based language can require that programmers update their code, but doing the same in a Blockly-based language can cause the code to fail to load so much that the user may just as well start over and rewrite it entirely.</li><li>Blockly is also quite poor at usability.  Being block-based is no panacea.  It could likely be made much nicer with some intelligent search features.  One could imagine clicking a connector to get a selection of blocks that would fit into that hole, or typing the first few letters of a function name to see a selection of blocks that begin with those letters.  As is, though, building anything non-trivial in Blockly feels so tedious as to be off-putting.</li></ol><div>Anyway, this is just thoughts that came to mind from that question.  Of course, there are deeper answers to how to design a visual functional language, too, based on dataflow diagrams and such.  Since a key part of my goal in the CodeWorld project is to teach the conventional syntax of algebraic expressions and functions, I wasn't actually so interested in those more ambitious language designs.  You might be, though.  If so, I hope someone else can share some information there.</div></div><div><br></div><div>Thanks,</div><div>Chris</div></div></div></div>