Have you read the Metaprogramming Ruby? If not, don’t worry about it, I didn’t start to read it, too. But have you heard about the Code Generation? This year will continue the discussion the Unlight which we had talked about it last year. Let’s review how much complexity of the Unlight’s DSL.
The Ruby is well known as the Metaprogramming and DSL support, except the Ruby on Rails, give us the DSL power to help our development, there have many gems that use this feature to provide the awesome feature.
For example, the community creates a gem for ElasticSearch APM (Application Performance Monitor) which implementation the span_method
that allows us to wrapper our method to traceable by the agent.
Besides, Ruby also allows us to use the eval
method. That means we can use Ruby to generate a code snippet, and use eval
dynamic extend our running program. Depend on these features,
we create a lot of useful tools (eg. Chef, Vagrant) to allow us to use a simple syntax to design mechanisms.
But what happens if we use too many DSL or Metaprogramming? Let’s review the code of Unlight how to use these features to speed up the game development. In this case, the DSL is useful and reduce the duplicate code, but is it a good idea when it becomes very hard to debug?
About Aotokitsuruya
The web developer at 5xRuby. Interest in game development but can’t get charged up about it.
Blog: https://blog.frost.tw/en