Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ specific patterns due to language design

It took me a long time to realize how important and subtle having variables that:

1) exist on the stack

2) have their destructors called when they fall out of scope

are.

These two things allow things like:

A) RAII

B) refcounted GC

Interesting enough, (1) & (2) are not available in "lower" languages like C/Assembly; nor in "higher" languages like Ruby/Python/Java (since GC prevents predictable destruction of objects).

I'm curious -- what other techniques do you know of that are very C++ specific, due to language design choices.

Thanks!

Edit: If your answer is "this works in C++ & this other langauge", that's okay too. The things I want to learn about are similar to:

By choosing to not have certain features (like GC), we gain other features (like RAII + predicable destructing of objects). In what areas of C++, by choosing to NOT have features that other "higher level" langauges have, C++ manages to get patterns that those higher level langauges can't express.

like image 382
anon Avatar asked Jan 26 '10 21:01

anon


People also ask

Are design patterns specific to a programming language?

Yes and no. Certain design patterns are not specific to particular languages, but there may be design patterns specific to classes of languages. For example, there may be functional design patterns that are specific to functional languages or object oriented design patterns specific to object oriented languages.

Are there any design patterns in C?

There are various patterns in the C language like star patterns, number patterns, and character patterns.

What are patterns in C language?

A pattern program in C generally contains nested loops where the outer loop controls the number of rows, and the inner loop controls the data in each row containing the contents to be printed.

What Is design pattern language?

An organized collection of design patterns that relate to a particular field is called a pattern language. This language gives a common terminology for discussing the situations designers are faced with. The elements of this language are entities called patterns.


1 Answers

curiously recurring template pattern

expression templates

Probably the whole meta-programming concept as well

like image 64
Anycorn Avatar answered Oct 04 '22 02:10

Anycorn