I’ve already got a park map.
try writing it it in Assembly
Small error, game crashes and takes whole PC with it burning a hole in the ground.
Just don’t make any errors. Not one.
It was really easy to crash an Apple II game and get into the assembler. And my goodness am I glad I didn’t destroy my computer as a kid randomly typing things in to see what would happen.
Remember old Apple, had to use them when learning to program, there were 2 types, one with the OS on a diskette, one with a small hard drive, and they randomly showed a large bomb in the middle of the screen and you had to reload the OS. Probably the compuler that broke everything.
That’s Mac era stuff. I’m talking about the Apple II series, which had no GUI.
Ha ha yeah, I’m confused and old 🤤 sorry about that.
Back into the fiery pit of hell, where it belongs!
It dis-assembled the computer!
petah please what’s this mean
The game Roller Coaster Tycoon was famously hand written in raw CPU instructions (called assembly language). It’s only one step removed from writing literal ones and zeros. Normally computers are programmed using a human-friendly language which is then “compiled” into CPU instructions so that the humans don’t have to deal with the tedium and complication of writing CPU instructions.
thanks petah
To send the point home even more, this is how in python you make a line of text display:
print("Hello World")
This is the same thing, in assembly (According to a blog I found. I can’t read this. I am not build better.)
org 0x100 ; .com files always start 256 bytes into the segment ; int 21h is going to want... mov dx, msg ; the address of or message in dx mov ah, 9 ; ah=9 - "print string" sub-function int 0x21 ; call dos services mov ah, 0x4c ; "terminate program" sub-function int 0x21 ; call dos services msg db 'Hello, World!', 0x0d, 0x0a, '$' ; $-terminated message
But python turns that cute little line up top, into that mess at the bottom.
I like python. Python is cute. Anyone can read python.
That assembly is for a DOS application. It would be more verbose for a modern Linux or Win32 application and probably require a linker script.
But python turns that cute little line up top, into that mess at the bottom.
Technically, not quite. Python is interpreted, so it’s more like “call the print function with this string parameter” gets fed into another program, which calls it’s own functions to make it happen.
Yeah over simplifying it a bit, and that’s funny that the stupid thing I found wasn’t even stupid enough.
But was mostly trying to impart that we should be happy for modern languages, because for every line you write in a modern language, it’ll do a dozen things on the back end for you that in assembly you’d need to do by hand.
This is what gcc 13.2.0 makes of it in Linux:
So basically just loading the string and calling ‘printf’ from the libc.
Glory to you… abd your hoooouse!
To further emphasize this, I had an assembly course in university. During my first lab, the instructor told us to add a comment explaining what every line of assembly code did, because if we didn’t, we would forget what we wrote.
I listened to his advice, but one day I was in a rush, so I didn’t leave comments. I swear, I looked away from the computer for like 2 minutes, looked back, and had no idea what I wrote. I basically had to redo my work.
It is not that much better than reading 1s and 0s. In fact in that course, we spent a lot of time converting 1s and 0s (by hand) to assembly and back. Got pretty good at it, would never even think of writing a game. I would literally rather create my own compiler and programming language than write a game in assembly.
I’m probably completely insane and deranged, but I actually like assembly. With decent reverse engineering software like Ghidra, it’s not terribly difficult to understand the intent and operation of isolated functions.
Mnemonics for the amd64 AVX extensions can go the fuck right off a bridge, though.
VCVTTPS2UQQ
might as well be my hands rolling across a keyboard, not a truncated conversation from packed single precision floats into packed unsigned quadword integers.I had a course in uni that taught us assembler on z/os. My advisor told me most students fail the course on the first try because it was so tough and my Prof for that course said if any of us managed to get at least a B in the course, he’d write us a rec letter for graduate school. That course was the most difficult and most fun I’ve ever had. I learned how to properly use registers to store my values for calculations, I learned how to use subroutines. Earned myself that B and went on to take the follow up course which was COBOL. You’re not crazy, I yearn to go back to doing low level programming, I’m mostly doing ruby for my job but I think my heart never left assembler hahaha
Ah yes, there was this guy in our tech school class that used to code golf in assembly. Was a crack in math and analytics too, which might explain it somewhat. Well, everyone is different i guess.
Not Assembly, but HROT was written in Pascal by one person and runs buttery smooth.
Oooh! Know what I’m playing this weeeknd! Thanks!
Your game will actually likely be more efficient if written in C. The gcc compiler has become ridiculously optimized and probably knows more tricks than you do.
Especially these days. Current-gen x86 architecture has all kinds of insane optimizations and special instruction sets that the Pentium I never had (e.g. SSE). You really do need a higher-level compiler at your back to make the most of it these days. And even then, there are cases where you have to resort to inline ASM or processor-specific intrinsics to optimize to the level that Roller Coaster Tycoon is/was. (original system specs)
I might be wrong, but doesn’t SSE require you to explicitly use it in C/C++? Laying out your data as arrays and specifically calling the SIMD operations on them?
Honestly, I’m not 100% sure. I would bet that a modern compiler would just “do the right thing” but I’ve never written code in such a high performance fashion before.
There’s absolutely nothing you can do in C that you can’t also do in assembly. Because assembly is just the bunch of bits that the compiler generates.
That said, you’d have to be insane to write a game featuring SIMD instructions these days in assembly.
Technically assembly is a human-readable, paper-thin abstraction of the machine code. It really only implements one additional feature over raw machine code and that’s labels, which prevents you from having to rewrite jump and goto instructions EVERY TIME you refactor upstream code to have a different number of instructions.
So not strictly the bunch of bits. But very close to it.
Technically correct. The best kind of correct.
I think they meant the other way around, that if you wanted to use it in C/C++, you’d have to either use assembly or some specific SSE construct otherwise the compiler wouldn’t bother.
That probably was the case at one point, but I’d be surprised if it’s still the case. Though maybe that’s part of the reason why the Intel compiler can generate faster code. But I suspect it’s more of a case of better optimization by people who have a better understanding of how it works under the hood, and maybe better utilization of newer instruction set extensions.
SSE has been around for a long time and is present in most (all?) x86 chips these days and I’d be very surprised if gcc and other popular compilers don’t use it effectively today. Some of the other extensions might be different though.
If you want to use instructions from an extension (for example SIMD), you either: provide 2 versions of the function, or just won’t run in some CPUs. It would be weird for someone that doesn’t know about that to compile it for x86 and then have it not run on another x86 machine. I don’t think compilers use those instructions if you don’t tell them too.
Anyway, the SIMD the compilers will do is nowhere near the amount that it’s possible. If you manually use SIMD intrinsics/inline SIMD assembly, chances are that it will be faster than what the compiler would do. Especially because you are reducing the % of CPUs your program can run on.
Oh I see your point. Yeah, I think they meant that. And yes, there was a time you’d have to do trickery in C to force the use of SSE or whatever extensions you wanted to use.
Yep but not if you write sloppy C code. Gotta keep those nuts and bolts tight!
If you’re writing sloppy C code your assembly code probably won’t work either
Except everyone writing C is writing sloppy C. It’s like driving a car, there’s always a non-zero chance of an accident.
Even worse, in C the compiler is just waiting for you to trip up so it can do something weird. Think the risk of UB is overblown? I found this article from Raymond Chen enlightening: https://devblogs.microsoft.com/oldnewthing/20140627-00/?p=633
A compiler making assumptions like that about undefined behaviour sounds just like a bug. Maybe the bug is in the spec rather than the compiler, but I can’t think of any time it would be better to optimize that code out entirely because UB is detected rather than just throwing an error or warning and otherwise ignoring the edge cases where the behaviour might break. It sounds like the worst possible option exactly for the reasons listed in that blog.
The thing about UB is that many optimizations are possible precisely because the spec specified it as UB. And the spec did so in order to make these optimizations possible.
Codebases are not 6 lines long, they are hundreds of thousands. Without optimizations like those, many CPU cycles would be lost to unnecessary code being executed.
If you write C/C++, it is because you either hate yourself or the application’s performance is important, and these optimizations are needed.
The reason rust is so impressive nowadays is that you can write high performing code without risking accidentally doing UB. And if you are going to write code that might result in UB, you have to explicitly state so with
unsafe
. But for C/C++, there’s no saving. If you want your compiler to optimize code in those languages, you are going to have loaded guns pointing at your feet all the time.
I recently came across a rust book on how pointers aren’t just ints, because of UB.
fn main() { a = &1 b = &2 a++ if a == b { *a = 3 print(b) } }
This may either: not print anything, print 3 or print 2.
Depending on the compiler, since b isn’t changed at all, it might optimize the print for
print(2)
instead ofprint(b)
. Even though everyone can agree that it should either not print anything or 3, but never 2.I hope you are not argueing that using assembly is an improvement over using C in that regard…
deleted by creator
- Programming was never meant to be abstract so far from the hardware.
- 640k is enough ram for everybody.
- The come with names like rust, typescript, go, and python. Names thought up by imbeciles.
- Dev environments, environmental variables, build and make scripts, and macros, from the minds of the utter deranged.
They have played us for fools
Adobe promised that Lingo was the future of ‘PC and internet gaming’
Luckily by the time I had to learn to write that garbage I already coded in several other languages. Made it easier, but somehow more painful. I’m pretty sure that shit was designed so that executives could look at the code and pretend they understood what was going on. At least with ‘common terms’ it eliminated the need for commenting out most of the time. One line of code would take a paragraph of text lol.
I dabbled with making a fairly complex program for a microcontroller the other day and quickly hit the stack limit for a simple object.
It wasn’t so much that it was a large object, but to provide flexibility I was amazed how fast I filled the memory.
I’ve done heaps with memory managed languages in the past but shit as soon as I had to think about what I was doing under the hood everything got hard af.
So serious question - does anyone have any good resources for a competent programmer, but with no clue whatsoever how to manage memory in a microcontroller space and avoid fragmentation etc?
I got it to work but I’m sure I did shit job and want to be better at it.
The best book I’ve ever bought on programming, and the second best book I bought for a class in uni, was https://dl.acm.org/doi/book/10.5555/1824214 it may be worth checking out on libgen and buy if it suits your needs.
Whenever I do low-level programming on the AVR architecture, I’ll make a memory map. As in I’ll map out where I’ll put what. It may not be suitable for more complex programs, but it does the job for me. And it has enabled teamwork in assembly in the past.
If you want to work in a language that doesn’t offer memory management, but manually mapping memory isn’t feasible either, how about building your own memory management? Or perhaps use an RTOS? I’ve used freeRTOS before on various arm-based micros, and it does take a bit to get started, but after that it’s easy sailing.
Sorry for the following tangent, all semi intelligent content in this comment is found above this line.
BTW I tried CoOS once, I wouldn’t recommend it… OK it was 12 years ago, I can’t remember exactly what was wrong other than the documentation was crap, but I don’t need to remember why to hold a grudge.Bought the book! Thanks
deleted by creator
I don’t know exactly how much code reuse Sawyer had going back then, but if you’ve ever played Transport Tycoon (or more likely the open source version around today, OpenTTD) then you know that the interface and graphics are extremely similar. So it’s not like he started from scratch each game with nothing but a hot spinning disc and a magnetized needle.
But yeah, the main reason to put up with all the modern framework bloat is the ever-ephemeral promise of being able to write your thing once and have it ported to run anywhere with minimal to no further effort.
I wanna see someone make a GPU accelerated game in assembly.
Just throw the Vulkan and DX12 C APIs in the garbage and do it all yourself lol.
Chris Sawyer is a madman.
I believe you meant to write genius.
Chris Genius is a madman.
Who the hell even is Madam Chris Genius?
Step 1: Begin writing in Assembly
Step 2: Write C
Step 3: Use C to write C#
Step 4: Implement Unity
Step 5: Write your game
Step 6: ???
Step 7: Profit
Good thing I wrote my own game engine using D, and soon there will be 2 (known) games for it.
D
I was really into D, but I gave up on it because it seemed kind of dead. It’s often not mentioned in long lists of languages (i.e. I think Stack Overflow’s report did not mention it), and I think I remember once looking at a list of projects that used D and most of them were dead. I think I also remember once seeing a list of companies that used D, and when I looked up one of them I found out it didn’t exist anymore 😐️
Give it another go, maybe join the community Discord server.
There’s some very well going hobby projects, and D3 seems to be inevitable (safe by default, PhobosV3, etc.).
I’m on E already
Eww Unity
I just want to note that “Implement Unity” includes the substep of “use C# to generate C++”.
Step 6 extort developers
Step 0: Invent the universe
What are we doing here? Baking a pie?
I don’t know if everyone gets the reference: RollerCoaster Tycoon is in fact writing mostly in assembly to use the hardware more efficiently
deleted by creator
Started playing openrct2 multiplayer with a friend yesterday. Some of the best fun I’ve had.
My friend and I created MONORAIL LAND
We created the world of monorail 1. Everything exists to bring more people to monorail 1. What is monorail 1? It is a 4 car monorail that takes the shortest possible path back to the start of the station. We have several other attractions at the park such as: The Pit; Memento Mori; Install CSS, but none of them are the main attraction.
Does it have a scientist Batman?
Damn this post. This is really going to f up my weekend plans.
OpenRCT2 ditched assembly tho. They wrote it entirely in C++.
Sorry, two separate thoughts. Wasn’t saying open RCT used assembly just wanting to shout out the project.
Ah, gotcha. Sorry about the confusion.
Writing it in assembly would make it pretty much the opposite of portable (not accounting for emulation), since you are directly giving instructions to a specific hardware and OS.
deleted by creator
That’s no less true than games written in C, or otherwise with few dependencies. Doom is way more portable than RCT precisely because it’s written in C instead of assembly.
you’re not usually directly accessing/working on the hardware
I mean, you are. Sure, there’s a layer of abstraction when doing tasks that require the intervention of the kernel, but you are still dealing with cpu registers and stuff like that. Merely by writing in assembly you are making your software less portable because you are writing for a specific ISA that only a certain family of processors can read, and talking with the kernel through an API or ABI that is specific to the kernel (standards like Posix mitigate the latter part somewhat, but some systems (windows) aren’t Posix compilant).
If you’ve written 500k lines of code you were surely pretty confident about your decision.
You sweet summer child…
I’m a developer, I don’t just continue doing things for years if it doesn’t make sense.
(If I’m the one making the decisions)
I have seen Devs do things for many years that make no sense
programmers just not a uniform bunch. not all of them blockchain grifters. fancy that.
Like the classic, inherit a broken code base, and not being allowed by the owner to rewrite it from scratch. So you have to spend more time making each part work without the others working. Also before you are finished the customer says they have something else for you to do
Programmers love to rewrite things, but it’s often not a good idea, let alone good for a business. Old code can be ugly because it is covered with horrible leasons and compromises. A rewrite can be the right thing, but it’s not to be taken lightly. It needs to be budgeted for, signed off on and carefully planned. The old system needs to stable enough to continue until the new system can replace it.
Okay, I’ll tell you, in this situation, the code never really worked outside of the demo stage. It was written in bash+ansibel+terraform+puppet designed to use ssh from a docker container and run stages of the code on different servers. And some of it supposedly worked on his computer, but when it failed to run when he was not clicking the buttons, and I read through each part, I can promise you that it never worked
I didn’t write broken code base because I didn’t like the code, I meant that it didn’t work
The whole point of docker is to solve the “work on my computer” by providing the developer hacked up OS with the app. (Rather than fixing it and dealing dependencies like a grown up)
Bit special for it to still be broken. If it flat out doesn’t work, at all, then it may well be “sunk cost fallacy” to keep working on it. There is no universal answer, but there is a developer tendency to rewrite.
I’ll consede that his point in using docker was to avoid the “it works on my computer” problem. It was literally one of his talking points in his handover meeting. But that is not the problem docker is trying to solve, and not it’s strength.
Docker and similar container software makes many things very convenient, and has uses far outside it’s originally intended usage.
And in this situation, when want stable package versions, and simpler uniform setup. And you don’t have stable package versions because docker doesn’t provide reproducible builds (and he didn’t do the work work srojdn that), and it is not a simpler setup when you want to use the hosts ssh agent with ssh inside docker, which require different steps for different distros, Mac and Idk if windows would have worked? And sharing your ssh agent into the docker image is not stable either even if you set it up, it isn’t sure to work the next reboot. And can be every difficult in some Linux distros due to permissions, etc.
Then I ended up putting it on a vm, that is already used for utilities. If I were to do it today, I would probsbly use nix, to actually run these programs that is very sensitive to program version changes in a stable reproducible environment that can run on any Linux distro, including in docker
But the program had many more issues, like editing yaml files by catting them and piping them into tac and piping into sed and then into tac again… And before you say you could do that just with one sed command, sure, but the sane solution is to use yq. Let’s just say that was the tip of the iceberg
Oh and just have to note, claimed working features, but no way for that code the be executed, and when I actually tried to hook up this code, I can’t believe its ever fully worked.
That’s when you start introducing modules that have the least impact on the legacy code base. Messaging is a good place to start, but building a new code next to the existing one and slowly refactoring whenever you got time to spare is at least a bearable way to go about it.
Shhhh you just described iterative development. Careful not to be pro agile, or the developers with no social skills will start attacking you for being a scrum master in disguise!
Fuck agile, or scrum, or whatever it is called. I just look at the issues and pick whatever I feel like doing. Kanban for life.
you need all of that when writing a game in assembly. wtf do you think assembly is?
They call me the Programmer and I speak to the metal,
Now check out this app, that really shows off my mettle!
where’s your furry cracktro then??