Hacker News new | ask | show | jobs
by asojfdowgh 1402 days ago
I always felt weird about the fact that Scratch et al exist, and that typing things manually exists, but you can't type code and get a visual result that is scratch-like

- - -

To clarify, I don't mean generating a visual version, but to instead highlight structure (e.g. background color for a for-loop and its indent), not keywords

6 comments

This is a kind of thing people built to realize they’re not that useful looking at the results (still think they can have value, it just feels too limited to be widely adopted)

Take SQL for instance: we already have tools that will take table definitions and built an UML tree from that. I used that kind of tools 3 times in my life, and threw away the result to draw something manually to really understand what was happening. The main issues were excessive visual complexity, noise from all the meaningless bindings, random component placement making is hard to mentally group components.

I’d expect these issues to be 100x worse with any code that expands beyond a single function, as the cyclomatic complexity would in average be a lot higher and we’d have a lot more noise from guard conditions and boilerplate.

Looking at it the other way works too: coding what we write everyday in ruby or typescript, but in Scratch, would be a crazy visual mess that would push anyone into depression.

Absolutely! UML gets a lot of discussion, but a more reflective model of a written program is something I long for. I love the feedback that I get from, say, writing a Tupfile and running `tup graph` to see an actual graph of all my recipes, complete with their commands, inputs, outputs, and interdependencies as understood by the build system. I haven't used Unity, but it looks like it has blender-like node-based programming that gives me the same feel, where each box ia just code but the connections between them are illustrated. Lastly, Emacs allows you to instrument function definitions with edebug, and stepping through the code or even just letting it run in a loop and observing the movement of the point-of-execution has given me a lot insight into packages that I've worked on. None of this is really "the thing", but each example gives me the same vibes, of showing how existing code or control flows are structured.
There was something like this a month ago on Show HN: PickCode – An educational coding environment for students after Scratch

https://news.ycombinator.com/item?id=32230329

The weirdest thing is that several languages have formatters and linters that constantly convert text into tokens and then back into text. Just do it one time and convert what text the user enters into a token then process that token like you say into a visual block that guides the developer better than plain text with completions.
The closest to this I have seen is something like Mathematica, where the frontend can map back and forth between visual widgets and code pretty seamlessly. I always wished they would actually take it a bit further, but some of the things you can do are cool.
I don’t know, in my opinion an advanced IDE is sort of that - I don’t think of IntelliJ’s text as notepad’s - it is more an AST in textual form as per the language’s grammar.

My human brain is very fast at parsing that to a tree based on visual cues, while the program does the same constantly - syntax highlighting is important exactly for this reason, if it is colorful, it parsed correctly, that’s the feedback between machine and human.

Even manipulations are AST-level, I expand the selection based on that, etc. It just has a very fast, “invisible” node-edit mode where you can just type a few characters to change the function node’s name.