11

系统编程语言 Hare lang

 2 years ago
source link: https://www.oschina.net/p/hare-lang
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Hare lang首页、文档和下载
授权协议 未知
操作系统 未知
软件类型 开源软件
所属分类 编程语言
开源组织 无
投 递 者 罗奇奇
适用人群 未知
收录时间 2022-04-25

Hare 是一门新的系统编程语言,它使用静态类型系统、手动内存管理和最小运行时,非常适合编写操作系统、系统工具、编译器以及其他低级高性能任务。

Hare 与 C 最相似,几乎所有用 C 语言编写的程序也可以用 Hare 编写,但 Hare 比 C 更简单。

Hare 的 Hello World 

use fmt;

export fn main() void = {
	const greetings = [
		"Hello, world!",
		"¡Hola Mundo!",
		"Γειά σου Κόσμε!",
		"Привет, мир!",
		"こんにちは世界!",
	];
	for (let i = 0z; i < len(greetings); i += 1) {
		fmt::println(greetings[i])!;
	};
};

 Hare 计算自己的 SHA-256 哈希:

use crypto::sha256;
use encoding::hex;
use fmt;
use hash;
use io;
use os;

export fn main() void = {
	const hash = sha256::sha256();
	const file = os::open("main.ha")!;
	defer io::close(file);
	io::copy(&hash, file)!;

	let sum: [sha256::SIZE]u8 = [0...];
	hash::sum(&hash, sum);
	hex::encode(os::stdout, sum)!;
	fmt::println()!;
};
展开阅读全文

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK