SKITSANOS FOR RIA

Skitsanos

Friday, April 24, 2009

myPatterns: XSLT / RegEx for JS Objects

Nic Volanschi pointed us to myPatterns:

myPatterns is a new library adding custom notations for data structures in JS (and also C). It’s really useful for writing elegant programs using general pattern matching.

To explain myPatterns, let’s introduce a standard JavaScript object:

PLAIN TEXT

JavaScript:

  1. {

  2. name: { firstname: “John”, lastname: “Smith” },

  3.   children: [

  4. { firstname: “Eric”, gender: “male”, born: 1991 },

  5. { firstname: “Deborah”, gender: “female”, born: 1996 }

  6. ]

  7. }

Using myPattern, you can write a test to check if this object represents a person whose first child is a boy 18 years old:

PLAIN TEXT

JavaScript:

  1. (s = match(x, “{name:{lastname: %l}, children:[{gender: 'male', born: %b} | %x]}”))

  2. && new Date().getFullYear() - s.b == 18

The website explains the pattern above:

In the above, the match() statement both checks whether the object has a certain form (e.g. that the children field is an array containing a first element of a given form), and returns a “substitution” object s having the following value: {l: “Smith”, b: 1991, x: [ {firstname: "Deborah" , born: 1996} ]}.

Furthermore, using your own notations, you could write the same condition more concisely, and with your own personal touch, for example:

PLAIN TEXT

JavaScript:

  1. s = match(x, “<%first ~ %last: [boy(18) | %rest]>”)

In the above, the object is noted in a more concise way, and the age of the first son is directly specified in the pattern, as if it was stored in the object, taking advantage of active patterns to compute the age on the fly.

Neat!

Wednesday, April 15, 2009

No More Underscores in VB 10

Source: InfoQ

Visual Basic 10 will have an improved compiler that makes underscores optional for most line continuations. This represents a significant change for VB, traditionally a line-terminated language. The Visual Basic team has an in-depth explanation of Implicit Line Continuation.

VB 1-6 and VB.NET (7-9) used the carriage return as a statement termination token, similar to the explicit semicolon ";" in C#. By moving to an implicit termination token, Visual Basic language readability will be greatly improved, especially when writing multi-line LINQ queries.

Dim dates = from d in listOfDates _
where d.Year > 2009 _
select d _
distinct _
order by d
Could become:
Dim dates = from d in listOfDates
where d.Year > 2009
select d
distinct
order by d
The VB team explanation mentioned above covers specific cases where implicit line continuation is not supported:
We don’t capture every scenario. Given our cost and time constraints around the feature, we tried to capture the most common cases that would provide the most bang for the buck. We also avoided the ones that just led to problems. Here are some examples of problems you could have if we had decided to allow implicit continuation anywhere. I take these from some analysis that Lucian Wischik (also on the VB compiler team) did on our grammar:
With y
A=x
.xfield
End With
If we allowed implicit continuation before the ‘.’ we would have problems knowing what the period belongs to. For example, it could be interpreted as:

With y
A=x.xield
End With
Or
With y
A=x
.xfield
End With
Channel 9 also has an excellent interview with Tyler Whitney, a developer on the Visual Basic compiler team.

Silverlight Has Lost an Important Customer

Source: InfoQ

Yesterday, the MLB 2009 season started being broadcasted live on the Internet by MLB.TV using Flash instead of Silverlight. After one year of using Silverlight, MLB switched back to Flash due to problems plaguing Microsoft’s player.

Microsoft had a one year deal for 2008 with MLB to use Silverlight as streaming platform for their MLB.TV web site with half a million subscribers. The MLB 2009 season started yesterday with a web site full of Flash and an online TV station broadcasting on Flash according to the 2 years deal with MLB announced by Adobe in November last year.

Little was said regarding the reasons why MLB renounced to Silverlight, but some details have transpired according to CNET. One of the main problems is availability of the player which cannot be installed at work by people without administrative rights. The other major reason was the series of glitches affecting last year’s Opening Day and the week following which most probably frustrated many subscribers which had difficulty logging in and watching the games.

Today, using Flash, MLB.TV offers the games in HD with DVR quality with pause and rewind even for live games, with game or player highlights using picture in picture, the ability to watch 4 games in the same time, the possibility to choose between radio and TV announcers, and player tracker.

While Microsoft lost a very important customer, Silverlight still provides coverage for NBA, NCAA events though CBS College Sports, and provides streaming for Blockbuster’s MovieLink and Netflix’ Instant Watch.

Webware development dedicated blog by Skitsanos R&D Labs. ASP.NET, XML, RIA, Adobe Flex, ActionScript 3, AIR, AJAX, Web 2.0, Backbase, CGI development with RealBasic and other web development issues.
News
Downloads