分析 GitHub 上的 Tab 與 Space

作者用 BigQuery 分析了 GitHub 上的 Tab 與 Space 的差異 (是個 flame war 開始的節奏 XDDD):「400,000 GitHub repositories, 1 billion files, 14 terabytes of code: Spaces or Tabs?」。

可以看到除了 C 與 Go 以外,大多數的程式語言都是 Space > Tab。另外在文章下面也有使用的 BigQuery 指令可以參考。

Golang 1.7

Golang 1.7 主打更小的 binary size:「Smaller Go 1.7 binaries」:

Typical programs, ranging from tiny toys to large production programs, are about 30% smaller when built with Go 1.7.

還附了一張經典的「Hello, world」程式的分析:

由於現代 CPU 的速度與 L1/L2/... cache 有緊密關係,當 binary size 變小時,常常會伴隨著 memory access 變快 (因為 hitrate 提昇),所以 binary size 也是效能指數蠻重要的一環。

在 C 裡 Concurrency 的 Library

看到「libdill: Structured Concurrency for C」這個東西,在 C 裡實作了兩個不同種類的 concurrency,一個是 proc (process-based) 一個是 go (corouting-based)。

支援的 function 算是蠻清晰的,範例也很清楚:

#include <libdill.h>
#include <stdio.h>
#include <stdlib.h>

coroutine int worker(const char *text) {
    while(1) {
        printf("%s\n", text);
        msleep(now() + random() % 500);
    }
    return 0;
}

int main() {
    go(worker("Hello!"));
    go(worker("World!"));
    msleep(now() + 5000);
    return 0;
}

也有 channel 的觀念可以用,之後需要寫玩具的話應該是個好東西...

用 JavaScript 寫的 NLP Library

nlp-compromise/nlp_compromise 是一個 JavaScript 寫的 NLP library,網頁上給的用法也很特別...

過去式:

nlp.text('She sells seashells').to_past()
// She sold seashells

複數形:

nlp.noun("dinosaur").pluralize();
// "dinosaurs"

還有這種用法:

nlp.statement('She sells seashells').negate().text()
// She doesn't sell seashells

也有這種用法:

nlp.sentence('I fed the dog').replace('the [Noun]', 'the cat').text()
// I fed the cat

抓人出來:

nlp.text("Tony Hawk did a kickflip").people();
// [ Person { text: 'Tony Hawk' ..} ]

不定冠詞:

nlp.noun("vacuum").article();
// "a"

還可以猜性別?

nlp.person("Tony Hawk").pronoun();
// "he"

str2num:

nlp.value("five hundred and sixty").number;
// 560

好像是好玩的東西... XD

Google 推出 iOS 上的搜尋輸入法 Gboard

Google 推出了 iOS 上的搜尋輸入法 Gboard:「Meet Gboard: Search, GIFs, emojis & more. Right from your keyboard.」,可以在 App Store 上下載「Gboard — Search. GIFs. Emojis & more. Right from your keyboard.」,目前只有英文版可以用,其他語言還要等:

Get it now in the App Store in English in the U.S., with more languages to come.

可以參考 Google 做的 GIF 動畫,把搜尋的功能結合進去了:

John Gruber 寫了一篇「Gboard」關於隱私問題的討論,看起來還頗正面的。除了搜尋結果當然會需要傳到 Google 的系統裡以外,只有 crash log 會匿名傳回去。

Mac 上的 Cleartext

看到 Mac 上的「Cleartext」這個軟體:

A text editor that only allows the 1,000 most common words in English

限制你使用比較簡單的英文,這樣可以讓讀的人比較容易了解 (尤其是非母語的人)。

有種跟 Simple English Wikipedia 的想法很像的感覺:

The project uses around 2,000 common English words, and is based on Basic English, an 850-word auxiliary international language created by Charles Kay Ogden in the 1920s.

另外還有提供 Trump mode XDDD:

Trained with a few of Trump's best known speeches, the app is now ready to help you write like a billionaire.

這好壞 XDDD

GitHub 上程式語言的趨勢

GitHub 給了從 2008 年到 2015 年現在,放在 GitHub 上專案所使用程式語言的排名:「Language Trends on GitHub」。

這同時包括了公開與私人 repository:

The rank represents languages used in public & private repositories, excluding forks, as detected by Linguist.

可以看到 Java 專案的排名逐步上升,應該是愈來愈多 Java 專案放到 GitHub 上 (應該是跟 Android 有關)。而 Perl 是掉出去很久了,PHP 則是萬年不動... XD

GitHut:GitHub 上程式語言的分析

Hacker News Daily 上看到的「GitHut - Programming Languages and GitHub」:

GitHut is an attempt to visualize and explore the complexity of the universe of programming languages used across the repositories hosted on GitHub.

主要是資訊呈現的方式很不錯,所以特別記錄下來...

C 對 Go Channel 的實做

在「Pure C implementation of Go channels.」這邊看到有人在 C 語言裡面實做 Go 的 Channel,包括了 Unbuffered 與 Buffered 版本。

看起來是支援 multithreading 的:「Add missing pthread_cond_destroy in chan init cleanup」、「Add -lpthread to CFLAGS」。

用 Spoofs Lang 更改網站偵測的預設語系...

因為 redports.org 一直連不上,寫信給網站管理者後才發現是 Trac 沒處理好 non-en 語系的部份,所以得先在 client workaround。(管理者說他有空的時候會去看看...)

Google Chrome 上可以用 Spoofs Lang 更改瀏覽器送出的 Accept-Language 欄位,進而達到修改網站偵測的預設語系...

除了 redports.org 以外,也順便把 php.net 系列的網站都改成英文語系了。