18 comments

[ 1958 ms ] story [ 1435 ms ] thread
Honestly, this looks like automatically generated code.
Specifically, it looks like someone created a decision tree using Weka's J48graft class, then translated it automatically to Python code.
What I can't get is the need to translate the Java code to Python. Ideas, anyone?
Python does has a nice clean grammar if you have to generate code, but yeah, if they already had a Weka model it's not clear why they aren't just evaluating that in a JVM. The only exotic thing they're doing is calling a Python module that can read Win32 portable executable files, though there appear to be similar Java libraries. Maybe they want end users to install and run something, so they avoided requiring the huge download footprint of a modern JRE?
Maybe they even shipped this to users automatically through an already existing (Python-supporting) system?
heh. this has to be some kind of output of a translator. if someone or some group was directed to make a file like this, we need a new name for design by committee :D
LOL. I sometimes wish I was able to write teh codez dis gud.
(comment deleted)
Ouch...my brain hurt after reading parts of that. I believe it was generated code, but if not...that poor dev!
The ugliest, deeply-nested part is just a machine-generated classification tree (e.g., http://en.wikipedia.org/wiki/Decision_tree_learning).

Notice how all the leaf nodes (ends of if/then branches) do only one thing: set isDirty to 0 or 1.

And, all the if/then conditions are just thresholds of one variable against a constant threshold.

The later part seems to be exceptions to the above tree. I've never heard of this, but it seems like what they used:

http://weka.sourceforge.net/doc/weka/classifiers/rules/Ridor...

"How not to write a HN headline"
From the description of the project: "The tool was developed using models resultant from running the J48, J48 Graft, PART, and Ridor machine-learning algorithms on a dataset of approximately 100,000 malicious programs and 16,000 clean programs."

This is just machine-generated J48Graft code. Amusing, but not as terrible as it appears at first blush.

Regarding the title of this submission: as demonstrated by the other comments here, it's good to have some context before you make snarky remarks about the work of others.
Automated code should be beautiful too. How can you debug what you generate if is so ugly? I would even say there is less of an excuse since 100% was written by you and you can easily rewrite all of it at once.
1) Use unit tests.

2) It isn't that ugly! If you know what the code is supposed to do (which should be clear from documentation or just the purpose of the program) and it fails in some cases, take that failing case and go through the if-else statements manually.

If this is machine-generated code the real program is the one outputting this script. The big machine-generated statements are just data from that program. That program may be much better structured.

(comment deleted)