Tag-Archive for » programming «

Saturday, December 06th, 2008 | Author: ranok

I spent my birthday yesterday polishing up FANG for it’s initial release to the public, after adding some error handling so it would fail more gracefully and adding the ability to parse in files and save the current state of the system to a file for later retrieval. I also did away with the rather hideous use of the process dictionary and moved to an auto balanced tree structure for storing the data.

Over break, I’m hoping to add enough other features to warrant a 0.2 release, which I’d like to have support for soft-processes (ala Erlang), multi-node support and transactional shared memory (using Mnesia). I would also like to add permissions and process jailing for the soft-processes to allow for running untrusted code in a sandbox of sorts.

I’ve started a very simple (and ugly) site to put my progress and releases. You can check it out here and please comment with suggestions or other features you’d think would be a valuable addition. Good luck on everyone’s finals and projects! Have a wonderful break!

Peace and chow,

Ranok

Tuesday, October 28th, 2008 | Author: ranok

For the past few days, I have been slaving away working on my latest creation: FANG, a programming language that I’m hoping will combine some of the best features I’ve found in my studies and remove some of the cruft. It will have scheme/lisp like syntax and Erlang like processes, and some other neat features from other languages I’ve come across. After this weekend, I have a rough start which supports variables, lambda functions, and auto-memoizing clean functions. You can download the source from SVN (username = password = anonymous) and check it out. Please feel free to comment with features to add, or things to change.

Features I want FANG to have:

  • Clean scheme/lisp syntax and macros
  • Lightweight processes and multi-node support
  • Arbitrary precision number support
  • Process jailing and permission setting
  • Simple networking and file I/O
  • Others I’m sure I forgot…

Code Examples:

  • (defvar ‘fib (lambda ‘(n) ‘(if (< n 3) (1) (+ (fib (- n 1)) (fib (- n 2)))))) - A plain recursive function that automatically will get memoized, so it’s rather speedy (use dirty-lambda to turn off the memoization)
  • (defvar ‘max (lambda ‘(a b) ‘(if (> a b) (a) (b)))) - A simple max function used in findset
  • (defvar ‘findset (lambda ‘(l) ‘(if (== (length l) 0) 0 (if (== 1 (length l)) (hd l) (max (+ (hd l) (if (== 2 (length l))) 0 (findset (tl (tl l)))) (findset (tl l))))))) - A function for a homework assignment to find the highest weighted independent set in a path
  • (defvar ‘fact (lambda ‘(n) ‘(if (== 0 n) (1) (* n (fact (- n 1)))))) - A memoized factorial function

Peace and chow,

Ranok

Tuesday, February 26th, 2008 | Author: ranok

It seems that recently, many of my classes have touched upon threading or multi-processing in some way. After spending time programming in Erlang, where the creation on a process is very cheap, it’s interesting to see how strategies must be adapted in order to fit other threading paradigms (like pthreads). As part of the COSI server challenge (basically, spend an hour or so making a web server in the language of your choice), my Erlang submission merely spawns off a new process for each incoming connection. As I read further, I came across Apache’s MPM threading model and it made perfect sense: have a pool of threads waiting for incoming connections, then handle them as they come. This makes the server much more responsive as it does away with the need for spawning a new (very short lived) thread. Once I read this, it was as if I made a mental leap, and now I can see how simple and brilliant this is.

I guess to to conclude I just think that you should always be ready to make that leap and keep an open mind, just because it works, and you’ve done it forever, does not make it the best possible way.

Peace and chow,

Ranok