← Back to context

Comment by _jal

4 years ago

Designing languages around autocomplete is like designing toilets for better toilet paper dispensers.

The language should be right for human understanding, not automated mad-lib generation.

You would think that but having used both I find writing Kusto/KQL much smoother, neater and faster and if I have to choose between writing a query in either one I'd pick KQL.

I understand this is just an opinion but it's an opinion held by everyone in my org who writes both.

Theoretical correctness loses to pragmatism a lot and I'd read the KQL every day. Look at the examples at https://docs.microsoft.com/en-us/azure/data-explorer/kusto/q... - look at the examples at https://docs.microsoft.com/en-us/azure/data-explorer/write-q... and tell me they're not more readable than comparable SQL?

(I can see the result type both by hovering on the query but also by just looking at the end of it - and in SQL most of the SELECTed items in complex queries are from subqueries anyway - at least in my use case)

Building for autocomplete is building for human understanding. If it is impossible for a computer to determine the context of your query, why would a human do much better?

  • They are not fully-aligned goals, and autocomplete should not be given equal consideration on par with human clarity.

    If you want nice autocomplete too, that's fine, but if there is a tradeoff, human understanding is the primary concern.

    • I don't understand why do you think about it this way

      C#'s LINQ (really powerful tool similar to SQL) works the same way

      look:

      var list = new List<int>{1,2,3}

      var extracted = list

      .............................Where(x => x > 1)

      .............................Select(x => $"my number: {x})

      .............................ToList();

      or

      var extarcted =

      ........................from x in list

      ........................where x > 1

      ........................select $"my number: {x};

      1 reply →

I’ve been frustrated by toilets where I have to contort my body to reach the dispenser. Similarly, I’ve had dispensers intrude on the space where my legs would normally be and make it awkward to even just sit on the toilet.

Toilets are absolutely designed to make the dispenser placement convenient. You just don’t think about it because 95% of toilets get it right, so it just doesn’t bother you that much that it can be wrong.

In SQL, some decisions are right about 10% of the time and are annoying and awkward the other 90%.

That’s why the order matters. Because everything else got it right.

I'd agree if there was any way whatsoever of fixing this issue, but there simply isn't. The editor can't even begin to guess what you might want until you write your FROM.

  • Maybe in gigantic systems with more tables than makes sense. Realistically, all of the columns available in a database can be fit in memory with ease.

    Then, the ide could basically fill my from out for me, based on what I'm asking for. Can even suggest what join I will need, if I list columns from multiple tables.

    • >Maybe in gigantic systems with more tables than makes sense. Realistically, all of the columns available in a database can be fit in memory with ease.

      Every table has more than one column

      So there's always more columns to remember than tables and generally tables are pretty easy like user invoices blabla

      I worked with systems that had like 500 tables and some of them with 20-50 columns

      you really want good intellisense in such a environment

      3 replies →

And one of use cases is writing queries which it helps immensely. Best of both worlds would allow both orders. Just automatically transform the query to the usual form after it's execution.