6 ms·
Crab – an interpreter for a tiny subset of Logo
- deleted 6y ago[deleted]
- gwf 6y agoI could have sworn that Logo was a tiny subset of Logo. Live and learn.
- gwf 6y agoMore seriously, this is cute and it brings back fond memories of L-systems.
- WorldMaker 6y agoYeah, "turtle graphics" were a tiny subset of what Logo was meant to teach.
- lioeters 6y agoThe source is fascinating to read, it's a self-contained HTML document with a single style and script element. At first I couldn't believe that's all there was. The heart of the interpreter is "almost nothing": const think = (l,r,x) => (iter(l, (f,l) => (r.push(x = call(f,l,r,x)), args[f])), {r,x}) const wrap = x => /[a-z]+/.test(x) ? '\''+x+'\'' : x const parse = x => eval('['+x.replace(/([a-z]+)|(-?\d+)|(\])/g, x => wrap(x)+',')+']') const run = (text, x) => [x].concat(think(parse(text), [], x).r) And the LOGO commands are simply global variables. It's a fun project, and I appreciated the hand-crafted code. It reminded me of how much is possible with so little, small is beautiful indeed.
- bitexploder 6y agoAs always line breaks and de-nesting a bit would make it more obvious and not quite so terse. However, parsers and DSL usually do look almost like nothing in lispy like languages/ functional style, yet in C it’s a rats nest of for loops and flow control to parse things.
- stevekemp 6y agoI had fun reading that too. I recently submitted a small post here about implementing a simple FORTH-like language, in golang. I figured I should go a step further and document how you'd embed that inside a host-application. So I came up with a trivial turtle-implementation. To draw a square: 50 forward 90 turn 50 forward 90 turn 50 forward 90 turn 50 forward Of course with FORTH you'd define a word to draw a square of the given size: : square ( top of the stack is length of side) dup dup dup 4 0 do forward \ move forward, drawing a line 90 turn \ turn 90 degrees. we're a square! loop ; The result was definitely fun to play with, especially once I made it output both the final result and an animated gif of each draw-step: https://github.com/skx/turtle https://github.com/skx/turtle This reminds me strongly of that post. DSLs are fun, and something like FORTH maps well to a lot of simple use-cases.
- hhas01 6y ago“Of course with FORTH you'd define a word to draw a square” With Logo you would do exactly the same. In fact, growing the language’s base vocabulary with your own words is the whole point of Logo and Forth. Why waste your entire lifetime speaking the machine’s primitive, low-level language when you can teach it how to speak your own powerful, high-level ones? +1 for using the amazing horseshoe crab† as cursor, but -1,000,000 for so utterly missing the point. -- † Not actual crabs, they’re more closely related to spiders and have lived on Earth virtually unchanged for almost half a billion years. https://oceantoday.noaa.gov/fullmoon-remarkablehorseshoecrab/welcome.html https://oceantoday.noaa.gov/fullmoon-remarkablehorseshoecrab...
- jhbadger 6y agoExactly. Logo is a real programming language and it is a shame that it gets reduced to "that children's toy for doing turtle graphics" in pop tech culture.
- WorldMaker 6y agoI think the way Logo was taught in schools certainly didn't help. When baby programmer me first discovered you could define functions and used them I remember getting scolded for not following the lesson plan and continuing to do things the hard way. The lesson plan of course lumped function definitions as "advanced" and really only for "the next grade up". My impression is most teachers didn't actually want to teach "the next grade up" of Logo (as it was hard for them) so it was always just the same basic Turtle graphics anyone ever learned (sometimes over and over again, grade to grade), diminishing the point of Logo as an entry way into those harder to teach topics such as functions and recursion. It doesn't seem surprising that pop culture only remembers turtle graphics, when that's all anyone was ever taught.
- empressplay 6y agoCool! On the opposite end of the spectrum, we're working on a very complex Logo with 3D OpenGL support https://turtlespaces.org https://turtlespaces.org
- speps 6y agoImagine just a kid on Windows, you have to go to the download page, find the right link (not at all clear from your CSS styles by the way). Then, if they don't read the warning you'll have a security warning. Then, Windows will warn because it's a downloaded executable from a website. Then you have to find where it extracted it and then run it! Port it to WebAseembly/WebGL already! No downloads, no warnings, also works on phones, etc. EDIT: just wanted to add that you have something really incredible in your hands, try to make it more accessible, more tutorials would be good
- ptrott2017 6y agoIs turtlespace planned to be open source? Wondering if possible to contribute. Its a very nice platform - congrats.
- VolatileVoid 6y agoThis is awesome! Whilst we were in lockdown the first time, I wrote a small Logo interpreter for my son with almost exactly the same commands: https://freememory.github.io/azlogo/ https://freememory.github.io/azlogo/ (https://github.com/freememory/azlogo https://github.com/freememory/azlogo) My code isn't nearly as elegant, not at all animated, and my parsing is awful but I had a lot of fun doing it. There's something magical about Logo, and even now as an adult of almost 40 I continue to enjoy playing with it and making pretty line graphics.
- ishcheklein 6y agoWhat are the current applications of these languages? Is there anything besides educational one (I remember we had a class at the middle school).
- GeneralMayhem 6y agoJust education and toys. The simplest ones like this aren't even Turing-complete, so you couldn't really program much in them even if you wanted to as a weird challenge - they're more like automated Etch-a-Sketches. They do make for good languages for toy robots, though - for instance, you can use Scratch with Lego Mindstorms in a way that's not much more advanced than Logo.
- empressplay 6y agoWe're working on making a Logo-based game engine; we're also going to release a command-line version for scripting soon. Actual Logo is a fully-complete language with sophisticated string and list handling. So we're hoping to make Logo more useful than just for education! =)
- RodgerTheGreat 6y agoIf you enjoy this, you might also like http://beyondloom.com/somascape/index.html http://beyondloom.com/somascape/index.html
- JosephRedfern 6y agoLogo was the first "programming language" I ever used. I had a fantastic primary school teacher in year 3 who introduced us to an implementation called MSW Logo. Very fond memories.