Sunday, January 23, 2011

How (Programming) Language Shapes Thought: Trip Down the Memory Lane

In my earlier posts I talked about interesting issue of how language you speak (may or may not) affect how you think.
How Language Shapes Thought
How Language Shapes Thought : Take 2

Being a computer engineer and an Agile Supporter I have to get back to my roots and passion: Programming languages and  how it affects the software life cycle.
Before I talk about how programming language can shape your thought. I must first confess how the whole tpoic has shaped and influenced my thoughts.  Where I come from and where I want to go ...

I was a passionate compilers freak in college days. 
I think I still am. I am one of those programmers who started coding in pre-internet era. Back in college days it felt like it was a privilege to get even a one hour of internet time each week. For most part we just coded and coded in turbo C.
Compiler was my favorite subject (with Computer Architecture equally appealing). As a final year college project I chose "Fortran Compiler for Java Virtual Machine". We defined our own IL,wrote an assembler for it, wrote "binary dumper and editor", and of course the compiler and also wrote a VB MDI application to provide the Visual Studio editor's cheap imitation.

Why fortran? Because we thought CDAC Param Super Computers guys might be interested. Well that never went too far beyond couple of meetings and we didn't followup either.

Recently I found the treasure trove of my own writings from my college days going back some fifteen years. My mom had kept all of the reams and reams of my hand written papers.It is an amazing experience to read those things.

Obsession in Two Stages
Back in 1996-97, I was obsessed with this idea of having a two stage  architecture where N number of languages could compile to common byte code,distributing it in that format and then installing/converting it to machine code of M different architectures.I have written reams and reams of paper describing the concept . I think I also wrote the specification for "my" virtual machine instruction set.
I was able to convince my friends to take the whole concept as our project and they helped me realize that idea back. We needed something concrete so instead implemented "Fortan compiler for Java Virtual Machine".
I got out of college, got the job and because of my exposure to compilers I got some project for testing one of the compilers. Years passed, projects changed ...And then I got another project involving something called COM 2.0 and COOL.
You can image my joy when I saw C# and .net for the first time. I was impressed with Microsoft.  I have to that Microsoft's C# guys have been consistently continued to impress me since then.
But it is kind of interesting to read some of my own writing after fifteen years and see how the idea progressed and how it still remains valid. In Indian education system publishing papers was never a goal. I wrote reams and reams of "papers" for myself  and back then it helped me in developing/clarifying those concepts. And I had time!!!

It is all about Syntax Sugar Stupid !
Programming languages are all about converting higher level abstractions into suitable low level constructs. Yes it is often syntax sugar but that is what compilers are for to make your job easier and fun. And make you productive and less error prone.

When I was in college I had another love affair.I wanted to create a new Programming language I used to call it Object Curry.
I was interested in another idea using SQL like syntax to manipulate object oriented data structures in the program. It was an awesome concept and I painfully  tried hundreds of syntax/semantics combination. I never got time to actually implement the language I spent so much time "Designing". Just Below are some of the scans of my written "papers" from those days.
(That must be at least fifteen years ago.)
Somehow I kept on switching between Pascal like syntax and C like syntax. There is something beautiful and "clean" about pascal like syntax and something powerful and natural about C like syntax. For most part they are equivalent. In that respect C# is actually clean like pascal and looks like C.
 Again you can image how happy I am to see C# finally getting those constructs. Personally today, I like to use the raw APIs themselves because they give so much flexibility.

It is interesting to compare "my syntax" with real C#/.net.
I had a  
for each (select_clause;from_clause;where_clause)
{//use variable names as you would use in normal case.}

I had this construct where I planned to change the meaning of the word enum to return a list of objects.
So you could do something like
enum x = {1,2,3}; 
enum y =  each(/*select*/ int a ; /*from*/ x; /*where*/ x%2 ==0);
for y { fn(y.a); }

Functional Beast. 
My notes/papers show that for some reason I was very interested in C having nested procedures .
I have to confess I always thought of delegate as simply a pointer to function and mildly amused by the closure concept. But I must say great way to pass a state machine.
Will talk about that in a next post.

Fast Faster Fastest:
 I also found many interesting things related to performance and concurrency.

Now that I have kind of enumerated what I used to think about in the past I will write about what i think about programming languages now in my future post.

No comments:

Post a Comment