iovxw

Ark —— Go 和 Rust 的结合体

只是没人用

编译器是用go和Rust写的,github在这里:https://github.com/ark-lang/ark

官网:http://ark-lang.org/

说是系统级编程语言,可以和C无缝交互

至于为什么说是go和rust的结合体

看下面的例子就知道了(https://github.com/ark-lang/ark-docs/blob/master/IDEAS.md

struct Bar {
    name: str;
}

struct Baz {
    name: str;
}

trait Foo {
    func fooBar();
}

impl Foo for Bar {
    func fooBar() {
        println("foobar method in foo for bar %s!", name);
    }
}

impl Foo for Baz {
    func fooBar() {
        println("foobar method in foo for baz %s!", name);
    }
}


// attributes look cool
// basically generics, we need to use
// them in this case instead of saying `value: Foo` as
// a param, because a trait does not have a constant
// size that is known at compile time, so the generic
// will basically compile down to [in this case] two
// functions one for Bar, and one for Baz, then it
// will know the size of the given value.
// this might be weird to understand but its 1am and im
// ill and tired. jah bless xx
func [T: Foo] callFooBar(value: T) {

}

func main() {
    // monomorphisation????
    baz: Baz = {
        name: "baz",
    };

    bar: Bar = {
        name: "bar",
    }

    callFooBar(baz);
    callFooBar(bar);
}

Chez Scheme 中的 machine-type

魔法的缩写

Chez Scheme 中可以用 (machine-type) 获取当前的运行环境

比如 64 位 Linux 获取到的是 a6le, 而如果启用了线程则是 ta6le

第一次看完全是一头雾水, 这到底是什么玩意?

其实只要注意看一下 Makefile, 就能明白了

Chez Scheme 性能测试

不用自己跑,省了很多事

#chez 频道里, @ecraven 使用 Chez Scheme 跑了下 Larceny 项目的 R6RS Scheme 基准测试 (感谢 ecraven)

测试环境是 Intel i7-4770 @ 3.4GHz, 结果如下:

http://www.nexoid.at/tmp/scheme-benchmark.html

为了省事在这里也放一份, 不过不保证更新, 最新结果请去上面的链接查看

total-accumulated-runtime

chez-9.4 (94.)larceny (235.)petite-9.4 (749.)racket (750.)petite-8.4 (889.)vicare (893.)ypsilon (1537.)

times-faster-than-any-other

petite-8.4 (2)larceny (3)racket (3)vicare (3)petite-9.4 (4)ypsilon (11)chez-9.4 (42)

打包发布 Chez Scheme 程序

简单暴力

上一篇文章 里说过如何将 Chez Scheme 程序编译为单文件, 不过仍然需要 Chez Scheme 或者是 Petite Chez Scheme 才能运行

但是总不能要求用户都安装 Chez Scheme, 因为这货在各大发行版官方仓库里都没有 (AUR 不是官方仓库), 只能自己编译, 更别说 Windows 了 (好好好, 我知道 Windows 10 发布了一个很重要的特性, 但那现在还是预览版)

解决方法很简单也很暴力, 发布的时候把 Chez Scheme 打包进去

将 Chez Scheme 程序编译为单文件

但是仍然依赖解释器

通过使用 make-boot-file 可以将 Chez Scheme 程序编译为单文件

文档如下:

procedure: (make-boot-file output-filename base-boot-list input-filename ...)
returns: unspecified
libraries: (chezscheme)

output-filename, input-filename, and the elements of base-boot-list must be strings.

make-boot-file writes a boot header to the file named by output-filename, followed by the object code for each input-filename in turn. If an input file is not already compiled, make-boot-file compiles the file as it proceeds.

The boot header identifies the elements of base-boot-list as alternative boot files upon which the new boot file depends. If the list of strings naming base boot files is empty, the first named input file should be a base boot file, i.e., petite.boot or some boot file derived from petite.boot.

Boot files are loaded explicitly via the --boot or -b command-line options or implicitly based on the name of the executable (Section 2.9).

See Section 2.8 for more information on boot files and the use of make-boot-file.

Chez Scheme Version 9 User’s Guide

LaTeX 依赖好麻烦

闲得没事自己编译了下,有一块竟然还要手动写日期,一堆依赖真是麻烦

Github: https://github.com/iovxw/csug9

PDF: https://iovxw.net/csug9/csug.pdf

HTML: https://iovxw.net/csug9/csug.html

Clojure Thread/sleep 在 core.async 里的坑

文档为何没标注

给 Telegram 写的一个 RSS Bot 总是随机出现大量重复推送更新的 BUG,还以为是数据库或者 RSS 对比的问题,然而逻辑上根本没问题

百思不得其解

直到发现了自己在 loop 用的是 Thread/sleep 来进行定时的,它是 Thread 啊!

「速报」世界上最好的 Scheme 编译器开源了

还没试

当然最好的不是我说的,是王垠说的 (冤有头债有主,别打我)

十二天前,Cisco 的 github 上新建了一个 repo,就是大名鼎鼎的 (被王垠吹上天的) ChezScheme

不过只有一个 README 和 LICENSE

而就在十分钟之前,终于推了源码上去了

HTML5 离线缓存两个需要注意的地方

笔记

这两天用 ClojureScript 弄了个 Todo List

在线版本: https://iovxw.net/text-todo-list/

为了能离线使用, 试着用了下 HTML5 加的 Application Cache, 效果当然是不错的

不过中间看文档不仔细导致白折腾了半天

不要去评价一门你没真正用过的编程语言

人类是无法互相理解的

只要是个程序员,肯定就陷入过这个话题中

究竟哪个语言更好?

一般这种话题开始后,只有三种结果