The computer language “immediate C”

The programming language “immediate C” or iC is a declarative, event driven extension of the procedural language C – useful for control and robotics and for dealing with events generated in a GUI.

iC utilizes the syntax of C to give meaning to statements that have no semantic support in C. In addition to standard variables, which are modified by the flow of instructions, iC provides so called ‘immediate‘ variables, whose values are updated, whenever a change of input calls for an immediate change in output. An efficient Data Flow technique implements this strategy.

iC provides programmers with built in operators, whose function is closely modelled on integrated circuits. The name iC is a reminder of this fact. Logical AND, OR, EXCLUSIVE-OR and NOT as well as D flip-flops, SR flip-flops, shift registers and many others are implemented in such a way, that their use in iC follows the same design rules, which apply to their hardware counterparts. These rules have led to a well-developed hardware technology, whose effectiveness is demonstrated by the success of today’s complex computer hardware. Particularly the concept of clocked functions plays an important role in the language iC. It gives the same protection against timing races in iC programs, as it provides for hardware IC designs. But iC is not a hardware description language nor a simulation language – it provides the functionality and some of the speed of field-programmable gate arrays to C programmers.

Writing programs in the language iC has the added quality, that many simple ideas and relationships, which should result in direct actions, can be written down immediately in one line. The coding of call back routines and other overhead is not required. It was this thought, which also prompted the name “immediate C“. The following is a fully working iC program. The output message is triggered by the external switch IX0.0.

 if (IX0.0) { printf(“hello, world\n”); }

The design of immediate C was very much influenced by thinking about biological neural networks in the brain. How is it possible that such relatively slow chemical components as neurons and synapses can process such vast amounts of information at the speed that they do? The algorithms at the heart of the iC system are based directly on synapses and biological neural networks – not for artificial learning, but simply to gain speed.

An iC program consists mostly of a series of logical and arithmetic expressions, each expression declaring the relationship between some external inputs and/or intermediate variables on either another intermediate variable or on an external output. This type of program and functionality is very similar to that of an industrial “Programmable Logic Controller (PLC)”. In iC, these expressions are not executed in sequence as is the case for all instruction flow languages, including PLCs, but only when an input to one of the expressions changes. The fundamental assumption for iC is, that the output of an expression does not change if none of its inputs has changed and therefore does not need to be executed until one of its inputs does change – but then it should be executed immediately (at least as soon as possible). This strategy gives iC an enormous speed advantage over PLC’s, which execute every instruction in the program sequentially.

Here is an example of a simple iC control program for a water heater with external inputs on, waterLevel, temperature; intermediate variables waterLo, tempLo and external outputs fill, heat, ready:

 imm bit on; // & is AND, ~ is NOT in iC
 imm int waterLevel, temperature;

 imm bit waterLo = waterLevel < 90;
 imm bit tempLo  = temperature < 98;

 imm bit fill    = on &  waterLo;
 imm bit heat    = on & ~waterLo & tempLo;
 imm bit ready   = on & ~tempLo;

If these expressions were placed in an instruction flow environment, each of the expressions would have to be executed over and over at regular intervals, because that is the only way to catch a change in any of the inputs to an expression. This is what an industrial Programmable Logic Controller (PLC) does. The polling interval determines the maximum response time of the controller. But this response time must always be a compromise between the total number of control expressions, an acceptable response time and an acceptable CPU loading. For PLC’s the CPU is 100% compute bound and even then there is a limit to the number of expressions that can be tolerated before such a controller becomes too slow.

Each of the above variables in the iC environment is an immediate variable. bit and int immediate variables are objects, which have a value, but each such variable also has a list of pointers to those expressions in which the variable occurs. Each of these variables, which have one assignment expression to determine their value, is called a Node and the pointers associated with each immediate variable Node object link these nodes into a network, much like a neural network, where the expression nodes are the synapses and the pointers to other expression nodes are the dendrites. This forward action of signals from one expression node to the next constitutes the basic data flow strategy of the iC system, which was copied from biological neural networks.

The Analogy to neural networks is even closer. Synapses fire when a certain threshold is exceeded at which time a signal flows through a dendrite to another synapse. Each AND or OR bit expression in iC is implemented by majority logic in which the number of hi inputs are counted. When the number of hi inputs reaches a threshold (just like in a synapse) the expression node fires, at which point it executes a similar action in the expression nodes on which it acts (in which it is an input). The only difference between an AND majority node and an OR majority node is the threshold, which is set once at initialisation of the system. The threshold for an OR expression node is 1 – only 1 input hi fires the node. The threshold for an AND node is the number n of its inputs. All n inputs of an AND node must be hi for it to fire. It only takes a few machine instructions to execute this algorithm. The upshot is, that the internal response time of the iC system is in the order of fractions of a microsecond for modern CPU’s, even for control programs with thousands of node expressions. Most of the real response time is in the drivers, getting inputs and outputs from and to their electronic connections. The CPU loading is generally well under 1%.

Another way to view the run-time model for iC is to think of expression nodes as digital or analog IC components, interconnected by their forward pointers. Keeping this view in mind may make programming iC easier. Even such concepts as Large Scale Integration (LSI) are catered for with so called ‘function blocks’, which allow the programming of groups of interconnected expression nodes into a sub-assembly with a list of parameters for connecting to the rest of the iC program. Such function blocks look very similar to C functions, but their execution is very different. C functions execute their instructions each time they are called. iC function blocks are templates, which are cloned for every instance in which the function block is used (not called). Each instance has its own internal expression nodes which only execute when one of their inputs changes.

To start with immediate C, have a look at the  immediate C Programming Manual in the Books section of this site, which starts with a tutorial introduction of the language in the style of the K&R C Programming Language, building up from there discussing all the features additional to C. The immediate C Reference Manual describes the iC language and its built-in function blocks in detail. Several small but important features have been added to the language in the last year and both manuals reflect these changes.

On a Linux system and particularly on a Raspberry Pi you can clone the whole GIT repository from or download the ZIP file of the latest release from the same GitHub site and try your own iC code very quickly.

immediate C is built with the usual configuremake – make testmake install commands. The README explains the details and how to make, run and debug iC apps.

A full Integrated Development Environment (IDE), with a full editor, buttons to build and run one or more iC programs in parallel and debugging facilities is included in the distribution A debugging facility called ‘Live display’ shows the state of iC variables of a running program by changing the colour of those variables in the program text. (This facility is standard for PLC’s and factory personnel would be very familiar with it). Another debugging facility are Watchpoints, which stop execution when any marked immediate variable changes or reaches a certain value and the ability to single step the code a single change at a time. This is more common for instruction flow language debuggers with Breakpoints, but the ability to freeze a program and look at its state while things are not changing makes testing iC code much easier.

immediate C can execute direct Input/Output on a Raspberry Pi computer. Drivers are included for digital I/O on GPIO’s and PiFace cards as well as a driver for PWM analog output on GPIO’s and analog input from an MCP3008 A/D converter. See README.RPi for details.

Author: John E

Retired software engineer interested in real-time control systems and languages. Developed "immediate C", a language for high speed control and robotics.

30 thoughts on “The computer language “immediate C””

  1. You really make it seem really easy along with your presentation having said that i
    find this topic to become actually something that I feel I would personally never understand.

    It appears to be too complicated and very broad to me.
    I’m anticipating for your post, I’ll try to have the hang of this!

    1. I am currently writing a Programming Manual, called the “iC PROGRAMMING LANGUAGE”, based on the style of Kernighan and Ritchie’s “C PROGRAMMING LANGUAGE”, with a similar easy Tutorial Introduction. The work embodied in “immediate C” covers 60 years of experience as a design engineer, starting in the telephone industry, working with electro-mechanical relays followed by switching systems using vacuum tubes, transistors, DTL, TTL etc integrated circuits followed by computer automation systems using home grown real time operating systems from the late 60’s onwards.
      I have included different aspects of all the different hardwares I have used over the years, crystallising them into am EASY TO USE computer application. The basic principles must be understood and are, I believe, quite simple. There is plenty of extra functionality in the system to allow engineers and programmers to do amazing things with the iC system. I have recently implemented a control system for a mechanical model of an elevator system built from Meccano parts by a friend. I will be posting pictures and a YouTube film of that shortly.
      That exercise proved to be quite challenging for me, although I wrote the system. There is a big difference between theory and doing. We all have to learn new Programming Systems by DOING. Hopefully you will find it enjoyable and not too frustrating. I have made a big effort to provide useful error messages to help you.

  2. Thank you for providing an exceptional opportunity to check tips using this site. It really is excellent and also brimming with fun for me personally in addition to my office colleagues to visit your site at least 3 times in 7 days to study the fresh advice you have. Two tips on this page are the most beneficial we have all ever had.

  3. I am now not positive where you are getting your information, however good topic. I must spend some time learning much more or figuring out more. Thanks for great information I used to be looking for this information for my mission.

  4. Wonderful blog! I discovered it while surfing around on Yahoo News.

    Have you got any tips on how to get indexed in Yahoo News? I’ve been trying for some
    time but I never appear to arrive there! Appreciate it

  5. Pretty section of content. I just stumbled upon your weblog and in accession capital to
    assert that I get actually enjoyed account your blog posts.
    Anyway I’ll be subscribing to your augment and
    even I achievement you access consistently rapidly.

  6. I’ve been surfing online a lot more than 2 hours today, yet I never found any interesting article like yours.
    It’s pretty worth enough in my opinion. In my opinion, if all site owners and bloggers made good content as you may did, the internet will be far more useful than before.

  7. Simply want to say your article is amazing. The clarity in your post is just spectacular and i can assume you
    are an expert on this subject.
    Thanks a million and please continue the rewarding work.

  8. Interesting. I have developed something similar using the Observer Pattern, but using old VB6. The overall performance is simply great: the time involved in the propagation is marginal compared to the time involved in computions of complex algorithms.
    I will give a try.
    Well done.

    1. When you say “the time involved in the propagation is marginal compared to the time involved in computations of complex algorithms” I assume you mean that event driven execution is much much faster than using algorithmic approaches to handling external and internal actions (events) for control purposes. That is undoubtedly the case.
      Please drop me a line by a comment here or email of your experience with immediate C.

  9. I think this is one of the most important information for me.

    And i am glad reading your article. But wanna remark on few general things, The web site style is perfect, the articles is really great : D.

    Good job, cheers

  10. I’m not that much of a online reader to be honest but your sites
    really nice, keep it up! I’ll go ahead and bookmark your website to come back later on. Cheers

  11. Nice blog right here! Additionally your web site a lot
    up fast! What host are you the use of? Can I get your associate link for your host?
    I desire my web site loaded up as quickly as yours lol

  12. Thanks on your marvelous posting! I truly enjoyed reading it, you can be a great
    author.I will ensure that I bookmark your blog and will come back in the foreseeable future.

    I want to encourage you continue your great writing, have a nice evening!

Leave a Reply

Your email address will not be published. Required fields are marked *