4 ms·
That approach may work in short term but in long term you'd likely end up with unreadable and brittle code that is often still not as fast as it would be after
by pkolaczk 3y ago
That approach may work in short term but in long term you'd likely end up with unreadable and brittle code that is often still not as fast as it would be after the rewrite. You'd introduce additional complexity into your product to overcome limitations of the platform. And tricks like reusing objects can turn into really nasty bugs, especially in languages that don't come with any tools to control aliasing.
- beezlewax 3y agoWhat does aliasing mean in this context?
- pkolaczk 3y agoIf you want to reuse an object to avoid allocation, you better not have a reference to that object from somewhere else. In JS AFAIK there is no way to detect such situation automatically.
- Etheryte 3y agoYes there is, it's called scope and it's super easy to keep track of? In fact, you have to go out of your way to share a reference if you scope it.
- pkolaczk 3y agoIn languages like JS, Java, Python is trivial to accidentally make an object escape the scope by storing a reference in a field of another object that outlives the scope. And it can be another developer 3 months later that can introduce a bug, not knowing about your clever object reuse.
- Cthulhu_ 3y agoI mean I hear what you mean, but counterpoints; The hot path of code is allowed to be more involved than a naive implementation. You mention "unreadable", "brittle" and "complex" as if those are inevitable; I don't believe it, and again, it's worth the tradeoff, like dropping down to ASM in the hot path of C applications. Another counterpoint: By switching to Rust, another language was added to the company's technology stack. This means that they now need to hire for Rust as well, if the author decides to leave. The simple graphics on https://boringtechnology.club/ https://boringtechnology.club/ are pretty interesting in that regard. I don't know anything about this company, but the general advice I'd give is: be careful with adding languages, it adds an exponent to the complexity of your organization and hiring.
- pkolaczk 3y agoThat's a fair point, but we really don't know if Rust was added to the company or only to this project. Big companies often use multiple tech stacks anyway. In my experience the language was never a bottleneck at onboarding new people to the project. It is always the complexity of the project itself, all the non-standard in-house built things that engineers invented over previous X years and often didn't even take time to document properly. I'd personally prefer a boring / standard solution in a relatively modern tech stack I have to learn from scratch than a pile of cleverness in something I know well (let's say Java). In the former case I can learn it quite quickly from the publicly available materials. In the latter case I need to reverse-engineer all the cleverness.