|
|
|
|
|
by tgv
1566 days ago
|
|
Some time ago, I wrote this in JS. The function has an understandable name, and this line is commented, so the implementation isn't that important. return String(this.path).split(".").reduce((obj, attr) => obj[attr], this.object);
Compare that to let attrs = String(this.path).split(".");
let obj = this.object;
for (let i = 0; i < attrs.length; i++) {
obj = obj[attr[i]];
}
return obj;
Yes, I'm a fan of Go. I've got ample experience in C, C++, Java, JS/TS, Python, and I've seriously tried Rust, and minor experience in a bunch of others (Scheme, Prolog, Perl, etc.), but I prefer Go for back-end software. The balance between abstraction and simply saying what you're doing is great. It may not be optimal, but it gets the work done, reliably and pretty fast.The other day, there were some complaints about Celery; the OP noted that just starting the application took 280MB, after which it grows to 14.5GB. I've inherited two Python web apps, and I understand the pain. My Python apps grow to about 4GB each. The Go app I've written powers two other web apps, one of which has a higher usage than the Python apps, and it hasn't grown beyond 40MB, and barely uses CPU, on a low-powered virtual server. |
|