Show HN:Goboscript,一种基于文本的编程语言,编译成Scratch
Show HN: Goboscript, text-based programming language, compiles to Scratch

原始链接: https://github.com/aspizu/goboscript

Goboscript 是一种基于文本的编程语言,可以编译成 Scratch 项目(.sb3 文件)。它允许开发者使用简洁易读的文本语法编写 Scratch 程序,从而更容易地管理代码、进行版本控制(使用 Git)和代码复用。Goboscript 提供了超越简单 Scratch 块转换的功能,包括局部变量、强大的宏系统(类似于 Rust 的)和优化功能。 aspizu.github.io/goboscript 上的安装说明专门面向为 Goboscript 本身做贡献的开发者,需要 Rust 工具链。在开发过程中,`tools/run` 脚本会自动化编译过程、使用 `scratch-parser` 对 Scratch 模式进行验证,以及提取/重新打包 `project.json` 文件以进行调试。 Goboscript 在 FOSS United 基金会举办的开源黑客马拉松 FOSS HACK 25 中获得一等奖,奖金为 50,000 印度卢比。此次黑客马拉松的重点是解决 Goboscript 中已存在的问题并实现新功能。

GoboScript 是一种新的基于文本的编程语言,可以编译成 Scratch 项目。其创建者希望它能够帮助孩子们从 Scratch 的可视化界面过渡到传统的编程。用户可以用文本编写 Scratch 程序,利用版本控制和文本编辑器的优点,例如查找/替换和复制/粘贴。它包含超越简单积木翻译的功能,例如局部变量和代码优化。 评论者 AlexanderDhoore 赞赏这个概念,因为它可以帮助 8-10 岁的孩子在掌握 Scratch 后过渡到“真正的编程”。他们指出,英语障碍、计算机概念和打字技巧等挑战可能会阻碍学习进度。虽然他们希望 GoboScript 使用 Python 等语言,但他们也认识到它在 Scratch 的熟悉环境中引入基于文本的编程的价值。 另一位评论者 japanuspus 建议在 README 中加入简单的安装说明,以便目标用户(从 Scratch 毕业的孩子)更容易上手。他们建议利用 Rust 工具链和 `cargo install --git ...` 命令来简化安装过程。

原文

image

Installation and documentation

goboscript is a text-based programming language which compiles to Scratch. It allows you to write Scratch projects in text, and compile it into a .sb3 file - which can be opened in the Scratch editor, TurboWarp or be uploaded to the Scratch website.

goboscript allows you to create advanced Scratch projects with ease, you can use any text editor, use a version control system such as git. You can refactor your code using search and replace. Text code can be copy pasted, which allows you to easily reuse code or share it with others. goboscript syntax is concise and easy to read.

goboscript allows you to integrate external tooling and workflows, such as using a script to generate costumes for a text rendering engine. Or loading in images into lists.

goboscript has a powerful macro system - similar to Rust's macro system. This allows you to write macros to generate code.

goboscript is more than just an 1:1 mapping of Scratch blocks to text, it also has additional features like local variables for procedures (custom blocks).

goboscript also performs optimizations, detects problems and unused code.

goboscript welcomes contributions in the form of Pull Requests.

goboscript is written in Rust. You'll need to install the Rust toolchain for development.

Note

To install goboscript, follow instructions at aspizu.github.io/goboscript. These instructions are for people who want to develop goboscript itself.

git clone https://github.com/aspizu/goboscript
cd goboscript

After cloning the repository, run goboscript locally from the repository root with:

cargo run -- build -i your_project/

But, to make development easier, and to validate the generated Scratch project - use the tools/run script:

This assumes that you have set-up a testing project at playground/. It will compile the project, validate it using the schemas from scratch-parser. If the validation fails, Scratch will refuse to load the project. To further debug the project, the generated project.json file is extracted from the .sb3 file in the playground/ directory.

Lets say that you modified the generated project in the Scratch editor or Turbowarp, and you want to look at the project.json. You can extract it with:

Lets say that goboscript produced a broken project, and you are able to fix it by hand - by modifying the project.json. You can add back the project.json to the .sb3 file with:

If you want to validate some .sb3 file, use:

tools/run check path/to/project.sb3

goboscript was one of the first-place winners of FOSS HACK 25, and was awarded a 50,000 Rs. prize. FOSS HACK 25 was a open-source hackathon conducted on 22nd - 23rd February 2025 by the FOSS United Foundation. During the 48-hour hackathon, I had worked on several goboscript issues and feature implementation. Thank you FOSS United for the platform and oportunity.

This section will be updated with information about how the funds will be utilized.

联系我们 contact @ memedata.com