News for hackers. Stuff that matters.
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by thom on Tuesday February 28, 2023 @06:30AM (#34968181)
There is no doubting Casey's chops when he talks about performance, but as someone who has spent many hours watching (and enjoying!) his videos, as he stares puzzled at compiler errors, scrolls up and down endlessly at code he no longer remembers writing, and then - when it finally does compile - immediately has to dig into the debugger to work out something else that's gone wrong, I suspect the real answer to programmer happiness is somewhere in the middle.
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by krapp on Tuesday February 28, 2023 @07:20AM (#34968474)
If you're talking about Handmade Hero, the real answer to programmer happiness is not using a language you despise and refusing to leverage the features of, not refusing to use libraries in that language or frameworks, not re-implementing everything from first principles, and to actually have your game designed first (not designing while you code.)
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by AnIdiotOnTheNet on Tuesday February 28, 2023 @08:55AM (#34969290)
Casey is a bad example of a game designer and he'll be the first to admit it. However, it is worth nothing that Jonathan Blow very much does design while he codes and recommends the practice. He also generally abstains from library dependencies and implements a lot of thing himself.

Of course, part of the point of Handmade Hero is to show that you can totally reimplement everything from first principles. Libraries are not magical black boxes, they're code written by human beings like you or me, and you can understand what they're doing.

For instance, he wrote his own PNG decoder[0] live on stream, with hardly any prior knowledge of the spec, even though I'm confident that under normal circumstances he'd just use stb_image. I'm sure he did this just to show how you'd go about doing that sort of thing.

[0] He only implemented the parts necessary to load a non-progressive 24bit color image, but that still involved writing his own DEFLATE implementation.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by bbatha on Tuesday February 28, 2023 @04:22PM (#34975026)
Is Blow even a good example to look at? He's released 2 games in 18 years which definitely had phenomenal game play but are not technically complex even for the the time.
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by AnIdiotOnTheNet on Wednesday March 01, 2023 @08:52AM (#34982369)
Yes, he is a good example. His games are as highly regarded as they are because he takes the time to really work through everything about them and ensure they're the product he wants. If you watch his streams you'll see that he is constantly experimenting with things, both gameplay-wise and in the engine... and now in his own compiler for his own programming language.

Jon is not making the by-the-numbers annual entry in the Call of FIFA series here.

But also, as a nit pick, Jon isn't just programming all the time, he's running a business and he is very involved in the indie game community and a founding member of indie fund. And when he is programming it isn't always for his own games. Here is a link to the credits page for him at MobyGames:

https://www.mobygames.com/person/188969/jonathan-blow/credit...

Where in addition to nebulous "Special Thanks" credits, you will note programming and QA credits on several non-Thekla games.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by bbatha on Wednesday March 01, 2023 @01:02PM (#34985859)
Look I'm a huge fan of his games! And I really can't understate how influential his game design nor the work he does for the indie community. However, I think a lot of folks tend to assume his software engineering skills are great because his game design is excellent. I don't think that's an earned position. Releasing 2 games in 18 years that are not pushing the technical envelope does not scream software engineering expertise. You say he has more credits but only one of those is programming since Braid. On the other hand, on a software engineering level those paint by numbers Modern Warfare and FIFA games are both more technically impressive and are designed for fast iteration.

Moreover he's pushing a particular paradigm and view point that is in many ways the opposite of clean code. He pushes for still doing very low level design with minimal abstractions. But even at the time Braid could have been written in python SDL wrappers and probably had similar performance, and the witness could have used unity. If clean code is about maintenance and time to market, the Blow paradigm hasn't proven that its needed or fixes the holes in clean code. This is not to say clean code is perfect just that Blow hasn't cracked the nut either and I don't know why people act like he is the final word, or honestly even a respected voice, in game software engineering. On the other hand, if Blow wanted to talk about managing indie studios or game design my ears would prick up instantly.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by AnIdiotOnTheNet on Wednesday March 01, 2023 @01:51PM (#34986659)
> I don't think that's an earned position.

I disagree.

> You say he has more credits but only one of those is programming since Braid.

He did start a company after that you know. A successful one that makes money and employs people to make art. I don't imagine that running a business takes no time from his life.

> But even at the time Braid could have been written in python SDL wrappers and probably had similar performance

Braid did a lot more than you give it credit for. Here's a GDC talk about the rewind system in which he explains some of the hurdles he had to deal with: https://www.youtube.com/watch?v=8dinUbg2h70&t=5s Pay particular attention to the discussion of the background particles and how to get that to work within the RAM constraints.

> On the other hand, on a software engineering level those paint by numbers Modern Warfare and FIFA games are both more technically impressive and are designed for fast iteration

Hardly anything about these games change from release to release. They're not exploring new gameplay problem spaces, they're not doing anything super interesting or surprising on a technical level either and I don't get why you think they are. Of course if you keep using essentially the same engine and know exactly what you're trying to make, making another like a goddamned factory is going to happen quicker than if you're trying to make something unique and meaningful.

> If clean code is about maintenance and time to market, the Blow paradigm hasn't proven that its needed or fixes the holes in clean code.

I have heard "maintenance and scaling" as an excuse for poorly performing software for a long time now, yet what I'm not seeing is software that has features added on quick schedules and without bugs. So at best I'd say that it isn't accomplishing what it is supposed to and, at the same time, it is wasting our time and resources by producing slow software to boot.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by andai on Tuesday February 28, 2023 @02:58PM (#34974000)
Doing things without libraries (except the stuff built into Windows XP?) is the whole point of the project.
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by hinkley on Tuesday February 28, 2023 @06:35PM (#34976504)
But the results of living in a contrived environment is that there are no guarantees that at the end you will understand 'normal' environments better or just be over-trained on your fictitious one.
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by krapp on Tuesday February 28, 2023 @06:44PM (#34976577)
The problem is people get hooked into Casey's misanthropic philosophies and take his rants as gospel, and wind up believing Handmade Hero represents the way game development should be done, that libraries and frameworks can't be trusted, that C++ shouldn't be used at all, and you should implement as much from scratch as possible, when none of that is true.
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by andai on Tuesday February 28, 2023 @09:37PM (#34978070)
refterm
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by krapp on Tuesday February 28, 2023 @09:39PM (#34978094)
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by TylerGlaiel on Tuesday February 28, 2023 @07:00PM (#34976742)
> and to actually have your game designed first (not designing while you code.)

tell me you've never made a game without telling me you've never made a game

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by jesse__ on Tuesday February 28, 2023 @09:44PM (#34978125)
hahahaahahaha, that's accurate af
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by rstefanic on Tuesday February 28, 2023 @10:35AM (#34970434)
When working with a larger code base, there will always be parts that you don't remember writing and you'll inevitably have to read the code to understand it. That's just part of the job/task, regardless of the style it's written in.
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by hinkley on Tuesday February 28, 2023 @03:56PM (#34974709)
In shared code particularly with a culture of refactoring, there's no guarantee that the function call you see is doing what you remember it doing a year ago.

When I was coming up I got gifted a bunch of modules at several jobs because the original writer couldn't be arsed to keep up with the many incremental changes I'd been making. They had a mentality that code was meant to be memorized instead of explored, and I was just beginning to understand code exploration from a writer's perspective. So they were both on the wrong side of history and the wrong side of me. Fuck it, if you want it so much, kid, it's yours now. Good luck.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by nonethewiser on Tuesday February 28, 2023 @04:36PM (#34975188)
Why were you making incremental changes?
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by hinkley on Tuesday February 28, 2023 @05:40PM (#34975959)
"Make the change easy, then make the easy change" hadn't even been coined as a phrase yet when I discovered the utility of that behavior. When I read 'Refactoring (Fowler)' it was more like psychotherapy than a roadmap to better software. "So that's why I am like this."

When we get unstuck on a problem it's usually due to finding a new perspective. Sometimes those come as epiphanies, but while miracles do happen, planning on them leads to disappointment. Sometimes you just have to do the work. Finding new perspectives 'the hard way' involves looking at the problem from different angles, and if explaining it to someone else doesn't work, then often enough just organizing a block of code will help you stumble on that new perspective. And if that also fails, at least the code is in better shape now.

Not long after I figured out how to articulate that, my writer friend figured out the same thing about creative writing, so I took it as a sign I was on the right track.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by randomdata on Tuesday February 28, 2023 @04:53PM (#34975400)
> there's no guarantee that the function call you see is doing what you remember it doing a year ago.

TDD provides those guarantees. If someone changes the behaviour of the function you will soon know about it.

That's significant because Robert 'Clean' Martin sells clean code as a solution to some of the problems that TDD creates. If you reject TDD, clean code has no relevance to your codebase. As Casey does not seem to practice TDD, it is not clear why he though clean code would apply to his work?

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by hinkley on Tuesday February 28, 2023 @05:34PM (#34975893)
It doesn't. TDD is about writing new code. It doesn't say anything about existing tests being sacrosanct, or pinning tests sticking around forever. I can extract code from a function and write tests for it. I probably know that there's still code that checks for user names but I can't guarantee that this code is being called from function X anymore, or whether it's before or after calling function Y. Those are the sorts of things people try to memorize about code. "What are the knock-on effects of this function" doesn't always survive refactoring. Particularly when the refactoring is because we have a new customer who doesn't want Y to happen at all. So now X->Y is no longer an invariant of the system.
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by randomdata on Tuesday February 28, 2023 @05:58PM (#34976135)
> TDD is about writing new code.

TDD is about documenting behaviour. Which is why it was later given the name Behaviour Driven Development (BDD), to dispel the myths that it is about testing. It is true that you need to document behaviour before writing code, else how would you know what to write? Even outside of TDD you need to document the behaviour some way before you can know what needs to be written.

A function's behaviour should have no reason to change after its behaviour is documented. You can change the implementation beneath to your hearts content, but the behaviour should be static. If someone attempts to change the behaviour, you are going to know about it. If you are not alerted to this, your infrastructure needs improvement.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by hinkley on Tuesday February 28, 2023 @06:08PM (#34976228)
> A function's behaviour should have no reason to change after its behaviour is documented.

That's only true with spherical cows. That something happens is a requirement. When it happens is often only as specific as 'before' or 'after' but tests often dictate that they happen 'between', which is not an actual requirement, it's an accident of implementation. It was 'easy' to put it here.

Nowhere is it written that behavior in a system is strictly additive.

Systems are full of XY problems. When you recognize that, and start addressing that problem, you sprout a lot of tests for the Y solution and block delete tests for the X solution. That behavior doesn't exist in the system anymore because it's answering the wrong question. Functional parity tests can be copied, or written in parallel. But the old tests disappear with the old code (when the feature toggle goes away).

Leaving the code for X around is at best a footgun for new devs, and at worse a sign of hoarding behavior of an intensity that requires therapy.

You're espousing a process whereby you've nailed one foot to the deck, preferring form over function. Whether you believe what you're saying or not I can't say, but it's restrictive and harmful.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by randomdata on Tuesday February 28, 2023 @11:42PM (#34978848)
> Nowhere is it written that behavior in a system is strictly additive.

For a unit of the same identity to suddenly start doing something different is plain nonsensical, never mind the technical challenges that come with breaking behaviour that should scare anyone away from trying. Logically, a unit is additive until the unit are no longer used, at which point it can be eliminated.

> But the old tests disappear with the old code (when the feature toggle goes away).

Absolutely, but static analysis can easily determine that the tests being removed correspond with units being removed. If (TDD) tests are removed and the unit code isn't, something has gone wrong and your infrastructure should make this known.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by hinkley on Wednesday March 01, 2023 @10:56AM (#34983709)
You should reread “Refactoring”.

Refactors compose. In three months you can completely rearchitect a module without breaking it at any point in the process. That’s the promise of refactoring.

Functions don’t have an identity. There is no such thing. I don’t know who taught you that but they have broken you in the process. Renaming things is a refactoring. We don’t check the entire commit history to make sure that function name has never existed. Only that it hasn’t existed recently. There’s no identity.

One of the reasons to refactor is that the function has been lying about its responsibilities. So you extract steps out of it, create a new call path that fixes the discrepancy, migrate the call sites, delete the incorrect function, and then, if the function name was really good, you might wait a while and rename the new function to the old name. Each step makes sense if you’ve followed the entire process. If you haven’t been following along at all then you have absolutely no idea how things got here until you read the git history thoroughly, which some people can’t do, and others won’t do if they expect the code to be static.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by randomdata on Wednesday March 01, 2023 @11:14AM (#34983961)
> You should reread “Refactoring”.

With respect, you should reread the comment chain. You're clearly just repeating what has already been said.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by hinkley on Tuesday February 28, 2023 @06:20PM (#34976366)
Also, to clarify, I'm talking about cumulative changes. If I'm working with someone on a feature then we both see all of the changes as they occur. If I'm off dealing with some long initiative, I may not look at that code for 3 months and so I miss all of the intermediate states that made perfect sense at the time.

Like visiting a friend who did their own house remodel. Their spouse saw all the steps, all you saw was before and after, and so the fact that the bathroom door is missing is confusing. The bathroom still exists, but now it's the master bath.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by sethammons on Wednesday March 01, 2023 @05:39AM (#34980826)
You seem to ignore that when the unit changes, the tests do too. If you come back a year later, foo.bar.baz(quux) might have been refactored and lazily so. The tests were also updated and still pass. You may jump into the code only to realize that someone no-op'd everything and never removed call sites. TDD is primarily a design tool, not a lock-into-implementation tool.
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by hinkley on Wednesday March 01, 2023 @11:02AM (#34983800)
Someone has put some notion of function identity in his head and I don’t know what school taught that notion but it needs to burn.

IBM’s Visual Age tried to behave that way and it didn’t end well. Eclipse dropped that conceit when it forked.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by randomdata on Thursday March 02, 2023 @02:08PM (#35000274)
> Someone has put some notion of function identity in his head

The only comment that talks about function identity is this one[1], and it is written by you. "His head" refers to your own?

I used the word identity earlier in that thread, but I definitely wasn't referring to functions. The word "function" isn't even found in the comment.

[1] https://news.ycombinator.com/item?id=34983709

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by jjeaff on Tuesday February 28, 2023 @04:41PM (#34975249)
Of course any code requires some refresher at time, but the difficulty and time required to figure it out again is a spectrum that goes all the way down to the seventh circle of hell.
Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by throw938383 on Wednesday March 01, 2023 @12:37AM (#34979138)
> There is no doubting Casey's chops when he talks about performance,

Remember that everyone has their blind spots!

I follow Casey on twitter, and a couple years ago there was a weird thread where he had hung his browser for 4-5 seconds by running some JS to assign CSS rules to ~50K div elements. And Casey was a million percent confident that the hang was due to JS being slow, and had nothing to do with CSS or DOM rendering.

Re:“Clean” Code, Horrible Performance – Casey Muratori [video] by wellanyway on Thursday March 02, 2023 @10:14AM (#34996647)
Because enterprise Java programmers never stare puzzled at anything.