The first goal we need to achieve is to abstract from a specific type. eventually write serialization/deserialization for the desired formats.just like in serde, we will have to analyze the source code and generate a new one to add support for new types - custom enum(class), struct and class.add support for standard types: int, float and other primitives strings arrays standard containers such as std::vector, etc.write a reflection library that will allow us to analyze objects, copy them, create new ones, etc.Solutionįirst of all, we need to determine the principles of our solution. With all this, we will never pay for what we don't use. We will make a lot to look like Rust and serde, but at the same time we will separate the wheat from the chaff - separate serialization and reflection. Almost like manual mapping but the compiler writes the code for us. Thanks to it, before compilation, code is generated containing the logic of serialization of the entire structure field by field. The secret here is simple, but not quite obvious. Let json_str = serde_json::to_string(&data).unwrap()) The data looks like this: struct TempHumData To make it easier to think about the problem, imagine that we want to send data from a temperature/humidity monitor and receive it on the server side. We, developers, need to somehow turn the data into language constructs and work with them. Now any iron can pass the REST data back and forth in some JSON. Modern-day development and Internet are inseparable in most cases. But you have to be ready that it's a semi-finished product that you'll have to cook. Overall, it's really interesting to write in C++. support for all possible architectures and operating systems.īesides, over the long life of C++, a huge number of frameworks, libraries, as well as many books and thousands of articles have been written for it and about it.mind-blowing templates and other magic.performance due to lack of garbage collection and the possibility of low-level optimizations.Google, Microsoft, Yandex, lots of financial technologies, crypto and blockchain startups use this language. C++ is used in game engines, in software for embedded systems. Section in README.It's really hard to use C++, especially in large projects, but this language provides great capabilities. This can replace passing 'class and method name as String' into something actually checked at compile time and refactorable. One part of the program implements the interface with method reference, and passes it to other, which can 'read' which method was actually referenced. This allows constructing interfaces which can act as a 'method reference marker'. The other cool feature is FunctionalReference. I spent hours and hours on research and testing and I hope I got it totally right (tests show that I might have some idea). TypeView, which is a wrapper on and makes it usable - for example allows testing subtyping, which is, as I experienced, very tricky (ever wondered if wildcard type with lower bound is a subtype of the bound? now you can check it!). Invocation.withReceiver(actualUserService).invoke() It simplifies creating proxy objects: ProxyBuilder.ofInterface(UserService.class) For example: introspect(target.getClass()).methods() Library provides methods for finding java elements by reflection using "queries". This is a "commons" library that makes annoying and ugly java reflections a little more pleasant (I hope). With great pleasure and incredible stage fright I present to you my first publicly released library: Introspectable.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |