Programming

A Nice C++ Linked List

I had reason to brush up on my C/C++ skills a bit and did something I've wanted to do for some time: implemented a nice encapsulated linked list. Read more for the source.

Threads Cannot Be Implemented as a Library

A paper by Hans Boehm demonstrates why vicarious multithreading, through library implementations (such as Pthreads), in languages like C and C++ can never be 100% correct.

The Joys of “perl -d:DProf”

I am working on my thesis for an MS in computer science, and my topic is finite automata. It is being done in Perl, and once I finish what I am doing I will be sure to release the details. I promise it is not Earth shattering. It seems like the more low level I get into CS the more I like it....anyway, on to the subject.

I discovered the joys of perl -d:DProf, and was able to drastically improve performance for RE->to_nfa by only changing state names if there was a clash and only sync’ing the epsilon symbol if they were different. This netted a 300% peformance gain when converting fifty 32-character regexes. Granted they were randomly generated and contained varying degrees of nested expressions, but it is still a great result!

Generic Specifics

Templates!! Aaah, we have all heard that name. But, have we ever used it? Well, I hadn't until recently, when during work, I was asked to generate a generic piece of code that can manage records. Please NOTE, this is NOT Siemens proprietary and it is just a simple record system asked by my mentor to start off my training skills. But, to be on the safer side, I will not post the code here HEHE!! :D

The objective of the record system is to be as scaleable, reusable as possible. So, obviously, Object Oriented programming is the solution to that problem for it to be reusable and scaleable. Now, how can it be generic enough that the record can manage ANY type of data?

HELLO TEMPLATES!!! Never fear, the templates are here. A beautiful concept of generic programming starts with something known as templates. It's a very simple concept as well. There are two types of templates - FUNCTION TEMPLATES AND CLASS TEMPLATES.

For the people who are aware of and use STL and MFC Container classes, STL's are THE example of function templates and Container Classes are the example of a class template.

So, what is this thingamajig ya call template? Well, lemme elaborate with a simple example - the tried and tested and easy to understand example of a max function!! We have in all probability used the max(x,y) function, where the function will return the larger of x and y.

Now, in C++ we used to generate overloaded functions of max(x,y) for the various data types, including user defined types. So what did we do to save time? Copy, Paste, Find, Replace and all the editing works that the editor provides us, and those of us who are seriously demented wrote a piece of code to replicate this and change it!! Hehe. Anyhoo, there is a much simpler way to do this using the concept of function templates. Aaaarrrrgggghhhh!! Ya keep talking about this damn thing - templates, when are you gonna show us how it looks? Well, here it is...

template /*Actually you are supposed to use the jargon "typenames" instead of class, as in template */
T max(T x,T y)
{
if(x > y)
{
return(x);
}
else
{
return(y);
}
}/*End of code*/
So, there it is mates! Now, all you need to do is call the function as you would normally ANY function. Reference it with its paramenters and BOOM, it works. You don't have to overload it for the enormous amounts of primitives.

The only thing extra you need to do to make it work with user defined types is to overload the ">" operator and BAM! there ya have it, a perfectly reusable piece of code.

Some Interesting things about templates :D!! Well, we know that code reuse is present in C++ through inheritance. When you think about it, some simple differences between ala Template and ala Inheritance.

Ze main difference is in how the reuse is happening? Templates are a sorta macro substitution of the typename to generate code for that typename whereas, inheritance is the code reuse across inherited classes. [PLEASE NOTE: It's more complicated than macro substitution and has proficient error checking during compilation].

So mate? Got 'e general 'dea o' 'em 'emplates? k?? Enough of Hagrid talk... let's get on with Class templates, where templates can be used to contain data and attribute and reuse them across the same functionalities across varied data types. :)!

As it's gonna take some time for me to code the damn thing and format it in html and I have to add more functionalities to the record system, I was talking about, lemme take leave now. But, to come back and prolly give another quill at class templates. More and more interesting things are taking place with programming.

On a high and mighty note, I am being put into development in SISL. It's an amazing place, highly knowleadgeable people, totally friendly and comfortable working environment :)!

Until next break... ENJOY!!!\:D/

---
As Always
Guru Panguji
http://members.lycos.co.uk/gurupanguji/

C++ : Operator overloading assignment operator

An exercise in writing the assigment operator for a class. Discusses to a good extend C++ memory management and exception handling.

The Anatomy of the Assignment Operator - by Richard Gillam

Comega

[img_assist|fid=72|thumb=1|alt=Microsoft Research]

Just stumbled upon "C Omega", a new data-oriented programming language developed by the Programming Principles and Tools group at Microsoft Research (UK). Cw extends C# by adding constructs that make it better at processing XML and relational data, with additional features for writing concurrent programs.

More -

Case Study: Rapid Development with Python

It's been said all over the web planet: Python is the best programming choice when it comes to rapid development. You want something done well now (as opposed to done a week later shoddily): use Python. I'll present here a case-study describing exactly how Python delivered in an instance.

COBOL, Live and Kicking

[img_assist|fid=58|thumb=1|alt=Application]

Contrary to what many believe, COBOL is not dead *shudder*. Apparently, code written for this beast of a programming language is too valuable to be discarded, and according to Micro Focus' survey, it still tops the chart as the programming language of choice in Mainframes.

According to preliminary results of Micro Focus' survey of 750 mainframers in the U.S. and Canada, 41% name COBOL as a principal programming language by an approximate 25% margin over Java, the next most popular language. Preliminary results also find 52% of mainframe applications are still written in COBOL.

What's hot as a mainframer is not just the ability to write COBOL code but also to be able to integrate it with newer frameworks such as .NET, J2EE etc. Universities have begun to include COBOL in their syllabus.

COBOL skills needed in the future

GCC 4.0 Review (not from me)

Just a side by side comparison with 3.4, but still a good read. I'd personally like to see some reviews on the autovectorization and sms features, but who has the time ;). http://www.coyotegulch.com/reviews/gcc4/index.html

Fortress

The "Next Java" is in the making. Fortress, a new programming language for scientific computing is being developed by a team of researchers led by Guy Steele, in Burlington, Massachusetts. The project, a Sun Labs effort to come up with a new design for high productivity computing systems, is being partly funded by DARPA (Information Processing Technology Office). The language, Guy Steele claims, will do for Fortan, what Java has done for C. The effort is focussed on High Productivity rather than High Performance -

The difference? High performance is all about giving a problem to a machine and getting the answer, fast. With high productivity, the clock starts when you give the problem to the programmers.

Similar to Java, some of features include - Extensive libraries, Platform Independence, Security Model (Type Safety), Dynamic Compilation, Catching "Stupid Mistakes" such as out-of-bound array references, null-pointer derefencing, premature storage deallocation etc. Fortress is designed to be a growable open language, with support for managing large projects, and distributed data/control models. Of particular note is the default parallelism of "loops".

Fortress has various advances in syntax including Unicode support, enabling the code to look like mathematical expressions.

Fortress focuses on the needs of programmers who work in mathematical disciplines and disciplines such as physics and chemistry that rely extensively on mathematics.[..] For starters, the code looks like math -- math the way it's written on a chalkboard, with square root signs and exponents placed above the line.

Guy Steele (author of the Lambda papers, editor of the Hacker's Dictionary before ESR, co-creator of Scheme programming language, co-writer of the specifications for Java, '98 ACM Grace Murray Hopper award winner, etc.), is currently a researcher for Sun Microsystems Laboratories, working on the Programming Language Research project.

Links

Syndicate content