Metaprogramming in .NET 读书笔记 - 1

什么是 Metaprogramming (元编程)

元编程从字面上理解就是“能处理程序的程序”。

这里的“处理”,有两个意思。

一是“编写”、“生成”,最经典例子就是编译器,它将我们的所编写的高级语言翻译成机器代码。编译器就像建筑工人,将“蓝图”(高级语言)转化成“高楼大厦”(机器语言)。还有一个我们经常用到的就是“宏”(Macro)。我们可以在代码中使用预先编写好的宏,在编译期,宏会被自动展开成相应的代码。这样的好处是用机器带替人类劳动。

“处理”的另外一个意思就是“处理自己”,元编程让程序在运行时了解自己的状态,并动态的扩展并执行的相应逻辑。

当然,最高级的“处理”就是能完全代替人脑的人工智能。如果那一天到来,我们就距离生活在Matrix里不远了。

元编程的实现

元编程主要实现在编译期前后以及运行时。

元编程主要依赖于以下技术:

  • 代码生成(code generation)
  • 反射(reflection)
  • 汇编重写(assembly rewriting)
  • 表达式 …
more ...

Why do I quit Leetcode contest?

Foreword

The title is quite "Yin-ish" as it seems, but I'm not a "Yin-ist". You know what I mean.

Why I quit?

I did a quite a good job in Leetcode Weekly Contest, at least in my point of view. I won a 4th place and a 6th place in …

more ...

STUP - the Implementation (3)

throughput and window size

The wisdom of STUP protocol is all about the window size. The throughput of a TCP communication is limited by two windows: the congestion window and the receive window. The congestion window can determine how many bytes that can be send a simple piece of time …

more ...

STUP - Packet Structure and State Machine (2)

STUP Packet Structure

Brief Introduction of TCP & UDP Packet Structure

STUP pretend itself as a protocol at the Transmission Layer, but actually it's absolutely an Application Layer protocol. So before we start, I'd like to recall some knowledge of two important Transmission Layer protocol: TCP & UDP.

It is well known …

more ...

STUP - another (stupid) TCP over UDP protocol (1)

What is STUP?

STUP is the abbreviation of "Speeded/Secure Tcp-like Udp Protocol", which means that it's another TCP over UDP protocol.

Why TCP over UDP?

TCP is a network protocol for general purpose, and it's one of the most commonly used internet protocol on this planet. It is reliable …

more ...

WorkflowyMd Release Note

What is it?

I've writen several workflowy enhance plugins by UserScript. The very first one is show the full content of the note of a bullet. The second one is to show images under the bullet. Then I worked on the background image to make a more colorful workflowy.

Yeah …

more ...