Class/Object questions

Monkey Forums/Monkey Programming/Class/Object questions

jondecker76(Posted 2014) [#1]
Hello

I have a very large project (nearing 100,000 lines of code) that was prototyped in PHP. It is a collections of data aggregation daemons that run on Linux. While PHP isn't normally chosen for this type of work, it has proven very reliable and completely stable even running months at a time.

Now that I'm paying for a lot of resources on Amazon AWS (5 EC2 instances, an RDS server and an ElastiCache server), I was going to start porting the code to C++ for better utilization of resources. I also have a few projects that I'd like to do in Monkey, so I was thinking of using the Monkey stdc target for this port in order to learn Monkey better for these future projects (plus it just sounds fun).

One of PHP's features that I use a lot in my code is that variable names can be used in place of just about anything in PHP. For example:
$data=new dataModel;
$foo="thing_a";
$value=$data->things->$foo->color ; // $data->things->thing_a->color

Is there a way to do something similar in Monkey? All aggregated data in my original PHP codebase gets put into an internal datamodel, so being able to address different parts of the datamodel indirectly like this is a huge time saver.

Thanks for any ideas.


AdamRedwoods(Posted 2014) [#2]
Is there a way to do something similar in Monkey?

you mean using a string to reference a class member? no, that's more like Javascript. the best you could do is create a StringMap() to get and set objects.

also, i'm not sure how well monkey would be on server resources for garbage collection. there is the #CPP_GC_MODE=2 compiler directive that collects on object creation, rather than per frame.


jondecker76(Posted 2014) [#3]
Thanks for the answer. Its pretty much what I was expecting, but just wanted to be sure. It's not a big deal, I would just have to be more creative and explicit in the object definition

Regarding GC - I'm sure it has to be lighter on resources than the PHP interpreter. Especially considering that I'm running many (nearly 100) "pseudo threads" in parallel for data aggregation. I still have to make a MySql and a Redis module to fully evaluate whether Monkey will suit my needs for this project. Since this project encompasses backend daemon services, frontend services, a web UI, etc. It would be nice to have everything share the same language instead of mixing PHP, Bash, JavaScript, etc..