Thursday, October 29, 2009

Emacs tramp mode vs. angeftp

Looks like I had it completely wrong!

Emacs tramp mode is really awesome. From windows if we use plink then everything just works, include things like vc-mode, make etc..

Wednesday, October 28, 2009

git-changelog

I like to use git tag to keep track of revision versions in my code. When I do deliver my code, its usually as a prebuilt binary with code, generated documentation and most importantly a CHANGELOG file. What does happen is that the entire .git tree is not shipped. (Hey, if you need the git tree, just pull off it. You don't need a release).

I tried git-log to generate a CHANGELOG but it does not give me a mapping to tags. So, here's a bash script that does that.


# Generate a nice changelog from git
PREV=
for I in `git tag`; do
echo " ";
git log --pretty=format:" %s" $PREV..$I;
echo " ";
echo $I;
PREV=$I;
done | tac > CHANGELOG


Works like a charm!

The difference between FILE* and FD

Obviously using fopen, fwrite etc... is a little bit easier especially since you don't have to keep track of the location in the stream, using plain old open, write etc.. also have their uses.

Consider this.. I want to write a test case which writes to a file over and over again. The idea is to write x bytes to the file, seek to 0, and repeat.

Problem is that this will not work when you use FILE pointers. It will work most times, except when the file itself has to be created. In which case, using seek to 0 does nothing, because every fwrite will automatically seek to the end of the file. So, fopen a new file will always open it in append mode.

Thursday, October 08, 2009

Its my baby

Started implementing my own stack based language. I have played a bit with factor and liked it, so I decided to base some things from it. I also have started to read a little more on forth and have now understood how some basic constructs can be created. Especially useful is jonesforth. The code is a must read!

So, the design goals I have in mind are as follows.

  1. Must be in embeddable in C. My main goal here is to be like Lua. A small library that you can call from C. The main users of this language would be hardcode C programmers esp. on embedded linux and embedded linux system testers. 
  2. Must be written in ANSI C. Factor implementation has moved to C++ and also has a lot work going on in creating a fast and optimizing VM. I don't have that goal, as I want to be able to port my language very quickly to different hardware. The easiest way to port? Just recompile. Obviously, you lose out on some performance, but that's ok. The target audience will code most of the fast bits in C anyways.
  3. Must be simple. System testers should be able to use this language very quickly to write small tests. The main part of the test application itself would be written in C, but the scripting part would be in this language.
  4. Support for quotations, sequences. Ideas from Factor (and lisp) and good ones too!
  5. Reader macros would primarily be from C. 

So far, I have the basic language working. It supports numbers, strings and quotations. You can define your own "words" and run them. There is a "if" control structure and a "loop" control structure. The implementation is still very buggy though. 

Will keep posting as I progress.