Keyboard shortcuts

Scrolling

dorCtrl+d
Scroll down
uorCtrl+u
Scroll up
Ctrl+e
One line down
Ctrl+y
One line up
gtheng
Top of article
G
Bottom of article

Articles

j
Older article
k
Newer article
O
Open original
H
Open hackernews
R
Open reddit

Lists

jor↓
Next item
kor↑
Previous item
gtheng
First item
G
Last item
oorEnter
Open selected item

Go to

gthenforgtheni
Feed
gthen1–9
Open feed entry
gthenb
Browse
gthenp
Preferences

Search and help

⌘+kCtrl+kor/
Global search
?
Show this help
Esc
Close this help

Copper – A minimal low-level programming language with OOP and generics

tibleiz.net via hnrss.org original

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

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.

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"

Copper is released under the BSD license.