13

What should one do in the case of duplicitous programming languages. Some languages, not saying any names ahem... java, seem particularly awful to the eye and the users of those languages write domain specific languages (DSL) that effectively replace the original language so that they read like Python e.g. Kotlin.

In the case that the original language and the DSL that replaces it are quite tightly coupled it seems that there will be a large number of questions that overlap with one another. This would include queries about syntax, common idioms and the like. If one encounters such questions should one encourage the original OP to request his answer in both dialects ?

Personally I arrived at the getOrDefault question with Kotlin as the search term and not Java and was initially tempted to provide an answer in Kotlin before adding it as a comment to the question. I have seen similar done elsewhere before. Should I have asked to OP to amend his question to include Kotlin ? Should the OP include, say, Jython too ? Should I have asked a new question myself reading identically to the OPs' but replacing all occurrences of Java with Kotlin ?

Now there will be complex questions in both the original language and the DSL that supersedes it that are not interchangeable and these rightly warrant separate questions but what should one do for the trivial cases ?

5
  • 4
  • 1
    Hmm, no sign of that question when I search with "[kotlin] getordefault". It is a plain [android] question, that comment can't be very helpful. Dec 3, 2018 at 21:26
  • @HansPassant the original post specified java as the language. I tried a few variations of your search and they also turn out duds. Should I delete the comment ?
    – Carel
    Dec 3, 2018 at 21:37
  • Yes, that's a good idea. Dec 3, 2018 at 21:52
  • This ties in with what goes on with JavaScript/jQuery questions. If the OP asks for vanilla JS then the answer should provide this. Often, scrolling a little further will discover jQuery answers and comments. It is useful for other, later, readers but should be additional, not tarnished with an imperative such as use jQuery (enter framework/language here).
    – Andy G
    Dec 4, 2018 at 11:18

2 Answers 2

15

Put your pinky down. :)

I'm a person who works professionally with Java and I have done so for most of my professional career. I'm also a person who loves Kotlin and would like to use it in more things.

Generally speaking, if you want to add an answer using a newer API, or in this case, language, you can do so with some common-sense limitations.

  • The language must be directly related to the actual question at hand. It is not beneficial to answer a JavaScript question with Ruby. It'd probably be okay to answer it with TypeScript if a framework required it (e.g. an AngularJS question vs Angular question).
  • The answer must make it explicitly clear that this is a modern approach to this problem.
  • You can't modify the question to invalidate any existing answers. I can't stress that enough; it's fine to add a new answer to an old question; it's not fine to change the old question into a new question.

If you think there's more value in a new question rather than just a new answer, you could create a question based on this one and ask for a Kotlin-oriented approach. You could even answer it yourself. The choice is up to you, there.

8
  • 1
    Glad you have a sense of humour w.r.t. the Java jab. Your first point makes me think I ought to re-title this question; what does one call Kotlin in relation to Java, it seems it's more then a DSL/API but less then say an alternate language ? I mean I've been working in Android for 2-3 weeks now and haven't actually hit a stitch of java just yet. Point 2 is why I reduced what was originally an answer to a comment under the original post. Point 3 is why I asked the meta question.
    – Carel
    Dec 3, 2018 at 21:13
  • 2
    @Carel: Kotlin is a full-fledged language which runs atop the JVM if you let it compile to that target. You can also transpile Kotlin to JavaScript if you so desired. You can use Kotlin as a DSL, but it itself is not a DSL.
    – Makoto
    Dec 3, 2018 at 21:30
  • Ah, so Kotlin is it's own language then, this makes my question moot. I may as well be asking if we should answer all questions in all languages then; which is clearly a nope.
    – Carel
    Dec 3, 2018 at 21:41
  • @Carel: Not necessarily. Again, Kotlin is largely replacing Java as the de-facto language in Android, so seeing answers in both languages isn't completely out of the ordinary. There's common-sense answers to this but there's no blanket solution. It has to be taken on a case-by-case basis.
    – Makoto
    Dec 3, 2018 at 21:56
  • Mumble, mumble... for the interim I have removed my comment and I'll leave it be. Should some one else post the Kotlin variant later on and get all my likes I'll be sure to unlike their comment and rage down vote this meta question @_@ You really have me wondering about Kotlin though. How does it work on the JVM without first compiling to Java ? Gradle seems to transpile all of my Kotlin into Java first, then build the application. Kivy would compile to the Python byte code and then substitute the Python symbols to JVM symbols (Both are stack based, or something, under the hood)
    – Carel
    Dec 3, 2018 at 22:20
  • 2
    I think this is rather similar to the whole Objective-C vs Swift discussion a few years ago, and I think the consensus back then was that one should not post answers using Swift to questions about Objective-C, and similar reasons apply here. Kotlin is not Java, and Java is not Kotlin. Dec 4, 2018 at 14:48
  • @MarkRotteveel: I see your point but a slight nit there is that Android is a framework and operating system, and solutions may be implemented in either Kotlin, Java or both if you so desire. Objective-C and Swift are bonafide languages in their own right, and while I was able to find clear official documentation on Kotlin and Java interop, I was unable to find such documentation for Swift and Objective-C interop.
    – Makoto
    Dec 4, 2018 at 16:08
  • The point there is, if this were a pure Java question, I'd be right there with you. But since this is more about the Android platform and ever so slightly less about the language, I could see an argument for allowing both languages in an answer.
    – Makoto
    Dec 4, 2018 at 16:09
6

I think it's far more useful to separate these things out, both to the OP who is only looking for the dialect they're using, and to future users looking for their dialect.

Asking a question about your own dialect, if the answer is indeed different, is perfectly acceptable. Rewriting the question out from under the OP or pressuring the OP to change what they're asking because that's what someone else wants wouldn't be right and would indeed conflict with the author's intent, one of the things we disapprove of when editing.

In the long run, don't overthink this too much. If the answers will be different based on the language/dialect involved, they're likely best in separate questions.

1
  • I mostly agree with this view but it is useful to have variants of an answer for different dialects in a common place, especially from a comparative point of view. Persons translating a source from one dialect to another would benefit from such sources. One might argue that this should really be born out by three questions, one for the first dialect, another for the second and then a third comparing these dialects. This gets messy quickly though especially if a third dialect becomes available at some later date.
    – Carel
    Dec 3, 2018 at 21:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .