Copper – 一个支持面向对象和泛型的极简低级编程语言
Copper – A minimal low-level programming language with OOP and generics

原始链接: https://tibleiz.net/copper/

Copper 是一种极简编程语言,设计为 C 语言的替代品。其特性包括任意类型的类型继承、泛型、多返回值、无序定义、简单的无头文件导入系统、延迟语句、简单迭代器、Ruby 风格语法、选项类型和快速编译。极简主义是核心,使语言保持简单易懂。示例展示了一个带有属性、初始化、平移和打印的 `Point` 类。Copper 由 Marc Kerbiquet 以 BSD 许可证发布。

Hacker News 上关于 Copper 的讨论;Copper 是一个由单个开发者为个人使用(例如 Clade 编辑器)创建的、具有面向对象和泛型的最小化低级语言。评论者指出其语法类似 Ruby,但声明不一致(例如 `var a: Int32` 与 `a = Int32: 42`),参数按引用传递,内存模型不清晰(带 `free` 的分配器,没有明显 GC),以及缺少 Unicode 和 C ABI 等细节。讨论涉及自托管的优缺点(引用 Zig)、面向对象定义和文件扩展名(`.co` 与 `.cu`)。一些人称赞其简洁 tasteful;另一些人觉得它陌生。旁支话题争论在 LLM 的情况下人类是否还编程。总体来说,尽管存在未解问题,人们对这种小型个人语言仍感兴趣。
相关文章

原文
Copper
Copper

Copper is a programming language that I use as a replacement to C. The main differences are:

  • Type inheritance for any type
  • Genericity
  • Multiple return values
  • Out-of-order definitions
  • Simple import system, no headers
  • Not everything in the global namespace
  • Deferred statements
  • Simple iterators
  • Ruby-style syntax
  • Option types
  • Fast compilation
  • Minimalism

Minimalism is the most important feature, the language is intended to be simple so that someone with limited brain power such as me could fully understand it. The syntax is simple, almost everything is explicit and most constructs are common.

Example

A simple example beyond the pointless "hello world".

class Point
    attr x: Int
    attr y: Int

    def init(x: Int, y: Int)
        self.x = x
        self.y = y
    end

    def translate(dx: Int, dy: Int)
        self.x += dx
        self.y += dy
    end
end

func main: Int
    var pt: Point!
    pt.init(3, 5)
    pt.translate(1, 0)
    println("x = \a, y = \a", pt.x, pt.y)
    return 0
end

import "std"

More Information

License

Copper is released under the BSD license.

联系我们 contact @ memedata.com