Git Product home page Git Product logo

askql's Introduction

AskQL is a new query and programming language that can express any data request.
Send executable code instead of JSONs.

  • Asynchronous by default
  • Processes only immutable data
  • Based entirely on the functional programming paradigm

Why and what for?

  • Next milestone after GraphQL and REST API
  • Send code to servers without the need to deploy
  • New safe query language
  • Compiled to clean functional code

Prerequisites

node >=12.14

Quick Start

Installation

In your Node project run:

npm install askql

Usage

Sample index.js file:

const askql = require("askql");

(async () => {
  const result = await askql.runUntyped(
    { resources: askql.askvm.resources },
    askql.parse("ask { 'hello world!' }")
  );

  console.log(JSON.stringify(result, null, 2));
})();

πŸ‘‰ More examples

Development & Contributing

Please find all important information here:

Contributing guidelines

Installation from source

  1. Clone the repository

git clone [email protected]:xFAANG/askql.git

  1. Install dependencies: npm i

  2. Build the project: npm run build

  3. Link the project to askql command: npm link

  4. Now you should be able to launch the interpreter (we use REPL for that): askql

Code examples

You can find all the examples in __tests__ folders (e.g. πŸ‘‰ AskScript tests) or in the Usage section below.

Documentation

Find AskQL documentation here.

The Documentation is divided into 4 parts:

Try It Yourself

Do not hesitate to try it out yourself! You can also find fellow AskQL devs in our Discord community.

Tools

CLI (AskScript interpreter)

Similar to python or node, AskScript CLI allows the user to type AskScript programs and get immediate result.

In order to run CLI:

  1. Build the code:

    npm run build
    
  2. Run:

    node dist/cli.js
    

Every input is treated as an AskScript program. For convenience, CLI expects just the body of your program, without ask{ }.

The editor has 2 modes - a default single-line mode and a multiline mode.

In order to enter the multiline mode, please type .editor.

At the end of your multiline input please press Ctrl+D.

    $ node dist/cli.js
    πŸ¦„ .editor
    // Entering editor mode (^D to finish, ^C to cancel)
    const a = 'Hello'
    a:concat(' world')

    (Ctrl+D pressed)

Result:

    string ask(let('a','Hello'),call(get('concat'),get('a'),' world'))
    'Hello world'

As the output CLI always prints AskCode (which would be sent to an AskVM machine if the code was executed over the network) and the result of the AskScript program.

Usage

  1. Write a hello world!

In AskQL we only use single quotes:

πŸ¦„ 'Hello world'
string ask('Hello world')
'Hello world'

In the response you get a compiled version of the program that is sent asynchronously to the AskVM.

  1. There are two number types
πŸ¦„ 4
int ask(4)
4
πŸ¦„ 4.2
float ask(4.2)
4.2
  1. Let's say we have a table of philosophers and their contribution to computer science as a score:
πŸ¦„ scorePerPhilosopher
any ask(get('scorePerPhilosopher'))
{
  Aristotle: 385,
  Kant: 42,
  Plato: 1,
  Russel: 7331,
  Turing: 65536,
  Wittgenstein: 420
}

Now let's find out the max score with a simple query:

πŸ¦„ max(scorePerPhilosopher)
int ask(call(get('max'),get('scorePerPhilosopher')))
65536

Nice!

  1. Write a first query, it can be a multi-liner. First step:

.editor

second step, we write the query:

query {
  philosophers
}

and here we have the answer:

any ask(query(node('philosophers',f(get('philosophers')))))
{
  philosophers: [ 'Aristotle', 'Kant', 'Plato', 'Russel', 'Turing', 'Wittgenstein' ]
}
  1. Exit the console!

ctrl + d

FAQ

What's the difference between ask { <askcode> } and eval( <javascript> )?

JavaScript's eval( <javascript> ) is terrible at ensuring security. One can execute there any code on any resources available in Javascript. Moreover there is no control over time of execution or stack size limit.

On contrary, Ask's ask { <askscript> } runs by default on a secure, sandboxed AskVM, which has a separate execution context. We have built in control mechanisms that only allow using external resources you configured. Ask programs are also run with the limits on execution time and stack size restrictions you define.

Troubleshooting

If you didn't find answers to your questions here, write on ourour Discord community. We will both help you with the first steps and discuss more advanced topics.

License

The code in this project is licensed under MIT license.

Core Team

  • Marcin Hagmajer (ex-Facebook)
  • Łukasz CzerwiΕ„ski (ex-Google)

askql's People

Contributors

czerwinskilukasz1 avatar mhagmajer avatar yonatankra avatar undomalum avatar tuhaj avatar xfaang-ci avatar kgajowy avatar piotrczubak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.