前两天好象听说。textmate 开源了?不知道是否听错,但传闻是在st(sublime Text2)的压力下开源的。。。(没有亲见,只是听闻而已)
结果又在cnbeta上看到标题所在的新闻了。。。
cnbeta上这么写着:
感谢中国 Linux 公社的投递
最近,一位 ID 为 ieure 的用户在文本编辑器 TextMate 的 GitHub 上提交了一个 patch,号称“修复了许多 bug”。在描述中,他说自己尝试使用 TextMate2,但是遇到了很多不可接受的错误。于是他制作了这个可以解决一切问题的 patch。
但这个 patch 的改动量实在是太大了,大到令人怀疑:算下来这个 patch 一共执行了几百万次代码改动。果然,这是一个来自高端黑 Emaser 的作品:这个 patch 会把 TextMate 删除干净之后安装上 Emacs.
于是这 patch 自然又是引起了一次已经让大家习以为常的“圣战”,Vim 用户也积极插上来一脚责问作者为什么不把它换成 Vim。但亮点根本不在于这场圣战本身,而是在于围观群众。
大量的中文用户观光团(包括但不限于豆瓣、煎蛋)跑到了这页面下面围观并留下脚印。现在,这个页面上绝大多数的留言都是中文的,内容也大多都是“XX观光团”。这还真是一则相当不错的黑色幽默呢。
截至发稿时,这个页面已经基本被中文回复占领,用户大多是来自豆瓣/人人/新浪微博/煎蛋的围观群众。
围观地址:GitHub
---EOF--
果然看到了很多类似“<豆瓣观光团> ”这样的内容。。。。中国人真多,这是我的感慨 .其他没了。
其实看到现在,很多人都在推荐go语言,理由有很多种,但对于PHPer来说,不一定就是适合的。go是google推出的语言,到现在为止也已经有很长时间了,再加上go又能底层,又能WEB,所以。。。
但是,究竟应该不应该学,还是会有点想法,所以看到这篇全英文的介绍的时候就蛋定不了了。
原文是来自于:Why you PHP guys should learn Golang
Go or Golang, is a open source, community supported, fast, consistent, scalable, productive language, and conceived by Google. More and more applications were build with it. Although Rob Pike has said that “… we expected C++ programmers to see Go as an alternative …”, but I really think of that: You PHP guys should learn Golang! Let’s talk about WHY.
Easy to learn
PHP is easy to learn. Golang is as easy as PHP!
The syntax of PHP is similar to C family’s programming languages(C/C++/Java etc.). If you have some experiences with those languages, it is not too hard to write some codes when you first met PHP.
Golang is also a C family’s programming language. Eh… with a litte syntax difference. For example, the keyword “for” is similar with PHP’s, but without the pair of parentheses. And the condition keyword “if” is without the pair of parentheses either. You can read Effective Go for more things.
Golang has only 30 keywords and 47 operators, delimiters or other special tokens. There is no need to work hard for remembering all the literals. The type system is exquisite and easy to use. No huge OO but a practical struct type with methods on it. The interface design is one of my favorate parts of Golang. When you have finished this A Tour of Go, based on your PHP experiences, some jobs could be done with Golang immediately.
Easy to Use
Your PHP scripts will be evaluated by SAPI components: web server module, PHP-fpm or CLI. All needed for PHP deploying is a SAPI environment. Deployment of the environment is the most difficult part to understand for a PHP beginner.
All the Golang’s codes will be compiled and linked into native code. So there is no need to deploy a environment for it executing but a build environment. Compaire with deployment of the PHP environment, it is not so much complex. Do you really think of the deployment of the PHP environment is really complex? I don’t think so. Really!
To deploy the build environment, just need 3 steps:
- Download Golang‘s source code.
- Setup the environment variables. Here’s a great blog post: Go environment setup
- Run the ‘all.bash’ in the ‘src’ directory.
Or only one step: Use the binary package to setup.
Then a toolset called “go” can be used. Using the go tool is as easy as using PHP’s CLI tool. “The Go Tool” has already explained it.
A myth of PHP
If a programming language is easy to learn and use, shall we learn and use it? Lots of programming languages are easy to learning and use. Shall we learn and use all of them? The answer is straightforward: NO!
But why you PHP guys should learn Golang? Just because it is cool! Ja, I’m kidding, but it is true. Anyway, let’s talk about PHP itself first.
PHP is “a general-purpose server-side scripting language originally designed for Web development to produce dynamic Web pages.(Wikipedia)”. The most important feature of PHP is embedding with HTML. PHP code write in “<?php … ?>” tag; HTML write outside. It also has a powerful extension system. The extension can be writen by C with Zend API. Data processing was actually done by those extensions. IMO, PHP must be the best template programming language.
But if you have years experiences with PHP and began face to some complex web application. You must have already felt some powerlessness to PHP. It dosen’t have concurrent mechanism build-in, no threads, multiprocessing or X-routines. A slow data source will be blocked entire page’s processing. A powerful web server in the front of PHP is always needed. Backend programes were writen to process data. Message Queue, Cache, Proxy … The system is not only about PHP, but also about a lot of services and system components. This time, PHP is really be a template language with few logical jobs.
PHPers are always looking for solutions, like “PHP multithread” or a concurrent RPC framework for PHP. I could not say witch one is better. But I’m sure that you must choose an other programming language for the backend job. In my own case, I tried C(struggle with malloc/free)/Java(stumble in the jar hell)/Python(never be pythonic but type lost)..If I get profermance, I must struggle with the memory management; If I use GC, I must deploy and turning VM; If I get convenient, careless would kill me….Eche has advantages, each also has a problem.
OK! Let’s back to Golang now!
Golang has GC, there is no need to care about memory management(or could pay less attention to it). And the code are compiled into native machine code. So, “cp” and “mv” are all needed for deploying the application writen by Golang. Oh, as I just said, Golang is a compiled language with a static type system. You have no chance to confuse veriable types. Of course, one of the most important thing is PHPer who moves to Golang “don’t have to surrender much expressiveness, but gain performance and get to play with concurrency(by Rob Pike)”. “Why Not Go?” talked about this deeply.
I would show parts of my own experience: a Gearman worker works for us to process backend data. PHP connected to the worker though Gearman Job Server with its Gearman API. The original worker was writen by python. There are lots of problems with that version(They are our own problems, but python’s). But it works for us. Then we rewrite the worker with Golang. It was amazing. I wrote a Gearman API for Golang, and a Golang package using Zend API(cgo is another amazing thing) for evaluating the PHP script in Golang. Then combined them together – A Gearman worker witch can execute PHP scripts. It works about 3 mounth in our production enverionment and looks great! Oh, I also wrote a RPC-combinator for combining the RPC call in PHP script. It will be used in our next product.
Everything goes right. Thanks Golang!
In any case, most of PHPers alwasy need to learn other languages for the backend development. If you have began looking for, or already tasted some of other languages. Why don’t you try Golang? It would make your life happy and easy. You could spend more time with your family and friends, eat your favorite foods and visit the places you love.
That’s why you PHP guys should learn Golang! Is it enough? I think so!
This is my writing exercise. If you find any grammatical or spelling error, plz tell me!
---EOF---
其实我也挺纠结的,要知道当时我刚跟着tour做了30多篇的时候,突然golang的网页就再也打不开了。再苦了,墙就是我们学习的最大障碍。想想这些年我们遇到了什么。。
sf.net被墙
groups.google.com被墙
python.org被墙
很多。。。。。这些都是我们的障碍啊
这是微博上的一小段内容:
【程序猿被提bug之后的反应】1.怎么可能;2.在我这是好的,不信你来看看;3.真是奇怪,刚刚还好好的;4.肯定是数据问题;5.你清下缓 存试试;6.重启下电脑试试;7.你装的什么版本的类库(jdk)8.这谁写的代码;9.尼玛怎么还在用360安全浏览器;10.用户不会像你这么操作 的。
原微博在这里:http://weibo.com/1577794853/ywgaHrmRE
哈哈。有好多次都是以5来处理。但现在没有很好的缓存清理工具。一般不会说10.。。说10的话太恶心了