《Programming from the Ground Up》學習第11天,p217-p238總結,總計22頁。
一、技術總結
1.C compiling
p216, C compiling is split into two stages - the preprocessor and the main compiler。
注:感覺這個寫法不好,因為preprocessor和compiler都是物件,這裡應該指動作。應該是:C compiling is split into two stages - the preprocessing and compilation。
(1)preprocessing
p216, The preprocessor is responsible for putting together the text of the program.
從程式碼上來說,透過#include <stdio.h>指令實現。
(2)compilation
#include <stdio.h>:尖括號(angle bracket)包含的內容一般會到/usr/include或者/usr/local/include路徑下尋找(如:stdio.h)。
#include "stdio.h":引號(quote)包含的內容一般會到當前目錄(current directory)下尋找。
2.Perl
Perl是一種解釋型語言。
#!/usr/bin/perl
print("Hello Perl!\n");
Perl語言的優點是“ In fact, one of Perl’s main strengths is it’s ability and speed at manipulating text.”。
3.Python
Python是一種解釋型語言。
#!/usr/bin/python
# filename: helloworld.py
print("Hello Python!")
以前總是不理解 #!/usr/bin/python的作用是什麼,看到這裡終於理解了。
當我們以 ./helloworld.py 的方式執行helloworld.py程式的時候, #!告訴電腦這是一個interpreted program, 使用/usr/bin/python(即/usr/bin目錄下的python)這個interpretor來interprete helloworld.py程式。
當我們以 python helloworld.py 方式來執行helloworld.py程式時,已經顯示指定了interpretor,此時#!/usr/bin/python會被忽略掉。
以前對這句話總是不理解,大概是因為頭腦中沒有interpretor這個概念,其實/usr/bin/下的python就是一個interpretor。
4.optimization(程式碼最佳化)
程式碼最佳化可以細分為speed, memory space usage, disk space usage等最佳化。書中講的主要是speed最佳化。
(1)when
p234, Therefore, the time to optimize is toward the end of development, when you have determined that your correct code actually has performance problems.
因此,我們往往在開發即將結束時進行最佳化,這時已經確定程式碼的正確性,也確定了程式碼確實存在效能問題。
(2)where
p234, A profiler(效能分析器) is a program that will let you run you program, and it will tell you how much time is spent in each function, and how many times they are run.
a.local
b.global
二、英語總結
1.stick
p217, This includes sticking different files together, running macros on your program text, etc.
vt. to cause sth to become fixed, for example with glue or another similar substance.
2.legwork
p219, You can see that interpreted languages are often focused on letting you get working code as quickly as possible, withou having to do a lot of extra legwork.
也寫作leg-work,u.the boring work that need to be done。Originally news reporter slang for an assignment that promised(這裡不是“承諾”的意思,而是“很可能(to seem likely)”) more walking than copy.
3.evident
p219, One thing about Perl that isn’t so evident from this example is that Perl treats strings as a single value.
剛開始看到evident的時候以為是“證據”,但用在這裡意思不符合,查了下“證據”的英文單詞是“evidence”。evident: ex-("fully") + *eid-("to see"), adj. easily seen or understood(顯而易見的)。
三、其它
耗時11天,終於完結了,明天出讀後感。
四、參考資料
1. 程式設計
(1)Jonathan Bartlett,《Programming From The Ground Up》:https://book.douban.com/subject/1787855/
2. 英語
(1)Etymology Dictionary:https://www.etymonline.com
(2) Cambridge Dictionary:https://dictionary.cambridge.org
歡迎搜尋及關注:程式設計人(a_codists)