Archive for the 'C++' Category

More fun with Java (scope and duplicates)

July 27th, 2010 | Category: C++, Java, Programming

I thought this was interesting… In Java, a block scoped variable may conflict with a local variable declared later in method scope, but not previously (as shown below):

class A{
  public static void main(String args[]){
    {int k = 5;}
    int k = 12; //this is OK
    {int k = 22;}//this is not....
  }
}

This is not the same as C++ where this compiles happily:

int main(){
  {int i;}
  int i;
  {int i;}
  return 0;
}

Usually C++ has the more obscure behavior….

Comments are off for this post

SWIG, Java, and JRuby

July 22nd, 2010 | Category: C++, Java, Networking, Programming, Ruby

Providing a robust, maintainable, and interactive interface to your C/C++ application can be a challenge, but I’ve found that a combination of SWIG, Java, and JRuby (or Jython if you prefer) makes for a very powerful combination.
Read more

Comments are off for this post

Spirit Vs. Lex/yacc/et al.

December 10th, 2008 | Category: C, C++, Networking, Programming, Python

What are the differences and when should I use one or the other?
Read more

Comments are off for this post

Boost Spirit III (Adding Error Handling)

November 04th, 2008 | Category: C++, Programming

This article expands the example from the previous two, here and here, to add more specific error information.

As always the full code from the example is available here here.

Read more

1 comment

Writing a custom check macro for the BOOST test library

October 13th, 2008 | Category: C++, Programming

In this article I demonstrate how to write your own check macros for the boost test library (not guaranteed to work in the future)

Full source code for this example can be downloaded here.
Read more

Comments are off for this post

What is a C++ Functor?

July 20th, 2008 | Category: C++, Programming

I did a presentation on the spirit library in the flesh recently and was surprised to find the big sticking point was C++ functors. So I thought I’d cover the concept here.

Read more

1 comment

Boost Spirit Part II (Attaching Actions to Your Grammar)

July 20th, 2008 | Category: C++, Programming

In the last article we covered how to define a grammar in the boost spirit library. This article will show you how to use the data parsed by the grammar with actions. The code for this example is here.
Read more

5 comments

Boost Spirit Part I (Validating Against a Grammar)

July 01st, 2008 | Category: C++, Programming

I haven’t done a post in a while, but I thought the boost spirit library was worth an entry. Spirit provides a way of specifying and parsing a custom language grammar right inline in C++ without the need for a code generator like lex/yacc. Spirit makes it so easy to specify and use a grammar that you should never hand write even the most trivial parser again.

The full code for this example can be found here.

Read more

5 comments

Why C++ is a Dying Language

February 17th, 2008 | Category: C++, Programming

From my blog you may notice I am an inveterate C++ coder. It was the first language I taught myself after pascal and my preferred language for compact, fast code.The downfall of C++ may not be news to many, but often it is written by opponents of the language rather than those who love it and all of its quirks. So from a fan, C++, the prognosis is poor. I could write a book on this, but I tried to distill it down to article size.
Read more

170 comments

Automatic Adaptation in C++

February 16th, 2008 | Category: C++, Programming

The adapter pattern is used to implement an interface required by one library in terms of an object declared in another. It’s a useful pattern, but implementing it can be a pain. You have to manually adapt objects as you get them and then you have to remember to clean up the adapter objects when you are done. Here is a way to have the compiler do it all for you in C++.
Read more

Comments are off for this post

Next Page »