The H++ Core Language Features – Part IV

In this post, I’ll describe the support for arrays in H++.

Local arrays

TH++PL support local arrays up to two (2) dimensions, and dynamic arrays (using the new operator) of one dimension only. When you have the need for more dimensions, you just have to create classes with array data members, and then create arrays of these objects to solve the problem.

Local array of doubles
Local array of doubles

It’s equal to C/C++ when subscripting an array for an element or component:

array subscripting
array subscripting

Here is another example of a sorting algorithm, expecting an array of doubles; also note the Swap function expect references to doubles:

array subscripting
array subscripting

Dynamic arrays

Here is an example of dynamic arrays using the new operator, and a two dimensional local array:

arrays of integer types
arrays of integer types

You can also declare arrays as data members for your classes; to create dynamic arrays, is necessary to use the new operator. Let’s see the picture below:

data member arrays
data member arrays

Static arrays

The support for static arrays is weak, because I’ve not finished the implementation; you can create an static array of object, the constructors will be called as expected; but every time you enter the same function by calling it, the constructors for all these objects that belongs to the same array, will be called also. The correct behavior is to call the constructors once for all the static array objects. So I have to make it happen just once as expected. Let’s see:

static arrays
static arrays

Array of chars

Array of chars
Array of chars

Array of strings

 An array of strings is like an array of const char* in C/C++:
Array of strings
Array of strings

Constructor and Destructor call for Local Object Arrays

For local arrays of objects, and for dynamic arrays, the H++ compiler makes sure that the constructor member function is called for every object in the array in a sequencial order; when the function  terminates, the destructor member function is also called for every object in the same array in the same order.

In the next picture, there is an array of  TestIntegers objects, which also have array data members being accessed in expressions:

local arrays of objects
local arrays of objects

Object Properties

In H++, you can define properties to objects using the get: and put: declarations, like in the TestIntegers class:

Object Properties declarations
Object Properties declarations

 In the next post, I’ll describe the support for custom/user data types, so, see you in the next post!

The H++ Core Language Features – Part III

 

In this post, I’ll describe the language statements supported by H++, but before I enter in details, I’ll describe a little bit the support for recursion.

Recursive functions

Recursive functions are very useful for implementing the most popular algorithms like n! and recursive power; but for very CPU intensive algorithms like determining the Fibonacci numbers, it’s not a good idea. Let’s see some popular algorithms implemented in H++ using recursion:

Recursive factorial
Recursive factorial

 Other function implemented with recursion, is the recursive power, a divide and conquer algorithm:

Recursive power
Recursive power

It’s important to note the use of the div operator in this algorithm, the quotient cannot be rounded, and that exactly what H++ does when the result is a floating point number: it round the result.

Another complex recursive function is the Ackermman algorithm:

Ackermman algorithm
Ackermman algorithm

 

H++ Statements

And now, I’ll show the statements supported in H++; I won’t make reference in particular for the if-else statements, because are very clear.

The For loop

Like in C/C++ and C#,  here are variations of the for statement:

Simple for loop
Simple for loop

The for loop with no expressions, is the infinite for loop.

Another loop
Another loop

In the example above, you can note an instance of the class TestFloatingPoint, which implements the recursive power; the loop shows all the powers of base 2, from 2^0 to 2^32; the other loop, does not have an increment expression in it but in the loop body.

You can observe other loops in the following picture:

For loops and static functions
For loops and static functions

This picture also demostrates static functions in H++.

While and do-While loops

These loops are very common in C/C++ and C#; when you have a bool true as the expression of a while statement, that means an infinite loop, so you must pay attention to where you terminate the loop using the break keyword. To avoid breaking, you can use the continue keyword to specify that:

while and do-while loops
while and do-while loops

You can also use the break and continue sub-statements in the for loop.

Goto statement

I know we all hate the goto statement, but this little friend sometimes comes in hand to help you until you re-design or refactor some piece of code to avoid it; H++ also supports the goto statement like in the picture below:

goto statement
goto statement

In the previous picture, I created a loop based on goto statements, for demo purposes only.

A sometimes useful statement is the with block:

with statement
with statement

Actually, I’m not done with the implementation of this statement, because H++ only support l-value expressions in the with block; when I’m done with it, it will also support r-value expressions.

try-catch blocks

TH++PL also supports exceptions actually in a very primitive way (don’t blame me, the subject is not to easy to grasp and understand), but it works! What’s under the generated code, is Structured Exception Handling (SEH); my implementation of SEH will be decribed in later posts that talks about the H++ Compiler and its Code Generator. For now, let’s see some examples of using the try-catch blocks:

try-catch block
try-catch block

Another try-catch block, where you can see a breakpoint that won’t be catched by any debugger, because the SEH exception is being handled by the H++ try-catch block:

try-catch block
try-catch block

I think for now, it’s a brief and quick introduction to the H++ for those who already program C/C++, C# or Java.

In the next post, I’ll describe the support for arrays and object properties

The H++ Core Language Features – Part II

 

After introducing H++ in the previous post, is time to show the basic H++ declarations, and typical H++ integer, double and boolean expressions.

Constants

H++ supports local and global constant declarations; in the future I will make changes to the compiler to support constant expressions resolved at compile time. for now, H++ allows simple const declarations with a simple initializer.

Constant declarations (globals)
Constant declarations (globals)

Also in the image above, you can see that H++ also support enumerations and type definitions using the enum and typename keywords respectively.

In H++ the float and double data types have the same size: 64-bits; I made it this way, because I thought that there are actually no complains about the size of the data when refering to floating point issues, but for accuracy and precision. So, that means that for now, you can use any of these keywords to work with floating point expressions, having the same results when it comes to precision terms.

Integer Expressions

The H++ integer expressions are similar to that of C/C++ and C#; I also added the mod and div operators, to obtain explicitly the modulus and the integer quotient in an integer division expression. Let’s take a look at the picture below:

Integer Expressions - Part I
Integer Expressions - Part I

You can see the famous C/C++/C# post-fix and pre-fix operators for addition and substraction of 1. 

Another way to obtain an integer result from a division, is by using the conversion fuction ftoi (actually an H++ alias to the real function), like in the next picture below; it will give the same result as using the div operator; the difference here is the extra call to a conversion function to transform the quotient from floating point to integer conversion; this is exactly what the H++ compiler does when it finds a floating point expression being assigned to an integer variable or data member. The compiler also notifies the user using warnings, for possible loss of data or truncation when it is doing an implicit conversion in an expression.

Integer Expressions - Part II
Integer Expressions - Part II

Other types of integer expressions very used in complex algorithms, are the bit shift operators << and >>:

Shift operators
Shift operators

These operators are very useful to write CRCs, Cryptographic Algorithms, Compression Algorithms between others. Other operators used in these algorithms are: ^ (for xor), & (for and ) and | (for or) operators; they are all supported in H++.

The following picture, shows member functions that help in testing the integer operations:

 
Integer Expressions - Part III
Integer Expressions - Part III

Calling these functions can show exactly what is expected:

Testing Integer Operations
Testing Integer Operations

The first function called is the member multiple_assignments, which demostrates that H++ allows multiple assignments for the same expression:

Multiple Assignments
Multiple Assignments

Floating point support

TH++PL also supports all type of floating point expressions; so you can create any type of algorithms that requires high accuracy, having results in double precision format:

Floating point support
Floating point support

What helps a lot is the Math class in the H++ library (HppSL); this class provides the fundamentals for constructing any mathematical or financial algorithm.

Strings in H++

In H++ I decided to have a string data type; this data type behaves like a const pointer to char in C/C++ (const char*). The idea is that if you want a string that can be modified, you just specify an array of chars like in: char array[n]; and when you just want to refer to a constant string, you use the string keyword to create a constant string declaration. The array of chars will be described in other post special for H++ array support.

Let’s see the relational operators that can be used with the string type:

String expressions
String expressions

Boolean Expressions

H++ uses the keyword bool to allow declarations of type boolean, and the keyword true and false, which terminates as 1 and 0 in the end; let’s see some boolean expressions:

Boolean expressions
Boolean expressions

Another type of boolean expressions, are the ternary expressions; also you may see one dead expression used in this testing unit; the idea is that when I optimize the compiler, this expression will  be removed using the dead-code elimination technique:

Ternary operator
Ternary operator

In the next post, I’ll be talking about recursive functions and the H++ statements supported.

The H++ Core Language Features – Part I

 

As I promised, I’ll talk about the core language features of H++, spliting these descriptions in five parts, each with a separate post.

Now, let’s take a look of a simple H++ program:

H++ Hello World
H++ Hello World

This was the result of running the H++ Compiler against hello.hpp:

Compiling hello.hpp
Compiling hello.hpp. The compiler switches /cl for compiling and linking, and /A to ask the compiler for annotations in the Assembly generated code.

And this was the first time running of hello.exe:

Running Hello.exe
Running Hello.exe

Here is another more complex example, where you can see a new class Cotorra is being instanced in the main function, and the Listen() and Talk() methods are being called:

Little Complex Hello World
Little Complex Hello World
Running Hello2.exe
Running Hello2.exe

The keywords namespace and class have exactly the same semantic values as in C++ and C#:  for program organization. The keyword class let us create Abstract Data Types (ADTs are mathematic models with data and operations in the same place), which can also have descendants with different behavior from their parents; so that means that we can have concrete types with polymorphic behavior.

 In H++ we have single inheritance, encapsulation, abstract types (virtual abstract), polymorphism (virtual functions), properties (get: and put:), access rights or privilege levels for data members, and functions. Let’s see another example, to see inheritance, polymorphism  and properties:

 
Polymorphic types
Polymorphic types Polymorphic types

 

The H++ Standard Library (HppSL)

Let’s start talking about the H++ Standard Library (HppSL), as it’s the basic construction block to create H++ programs.

The H++ Standard library is based on the basic constructs that allows H++ programmer to create programs and libraries. The classes in HppSL belongs to header stdapi.hcc, as in figure:

H++ System classes
H++ System classes

The class System, is the principal class in the library, besides is not completed yet; these are the classes that belongs to it:

System:: Debug;   //for debugging purposes
System::Memory;  //it’s all about memory handling (allocation and release)
System::Exception;  //support for exception handling and types

These are the supported exceptions, based on the SEH types defined in winnt.h:

H++ SEH Exceptions
H++ SEH Exceptions

//classes that will be implemented as soon as possible
System:: Directory;  //OS directory support
System::Thread;  //Concurrency support: multi-threading programming
System::Synchronize;  //Concurrency support: locks and mutexes

The extern keyword, allows H++ to include in the compilation object files; so in the case of HppSL that means, that the implementation for each function is actually for external linkage, and that the functions are implemented in Assembly x86 32-bits anywhere else.

Console support

The support for console applications was my main goal because it was easy to implement; my next step will be to create a Windows library, which will take me more time (I’ve alredy created Windows Applications’ prototypes with basic functionality in Assembly 32-bit, to play a little bit with some of the Windows APIs I’ll be using to create the H++ Windows library).

H++ Console Support
H++ Console Support

File I/O support

I also implemented a basic file support class:

File I/O Support
File I/O Support

 

 Basic scalar types support


These classes implements the fundamental conversions between scalar types like double and integer; also the support for string types is also implemented partially:

H++ Basic types conversion functions
H++ Basic types conversion functions

 

 H++ Aliases

To avoid the problem of typing these long names when using the conversion classes, I decided to implement the using keyword (this feature was suggested by my friend Adonis) to overcome the problem:

H++ Aliases
H++ Aliases

Math support

The math library was implemented almost 95% in Assembly language, with a lot of FPU programming; portions of this library was also implemented in H++ itself:

H++ Math Library
H++ Math Library
H++ Math Library
H++ Math Library

 

Inverse Functions

H++ Math Library (Inverse Functions)
H++ Math Library (Inverse Functions)

 

Hyperbolic Functions

H++ Math Library (Hyperbolic Functions)
H++ Math Library (Hyperbolic Functions)
H++ Math Library (Hyperbolic Functions)
H++ Math Library (Hyperbolic Functions)

The H++ Compiler was written in C/C++, and the H++ Standard Library (HppSL) in 32-bits x86 Assembly. The H++ Compiler will have its own set of posts itself, when language description posts have been completed first.

In the next post, I’ll be talking about the different expressions supported in H++ as a programming language. I hope that this post have illustrated you the idea I have with H++ as a language. 

See you in the next post!

Some notes to Programming Languages and Pioneers

 
 
Before introducing the books I used, and the OOP and core language features implemented in H++, and its future implementations, I decided to first have a talk about some of the major contributors to design and implementation of programming languages, compiler design and others.

Pioneers in Modern Computing

 Almost all Object Oriented Programming languages, take the class concept from C++; but before C++, my favorite programming language (yes, still my favorite besides the new ones like Java or C# which I like very much), there was a tree full of programming language branches like Fortran, Algol, BCPL and Simula 67; the later is the one that influenced the most in OOP terms, to C++.

In Design & Evolution of C++, Dr. Stroustrup says: “C++ was designed  to provide Simulas’s facilities for program organization together with C’s efficiency and flexibility for systems programming….”. These words were the motivators to make H++ looks close to C++ and C#.

Is important to mention the big contribution, to at the time it was release, a new programming paradigm; like the one achieved by Niklaus Wirth, the designer of the Pascal Programming Language in 1968/69. This was the influence for a new generation of programming languages, and also the start point to Object Pascal (now Delphi), the object oriented version.

Dr. Niklaus Wirth
Dr. Niklaus Wirth

Brian Kernighan, also from Bell Labs,  a great contributor to software and programming, once expressed that Pascal was not his favorite programming language in:  Why Pascal is Not My Favorite Programming Language. My personal opinion is that Pascal, and also Object Pascal are great languages, but they are not my favorites, and I have to say that I’ve programmed using Pascal and Object Pascal for almost 3 years and half in Delphi.

Dr. Stroustrup once mentioned in his book Design & Evolution: “I had found Pascal’s type system worse than useless — a straitjacket that caused more problems than it solved by forcing me to wrap my designs to suit an implementation-oriented artifact….”; and more ahead in the same reading, he says: “Whether that harsh judgement on Pascal was fair and whether I would make the same judgement today (…) is irrelevant….I could not delete the fact, or modify it…”.

I think that these thoughts were well founded before the new Object Pascal and others similars.

Dr. Brian Kernighan
Dr. Brian Kernighan

Another languages that were the beginning of all this era, were BCPL  (BCPL to B to C), Simula 67, and the most influencer: The C Programming Language by Dennis Ritchie.  Almost all the innovations in programming languages have come from the Bell Labs.

Dr. Dennis Ritchie
Dr. Dennis Ritchie

At the end, the C and Simula 67 languages, were the most influencers, and the start point and motivation for Dr. Stroustrup to create TC++PL. The C language became a very famous and used worldwide, because of the success of the Unix Operating System. And C++ (TC++PL), also became famous and widely used, because of the flexibility and power of C, his ancestor. If you want to read more about these details, please visit this interview called:
The C Family of Languages: Interview with Dennis Ritchie, Bjarne Stroustrup, and James Gosling, where the designers and creator of C, C++ and Java, explains their points of view.

As this blog is about The H++ Programming Language, I should change now the context, but not before I mention some issues about C++.

The C++ Programming Language

I’ve already mentioned that the books Design & Evolution and TC++PL, are the authorities when it comes to C++; actually we have a new C++ standard coming soon called C++Ox, which by the way, all the C++ Experts will have to re-learn almost by complete, because it’s full of new language features and extensions, which makes it a really new programming paradigm; by including a lot of new core language features that extends C++ in Generative Programming to a new more powerful level. Also, the new thing is that the language will have multi-threading programming native (for each Operating System), which is a great deal to avoid writing different multi-threading code in each different platform.  It’s is a major improvement for a programming language, because it will be supported at the compiler level, and not library-based.

Dr. Bjarne Stroustrup
Dr. Bjarne Stroustrup

So, I have to say, that TH++PL was implemented using STL, IO Streams, and C++98, the standards that I’ve used. I’m actually not thinking about porting or moving my compiler to the new standard until I learn it and become and expert in the new one.

New C++0x Advanced Features

C++ is well recognized for letting good library writers to write good libraries. Now with the C++0x standard, you’ll be able to create real portable libraries between operating systems (I’m talking about the source code, of course).

As the C++0x team say, the goals for the standard are:

extend the language in new domains
enable programmers to write better programs
preserve source compatibility
the major C++0x features are:

  • Concurrency
  • Template concepts
  • r-value references mechanism
  • The constexpr (constant) expressions

The standard has not finished yet, and also compilers will not agree at first to implement these features yet.

 

C++0x Concurrency support

The language now supports concurrency, so that everything that you write in C++0x, will have a support for multi-treading environments. If you want to see the view the video, check the Advanced Topics in Programming Languages: C++ Threads directly from youtube.com.

Not all the C++ compilers will have these features faster, because the standard is still open.

You will be able to have effective internet programming, and also multi-core processor support on PCs

This is all done to make code more portable than never; also, C++ has new syntax and semantics that we should learn to dominate this huge and powerful language.

The C++ Threads now will be OS independent; so you’ll have this equation:

C++ Threads = OS Threads

These feature of multi-threading in the language won’t replace the current OS features; it will be just an accessability to make multi-threading programming easier.

You will still have the responsability to synchronize the variables, because by default they are not. But that’s ok; it’s not too bad. But the standard library will be very powerful.

These new language features appears to be very difficult to implement at first; it looks like that.

Now you’ll be able to write code like this for atomic access:

//to write atomically, and then release:

atomic_store_release(&value, 3); //from Thread1

….

//to read atomically, by acquiring the lock

int i = atomic_load_acquire(&value); //from Thread2

i += value;

….

As before, the libraries will have to implement memory fence to delimit the memory sides, to detect memory overriding that would be a plus, but is not really critical.

The data race condition will still exists, if you have two or more threads reading/writing over the same memory variables without these atomic operators.

They also have implemented basic atomic types like: atomic bool, atomic integers

and atomic voids, which you can apply atomic assignments (swap, writes).

But, to still preserve the C compatibility, there won’t be atomic assignment for all types,

but throught the atomic types or using the atomic operators for acquire and release.

They have a new template feature called atomic template, which allows you to have a non-

atomic variable instance behave atomic, like:

atomic < int* > aip = { 0};

aip = &value;

atomic < Circle > ac; //works, but not recommended

The type of locks are: lock-free, wait-free and address-free

C++ now will have fork and join like constructs that looks like instantiating a thread but

has nothing to do with threads except for fork and joins over specific functions or codes.

The mutexes supported are:

  • exclusive (single reader/writer)
  • shared (multiple readers, look a the Single Write Multiple Readers definition)
  • convertible (between exclusive and shared)
  • upgradeable (right to become the writer)

The lock to hold a mutex within a given scope, represents the mutex acquire/release template objects; the mutex is released in the destructor of the lock object; here is an example:

std::upgradable_mutex  _mutex;

void func1()
{
std::upgradable_lock  read_lock( _mutex);

//…do read operation
if(condition)
{
std::exclusive_lock write_lock(std::move(read_lock));
//…do write operation,
}

//when the function goes out of scope, the mutex is then released
}

They also have something called Condition Variables, where a thread may wait on a condition to complete before waking up and continue execution.

The exception supported was extended to add manual cancellation of exceptions;

The threads could now cancel at one point, wait on locks, wait on condition variables, join, wait an amount of time, others.

C++0x won’t have library support for threads to wake up on I/O, because of some weaknessess on the current Operating Systems; if you’ve used I/O Completion Ports in Windows, probably you know what I’m talking about, but this subject is out of the scope of this blog. Sorry.

I think that the C++0x Standard Library will be very complete besides minor points and exceptions.

C++0x standardization team says that for now, C++ won’t have Lambda support, because there is no way for implementation of these feature.

C++ will also support a very weird feature called future: you call a function and then later you can request the return value, or the exception that was thrown will be catched by all joiner threads, or the thread cancellation will affect all threads that are expecting the result from the future function.

 If you want to get more information about the C++0x Standardization works, please visit the C++0x Standard site.

 

C++0x Concepts

The concepts feature is all about typechecking for templates parameters, in a template declaration:

//Before:

template<typename _Ty, typename _Vy>
_Ty find(_Ty _F, _Ty _L, const _Vy& _X)
{
   while(_F!=_L && _F!=_X)
 ++_F;
   return _F;
}
//Now, in C++0x:

template<typename _Ty, typename _Vy>
   requires InputIterator<_Ty, _Vy>; //types requires this concept or constraint for using this template
_Ty find(_Ty _F, _Ty _L, const _Vy& _X)
{
   while(_F!=_L && _F!=_X)
 ++_F;
   return _F;
}
//Also, the concepts in declarations:

auto concept Regular<typename _Ty> //all the contraints are defined within this block:
{
  _Ty::_Ty(); _Ty::_Ty(const _Ty&); _Ty::~_Ty();
  _Ty& operator=(_Ty&, const _Ty&);
  bool operator==(const _Ty&, const _Ty&);
  bool operator!=(const _Ty&, const _Ty&);
  void swap(_T&, _Ty&);
}

concept InputIterator< typename _IIter, typename _Vy>
{
   requires Regular<_IIter>; // this is a contraint to be applied to the type in the template parameter _IIter
   _Vy operator*(const _IIter&);
   _IIter& operator++(_IIter&);       //prefix
   _IIter operator++(_IIter&, int);   //postfix
};
rvalue refs mechanism (note the double & for r-value refs):

Type a;
Type& a_ref1  = a; //an l-value reference
Type&& a_ref2 = a; //an r-value reference

Type& a_ref3 = Type(); //error!

Type&& a_ref4 = Type(); //ok

take a look at the next example:

template <class _Ty>
void swap(_Ty& a, _Ty& b)
{
   _Ty tmp(a); //two copies of a
   a = b;      //two copies of b
   b = tmp;    //two copies of tmp, now a;
}

This is now solved this way:

template<class _Ty>
void swap(_Ty& a, _Ty& b)
{
   _Ty tmp(std::move(a));
   a = std::move(b);
   b = std::move(tmp);
}

Also, was added a very important feature for optimization purposes, for data that will never change, thus the phrase of Constant expressions (using the constexpr keyword).If you wish to know more about the whole cool new features added to C++0x, take a look at the New C++ Features Video.

 

New Era of Programming Languages

Before entering my description of C#, a powerful programming language, for those who might think that C++ is dead, take a look at the list of applications created with C++, including Operating Systems, Databases, Compilers, CAD Software, Virtual Machines, others.

 

The C# Programming Language

Anders Hejlsberg, the most important designer and compiler writer for the Pascal and Object Pascal language, and the Lead Architect of the C# Programming Language, is actually the youngest pioneer of this brief list of modern programming languages. He is actually working on the latest specification of C# 4.0. If you want to know a little about the development of C#, please visit this interview called: Deep Inside C#: An Interview with Microsoft Chief Architect Anders Hejlsberg, and you will have a lot to learn of a language design and development team structure and project organization (I’m actually reading and learning a lot from this interview).

C# is a simple, modern, object-oriented, and type-safe programming language that combines the high productivity of rapid application development languages with the raw power of C and C++.

Anders Hejlsberg is the creator of C#, and he is always improving the design of this beautyful language (the second son of C++, as I call it), to make it more productive for users (developers) of the language and the .NET Framework.

I’ve been programming C# and .NET since Beta 2 of Visual Studio.NET, but actually I’m a little out of date of the new features. I stopped keeping track of the latest advances in C# and .NET since VS.NET 2003; so that means that I will have to read a lot about the latest improvements to the .NET Framework, for the Visual Studio.NET 2010.

This are the list of features from the birth of  The C# Programming Language (TC#PL):

C# 1.0, was all about Managed Code; C# was born, the CLR was created, and .NET Framework was ready with basic functionality, supporting both Windows Forms and Web Forms applications.

C# 2.0, Hejlsberg added the Generics feature, which allows you to do what you can do with C++: Generative Programming and Template Programming, but with managed code. This is a feature that I really appreciate because is one of the most important features I find in C++.

C# 3.0, the Language Integrated Query was added, so you can do queries to MSSQL Database server, using C# instead of T-SQL, so you can create assemblies for Stored Procedures compiled in .NET, to run in MSSQL.

The C# language and its framework, Imperative Programming which I love a lot, but requires a lot effort
Trends

Declarative Programming based on attributes, which ease the programming efforts to a minimum.

In C# 4.0, there are a lot of new features for this release:

  • Support for Dynamic Programming and Dynamic Languages: Better interface with scriptings like Javacript or Python code
  •  Support for Better interoperability with COM and Office Object Model
      now implemented default options in functions like in C++, and named parameters
  •  Now they have the Dynamic Language Runtime, which runs on top of the .NET Runtime to support the scripting languages, and the the dynamic codes

  I must say that I am not a big fan of dynamic languages or scripting languages and its type management; I prefer to write code to run native, because is 10-100 times faster than scripting code, and because syntax errors are discovered inmediately in the compilation process.

If you want to understand or get acquainted with this language, I recommend the book: The C# Programming Language.

 I’ve found that all the videos I’ve seen about the works of this language designer and compiler writer are fascinating, so I hope you think alike. If you want to know about software composability and the future, take a look a these videos from Anders Hejlsberg about the subject.

Anders Hejlsberg
Anders Hejlsberg

Anders Hejslberg talking about the new features for C# 4.0:

New technology for compiler writers to implement

I want to mention, that the new tecnologies are almost all oriented to Paralelism and Vectorization, and one crazy little thing called Multi core Programming; if you wish to learn a little bit about that, please read this chapter from the book on Multi core Programming from Intel.

Final Comment

I have to say before I finish this new post, is  that every programming language is designed to solve a particular set of problems, as Dr. Stroustrup mention  in D&E. So, that H++ should also has its purpose as a programming language too. But this idea also creates a new fact, and is that this is an Object-Oriented Programming Language (OOPL) created by a young dominican software engineer, and that H++ is the first OOPL created in Dominican Republic that I could testify.

I’ve heard of other compilers created in my country, but for the C Programming Language, for a specific micro-controller, with a reduced set of instructions. But H++ is targeted to the 32-bits x86 Intel Platform, and also supports double-prescision types like the Int64, and floating point type called double.

The next post is dedicated to the H++ core language features, where I will describe the important features briefly. But before ending, let’s sing with our master Bjarne Stroustrup this song:

I hope that you enjoy : No Time for Java!

We’ll keep compiling ’till the end!

See you in the next post!

 

The birth of the H++ Programming Language

As every new project or product that comes to light, once in the time, there was an idea to write a compiler for a well-known programming language. As the idea was evolved, the original one fade away, and comes back as a better one.

The H++ programming language (TH++PL) was born from my idea to create a C/C++ compiler of my own; so, as I’ll explain the motivation of this idea I had, I must also explain what did make up my mind while being in development.

The Original Idea

Dr. Bjarne Stroustrup
Dr. Bjarne Stroustrup

The C++ programming language (TC++PL), by Bjarne Stroustrup, was my inspiration from the first day I came up with the idea, and was the motivation to create a compiler for a language I adore and live for.

As a software engineer, I was always fascinated by the Object Oriented Programming paradigm, and almost all that has to do with OOAD. My first books I read on OOAD and OOP, were by Grady Booch, and James Martin and James Odell; these books influenced me on how to think when designing and developing OO systems and applications.

After I understood what is OOP and OOAD, I realized that I needed a powerful programming language like C++, which could allow me to write software with the more flexibility such as accessing the hardware, and at the same time, creating GUI applications, Databases, Compilers and Operating Systems. My selection was C++. But before I would become an expert in C/C++, I had to learn a lot of other programming languages like Pascal, TurboBasic, QBasic, Cobol, BBX, Object Pascal, Visual Basic, others.

My days programming Delphi (Object Pascal), happened from 1999 to 2001, where I learned from guys like J.L. Coronado, and Alexius Santoni, PhD. In the later, at ISaturno, S. A., I developed myself with SQL Database Programming (Microsoft SQL Server, and Sybase Adaptive Server), and a lot of coding requested every day from Dr. Santoni. I will never forget those days where I started gaining experience in OOP at a high level.

When I started programming C, I was still at college, but my knowledge of memory, data structures and algorithms, was not good in those days. So I was forced to get knowledge by reading a lot of books, and gaining experience by coding and error.

Suddenly, there was my first time with C++. I was amazed of the power I had in my PC at that time. So I started buying all the C++ books I could, beginning my journey to become an C/C++ Developer who can consider myself, an Expert.

My first books on C/C++ where the Thinking in C++ Saga (Volume I and Volume II), from one of my favorite writers, Bruce Eckel.  Design Patterns, I/O Streams, C++ String manipulation, STL, meta programming, and a lot of excercises; exactly what I was looking for.

As I was getting acquainted with C/C++, I’ve found the books The C++ Programming Language by Bjarne Stroustrup, and the C++ Primer by Stanley Lippman, which for me were the final stage to become an expert, because actually these books are still the authorities in C/C++.

At the moment, starting in 2001, I was working as a Software Development Engineer, for a local company called Innovatica, S. A. I was very proud to work with such great people, like Juan Castro (Adonis), Gilberto Molina and Jose Pedro Díaz. Those days, I dedicated all my time to become an expert in C/C++; as I was there to create software, I also had to study and learn C# and the .NET Framework, but that was also very cool for me, because C# has the same syntax borrowed from C/C++.

In 2002, I finished the college obtaining a degree in Informatics & Software Engineering, which allowed me concentrate myself in the topics of interest to me, like Compilers and Reverse Engineering.

In 2003, after these years learning computer science and software engineering at its higher level, I thought that I should make a tribute to C++,  by creating a compiler for this wonderful programming language.

That was the reason to create a compiler.

The Birth of H++

But, as I was reading Design and Evolution (D&E) of C++ by Stroustrup too, I’ve realized that I could not complete a compiler for such a huge programming language as C++, because as I did read, I understood that the time that will take me to implement such an OOP language (a language full of rules that must be respected because of the C++ ANSI/ISO Standards), would be to long to finish such a complex compiler.

D&E by Stroustrup 
D&E by Stroustrup
So, I decided to create a new programming language, which I called H++, using or borrowing the same language constructs that Dennis Ritchie and Bjarne Stroustrup used for their languages (C and C++ respectively). My idea was to make it look like C# or Java; to make the language a little bit different, I decided to add new language constructs found in other programming languages like JavaScript.

TH++PL is my personal research project to become a good computer scientist. The H++ Compiler will be described in full in the nexts posts, but first, I must write in particular of some of the books that gave me the skills and knowledge to create it. That will the subject of the next post!