聚會時間公告: 因應COSCUP 2011, Kalug 8月份休會一次

十一月 8, 2012
» Go vs node.js vs PHP vs Python, Loop benchmark.

剛好跟lloyd大大聊到node.js V8的效能. 試寫了幾行發現速度還真是非常的快.

隨手用四種語言寫個forloop. 時間消耗依序是這樣的 Go < node.js < PHP < Python
其中 node.js 直譯器的需要編譯時間最長. 所以如果loop的max=100時.
其時間消耗變成這樣 Go < PHP < Python < node.js

這個實驗告訴我們 benchmark 是可以做到人人都滿意的。:P

package main
func main() {
    max := 1000000000
    var a,b,c int
    for i:=0;i<max;i++ {
        a = 1234 + 5678 + i
        b = 1234 * 5678 + i
        c = 1234 / 2 + i
    }
    _=a+b+c
}
var i, a, b, c, max;
max = 1000000000;
for (i = 0; i < max; i++) {
        a = 1234 + 5678 + i;
        b = 1234 * 5678 + i;
        c = 1234 / 2 + i;
}
<?
$max = 10000000;
for ($i = 0; $i < $max; $i++) {
    $a = 1234 + 5678 + $i;
    $b = 1234 * 5678 + $i;
    $c = 1234 / 2 + $i;
}
?>
max = 10000000;
for i in range(max):
    a = 1234 + 5678 + i
    b = 1234 * 5678 + i
    c = 1234 / 2 + i

仔細看code. Go & node.js 的for loop都比PHP & Python大了100倍.
因為nodejs的效能好到不能跟後兩者放在同一個量級比賽. 所以加了100倍之後拿來跟Go比.

在這邊Go很明顯多做一些事, 那是因為Go不能宣告了變數又不用.

time ./b;time node b.js;time php b.php; time python3 b.py
real  0m1.422s
user  0m1.417s
sys  0m0.004s

real  0m2.941s
user  0m2.967s
sys  0m0.018s

real  0m2.901s
user  0m2.875s
sys  0m0.025s

real  0m4.769s
user  0m4.746s
sys  0m0.022s

嘿嘿.

至於Go如果做假宣告的話那會是這樣.

package main
func main() {
    max := 1000000000
    for i:=0;i<max;i++ {
        _ = 1234 + 5678 + i
        _ = 1234 * 5678 + i
        _ = 1234 / 2 + i
    }
}

real  0m0.944s
user  0m0.938s
sys  0m0.005s

The post Go vs node.js vs PHP vs Python, Loop benchmark. appeared first on Kevinwatt's Blog.

九月 26, 2012
» Malware 惡意程式的軟體開發者開始使用 Go

Symantec最近回報了一些由Go撰寫的惡意程式(Malware),這個惡意程式在一個名為GalaxyNxRoot.exe 的 android rooting tool上被發現。在這個tool 中分別有兩個檔案由Go所撰寫 PPSAP.exe adbtool.exe。


GalaxyNxRoot.exe properties

Once executed, the GalaxyNxRoot.exe file drops and launches two executable files, both written in Go:

%Temp%PPSAP.exe
%Temp%adbtool.exe
The dropped PPSAP.exe file is an information-stealing Trojan. It collects system information such as current running processes, user name, MAC address, etc., and posts it to the following remote location:
[http://]golang.iwebs.ws/about/step1.php

The dropped adbtool.exe file downloads an encrypted file from the following remote location:
[http://]sourceslang.iwebs.ws/downs/zdx.tgz

This file is decrypted as a Dynamic-link library (DLL) file and then loaded. It attempts to encrypt various file formats on the compromised computer. The targeted file formats include:

Source code files (.c, .cpp, .cs, .php, .java, .pas, .vb, .frm, .bas, .go, .asp, .aspx, .jsp, .pl, .py, .rb)
Image files (.jpg, .png, .psd)
Audio files (.wav, .wma, .amr, .awb)
Archive files (.rar, .zip, .iso, .gz, .7z)
Document files (file extensions containing the following strings: doc, xls, ppt, mdb, pdf)
Other types of files (file extensions containing the following strings: dw, dx, sh, pic, 111, win, wvw, drw, grp, rpl, mce, mcg, pag)

全文:http://www.symantec.com/connect/blogs/malware-uses-google-go-language

三月 17, 2010
» new command: goinstall

golang
http://golang.org/cmd/goinstall/

各位太太小姐,您是否每次安裝library都要下10行command呢?還記不清是先pull還是先up?

upgrade 時老忘記這個library是在下git還是hg?還是前面兩種都試完才發現是svn?

體貼各位開發者的辛苦,美國加力佛尼亞的g公司最新科技登場…
每次裝library要手動一步一步來的時代已經過去了。

現在裝Go-MySQL-Client-Library就是這麼簡單
goinstall -dashboard=true github.com/thoj/Go-MySQL-Client-Library

程式中要使用它,直接import library在goroot/pkg/$arch/下的路徑即可。
import (mysql "github.com/thoj/Go-MySQL-Client-Library")

這個cmd是Russ Cox上個月底加的
主要是簡單安裝第三方library. 目前goinstall支援git, hg, svn 三種。

» Go Wiki!

http://code.google.com/p/go/wiki/WikiIndex
其實這一兩天已經從golang-dev嗅到一點wiki的味道了,go wiki正式上線。

不過要參與編輯的話必須要成為contributer,需照以下方法確保你的貢獻會採用Google版的BSD Style License。
Contributor License Agreement: http://golang.org/doc/contribute.html#copyright

我個人不是很喜歡這種作法。

三月 15, 2010
» 上課囉,Go語言在羅徹斯特理工學院(RIT)開課了。

http://www.cs.rit.edu/~ats/

null

Go, Concurrent and Systems Programming (in mycourses)
4003-561-70, 4005-714-70 MW 6:00-7:50 pm, 70-3560

這堂課從2010年春季開始講授。

相關資料跟note可以參考

http://www.cs.rit.edu/~ats/go-2009-3/index.xml

三月 11, 2010
» Go出書了?Go for Dummies

golang

還差的遠呢… Go每週Release一次,平均每兩到三個星期就會有一次語言上的修正。
這種書怎麼寫啊?

不過現在 Toni Mikael Korpela 整理了一份給笨蛋的Go入門資料(Go for Dummies)。
如果你還沒入門,可以參考看看。

http://docs.google.com/Doc?docid=0Abeqw3xBUqsUZGY2YnM5Z2tfN3NzNWJ0NGdk&hl=en

» Go in Google AI Challenge

Go在Google AI Challenge貪吃蛇大賽中表現亮眼。

http://csclub.uwaterloo.ca/contest/index.php



其中使用Go語言的shinobi贏得整個賽事第29名,排名他在之前的程式都是由 C++, Common Lisp, 和 C# 所撰寫的。

http://csclub.uwaterloo.ca/contest/language_profile.php?lang=Go

http://csclub.uwaterloo.ca/contest/rankings.php?page=1

RANK USERNAME COUNTRY ORGANIZATION LANGUAGE ELO SCORE
1 (29) shinobi Other Go 2570

» new package: websocket

http://golang.org/pkg/websocket/

websocket

websocket是html5中WebServer跟Browser交換資料的新方法。

http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-74

不仰賴 XMLHttpRequest or iframe s 這些傳統的作法,也不用開啟多個HTTP connections就可以進行資料交換。

是一個很有趣的東西。

十二月 11, 2009
» 一個關於Ken Thompson的小故事

Go 的建立者之一,也是UNIX的建立者 Kenneth Thompson Kenneth Thompson
他在1960年發明了 B 語言,然後和 C 語言的建立者之一 Dennis Ritchie 一起用 C 語言寫了 UNIX 作業系統。
Anyway,他一直有一個遺憾。

http://en.wikiquote.org/wiki/Kenneth_Thompson

Ken Thompson was once asked what he would do differently if he were redesigning the UNIX system. His reply: 『I’d spell creat with an e.』
Ken Thompson有一次被問到,如果你有機會重新設計UNIX系統,你最想改的是甚麼?他回答:我會讓creat這個拼寫加上e。

就是 UNIX 的系統呼叫建立檔案都是用 O_CREAT。
他一直想要把它改成 O_CREATE ,但是 O_CREAT 已經被 IEEE 已經加到 POSIX 裡作為規範了。

因為Go,他終於辦到了…

Ken Thompson的Log message


// Flags to Open wrapping those of the underlying system. Not all flags
// may be implemented on a given system.
const (
O_RDONLY = syscall.O_RDONLY; // open the file read-only.
O_WRONLY = syscall.O_WRONLY; // open the file write-only.
O_RDWR = syscall.O_RDWR; // open the file read-write.
O_APPEND = syscall.O_APPEND; // open the file append-only.
O_ASYNC = syscall.O_ASYNC; // generate a signal when I/O is available.
O_CREAT = syscall.O_CREAT; // create a new file if none exists.
O_EXCL = syscall.O_EXCL; // used with O_CREAT, file must not exist
O_NOCTTY = syscall.O_NOCTTY; // do not make file the controlling tty.
O_NONBLOCK = syscall.O_NONBLOCK; // open in non-blocking mode.
O_NDELAY = O_NONBLOCK; // synonym for O_NONBLOCK
O_SYNC = syscall.O_SYNC; // open for synchronous I/O.
O_TRUNC = syscall.O_TRUNC; // if possible, truncate file when opened.
O_CREATE = O_CREAT; // create a new file if none exists.
)

………………..花了40年啊~

聽完這個故事有沒有很感動? 要不要好好學 go?
http://golangd.com/

A Feedjack powered Planet
A Django site.