by DoubleCluster · 13y ago · 0 comments
They rewrote the entire codebase and obtained for just a 25% gain? It doesn't sound like they are very happy to be coding in javascript now either.
Everyone: please don't rewrite your code, it's almost never worth it. The one exception is rewriting a core part of an algorithm in C for speed (the last 10x speedup).
It sounds a bit like you guys rewrote it because node.js is hot and you then stuck with the rewrite because of sunk costs. Or am I imagining things?
Thanks for sharing your experiences with us. I'm just asking those questions because I want to learn more about them.
The article might as well be written as "we refactored our code and got a nice speed boost".
Couldn't you rewrite for ease the maintenance in ruby?
Trying to make do with horrible code for long periods of time, suffering through bugs in every change... Until we finally rewrite it. I've never regretted a rewrite, and it has always ended up significantly better than the original (possibly because the horror threshold for rewriting is high, so that's not saying much).
A large, extremely messy code-base can make even trivial changes unsafe, let alone large changes.
The effort required not only to figure out what point B is, but also how to safely reach it from point A is immense. Much much harder than a rewrite.
However, it is a very good idea to meticulously read the bad old code and write down a list of things it handles -- to make sure none of it is missed in the rewrite.
In that case it's a pretty good achievement, since the rewrite will have a lot more low-hanging fruit regarding performance improvements, than a polished, existing product. I'm used to see rewrites which are at least a little bit worse than previous versions due to all the work done to squeeze everything out of version N-1.
Also, C is not the only language worth rewriting in.
I would really like to see someone write a node.js and Go back-end for the same front-end and do a head to head comparison.
As someone who spent a fair amount of time rewriting node.js prototypes in Go, I'm probably biased. I feel like javascript is a much less maintainable language. Perhaps is was the original node.js implementations (I don't think it was), but the Go versions were always faster, used less memory and IMHO were more readable.
I've got a small but growing node/socket.io app I figured I'd have to one day rewrite in go if I really wanted it to scale.
* Use Go tip; You can grab a snapshot review all the open issues for that snapshot (most are enhancements).
* Like any re-factor doing it sooner as opposed to later is less work :)
* Do some "from scratch" Go projects before doing re-factor projects to get your legs under you (if they are not already there)
* Write Go in Go, not C/Python/Java in Go. This is harder than you think when you get started, but, if you ask for help and people tell you you are fighting the system, carefully consider their advice.
* A lot of the Go community likes to use single letter variable names in contexts like receivers, struct state (just look at the stdlib), buck the system, don't do that, use short camel case names. The next guy / you in six months will be glad you did.
* If you have a Java/C++ background you might often write a single threaded version of a daemon and later multithread it later, this is generally an unnecessary step in Go.
* The Go versions really are not much larger (LOC)
* There is lots of useful Go code on github (don't be afraid to try them)
* If you are doing front-endy kind of stuff supplement "net/http" with Gorilla where needed whenever you can rather than rolling your own. ttp://www.gorillatoolkit.org/
* "go tool prof" is a great tool, know how to use it and its top20 / web commands. Even if you don't feel the pain, use it and you will learn what things you do are expensive and it will keep trouble from sneaking up on you.
* If you are using a SQL based store, use a driver that implements the interfaces in "database/sql" rather than providing its own interface. This will make your life very simple if you need to migrate between mySQL <-> Postgre, etc
* LiteIDE is a nice lean cross platform Go IDE that includes syntax highlighing, autocomplete (with gocode) and debugging support. The only think I had to do was write my own syntax highlighting theme, based on Solarized, because I thought the included ones were gross.
Another reason might be, that their workload is IO-bounded, so faster VM like V8 doesn't help.
- js / node.js is very young, it might fade out of fashion, and in 10 years it is not impossible that good coders in js will be hard to find.
- Readability and simplicity are prominent in this context, and js has a syntax that is less than optimal in this regard.
- Maintenance tooling may be lacking.
If I were to choose a language for a project that I new will be big and will need care in 10 or 20 years, I'd hesitate, and maybe choose Java (which I hate) or Python (which I hate less). If in a risk-things mood, I'd give Go a try.
What interested me most is the community part. I've always thought ruby/rails community is awesome. Maybe I should start learning some JavaScript now.