Title
m

mahdi_perfect

03/11/2019, 11:58 AM
Hi. I've just made a simple markdown DSL, maybe it helps you somewhere. github.com/mahdi13/markdownk.git Also, I would like to know your opinion about this kind of projects, I mean 'converting (almost) everything to kotlin'. Things like android manifest, resources... It could make us reach 100% kotlin projects. Do you think its good? Or wasting time...?
t

tddmonkey

03/11/2019, 12:04 PM
If you enjoyed it and/or learned something it’s never a waste of time 🙂
💯 2
s

Sean van Dijk

03/11/2019, 12:13 PM
Personally I would love to see things like android manifest as code
👍 1
1
m

Mike

03/11/2019, 12:31 PM
As to the ’is it worth it?’, that’s a tough call. When the DSL helps with catching errors earlier, or makes creating things more intuitive, and doesn’t noticeably impact build/processing times, then there’s a good case for creating it. But if it’s not that much different than what’s there, or impacts build times too much, or doesn’t provide much benefit over what’s there, then it’s less worthwhile. (Gradle Kotlin DSL falls into that camp for me. Gradle wrapper
-all
, and IntelliJ is darn close w/o the performance issues) Just keep in mind that it does increase the learning curve on your project when someone new joins. If they don’t already know your stack, it’s less of an impact as they have to learn it all anyway, but for an experienced person… It also makes it harder to create new code as all the examples won’t be in the DSL. If you can create something really good AND get it as the default, then that’s a different story.
❤️ 1
g

gildor

03/11/2019, 12:44 PM
I disagree about Kotlin DSL, there are a lot o improvements in last versions, and it provides much better experience on config writing, finally I just see available config in autocomplete instead of copy-paste, run and pray. It of course works well only with static accessors, but now it's already much better and will be better in futute But in general I don't think that Kotlin DSL is the same case as markdown/html/etc, because Kotlin DSL replaces another DSL! Groovy DSL that just terrible, dynamic, magic as hell, impossible to understand what is going on there, and IMO it harm Gradle, and I still believe that Kotlin DSL is right choice for Gradle in general, but it's painful migration of whole Gradle ecosystem that too big and messy because of Groovy to solve it fast
👍 3
m

Mike

03/11/2019, 3:34 PM
That’s fine, we can disagree. If you use IntelliJ to modify the gradle file, and use the
-all
version of wrapper rather than
-bin
, then the experience is very similar. And I’ve been using Groovy DSL awhile so I’m comfortable with it. If all you’re doing is copy-paste, run and pray, then… There’s no magic, it’s doing the same thing as the Kotlin one, and you can find information the same way. I do agree the Kotlin one is reasonable, and I think with v1.0 of Kotlin DSL (was that Gradle 5?), it’s finally worth considering. Still some edge cases where plugins don’t cleanly support/work with it, but at least it’s usable, and improving with every release. The Kotlin DSL also creates tight coupling with the version of Gradle you’re using. Groovy is more flexible in this regard…
l

louiscad

03/12/2019, 2:16 PM
I'd be very interested in generating
AndroidManifest.xml
from Kotlin code, and I'd be even more interested in making a multiplatform text/string resources format that could be exported to Android xml resources, but also for other platforms with different conventions. multiplatform i18n and l10n! @mahdi_perfect If you want to discuss collaboration, we can talk about it in #dsl (or #kotlin_dsl?), we can open a new channel, or you can DM me.
g

gildor

03/12/2019, 2:38 PM
I don't see why Android manifest should be generated from code, like replace XML with DSL, I would prefer do not have it, all the information may be provided by annotating required Activities, services etc, or directly from Gradle, but I don't think that it possible to implement effectively without deep integration with Android Gradle plugin
Also think that use dsl for strings/plurals is overkill and make things more complicated for import/export tools without any advantages, write converter to/from Android XML strings is easy, and XML is good format for this much better than for example iOS format But maybe generate analogue of R files for Multiplatform is not bad idea, but I'm not sure that it should be source format, rather thing that generated from some other format and only for particular platform (because you probably don't need it for Android)
l

louiscad

03/12/2019, 2:54 PM
About AndroidManifest.xml, there's a lot of repetition in them, and I dislike it. Also, they are not checked like Kotlin would be at compilation. I've been working on a few projects, one quite big in terms of Android integrations, and the manifest is hard to read, yet critical. There's tons of boilerplate in it. That why I'd prefer a DSL where I could add my logic, add loops and functions.
For strings/texts, just remember the fact that in Android, you have to escape the apostrophes (aka. single quotes
'
)! This is impractical to write, and I can't use them in multiplatform modules, nor in JVM modules. What I want is simple: a way to write key and text without having to think about "oh, I need to escape this, oh, line breaks don't work, I need to use
\n
, I'll have to copy paste all of this for that other platform and remove all the escaped apostrophes, oh, I forgot this…" This has to change. I have better things to think about, and I'm willing to do the effort (preferrably with collaboration) to never have to think about it when it's done.
g

gildor

03/12/2019, 3:12 PM
Escaping is not hard, you need it in any case for every solution
l

louiscad

03/12/2019, 10:28 PM
Not hard, but annoying, and makes reading harder. I never fully accept annoying things, because I know this has bad effects on the long term.
Escaping should be done automatically. Translations don't fit well in xml, despite the fact that Android's way is better than iOS technique.
g

gildor

03/12/2019, 11:04 PM
What is better than XML?
l

louiscad

03/13/2019, 1:03 PM
Text, where you just edit the key, and the value? I mean, if we start from base, plain UTF-8 text in a file, there's no reason we can't make something better than xml for that specific purpose (i18n & l10n of strings), that could then be made to work with Android, but also other platforms. Some people already do it in spreadsheets, but I think it's overkill and does not integrate well with developer tools.