Home iKnow Main menu

    > Home > Blog > C* - C Star
separator


C* (C Star)

C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language.

C++ support multiple programming styles like procedural programming (similar to C), object-oriented programming and generic programming (templates).

C* focus on procedural and object-oriented programming, inspired by Embedded C++.

The following language features have been removed in Embedded C++
- Multiple inheritance
- Virtual base classes
- Run-time type information (typeid)
- New style casts (static_cast, dynamic_cast, reinterpret_cast and const_cast)
- The mutable type qualifier (used on class data member to make modifiable even if member part of const object)
- Namespaces
- Exceptions
- Templates

The only exception to this list for C* is the use of namespaces for better organization of the code. Bjarne Stroustrup (C++ inventor) also wanted to keep this, as it gives no runtime overhead in space or speed.

Removing the use of templates is probably the decision with the biggest consequences. Templates are very powerful, and can give you extra performance if used correctly. The standard template library also gives you many useful utility classes. However, templates are very complex, are very different from the "traditional" C/C++ syntax, and very often increases the compilation time significantly.

By removing the generic programming (templates), using object-oriented programming for the AI Framework primarily, and using procedural programming (using framework objects) in the application code, the development is simplified and more focused.

To obtain the fast feedback cycle of scripting languages we removed templates and optimized the organization of the source/header files. Changing a single file and re-compiling is performed in less than 2 seconds, giving a very fast feedback cycle.

In addition to removing C++ features, the C* "language" has some other additions and features like:

- Command Guards: Wrapping individual commands with commands like aia and aib to automatically check for error codes and jump to error handling or cleanup.

- Design by Contract: Using pre- and postconditions to verify that required conditions are met for running a procedure, and verify that the procedure did what it was supposed to do before exiting.

- Aspect-oriented programming (AOP): AOP is used for cross-cutting concerns such as identification of each module, automatic tracing and logging, error handling and additional metadata when debugging. AOP is used for inspiration and as a convention, meaning it is fixed rather than dynamic (to avoid the downsides of AOP).

- Error handling using error codes and conventions (aih, aie, AIE, AICleanup etc) to make it easier to use and more consistent.

The AI Framework

Inspired by the research done for Python and other scripting languages, the AI Framework is a very ease-to-use wrapper for Win32 that provides higher-level abstraction and "requires less code to do more".

The AI Framework also provides three powerful datatypes for strings, lists and maps/dictionaries that are often used in scripting languages (and which are also in the removed Standard Template Library).

Example code (AI Framework level – lower level code):

Notice the use of colors in the code. There is one example bug here – it should be very easy to spot due to the use of colors. Comments are very subtle and "out of your way" because of the dark color.

AIA (assertion) is a Design by Contract pre-condition that must be valid and will result in an error if not. In this example it is acceptable with an empty in-string, so we use AIB (barrier) instead of AIA to jump out of the function without an error.

aih will check the handle, and aie will check error codes and jump to error handling if incorrect. AIE is shorthand for an empty AIErrorhandling (and AIC is shorthand for an empty AICleanup).

Example code (C* level (application) – higher level code)


If you look at the two code samples, you’ll notice that they’re a bit different. The first example communicates directly with Win32 (CreateFile, ReadFile etc) and uses additional error checking and handling (AIA, aih, aie, AIE, AICleanup) that the second example does not use.

The first example is part of the AI Framework, and it is therefore very robust and error-safe.

The second example is the "application code", and is easier to use and read. It uses the powerful datatype AIString, the standard object Ribbon, the global variable structure r (r.Zoomsize) for registry values, the global ribbon control font_zoom_list (g.ribbon.font_zoom_list) and calls the function refresh which is part of the Main::editor namespace.

It also calls the Win32 function UpdateWindow directly (it could have used winApp.Form.Update () instead, but this demonstrates that you can use Win32 directly if you want to). In addition, it uses the built-in macro is which is used for emulating named parameters (the order of the arguments is still important, but it makes it much easier to describe what a certain parameter means).

The combination of C* "language"/embedded C++, AIFramework, standard objects and use of conventions results in an "emulated" Very High-level language enabling great programming productivity combined with the speed of C/C++.

External links

- Teach yourself programming in Ten years
- Language Wars (Joel On Software)
- Wasabi (Joel On Software)
- Succinctness is power (Paul Graham)
- Making wrong code look wrong (Joel On Software)
- Objecting to Objects
- What makes a good programming language ?

- If programming languages were cars... (fun)

About

My name is Atle Iversen, and I'm the founder of PpcSoft (read more).

Contact me at atle.iversen@ppcsoft.com

RSS feed

Most popular

KM 3.0: This time it's personal
PKM, filtering and Information overload
iKnow vs. OneNote vs. Evernote
The power of checklists
Synchronizing multiple computers

Latest articles

iKnow 2011 released !
The Memex

Windows Development
Programming Productivity
C* - C star
iKnow minor update
iKnow and information overload

Using iKnow for movies
Using iKnow for research
Efficiency and Scalability
iKnow for Mac/Linux
E-learning

PKM, filtering and Information overload
Note: Grammar Mistakes
PpcSoft iKnow Help
Price, service, features
Note: Life

Yellow notes
Note: xPeople
Usability: Full-text search
Personal Wiki
Usability: Font size

KM 3.0 Part IV: A practical KM system
KM 3.0 Part III: The KM process
KM 3.0 Part II: The value of knowledge
KM 3.0 Part I: What is KM ?
KM 3.0: This time it's personal

Usability: Incremental search
Synchronizing multiple computers
Note: First Aid
iKnow vs. OneNote vs. Evernote
Wikipedia + Google = iKnow

Usability: Copy / Paste
Note: Poems
Note: Google
Usability, Simplicity, Productivity
Productivity Secrets

The power of checklists
Capturing vs. Sharing knowledge
Second-sibling problem
Note: 2Do
Note: Creativity

Note: Productivity
E-mail
Information overload
Productivity
Enterprise 2.0

Personal KM
The Greatest Thing
Social Media
The Answer
About





Copyright ©2002-2012 PpcSoft. All Rights Reserved. | Sitemap | Contact Us