Spare Me the Clever Language Developers
So today I was digging into the custom language code of a vendor's package that was customized by the vendor's consultants for us. The language is designed to be simple and fast to update - everything is based on function calls. Everything.
I can see the advantage - it's a simple function call graph. If there's a value in the tree that doesn't change, then there's no need to make the next level call because nothing is going to change. Seems reasonable, until it's taken to extremes. Like this code.
If you're going to base a language on functions, then you need to have functions that can handle if statements and conversion of variable types: boolean to integer, for example. That's kind of obvious. What this vendor did was to make the bare minimal set of functions that can be used to derive most other things, but there was not care put into it to make the language easy to use.
And they took advantage of that.
Case in point: using a max() function to find the only non-zero value in an array. Why do that? What happens if your assumptions are wrong and there isn't only one non-zero value - say there's two. What then, Sherlock? Yeah, it breaks. Why not be a little smarter and filter out the data and then call the function on the one object you want. Seems pretty simple to me.
But that's not how it was built. It's like they planned on doing a lot of extra work and then "making up for it" in volume, or something like that. It's crazy. No filters means that you have to filter on each value and then pick the max() of the set. What a waste.
Sure, I got it done, but had I been able to write it in a more expressive language, it would have been far easier, and I probably would not have had to go in and fix it in the first place. The original author probably would have gotten it right the first time.
So I spent an hour in Function Land, and I can't say I'm a better person for it. I know it's not the last time I'll have to do this, but I'm hoping that as time goes on I'll be able to remove this horrible code and make it simpler. Like basing it on the non-function-based scripting language they use for everything else. Yeah, it'll be slower, but it will be 100x more maintainable.