Skip to main content

Best of…: Classic WTF: A Dumbain Specific Language

1 month 3 weeks ago
It's a holiday here in the US, a celebration of labor, so we're reaching back through the archives for a story about an attempt to be labor saving that was not successful. Original. --Remy

I’ve had to write a few domain-specific-languages in the past. As per Remy’s Law of Requirements Gathering, it’s been mostly because the users needed an Excel-like formula language. The danger of DSLs, of course, is that they’re often YAGNI in the extreme, or at least a sign that you don’t really understand your problem.

XML, coupled with schemas, is a tool for building data-focused DSLs. If you have some complex structure, you can convert each of its features into an XML attribute. For example, if you had a grammar that looked something like this:

The Source specification obeys the following syntax source = ( Feature1+Feature2+... ":" ) ? steps Feature1 = "local" | "global" Feature2 ="real" | "virtual" | "ComponentType.all" Feature3 ="self" | "ancestors" | "descendants" | "Hierarchy.all" Feature4 = "first" | "last" | "DayAllocation.all" If features are specified, the order of features as given above has strictly to be followed. steps = oneOrMoreNameSteps | zeroOrMoreNameSteps | componentSteps oneOrMoreNameSteps = nameStep ( "." nameStep ) * zeroOrMoreNameSteps = ( nameStep "." ) * nameStep = "#" name name is a string of characters from "A"-"Z", "a"-"z", "0"-"9", "-" and "_". No umlauts allowed, one character is minimum. componentSteps is a list of valid values, see below. Valid 'componentSteps' are: - GlobalValue - Product - Product.Brand - Product.Accommodation - Product.Accommodation.SellingAccom - Product.Accommodation.SellingAccom.Board - Product.Accommodation.SellingAccom.Unit - Product.Accommodation.SellingAccom.Unit.SellingUnit - Product.OnewayFlight - Product.OnewayFlight.BookingClass - Product.ReturnFlight - Product.ReturnFlight.BookingClass - Product.ReturnFlight.Inbound - Product.ReturnFlight.Outbound - Product.Addon - Product.Addon.Service - Product.Addon.ServiceFeature In addition to that all subsequent steps from the paths above are permitted, that is 'Board', 'Accommodation.SellingAccom' or 'SellingAccom.Unit.SellingUnit'. 'Accommodation.Unit' in the contrary is not permitted, as here some intermediate steps are missing.

You could turn that grammar into an XML document by converting syntax elements to attributes and elements. You could do that, but Stella’s predecessor did not do that. That of course, would have been work, and they may have had to put some thought on how to relate their homebrew grammar to XSD rules, so instead they created an XML schema rule for SourceAttributeType that verifies that the data in the field is valid according to the grammar… using regular expressions. 1,310 characters of regular expressions.

<xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="(((Scope.)?(global|local|current)\+?)?((((ComponentType.)? (real|virtual))|ComponentType.all)\+?)?((((Hierarchy.)?(self|ancestors|descendants))|Hierarchy.all)\+?)? ((((DayAllocation.)?(first|last))|DayAllocation.all)\+?)?:)?(#[A-Za-z0-9\-_]+(\.(#[A-Za-z0-9\-_]+))*|(#[A-Za-z0- 9\-_]+\.)* (ThisComponent|GlobalValue|Product|Product\.Brand|Product\.Accommodation|Product\.Accommodation\.SellingAccom|Prod uct\.Accommodation\.SellingAccom\.Board|Product\.Accommodation\.SellingAccom\.Unit|Product\.Accommodation\.Selling Accom\.Unit\.SellingUnit|Product\.OnewayFlight|Product\.OnewayFlight\.BookingClass|Product\.ReturnFlight|Product\. ReturnFlight\.BookingClass|Product\.ReturnFlight\.Inbound|Product\.ReturnFlight\.Outbound|Product\.Addon|Product\. Addon\.Service|Product\.Addon\.ServiceFeature|Brand|Accommodation|Accommodation\.SellingAccom|Accommodation\.Selli ngAccom\.Board|Accommodation\.SellingAccom\.Unit|Accommodation\.SellingAccom\.Unit\.SellingUnit|OnewayFlight|Onewa yFlight\.BookingClass|ReturnFlight|ReturnFlight\.BookingClass|ReturnFlight\.Inbound|ReturnFlight\.Outbound|Addon|A ddon\.Service|Addon\.ServiceFeature|SellingAccom|SellingAccom\.Board|SellingAccom\.Unit|SellingAccom\.Unit\.Sellin gUnit|BookingClass|Inbound|Outbound|Service|ServiceFeature|Board|Unit|Unit\.SellingUnit|SellingUnit))"/> </xs:restriction> </xs:simpleType> </xs:union>

There’s a bug in that regex that Stella needed to fix. As she put it: “Every time you evaluate it a few little kitties die because you shouldn’t use kitties to polish your car. I’m so, so sorry, little kitties…”

The full, unexcerpted code is below, so… at least it has documentation. In two languages!

<xs:simpleType name="SourceAttributeType"> <xs:annotation> <xs:documentation xml:lang="de"> Die Source Angabe folgt folgender Syntax source = ( Eigenschaft1+Eigenschaft2+... ":" ) ? steps Eigenschaft1 = "local" | "global" Eigenschaft2 ="real" | "virtual" | "ComponentType.all" Eigenschaft3 ="self" | "ancestors" | "descendants" | "Hierarchy.all" Eigenschaft4 = "first" | "last" | "DayAllocation.all" Falls Eigenschaften angegeben werden muss zwingend die oben angegebene Reihenfolge der Eigenschaften eingehalten werden. steps = oneOrMoreNameSteps | zeroOrMoreNameSteps | componentSteps oneOrMoreNameSteps = nameStep ( "." nameStep ) * zeroOrMoreNameSteps = ( nameStep "." ) * nameStep = "#" name name ist eine Folge von Zeichen aus der Menge "A"-"Z", "a"-"z", "0"-"9", "-" und "_". Keine Umlaute. Mindestens ein Zeichen componentSteps ist eine Liste gültiger Werte, siehe im folgenden Gültige 'componentSteps' sind zunächst: - GlobalValue - Product - Product.Brand - Product.Accommodation - Product.Accommodation.SellingAccom - Product.Accommodation.SellingAccom.Board - Product.Accommodation.SellingAccom.Unit - Product.Accommodation.SellingAccom.Unit.SellingUnit - Product.OnewayFlight - Product.OnewayFlight.BookingClass - Product.ReturnFlight - Product.ReturnFlight.BookingClass - Product.ReturnFlight.Inbound - Product.ReturnFlight.Outbound - Product.Addon - Product.Addon.Service - Product.Addon.ServiceFeature Desweiteren sind alle Unterschrittfolgen aus obigen Pfaden erlaubt, also 'Board', 'Accommodation.SellingAccom' oder 'SellingAccom.Unit.SellingUnit'. 'Accommodation.Unit' hingegen ist nicht erlaubt, da in diesem Fall einige Zwischenschritte fehlen. </xs:documentation> <xs:documentation xml:lang="en"> The Source specification obeys the following syntax source = ( Feature1+Feature2+... ":" ) ? steps Feature1 = "local" | "global" Feature2 ="real" | "virtual" | "ComponentType.all" Feature3 ="self" | "ancestors" | "descendants" | "Hierarchy.all" Feature4 = "first" | "last" | "DayAllocation.all" If features are specified, the order of features as given above has strictly to be followed. steps = oneOrMoreNameSteps | zeroOrMoreNameSteps | componentSteps oneOrMoreNameSteps = nameStep ( "." nameStep ) * zeroOrMoreNameSteps = ( nameStep "." ) * nameStep = "#" name name is a string of characters from "A"-"Z", "a"-"z", "0"-"9", "-" and "_". No umlauts allowed, one character is minimum. componentSteps is a list of valid values, see below. Valid 'componentSteps' are: - GlobalValue - Product - Product.Brand - Product.Accommodation - Product.Accommodation.SellingAccom - Product.Accommodation.SellingAccom.Board - Product.Accommodation.SellingAccom.Unit - Product.Accommodation.SellingAccom.Unit.SellingUnit - Product.OnewayFlight - Product.OnewayFlight.BookingClass - Product.ReturnFlight - Product.ReturnFlight.BookingClass - Product.ReturnFlight.Inbound - Product.ReturnFlight.Outbound - Product.Addon - Product.Addon.Service - Product.Addon.ServiceFeature In addition to that all subsequent steps from the paths above are permitted, that is 'Board', 'Accommodation.SellingAccom' or 'SellingAccom.Unit.SellingUnit'. 'Accommodation.Unit' in the contrary is not permitted, as here some intermediate steps are missing. </xs:documentation> </xs:annotation> <xs:union> <xs:simpleType> <xs:restriction base="xs:string"> <xs:pattern value="(((Scope.)?(global|local|current)\+?)?((((ComponentType.)?(real|virtual))|ComponentType.all)\+?)?((((Hierarchy.)?(self|ancestors|descendants))|Hierarchy.all)\+?)?((((DayAllocation.)?(first|last))|DayAllocation.all)\+?)?:)?(#[A-Za-z0-9\-_]+(\.(#[A-Za-z0-9\-_]+))*|(#[A-Za-z0-9\-_]+\.)*(ThisComponent|GlobalValue|Product|Product\.Brand|Product\.Accommodation|Product\.Accommodation\.SellingAccom|Product\.Accommodation\.SellingAccom\.Board|Product\.Accommodation\.SellingAccom\.Unit|Product\.Accommodation\.SellingAccom\.Unit\.SellingUnit|Product\.OnewayFlight|Product\.OnewayFlight\.BookingClass|Product\.ReturnFlight|Product\.ReturnFlight\.BookingClass|Product\.ReturnFlight\.Inbound|Product\.ReturnFlight\.Outbound|Product\.Addon|Product\.Addon\.Service|Product\.Addon\.ServiceFeature|Brand|Accommodation|Accommodation\.SellingAccom|Accommodation\.SellingAccom\.Board|Accommodation\.SellingAccom\.Unit|Accommodation\.SellingAccom\.Unit\.SellingUnit|OnewayFlight|OnewayFlight\.BookingClass|ReturnFlight|ReturnFlight\.BookingClass|ReturnFlight\.Inbound|ReturnFlight\.Outbound|Addon|Addon\.Service|Addon\.ServiceFeature|SellingAccom|SellingAccom\.Board|SellingAccom\.Unit|SellingAccom\.Unit\.SellingUnit|BookingClass|Inbound|Outbound|Service|ServiceFeature|Board|Unit|Unit\.SellingUnit|SellingUnit))"/> </xs:restriction> </xs:simpleType> </xs:union> </xs:simpleType> hljs.initHighlightingOnLoad(); [Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!
Remy Porter

Roku's 24/7 AI Slop Channel Is Even Worse Than Expected

1 month 4 weeks ago
A new streaming TV channel shows films made with genAI, reports Engadget. "Fairground AI Creator TV" is free — and supported with ads — describing its material as "AI Cinema": "AI-generated" can make it sound as though someone typed a sentence into a machine and came back five minutes later to find a finished movie. Fairground's catalog shows why that description can be too simple. Take Lost Garden: The Awakening of the Lantern Knight. According to its Fairground page, creator Frank Houbre wrote the world, characters, mythology, emotional arc and screenplay himself. AI tools were used mainly for animation and visual production, with other tools helping create voices and music before the episode was assembled in conventional video-editing software. There's still one question, the article notes: "whether viewers actually want an AI-focused TV channel." More than 100 AI creators have contributed to the 24-hour slate of programming, although Variety points out several of them were discovered on social media. The channel was recently profiled in an article by the Guardian. Its headline? "'Nightmare fodder': Roku's AI slop channel is even worse than expected." (And its subheading calls it "a 24/7 channel devoted to low-quality AI content for viewers sick of watching real people move...") What about people who hate plot and vision and the sight of people speaking convincing dialogue that synchronises perfectly with the movement of their lips? What about the people who just want to watch an unyielding torrent of eerily weightless nightmare fodder? Well, good news. Roku has finally caught up... Early reactions were, to put it mildly, not great. The Verge compared it to eating from a trough, while Futurism called it "bottom-of-the-barrel slop"... On the plus side, the channel is evidence that artificial intelligence has come on in leaps and bounds over the last couple of years... However, it is still awful. Categorically, catastrophically awful. The channel doesn't so much offer shows as a drifting dreamscape of bad ideas rendered as horribly as possible with no thought paid to scheduling. At one point on Wednesday, a shrill high-frequency anime gave way to a long and staid German-language short about Nazi bureaucracy. After that came a sort of Gladiator ripoff that had all the dynamism of an exhibit you'd see at the fourth-best museum on a poorly planned family holiday.

Read more of this story at Slashdot.

EditorDavid