Language design suggestion on database query [closed]

I am designing a new programming language.

I am designing a syntax to implement queries. Currently this is how it works.

The database is accessible through entity object.

on this sample I have “entity.manufacturers” and “entity.products” table

To get manufacturer with an ID of 1:

   var @manufacturer = entity.manufacturers where id = 1;

To query all products for @manufacturer:

    // Get all manufacturers products 
    var @products = entity.products under @manufacturer;
    // No need to specify what links both since system already knows how entity is related

Currently I am using “under” as a keyword to get all records for @manufacturer. I want it to make sense by just reading the code.

If you can give suggestions on a better syntax or keywords on how to implement this that will be awesome.

7

Designing good concrete syntax is ridiculously hard. And unfortunately, while the best syntax in the world can’t save a lame language, bad syntax can (has) doom(ed) good languages.

If this is a toy language, “full speed ahead” say I! But if you want to create a practical language for people to use, I have the following observations based on my personal experiences. YMMV:

  • focus on the semantics and abstract syntax of your language. This is the core of a language, and how people will learn and understand it. Figure out how elements of the language can be defined, combined, and abstracted. Absolutely do not let concrete syntax dictate the semantics or abstract syntax of your language.
  • keywords, braces, semicolons — these are all totally irrelevant as far as abstract syntax and semantics are concerned. There can be multiple concrete syntaxes for the exact same language.
  • implementing features as libraries is usually preferable to implementing them as syntax
  • syntax is hard to fix
  • syntax is hard to extend
  • syntax is hard to compose
  • syntax is not accessible at run-time

So my answer to your question is: design your abstract syntax and semantics first. Without seeing those, it’s very hard to come up with a good concrete syntax. Once you have those, a concrete syntax should be much easier to derive.

Or you could just go with Lisp. 😉


Also, since you mentioned I want it to make sense by just reading the code, I should point out that designing a syntax that reads like plain English, yet is also simple, unambiguous and powerful has never been done (to my knowledge). I do not believe this is possible (although I hope I am wrong).

2

I don’t think under is the right word here as it makes to many assumptions about the nature of the relationship between two entities, when all you really need to indicate is fact that they are related. In many entity relationship, one entity may be thought of as under another, but this is certainly not the case for all entity relationships.

I’d use the word by instead, as in

var @products = entity.products by @manufacturer;

Or on, as in

var @products = entity.products on @manufacturer;

Since it hints that you are creating a simplified join syntax.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật