Archive for the 'Programming' 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….

No comments

Protected within Java Enums

July 22nd, 2010 | Category: Java, Programming

I just noticed that java enums allow protected member variables and methods. Why is this interesting? Can you think of any code that might actually make use of a protected member in an enum (as opposed to private)? Example after the jump (warning, not practical…).
Read more

No comments

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

No comments

Opening a TUN Device on UNIX

November 19th, 2009 | Category: C, Networking, Programming

The TUN/TAP interface under Linux provides user space access to Transport (Ethernet) or Network Layer (IP) traffic by allowing a developer to create a “virtual” interface that can be openend in user space as a file descriptor.
Read more

1 comment

RSS and mercurial

October 27th, 2009 | Category: Programming

In a surprisingly well-kept secret, HgWeb and HgWebDir support RSS. Details below.
Read more

1 comment

Why is XML Better?

July 24th, 2009 | Category: Programming, XML, XPath, XSLT

Why is XML better than custom internal formats? Isn’t a non-standard set of XML tags basically equivalent to a custom format when using data internally to an application? Absolutely not, and here is why.
Read more

No comments

DVSL: An Alternative to XSLT

June 26th, 2009 | Category: Java, XML, XPath, XSLT

DVSL is a fairly small, little known, product associated with the Velocity project over at Apache which takes the best part of XSLT: XPATH, and replaces the verbose and frustrating scripting of XSLT with a java-based template language instead.
Read more

No comments

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

No comments

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

No comments

Next Page »