Javascript reflections and metadata

Hi there!

First of all, kindest apologies for my grammar.

Recently, i’ve been looking for some staticaly typed language that could compile itself to javascript so that i don’t have to debug typos and obvious mistakes in runtime… or at client’s home… yea.
So far i’ve looked at TypeScript, Haxe and, of course, Kotlin, where the last seems the best so far. It lacks a few things that haxe has though (not fully, but still): Reflection.
I haven’t been able to find any document regarding reflections/metadata support in the internet, so in act of desperation i’ve decided to simply browse the source code of kotlin javascript runtime library and i’ve traced some functions that seemed to leave metadata behind. My question is: is that “public”? Or usable in any way? If not, is support for reflection planned in the (best, near) future? And if yes, to any of these questions, are/will be traits also included in metadata? I need some kind of replacement for interfaces and triats seems like the best choice. Or in fact, only choice, at least in Kotlin.


Right now we don’t have any public API for Reflection, but, of course we will have it. And of course yes – you will can use reflection for trait too.

Yes, we have some metadata, but now it’s for internal use only. You can try use it at your own risk but remember it may be changed in the future.It doesn’t have any api for access from kotlin code, so you will have to write some stubs/declarations.

We can try help you to find solution for your problem if you describe it. And feel free to ask questions.

Thank you for your fast answer.

I wanted to have reflections for serializer/deserializer. The concept is, that when i request JSON object from server, i’ll most likely know what type i expect it to be. If i could reflect that type, read it’s fields, their types and so on, deserialization would be super easy. Same goes for serializing, but it needs a little less of reflecting.

Hi Tomek, did you manage to find a solution for JSON <-> Kotlin data class (de)serialization? I am just trying to resolve the same problem and this post by you. Thanks, Jan


Once i got my resposne, i’ve abadon kotlin for good so no, i didn’t resolve it.
I’ve continued my search of good language compiled to javascript. First and kinda obvious find is GWT. They also lack reflections, unless you add some tricky plugins. Neverthless, it didn’t work too well, so i’ve continued my search.
Then i stumbled across JSIL and then WootzJS. They’re both C# to JS compilers, and both are very young projects. While they do support reflections, their standard library implementation is still very incomplete and buggy.
Hope this answers your question.

EDIT: There’s also SharpKit. It’s in a bit better shape than JSIL and Wootz, but it’s paid.


Hi Tom,

I may be misunderstanding your needs, but you can do reflection in GWT, you just need to add an entry in your *.gwt.xml module files to list the classes you want to allow reflection.

That being said, I find that the workflow with GWT is very slow, and unless you do your iteration in a desktop window, the GWT workflow is quite painful.


Hi guys. any news about reflection support on the javascript side?