Jump to content
  • Advertisement
Sign in to follow this  
fries

Code generation and entropy coder

This topic is 1051 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement

Your code generation article is really interesting, although got me wondering. 

The last time I did code generation, I used PHP. The syntax is generally really easy, it is a general-purpose language, so you can do mostly whatever you want, and it is high-level and productive. Also, it is really easy to use it for generating text because you can freely mix raw text and code ( instead of long print("..."); lines ). 

The example you show ( index the template xml itself ) could also be done, although would need some preprocessing. 

So, I'm curious as to why implement template-specific languages, instead of get download a php and type away. What are the pros and cons? 

Share this post


Link to post
Share on other sites

Well that’s a good point, or another idea could be to just use python and jinja2 itself, but I can give you 4 reasons why I did this.

 

Firstly the last time I checked, this was all only about 1000 lines of code and this will probably shrink once i write a decent parser and evaluator for the entire syntax that I’m using. At the moment there is a mix between two different parsers in there, one for control statements and one for math expression and function calls.

 

Secondly I’m not very familiar with python or php, and didn’t really want to add a whole package to my build pipeline as it would make interactions between the different parts of the pipeline more tedious to implement, so I stuck with C++. In hindsight i would have preferred C#.

 

Third reason is that I've never implemented a tokenizer/parser/evaluator for a script like language and I thought it would be a fun learning exercise.

 

And the forth is that now that it's working, someone else with the same requirements as I might not have to re-invent the wheel like I have.

 

The pros would that you could completely customize it to your needs since the entire source is there. The cons I guess are that I have to implement it, which is probably more work than doing it in php/python, but still only about 1000 lines of code :)

 

I hope this answers your question :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!