7 ms·
I remember many years ago coming across a reimplementation of the server side for a popular MMORPG of the time, reverse-engineered from the client (which was Fl
by userbinator 5y ago
I remember many years ago coming across a reimplementation of the server side for a popular MMORPG of the time, reverse-engineered from the client (which was Flash) by what was likely a teenager --- it was over 100k lines in a single file, written in Visual Basic. Global variables everywhere, short names, and not even indentation. All the account data was stored in flat files, there was no actual DB. No "best practices" at all. Yet, not surprisingly, it worked pretty well and was actually not difficult to modify --- Ctrl+F would easily get you to the right place in the code.
I guess the moral is, never underestimate what determination and creativity can do, and always be skeptical when someone says there's only one best way to do something.
- gofreddygo 5y agoFunnily enough, I have recently had great success by reversing the "best practices" on a distributed "micro services" architecture application into a single big Java file. Best practices were the usual suspects DRY, IOC, SQL + NoSQL, separation of concerns, config files over code, composition over inheritance, unexplainable overlapping annotations, dozens of oversimplified components doing their own thing, and some $something_someone_read_on_a_medium_post The Single Java File was around 500 lines no db, lots of globals, a dozen or so classes and some interfaces, Threads for simulating event based concurrency, generous use of Java queues and stacks but i specifically made it static with Zero dynamic hashmaps. It actually runs in my IDE, I can understand what the hell the product is supposed to do what component is doing more than it should and more valuable was to predict what could break if I change that value in the helm chart from 5.0 to 5.1. It is quite useful and pleasing, I can actually reason about things and I have new found use and appreciation for Type Systems and compile errors. And I can write tests that run in under 3seconds.
- teaearlgraycold 5y agoHaving the whole project actually in one project is critical. I think some of these “best practices” are actually very useful when applied with caution. But you sometimes need to break the rules. Everything should be optimized for developer convenience. Convenience in deployment. Convenience in debugging. Convenience in refactoring. Only do what HN and FAANG says is “right” when you need to.
- KwisaksHaderach 5y agoThis application must be really really simple ;), so no database?
- gofreddygo 5y agoNo and no.
- smaudet 5y agoYou'd be surprised the garbage overhead brings into an app architecture... These best practices really only make sense in large organizations, i.e. Conways law. After all, you can't really ask 100 developers to all add code to one file in a couple weeks - they will spend a month or so just resolving conflicts... 100 file repos are designed so that 100 developers can edit them (in theory), and have relatively few conflicts, not because its better code. As another anecdote, I find whenever I do solo code I can easily spin out thousands of lines of code within a week (includes testing), when doing code on a project with many other devs my rate drops into the range of maybe 200 a week, just because so much time is spent interlinking other code, finding fixing bugs and tests strewn across many files...
- sillysaurusx 5y agoIronically, this is a description of hacker news itself. https://github.com/shawwn/arc/blob/arc3.1/news.arc https://github.com/shawwn/arc/blob/arc3.1/news.arc (HN has indentation, though.) It’s important to realize that this is good design. It’s hard to separate yourself from the time you live in, but the rewards are worthwhile.
- lupire 5y ago2600lines is not 100k lines.
- exdsq 5y agoThe only readability issue I have with that is the functions expected arguments. Add some types and I’d be very happy to work on it. I believe Facebook uses a single directory of files now as best practice? With the file names including namespaces. That was an HN comment from ages ago so could be wrong or misinterpreted.
- sillysaurusx 5y agopg's new lisp, Bel, has something close to typed arguments: (def add1 (x|int) (+ x 1)) http://www.paulgraham.com/bel.html http://www.paulgraham.com/bel.html I've been implementing it for a couple years now, though not seriously till the past couple months. There are some interesting (and overlooked) ideas in Bel. Bel is sort of the limit case of generality. For example, you might expect the "type" above to be a separate kind of object, the way that types are separate kinds of things in TypeScript. But in fact, it's simply a function that receives the argument and can throw an error. So for example, you can do something like: (def positive (x) (if (< x 0) (err 'negative) x)) (def sqrt (x|positive) ...) I just wish he'd solved keyword arguments as thoroughly as every other kind of argument. There are hints that it was always in the back of his mind. Though it's true he never needed them, so that's probably why he never made them.
- exdsq 5y agoIt's nice to have invariants - I believe I've seen them in Rackets contracts but I'm a little away from that stuff in my Lisp journey :)
- wefarrell 5y agoYou can get away with a lot on a single developer project and best practices aren’t in place solely to make code functional. That application would likely fall apart if multiple developers of with diverse backgrounds had to maintain it and add new features.
- userbinator 5y agoI don't know what you mean exactly by "diverse backgrounds" and it doesn't matter in this case either, because there were definitely multiple people working on it (although the initial version was the work of one.) They effectively used a forum thread as source control, and just attached their modified versions to the posts.
- suifbwish 5y agoTo be fair even with using best practices, code can still fall apart with multiple developers from diverse backgrounds.
- Dudeman112 5y agoThe conclusion, of course, being that if you need multiple developers the code is less likely to fall apart if they have similar backgrounds ;)
- tokamak-teapot 5y agoPresumably VB.NET? Because the VB6 IDE wouldn’t let you write more than 65534 lines [1]. Don’t ask how I discovered this. [1] https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-basic-6/aa240819(v=vs.60)?redirectedfrom=MSDN https://docs.microsoft.com/en-us/previous-versions/visualstu...
- swayvil 5y agoAh, that takes me back. Commodore 64 freeware games written in Basic. Ya, you could just go in there and mess with the code all over the place.
- formerly_proven 5y agoIt always seemed surprising to me how some of the big Oblivion and Skyrim mods would get by with fairly few bugs despite there being no way to have automated tests and some of them having 10k lines of scripting (or much more in some cases) spread around dozens or hundreds of quests (quests in the CE engine are not just the quests you as a player see, but also a huge number of invisible quests because quest state machines and associated scripting is how scripting works).
- theobeers 5y agoI think it makes sense. Modders get a kind of obsessive testing from their communities (including themselves) that devs in most commercial contexts couldn’t dream of. Skyrim mods are, if anything, correcting for bugs in the game.
- pnt12 5y agoFor a single modder, it may have to do with being a single developer, working on it over a long period of time and being a passion project. For a while, I was the only developer working in a small module of a bigger project: I started the code base, discussed requirements with clients, implemented the needed features, tested the whole product end to end. I developed a very good instinct about it and about what any change would do, much better than any other project. My theory is that the code base matched my way of thinking, so thinking about it was pretty easy.
- MauroIksem 5y agoThis description has been life the last 4 years.
- Breza 5y agoWhat are you working on?
- smaudet 5y agoFewer (in charge) developers makes for a more stable product - even open source products fair better when they have a long term maintainer versus ownership changes frequently. The other thing is style - when used well, state machines don't require testing. There's nothing to test - either your machine works or it doesn't, there is no point testing state transitions because that is the fundamental job of the state machine. You may as well test that addition works. Ofc, they must be used well - problems may be difficult or overly complex to model as a state machine or even set of state machines - the pattern excels for small problems, less for large ones.
- rezonant 5y agoI suspect the game was Runescape. My brother used to be a fan of these custom servers.
- RTFM_PLEASE 5y agoA likely guess, although RuneScape isn't Flash based (Java & RuneScript).
- rezonant 5y agoOh right.
- elvennn 5y agoI think the game is Dofus, a French MMO ;)
- yoursunny 5y agoCirca 2006, I was in college, and I got hired to write a webapp for a college department. I didn't know JavaScript could have classes and capture variables, so I made the app with entirely global variables and plain functions combined with `eval`. It's over 2000 lines, and nobody after me could understand it.
- KwisaksHaderach 5y agoSee also Bellard's QuickJS (54k lines) https://raw.githubusercontent.com/bellard/quickjs/master/quickjs.c https://raw.githubusercontent.com/bellard/quickjs/master/qui...
- juancampa 5y agoCame to say this. I actually find QuickJS pretty easy to understand and modify, in part because everything is one file and it's easy to search, using vim's `#` and `*` keys, for example. When working on projects by myself, I like putting everything in one big file too. Trying to find the "right" place for something is some unnecessary overhead, not to mention the navigation cost. It's a different story when a team is involved though.
- weq 5y agome when i look back at the code i pumped at as a 15yr old writing a java servlet web app that could admin a quake1 tf server game