Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
I'm designing a new query language and looking for initial comments. (michaelspeer.blogspot.com)
1 point by knome on Nov 13, 2007 | hide | past | favorite | 2 comments


What is the advantage of your language?

The easiest way to present your language is to motivate it. What is wrong with SQL that you are fixing?

If you say, "cleaner syntax", then good luck. Don't forget the history. Codd wanted Alpha, but politics at IBM is what gave us SQL. Once SQL started rolling, it's what stuck.


Interpreter for AsYetUnnamedProgrammingLanguage by

MichaelSpeer v0.-1

>

> declare

. Products

. :name PHRASE

. :price MONEY'USD

. ;

> create Products [ :name , :price ] =

. [ "DVD Player" , 20'USD ] ,

. [ "VCR" , 15.5'USD ] ,

. [ "DVD" , 7'USD ] ,

. [ "VCR Tape" , 4'USD ]

. ;

> Products ;

[ 1 , 2 , 3 , 4 ]

> Products:id ;

[ 1 , 2 , 3 , 4 ]

> Products[ :id , :name ] ;

[ 1 , "DVD Player" ]

[ 2 , "VCR" ]

[ 3 , "DVD" ]

[ 4 , "VCR Tape" ]

> Products( :price < 5'USD )[ :name ];

[ "VCR Tape" ]

> Products( :price > 10'USD ):name ;

[ "DVD Player" , "VCR" ]

> Products( :price > 10'USD )[ :name ] ;

[ "DVD Player" ]

[ "VCR" ]

> Products( asc :name ):name ;

[ "DVD" , "DVD Player" , "VCR" , "VCR Tape" ]

> declare

. Categories

. :name PHRASE

. :sub-products -> Products:category single

. ;

> create Categories [ :name , :sub-products ] =

. [ "Video Players" , Products( :name in [ "DVD Player" , "VCR" ] ) ]

. ;

> Products:category:name ;

[ "Video Players" ]

> Products[ :category:name ] ;

[]

[ "Video Players" ]

[]

[ "Video Players" ]

> Products( :category ):name ; -- returns products that have a category

[ "DVD Player" , "VCR" ]

> Products( not :category ):name ; -- returns products lacking a category

[ "DVD" , "VCR Tape" ]

> Products( :id != 3 && :id != 4 )[ :name ] ;

[ "DVD Player" ]

[ "VCR" ]

> create Categories [ :name , :sub-products ] =

. [ "Blank Media" , Products( not :category ) ]

. ;

> Products( :category( :sub-products( :name == "DVD" ) ) ):name ;

[ "DVD" , "VCR Tape" ]

> alter Products( :category( :name == "Media" ) )[ :price ] = [ :price += 1'USD ] ;

> declare Categories:recommended -> :sub-products:recommended-by ;

> alter Categories( :name == "Media" )[ :recommended ] = [ :sub-products( :name == "DVD" ) ] ;




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: