Live data from Hacker News

Best practices can slow your application down

stackoverflow.blog

171–180 of 187 posts

Re: Best practices can slow your application down

#171

I get a bit annoyed by this sort of post, blanket statements like: "With our code base, you won’t be able to easily do test driven development or similar practices that the industry seems to love." Why does the industry seem to love testing? Does the industry love testing? Does this mean you do or don't love testing? It also feels like they wrote this blog post to show off: we write our c# code as if it was c code be…

100% agreed. This was a very poor article. They've basically gone with an overly expensive Microsoft stack which meant that from the beginning they were fighting the wrong fight. Instead of thinking about scale for best performance, they had to think about best cost for minimum scale. Furthermore they decided to bastardise their C# code to some fake low level untestable C dragon code which makes matters even worse. T…

> The best practice would have been to build the parts which matter most in a language which allows them to be blazingly fast and write nice testable and easy to understand code. Something like Rust or Go. But no, they stuck with C# for god knows what reason

Whilst for work I've done approaching two decades of C#, for my own stuff I have largely used Go for years now so I'm far from an MS apologist, but that impression of C# is wrong. To be fair, the article leads partly to your conclusion so that's understandable.

C# with .Net Core, almost by design and by default, massively encourages "nice testable and easy to understand code" - much more so than most languages out there.

And unless the codebase is a hacked together monstrosity of the type that can be created using any ecosystem, .Net Core and C# are massively performant (pre-Core .Net was just about up there with some competitors but Core is in another league over the old Framework).

It's a shame that it doesn't have the mindshare outside of enterprise that it deserves, as C# on .Net Core basically gives you (practically, not syntactically) type-safe Node in terms of async/await, Go-like performance, Java-like power, and Ruby-like simplicity. Though to be honest it can take a fair while to advance from "hello world" given the atrocious naming and versioning mistakes Microsoft have made and how that impacts documentation and research.

Re: Best practices can slow your application down

#172
post #24

Earlier quoted context omitted.

I have seen a lot of projects that use interfaces in C++ or Java just to be able to mock the tests. This puzzled me. If it is known that the there will be exactly 2 implementations of the interface, one real one and one for mocking, then do not use interfaces. Instead use a global flag and at relevant places instead of calling interface’ methods just test the flag and branch for test/non-test code. If the flag is a c…

It massively hurts readability and can quickly become messy in my experience. If you're running on multiple targets and testing on host, then you have an #ifdef spaghetti in no time. In all the codebases I have worked on, they started like this because it is easy, but then moved on to interfaces/templates because maintainability is an issue with this method.

I worked on QT application where we observed the opposite. As typical with QT the code was a collection of components that were glued together in the main application. For testing it turned out adding few flags to the application was enough to implement unit and integration test driver.

Surely there were few ifs, but the code was very readable and such design allowed very straightforward implementation of integration tests.

Re: Best practices can slow your application down

#173
post #138

Earlier quoted context omitted.

Eh, not sure that follows. Here's the thing, costs aren't linear. If you do what AWS does and create some artificial "compute units" as a sort of fungible measure of processing power, what you'll find is that the sweet spot for price per compute unit is a medium power system. The current mid-range processors tend to be slightly more expensive than the low-end processors, but significantly cheaper than the high-end pr…

> If you do what AWS does and create some artificial "compute units" as a sort of fungible measure of processing power, what you'll find is that the sweet spot for price per compute unit is a medium power system. At least when I look here the costs are linear. E.g. c5.2xlarge is double a c5.xlarge, and a c5.24xlarge is 24 times higher than a c5.xlarge. https://aws.amazon.com/ec2/pricing/on-demand/

That's interesting, it didn't used to be linear, particularly on the very large instances. Oddly when looking at the prices for RHEL those are much closer to what all the prices used to look like (I hadn't actually looked at AWS pricing in a few years). I wonder if AWSes virtualization tech has just reached the point now where all processing is effectively fungible and it's all really just executing on clusters of mid-range CPUs no matter how large your virtual server is.

Re: Best practices can slow your application down

#174
Don’t fully understand the argument here. One the one hand they claim they built a successful solution with minor problems without test driven development or a lot of unit tests.

On the other hand they claim to really like tests and have it as a goal to do more of them.

But this is a contradiction. If they successfully built a large site with minimal testing then why exactly do they need all these unit tests?

If they where successful without test driven development then why do they need TDD?

To be cool?

It sure what to make of this. The argument seems inconsistent. If I had major success without best practices I would have proclaimed loudly that those practices are BS. But these guys seem to want it but ways.

Re: Best practices can slow your application down

#175

I get a bit annoyed by this sort of post, blanket statements like: "With our code base, you won’t be able to easily do test driven development or similar practices that the industry seems to love." Why does the industry seem to love testing? Does the industry love testing? Does this mean you do or don't love testing? It also feels like they wrote this blog post to show off: we write our c# code as if it was c code be…

100% agreed. This was a very poor article. They've basically gone with an overly expensive Microsoft stack which meant that from the beginning they were fighting the wrong fight. Instead of thinking about scale for best performance, they had to think about best cost for minimum scale. Furthermore they decided to bastardise their C# code to some fake low level untestable C dragon code which makes matters even worse. T…

C# is one of the best choice at the time (and still). Adopting Windows at the time is trade off.

Re: Best practices can slow your application down

#176

Earlier quoted context omitted.

100% agreed. This was a very poor article. They've basically gone with an overly expensive Microsoft stack which meant that from the beginning they were fighting the wrong fight. Instead of thinking about scale for best performance, they had to think about best cost for minimum scale. Furthermore they decided to bastardise their C# code to some fake low level untestable C dragon code which makes matters even worse. T…

C# is one of the best choice at the time (and still). Adopting Windows at the time is trade off.

If that’s true why has nobody (who isn’t Microsoft) ever build anything large scale in C# before or after StackOverflow?

Re: Best practices can slow your application down

#177

Earlier quoted context omitted.

100% agreed. This was a very poor article. They've basically gone with an overly expensive Microsoft stack which meant that from the beginning they were fighting the wrong fight. Instead of thinking about scale for best performance, they had to think about best cost for minimum scale. Furthermore they decided to bastardise their C# code to some fake low level untestable C dragon code which makes matters even worse. T…

> The best practice would have been to build the parts which matter most in a language which allows them to be blazingly fast and write nice testable and easy to understand code. Something like Rust or Go. But no, they stuck with C# for god knows what reason Whilst for work I've done approaching two decades of C#, for my own stuff I have largely used Go for years now so I'm far from an MS apologist, but that impressi…

> Go-like performance, Java-like power, and Ruby-like simplicity

You massively overestimate C#. Microsoft devdiv marketing is working.

Re: Best practices can slow your application down

#178

Earlier quoted context omitted.

C# is one of the best choice at the time (and still). Adopting Windows at the time is trade off.

If that’s true why has nobody (who isn’t Microsoft) ever build anything large scale in C# before or after StackOverflow?

What gives you the idea that that's remotely true?

Re: Best practices can slow your application down

#179

Don’t fully understand the argument here. One the one hand they claim they built a successful solution with minor problems without test driven development or a lot of unit tests. On the other hand they claim to really like tests and have it as a goal to do more of them. But this is a contradiction. If they successfully built a large site with minimal testing then why exactly do they need all these unit tests? If they…

I don't mean this as insulting, but let's think this through, with the exception of the scale SO is a forum (a QA where the OP post is a question - a topic in a forum - and the following posts are answers). It does have many details that were built throughout time (moderators, different exchanges, job posts, etc) that can significantly increase the complexity of it all when thought as a single platform, but it's nothing ground-breaking per se, even in 2008 (again, not saying that the scale and amount of exchanges and keeping all that working together non-stop is trivial or not worthy of note by itself).

But you can imagine that, perhaps, the slow down in what they can do with all these platforms - most developments seem to be things in separate bolted on to the main QA idea, others take a long time to see the light of day - is that it has become quite difficult/slow to move without breaking half of it? That would explain why they want to move towards writing code in a more testable manner.

I don't even need to experience their scale to know what the pains are of trying to refactor or add functionality to an existing code base that is untested and where I was the one writing the code - ALONE - it has happened to me, with my perfect code writing abilities and clear pure thought more than I would like to admit.

And the same is true when we talk about mocks and etc. Yeah, if you don't think in using them from the beginning it becomes usually really problematic to implement tests and mocks after the fact. You don't need to write them but your code needs at least to know they're going to be used and written in a way that does - the problem with this approach is that you really need to know what you're doing to write it in a way that is testable without writing the tests, so my takeaway from my own endeavours is, write the tests as they'll show you exactly if something is well or not written, because when you start digging deep into 3 nested layers and building complex mocks of responses to mock a signup you know something is wrong. If you don't do it from the beginning guess what, you would have to have studied whatever you're integrating with and written that mock (even if mentally) to write that code ANYWAY, with the difference being that now all that work you did went to the bin because it only exists the execution path. What you learned from it is nowhere to be used and provide small guarantees.

If you don't write them, once it's all working and working correctly, you're in a world of pain, and you're probably going to be overtaken at some point by something new that sees what you're doing and do it better (because in the end it's not rocket science) - the ones who can ignore this and can punt all the way usually have some deep pockets.

> If they where successful without test driven development then why do they need TDD? They were also funded in total up till now with $153M, one year after being beta they had a $6M funding. I think these kind of posts do a disservice. I know I said to myself "you don't need that, look at X doing without it". Sometimes I look at the industry and think we pat ourselves way too much on the back when we shouldn't.

As an example that isn't web based. I used to work with Adobe Suite, CS5/6 - as an aside the current experience for me is an awful thing, so awful that I went to GIMP instead - but forgetting that, for instance they had and still have a batch utility (Image Processor) to do bulk transform pipelines on collections of images through scripts recording your actions. It had and still has many small stupid things but it mostly worked well. At some point, they decided to do a better one and touted it as the replacement so they did. Result, it's way slower to operate and, guess what, it can only work on an image at a time. What? It does better compression of gifs for instance, but it can't do batch processing. There's tickets open for years asking for the batch processing. Not done. Probably won't ever be. The previous processor also didn't get the benefits of this new compressing algorithm. What? How can it be that switching the used algorithm on the old one or adding the ability to do multiple images is more than a one man month work?

Re: Best practices can slow your application down

#180
post #61

Earlier quoted context omitted.

I like RDS because I don't have to think about backups, replication etc but if I colocate the app server (web server, application code) and the database server on the same machine I see 1-2 orders of magnitude performance improvement in database-intensive apps. Replication is the same as usual; have another machine setup to replicate onto. The restriction is you can't fan out hundreds of application servers and half…

I like RDS for the same reason, but I wonder if there's a way you could run Postgres locally, as you suggest, while still using RDS for all the replication/backup side of things? That way the local Postgres management could be pretty minimal and outsource the "annoying bits" to RDS as before. I need to look into the best way to set up something like that.. perhaps pgPool-II.

Would this cope with needing to replicate the web server onto another machine as well, for cloud-level reliability?

Rather than

    web + local db  rds
you end up with

    web + local db  rds
    web + local db 
At which point the two masters plus a RDS slave is something I don't know if it's feasible.
Post reply on HN