:technologist: If you haven't tried <Kotlin Notebo...
# education
k
🧑‍💻 If you haven't tried Kotlin Notebook yet, check out the new blog post to see how it can help you teach programming. Kotlin Notebook lets you combine runnable code, Markdown explanations, and visuals in one interactive space. • It supports incremental execution, allowing you to show language constructs and code snippets in an isolated way, debugging, testing, and rerunning chunks of code without restarting the whole script • Notebooks combine different types of data in a single environment • Everything can be easily shared and launched in preset setups Give it a try and let us know what worked (or didn’t)!
c
Is there a plan to unify it with the capabilities of the HTTP client? Both of these feel very similar. For example, we have a few
.http
files to easily test some of our endpoints. These contain assertions in JS, which are honestly not fun to write. Having the ability to use Kotlin code for the assertions would help a lot, and the ability to use Markdown snippets would help too. But right now, it's not as easy to declare HTTP requests in Notebooks, and also Notebooks are much more expensive in performance (lots of RAM+they're slow).
k
Hi Ivan! Sorry for such a late reply. Here's a response I got from the Notebook team:
We don't have such plans.
For writing HTTP requests, we have
%use ktor-client
, wrapper on top of Ktor library: https://github.com/Kotlin/kotlin-jupyter-http-util
But it's true it's not integrated with .http files well.
If you have any ideas of how this integration might look like, let's discuss your use case and ideas in detail
c
I'm thinking: • Add a third type of cell in notebooks (current: Markdown, Kotlin; add: HTTP) • Within the HTTP kind of cell, all the features of .http files are available (so not just HTTP, but also gRPC etc) • If we use the JS APIs within the cell to create a new variable, that variable is also exposed in subsequent Kotlin cells as a regular Kotlin variable • The result of the request itself (the JS variable
request
) is exposed in subsequent Kotlin cells, using the existing mechanism of the Ktor client to make it typesafe etc I think this would go a long way into making HTTP files more convenient to use, because: • The developer experience with JS assertions in HTTP files is quite poor (no autocomplete, etc) → Kotlin Notebooks have a feature to solve this! • Writing HTTP requests in Notebooks is possible thanks to the Ktor integration, but for non-Ktor users it can be more difficult to know what to write compared to a plain .http file where the request is written as-is → having the ability to write plain old HTTP in Notebooks would make Notebooks more approachable I think they both have features that have lots of benefits for the other
We currently use HTTP files for: • quick tests: we have a file for each resource with an example usage of each of its endpoints, this way we can quickly run one and see what is returned → these usually have very simple coherence assertions which would be better to write in Kotlin as the server is in Kotlin already • initial data setup: these just create some initial entities, they are fine as HTTP files • cookbooks: specific files to interact with the system at the API-level, using functionality not available to users. e.g. "kill all the on-going tasks and restart them all" or "list all the connected users" etc. These are either troubleshooting guides or data analysis tools. → Notebooks would be more convenient because they offer lots of tools to create graphs etc All of these are written by the devs, the last type are written for non-dev people (support staff, POs…). Because it's the devs who write them all, it's simpler if they all use the same tooling, and HTTP files are easier to write so that's what they use. However, Notebooks have many advantages for analysis/etc, and the ability to write formatted text, which would be very interesting if it didn't mean having to rewrite them all with a new syntax.
k
Cc: @Ilya Muradyan
👀 1