Show HN:Thoreau BASIC——如果 BASIC 没有过时,会怎样?
Show HN: Thoreau BASIC – What if BASIC hadn't gone out of fashion?

原始链接: https://thoreaubasic.com/

**Thoreau BASIC 3.2** 是 GW-BASIC 风格编程语言的现代 64 位演进版本。它可运行于 Windows,也可直接从 UEFI 固件启动而无需操作系统;程序可打包为独立的 Windows EXE 文件或可启动的 EFI 应用程序。 3.2 版本新增了 BASIC 原生文件浏览器和菜单、保留文件名大小写、最长 4,095 字节的路径、交替校验状态检查点、分阶段保存和经验证的备份、CRC32、文本统计、扩展的系统报告、JIT 优化,以及改进的程序重新启动功能。 其功能包括 24 位图形、精灵、鼠标输入、TCP/IP 和 HTTP、调试与性能分析工具、多核 `PARFOR`、原生 x64 JIT 编译,以及复数、四元数和八元数运算。多媒体支持涵盖 GM/GS 波表,以及 MIDI、WAV、FLAC 和 Opus 播放,并可在播放前扩展音色库。 Windows 和 UEFI 版本使用相同的解释器和波表。该版本还包含 BASIC 示例程序 Pixel Prose 及其独立应用程序。可通过项目的 itch.io 页面下载并获取更多信息。

Thoreau BASIC 是一个免费的 x64 BASIC 解释器,灵感来自 GW-BASIC,旨在探索 BASIC 如果持续发展,而不是逐渐过时,会呈现怎样的面貌。3.2 版本保留了熟悉的语法——行号、GOTO、GOSUB、PRINT、图形和声音——同时加入了现代功能。 主要亮点包括原生 x64 JIT 编译和解释器回退、多线程 PARFOR 循环、SSE2/AVX2 加速、64 位寻址、超大数组、超复数、24 位图形、精灵图、多边形渲染、鼠标输入、TCP/IP 网络,以及调试、性能分析、执行跟踪和系统诊断。它最多支持 32 个乐器通道、64 个音效通道和 256 个声部。 程序可以使用 CREATEEXE 打包成独立的 Windows 可执行文件,也可以使用 CREATEEFI 打包成可启动的 UEFI 应用程序。Windows 和 UEFI 环境旨在运行基本相同的语言。演示项目包括实时交互式曼德博集合探索器、3D 和程序化图形、精灵图、网络、游戏以及超复数分形。本项目欢迎 GW-BASIC/QBasic 用户、编译器开发者,以及任何希望在裸机硬件上直接运行现代 BASIC JIT 编译器的人提出反馈。
相关文章

原文

Download

Windows x64 · ZIP

UEFI x64 · ZIP

Plain-text documentation

3.2 release notes

THOREAU_GM.TBGM · losslessly compressed wavetable · 513.5 MB

3.2

File browsers and menus are now ordinary BASIC commands. GETFILES gathers files, directories and the parent entry with an optional file mask. SELECTBOX turns a string array into a keyboard- and mouse-controlled selector, with multiple columns, optional colors, and single or double box-drawing frames.

Filenames keep their original spelling and case throughout the file commands. Masks are case-sensitive. Full paths can contain up to 4,095 bytes, including an added extension; filesystem limits on individual names still apply.

STATEWRITE and STATELOAD checkpoint selected variables to two alternating, checksummed generations. FLUSH, FILECOMMIT and FILECOPY support staged saves and verified backups. CRC32 checks byte strings, and TEXTSTATS counts words and characters in a range of a string array.

SYSTEMINFO$ reports CPU and firmware details, usable AVX2 or SSE2, PARFOR capacity, the calibrated TSC counter rate, display backend and build information. Targeted JIT changes reduce work in floating-point INT and native complex, quaternion and octonion arithmetic. RUN can restart a program without growing the host stack, and HELP category headings appear once.

The Opus wavetable and WAV, FLAC, Opus and MIDI playback remain available. Sound banks are expanded to PCM before playback, with no decompression while music plays. Standalone EXE and EFI applications can omit the bank with NOGM. See the manual and release notes for the full changes and syntax.

What it is

Thoreau BASIC starts from GW-BASIC-style syntax but is not trapped in 1983. It has 64-bit memory, 24-bit graphics, sprites, mouse input, TCP/IP and HTTP, a complete GM/GS wavetable with MIDI/WAV/FLAC/Opus playback, complex/quaternion/octonion values, a debugger, profiler, source tools, multicore PARFOR, and native x64 JIT compilation.

The same BASIC language runs as a normal Windows program or directly from UEFI firmware without an operating system. BASIC programs can also be packaged as standalone Windows EXE or bootable EFI applications.

Still BASIC

10 CLS
20 PRINT "HELLO FROM THOREAU BASIC"
30 FOR I=1 TO 5
40 PRINT I
50 NEXT I
60 END
RUN

And now the orchestra is BASIC too:

SOUND PRELOAD
LOADMID 0,"BALLADE.MID"
PLAYMID 0

Graphics, networking and sound remain ordinary BASIC commands, not separate frameworks.

BASIC without an operating system

The UEFI build boots directly on x64 machines. It uses GOP graphics, firmware or raw HID keyboard input, mouse support with fallbacks, networking through firmware protocols or Thoreau's own SNP-based stack, HDA/Azalia PCM sound where available, and the same interpreter/JIT and GM wavetable used by the Windows version.

Pixel Prose

Pixel Prose is included as a Thoreau BASIC example and is also available as standalone EXE and EFI builds. The original versions for DOS, Commodore 64 and Amstrad CPC live with my other retro projects on itch.io.

Project

The project page and downloads are on itch.io.

Contact

[email protected]

Bug reports, compatibility notes and strange BASIC edge cases are very welcome.

If you want to support development, PayPal is available. No nag screens, no locked features.

联系我们 contact @ memedata.com