Reading Notes-"The Marrow of Code"

2016/2/20
How to learn?
1. Learn by comparison. By comparing multiple languages, it summarizes the unique characteristics of a certain language and the common characteristics of multiple languages.
2. Learn in history. By tracing the history of language development, we can understand how language came into being, change and disappear, and explore the trajectory of language development and evolution.
3. Learn by doing. Only by personally designing programs, thinking about how to program while practicing, can we deeply understand the intentions of the language designer, and at the same time, we can also find out where I did not understand.

2016/2/21
Knowledge common to multiple languages ​​is the point. Mastering these points will make it easier to learn other languages.
When learning multiple languages ​​in comparison, some knowledge can be understood more deeply. The so-called language is different, the rules are different.
If the goal is clear, the learning efficiency will naturally increase.

2016/3/17
        birth variables, is to use a string Alternatively expressed numerically stores a value of the memory location . (《代》P.45)

2016/3/23
       As the program becomes larger and larger, it becomes difficult to grasp the overall situation. At the same time, very similar operations may need to be used multiple times.
       The function is created to solve this problem. By semantically splitting a whole block of code and naming it until it is named, it becomes easier to understand this code. In addition, by calling this function elsewhere, the code can be reused.
       Along with the use of functions, a programming technique of recursive calling is produced, which is very suitable for processing nested data. (《代》p.52)        How to communicate errors on

4/10 of 2016
?
       Suppose there is a function that may make an error during execution, named shippai. When calling this function, it may succeed or go wrong. So how to separately write the operation on success and the operation on error (error handling)?
       There are two ways to write error handling. 1) is the use of the return value of the function shippai to convey information to program error , the function caller to correspondingly process the return value of the errors by checking. 2) The other is to set the error handling code before calling the shippai function, and jump to the corresponding error handling code when an error occurs. The former is still often used in languages ​​such as C language, and the latter is called exception handling. ("Generation" p.55)

2016/4/12
      When to throw an exception?
      1.  When the parameters are different when the function is called . For example: what happens when you call a function with two parameters but only pass one parameter? Python language and Ruby language will throw an exception at the moment of function call. But the JavaScript language will continue to execute the missing parameters as undefined special values ​​(undefined). (P.68)
      2.  The situation where the array is out of bounds. For example, what happens when you try to read the fourth value of an array with only three numbers? This is the out-of-bounds operation of the array. At this time, the Python language will throw an exception, the Ruby language will return a special value (null) indicating that it does not exist, and the JavaScript language will return undefined. (P.69)

2016/4/25
具体的知识和抽象的知识
在语言x中如何实现y, 像这种具体的知识(know-how)可快速提高你的工作效率。但是一旦语言发生变化,这种知识就无法再使用。因此,我们不仅要学习具体的知识,更要有意识地去学习那些应用范围广泛的抽象的概念。
当然,学习了抽象的元知识,如果不将其与你具体的经验相结合,也无法在实际应用中发挥其作用。喜欢樱花的人即使剪下花开的树枝带回家,终将看到的也仅仅是枝枯花败的场景而已。要想樱花年年盛开,离开根部和枝干是不行的。
我们所学的知识到底有没有真正的“根基”,可以通过考察能否具体地举例或者具体地实现来确认。没有真正根基的知识是无法树藤摸瓜、触类旁通的,所谓学习到的知识也只能像鹦鹉学舌般的重复讲讲而已。想要因地制宜地活用知识更是缘木求鱼,根本没有可能了。(p.73)

2016/5/4
所谓递归调用,是指函数内部再次调用当前函数的过程。
当有一重嵌套、二重嵌套、三重嵌套时,可以考虑使用for循环解决。那么当有几十层这样的嵌套时,处理这样的数据结构,需要的是不管多少层嵌套都能做处理的机制,多层嵌套for语句是无法做到的。尤其是无规律的情况,比如循环一个数组中的数字相加求和,但是有的应该放数字的位置放了一个数组,这时使用for循环就无法处理了。
例如,有个数组:[ 1, 3, [1,2], 5 ]
那么当1加到3时,发现后面的不是整数,这时,如果调用自身(递归),把[1,2]中的“1”,“2”作为参数传入函数自身,则可求得为3,这时函数返回值为3, 然后继续往后边加,即最终实现:1+3+3+5 = 12.

读书笔记(完)
(如有其它新的读书笔记会第一时间发到博客)
Steven
2016/5/4

Guess you like

Origin blog.csdn.net/ZxxSteven/article/details/53946526