August 10, 2013

Reading note of SICP (4)


Aug. 10th. Complete the 1st chapter of sicp.

I really appreciate the exercises within each subsections, because I can feel that they are well designed. I used to have the same feeling when I did the homework from Dan's course of programming languages. The exercises make the general concepts concrete and doable.

The abstraction is far from merely making the code more structured and readable. It is a design choice. Sometimes, it takes experience to find out where should be abstracted. And sometimes, it takes much more endeavors than simply mix everything together. But once the choice of abstraction is right, the program becomes clearer, and it increases many degrees of freedom for the design afterwards.

August 8, 2013

Reading note of SICP (3)

 
At the end of the 1st chapter, it enumerates the basic reason for the powerful lisp: first-order procedure.

The major "privileges" of the first-order elements are:
1) They may be named by variables.
2) They may be passed as arguments to procedures.
3) They may be returned as the results of procedures.
4) They may be included in data structures.
They can be crucial abstraction mechanism permitting to express the general methods of computing as explicit elements in programming language, so that they can be handled just like other computational elements. The expression power is enormous.

I have already been used to use the first two kinds of procedures, but the last two actually make the program even more expressive and powerful. Those are also the attractive properties sharing among functional programming languages.

August 7, 2013

Reading note of SICP (2)


While I am reading, I always try to distinguish which part of thoughts I used to learn from here when I read it for the first time, and which part I learned from Dan's course. And, surprisingly enough, I learned almost all basic factors from Dan, though I always felt I learned a lot of things last year when I began to read it.

The name of this book is perfect for the content -- Structure and Interpretation of Computer Programs. It does not teach about how to program, nor a specific programming language. Of course it is a legacy book. But it seems to me that I cannot get enough from this book unless I have mastered quite a few programming languages. After Dan taught me everything about basic aspects of programming languages and I played with Ruby and Racket for a long time, even after I leaned all those "nontrivial" trivial things about C++, when I read it now, I am able to distinguish which part is the essence and which part is written just for the ease of learning, and I can fully focus on how to put different abstractions into different layers-- in other words, learning the structure and interpretation of computer programs.

I read a comment, saying that Chapter 4 and 5 are the essence of the book. Hopefully, I can finish reading it before September, and leave enough time for Design Patterns.

August 6, 2013

Reading note of SICP

P59. I still don't think it is necessary to use "square" instead of (* x x) everywhere we perform this operation, but I appreciate the idea of "abstraction". It is really a good idea (and practice) to abstract concepts in different levels and use them accordingly.

Most of the examples I read are in a top-down design manner: firstly use the abstract concepts, and then implement it in a lower level. The concerns for specific lower-level modules is similar to the way I did using unit test. But I am a little bit confuse how to perform the unit test in this manner. Especially for the closure using in LISP--implementing local helper functions right after building major function-- how can I make sure the helper functions are right before I run the program as a whole? If I separate a helper function as an independent one, it seems that quite a little redundant work has to perform when I move it back to the major function.

Anyway, SICP just makes me love Racket even more =D

cheers,

July 23, 2013

Python/Numpy version collisions

   
Before this accident, I did not even know there were so many places relevant with a single program... I opened the pandora's box beginning with using brew doctor  which told me to move directory /usr/local/bin/ prior to /usr/bin/ so that all the homebrewed packages could be found automatically. After I did this, if I executed matplotlib, I would have this runtime error RuntimeError: module compiled against API version 8 but this version of numpy is 6 which was somewhat correct by the way. Because I used superpack installed the latest version of numpy(1.8), scipy(0.13), and matplotlib(1.4), but if I printed out the "numpy.__version__" in a script, it showed 1.6.1.

1) delete all of the outdated versions of numpy
2) make sure I explicitly add PYTHONPATH in the bash_profile.
3) I even uninstalled and reinstalled the numpy
But the problem was still there.

After an exhausted search, I found that numpy-1.6.1 in "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/" WTF! I still don't know why it search into 2.6 given there is another 2.7 in the same level of directory. Deleting both 2.6 and 2.7 directories (only delete the 2.6 could not work either...) finally solved the problem. ahooooo....

July 1, 2013

Setup emacs in Mac OS


The setup is much harder than I thought...

1) using homebrew installs the emacs and guile. Then, I also need to add path in the .bash_profile to launch the up-to-date emacs rather than the original version 22.1 shipped with the os.
export PATH=/usr/local/Cellar/emacs/24.3/bin:$PATH
2) Enable the Meta key in terminal, or similar position for iterm2.

After these two steps, the following is more straightforward.

3) I accidentally found this "emacs-starter-kit", which had 2300+ stared and really saved my day. Just follow the instruction and everything will be fine.

In current state, I feel emacs kind of like vim+tmux. Anyway, learning new knowledge is always a pleasure, especially about this kind of "legacy" stuff.


cheers,

[UPDATE: after changed the loading sequence of bash in /etc/paths/ the first step seems unnecessary... actually, that was something I should do as soon as I used homebrew to port packages. http://bit.ly/IUVl9a

June 5, 2013

C++ rants (continued)

(link)

>Care to write an explicit example of a deep problem? (Except memory management - you already mentioned garbage collection.)

Concurrency, for example.

My point being, that C++ adds absolutely nothing interesting.

>All right. Then why do you think C should have support for structures (struct {...})?

That's just singularly stupid.

C is a good language. It's complete enough (and yes, the ability to handle structured data is very much required for any serious language) to be supremely useful, while at the same time being quite simple.

A language without structured data types would not be a powerful language the way C is. You do need data structures, and you need pointers (to both data and code) to be at all interesting.

But where do you draw the line?

I know that you as a C++ proponent you probably won't really "get" this simple argument, but try:

- read the K&R book on C (the ANSI edition), and be enlightened.

Notice how the language is basically described by one rather thin book. Readably.

So what C does so well is to do that whole "make it as simple as you can, but no simpler". And that is what makes it great. The language is powerful, yet fairly minimal.

There really aren't many features you could remove from the C language without crippling it. Sure, there's
three different looping constructs, and you could make trivial (syntactic) changes to the language, but that's
really not the point. The language is simple, but without being too simple.

Now, that's not what you always want. I understand very well why people want less system-oriented languages with more built-in functionality. As mentioned, support for both garbage collection and concurrency are quite real problems, and they are both things you can do in C, but that you cannot do well with library interfaces, which is how you normally would extend on C.

And garbage collection and concurrency are way more than just syntactic extensions. You can still do them very badly, of course, so it's not a trivial path to go down, and I'm not saying hat a language magically becomes "good" just from supporting one or the other.

But again: C does what it does very well, and with a clarity of thought and design that is entirely and utterly lacking from C++.

And yes, I happen to think that clarity of thought and design is a good thing. It's why I liked UNIX, even though I was initially introduced to other things (VMS - ugh).

C++ is a mess. There's no design. It's just "add crud on top of C". And the crud isn't even meaningful, much less does it have a design. It's totally and utterly random.

It started out random, now it's randomness that gets added to by a committee.

>For example, namespaces and function overloading are *not*
>useless. They *do* solve a real problem that C is incapable
>of solving.

You're full of it.

>For example, if you want in your source code to define a
>function called "connect" and you also want include
>"sys/socket.h", you cannot do that in C.

So to prove how it's not just a syntactic feature, you start talking about syntax?

What drugs are you on?

The name overloading is a total syntactic feature. In C, the way you fix your problem is by a totally trivial syntactic change: you call your function "my_connect()".

Wow. It's like magic. I added three characters, and made your whole reason for the crap that is C++ go away.

The thing is, the above is a really good example of why C++ is horrible, and why C is so simple.

Yes, the C solution is really simple. It's so simple that it looks downright stupid. But it's actually so simple that it is smart because quite frankly, it's a lot easier to get confused in C++ code, when the same function name means totally different due to overloading.

Of course, you're not "supposed" to overload things in confusing ways, but the thing is, just do what C does: just make your function names unique. It's not that hard, and by avoiding the overloading mess, you make it a lot easier to search for (hey look! "grep -w my_connect" just works!), and you avoid ambiguity.

(Same exact thing goes for your other example: just add a module prefix or have some other trivial naming rules for your functional split-up, and be happy)

Linus

C++ rants

By Linus Torvalds:

On Wed, 5 Sep 2007, Dmitry Kakurin wrote:
>
> When I first looked at Git source code two things struck me as odd:
>1. Pure C as opposed to C++. No idea why. Please don't talk about portability,
>it's BS.

*YOU* are full of bullshit.

C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C.

In other words: the choice of C is the only sane choice. I know Miles Bader jokingly said "to piss you off", but it's actually true. I've come to the conclusion that any programmer that would prefer the project to be in C++ over C is likely a programmer that I really *would* prefer to piss off, so that he doesn't come and screw up any project I'm involved with.

C++ leads to really really bad design choices. You invariably start using the "nice" library features of the language like STL and Boost and other total and utter crap, that may "help" you program, but causes:

 - infinite amounts of pain when they don't work (and anybody who tells me that STL and especially Boost are stable and portable is just so full  of BS that it's not even funny)

 - inefficient abstracted programming models where two years down the road you notice that some abstraction wasn't very efficient, but now all your code depends on all the nice object models around it, and you cannot fix it without rewriting your app.

In other words, the only way to do good, efficient, and system-level and portable C++ ends up to limit yourself to all the things that are basically available in C. And limiting your project to C means that people don't screw that up, and also means that you get a lot of programmers that do actually understand low-level issues and don't screw things up with any idiotic "object model" crap.

So I'm sorry, but for something like git, where efficiency was a primary objective, the "advantages" of C++ is just a huge mistake. The fact that we also piss off people who cannot see that is just a big additional
advantage.

If you want a VCS that is written in C++, go play with Monotone. Really. They use a "real database". They use "nice object-oriented libraries". They use "nice C++ abstractions". And quite frankly, as a result of all these design decisions that sound so appealing to some CS people, the end result is a horrible and unmaintainable mess.

But I'm sure you'd like it more than git.

Linus

=====

Heath Provost (galvanash@hotmail.com) on 6/5/10 wrote:
>
>As for C++ exceptions - the same thing really applies here.
>They are trying to write explicit code. Exceptions are the
>poster child for implicit magic...

Yes, exceptions is a good example. The Linux kernel actually does its own exception mechanism, exactly because that way we control what is going on (and do it much more targeted to the actual need in question while giving much better performance and avoiding the crazy unwinding issues).

And I really do dislike C++. It's a really bad language, in my opinion. It tries to solve all the wrong problems, and does not tackle the right ones. The things C++ "solves" are trivial things, almost purely syntactic extensions to C rather than fixing some true deep problem.

(The C++ objects, templates and function overloading are all just syntactic sugar. And generally bad syntax at that. And C++ actually makes the C type system actively worse.)

In non-systems programming, you should almost certainly use a language that offers garbage collection. That will possibly make a real difference in the complexity of your application. The C++ features? Largely useless, and just helps you screw up more.

And in systems programming, you're simply better off with C. You'll have a way easier time using all the existing code and libraries out there (re-using C++ code? Good luck). Fewer headaches, fewer opportunities to mess up the design and pick some unstable template library.

So in neither case is C++ likely the right choice.

Linus


June 4, 2013

excerpt from "effective c++"

   
Cpp is like some stubborn old man, who always says "i have lots of obscure habits, dealing with it"......

Lesson 4: the initialization is different from assignment, as well as their representations respectively. It is better to write the constructor as the form of initialization, named "initialization list", rather than just simply give the variables first assignment.

To avoid using objects before they're initialized, then, you need to do only three things. First, manually initialize non-member objects of built-in types. Second, use member initialization lists to initialize all parts of an object. Finally, design around the initialization order uncertainty that afflicts non-local static objects defined in separate translation units.

Lesson 7: declare destructors virtual in polymorphic base classes. C++ specifies that when a derived class object is deleted through a pointer to a base class with a non-virtual destructor, results are undefined. What typically happens at runtime is that the derived part of the object is never destroyed. Eliminating the problem is simple: give the base class a virtual destructor. Then deleting a derived class object will do exactly what you want. It will destroy the entire object, including all its derived class parts.

The purpose of virtual functions is to allow customization of derived class implementations. Any class with virtual functions should almost certainly have a virtual destructor. The implementation of virtual functions requires that objects carry information that can be used at runtime to determine which virtual functions should be invoked on the object. On the other hand, if a class does not contain virtual functions, that often indicates it is not meant to be used as a base class. When a class is not intended to be a base class, making the destructor virtual is usually a bad idea.

Lesson 9: Never call virtual functions during construction or destruction. Because during base class construction of a derived class object, the type of the object is that of the base class. Not only do virtual functions resolve to the base class, but the parts of the language using runtime type information (e.g., dynamic_cast (see Item 27) and typeid) treat the object as a base class type.

The same reasoning applies during destruction. Once a derived class destructor has run, the object's derived class data members assume undefined values, so C++ treats them as if they no longer exist. Upon entry to the base class destructor, the object becomes a base class object, and all parts of C++ treat it that way.

Since you can't use virtual functions to call down from base classes during construction, you can compensate by having derived classes pass necessary construction information up to base class constructors instead.

February 19, 2013

Set up Racket for Vim and mac Terminal

   
Racket is fairly great:), though the setting up procedure is kind of twisted. There is a .dmg installation file in the official website, which makes it quite straightforward to install in the Application folder. And, of course, the DrRacket app is awesome when I accidentally put mouse in one of the variables in the code, and then all its dependencies reveal via arrows.

But I am still used to writing code in vim and testing it in a parallel split window of iterm. I googled the solution, but cannot find a comprehensive one. So, I just list my solution here, which come from either stackoverflow or other persons' blogs.

1) vim syntax and highlight are out there ready for use.

2) Adding one command line to ~/.vimrc
 au BufRead,BufNewFile *.rkt set filetype=racket
3) Adding the path of executable racket to ~/.bach_profile.
export PATH=$PATH:/Applications/Racket\ v5.3.3/bin/
4) If using the existing file, one should delete the first line of code "#lang racket" if existed.

5) Optional. Installing rlwrap to make the repl more user friendly.

That is much of it.


cheers,

February 14, 2013

1st update in 2013

   
The issue came from my question in stackoverflow. Basically, it was a misplaced question, because the reason why my program would hit the "RuntimeError: maximum recursion depth exceeded" was that I just passed the sorted array by the first scenario to the second scenario. This caused the second one hit the "worse case" and exceed the "maximum recursion depth". Well... it was embarrassing to admit that I forgot dereferencing the variable...

But, anyway, the question concerning recursion in Python has been in my head for a while, even since I started learning Scheme. This time, the kind answer below my question shed lights on how to solve this kind of problem. Then I dug a little deeper and find more about tail recursion in Python.

The following is an example with problematic way to implement a recursion function:

def fac(n):
    return 1 if n < 2 else n * fac(n - 1)

> fac(3000)
> RuntimeError: maximum recursion depth exceeded

The right way to do this is to make a local helper function "tail recursive" with the help from anonymous function.

def fac(n):
    def f(n, acc):
        return acc if n < 2 else lambda: f(n - 1, acc * n)

    t = f(n, 1)
    while callable(t):
        t = t()
    return t

And an even elegant way is to use built-in function "reduce":

def fac3(n):
    return reduce(lambda x,y:x*y, xrange(1,n))
The latter two could deal with any input number. Tada~

A little extended reading about this topic:
Origins of Python's "Functional" Features
Tail Recursion Elimination
Tail Recursion Elimination in Python

Besides, studying Standard ML does give me much much more insights into both programming itself and programming in Python. Except the attractive tail recursion, Python has quite a few amazing features of functional programming.  In retrospect, now I appreciate more about what was listed in the "progression path", and of course, cannot wait to progress to Haskell.





cheers,

October 4, 2012

Install opencv in mac osx

The most straightforward way is via homebrew.
brew update
sudo brew install opencv

Then, all of the dependencies will be install with opencv. The reason to use "sodu" is because there will be twice "brew link" used in the process which could not link certain libraries without permission.

Finally, the brew gave a wrong file to update. Instead of updating .profile, the correct destination should be .bash_profile. Add this line:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages/:$PYTHONPATH<\code>

That is it.


cheers,

September 17, 2012

missing you


小葛儿转眼安排好纽约面试就登飞机了。因为GPS的缘故,在机场周围转了好几圈,结果弄的再见都匆匆忙忙。送完她回到寝室——是的,没有了她,这里还是叫寝室合适——空荡荡的,安安静静。一分钟都不想多停留,背着书包就去了实验室。

晚上也不想回去,因为想到又是空空的房间就不自在。

一个人在这里。忽然一下安静了。多出了好多时间来想你,似乎一切记忆瞬间无比清晰,触手可及。你的肩膀软软的,抱在怀里的时候,还要告诉自己小心别把你弄疼了。你哭的时候,撅着嘴,鼻子里些许呜哝呜哝的声音,眼泪扑簌扑簌就落下来了。你笑的时候,眼睛眉毛嘴角都弯弯的,咯咯咯的,清脆悦耳。每到这个样的时候,我都在反问自己,为什么要和你吵架啊,有什么气好生呢。

可无论怎么吵架,我都还是爱你的,比每一次吵架前还要爱你,比每一次生气之前还要更想和你在一起。有时候会想,也许我太把你说的每句话当回事儿了,才会又好多的弄巧成拙。但翻回头来,我仍就欠你好多在一起的时光。

小葛儿啊。你的一举一动,一颦一笑,我都记在心里呢。欠你的那些时光,我也一定要都好好还你。快回来吧。有你在的地方,我就认为是家了。

我想你。

September 14, 2012

My August and a new beginning


八月份,是个开始的月份,来到了一个小屯子里,没有公交,没有市集,只是明晃晃的阳光,会照的人发晕。当真是个修行的地方。有关这里,想法都有关不要虚度光阴,要快些离开这里。

月中,和大瀾、乌龟、聪哥、温总一起去了黄石,西雅图,以及波特兰。这次旅行,如同酿酒发酵一般,越到后来越是留恋。

刚到Bozman的时候,大瀾看着大山都激动的手舞足蹈。然后进入黄石以后,各种臭泉以及异常干燥的气候弄的大家都越发烦躁起来。大瀾背着手,像居委会大妈一样视察颜色异常的泉水;也会二劲儿大发,摘下花来给每个人带上,拍个大头贴。大乌龟在走trail时候,被路上唯一的一个钉子扎破了后背。甩着舌头奔跑的牦牛,成群在树林里休息的大鹿,elk or moose。在大峡谷的晚上,八月间,大家竟然都被冻醒了,我迷迷糊糊间,看着大瀾给我盖被子,感动了好久。

三日后的大提顿满是惊喜。前一天晚上大瀾肚子疼的没吃好晚饭,扶她回房间后,我连吃饭的心思都没有了,更不要说后一天的提顿之旅。第二天早晨,大家也是有懒床的,有睡回笼觉的。只有唯一想去的温总,一肚子郁闷说不出口。而且刚启程,就发现没带门票,又折回。我开着车都能想到留守的聪哥似笑非笑的的得意样子。最终正午才进入大提顿,就遇见了满眼惊喜。厚厚的草甸,飘满小花的湖泊。大瀾拄着两人多长的树枝照相。在Jackson Lake租船的时候,旁边的小孩儿们兴奋的举着水瓶,炫耀捉住的水蛭。大瀾在船上,看不出任何身体异样,兴奋的拍水,尝试各种怪异的划船方法,几次都殃及到了坐在后面的我。但不管怎样,我俩划起船来,左右开工,还喊着号子,小船乘风破浪的指那儿打哪儿,相比而言,乌龟和温总的另一艘船大多就是在原地打转了。上岸之后,我们还在岸边的饭馆儿吃了进黄石以来最丰盛的一顿饭。在Jenny Lake,看着一湖清水,我和温总都脱到只剩内裤,跳进去玩水,结果上岸时候悲剧了,小石子们就像是锥子一样,走向岸边每一步都钻心的疼。。。大瀾在岸边,一边叹息着想游泳啊想游泳,一边带着乌龟和温总的俩单反,不断练习摄影技术。傍晚看日落,所有的山峰都一览无余,感慨自然壮丽。然后在把车开到山间处,再看一遍日落,再感慨一遍。晚上回程,看到了过马路的小狐狸,也许是被车灯照迷糊了,久久不离去,真想把它抱回来养。

晚上回到酒店,又出门,和大瀾并排躺在码头上,我第一次清楚看到了银河,像棉絮一样一团一团的,还看到了流星。拉着大瀾的手,看着奇妙的景色,时间就静止了。

到西雅图的第一天晚上,还有更多的惊喜。从倾斜的街道看到大海,身旁小酒馆门庭若市。城市真好。也是在这个时候,我们发现Yelp的预算对我们不适用。$的我们可以吃成$$$,$$的我们能吃成$$$$的。几个难民坐在日式料理最靠窗的桌子,烤肉、寿司、炒饭、拌面...,我们狼吞虎咽的样子,就是这家店最好的活体广告了。酒馆、小肥羊、牛逼的图书馆、大麻公园、面海公寓、满是鲜花的阳台,这就是我对西雅图的印象。

去波特兰是因为Grimm。精致的block,友好的大瀾校友,以及玫瑰花园。我们在市区停留只有半日。然后就是一个小时的公车,从二十几街坐到了245街。。作为这座庄园里唯一一队乘坐公车前来的客人,我们受到了主人的热情接待,安排我们住宿在一个墙上画着这个庄园某位109岁员工的房间里。庄园的晚饭不错,温总一时兴起喝了六七杯或者十来杯红酒,结果把大乌龟给喝醉了,嚷嚷着要脱衣服去游泳,又把聪哥紧张的如同被非礼了一样。。晚饭后我们还视察了庄园的绿化状况,并亲切会见了酒馆里的各种奇怪大叔大妈。

转眼相聚就要分离,回家的回家,旅行的继续上路,确实舍不得另外三位。昨天在豆瓣上读到马克吐温的一句话,“好友、好书,不轻易判断是非,这就是理想生活”。一路上颠簸,没读什么书,这生活却以足以让我留恋了。

在这里,开始学习工作快满一月了。老板人不错,几次问他有关研究的问题,他都很耐心的回答,给的方法也足够有操作性。今天一个师兄作报告被骂,也从另一个侧面证明老板足够聪明,不能唬弄。组里大家关系也很融洽,实验室、图书馆,资源也算充裕。新车也用的顺手。还是开始时的那个想法,不要浪费时间,早些离开这里。

June 12, 2012

Valve recruiting sidenotes

    
• Would I want this person to be my boss?
• Would I learn a significant amount from him or her?
• What if this person went to work for our competition?

Across the board, we value highly collaborative people. That means people who are skilled in all the things that are integral to high-bandwidth collaboration—people who can deconstruct problems on the fly, and talk to others as they do so, simultaneously being inventive, iterative, creative, talkative, and reactive. These things actually matter far more than deep domain-specific knowledge or highly developed skills in narrow areas. This is why we’ll often pass on candidates who, narrowly defined, are the “best” at their chosen discipline.

We value “T-shaped” people. That is, people who are both generalists (highly skilled at a broad set of valuable things—the top of the T) and also experts (among the best in their field within a narrow discipline—the vertical leg of the T).

This recipe is important for success at Valve. We often have to pass on people who are very strong generalists without expertise, or vice versa. An expert who is too narrow has difficulty collaborating. A generalist who doesn’t go deep enough in a single area ends up on the margins, not really contributing as an individual.

reference: Valve handbook

June 4, 2012

General posts about Lisp

    
Paul Graham: The Roots of Lisp (ps), What Made Lisp Different (Chinese translation), and his collection.
The Lisp Curse by Rudolf Winestock
Why Lisp macros are cool, a Perl perspective
The Nature of Lisp
Lisp: Good News, Bad News, How to Win Big (pdf)
The Bipolar Lisp Programmer
Natural Language Processing in Lisp (book)
Tips for using Scheme and debugging your code
Lisp的永恒之道 (Chinese)


A great explanation from ITA Software about why and how to use different languages, including Lisp (CL), Python, Java, and C/C++.
Lisp is a programmable programming language, and one of the few languages that can be used for a wide range of applications. At ITA we have projects with vastly different focus, and it's precisely Lisp's versatility that makes it so useful to us. Lisp allows us to define a wide variety of abstractions to manage the complexity, and at the same time we get the speed we want - and our customers demand.

While most of ITA's algorithm-intensive code is implemented in high-level languages like Lisp, we use C/C++ to provide system support to our Lisp-based applications where the Common Lisp runtime support is inadequate. For instance, we represent large static datasets as densely packed arrays stored in files. We use C++ to make the mmap() calls and fetch pointers into these mappings for Lisp to access.

Once in a while, we have had a hard time fooling the Lisp compiler into generating sufficiently fast machine code for a given function. When that happens, we can usually just rewrite the function in C++ and call it from Lisp.
and... quote from an email of Carl de Marcken from Paul:
A lot of our Lisp is designed to compile into very efficient assembly. We make a lot of use of Lisp's macro capabilities, but shy away from many other Lisp features like closures, generic functions, complex sequence functions and garbage collection. We're doing an incredible amount of computation - getting 10 seconds on a modern machine is an incredible gift - but if we're sloppy at all 10 seconds can turn into ten minutes, not adequate for a travel agent or web site. We disassemble most every Lisp function looking for inefficiencies and have had both CMUCL and Franz enhanced to compile our code better.

We've had very little trouble getting non-Lisp programmers to read and understand and extend our Lisp code. The only real problem is that the training most programmers have in Lisp has taught them to code very inefficiently, without paying any attention to the compiler. Of course, with things like STL and Java, I think programmers of other languages are also becoming pretty ignorant.



May 16, 2012

HD and SICP

    
Humming Identification.

已然经历了两次较大的重建,现在的中段程序应该算是稳定了,前段程序接近黔驴技穷了,后段程序最后一次大修改后还在服务器里面跑着。出结果之后再用一两天时间整理,然后再看看清唱部分的阈值应该如何处理。不出意外的话,这就接近世界先进水平了:)

现在回头看来,其实真正值得研究的部分还是在最初的参数提取。SIFT里面对于图像的各种锥形不变、边框加深、棱角过滤,对于音频信号都是不适用的。而语音信号的频谱重复或者音乐信号的长时重复在哼唱识别中又是不适用的。所以现在只能使用较为原始的 local maximum cascade filtering。若是频谱图能如图像般的直观,有些经验总结的东西在里面,就好了。


SICP

思考过一段时间的结果,因为有了电据就少用到电钻,于是熟练了Py也就先放放ruby了。转过身来硬着头皮读这本书。而第一天读过前言,我就知道这决不会是个令我后悔的决定。无数人的推荐,自然是有其中道理的。而把读过的几本经典书籍横向比较,会发现它们都会刻意避开很多fancy的概念,着力强调着那些在设计程序过程中永恒不变的东西。K&R把C的很多基本库函数都重建了一遍,而SICP更是从加减乘除开始重构。

开始读书之前,我也刻意找了一下CL和Scheme的对比。记得有个人说,如果想用Lisp做项目,CL更合适;想体会编程的乐趣,Scheme更合适,只是,它的核实在是太简单了。几个月看下来,其对于Scheme的评价当真实字字珠玑。这是一个无比强大的语言,data abstraction & procedure abstraction,之后再抹去两者的差别,都只是当作object处理。看到这里,我会有错觉,认为自己都可以来设计Clojure了,这简直就是顺理成章的事情!tail recursion,比循环更加直观易懂,而更牛逼的是这竟然不会按照stack的模式迭代后增加内存的占用。至于enclosure和lambda calculus,在Python里面也有借鉴,但是我是直到这里才真正学会了如何使用它们⋯⋯当然,我很清楚这些词汇推砌起来的仍然仅仅是些皮毛。里面很多在程序设计时的考虑,才是更需要我好好体会的。


BTW, 今天的时间累计到2800了~

cheers,

April 10, 2012

Install MIT/Scheme with Vim

    
After wondering around for a while, I finally found this was quite foolproof...

It could be divided into five steps:
1. $ brew install mit-scheme. (Its version is usually a little bit older than the latest MIT/GNU Scheme)
2. Install GNU screen if it was not installed before.
3. Install Screen Vim plug-in according the steps in that webpage.
4. $ vim ~/.vimrc
"For screen.vim send block
"to SendScreen function
"(eg Scheme interpreter)
vmap :ScreenSend
nmap vip

5. Launch Vim and write ":ScreenShell mit-scheme". It is all set for the fun:)

References: [1], [2]

cheers,

March 16, 2012

Reading digest 03/16/12

Smart and Gets things done
What should you look for during the open-ended questions?
One: look for passion. Smart people are passionate about the projects they work on. They get very excited talking about the subject. They talk quickly and get animated. There are far too many people around who can work on something and not really care one way or the other. It’s hard to get people like this motivated about anything.
Two: good candidates are careful to explain things well, at whatever level. You don’t want to hire some one, basically, because he is not smart enough to comprehend what it takes to make other people understand their ideas.

No Designer's Design Book
When several items are in close proximity to each other, they become one visual unit rather than several separate units. As in life, the proximity, or the closeness, implies a relationship.
By grouping similar elements into one unit, several things instantly happen: The page becomes more organized. You understand where to begin reading the message, and you know when you are finished. And the “white space” (the space around the letters) automatically becomes more organized as well.

January 24, 2012

Reading digest 01/24/2012

    
My plan for 2012: do things that children do
Learn things
Play sports
Sing and play instruments
Draw and paint
Write stories
-- I have to say it is a better "next year resolution" than what I have made. The explanation is clear and straightforward. So, I should add them to my resolutions!

Life Tastes Best When You Eat What You Kill
Don’t depend on one boss, buyer for your company, product, service you offer, etc. Diversify everything you can.
Become an expert.
Connect people.
Give ideas for free.
Always work on your exit. No matter where you are: a job, a startup, your startup, writing a column, working at Mcdonalds, always diversify your possible exits and begin immediately working on them. You don’t have to exit tomorrow, but never forget that you can get that email tomorrow that says you have to clean out your desk by Saturday.
Never say a bad word about anyone.
Don’t care what people think.
Create your luck.
Take responsibility for all failures.
Honesty. If you don’t ask for what you want, chances are you won’t get it. If you don’t say what you believe, you’ll never stand out from the 99% of people out there who hide the truth about themselves and their desires. If you don’t stand up and say or show how special you are, nobody will ever think you are special. Nobody is out there advocating for you. Honesty about what you feel, believe, know, think, want, will make you a multi-dimensional being in a flatland world.
Patience.让子弹飞一会儿。
-- The general guidelines might be too vague to follow or helpful to summarize some vague thoughts in mind. This one is much closer to the latter category.

Days of our lives

Daisypath Anniversary tickers