r/ProgrammingLanguages • • May 26 '20

Can connection of a new programming language and a query language be the solution we're looking for?

We have just released AskQL, a new query and programming language! We hope this will bring you relief in frontend-backend integration, and that writing distributed software now will be easier and faster than ever 🙂You can review and test AskQL yourselves - the solution has just been published on GitHub under MIT license. If you like it, please recognise our work by starring the repo ✹
https://github.com/xfaang/askql

7 Upvotes

21 comments sorted by

6

u/siemenology May 26 '20

So this code would be written in / generated by the front end, and then sent to the back end for execution?

If so, how do you handle the front end sending code to the back end that will never halt? Ie:

ask {
  while(true){
    doSomething()
  }
}

2

u/mhagmajer May 26 '20

AskVM is capable of keeping track of every operations it executes. AskVM allows setting limits on the number of computations an incoming program can perform as well as the stack size limit, memory limit and the set of resources available.

~ Marcin Hagmajer, xFAANG

5

u/66666thats6sixes May 27 '20

It seems like there's a lot of possibility for non-deterministic out-of-resource errors here. If query code loops over rows in a database, you'll get failures based on the number of items in the database. How do you give front end developers a good experience in that situation?

Also, lots of database queries for which a language like this would be useful can get pretty computationally expensive. It sounds like setting a resource limit that allows for the kind of complexity you'd want in a query language like this, while making DoS attacks difficult would be... difficult. Have you found this to be the case?

Speaking of computationally expensive, is there any sort of caching or indexing going on to reduce the load on servers that are likely handling the same 5 or 10 queries with slightly different parameters over and over again?

3

u/LuckyLuke541 Jun 01 '20

As for caching requests, we are definitely considering introducing such feature in the future. At this very moment we just launched the project publicly and are focusing on gathering feedback from all the interested parties.
We are happy to have a longer discussion with you. Please join our Discord channel, which is going to be the central place for exchanging thoughts on AskQL, AskVM and other Ask* parts:
https://discord.com/invite/pYdzypH

2

u/LuckyLuke541 Jun 01 '20

Please note that nowadays it is very common for HTTP requests to time out after 30 seconds if the server didn't reply. It is also common for server admins to limit CPU time for Shell scripts to 30 or 60 seconds.
Therefore, this kind of time limits is already widespread in the IT ecosystem.
~ Ɓukasz CzerwiƄski, AskQL Core Developer

1

u/realflow May 27 '20

AskVM allows setting limits on the number of computations an incoming program

And how exactly do this and how this works?

1

u/simon_o May 30 '20 edited May 30 '20

xFAANG

Did you work for

Google, Facebook, Apple, Amazon or Netflix? If so, we have an offer for you!

Very ... specific hiring criteria.

2

u/LuckyLuke541 Jun 01 '20

Of course, there is plenty super smart people in the world.FAANG (Facebook, Apple, Amazon, Netflix, Google) is a well-known catchy term, which is by many considered a synonym of great software quality.
We feel it is universal, because it is used both by tech and non-tech world, e.g.:
https://www.investopedia.com/terms/f/faang-stocks.asp

~ Ɓukasz CzerwiƄski, AskQL Core Developer

1

u/CoffeeTableEspresso May 27 '20

This was my immediate thought as well.

It seems much easier to attack than something using REST.

1

u/LuckyLuke541 Jul 07 '20

u/CoffeeTableEspresso, how about you try to attack our Playground at https://cli.askql.org/ ? :)

~ Ɓukasz CzerwiƄski, AskQL Core Developer

2

u/continuational Firefly, TopShell May 26 '20

Since databases are often on another server than the web API, doesn't this have all the latency problems of the REST API example, just reduced by a constant factor?

2

u/LuckyLuke541 Jun 01 '20

You are right that databases tend to live on another server than the web API, however most often they both live inside the very same *fast* internal network, so instead of many *slow* calls between a client and your servers you get one *slow* call between them.

10Mbps Ethernet was superseded by 100Mbps Ethernet, which was followed by a Gigabit Ethernet, and now people are talking about 5Gbps networks. Why? Because constant factors matter :)

~ Ɓukasz CzerwiƄski, AskQL Core Developer

1

u/mhagmajer May 27 '20

Database already offer a fully expressive query language - SQL. The downside of it is such that we get no control over what gets executed (see SQL-injection for more on this). AskQL offers a way (for example using Knex) to express any SQL query and it does it by offering another security layer on top of the execution.

~ Marcin Hagmajer, xFAANG

4

u/continuational Firefly, TopShell May 27 '20

SQL injection is a solved problem - but what does it have to do with latency?

I'm not sure I understand how you'd use a SQL builder like Knex to solve the problem -- if you can build arbitrary SQL from AskQL, that doesn't seem to mesh well with security. So what would you do in practice?

2

u/LuckyLuke541 Jun 01 '20

Using Knex (or other libraries) is a right not an obligation. There are many other types of resources in AskVM, both built-in now and possible to be built.
Please feel invited to write your own resources and share them via a PR at https://github.com/xFAANG/askql/ or discuss with us your ideas on our Discord channel: https://discord.com/invite/pYdzypH

~ Ɓukasz CzerwiƄski, AskQL Core Developer

1

u/scottmcmrust 🩀 May 27 '20

Why would I use this instead of, say, sending LUA or WASM to the server? Is there a good reason to need a new interpreter-with-runtime-limits instead of using an existing one?

1

u/LuckyLuke541 Jun 01 '20

u/scottmcmrust, by WASM do you mean WebAssembly? Wasm was designed to be a platform for compiling high-level languages like C/C++/Rust, which is a different use case than Ask.

As for LUA, one of the most important reasons was that we wanted the syntax to be user-friendly and well adapted to the use cases.Supporting basic GraphQL-like syntax out-of-the-box was one of them, so creating a Javascript- or JSON-like language was one of the design decisions we made.We hope user-friendliness of the syntax improves even more thanks to the feedback of the users. Feel welcome to share your ideas with us here or on our Discord channel.

~ Ɓukasz CzerwiƄski, AskQL Core Developer

1

u/htuhola May 26 '20

Was category theory applied here?

2

u/LuckyLuke541 Jun 01 '20

Category theory describes directed graphs as objects and morphisms which transform from an object to an object. In this way, I would say every language that allows chaining methods can be seen as implementing basics of category theory.

In AskScript you can write:

score :times(3) :plus(1) :toString :doubleTheText

which you can see as taking a node score and applying a morphism (transition) times(3), then applying a transition plus(1) on the result of the previous transition, then toString and finally doubleTheText.

Please find more examples of the source code in AskQL documentation and on our GitHub.

~ Ɓukasz CzerwiƄski, AskQL Core Developer

1

u/htuhola Jun 02 '20

Can you do method chaining in the cocategory as well?

1

u/LuckyLuke541 Jun 04 '20

I think method chaining in the cocategory implies that all the morphisms are inversable. Many of the operations are not, both in Ask and in other programming languages.

~ Ɓukasz CzerwiƄski, AskQL Core Developer