Further reading

Casting an object array to a string array

at 2008-07-19 in Further reading by friebe

While testing the new EASC server and client implementations we're currently working on, we asked ourselves how to cast an object array to, for example, a string array.

The following is an array of objects consisting solely of strings:

  Object[] strings= new Object[] { "Hello", "World" };

The first thing we tried was to cast it via (String[])strings. This is legal sourcecode but will raise a java.lang.ClassCastException in Java, and a System.InvalidCastException in C#, both at runtime.


(more)

Exceptions in Java

at 2008-06-25 in Further reading by friebe

Found this nice article on exceptions in Java - from a historic overview of Oak, on checked and unchecked exceptions, and asynchronous exceptions it explains nicely (and with code examples) what the Java exception mechanism is about. What I like most are the best practices section, which applies not only to Java:

  • Don't Write Own Exceptions
  • Write Useful Exceptions
  • Throw exceptions early
  • Catch exceptions late
  • Document exceptions
  • Unit Test Exceptions

http://www.javaspecialists.eu/archive/Issue162.html



Frank Kleine on Namespaces

at 2007-11-11 in Further reading by friebe

On a short note: In Gathering practical experience with namespaces, Frank describes his first impressions of PHP 5.3 with namespaces:


Oh boy. You should never even think about porting your application completely to namespaces if you do not have enough unit tests!

Reminds me of the rule of thumb that one never has enough unittests:-)



PHP6 Namespaces patch backported

at 2007-07-21 in Further reading by friebe

Beginning of this month, Dmitry Stogov from Zend published a patch implementing namespaces in PHP6.

To be able to begin playing around with it without adding further points of possible failures for our XP unittests with new PHP6 (e.g., unicode-related breakage), I started and after a day's work succeeded in backporting the patch to current CVS HEAD, that is, PHP 5.2.4-dev.


(more)

Scala

at 2007-04-07 in Further reading by friebe

Found this while surfing the web for Java 7 ideas:


Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages. It is also fully interoperable with Java.


http://www.scala-lang.org/



I can't believe it's not XML!

at 2007-03-31 in Further reading by friebe

Really enjoyed reading a weblog entry I found while surfing around for JSON-related stuff.

There seem to be a lot of XML folks who can't understand JSON - yes, Dave, it's not even XML. I have a theory on why that is, but to explain it I need to go into a couple other things first.


http://www.b-list.org/weblog/2006/12/21/i-cant-believe-its-not-xml



Static initializers

at 2007-03-29 in Further reading by friebe

Nice to see other folks are adapting the static initializer idea. Too bad the PHP folks won't.

Example:

<?php 
class Console extends Object {
public
static $out, $err= NULL;

static function __static() {
self::
$out= new OutputStream(STDOUT);
self::
$err= new OutputStream(STDERR);
}
}
?>

This was originally described in the XP Framework's RFC #0002 as early as November 2003:)



Five questions about language design

at 2006-11-24 in Further reading by kiesel

There's a nice write-up of Paul Graham with some of his thoughts about
language design.

Some of topics he talks about are:

  • the quality of a language designed for use of yourself vs. the quality of a language designed for use of others

  • good languages should allow writing things brief

  • languages should not concentrate on being fast, but instead give their users tools to find bottlenecks in their application

  • You Need an Application to Drive the Design of a Language


  • ... read more.



    C#'s "using" statement

    at 2006-10-22 in Further reading by friebe

    Having blogged about Python's new with statement (see entry #117), I decided I'll also mention C#'s using() which is quite similar.

    From the C# Reference:


    Defines a scope, outside of which an object or objects will be disposed.


    (more)

    "with" elsewhere

    at 2006-10-08 in Further reading by friebe

    You might know the with statement from JavaScript or Pascal (where it saves a few keystrokes by "auto-importing" the object).

      Person.Name= 'Timm';
    Person.Id= 1549;

    {* equvialent *}
    With Person Do Begin
    Name= 'Timm';
    Id= 1549;
    End;

    The XP framework also has with, not really as statement, but as a noop function:
    <?php 
    with
    ($p= &new Person()); {
    $p->name= 'Timm';
    $p->id= 1549;
    }
    ?>

    You could basically omit with () and the brackets, they serve no purpose except making the above bit more readable (especially when you're using lots of assignments or method calls on an object).

    Now in Python, with serves a different purpose - in a quite flexible way: What's New in Python 2.5 - The 'with' statement.



    Subscribe

    You can subscribe to the XP framework's news by using RSS syndication.


    Categories

    News
    General
    PHP5
    Announcements
    RFCs
    Further reading
    Examples
    Editorial
    EASC
    Experiments
    Unittests
    Databases