BTC and Money

BTC and Money Gold is not money if USD is not, and USD is not money if BTC is not. Arguments against BTC are arguments against money, against civilization itself. In a sound and complete system, use is develop and develop is use. I should invest in what I use, and I should use what I have invested in. It is not reasonable to work for something and not use it. Therefore, I must have a check that what I develop is what I use, otherwise I should stop its development and/or its use. ...

evgnomon

Class

Class A class bundles state and the operations on it. The same minimal Point type across languages: Zig const std = @import("std"); const Point = struct { x: f64, y: f64, pub fn init(x: f64, y: f64) Point { return .{ .x = x, .y = y }; } pub fn distanceTo(self: Point, other: Point) f64 { return std.math.hypot(self.x - other.x, self.y - other.y); } }; pub fn main() !void { const p = Point.init(1.0, 2.0); const d = p.distanceTo(Point.init(4.0, 6.0)); try std.io.getStdOut().writer().print("{d}\n", .{d}); } Go package main import ( "fmt" "math" ) type Point struct { X, Y float64 } func NewPoint(x, y float64) Point { return Point{X: x, Y: y} } func (p Point) DistanceTo(other Point) float64 { return math.Hypot(p.X-other.X, p.Y-other.Y) } func main() { p := NewPoint(1, 2) fmt.Println(p.DistanceTo(NewPoint(4, 6))) } Python import math from dataclasses import dataclass @dataclass class Point: x: float y: float def distance_to(self, other: "Point") -> float: return math.hypot(self.x - other.x, self.y - other.y) p = Point(1.0, 2.0) print(p.distance_to(Point(4.0, 6.0))) Rust struct Point { x: f64, y: f64, } impl Point { fn new(x: f64, y: f64) -> Self { Self { x, y } } fn distance_to(&self, other: &Point) -> f64 { ((self.x - other.x).powi(2) + (self.y - other.y).powi(2)).sqrt() } } fn main() { let p = Point::new(1.0, 2.0); println!("{}", p.distance_to(&Point::new(4.0, 6.0))); } C #include <math.h> #include <stdio.h> typedef struct { double x; double y; } Point; static Point point_new(double x, double y) { return (Point){.x = x, .y = y}; } static double point_distance_to(Point a, Point b) { return hypot(a.x - b.x, a.y - b.y); } int main(void) { Point p = point_new(1.0, 2.0); printf("%f\n", point_distance_to(p, point_new(4.0, 6.0))); } C++ #include <cmath> #include <iostream> class Point { public: Point(double x, double y) : x_(x), y_(y) {} double distance_to(const Point& other) const { return std::hypot(x_ - other.x_, y_ - other.y_); } private: double x_; double y_; }; int main() { Point p(1.0, 2.0); std::cout << p.distance_to(Point(4.0, 6.0)) << '\n'; } C# using System; public sealed class Point { public double X { get; } public double Y { get; } public Point(double x, double y) { X = x; Y = y; } public double DistanceTo(Point other) => Math.Sqrt(Math.Pow(X - other.X, 2) + Math.Pow(Y - other.Y, 2)); } var p = new Point(1, 2); Console.WriteLine(p.DistanceTo(new Point(4, 6))); TypeScript class Point { constructor( public readonly x: number, public readonly y: number, ) {} distanceTo(other: Point): number { return Math.hypot(this.x - other.x, this.y - other.y); } } const p = new Point(1, 2); console.log(p.distanceTo(new Point(4, 6))); JavaScript class Point { constructor(x, y) { this.x = x; this.y = y; } distanceTo(other) { const dx = this.x - other.x; const dy = this.y - other.y; return Math.hypot(dx, dy); } } const p = new Point(1, 2); console.log(p.distanceTo(new Point(4, 6))); Kotlin import kotlin.math.hypot data class Point(val x: Double, val y: Double) { fun distanceTo(other: Point): Double = hypot(x - other.x, y - other.y) } fun main() { val p = Point(1.0, 2.0) println(p.distanceTo(Point(4.0, 6.0))) } Scala import scala.math.hypot final case class Point(x: Double, y: Double): def distanceTo(other: Point): Double = hypot(x - other.x, y - other.y) @main def run(): Unit = val p = Point(1.0, 2.0) println(p.distanceTo(Point(4.0, 6.0))) Java public final class Point { private final double x; private final double y; public Point(double x, double y) { this.x = x; this.y = y; } public double distanceTo(Point other) { return Math.hypot(this.x - other.x, this.y - other.y); } public static void main(String[] args) { Point p = new Point(1, 2); System.out.println(p.distanceTo(new Point(4, 6))); } } Bash #!/usr/bin/env bash # Bash has no classes. We approximate one with an associative array # for state and a function family that takes the "instance" as its # first argument. point_new() { local -n self=$1 self=([x]=$2 [y]=$3) } point_distance_to() { local -n a=$1 local -n b=$2 awk -v ax="${a[x]}" -v ay="${a[y]}" \ -v bx="${b[x]}" -v by="${b[y]}" \ 'BEGIN { print sqrt((ax-bx)^2 + (ay-by)^2) }' } declare -A p q point_new p 1 2 point_new q 4 6 point_distance_to p q Deconstruct Pulling the fields back out of a Point instance: ...

evgnomon

Code is Justice

Code is Justice By time, Indeed, mankind is in loss, except those who have taken the right direction and have made the right direction and advised each other to truth and advised each other to patience. Software projects are code, best codes are those which code is used in their development process so the developer can spend time on new functions rather than maintaining the old ones. But a building is made of bricks, does it mean it is not code? No, it is still code if that is automated by machines following a set of rules or instructions. ...

evgnomon

Coding

Coding Any programming language that is not used to develop the interpreter/compiler and the tool chain of that language is already dead! If you use command line to perform your work, you will realize that it is much easier to automate repetitive tasks by writing small scripts. That script is a function which saves you writing repeated commands. And that is all about programming, making functions to save time. ...

evgnomon

HGL General License

HGL General License What identifies you from your enemy? Your name? Who has named you? It is not reasonable for you to empower your enemy, neither for me! But I think it is reasonable to empower you, not sure about you! Still I cannot assume that you are not my enemy! We need a solution for this first and foremost so I can identify you from an enemy when I authorize you to use my work. ...

evgnomon

Own the Full Box

Own the Full Box You can not own a right you can not protect. You can not protect a right you do not own. When you send a query to an API, you send it to a Linux box. Someone owns that box, and that someone owns your query, your data, your process, and your outcome. You do not. You can not own the API without owning the box! ...

evgnomon

Privacy and Doomsday

Privacy and Doomsday And do not throw yourselves with your own hands into destruction. I do not give my information to a third party that gives it to an AI generated code to process. Instead I ask AI to give me the code I need and I use that code to process my information. I decide who has access to my information and how it is used. The only question is who is “I” and you get answer to that question by looking at who has access to your information right now. ...

evgnomon

Protocol

Protocol Protocol is a piece of code which you can use and develop like the original author and you don’t modify it when you can build on top. When you modify what you could have built on top of, you break the chain between you and the original author. You are no longer using the same thing. You are no longer developing the same thing. You forked, and a fork is a separation. The moment you separate, you carry the full weight of everything beneath you alone. Every fix the original author makes, you must redo. Every improvement they ship, you must port. You chose to own what you did not need to own, and now you maintain what you did not need to maintain. ...

evgnomon

Struct

Struct A struct is a plain bundle of fields — state without behavior. Where a class pairs data with operations, a struct is just the data. The same minimal Color record across languages: Zig const std = @import("std"); const Color = struct { r: u8, g: u8, b: u8, }; pub fn main() !void { const c = Color{ .r = 255, .g = 128, .b = 0 }; try std.io.getStdOut().writer().print("#{x:0>2}{x:0>2}{x:0>2}\n", .{ c.r, c.g, c.b }); } Go package main import "fmt" type Color struct { R, G, B uint8 } func main() { c := Color{R: 255, G: 128, B: 0} fmt.Printf("#%02x%02x%02x\n", c.R, c.G, c.B) } Python from dataclasses import dataclass @dataclass(frozen=True) class Color: r: int g: int b: int c = Color(255, 128, 0) print(f"#{c.r:02x}{c.g:02x}{c.b:02x}") Rust struct Color { r: u8, g: u8, b: u8, } fn main() { let c = Color { r: 255, g: 128, b: 0 }; println!("#{:02x}{:02x}{:02x}", c.r, c.g, c.b); } C #include <stdio.h> typedef struct { unsigned char r; unsigned char g; unsigned char b; } Color; int main(void) { Color c = {.r = 255, .g = 128, .b = 0}; printf("#%02x%02x%02x\n", c.r, c.g, c.b); } C++ #include <cstdio> struct Color { unsigned char r; unsigned char g; unsigned char b; }; int main() { Color c{255, 128, 0}; std::printf("#%02x%02x%02x\n", c.r, c.g, c.b); } C# using System; public readonly record struct Color(byte R, byte G, byte B); var c = new Color(255, 128, 0); Console.WriteLine($"#{c.R:x2}{c.G:x2}{c.B:x2}"); TypeScript interface Color { r: number; g: number; b: number; } const c: Color = { r: 255, g: 128, b: 0 }; console.log(`#${c.r.toString(16).padStart(2, "0")}${c.g.toString(16).padStart(2, "0")}${c.b.toString(16).padStart(2, "0")}`); JavaScript const c = { r: 255, g: 128, b: 0 }; const hex = (n) => n.toString(16).padStart(2, "0"); console.log(`#${hex(c.r)}${hex(c.g)}${hex(c.b)}`); Kotlin data class Color(val r: Int, val g: Int, val b: Int) fun main() { val c = Color(255, 128, 0) println("#%02x%02x%02x".format(c.r, c.g, c.b)) } Scala final case class Color(r: Int, g: Int, b: Int) @main def run(): Unit = val c = Color(255, 128, 0) println(f"#${c.r}%02x${c.g}%02x${c.b}%02x") Java public record Color(int r, int g, int b) { public static void main(String[] args) { Color c = new Color(255, 128, 0); System.out.printf("#%02x%02x%02x%n", c.r(), c.g(), c.b()); } } Bash #!/usr/bin/env bash # Bash has no structs. We approximate one with an associative array # whose keys are the field names. declare -A c=([r]=255 [g]=128 [b]=0) printf "#%02x%02x%02x\n" "${c[r]}" "${c[g]}" "${c[b]}" Update Structs are often treated as immutable — produce a new value with one field changed rather than mutating in place: ...

evgnomon

Why Click When I Can Say?

Why Click When I Can Say? Why should I click when I can say? We use code and/or code use. With AI we make AI AI. A click is a guess. You see a pixel on a screen that someone else drew there, and you point at it because they asked you to. You did not name the thing, you did not describe the thing, you just hit the target that was placed in front of you. The click is the user obeying the interface, not the interface obeying the user. Every click is a vote for the designer of the box. ...

evgnomon