Live data from Hacker News

The Wrong Kind of Paranoia

prog21.dadgum.com

1–10 of 54 posts

Re: The Wrong Kind of Paranoia

#2
Over here in the dynamic languages world (JS, Ruby, Python, etc) I often cry myself to sleep because I spend hours debugging something that turns out to be preventable with a const or a private function or something.

Re: The Wrong Kind of Paranoia

#3
"There's an architecture used in video games for a long time now where rendering and other engine-level functions are decoupled from the game logic, and the two communicate via a local socket."

Is he talking about multiplayer or has anyone ever actually seen this?

Re: The Wrong Kind of Paranoia

#4
post #3

"There's an architecture used in video games for a long time now where rendering and other engine-level functions are decoupled from the game logic, and the two communicate via a local socket." Is he talking about multiplayer or has anyone ever actually seen this?

Some games (even in singleplayer) host a "local server" and environment information is passed to that. If you're making a networked game it makes sense as you'd be creating the server anyway, decoupling is nice and less codebase to manage.

Steam's Source games, UT do this, if you open up the console and scroll up you can see the local server initializing.

Re: The Wrong Kind of Paranoia

#5
post #3

"There's an architecture used in video games for a long time now where rendering and other engine-level functions are decoupled from the game logic, and the two communicate via a local socket." Is he talking about multiplayer or has anyone ever actually seen this?

I met a longtime game dev at a reasonably well-reputed game company talk about how they did something similar where they did a message passing architecture between threads in a single process, and how this also helped contain old code that people were afraid to touch while allowing newer practices and refactoring to happen in other regions.

Re: The Wrong Kind of Paranoia

#6
> If they're not in the tutorial, examples, or reference, you don't even know they exist. If you use the header file for documentation, and internal methods are grouped together beneath the terse comment "internal methods," then why are you calling them?

Autocomplete is a thing. Even if there is a big comment explicitly saying not to use a function, if it doesn't show up in the autocomplete window someone will inevitable use the function anyway (and sometimes even if it does).

Re: The Wrong Kind of Paranoia

#7
In my view the purpose of const/protected/internal/static etc is not so much to prevent mistakes by myself or others, but to embed in my code a 'living documentation', enforced by the compiler.

If I mark a method as internal, that means I intend it for reuse within the library but don't expect it to be used by any external caller, which means another developer can come along and make changes to it without needing to worry about anything outside the library (short of those in C# using [InternalsVisibleTo] or similar, which hopefully is restricted heavily to obvious test projects).

By decorating my code appropriately, I don't need to write comments most of the time, which means I don't run the risk or filling my code with out-of-date or poorly understood annotations that become useless almost as soon as I finish writing them.

Re: The Wrong Kind of Paranoia

#8
Static also allows the compiler to make better optimizations, knowing that nothing outside of the current compilation unit will ever use it.

Const also allows the compiler to optimize better with the knowledge that the called function won't perform any writes to the object state.

Access modifiers give you a way to separate out functions that can be called externally vs those that shouldn't. The API doc generator won't know which is which unless you mark these correctly. You use access modifiers to show intended use and keep things clean, not to lock someone out. Same goes for internal classes.

Re: The Wrong Kind of Paranoia

#9
post #2

Over here in the dynamic languages world (JS, Ruby, Python, etc) I often cry myself to sleep because I spend hours debugging something that turns out to be preventable with a const or a private function or something.

JavaScript tears :'(

Re: The Wrong Kind of Paranoia

#10
post #3

"There's an architecture used in video games for a long time now where rendering and other engine-level functions are decoupled from the game logic, and the two communicate via a local socket." Is he talking about multiplayer or has anyone ever actually seen this?

Most games that do non-authoritative peer-to-peer multiplayer ultimately do something similar for singleplayer. Although it may not be as far down the layers as a local socket.

Also, Minecraft uses something vaguely similar, with a separate client and server, with the client and server communicating locally via shared memory (effectively a local socket, but not bothering to bounce through the OS). Though Minecraft's an odd case - they used to not do it this way, and switched to it, and in the process broke a lot of things.

Post reply on HN