Building the next new language

Something probably to fuel the debate on Stored procedures versus Dynamic SQL.

Ted Neward propose simply to implement some database relational functions in the language.

The idea of transacted code seems to be futuristic but why not ?

x = 5;
transacted
{
  x += 5;
  throw new IllegalArgumentException("can't do this!");
}
finally // a.k.a. commit
{
  printOut("We committed! x = " + x);
}
rollback
{
  printOut("We rolled back! x = " + x);
}

// x has the value "5", since the exception forces an implicit rollback

A bit freaky to see this kind of mix:

What I want is primitive types that understand the relational and hierarchical data models intuitively and allow me to exercise those operators as a first-class language concept.

At this point, I have no real idea how you would make all this work, but I envision something along the lines of:

relvar r = { fn, ln, age} [ ["Ted", "Neward", 32] ["Don", "Box", 39] ];
foreach (tuple t in r)
{
  printOut("Name is " + t.fn + " " + t.ln + ", " + t.age + " years old");
}

relvar r2 = { fn, ln, age} [ ["Fritz", "Onion", 39] ];
relvar r3 = r UNION r2;
printOut(r3.count); // Prints "3", since there are 3 tuples


 

3 Comments

  • Well, how is transacted different from try and how is rollback different from catch.

  • Wesner I think it's different from a try...catch because the transacted loop would make the code batch. I know I have the same reaction ahen I read the article, but I think the point I like is more the relation part. The link between object using stuff like Union is challenging.

  • I agree with a little syntax change:



    transaction{}

    commit{}

    rollback{}





    Now THIS would be also interesting:



    DataTable Clients, Overdue;

    // populate Clients from your server



    Transaction

    {

    Select * From Clients Into Overdue Where duedate>DateTime.Now;

    Update Overdue Set LateFee = Amount *.05;

    }

    Commit{ Print("Ok");}

    Rollback{ Print("oops");}



    // continue massaging data with user interaction before sending results back to the server



    Fully embedded SQL in the language...

Comments have been disabled for this content.