메뉴
HN
Hacker News 23일 전

현대적인 자가 컴파일 파스칼 컴파일러 Blaise 공개

IMP
7/10
핵심 요약

수십 년간의 레거시 부채를 없애고 현대적인 개발자 생산성과 메모리 안전성을 확보한 차세대 오픈소스 Object Pascal 컴파일러인 Blaise가 소개되었습니다. 단일 언어 모드, 단일 UTF-8 문자열 타입, 자동 참조 카운팅(ARC)을 채택하여 복잡성을 대폭 줄였으며, 이미 자가 컴파일링( Self-hosting)을 달성했습니다. 향후 LLVM 백엔드와 다양한 OS 지원, VS Code 확장 프로그램 등을 통해 기존 FPC/Delphi 개발자들에게 강력한 대안을 제공할 것으로 기대됩니다.

번역된 본문

Blaise Pascal Compiler: 당신이 사랑하는 파스칼을 현대에 맞게 새롭게 탈바꿈하다. Blaise는 수십 년의 레거시 부담을 해소하기 위해 밑바닥부터 새로 구축된 차세대 Object Pascal 컴파일러입니다. 이 컴파일러는 개발자의 생산성, 메모리 안전성, 고성능 실행을 최우선으로 삼습니다.

✨ 비전 Object Pascal 생태계는 현재 두 가지 선택지가 있습니다. Embarcadero Delphi(상용, Windows 우선)와 Free Pascal(오픈소스이지만 30년간 축적된 복잡성—5가지 언어 모드, 5가지 문자열 타입, 수천 개의 포함 파일—을 가짐)입니다. 이 컴파일러는 다른 접근 방식을 취합니다:

  • 단일 언어 모드: {$mode} 스위치가 없으며, 레거시 방언을 지원하지 않습니다.
  • 단일 문자열 타입: UTF-8 참조 카운팅 문자열입니다. 바이너리 데이터를 위한 RawBytes를 제공합니다.
  • 단일 메모리 모델: 자동 참조 카운팅(ARC)이 문자열, 클래스, 인터페이스에 균일하게 적용됩니다. TObject와 TInterfacedObject 간의 수동/자동 분할이 없으며, [Weak] 속성으로 순환 참조를 해제합니다. Free는 즉시 해제의 동의어로 유지됩니다.
  • 깔끔한 인터페이스: COM GUID가 없으며, 컴파일 타임 vtable 매핑을 통해 인터페이스 디스패치가 이루어집니다.
  • 구체화된 제네릭(Reified generics): 컴파일 타임에 모노모피화(Monomorphization)가 이루어지며, 타입 소거(Type erasure)가 없습니다.
  • 현대적인 빌드 시스템: project.xml을 사용하는 PasBuild를 사용하며, makefile은 필요하지 않습니다.
  • 일급 디버거: OPDF가 기본 디버그 형식이며, DWARF가 필수적이지 않습니다. 자세한 아키텍처와 구현 계획은 docs/design.adoc을 참조하세요.

결과 — QBE(그리고 향후 LLVM)를 통해 네이티브 코드를 타겟으로 하는 현대적인 크로스 플랫폼 Object Pascal 컴파일러가 탄생했습니다. 단일 언어 모드, 단일 문자열 타입, 제로-GUID 인터페이스, 구체화된 제네릭, 그리고 일급 OPDF 디버그 형식을 지원합니다.

🚀 프로젝트 상태

  • 자가 호스팅(Self-Hosting): 예. Blaise는 현재 스스로 부트스트랩하고 재컴파일하며 바이트 단위로 완벽하게 일치하는 결과를 냅니다.
  • 테스트: 1200개 이상의 테스트가 있으며 계속 증가 중입니다 (첫날부터 테스트 주도 개발 방식 채택).
  • 백엔드: 현재 QBE 백엔드를 사용 중이며, LLVM 백엔드를 활발하게 개발하고 있습니다.

단계별 목표 및 상태: 1단계: 부트스트랩 파이프라인 — PasBuild를 통해 Linux x86_64에서 Hello World 실행 (완료 ✅) 2단계: 타입 시스템 — 클래스, 레코드, 자동 참조 카운팅(ARC), 예외 처리 (완료 ✅) 3단계: 제네릭 + 제로-GUID 인터페이스 (완료 ✅) 4단계: OPDF 디버그 정보 생성 (완료 ✅) 5단계: 자가 호스팅 + LLVM + Windows + macOS ARM64 (진행 중) 6단계: LSP + VS Code 확장 프로그램 (계획 중) 7단계: FPC/Delphi 코드베이스를 위한 마이그레이션 분석기 (계획 중)

고전 파스칼에서 제거된 기능들:

  • ShortString, AnsiString, WideString, UnicodeString -> 단일 UTF-8 참조 카운팅 문자열 타입으로 대체됨.
  • with 문 -> 진단하기 어려운 기호 해결 버그의 원인이 되며 정적 분석을 방해함.
  • 구식 객체 타입 -> 대신 record(스택/값) 또는 class(힙/참조)를 사용하세요.
  • COM 방식 인터페이스 GUID -> 컴파일 타임 vtable을 통한 인터페이스 디스패치; GUID는 불필요한 복잡성임.
  • 다중 언어 모드 -> 하나의 방언을 잘 유지하는 것이 다섯 개를 형편없이 유지하는 것보다 낫습니다.
  • assign, reset, rewrite, blockread -> 스트림 기반 I/O RTL로 대체됨.
  • TObject vs TInterfacedObject 분할 -> 자동 참조 카운팅(ARC) 아래 하나의 통합 클래스 모델 사용; [Weak]으로 순환 참조 해제.

📢 커뮤니티 핵심 아키텍처가 아직 확정되지 않았으므로, 이 프로젝트는 아직 코드 기여를 받고 있지 않습니다. 언어 설계, 구문 선택 및 Blaise의 미래 방향성에 대한 피드백은 환영하며, GitHub의 Discussions 탭을 이용해 주세요.

리포지토리 구조 이 프로젝트는 PasBuild의 멀티 모듈 레이아웃을 사용합니다. project.xml이 있는 각 하위 디렉토리는 독립적인 모듈이며, 루트 project.xml이 이들을 통합합니다.

project.xml (루트 통합, packaging=pom) │ ├── compiler/ (컴파일러 바이너리, packaging=application) │ ├── project.xml │ └── src/ │ ├── main/pascal/ (uLexer, uParser, uAST, uCodeGenQBE, ...) │ └── test/pascal/ (컴파일러 유닛용 FPTest 테스트 스위트) │ ├── rtl/ (런타임 라이브러리, packaging=library) │ ├── project.xml │ └── src/ │ ├── main/pascal/ (System.pas, SysUtils.pas, Classes.pas, ...) │ └── test/pascal/ (RTL 유닛용 FPTest 테스트 스위트) │ ├── tools/ │ └── migration-analyser/ (FPC/Delphi 마이그레이션 보고서 도구, packaging=application) │ ├── project.xml (compiler 모듈에 종속) │ └── src/ │ └── main/pascal/

원문 보기
원문 보기 (영어)
Blaise Pascal Compiler The Pascal you love, reimagined for the modern era. Blaise is a next-generation Object Pascal compiler built from the ground up to eliminate decades of legacy baggage. It prioritizes developer productivity, memory safety, and high-performance execution. ✨ The Vision The Object Pascal ecosystem has two options: Embarcadero Delphi (proprietary, Windows-first) and Free Pascal (open source but carrying 30 years of accumulated complexity — five language modes, five string types, and thousands of include files). This compiler takes a different approach: One language mode. No {$mode} switches; no legacy dialect support. One string type. UTF-8 reference-counted string. RawBytes for binary data. One memory model. Automatic reference counting applies uniformly to strings, classes, and interfaces. No manual/auto split between TObject and TInterfacedObject ; [Weak] breaks cycles. Free is retained as a synonym for immediate release. Clean interfaces. No COM GUIDs; interface dispatch via compile-time vtable mapping. Reified generics. Monomorphization at compile time — no type erasure. Modern build system. PasBuild with project.xml ; no makefiles. First-class debugger. OPDF is the default debug format; DWARF is not required. See docs/design.adoc for the full architecture and implementation plan. The result — A modern, cross-platform Object Pascal compiler targeting native code via QBE (and eventually LLVM). Single language mode, single string type, zero-GUID interfaces, reified generics, and first-class OPDF debug format support. 🚀 Project Status Self-Hosting: Yes. Blaise currently bootstraps and recompiles itself with byte-for-byte exact matches. Testing: 1200+ tests and growing (Test-Driven Development from day one). Backends: Currently utilizing a QBE backend, with an LLVM backend in active development. Phase Goal Status 1 Bootstrap pipeline — Hello World on Linux x86_64 via PasBuild Complete ✅ 2 Type system — classes, records, ARC, exceptions Complete ✅ 3 Generics + zero-GUID interfaces Complete ✅ 4 OPDF debug info emission Complete ✅ 5 Self-hosting + LLVM + Windows + macOS ARM64 In-Progress 6 LSP + VS Code extension Planned 7 Migration analyser for FPC/Delphi codebases Planned What Is Dropped From Classic Pascal Feature Reason for removal ShortString , AnsiString , WideString , UnicodeString Replaced by a single UTF-8 reference-counted string type with statement Source of hard-to-diagnose symbol resolution bugs; breaks static analysis Old-style object types Use record (stack/value) or class (heap/reference) instead COM-style interface GUIDs Interface dispatch via compile-time vtable; GUIDs are unnecessary complexity Multiple language modes One dialect, maintained well, beats five dialects maintained poorly assign , reset , rewrite , blockread Replaced by a stream-based I/O RTL TObject vs TInterfacedObject split One unified class model under automatic reference counting; [Weak] breaks cycles 📢 Community The core architecture is still being finalised, so the project is not yet accepting code contributions. Feedback on language design, syntax choices, and the future direction of Blaise is very welcome — please use the Discussions tab on GitHub. Repository Layout This project uses PasBuild’s multi-module layout. Each subdirectory with a project.xml is an independent module; the root project.xml is the aggregator. project.xml Root aggregator (packaging=pom) │ ├── compiler/ The compiler binary (packaging=application) │ ├── project.xml │ └── src/ │ ├── main/pascal/ uLexer, uParser, uAST, uCodeGenQBE, ... │ └── test/pascal/ FPTest test suite for compiler units │ ├── rtl/ Runtime library (packaging=library) │ ├── project.xml │ └── src/ │ ├── main/pascal/ System.pas, SysUtils.pas, Classes.pas, ... │ └── test/pascal/ FPTest test suite for RTL units │ ├── tools/ │ └── migration-analyser/ FPC/Delphi migration report tool (packaging=application) │ ├── project.xml depends on compiler module │ └── src/ │ ├── main/pascal/ │ └── test/pascal/ │ ├── vendor/qbe/ Vendored QBE backend source (pinned, built from source) └── docs/ Design documents and specifications PasBuild compiles each module to its own target/ subdirectory. Build output is never committed to the repository. Building Prerequisites Free Pascal Compiler 3.2.2 or later (stable; 3.3.x development snapshots are not required) PasBuild A C compiler ( gcc or clang ) for building the vendored QBE backend GNU ld or lld (Linux); ld (macOS) Build all modules pasbuild compile PasBuild resolves the module dependency order automatically and compiles rtl → compiler → tools/migration-analyser . Build with a profile pasbuild compile -p debug # includes -g -gl -Criot -gh pasbuild compile -p release # includes -O2 -CX -XX -Xs Run tests pasbuild test Build a single module pasbuild compile -m blaise-compiler Running the compiler Once built, the compiler binary is at compiler/target/blaise . # Compile a single file compiler/target/blaise --source Hello.pas --output Hello # Compile via project.xml compiler/target/blaise --project project.xml --config debug --output myapp # Emit QBE IR (useful for debugging the compiler itself) compiler/target/blaise --source Hello.pas --emit-ir Licence Apache License v2.0 with Runtime Library Exception. See LICENSE . Built with ❤️ for the Pascal community by Graeme.