谈谈多门程序语言的学习策略之一
<div id="cnblogs_post_body">body{ margin: 0 auto; font-family: georgia, palatino, serif; color: #444444; line-height: 1; max-width: 960px; padding: 5px;}h1, h2, h3, h4 { color: #111111; font-weight: 400;}h1, h2, h3, h4, h5, p { margin-bottom: 16px; padding: 0;}h1 { font-size: 28px;}h2 { font-size: 22px; margin: 20px 0 6px;}h3 { font-size: 21px;}h4 { font-size: 18px;}h5 { font-size: 16px;}a { color: #0099ff; margin: 0; padding: 0; vertical-align: baseline;}a:hover { text-decoration: none; color: #ff6600;}a:visited { color: purple;}ul, ol { padding: 0; margin: 0;}li { line-height: 24px; margin-left: 44px;}li ul, li ul { margin-left: 24px;}p, ul, ol { font-size: 14px; line-height: 20px; max-width: 540px;}pre { padding: 0px 24px; max-width: 800px; white-space: pre-wrap;}code { font-family: consolas, monaco, andale mono, monospace; line-height: 1.5; font-size: 13px;}aside { display: block; float: right; width: 390px;}blockquote { border-left:.5em solid #eee; padding: 0 2em; margin-left:0; max-width: 476px;}blockquotecite { font-size:14px; line-height:20px; color:#bfbfbf;}blockquote cite:before { content: '\2014 \00A0';}blockquote p { color: #666; max-width: 460px;}hr { width: 540px; text-align: left; margin: 0 auto 0 0; color: #999;}button,input,select,textarea {font-size: 100%;margin: 0;vertical-align: baseline;*vertical-align: middle;}button, input {line-height: normal;*overflow: visible;}button::-moz-focus-inner, input::-moz-focus-inner {border: 0;padding: 0;}button,input,input,input {cursor: pointer;-webkit-appearance: button;}input, input {cursor: pointer;}/* override default chrome & firefox settings */input:not(), textarea {-webkit-box-sizing: content-box;-moz-box-sizing: content-box;box-sizing: content-box;}input {-webkit-appearance: textfield;-webkit-box-sizing: content-box;-moz-box-sizing: content-box;box-sizing: content-box;}input::-webkit-search-decoration {-webkit-appearance: none;}label,input,select,textarea {font-family: "Helvetica Neue", helvetica, arial, sans-serif;font-size: 13px;font-weight: normal;line-height: normal;margin-bottom: 18px;}input, input {cursor: pointer;margin-bottom: 0;}input,input,textarea,select {display: inline-block;width: 210px;padding: 4px;font-size: 13px;font-weight: normal;line-height: 18px;height: 18px;color: #808080;border: 1px solid #ccc;-webkit-border-radius: 3px;-moz-border-radius: 3px;border-radius: 3px;}select, input {height: 27px;line-height: 27px;}textarea {height: auto;}/* grey out placeholders */:-moz-placeholder {color: #bfbfbf;}::-webkit-input-placeholder {color: #bfbfbf;}input,input,select,textarea {-webkit-transition: border linear 0.2s, box-shadow linear 0.2s;-moz-transition: border linear 0.2s, box-shadow linear 0.2s;transition: border linear 0.2s, box-shadow linear 0.2s;-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);-moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);}input:focus, input:focus, textarea:focus {outline: none;border-color: rgba(82, 168, 236, 0.8);-webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);-moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1), 0 0 8px rgba(82, 168, 236, 0.6);}/* buttons */button {display: inline-block;padding: 4px 14px;font-family: "Helvetica Neue", helvetica, arial, sans-serif;font-size: 13px;line-height: 18px;-webkit-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px;-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);background-color: #0064cd;background-repeat: repeat-x;background-image: -khtml-gradient(linear, left top, left bottom, from(#049cdb), to(#0064cd));background-image: -moz-linear-gradient(top, #049cdb, #0064cd);background-image: -ms-linear-gradient(top, #049cdb, #0064cd);background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #049cdb), color-stop(100%, #0064cd));background-image: -webkit-linear-gradient(top, #049cdb, #0064cd);background-image: -o-linear-gradient(top, #049cdb, #0064cd);background-image: linear-gradient(top, #049cdb, #0064cd);color: #fff;text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);border: 1px solid #004b9a;border-bottom-color: #003f81;-webkit-transition: 0.1s linear all;-moz-transition: 0.1s linear all;transition: 0.1s linear all;border-color: #0064cd #0064cd #003f81;border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);}button:hover {color: #fff;background-position: 0 -15px;text-decoration: none;}button:active {-webkit-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);-moz-box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);box-shadow: inset 0 3px 7px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);}button::-moz-focus-inner {padding: 0;border: 0;}/* CSS stylesheet is based on Kevin Burke's Markdown.css project (http://kevinburke.bitbucket.org/markdowncss) */谈谈多门程序语言的学习策略之一导言
作为一名程序首先要选好一门程序语言,这重要性好比找对一个老婆重要,可是,程序语言毕竟只是一门工具,不像老婆那样选了就很难换了(当然不合适离了不也一样..呵呵),有时候,在实际需求中我们需要,一定程度的&quot;外遇&quot;才能满足各种需求,但是,&quot;外遇&quot;不是每个屌丝都能碰到的好运,还好我们程序员要碰&quot;外遇&quot;太简单了,直接上官网,下文档,接下来,就是开个房间...苦读文档...补充一下寻找&quot;外遇&quot;之前先把&quot;老婆&quot;找到,不然就不叫外遇了...
当年的&quot;老婆&quot;现在的&quot;小三&quot;
如果,我们都把美女的渴望,放到对程序语言的学习上面的话,估计没啥是学不好的...
竟然,我们是有&quot;家室之人&quot;,不是当年一样啥都不懂的&quot;年轻少年&quot;.作为有着一定经验的男人而已,竟然,开房了我们就要一看到底...
&quot;老婆&quot; &quot;小三&quot; java lua 在经历一段比较漫长的事情后,我们终于有了一个&quot;老婆&quot;其中的艰辛,当然只有我们心里清楚,我们为了以后能更方便的找到&quot;外遇&quot;,作为一个立志于建立&quot;后宫&quot;的程序员,我们要好好思考,我们是怎么把&quot;老婆&quot;搞到手的.
作为一门程序语言,我是这么想的:
文件后缀 -> 关键字 -> 程序输入输出 -> 高级数据类型(即数据结构) -> api
说得挺抽象的,当年,我是这样追现在的&quot;老婆&quot;
程序文件后缀
[*]java的文件需要以.java文件保存,然后通过对.java文件进行编译,生成最终用来运行的.class文件 例如有如下一段代码
public class Hello{
public static void main(String[] args){ System.out.println(&quot;Hello world!&quot;); } } 将这段代码保存为
.java文件! 接着我们编译代码
javac Hello.java //编译代码
Java Hello //运行代码
从这里我们可以知道,一个程序代码一般而言是需要通过一次编译(手动(编译语言),或者自动(脚本语言))才能执行,简单来说就是需要一个&quot;玩意&quot;(编译器)把我们写的类似于自然语言的东西,通过这么一个&quot;玩意&quot;(编译器)编译成机器代码以后,我们写的程序才能真正运行起来!
接下来,我们面对&quot;小三&quot;的时候,还需要搞清楚这点吗?我们直接开敲就好!
print(&quot;Hello world !&quot;)
这样,我们就开始了我们的&quot;外遇&quot;之旅,额,应该是lua学习之旅,现在,我们还需要搞清楚lua的文件后缀是多少,怎么编译的吗?&quot;女人&quot;不都一样吗!
关键字
当年,我们追我们&quot;老婆&quot;的时候,需要知道&quot;老婆&quot;的脾气,爱好,等等东西,总结起来就是,找&quot;小三&quot;的时候,我们也需要这么做,例如,lua
and break do else elseif end false for function if in local nil not or repeat return then true until while
从这个lua小三爱好表里面看到,我们可以看出,有些&quot;爱好&quot;跟我们追&quot;老婆&quot;的时候不也一样,if,else..那么,我们只要针对一些我们&quot;老婆&quot;没有的爱好进行调查,例如
function,nil,local 等
当然有些&quot;爱好&quot;是相同的,例如,我的&quot;老婆&quot;喜欢善良的男人,&quot;小三&quot;也喜欢善良的男人,但是这个善良的男人该善良到何种程度才算得上是,&quot;老婆&quot;或者&quot;小三&quot;喜欢的类型,这个就需要我们自行琢磨了...就好比
java的else if跟lua elseif 是一样的吗(注意关键字!)?虽然,做的事情都是一样的.当然,这些不应该成为我们需要花时间的地方,我们应该把更多的时间放在&quot;小三&quot;跟老婆不一样的地方.
所以,最后,我们只要学习一下,一些新增的关键字就足矣!
程序输入输出
我们把以上几点搞清楚以后,我们就可以更&quot;小三&quot;进行一些papa(打键盘的声音)的事情了,我们一个程序的运行其实,干的就是这么一件事情
接收我们输入的参数 -> 处理我们的参数 -> 输出我们期望的参数
那么,根据,我们当年追&quot;老婆&quot;的时候,经过,一番通过的学习以后,我们可以搞清楚输入无非有如下情况
输入
1. 控制台输入
2. 文件输入
3. 变量输入
输出
1. 控制台输出
2. 文件输出
3. 变量输出
这个过程,应该在我们当年搞&quot;老婆&quot;的时候已经烂熟与心,现在搞&quot;小三&quot;的时候,只不过是变了一点而已,例如,以前&quot;老婆&quot;的是B杯,现在的&quot;小三&quot;变成了F杯而已... 例如当年我们控制台输出的时候是这样写的
Scanner s = new Scanner(System.in);
String s2 = s.next();
System.out.println(s2);
现在Lua变成了这样而已
a = io.read(&quot;*number&quot;)
print(a)
只是一些语法的改变的,&quot;胸&quot;(IO流)还是那样的&quot;胸&quot;(&quot;IO流&quot;)所以,男人们改变一下手法即可!当然,要摸熟则需要一定的时间
高级数据类型(即数据结构)
对于,基本数据类型,其实,是门程序一样都不会有太大的改变,不过,对于高级数据类型就可能有些变化,例如,java的数组,就肯定没有php的数组强大,例如,java有专门的泛型,php则是万物皆是泛型就好比一些女人是M属性一些女人是S属性,一些女人则是SM属性...还是拿java说事,在C语言的年代,我们需要深刻理解什么是list,stack,map才能写出相应的代码不过在java 已经打包好实现,我们自己使用就好!
无论语言如何变化,对于我们知道list,stack,map 是怎么一回事有影响吗?我们知道list,stack,map该怎么用就好,语言本身实现了,我们直接就调用,没有的google一下找实现,还没有的自己写一套..不过,一般google一下都有实现了吧...还没有的话,莫非是你自己自创的语言?
List arraryList = new ArrayList();
arrayList.add(&quot;oh yeah&quot;); 剩下的自己领会吧...
一切的基础API
到最后,最激动人心的一部分了!当我们,基本把一个&quot;小三&quot;搞到手以后,就是开始细致了解她的时候了,至于怎么了解,当然就是在日常生活中慢慢深入,对于一门程序语言而已,API是必须学习的一部分,基本上,要算的上熟悉一门语言,API是必须烂熟于心,这样才不会把时间浪费在一些重复制作轮子上,也可以在这个基础上,把轮子做得更好!例如,学习C语言的,你没把C99标准库里面所有库函数搞明白,都不好意思说自己是学C语言的(印象中C99标准库没几个函数,当然这个是跟java的api比较)
API这种东西,我们不需要专门去学习!只不过是当我们遇到某件事的时候,第一时间是找API文档,而不是GOOGLE一下!这样,一门语言在不断使用过程中就掌握了,至于以后可能很长一段时间不用,也可以从API文档中迅速回到状态,因为API是一门语言的基本所在,掌握了API基本一门语言也就掌握了.
当然,你对API不屑一顾的话,那就证明你已经达到了一种更高的层次,看破红尘,世事如烟...
貌似都说完了,还会有之二吗?
页:
[1]