Solod:Go 语言可以成为更好的 C 语言
Solod: Go can be a better C

原始链接: https://solod.dev

Solod (So) 是 Go 语言的一个子集,旨在直接编译为可读的、零运行时的 C11 代码。它为 Go 开发者提供了一个系统级的编程环境,且无需垃圾回收、引用计数或隐藏的内存分配。 主要特性包括: * **原生 C 互操作性:** 无需 CGO 即可与 C 代码无缝集成。 * **Go 工具链:** 支持标准的 Go 开发工作流,包括 LSP、代码检查(linting)和 `go test`。 * **内存控制:** 默认使用栈分配,并可通过标准库进行可选的堆管理。 * **熟悉感:** 提供已移植的 Go 标准库函数,并支持结构体、方法、接口、切片和 `defer` 等核心 Go 特性。 目前该项目处于活跃开发阶段(v0.2 版本,v0.3 即将发布)。对于追求 Go 语言简洁结构与安全性,同时又需要 C 语言性能与可预测性的程序员来说,So 是理想的选择。虽然尚未达到生产就绪状态,但对于热衷于底层控制并希望使用熟悉语法的开发者和爱好者而言,它是一个优秀的工具。用户可以通过在线演练场、详尽的指南以及 GitHub 上的源代码来探索该项目。

Hacker News 最新 | 往期 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Solod:Go 语言可以成为更好的 C 语言 (solod.dev) 11 个积分,作者 koeng,1 小时前 | 隐藏 | 往期 | 收藏 | 2 条评论 bb88 12 分钟前 | 下一条 [-] 如果一切都基于栈,它是如何处理指针的?你无法真正返回一个指向栈上某处的指针,因为它在你返回它和访问它之间可能会被覆盖。回复 leecommamichael 30 分钟前 | 上一条 [-] 我真的很喜欢这个想法。我之前读过一篇关于 Go 泛型如何实现的文章,以及它们是如何在“运行时”中利用根 GC 类型来避免像 C++ 中单态化(monomorphization)所导致的膨胀。我想知道 Solod 将如何处理这个问题?我猜是简单的单态化?鉴于 C 编译器速度很快,这应该没问题。回复 考虑申请 YC 2026 年秋季批次!申请截止日期为 7 月 27 日。 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系方式 搜索:
相关文章

原文
Solod

Solod (So) is a strict subset of Go that translates to regular C.

Highlights

  • Go in, C out. You write regular Go code and get readable C11 as output.
  • Zero runtime. No garbage collection, no reference counting, no hidden allocations.
  • Rich standard library. Use familiar types and functions ported from Go's stdlib.
  • Native C interop. Call C from So and So from C — no CGO, no overhead.
  • Go tooling works out of the box. Syntax highlighting, LSP, linting and "go test".

So supports structs, methods, interfaces, slices, maps, multiple returns, and defer. Everything is stack-allocated by default; heap is opt-in through the standard library. There is limited support for generics, and concurrency is provided by the standard library instead of being built into the language.

So is for Go developers who want systems-level control without learning a new language. And for C programmers who like Go's safety, structure, and tooling.

Playground

Here's some Go code in a file main.go. Click Run to execute it, or Translate to see the generated C code (main.h + main.c).

package main

import "solod.dev/so/time"

type Person struct {
    Name string
    Age  int
    Nums [3]int
}

func (p *Person) Sleep() int {
    p.Age += 1
    return p.Age
}

func main() {
    p := Person{Name: "Alice", Age: 30}
    p.Sleep()
    println(p.Name, "is now", p.Age, "years old.")

    p.Nums[0] = 42
    println("1st lucky number is", p.Nums[0])

    year := time.Now().Year()
    println("The year is", year)
}

Getting started

Even though So isn't ready for production yet, I encourage you to try it out on a hobby project or just keep an eye on it if you like the concept.

Installation and usage to work with So locally.

Language and standard library guides for a quick overview.

So by example for a hands-on introduction.

Source code to see the internals or contribute.

Current status  v0.3 in progress

As of July 2026, So is in active development. The latest release is 0.2, which adds support for networking, WebAssembly, and freestanding mode. The next release, 0.3, will add concurrency support.

If you have any questions, feel free to reach out on GitHub.

🧑‍💻 Anton Zhiyanov

联系我们 contact @ memedata.com