27

The tag has a few hundred questions - not the highest priority, but there are more visual languages that are on topic for Stack Overflow, and the site is supposed to be comprehensive.

I found this older question in which the question describes a task (rather than seeking debugging help) and the answers show some Scratch code in a text form while linking to some kind of renderer for the "visual representation" of the code (which is the default way of working with code in Scratch).

It seems, however, that most OPs will simply take a screenshot from the editor and/or link the editor with some project ID (as in this example which motivates me to ask, which did both), neither of which is ideal.

For MIT Scratch specifically, is there support provided by the editor for exporting a textual form that would be suitable for posting code as text (in the way that we normally expect)? Would it be possible to integrate support into the site for rendering such code, in both questions and answers, along the lines of how "Stack snippets" currently work for web examples?

More generally, can we do more to support visual languages on the site?

5
  • 9
    For people with ideas, I encourage you to post them as answers rather than comments, so that it's easier to discuss them.
    – Ryan M Mod
    Commented Sep 17, 2023 at 0:56
  • Maybe with diagramming or charting support like with mermaid.js one could have more visual kinds of input without needing to rasterize the input. Commented Sep 18, 2023 at 13:58
  • -1 Not sure if this is a general question about graphical languages in general (in PLC-land, SFC and LD come to mind), or is it about mit-scratch? The SO issue is with graphical languages in general, but yet the question/(accepted) answer appears to be about mit-scratch?
    – franji1
    Commented Sep 18, 2023 at 19:38
  • 2
    @franji1 I was perhaps hasty in accepting it. I did intend the question to be general, but it seems likely - based on the scratch-based reply - that there is nothing that can realistically be done. Commented Sep 18, 2023 at 20:40
  • Good question. I'd say a big component in these kind of situations is (again) to do with duality. Some people allow themselves to be flexible especially where specific tags are involved and do what is needed to get a question answered, others make no exceptions and thus apply rigidity. It is that duality which can really cause particular types of question to either do well or crash and burn, seemingly random because it depends on which eyeballs land on it. Woe is any such question which ends up in a review queue.
    – Gimby
    Commented Sep 20, 2023 at 11:46

1 Answer 1

23

For MIT Scratch specifically, is there support provided by the editor for exporting a textual form that would be suitable for posting code as text (in the way that we normally expect)?

No. It doesn't even seem to be possible to "copy" anything in any of the editors; you have to "duplicate" code. Any textual representation would require the author to manually type it up and then anyone interested in using the code to reproduce that via blocks in their own project.

There is scratchblocks, which allows text to be converted to an image of blocks (example code (golfed) — note that links do not play well with markdown, however). It even can be embedded in a page, like syntax highlighting that instead converts text to an image — this is enabled on the Scratch forums so it's pretty standard. It's handy, but the generator doesn't work for the newest version (3.0), which is the only viable version since the old ones require Flash.

The only way to efficiently share code is to use the online editor where you can upload code you were working on directly from your computer. The project can be edited from there (probably with no obvious version control), or it can be downloaded. The project can also be embedded in another site via an iFrame, but on SO this errors out in a snippet due to the website settings. Example project:

Block Palette next to the code next to the game preview

Bottom line, considering the state of the technology, combined with the target demographic for MIT-Scratch (children, so askers as young as 13), there's not many options.

2
  • 10
    This seems like an issue to bring up with the developers as a feature request. Adding something like an XML representation as a text import-export format.
    – Dave S
    Commented Sep 18, 2023 at 2:07
  • 9
    Scratch has an unofficial text representation which allows import and export, tosh2. For a different visual programming language, Access macros, I tend to answer in the text representation (AXL), which usually works fine, and sometimes link to a self-answered Q&A on how to work with the text representation. I'm unaware of programming languages with no text representation at all
    – Erik A
    Commented Sep 18, 2023 at 10:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .