分类: tech

  • Lua简介

    lua是一个很有意思的编程语言,我是用它写base64编码辅助工具时候发现的。

    lua是巴西里约热内卢大学的一个研究项目,最新版本5.1,真正变成一个人人皆知的编程语言还是因为魔兽世界这个网络游戏。因为暴雪选择了lua作为插件语言,一时间变得众人皆知。现在国内也有不少网络游戏使用lua作为脚本语言。

    (更多…)

  • 把脉-给自己做个技术“体检”

    看到了白乔的这篇博客“VC程序员的常见症状……”,感到颇有一些标题党的意味,因为他说的这些症状,我一个也没有,哈哈!不过倒是勾起了我写字的一些灵感。

    公司每年都会有一次常规体检,看看员工的健康状况,体检的好吃在于防患于未然,或者防止小病成大害。对于自己的技术,其实也应该经常的做做“体检”。

    ========  我的技术检查表 =========

    ****改进实施方法:阅读相关经典书籍及进行必要的实践。每个需要改进的地方都需要写出博客文章作为总结。

    ————————

    基础教育状况:

    我是95年上大学,计算机专业的本科和研究生,但是自己感觉是非常不足的。这个不足有学校的原因,主要还是自己不够努力,底子没有打好,很多专业课就是糊弄糊弄,比如数据结构、离散数学或者编译原理这样非常重要的基础课,基本上都忘得差不多了。

    ****评语:开始复习数据结构以及常用的算法,达到可以闭卷准确书写的程度。

    ———————-

    熟练技术状况:

    从2003年毕业到现在的这个公司工作,一直使用Visual C++做windows下的桌面开发。在此期间主要熟练于windows API、MFC、微软COM技术、C++基础、常用界面编程、调试技术、多线程编程。相关领域不太熟悉的是标准C语言编程、WTL、STL、数据库编程、网络编程。

    ****评语:在这方面自己近期比较注意,针对一些常见的技术难点写了几篇文章,但是还是不够深入,近期准备在网络编程方面多多学习补充(结合asio和libevent),另外对于QT的Signal和Slot机制做些学习。对于STL结合侯捷的书籍进行学习。其他方面待定。对于标准C语言编程准备结合后面的Lua代码阅读一同进行。

    ——————–

    一般掌握技术评估:

    对于Python、Php、Java,现在可以达到跟着帮助写代码,熟练程度一般。针对Discuz论坛做过一些hack动作,针对google appengine写了一些demo,另外使用ROME库练习解析RSS。

    ****评语:对于脚本语言和Web开发,由于公司当前没有相关开发,基本处于兴趣爱好阶段。现有的程度已经足够。这方面准备学习一下Lua(结合代码阅读)。另外有时间准备学习ROR。

    ——————–

    管理及软件工艺:

    紧跟当前的IT趋势,及时阅读中英文的新闻及博客,积极参与TopLanguage群组讨论,这方面做得尚可。

    ****评语:针对软件开发工艺方面,学习make的使用,了解Mercurial版本管理,了解Code view方法及工具。在自己开发项目中尝试引入unit test(google test)。结合对“四人帮”经典的阅读,复习设计模式Reading group学习的知识。

    ——————

    总的来看,自己的体检状况只能说很一般,很多地方需要补充营养,又给我的Todo列表加了不少项目啊。时不我待,立刻开始!

  • Intel x86 Function-call Conventions – Assembly View中文版

    我翻译的中文版本,比较粗糙,但是对于理解Visual C++生成的汇编代码很有帮助。

    中文版在线链接:http://docs.google.com/View?id=dcrhkvwg_159d8gpf4dx

    英文版链接:http://unixwiz.net/techtips/win32-callconv-asm.html

    One of the “big picture” issues in looking at compiled C code is the function-calling conventions. These are the methods that a calling function and a called function agree on how parameters and return values should be passed between them, and how the stack is used by the function itself. The layout of the stack constitutes the “stack frame”, and knowing how this works can go a long way to decoding how something works.

    查看编译后的C代码有一个大问题就是函数调用约定。这是调用方与被调用方约定好如何互相传递参数和返回值,以及函数自己如何使用栈。栈的布局组成了“栈帧”,知道这些如何运作需要一些脑力劳动去破译。

  • Profiling C++ performance in windows

    Profiling in software

    http://en.wikipedia.org/wiki/Software_profiling

    In software engineering, performance analysis, more commonly known today as profiling, is the investigation of a program’s behavior using information gathered as the program executes (i.e. it is a form of dynamic program analysis, as opposed to static code analysis). The usual goal of performance analysis is to determine which sections of a program to optimize — usually either to increase its speed or decrease its memory requirement (or sometimes both).

    continue to read online:

    http://docs.google.com/View?id=dcrhkvwg_124f7b38qfm

  • Useful code snippet : GetBit & SetBit functions

    If you want to manipulate the bit in BYTE array, following functions are useful to you.

    BYTE GetBit(BYTE* pBuffer, int nBit)
    {
        int bitOffset = nBit & 7;
        BYTE ret = pBuffer[nBit >> 3] >> bitOffset;
        ret &= 1;
        return ret;
    }

    void SetBit(BYTE* pBuffer, int nBit)   
    {
        BYTE val = 1 << (nBit & 7);
        pBuffer[nBit >> 3] |= val;
    }

    For the GetBit, nBit is the bit offset you want to test.

    nBit & 7 is equal to nBit % 8, it will get bit offset for input parameter nBit.

    nBit >> 3 is equal to nBit / 8, it will get the byte offset in Byte array.

    Why we use bit operations instead of mod and div operation? The reason is simple, for the bit operation, it will generate more fast and simple assembly code. You could see my build result like:

    ; 160  :     unsigned int modVal = i % 8;

        mov    eax, DWORD PTR _i$[ebp]
        xor    edx, edx
        mov    ecx, 8
        div    ecx
        mov    DWORD PTR _modVal$[ebp], edx

    ; 161  :
    ; 162  :     unsigned int andVal = i & 7;

        mov    eax, DWORD PTR _i$[ebp]
        and    eax, 7
        mov    DWORD PTR _andVal$[ebp], eax

    The code is generated by VC2008 and disabled optimization. For mod operation "i % 8", it has "div" and will be slow then "i & 7".