昨天晚上写代码到深夜,一头扎到床上,沉沉睡去。
第二天睁开眼镜,我发现自己居然坐在一个咖啡馆里,旁边的墙上贴着最新的英文电影海报《阿甘正传》、《肖申克的救赎》
这都是1994年的经典电影,我意识到,自己穿越到了1994年的美国!
对面坐着一个帅哥,一边操作电脑,一边在不停地赞叹。
我探过头去,发现他正在看这个东西:
我说:“哥们儿,这不是安德森开发的Mosaic浏览器吗?这么丑,你怎么不用网景?”
“网景?那是什么东西?不过兄弟不简单啊,我在咖啡馆喝了这么多天的咖啡,你是第一个识货的,还知道安德森,肯定也是个程序员吧,要不一起干吧!”
“干什么啊?”
“浏览器绝对是互联网的未来,现在很多公司都在狂热地拥抱它, 他们就使用 Microsoft Word写文档,然后将文档保存为 HTML,通过 FTP 将它们放到网上,这里边有商业机会啊。”
“写个HTML会有什么商业机会?”
“静态的网站是和枯燥的,这些公司很快就会发现,可以和用户交互的、动态的网站才有商业价值。我准备专门提供这样的咨询服务,为他们开发各种动态的Web应用程序。对了,忘了自我介绍了,我叫Rasmus Lerdorf。”
这个人名怎么这么熟悉?
我想既然穿越而来,那就看看1994年的动态网站是怎么开发的吧。
我说:“我叫张大胖,主要用Java编程。”
“Java?那是什么语言?” 他两眼立刻放光了!
我意识到说漏嘴了,Java这时候还没诞生呢!
“其实叫C++--,一个小众语言。”
“和C语言相关,那就好,我们得用C语言写CGI脚本。”
我和他合伙开了个咨询公司,专门接开发动态网站的活儿。
但是开发一开始,我就崩溃了:没有前后端分离,没有Java,没有JSP,ASP, 真的全靠在C语言!
给大家看看:
void main(int argc, char *argv[]) { char *params, *data, *dest, *s, *tmp; char *name, *age; puts("Content-type: text/html\r\n"); puts("<HTML><HEAD><TITLE>Form Example</TITLE></HEAD>"); puts("<BODY><H1>My Example Form</H1>"); puts("<FORM action=\"form.cgi\" method=\"GET\">"); puts("Name: <INPUT type=\"text\" name=\"name\">"); puts("Age: <INPUT type=\"text\" name=\"age\">"); puts("<BR><INPUT type=\"submit\">"); puts("</FORM>"); data = getenv("QUERY_STRING"); if(data && *data) { params = data; dest = data; while(*data) { if(*data=='+') *dest=' '; else if(*data == '%' && ishex(*(data+1))&&ishex(*(data+2))) { *dest = (char) htoi(data + 1); data+=2; } else *dest = *data; data++; dest++; } *dest = '\0'; s = strtok(params,"&"); do { tmp = strchr(s,'='); if(tmp) { *tmp = '\0'; if(!strcmp(s,"name")) name = tmp+1; else if(!strcmp(s,"age")) age = tmp+1; } } while(s=strtok(NULL,"&")); printf("Hi %s, you are %s years old\n",name,age); } puts("</BODY></HTML>"); }
用一句话来说那就是:在C语言当中输出HTML代码。
这是人干的活吗?我都快写吐了!
Rasmus:“没办法啊,C语言编写CGI脚本,实现动态网页,可不就得这样嘛?对了,你会用Perl吗?”
“就是那个写出来以后代码谁都不认识的语言?我不想用!”
时间长了,Rasmus 也受不了了:“这些CGI 脚本无外乎就是处理表单, Post数据,过滤等,重复代码太多了,怎么样才能提高效率呢?”
他有空就琢磨这件事情,有一天,他想到了一招,把这些常用的功能都包装到一个C语言库中,它“植入”NCSA Web 服务器中(这是Apache之前最流行的服务器),然后在上面添加了一个模板系统,可以轻松地调用他们。
于是代码就是变成这个样子:
<html><head><title>Form Example</title></head> <body><h1>My Example Form</h1> <form action="form.phtml" method="POST"> Name: <input type="text" name="name"> Age: <input type="text" name="age"> <br><input type="submit"> </form> <?if($name):?> Hi <?echo $name?>, you are <?echo $age?> years old <?endif?> </body></html>
换句话说:就是在HTML中“混入”代码。
和CGI对比,这种方式对程序员来说非常友好,我们的工作效率一下子提高了很多。
说实话,我早就知道这种方式,就是ASP,JSP嘛,但是自己没那技术实力,实现不了啊!
Rasmus 很快就找到了一个新客户,用新工具为他们开发Web程序,连接到数据库,满足他们各种各样的需求。
随着客户的增多, 客户的需求也略有不同,于是,Rasmus 就不断地扩展它的工具箱, 从简单的解析器慢慢发展为包含条件标签,然后是循环标签、函数等各种复杂的东西,这已经是一门语言了。
Rasmus 把它们称为Personal Home Page,简称PHP
。
我这才意识到,原来遇到了<strong>PHP之父</strong>
!
很快就有其他程序员找上门来, 问我们:Rasmus, 你们怎么开发得这么快!
Rasmus说:我有个人工具箱啊!
“那我能不能用?”
Rasmus说:“可以啊,工具只是我的锤子,每个人都可以用我的锤子。”
我赶忙阻止他:“Rasmus, 你把锤子给别人, 那咱们靠什么赚钱?”
“我不靠锤子赚钱,我卖的是解决问题的服务。”
我心想他真是傻瓜,为什么不靠卖他的工具来赚钱呢?学学Bill Gates,过几年上市!
让我没想到的是,神奇的事情发生了。
People who use PHP started sending patches to Rasmus - they found bugs that Rasmus didn't even find!
So Rasmus went to the customer and said: I upgraded to a new version, changed this, changed that.
Customers are very satisfied. They think our work efficiency is very high, not only can we complete functions quickly, but we can also quickly fix bugs.
I suddenly realized: Isn’t this open source?
Of course, this was 1994 or 1995, and the term open source had not yet appeared. At that time, there was only free software advocated by RMS.
As more and more people submitted patches, PHP gradually improved. In 1995, Rasmus saw that the time was ripe and officially announced the birth of PHP 1.0.
So this is how PHP started!
Rasmus showed the generosity and style of a leader when he gave up exclusive control of PHP.
By giving ownership of the project to others so that everyone can contribute, PHP becomes everyone's project, not Rasmus's alone.
At that time, the PHP source code was placed in CVS. I wanted Rasmus to put the PHP source code on GitHub. But at that time, there was not even Git. Where did the Hub come from?
There is no management here. Everyone is a small self-organized group. They can self-organize around what they are interested in.
Appoint people on their merits and let the code speak for itself.
This really changes the nature of PHP.
One weekend, Rasmus and I came to the cafe for coffee again, and I said: "I think you need to add some advanced features to PHP!"
"For example, generics, annotations , Function-oriented programming, Lambda and the like."
"No, no, I hopeto control the threshold for entering PHP at a very low level, whether using it or contributing to it. Anyone who wants to solve a web problem will usually find a very straightforward solution through PHP. Many of the alternatives that claim to solve web problems are too complex. Think about it. You have until Friday to get the job done, but you have to flip through 800 pages of it. Manual, this is frustrating."
"Have you ever thought that PHP will dominate the Web in the future?"
"Haha, is this possible?"
Little did Rasmus know at the time that PHP would grow wildly in the Internet tide, marrying Linux, MySQL, and Apache, and constantly conquering cities and territories.
W3Tech statistics show that PHP dominates the Web, with nearly 80% of websites using PHP!
"If you were asked to summarize how to create a successful open source project, what would you say?"
When talking about this topic, Rasmus suddenly He started talking non-stop, because he developed a project from 0 to 1, so he had so much say!
“ If you only have one cool idea, no one will join your project, everyone has cool ideas.
If you Create something that's half-baked, and people will probably turn their noses up at what you're doing, and they'll go their own way to solve the problem.
Only if you build something useful enough, People will come to you, they'll be more receptive to your code, and then extend it a little to solve their own problems, and then the snowball will start rolling.
So, be To start an open source project, you have to solve a problem that has been bothering you for a while. It may take months to find the real problem and solve it. Then you have to accept the advice of early adopters and do your best to make the tool more useful for the future. A broad audience helps.
Finally consider giving up control and letting others work with you. When people do whatever they want with your code, your The open source project was successful!”
“That’s great, I hope all my readers can see this paragraph.”
“Your readers?”
"Yes, the coder turned over the headlines, I can't say too much, the secret must not be leaked, I have to leave."
After saying that, I disappeared.