My fingers are lazy, and typing parentheses on a Q...
# stdlib
l
My fingers are lazy, and typing parentheses on a QWERTY keyboard requires 2 hands (or streching). Consequently, I'd like the following to be provided in Kotlin stdlib out of the box:
val TODO: Nothing inline get() = TODO()
The lowercase version could also be nice.
🆒 1
❤️ 3
z
Sometimes I think about making an alias
TOOD
because I always typo it that way 😅
2
t
if you’re using IDEA you can just setup a template?
👍 1
l
Nowadays I'm sticking to defaults as much as possible because it's a hurdle to sync settings between multiple IDEA and Android Studio installations.
3
@Zach Klippenstein (he/him) [MOD] Now thinking about making an IDEA plugin for us in these moments when our fingers type
async
and don't
await
each other.
⏸️ 2
s
have you tried getting bigger hands? 😛
l
@Shawn I can litteraly press both
tab
and
enter
with one hand, so it's not so much a hardware problem 😉
s
¯\_(ツ)_/¯ I feel like you gotta be real darn lazy to have a problem with hitting shift+9 if you can easily reach both keys
l
Honestly, it feels more like you don't share the problem, and didn't try to understand it before commenting 😛
I didn't say I can easily press both tab and space with one hand. It's insanely hard actually, I can stretch up to 26cm, and it hurts on the long run.
The thing is when you type a todo call, you don't want to deal with the syntax, your mind is focused on the bigger picture or other details, so requiring effort to type
TODO()
properly so the code is not all red is counter-productive.
f
It's autocompleted, no? Or is IntelliJ to slow? That said, I recommend to learn typing with the 10 finger system (do you call it like that in English too) then you press shift with the left pinky and hit the parens keys with your right hand. No more stretching and your typing speed can become really, really fast if you master it. Adding a great mechanical keyboard with keys that fit your style can give you another boost plus learning shortcuts so you never need the mouse.
t
I’m struggling to see the problem too. I know we’re all different, but my need to type parens outweighs my need to type TODO() by a huge margin
m
On that note I’d also add
FIXME
. The IDE supports both. And for me
FIXME
is urgent while
TODO
is not.
l
For me, uncommented `TODO`s are urgent, while the commented ones last until the project dies (kidding, some die before the project 😄)
m
That’s difficult to search for though.
l
Not really, I never commit
TODO()
calls beyond WIP branches, plus you can use find usages.
m
Find usages requires IDE. And in projects that span a long time FIXMEs will be everywhere for quite a while 😅
l
For the ones in code, you can do a Find in Path (ctrl/cmd + shift + F) and type
//TODO
in it, it will find all the ones in EOL (end of line) comment.
m
It’s not really clear to people reading the code that there are two different meanings of
TODO
, is it? Also, you can only use
TODO()
if actual code is involved replaced. You cannot just add a note
// FIXME There's an occasional race condition.
l
TODO()
in code will crash when reached, plus all the code after is marked as unreachable, I think that's good enough. If people cannot understand the difference, I'd question giving them the power to do whatever on your codebase.
m
I don’t want the code to crash just because there is something to potentially be fixed in a few months…
l
BTW, the "Find in Path" option has filters to exclude comments 😉
m
Again, relies on IDE. Cannot do so on GitHub for example.
l
Yeah, then just use the comments
m
Yeah, then just use the comments
But then I do need a FIXME instead of TODO?
l
I never said you'd
m
How else would I know the difference between “must be fixed for production” and “improve this some day”.
l
GitHub cannot search ignoring comments, well, that's sad, but I won't shape my codebase based on GitHub limitations 😄
m
You don’t have to, it’s just two simple words. Lots of clarity and ease of use just by using them 🤔
l
There are many ways, if your is using TODO or FIXME, or suffixing TODO with a marker keyword like
//TODO (DONT DEPLOY)
, then great 😉
For now, there's no semantics/metadata for TODO and FIXME besides non structurally enforced plain text.
m
True. I just find
TODO
quite weak for something that’s completely missing.
l
You can make your own TODO/FIXME/Whatever library I guess, then you'd ask for a Kotlin feature that allows to mark some function calls as TODOs 😄
m
Calls?
l
Kinda like
@RequiresOptIn
Yep, like mark calls to
YourSuperToDo(…)
,
FixMeBeforeProdDeploy()
, etc.
BTW, you can already use annotations, and have a compiler plugin or an annotation processor that will fail the release/prod build if any is used 😉
m
Ah, you mean instead of having a magic
fun TODO()
in Kotlin it would just be a regular function (or
val
) with a special annotation?
l
Yep, something like that. Similar to
@DslMarker
. Example name:
@TodoMarker
m
That would also work, yes. Although more complex implementation-wise.
l
I think for your use case, custom annotations + a compiler plugin or processor (using ksp) would work best since you don't want to crash the code but fail the production builds.
m
Well there are no production builds though
The test system simply gets promoted to production
l
If it's dynamic, it's tougher then
m
But it would help nonetheless
Interesting hacks how the IDE finds `TODO`s: https://github.com/JetBrains/kotlin/commit/ded5bfb841ed388c1d3f0740de71a22d9ca071ab (may be outdated though)
l
You could have it (ksp, or compiler plugin) run on the system that checks if a test build can be promoted to prod
f
Why not simply collect them all with Gradle, a test, ... I don't see why it needs to be part of the language or something complex in general. It's easy to find comments starting with keywords, especially with Gradle which you can make cached, incremental, and parallel with ease. Then you can do whatever. Post it to Slack, GitHub Wiki, ...
g
For me it’s enought to type “TO” + Tab to write
TODO()
, it always top suggestion if you use capital letters
l
Yeah, autocomplete is blazing fast for Kotlin code, especially when you have dozens of modules, for sure. 😅
g
Well, any of proposed solutions would help with this case in this case
I’ve checked, it’s actually fast for me, at least for todo, less than a second in this case I have 250 modules
l
I have less than 100 modules, but about 400 Chrome tabs (so far)
Did
TO
+ hit the tab key quickly. Result:
TO
It's unreliable, unless I force myself to type slowly 😞
g
yes, you have to wait until dialog is appeared