Git Product home page Git Product logo

argent's Introduction

Hi there ๐Ÿ‘‹

I'm Abhishek Chakravarti, and I live and work in Kolkata, India. I'm currently working at Live After 60, where I have the opportunity to pursue my interest in developing web applications in the C programming language. I tend to believe that the C language can be used almost as effectively as higher level modern languages such as Python, and I'm grateful to have the chance to experiment with this idea at my work place.

I'm also very happy to be associated with the RefPerSys Project under the mentorship and support of @bstarynk. RefPerSys is a research project in Artifical Intelligence, building on the ideas of the late Jacques Pitrat. I've learned a lot from the RefPerSys Project, and find its goal of generating code on the fly using metaprogramming techniques particularly intriguing.

I use Arch Linux on all of my development machines, and manage production servers on Ubuntu Server virtual machines. Of late, I have become interested in FreeBSD, and have been exploring the possibility of migrating one of the key production servers I manage to FreeBSD.

From a philosophical standpoint, I appreciate minimalism, and perhaps this is one reason that makes a language such as C appealing to me. I also tend to believe that it's important that we consider the environmental impact of our source code, especially its carbon footprint. I realise that this is a very vague metric, but with so much power being expended on running data servers, it is certainly worth considering.

Dev Ops
Arch Linux C CSS3 Emacs HTML5 JavaScript Python Alpine Linux Debian DigitalOcean FreeBSD Git GitHub POSIX Shell Ubuntu Vagrant Vim
Doc QA
LaTeX m4 Markdown Pandoc Gherkin Pytest Valgrind

Abhishek's GitHub stats

Top Langs

achakravarti's wakatime stats

argent's People

Contributors

achakravarti avatar

Stargazers

 avatar  avatar

Watchers

 avatar

argent's Issues

Logging mechansim

We need a means to log information at runtime. The logging mechanism provides an interface for adding log messages of varying severity. Ideally, the logging mechanism would be a wrapper around the syslog facility.

Create FastCGI wrapper

Probably the most important feature of the Argent Library is its ability to handle the FastCGI protocol. We need a wrapper around the libfcgi API in order to simplify the handling of HTTP requests through FastCGI.

Create association list interface

Association lists (a-lists) are lightweight singly linked lists containing key-value pairs, and are useful in situations where there are only a few such key-value pair mappings.

Incorporate reference counting in memory block interface

Experience has shown that it is useful to incorporate reference counting directly into the memory block interface. This would simplify the implementation of string and object interfaces. The only caveat is the extra size_t bytes that are padded into each memory block. However, nearly every type that relies on dynamic memory would be satisfied by either an object or a string, this is an acceptable compromise.

Accordingly, we are revising the existing interface with the following functions:

  • ag_mblock_new()
  • ag_mblock_new_align()
  • ag_mblock_copy()
  • ag_mblock_retain()
  • ag_mblock_release()
  • ag_mblock_dispose()
  • ag_mblock_cmp()
  • ag_mblock_lt()
  • ag_mblock_eq()
  • ag_mblock_gt()
  • ag_mblock_sz()
  • ag_mblock_refc()
  • ag_mblock_alignment()
  • ag_mblock_resize()
  • ag_mblock_str()

We are choosing _mblock_ identifiers in order to avoid namespace collisions with the existing _memblock_ identifiers. The ag_mblock_retain(), ag_mblock_release() and ag_mblock_refc() functions are specifically related to reference counting.

References:

Fix bugs with http subsystem

While attempting to run a client application using the Argent Library, bugs are being detected in the HTTP subsystem. These need to be fixed as they are being detected.

Create HTTP request object

Object system

Experience has shown that having an object system is a very useful abstraction. The object system provides a reference counted object model that implements a simple copy on write mechanism for improving copy performance.

Create dynamic type system

A dynamic type system supporting both primitive types and ag_object_t instances would be very helpful in creating generic containers. The type system would be inspired by the one implemented in JavaScript.

Rewrite object interface

Now that we have improved memory block and string interfaces in place, we can take the next step of rewriting the existing object interface with the new code. We should also consider adding a valid() function to the object interface to indicate whether or not it is in a valid state. This may be particularly useful in the case of business objects.

Scaffolding for documentation

Documentation is an important part of this project, and I would like to explore the ideas that I have developed while working on the Live After 60 project. Although many documentation generators exist such as Doxygen, I have opted to use LaTeX owing to a rich feature set provided by it in addition to the flexibility and rigour that it entails.

In this issue, we need to create the general layout of the documentation, and the Makefile build target to generate the same.

Rewrite object v-table as shared hash table

Currently, every object has its own copy a struct ag_object_vtable. This makes objects relatively bulky. We can trim down the fat by sharing the struct among all objects of the same type. To do so, we need to introduce a type field to the object against which it can perform a lookup in the object v-table hash table.

Runtime checks

Runtime checks through assertions and a simplified exception handling system need to be introduced.

Unit testing

Although I don't follow a TDD approach, ensuring high coverage in testing is of prime importance. Although there are several testing frameworks available, I prefer to use a hand-rolled testing system that just fits in with the project workflow and keeps things comparatively simple.

Improve exception handling interface

The existing exception handling interface is usable, but experience has shown that it is a bit clunky and that there is room for improvement. The main improvement comes through creating a list that holds the exception handlers. This helps make both the existing exception handling interface and the client code depending on it cleaner.

Accordingly, we would revise the interface as follows:

  - ag_erno;
  - ag_exception_handler(erno, func, file, ln, void *);
  - ag_exception_init();
  - ag_exception_exit();
  - ag_exception_register(erno, msg, hnd);
  - ag_exception_msg(erno);
  - ag_exception_hnd(erno);
  - ag_assert();
  - ag_require();
  - ag_require_opt();

Rewrite value interface

Now that we have the memory block, string and object interfaces rewritten, we are in a position to rewrite the value interface to use the new interfaces.

Add backtracing support

  • backtrace()
  • backtrace_symbols()

Supported both on GNU/Linux and FreeBSD. Threads supported.

Add DSO wrapper interface

  • typedef void ag_dso;
  • ag_dso *ag_dso_load(const char *path);
  • void *ag_dso_sym(ag_dso *ctx, const char *sym);
  • void ag_dso_unload(ag_dso **ctx);

Create HTTP client object

  • ag_http_client *ag_http_client_new(const char *ip, const char *port, const char *host, const char *agent, const char *referer);
  • ag_string *ag_http_client_ip(const ag_http_client *ctx);
  • ag_uint ag_http_port(const ag_http_client *ctx);
  • ag_string *ag_http_host(const ag_http_client *ctx);
  • ag_string *ag_http_client_agent(const ag_http_client *ctx);
  • ag_string *ag_http_client_referer(const ag_http_client *ctx); [sic]

Memory pool

Heap memory management is essential, and I hope to eventually develop a memory pool system for use with this project. However, for now, the memory pool interface would simply be a wrapper around the standard malloc(), realloc() and free() calls.

Create HTTP server object

  • Manage FastCGI calls
  • Manage HTTP request plugins/callbacks
  • typedef void (*ag_http_handler)(const ag_http_request *req);
  • void ag_http_server_init(void);
  • void ag_http_server_exit(void);
  • void ag_http_server_register(const char *path, const char *dso, const char *hnd);
  • void ag_http_server_run(void);

Memory pool test cases

The test cases for the memory pool interface need to be prepared.

Edit: The memory pool interface has been deprecated in favour of the ag_memblock_t interface.

Compiler extensions

Experience has shown that a few of the extensions provided by GCC are quite useful. Wrapping them around macros provides a clean way to degrade them on compilers that do not support the GCC extensions.

Create HTTP URL object

  • ag_http_url *ag_http_url_new(bool secure, const char *host, const char *port, const char *path);
  • bool ag_http_url_secure(const ag_http_url *ctx);
  • ag_string *ag_http_url_host(const ag_http_url *ctx);
  • ag_int ag_http_url_port(const ag_http_url *ctx);
  • ag_string *ag_http_url_path(const ag_http_url *ctx);

Strings

Strings play a pivotal role in this project as they are used for exchanging data between the database, application and user interface layers. Since there is potentially a lot of copying of string instances involved, it would seem to be a good approach to implement them as a specialisation of the object model.

Create list container for objects

One of the benefits of having an object model is that we can create generic data structures. We need a singly linked list container for objects for situations where the number of nodes is few and the performance penalty for sequential access is acceptable.

Simplify logging interface

  • Introduce enum AG_LOG_LEVEL
  • Replace current functions with single ag_log_write()
  • Keep possibility of introducing ag_log_read()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.