明月清风此夜
music
I love Brahms’s piano concert no. 1 so much that I listened to it for more than 50 times this year. My favorite performance is this one. It is no exaggeration to say Hélène Grimaud took my breath away. You may notice the sound distortion towards the end of this recording. Whenever I felt spiritless, I listen to this piece. There are times when even the first movement can’t beef me up.
I also love Les Misérables in Concert: The 25th Anniversary.
books I read (some reread)
The most sensational books I read last year are:
宋词鉴赏辞典、唐宋词鉴赏辞典、唐诗鉴赏辞典
There comes one nail after another on my coffin. I was at an all-time low ebb. I had forgotten the good old dogma of “Read not to contradict and confute, nor to believe and take for granted, nor to find talk and discourse, but to weigh and consider”. All that I wanted was to find someone who can express all these inexplicable things. Have to say I had some good finds. I reckon there ain’t any tranquilizer like another undeserved underdog life.
The Death of Ivan Ilych
I never read any sentimental book like this.
To Ivan Ilych only one question was important: was his case serious or not? But the doctor ignored that inappropriate question. From his point of view it was not the one under consideration, the real question was to decide between a floating kidney, chronic catarrh, or appendicitis.
Why, and for what purpose, is there all this horror? But however much he pondered he found no answer. And whenever the thought occurred to him, as it often did, that it all resulted from his not having lived as he ought to have done, he at once recalled the correctness of his whole life and dismissed so strange an idea.
To Kill a Mockingbird
The first time I saw the movie, it was a disappointment. After read this book, I re-watched the movie. It was a bigger disappointment. This book really taught me so many things. I think the story about racism is least of them. Also, there are some cliches in this book. But I was sold anyway.
It’s when you know you’re licked before you begin but you begin anyway and you see it through no matter what.
movie
The only movie that disquiets me is The Best of Youth. The movie itself is mundane at best. I am also not impassible to the plot. It’s only one of the protagonist Martin that makes me go through the whole movie. But I don’t really understand Martin, because I am Martin. Following Martin’s trails is like watching myself from an outsider’s point of view. My own life is no less dramatic than his. Sometimes I felt miserable for him. Why, and for what purpose, is there all this tragedy? Whenever the thought that it all resulted from his not having lived as he ought to have done, I at once recalled the correctness of his whole life and dismissed so strange an idea.
languages I learned (some relearned)
go
Go is a strongly opinionated language with an excellent standard library which is ostensibly simple. A have quite a few complaints against go, as last year I worked mostly with go.
No generics
You can not even curry arguments, let alone A plethora of goodies that were only possible with generics. Golang Has Generics—Why I Don’t Miss Generics Anymore · Jonathan Oliver People even defended the lack of generics with interface. It is ridiculous. Also, using interface can be ungainly sometimes. Image you want to sort a struct a. You defined a TotallyOrdered
interface with method geq
. You defined quicksort function on with the TotallyOrdered
slice. Now you run the function with signature func(set []TotallyOrdered) []TotallyOrdered
. The thing is that you are not getting []a
. Converting TotallyOrdered
slice back to a slice requires type assertion one by one. This is really ugly. And of course, this is not how go’s sort.Slice
is implemented. Its signature is actually func Slice(slice interface{}, less func(i, j int) bool)
. But you can easily imagine situations where interface must be returned.
No algebraic data type
As mentioned before go has no generics, so algebraic data type is simply not an option, but I do want options.
Go authors defended the choice of its error handle model. Error handling is just about try and catch. The option applicative is a much more elegant way to handle errors. Go’s
if err != nil {
return err
}
is quite wordy. Even the ? macro of rust is much better.
Another casualty of missing algebraic data type is the abuse of type assertion. Below is a snippet from an implementation of actor model in go
type Hello struct{ Who string }
type HelloActor struct{}
func (state *HelloActor) Receive(context actor.Context) {
switch msg := context.Message().(type) {
case Hello:
fmt.Printf("Hello %v\n", msg.Who)
}
}
Moreover, there are situations where simple abuse of type assertion not work.
overloading and collections
Go authors always know the best. Their choice of Mul
, Quo
in math.big
is ok for me. Having no way to reuse range reuse if v, ok := m[k]; ok {}
is also tolerantable. But I really abhor writing another thread-safe map-like thing in yet another program manually. Oh yeah, I see your point that overhead should not be amortized to every map. Just give me a way to import another map library with which k, v := range m
just works concurrently. As you have already seen, creating generics collection types is not possible. if v, ok := m[k]; ok {}
is go authors’ privilege. We shall not touch.
reproducible build
GOPATH, or go’s another design which failed to simplify your life. go get
is great till it is not. The other day, I find shfmt for nix is outdated, monstrously outdated. My emacs auto format plugin already uses the new command line argument. So every-time I save a shell script, an error message pops up. I decided to write build script for nix. But I didn’t, as I don’t want the hassle of obtaining the latest revision of shfmt’s dependency.
I understand your need for deterministic build. You may use gopkg.in/xxxvy, or better, vendor. But please be prepared for magic like this.
Glad to see go mod
is coming. But people are still using vendor anyway. I still need to delete the vendor folders manually.
goroutines and channels vs actors
One of go’s major selling point is easy concurrency. I am just a dabbler of actor model. But actors seems to be much better in the following aspects. First, actors can be viewed as a monad. They are much more composable. Second, supervisor tree is much better than context, the infectious context. Third, in go, value can not be passed to channels by another process. Forth, message passing is fault tolerant.
other quirks
You may be amazed to see code like this
// BodyArgs returns a scanner that returns arguments passed in the body as tokens.
//
// Returns nil if there are no arguments to be consumed via stdin.
func (req *Request) BodyArgs() StdinArguments {
// dance to make sure we return an *untyped* nil.
// DO NOT just return `req.bodyArgs`.
// If you'd like to complain, go to
// https://github.com/golang/go/issues/.
if req.bodyArgs != nil {
return req.bodyArgs
}
return nil
}
This can be dramatized by the following simplification
func (x *testStrcut) testFunc() testInterface {
if x == nil {
return nil
}
return xxx
}
You may be the explantion here.
tooling and ecosystem
Go’s tooling is pretty good. I love how easy cross compilation is with go. go’s standard library is also among the best.
haskell
I did not learn so much time on learning haskell itself. Instead, I spent quite some time on figuring out the best developing environment for haskell and learning functional programming. I spend quite some time get used to nix. It pays off. Nix + stack are a great combo. See Nix Loves Haskell and haskell-nix.
As for editor integration, having tried intero, dante, and haskell/haskell-ide-engine, I come to the conclusion that there ain’t any place like intellij-haskell for me currently. intellj-haskell build intero on the fly from stack.yaml, which avoids conflicting ghc versions. It seems none of intero and dante does this. Frequently I am unable to jump to definition. Jumping to definition of Haskell ide engine works only within project, i.e. it is useless for now. But ghc 8.8 is coming. ghc 8.8 can optionally save the symbol information into HIE Files, which may help haskell ide engine find definitions. I am really 一颗赛艇.
People always complain about buzz-words. It is quite new-comer unfriendly to use a lot of jargon. But I think most of the terminology makes communication more efficient. Also, the distillation of some common phenomena is quite necessary. I had my difficult times, and I am still having. But I really enjoy the new terms after solving (and perhaps more importantly, failing to solve) lots of exercises.
I read some papers like Applicative Programming with Effects, Notions of Computation and Monads, Imperative functional programming, Typeclassopedia and A History of Haskell: Being Lazy With Class.
When it comes to hands-on with haskell, I only did the exercises in the first two chapters of Discrete mathematics using a computer and fiddled with xmonad.
scala
I read the book Function Programming in Scala, did 3/5 of the exercises. I have to say this book is absolutely stunning.
As someone who once was a physics student and who once became mathematics major, I am mostly stunned by the fact that full power of imposing limit. My mind has been framed to generalize everything. Come up with a theory that encompass everything is the greatest virtue I can imagine. Never had I dreamed of imposing unnatural limit can be so powerful. Given
return a -> m a
It is a no-brainer to define
bind' a -> m b -> m a -> m m b
This is what natural means. But crazy programmers defined something as ugly as
bind a -> m b -> m a -> m b
This join function m a -> m m a
is invented by a genius. You may have your objection, this is just discovered. My world is thus subverted.
I have a few more words about this book. This is truly the best introductory book you can find for functional programming. I think you’d feel comfortable about scala before you start this book, lest some obscures scala grammar prevents you from keep going. I, myself was baffled by the map signature in page p53. It makes absolutely no sense to me before I know self. I read Scala for the Impatient. Did some exercise, and finally I felt comfortable with scala. Then I returned to this book.
nix
nix’s centralized management of configuration makes life a lot easier. Moreover, I really enjoyed the declarative style of configuration. Imperative deployment tools like ansible are nothing but bash with templates to me (of course, more libraries to use). I really do not see their so large a benefit as advertised. With nix, I do not need to dive into the syntax of the services I want to configure. All that I need is man configuration.nix
. This is really great. Also, having manually tweaked my configuration files for individual hosts for a while, I find with a real programming language to configure all my computer a big relief.
Nix-shell is also awesome. I can now make a virtual environment for any languages.
I have a wishlist for nix. The first item within this list is user-wise configurations. I really want a counterpart of systemd use unit for configurations.nix. Nix, the language is insufficient. I would like to seem a statically typed nix (A chartered GitHub - haskell-nix/hnix: A Haskell re-implementation of the Nix expression language maybe). I want also jump to definition support.
rust
Giving my frustration on go, it is not hard to imagine I have more adoration on rust, another native language. Rust has many features beyond 70’s. Immutable data, generics, algebraic data type, pattern matching. What more can you expect from a imperative language (Functions in rust is not first-class citizens)? Also, it is just me not being able to encountered so many segfaults that makes me forget to praise ownership and borrow. But that is not I wanted to learn rust really. I learned rust so as to approach its great community. People had created many things 一颗赛艇. For one, operating system redox, for another, remacs. Rust is really a better choice for system programming. I really had it enough with dynamic linking. Everytime I compiled something on my nixos machine, I have to do patchelf. It is really annoying. Sometimes things went from bad to worse, I have different glibc versions on different machines.
c
Really can’t believe the git statistics, I wrote some like two thousand of c code. C is not a good language. Unix is not a good operation system. But sometimes, from a pragmatic point of view, nothing beats them. I would like to learn them more with Advanced Programming Environment in Unix, but time is so limited and my interests shift so quickly.
elixir
Really, I didn’t learn elixir, just finished one fifth of Elixir in Action. It is yet another great book that I did not finish reading.
misc
Zhao
My loathing for Zhao’s country grows with every day. Never did I fell like more like a stranger in a strange land. The hatred I’ve harbored is becoming more and more explosive.
sleepless nights
I had quite a few sleepless nights. Here is what my day is like. Yesterday I was sleepless, and today I am worn out. So I go to bed. But not fall asleep so fast. Normally go to bed at 0:00, then at 1:00 or so I find out it is of no use to not play with my phone. At 3:00, I am too tired to play with my phone. At 4:00, or maybe 5:00, I fall asleep. Get up at 9:30 or so, eat something. Catch the bus or grab my bike to the workplace.
fiddling
I destroyed 2 phones this year.
Mi max
The first phone is Mi max. This phone was smashed a few times. The first the front screen was broken, I had it fixed. When the second accident happened, I decided to not care any anymore. I used it for reading, or rather I had planned to use it for reading. I want something like whisper sync. Syncthing is a great choice. Latter I find the phone unwieldy. It is way too big to carry, but still kinda small for pdf. Latter, the touch screen of this phone did not function normally any more. I tolerated it until the power button became unresponsive.
oneplus 3
The second phone was an oneplus 3. I am frustrated by shitty mi’s unlocking policy. Yes, it can be done with an application form. But I find the lengthy process humiliating. This phone was also smashed a few times. When it was only the outer glass that was broken, I compiled the Linux kernel to simulate it as a keyboard. My ecstasy for a portable keepass database didn’t last long. The second day, the phone’s inner LCD screen was destroyed.
failures
Things I failed to do - go abroad. I have used to solace self 大道如青天 我独不得出. - use up all the scratch papers. When I moved to the new house, I decided I wanted to use up all the scratch papers, but I didn’t. - 52 books challenge. I forgot to take notes on how many books I read last year, which automatically render my challenge failed.
a pagan to minimalism
I have brought a few things which makes me really happy for my financially quasi-independency.
- gregory baltoro 85. can confirm this is a great bag. Don’t know if it is the best.
- aoc monitor. The long long screen is disgusting.
- mobi garden tent. used it for only once. I definitely love it.
- mobi garden hammock. didn’t find any place to put up.
- muzino sneaker. latter I really love running in the morning and have some Les Rêveries du promeneur solitaire.
new year resolution
This is an obligatory new year resolution section.
This year, I accepted the 52 books challenges once again. Finished 10 as of Mar 3th. In the long term, I wish I can find a remote job, buying a vanhouse. I want to buy the following things this year.
- backpack for running. My current backpack is not very suitable for running.
- ebook reader powered by android. I want seamless sync.
- a computer. It humiliates me on the thought of having to do such such and such such for a few dollars less.
I want to read the following books or do the following projects (preferably in the same order). I will go to Phong Nha-Kẻ Bàng National Park upon finishing ten of the books below. I will go to any one of these places upon finishing twenty of the followings. I am going anyway. I just want to delay gratification.
- Functional Programming in Scala. Almost done. Some concluding work.
- Readings in Database Systems. Read one paper.
- 6.824
- xv6
- Real World Haskell. Both Getting programming with haskell and Learn You a Haskell for Great Good! can not compare this book in depth. Haskell Programming From First Principles is too long-winded. I intend to use this GitHub - tssm/up-to-date-real-world-haskell: I’m trying to update the Real World Haskell book.
- A Graduate Course in Applied Cryptography. Exercise is challenging. Last time I opened this book is a long time ago.
- Computation Complexity: A Modern Approach. Chanlleging.
- Computer Systems: A Programmer’s Perspective
- Computer Architecture: A Quatitative Approach
- Mathematics of Computer Science. Finished 3/5 long time ago.
- Algorithms: An Introduction.
- Understanding Machine Learning From Theory to Algorithms This book is pretty bad. Can’t find anything better.
- Foundations of Machine Learning. No good either. Complement to the above book.
- Foundations of Data Science
- Type-Driven Development with Idris
- Reverse Engineering for Beginners
- The Design and Implementation of the 4.4BSD Operating System
- Purely Functional Data Structures
- Compilers: Principles, Techniques, and Tools. Anders Hejlsberg said this book is somewhat outdated.
- Fluent Python: Clear, Concise, and Effective Programming.
- Handbook of applied cryptography. Just another storybook which is easier to digest.
- Structure and Interpretation of Computer Programs. Finished chapter 1 long time ago.
- Haskell in Depth. Not released yet.
- Parallel and Concurrent Haskell
- Advanced Programming Environment in Unix
- Elements of Information Theory
- Communicating Sequential Processes
- elixir in action. Finished 1/3.
Below are some books may be counted in the above list, but most likely will not be counted. - Discrete Mathematics Using a Computer - Distributed Algorithms (The Morgan Kaufmann Series in Data Management Systems) - Linux Kernel Development - Functional Programming for Mortals - Introduction to Automata Theory, Languages and Computation: Theory of Computation - UNIX Network Programming - Concrete Mathematics: A Foundation for Computer Science (2nd Edition) - Graphentheorie (Springer-Lehrbuch Masterclass) (German Edition)