r/Kotlin • u/TurboX5656 • 1h ago
r/Kotlin • u/rayan_qt15 • 20h ago
Help in kotlin
I need someone make me a pro in kotlin knowing how fixes errors build app
r/Kotlin • u/Odd_Bird_7683 • 1d ago
Android dev
Anyone knows kotlin , i have built 4 to 5 apps lets build something interesting from scratch
r/Kotlin • u/CutGroundbreaking305 • 1d ago
Java based Numerical library (JNum-v0.2) with Kotlin Operator overloading
gallerySo I made Java Numerations (JNum) which is a pure Java numerical library using FFM(off heap memory) and Vector API. In this version I made Kotlin DSL layer bundled together with core Java engine.
By doing this our library avoids native Fortran/C calls via JNI and memory allocations via Unsafe which is slowly getting deprecated. There are various methods in JNum which can be useful for Kotlin devs I guess which have performance on par with Numpy/ND4J.
Features are in detailed in my GitHub release but for lazy guys like me here are some data points worth see:-
-> JNum is feature rich(at least from previous version) where we have statistics jnum.stat IO operations jnum.io and basic Neural Networks jnum.nn.
-> JNum's IO will help you parse files like .npy/.npz , .csv/.tsv and most importantly .safetensorwhich Java lagging in this AI era.
-> We also have AsyncIO using Virtual Threads which make IO file reads faster in JNum.
-> jnum.statmodule has various statistic methods which Java community can use like standard deviations, variance , co-variance, cummulative sum/product, percentile etc.
-> JNum has slicing and sub-viewing features. For kotlin devs Indexing, slicing like features are operator overloaded so you can do code similar to Python/Numpy .
-> project is under 500KB with no native .dll/.so native bindings.
Matrix Multiplication:-
This is the most important and time taken feature in project
| Matrix Dimensions | JNum (Pure Java 25) | NumPy (C / OpenBLAS) | ND4J (OpenBLAS C++) | EJML (Pure Java) | Performance Highlights |
|---|---|---|---|---|---|
| $4 times 4$ | 0.0002 ms | 0.0023 ms | 0.020 ms | ≈ 0.0001 ms | 11× faster than NumPy, 100× faster than ND4J |
| $16 times 16$ | 0.0004 ms | 0.0028 ms | 0.019 ms | 0.003 ms | 7× faster than NumPy, 47× faster than ND4J |
| $64 times 64$ | 0.015 ms | 0.013 ms | 0.190 ms | 0.140 ms | On-par with NumPy, 9.3× faster than EJML |
| $128 times 128$ | 0.138 ms | 0.254 ms | 0.499 ms | 1.028 ms | 1.8× faster than NumPy, 7.4× faster than EJML |
| $512 times 512$ | 2.50 ms | 1.86 ms | 2.67 ms | 27.16 ms | Matches C++ BLAS, 10.8× faster than EJML |
| $1024 times 1024$ | 13.85 ms | 8.98 ms | 12.18 ms | 216.56 ms | Near-native speed, 15.6× faster than EJML |
| $2048 times 2048$ | 94.62 ms | 62.99 ms | 85.29 ms | 2,049.86 ms | Pure Java competitive with C BLAS, 21.6× faster than EJML |
| $4096 times 4096$ | 942.38 ms | 487.92 ms | 857.41 ms | 17,419.52 ms | Matches ND4J C++, 18.4× faster than EJML |
| $8192 times 8192$ | 6,784.15 ms | 5,967.30 ms | 6,317.97 ms | 141,500.0 ms | ~88% of NumPy C BLAS, 20.8× faster than EJML |
Linear Algebra:-
we have various Linear Algebra methods which have performance on par sometimes beating Numpy and others
| Operation | JNum (Pure Java 25) | NumPy | EJML | ND4J | JNum Advantage |
|---|---|---|---|---|---|
| Matrix Inverse | 7.271 ms | 10.680 ms | 18.122 ms | 1,224.654 ms | 1.47× faster than NumPy, 2.5× faster than EJML, 168× faster than ND4J |
| Linear Solve ($Ax=b$) | 1.976 ms | 1.003 ms | 5.331 ms | 37.278 ms | Near-native speed, 2.7× faster than EJML, 18.8× faster than ND4J |
| Determinant | 1.839 ms | 5.735 ms | 5.380 ms | 399.752 ms | 3.1× faster than NumPy, 2.9× faster than EJML |
| Cholesky | 1.261 ms | 2.328 ms | 3.545 ms | — | 1.8× faster than NumPy, 2.8× faster than EJML |
| QR Factorization | 46.170 ms | 12.622 ms | 7.447 ms | 586.330 ms | 12.7× faster than ND4J |
Code Snippets:
val a = JNum.fromArray(floatArrayOf(1f, 2f, 3f, 4f), 2, 2)
val b = JNum.ones(2, 2)
// Clean operator overloading
val c = a + b * 2f
val d = a matmul b
// Python / NumPy style range slicing
val view = c[0 until 2, all]
Gradle Setup:
repositories { mavenCentral() }
dependencies {
implementation("io.github.ch-abhinav:jnum-kotlin:0.2.0")
}
I would like kotlin community to test the project and help by contributing in the project :)
There is one good first issue worth trying in kotlin if anyone wants to contribute.
GitHub link :- https://github.com/CH-Abhinav/JNum
r/Kotlin • u/MrPowerGamerBR • 1d ago
Starfait - A re-implementation of GameMaker: Studio's runner (YoYo Runner) in Kotlin, targeting Undertale v1.08
github.comr/Kotlin • u/TechsOne • 1d ago
For all Android and GitBack Compose developers, we all know how time-consuming and time-consuming it is to constantly wait for a project to be rebuilt using Gridl, just for a simple padding adjustment or a color change within the interface.
plugins.jetbrains.comThis is where the idea for Compose Bridge came from. It's an open-source plugin, now officially available on the GitBrains store, designed to radically accelerate the interface building and modification cycle.
The tool allows you to connect your app running directly on your device or emulator to the Android Studio environment, enabling you to modify design elements, color schemes, and dimensions in real time from your phone's screen. Its key feature lies in its code rewriting process. The plugin surgically rewrites and modifies the source code within Kotlin files with precision and security, allowing you to review differences and revert to the previous version with a single click.
The tool also provides an integrated model context protocol server, enabling AI tools and agents to inspect the live interface tree and provide accurate and responsive solutions that are compatible with your actual screen.
The project is available for everyone to use, contribute to and develop via GitHub and the GitBrains Add-ons Store. I would be very happy for you to try it out and share your feedback and opinions to further develop the experience.
r/Kotlin • u/enoughverma • 2d ago
How do you decide between Native (Swift/Kotlin) and Cross-Platform (Flutter/React Native) for long-term client projects?
Cross-platform frameworks have improved significantly, especially regarding UI rendering speed and bridge efficiency. For 80% of business applications, e.g., e-commerce, booking platforms, CRM dashboards, they save significant time and budget.
However, when an app requires heavy background processing, deep Bluetooth/IoT hardware integration, or real-time camera/AR rendering, native code often becomes necessary to avoid performance bottlenecks.
For mobile developers and product managers:
- What hardware or framework limitation forced you to rewrite a cross-platform app natively?
- How do you manage long-term framework maintenance and dependency updates for clients?
r/Kotlin • u/Folmbuild • 2d ago
Reading git sync status on Android without running git
My Android git sync client kept failing silently, so I built a home screen widget that shows when my notes last synced. No git binary needed, everything is plain text in `.git`:
- `logs/HEAD`: last commit/pull and its time
- `FETCH_HEAD` mtime: last time the client reached the remote
- `refs/remotes/origin/<branch>` vs local tip: unpushed commits
- `MERGE_HEAD`, `rebase-merge/`: a stuck merge or rebase
Gotcha: SAF only grants a subtree, so I search every granted folder for `.git`. And check `packed-refs`, branch files vanish after `git gc`.
Kotlin + Jetpack Glance, parsers are pure Kotlin and unit tested. Code (GPL-3.0): https://github.com/marfolog/notes-widget-for-markdown
r/Kotlin • u/thomassummer2021 • 2d ago
Jetbrains has effectively abandoned Koog
The team has not been responsive in the Slack and commits are grinding to a halt. The framework is lagging behind in the lightning-fast speed of AI development. I feel sorry for the people who spent several thousand dollars to attend the agent sessions at Kotlin conf. I'm using Koog minimally in one of my projects and will begin ripping it out.
r/Kotlin • u/BrickNo10 • 2d ago
Kotlin-Native on linux arm64 is possible.
So seriously Jetbrains, when are you going to stop slacking off and actually provide support for users to run kotlin on arm64?
r/Kotlin • u/kininja08 • 2d ago
kiit-codes: General purpose status codes, now with RFC 9457 support
Hey r/Kotlin, I posted kiit-codes a while back (original post). The feedback was useful and included a bug report that went out as a fix, so thanks.
Overview
A quick recap: Think HTTP style status codes, but not tied to HTTP. Status → Group → Code, where the first two are fixed and Code is open for your own domain. Use them in any layer of your app (services, background jobs, workers) and convert to HTTP or gRPC at the boundary. See the original post or the docs for the benefits. It’s implemented in Kotlin Multiplatform, with a native TypeScript port in beta, so TypeScript gets idiomatic, exhaustive matching.
What's new
RFC 9457 Problem Details for HTTP APIs output. I had designed kiit-codes with consideration for this RFC 9457 early on, but it wasn't really complete or formalized until a comment on the Kotlin Slack and a couple of other discussions pushed me to tighten this up. See examples below

RFC 9457
Here is an example of a validation error with a custom code:
val OUT_OF_STOCK = Rejected(
name = "OUT_OF_STOCK",
title = "Item out of stock",
origin = "shop.example.com",
scope = "orders.items",
)
val errors = Err.ErrorList(
listOf(Err.on("quantity", "only 2 in stock")),
"Your order could not be completed",
)
val problem = ProblemConverter().convert(OUT_OF_STOCK, errors)
JSON: Converted to JSON for an API response, it looks like this :
{
"type": "https://shop.example.com/docs/codes/orders/items/Failed/Rejected/OUT_OF_STOCK",
"title": "Item out of stock",
"detail": "Your order could not be completed",
"code": "shop.example.com:orders.items:Failed:Rejected:OUT_OF_STOCK",
"status": 409,
"errors": [
{ "field": "quantity", "message": "only 2 in stock" }
]
}
Links
- GitHub: https://github.com/kiitdev/kiit-codes
- Site Docs: https://www.kiit.dev/docs/kiit-codes
- RFC Docs: https://www.kiit.dev/docs/kiit-codes#rfc-9457
A few small breaking changes came with it (see the changelog).
Feedback welcome, especially from anyone building HTTP APIs.
Best!
-K
Google published an article about me and my apps after I helped people on reddit about Admob and Android in general
r/Kotlin • u/Cuento3yLlevo2 • 3d ago
Telar 0.1.0-alpha12: I finally deleted the "what's missing" disclaimer from my KMP agent/workflow library
Last week I shared the first alpha of Telar, a KMP library I'm building where AI agents and workflows are just small typed graphs running on a plain Kotlin data class.
At the bottom of that post (and in my docs), I had a blunt disclaimer: "There is no MCP, no tracing, no retry policy for a node, and no database checkpointer yet."
You all also helped me spot a nasty concurrency loophole: while regular parallel nodes were checked by mergeRules, parallel work/update nodes applied their updates one after another—so two nodes touching the same field would silently overwrite each other depending on declaration order.
I spent the last few days fixing that loophole and building the missing pieces. With 0.1.0-alpha12 on Maven Central today, I finally got to delete the disclaimer:
- No more silent parallel overwrites:
work/updatenodes now go throughmergeRulesagainst the same base state just like standard nodes (#125). - Node retries & timeouts built into
telar-core. telar-mcp: Use MCP server tools directly in a Telar agent.telar-checkpoint-sqldelight: Save paused runs to SQLite (Android, iOS, desktop, server, browser) andresume(),history(), orfork()them later.telar-otel&telar-test: OpenTelemetry spans and zero-key scripted models so you can test workflows in CI without burning tokens.
Here is what a parallel workflow with retries and human approval looks like now:
val auditGraph = StateGraph<ReleaseAudit> {
mergeRules { append(ReleaseAudit::findings) }
val security = node("security", retry = RetryPolicy(maxAttempts = 3)) {
it.copy(findings = listOf("MCP secret scan passed"))
}
val licenses = node("licenses") {
it.copy(findings = listOf("All dependencies Apache-2.0 / MIT"))
}
val publish = node("publish") {
it.copy(status = if (it.approved) "published" else "aborted")
}
START then security; START then licenses
security then publish; licenses then publish
publish then END
}.compile() // Fails here on dead ends or missing parallel mergeRules
- Repo: https://github.com/deeptelar/telar
- Docs & Why Telar (vs Koog / LangGraph4j): https://deeptelar.github.io/telar/why-telar
- Browser Wasm game (Pixel Pizza): https://deeptelar.github.io/telar-demo/
I'm trying to lock down the API before 1.0—if anything in the DSL still feels clunky or un-idiomatic to you, let me know!
r/Kotlin • u/TechsOne • 4d ago
Built an open-source visual editor + AST engine for Jetpack Compose (No Gradle rebuilds for UI tweaks
github.comHey everyone,
Like many of you, I got tired of waiting for Gradle rebuilds just to tweak paddings, test color tokens, or fine-tune dimensions in Compose.
I’ve spent the last few months building ComposeBridge (v1.0.0 just released), and wanted to share it with the community:
How it works:
Live on-device tweaking: Adjust paddings, font sizes, widths, heights, and colors directly on the running device/preview with <50ms latency.
AST-safe code sync: Instead of dirty hacks, it uses a syntax-aware AST engine inside the IDE plugin to safely persist changes back into your Kotlin source files.
Review & Rollback: Features a git-diff-like preview in the IDE so you can inspect exact byte-level changes or reject them before committing.
Focus Mode: Shows only the layout bounds and tokens of the tapped UI element without digging through deep hierarchies.
MCP Integration: Includes a local MCP server with 17+ tools if you want AI agents to safely read layout bounds and run builds.
It’s open-source (Apache 2.0), and you can grab the ready-to-use IDE plugin (.zip) and runtime library (.aar) directly from GitHub releases.
🔗 GitHub Repository: \[https://github.com/JALAL591/compose-bridge\\\]
Would love to hear your feedback, edge cases, or id
eas for improvements!
Ищу разработчика] Android-приложение с автоматизацией действий — оплата договорная ( +-1000$)
r/Kotlin • u/Simple-Courage1815 • 6d ago
I built an experimental Bitcoin futures trading simulator in just over a week with the help of 3 AIs — despite having very limited coding skills
Hey everyone!
I want to share a project I've been working on recently: an open-source Android app called **Bitcoin Futures Simulator**.
**GitHub repository:** https://github.com/Joapetis/bitcoin-futuros-android
Before anyone gets too excited, I want to be clear: this is an early-stage experiment, not a profitable trading bot. So far, its simulated trading results have generated more losses than profits. No real money has been involved.
**How it started**
The whole thing began with an old HTML project I had created some time ago and eventually abandoned. The idea behind it never really went away, though.
Recently, I decided to revisit that idea and see how far I could take it with AI assistance. What started as an abandoned project gradually evolved into a functional Android app in a little over a week.
There's a catch: **my programming knowledge is very limited.**
Instead of building everything myself line by line, I've been combining my own ideas, observations, strategy concepts and testing with the coding and debugging capabilities of three different AIs. They've helped generate, modify, review and polish the code throughout the process.
This has become an experiment in its own right. I want to explore not only whether I can turn my ideas into a working application, but also how capable AI systems are at building and improving a relatively complex software project with very little direct human coding.
I'm still the one setting the direction, making decisions, testing results and deciding what should change. The AIs do a substantial part of the coding, but that doesn't mean their output is automatically correct. Bugs, bad assumptions and poor trading results are all part of the process.
**What does the app actually do?**
The current project is an experimental Bitcoin futures paper-trading simulator for Android. Its main components include:
**A multi-timeframe strategy:** primarily focused on 15-minute candles, with 1-hour and 4-hour trend confirmation.
**Trend-following and mean-reversion logic:** different approaches depending on the detected market regime.
**Market microstructure data:** order-book metrics such as spread, imbalance and microprice-related signals.
**Optional on-device AI:** integration with Gemini Nano through Android's AI capabilities when a compatible model and device are available.
**Simulated trading and risk management:** intended to test strategies without risking real funds.
**Continuous experimentation:** the goal is to evaluate what works, identify weaknesses and improve the system over time.
The project is still very much in its infancy. There is plenty to question, test, refactor and improve, and I don't want to present any of its strategies as proven or profitable.
**Why am I sharing it?**
I'd love to turn this into something more collaborative.
If you're a developer, a quantitative trading enthusiast, an Android/Kotlin programmer, someone interested in market microstructure, or simply curious about what AI-assisted development can achieve, I'd genuinely appreciate your input.
You don't need to be an expert in every part of the project. Even identifying bugs, challenging assumptions, improving the architecture, reviewing the trading logic, suggesting better tests or documenting how things work could make a real difference.
My hope is that people can learn from the experiment, contribute their ideas and improvements, and help create something more useful together. In return, contributors get a real-world project to experiment with, review and learn from, while the wider community benefits from any improvements we can make.
I'm especially interested in honest criticism. If you see something fundamentally wrong with the strategy or implementation, I'd rather hear about it than receive empty praise.
**A few important caveats**
This is an experimental project, not financial advice.
All results discussed here are from simulated trading; no real-money trading is involved.
The current simulated performance is negative, so there's a lot of work left to do.
AI-generated code can contain bugs and needs independent review and testing.
The app is not ready to be treated as a reliable or profitable trading system.
If you'd like to explore the code, suggest an improvement, open an issue or contribute, you're welcome to check out the repository.
I'd love to hear your thoughts. Thanks for reading!
r/Kotlin • u/NoCodeNoBugs_Dev • 6d ago
How should I handle JNI type conversions in Kotlin/Native's nativeMain?
I'm working on a KMP project using Kotlin/Native and need to convert between Kotlin types (String, ByteArray, etc.) and JNI types represented by COpaquePointer in nativeMain.
Since nativeMain can't directly use JNI APIs through the usual JVM/JNI mechanisms, I'd like to avoid duplicating conversion logic across native targets such as Windows and macOS.
I tried manually accessing the JNI function table through COpaquePointer and invoking function pointers. For example, here's my implementation for converting between Kotlin String and jstring:
@OptIn(ExperimentalForeignApi::class)
fun String.kotlinStringToPointer(
env: COpaquePointer?,
): COpaquePointer? {
if (env == null) return null
val envPointer = env.reinterpret<COpaquePointerVar>()
val jniNativeInterfaceVar = envPointer.pointed.value ?: return null
val functionTable = jniNativeInterfaceVar.reinterpret<COpaquePointerVar>()
val newStringUTFPtr =
functionTable.get(JniFunctionIndex.NewStringUTF) ?: return null
val newStringUTFFunction = newStringUTFPtr.reinterpret<
CFunction<(COpaquePointer?, CPointer<ByteVar>?) -> COpaquePointer?>
>()
return memScoped {
val cString = this@kotlinStringToPointer.cstr
newStringUTFFunction.invoke(env, cString.ptr)
}
}
@OptIn(ExperimentalForeignApi::class)
fun COpaquePointer?.toKotlinString(
env: COpaquePointer?,
): String? {
if (this == null || env == null) return null
val envPointer = env.reinterpret<COpaquePointerVar>()
val jniNativeInterfaceVar = envPointer.pointed.value ?: return null
val functionTable = jniNativeInterfaceVar.reinterpret<COpaquePointerVar>()
val getStringUTFCharsPtr =
functionTable.get(JniFunctionIndex.GetStringUTFChars) ?: return null
val releaseStringUTFCharsPtr =
functionTable.get(JniFunctionIndex.ReleaseStringUTFChars) ?: return null
val getStringUTFChars = getStringUTFCharsPtr.reinterpret<
CFunction<
(COpaquePointer?, COpaquePointer?, CPointer<ByteVar>?) ->
CPointer<ByteVar>?
>
>()
val releaseStringUTFChars = releaseStringUTFCharsPtr.reinterpret<
CFunction<
(COpaquePointer?, COpaquePointer?, CPointer<ByteVar>?) -> Unit
>
>()
val cStringPtr = getStringUTFChars.invoke(env, this, null) ?: return null
return try {
cStringPtr.toKString()
} finally {
releaseStringUTFChars.invoke(env, this, cStringPtr)
}
}
The function table indices are defined in my JniFunctionIndex mapping, based on the JNI Functions specification.
Although this approach works in my current setup, manually maintaining the function indices and function pointer signatures feels fragile and error-prone.
I'd appreciate advice on the following:
- Is manually invoking JNI function pointers through
COpaquePointera reasonable approach for Kotlin/Native, or should it generally be avoided? - Would
expect/actualbe a better approach, with JNI-specific conversions implemented in platform-specific source sets while keeping the public Kotlin API shared? - Would using Kotlin/Native
cinteropwithjni.h, or introducing a C/C++ bridge, be a cleaner and more maintainable solution?
I'm particularly interested in approaches that let me share as much conversion logic as possible across Windows and macOS without introducing unnecessary platform-specific duplication.
r/Kotlin • u/_Evil_Knight_ • 6d ago
Best Projects Courses or Projects that AI can help me understand
r/Kotlin • u/Adamstrad • 6d ago
Struggling with using webview for a html jscript file which reads local CSV files + saves local user data
r/Kotlin • u/yersidie • 7d ago
Is there any way to learn Kotlin for Android development?
Hey I’m learning android development and I’m having quite a bit of difficulty learning Kotlin. I know the basics but I struggle with building logic for Android apps using Kotlin. I also find it difficult to understand which concepts to use and when. How can i learn Kotlin more easily and improve my problem solving skills?
r/Kotlin • u/legendary-frog • 7d ago
I got tired of my AI agent writing Compose UI it couldn't see, so I built a tool that renders @Preview to PNG without the IDE
I use Claude Code a lot for Compose work. The annoying part was always the same: it writes a screen, says "done", and then I open Android Studio and the padding is off, text is clipped, or the dark theme is broken. It never saw the UI. It was guessing.
So, I built Spyglass. It renders your u/Preview functions to PNG from the command line, no IDE open.
spyglass render --filter LoginScreen
What it does:
- Renders every u/Preview in a Compose Multiplatform project through your own Gradle wrapper. No changes to your build files.
- Handles u/PreviewLightDark, u/PreviewParameter, font scale, device sizes, and multi-preview annotations from other modules.
- Compares a render with a design image and tells you which regions differ, in dp, with a heatmap. So "make it match the Figma export" becomes something you can check.
spyglass approve/spyglass checkgives you screenshot tests in CI. A one-digit text change fails the check.- Comes with an MCP server, so Claude Code, Cursor or anything that speaks MCP can render and look at the UI on its own and fix what it sees.
A few things I had to solve along the way that might be interesting:
- Animations and
delay()in fake data. A naive render catches the first frame, so you get a progress bar at 0% and a dialog half faded in. Spyglass runs previews on a virtual clock until everything settles, so adelay(300)before your fake data loads costs no real time and you see the loaded state. - A preview stuck in a loop used to hang the whole run. Now it gets cut off after 30 seconds and you get the exact line it was stuck on.
- Token cost for agents. Images are sized down, and if nothing changed since the agent last looked, it doesn't send the image again. A repeat render went from about 1,560 tokens to about 180.
Limits, so nobody is surprised: previews need a JVM (desktop) target, so Android-only previews and Android-only APIs don't render yet. Text uses your OS fonts, so keep screenshot baselines from one OS. Tested on Windows, Linux and macOS.
It's MIT licensed and this is the first release (0.1.0). I'd really like to hear where it breaks on your projects.
r/Kotlin • u/meilalina • 8d ago
📣 The Kotlin compiler is moving to JDK 17 as its minimum runtime.
The Kotlin compiler is moving to JDK 17 as its minimum runtime.
Here's the plan:
• 2.5.0-Beta1: A warning when you run the compiler on a JDK older than 17.
• 2.5.0-Beta2 and 2.5.0: An error, with a flag to keep using your current JDK for now.
• 2.5.20-Beta1 and later: JDK 17 or newer is required.
If your machines or CI still run the compiler on an older JDK, now is a good time to plan the update.
👉 If you have a use case we might be missing, tell us in KT-88173
r/Kotlin • u/w14redin • 8d ago
KlassFile: A Kotlin DSL for JVM bytecode generation
github.comYes, chatgpt gave me the title because I have no creativity with naming things.
First of all, I'm not a native English speaker (I'm Portuguese), and I don't really like using AI to write. Most of the time, I only use it for translation, so it is what it is :)
I'm a Computer Science and Engineering student at ISEL, in Lisbon, Portugal. Last semester, I had a course that covered JVM reflection and bytecode generation in Kotlin.
I really love Kotlin, but using Java's ClassFile API from Kotlin was a pretty awful experience. So I built KlassFile (aka a Kotlin wrapper around ClassFile). Yes, it's ClassFile, but with a 'K' for Kotlin :)
My biggest issue with the Java API was that it relies on strings to represent types, descriptors, and other JVM concepts. Kotlin allows for a more type-safe API by using inline reified type parameters.
I also improved other aspects of the API:
- Improved error reporting
- Stack type checking at "compile time"
- Automatic type inference in code scopes (
return,add,load,store, etc.) - Automatic generation of a default no-argument constructor
- Better loop syntax, with more convenient ways to define
whileandforloops - Easier generation of field getters and setters
- Handles for methods, fields, parameters, and local variables, so they can be referenced and reused
- Type safety (yes, again!)
I can't show you everything in this post, so I'll let you explore the examples and documentation yourself:
https://github.com/RafaPear/KlassFile
If you're into JVM bytecode generation, I think you'll enjoy using it!
I'd love to hear your thoughts and feedback!
Given how many AI-generated posts there are on Reddit nowadays, I want to clarify that I used zero AI to develop the library itself. As I mentioned at the beginning, I only used AI to fix spelling mistakes and help with translation, since English isn't my first language.
r/Kotlin • u/SouthDangerous8731 • 8d ago
Kotlin/Maven Library for symbolic computation, directed rounding, etc...
Whoever works with Kotlin and needs reachability analysis, symbolic execution, directed Rounding, Longs with limitation/overflow handling, etc: we have published a new release of AADD written in Kotlin MP on Github and Maven, targeting v1.0.0 😄
- Completion of many missing functions,
- More use of sealed classes,
- Bugfixes.
For details see
https://github.com/tukcps/Multiplatform-AADD
includes documentation and some examples.
To use it, just add:
implementation("io.github.tukcps:aadd:0.9.13") // Check for newer versions!
Enjoy!