Day 15: Use Meta Programming When Possible

Meta programming is a style of software development where one is able to modify programs automatically, based on rules that have been previously defined in the system.

For example, suppose that one wants to create a graphical interface based on simple specifications. The UI code may be written as a complicated C program, which makes it difficult to adapt the system every time there are changes.

A better way to solve the problem is to have a separate program that reads a simpler specification for the graphical interface and produces C code that implements the specifications. It may be a little complicated to write a program to read the specifications and write the code in C, but once this is done it is a simple issue of adapting the specification file, instead of rewriting the GUI code.

In meta programming, we are thinking about ways of avoiding writing software by converting simple specifications into real code. By doing this, a programmer can speed up development time, because now the changes can be made by the computer, not by yourself.

The number of bugs can also be drastically reduced, because you need only to check that the generation is of code is correct. Once this is done once, every time there are changes you can rely in the code generator to do the right thing.

Language Support

A few languages make the concept of meta programming easier to use. For example, Lisp provides macros as a standard facility to write code that will be directly read and compiled by the system. Prolog provides simple clause expansions that may be used to generate code as needed.

For more traditional languages, meta programming is not part of the normal development process. This doesn’t mean however that it cannot be used. In fact, more verbose languages such as C/C++ and Java are the best targets for meta programming, because we can avoid writing a huge amount of code with such a facility.

A well known example of code generation with C is the lex/yacc system for generation of parsers and lexical scanners. Instead of doing the laborious work of generating a parser in C or C++, one can use yacc to generate the repetitive parts of the program. Then, one can add only the code necessary to operate on the parsed entities.

Similar programs exist for Java and C#. The general idea, however, is that such an approach can be used anywhere we have a formal specification for which we know how to generate code.

Nowadays it is easier than ever to use meta programming. For example, one can simplify the task of parsing the formal specification by using XML as the specification language. We have standard tools and libraries that can parse XML and generate code as necessary.

The main step in leveraging meta programming is thinking about the needs of the system and take advantage of simpler specifications whenever possible.Using meta programming when possible can easily reduce the cost and time of development for a system by one order of magnitude, while improving the overall quality of the resulting code.

Further Reading

Flex & Bison (Bison is a version of YACC) provide a simple way of meta programming, where code is generated based on the syntax of a particular language.

Generative Programming is a book that describes methods to create systems through code generation. It has many novel ideas that are of interest for practical applications.

Similar Posts:

Similar Posts

9 Comments

  1. In den top online casinos finden Spieler zudem eine Vielzahl von Bonusangeboten und Aktionen.
    Zudem sind viele online casino seiten darauf spezialisiert, die besten online casino spiele anzubieten. Um sicherzustellen, dass ein Glücksspielanbieter legal
    ist, solltest du auf eine gültige Glücksspiellizenz
    achten, die von der deutschen Regulierungsbehörde
    ausgestellt wurde. Nur Anbieter mit einer deutschen Glücksspiellizenz dürfen in Deutschland
    operieren und ihre Dienste anbieten. Es ist von großer Bedeutung, in legalen Online-Casinos mit
    einer deutschen Lizenz zu spielen. Haben Sie ein für Sie besonders reizvolles
    Spiel gefunden, können Sie dann eine erste
    Echtgeldeinzahlung vornehmen, sich den Willkommensbonus
    des Casinos sichern und dann im Casino online spielen,
    mit Echtgeld.
    Die Anbieter locken Neukunden mit hohen Summen und Freispielen. Ein deutsches Online Casino bietet so gut wieder immer
    Casino Bonusse an. Wie und wo ihr zu jeder Zeit im Online Casino
    legal spielen könnt, erfahrt ihr bei uns. Für diejenigen, die Poker spielen möchten,
    gibt es Cash Games und regelmäßig Poker Turniere.
    Wir stellen sicher, dass das Casino verschiedene Kommunikationskanäle für den Kundenservice
    anbietet, um den Bedürfnissen der Spieler gerecht zu werden. Der Kundenservice ist ein wichtiger Aspekt bei der
    Bewertung eines Online-Casinos mit deutscher Lizenz.

    Es ist schwierig, eine allgemeine Tabelle mit
    den besten Boni in Casinos mit deutscher Lizenz zu erstellen, da die Bonusangebote je nach Casino und Zeitraum variieren können.

    References:
    https://online-spielhallen.de/bwin-casino-cashback-so-holen-sie-das-beste-heraus/

  2. Besides, all information punters send to the casino is encrypted
    and their data is carefully handled. Being their license means
    the casino adheres to all rules regarding safety and fairness.
    Both the company and the license issuer are known for strict gambling practices.

    Another great advantage of Nationalcasino.com/au/ is the absence
    of fees. Most deposit methods can also be used for payouts, which is pretty convenient.
    This section also has craps and unique titles that you
    can’t find at your typical casino, such as Dream Catcher.

    This means you get accurate information without language barriers affecting the quality of support.
    During busy periods or holidays, response times may be slightly longer.
    These enquiries receive immediate attention from our senior support staff.
    We prioritise urgent matters like account security
    concerns and payment issues. Our response times vary depending on the method you choose to contact us.
    We aim to respond to all customer enquiries as quickly as possible across
    all our support channels.
    Live sports betting is ideal for those who love the thrill of instant decision-making and the fast-paced nature of live events.
    National Casino’s live sports betting feature further enhances
    the excitement by allowing users to place bets during ongoing events.
    The platform also provides a user-friendly interface,
    making it easy to find answers to your questions and get the help you need.
    The support team is professional and knowledgeable, ensuring that any problems you encounter are resolved quickly and efficiently.
    Whether you’re on a break at work or commuting, National Casino’s mobile app ensures that you never have to miss out on the
    action. With its commitment to secure gaming, National Casino guarantees that your personal information and funds are always protected.

    References:
    https://blackcoin.co/ggbet-casino/

  3. PlayOJO Casino is the go-to gaming site for many Canadians due to its
    reliability, 3,000+ title portfolio, and top-notch banking system.
    LeoVegas was founded in and it has become a trusted name within the
    gaming industry. Mafia Casino has excellent game options with
    a great VIP program for users in Canada.
    If you are specifically interested in no deposit bonuses, simply head to our list of no deposit
    casino bonuses and browse our selection there. You might notice that a bonus is displayed next to each casino site on this page that currently has one on offer.

    Firstly, you need to choose a reliable online casino,
    so that your winnings are paid out to you if you do win. In most cases, the payouts you can expect depend on the games you are playing, not on the casino you
    are playing them at.

    References:
    https://blackcoin.co/mind-boggling-facts-you-didnt-know-about-online-casino-gaming/

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.