Two New AWS SDK Releases
Written by Nikos Vaggalis   
Monday, 11 December 2023

SDKs for Kotlin and Rust have been released, almost simultaneously, by Amazon Web Services, both ready for production use.

November 27 saw the announcement of the general availability of the AWS SDK for Kotlin, followed the next day with the announcement of the general availability of the AWS SDK for Rust.

While Kotlin devs could write Kotlin on AWS , it was through the Java SDK as Kotlin was converted to Java. As such, there wasn't a native Kotlin experience. This SDK changed that, by taking full advantage of the Kotlin language and allowing devs to write idiomatic Kotlin.

This is especially of value to Android devs as code for the platform is almost exclusively written in Kotlin. As such the new SDK supports Android API 24+ as a first class target. The SDK was also developed as a multiplatform library from the beginning so that you can use it to write code that is shared between Linux, Windows and MacOS.

It's main features are:

Idiomatic Kotlin
The SDK provides DSLs following a type-safe builder pattern to create requests.

First class coroutines support
The SDK is asynchronous by design. It uses suspend functions for all service operations, which must be called from a coroutine.

Streaming operations
Operations involving streaming output, like Amazon S3 getObject, are scoped to a block. Instead of returning the response directly, you supply a lambda that is given access to the response (and the underlying stream). This scoping of streaming responses simplifies lifetime management of resources for both the caller and the runtime.

Pagination
To maximize availability and minimize latency, many AWS APIs break up a result across multiple “pages” of responses. The SDK can handle this automatically for you.

Waiters
When working with services that are eventually consistent, or services that asynchronously create resources, it is common to write logic that periodically polls the status of a resource until a desired state is reached or an error occurs. The SDK provides waiters that can handle this polling logic for you.

Pluggable HTTP layer
The SDK includes a default HTTP client (based on OkHttp) that works well for most use cases. However, there may be benefits to using a client that is more optimized for your runtime environment (for example, to optimize AWS Lambda cold start times). The SDK allows the HTTP client to be configured with another implementation that better suits your use case.

Now let's take a look at the next SDK, that of Rust.

The SDK supports modern Rust language features like async/await, non-blocking IO, and builders. It provides access to 300+ AWS Services, each with their own crate. No wonder that in order to support that many Services, the Rust SDK is built on top of the smithy-rs code generator. We've examined the value of Smithy in Model Your APIs With AWS Smithy:

Smithy was initially developed for use in Amazon's own services and internal use but has been nevertheless released to the public as an open source project since 2019. As a matter of fact Smithy has now become the default choice at Amazon for modeling services.

Why is that? First of all it's a protocol-agnostic IDL, meaning that it is designed to work with any programming language, describe services running in any environment, and work with any kind of transport or serialization format. Then, its code generation can be extended with custom traits and enable automatic API standards enforcement.

As such, the SDKs are generated from interface files , therefore are always in-sync with the Services APIs in every language.

The Rust SDK is also modular, allowing customers to compile crates only for the services they use. As a matter of fact, it itself can be accessed through crates. io. Additionally to adding custom crates to your Rust project you can as well add an async runtime such as Tokio. For instance, an example of using Tokio for listing your DynamoDB tables with the Rust SDK

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let sdk_config = aws_config::load_from_env(). await;
let client = aws_sdk_dynamodb::Client::new(&sdk_config);
let res = client
. list_tables()
. limit(10)
. send()
. await?;
println!("Current DynamoDB tables: {:?}", res. table_names());
Ok(())
}

So there you have it. More reasons for devs to go AWS!

More Information

Announcing general availability of the AWS SDK for Rust

Announcing general availability of the AWS SDK for Kotlin

Related Articles

Model Your APIs With AWS Smithy

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Is PHP in Trouble?
10/04/2024

The April 2024 headline for the TIOBE Index, which ranks programming languages in terms of their popularity, reads, "Is PHP losing its mojo" asking this question because this month PHP has dropped out [ ... ]



Insights From AI Index 2024 Report
17/04/2024

Published this week, the latest Stanford HAI AI Index report tracks worldwide trends in AI. A mix of its new research and findings from many other sources, it provides a wide ranging look at how  [ ... ]


More News

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Monday, 11 December 2023 )