Mctrain's Blog

What I learned in IT, as well as thought about life

Redexer and Ocaml

| Comments

上一篇博客是一个用ruby和OCaml写的Dalvik binary rewriter,它提供了unparse, htmlunparse, id, combine, info, classes, api, opstat, cg, cfg, dom, pdom, dump_method等功能,还可以自己扩展相应的功能,具体的可以参看它的github主页

redexer主要原理就是将.dex文件按照Dalvik Executable Format映射到内存中的数据结构,然后根据这些数据结果进行分析,可以达到比较高的性能。

这里主要想要说说OCaml这个语言。

OCaml的全称是Object Caml,是一个有OO扩展的函数式语言(Functional Language),看了看它的语法,和我们程序语言理论里面的那个simPL非常的像,也和当时学FP的时候讲的Haskell很像。

查了查functional language和imperative language有什么不同,在wiki上似乎有一个最大的区别在于:

It emphasizes the application of functions, in contrast to the imperative programming style, 
which emphasizes changes in state. The most significant differences stem from the fact that 
functional programming avoids side effects, which are used in imperative programming to implement 
state and I/O. 

然后在stack overflow里面有一个蛮经典的回答”When do you choose functional programming over object oriented ?“

stackoverflowans

另外,在OCaml里面有很多FP的特性,比如 static type system, type inference, parametric polymorphism, tail recursion, pattern matching, first class lexical closures, functors (parametric modules), exception handling, and incremental generational automatic garbage collection等等,这些会在之后对OCaml的学习中慢慢弄清楚来吧~

Comments