My Problem with SSA frameworks (notably Knit)

Heyo,

(why can’t i indent) So recently, I began work on a game, and it was half-way done. Then, I noticed that the code didn’t look pretty, like for my character state machine I had a singular function just for vaulting with a bunch of hardcoded values etc. and this (to me) looked ugly. I needed to apply body gyros and velocities to the character in two seperate instances:(the dictionary definition not roblox) where the character had to jump from a bar to another, and one for vaulting over objects. I turned it into a function because I also thought it was just hard to look at.

I hated it. I hated it so much and I had no solution so after my game is half done I decided to scrap it in favour of a rewrite. Why did I do this? Because (in my head) I thought that;

  • it was ugly
  • it was unprofessional
  • it was like spaghetti
  • and i felt like i couldn’t add on to it without a headache wondering where to do something

I needed some way to organize my game, so I tried looking for frameworks. Now I never used a framework before because they were so complicated, and I never really knew what they were used for because the language used by their creators is so technical and hard to read.

Anyways…

I tried using Knit. I made some dumb state machine thing that isn’t really a state machine because all it does is change a string value on function. At this point I really felt like giving up because frameworks in general are just complicated. Sleitnick’s only appliable tutorial on using Knit in a game never really covers things that SSA frameworks are useful for;

modularity and breaking down complex mechanics in a readable and editable fashion.

Not only this, he constantly replaces modules and changes the API to an unreadable mess. There used to be a function in his Component module called “.Auto(folder: folder)” and it automatically loaded all components in a folder (duh). The API included a mention of how using .Auto() is the best practice for loading components. Now, that mechanic and information is missing from the API, it doesn’t explain the best way to do it, and people had to ask about it themselves to others just to figure it out.

Programming in this modular way has always given me a headache. It adds so much unnecessary complication to the process of simply “Starting A Project” that it makes me not want to start. I genuinely feel lost when trying to program with this format. I know it’s possible, because a lot of games use Knit, but I really don’t feel like it’s for me. I feel obligated to use a framework or an SSA structure because all the “iNdUstRy pRoFeSsIonAls” say it’s the best practice.

I’m not saying using modules is bad, but using modules for every single thing in your game feels intoxicatingly complex for something that doesn’t even need to be.

I can’t, I literally just can’t. I’m turned away by MSA because of my previous experiences of not being able to handle complex scripts with specific actions like my previous example, but then I’m also unable to fluently program in SSA (again, mostly Knit) because I’m either;

  • so caught up in trying to understand how to even use it
  • or, trying to figure out how to apply a module script that is only ran once in the way that a normal script probably was meant to run.

I don’t know, I feel like I haven’t explained this properly yet I have nothing more to say. I just want to know what I should do because I don’t want to go back to MSA because people say it’s the devil or whatever, and then I don’t want to use SSA because for me it’s just demotivating. I used to be worried about what I was going to add and what kinda cool stuff I would make, now I’m worried about how I’m going to even start.

Thanks for reading my stupid rant, any help is appreciated.

2 Likes

Hey, it’s great that you care about organization, like seriously, I see people just throwing scripts here and there and calling it a day.


NOTE: I have no idea what SSA and MSA even mean, but I grasped the meaning from the contexts in which they were used


MSA (aka, normal coding?)

I liked to structure things in this way (same way for the server):

client (local script)
   |— Module A
        |— Inner module A
   |— Module B
   |— Module C

And you get it, the main client file loads these modules in order, I like making each module do a specific feature for the game.

Now for the pros and the cons.

Pros

  • Modularity :wink:
  • You can easily expose the functions you want to expose and hide others - no need to create different files.
  • You mostly won’t need BindableEvents and such.
  • You can load the files in the order YOU want
  • That also allows u to comment out the loading of a module, effectively stopping that feature!

Cons

  • You said you didn’t like it lol, but this is here, just in case you used another method and maybe you like this one more.

SSA (Knit)

I would take a wild guess and say, you’re issue is that you tried writing code in the framework, not writing code for the framework (Did I say that right?). Yup that’s it, I’m done.

Jokes aside, you said you used components, for example, that’s quite the usual, but before Knit, did you ever use such component? No? Then you used classes, so continue to do it! You don’t have to change your entire codebase to be perfect for the framework, where perfect is how others use the framework. It’s your own game, you define that “perfect”, general idea is, controllers and services, that’s it, everything else is all up to you. I personally like having things like this:

image

  • Classes, well, contains classes lol
  • Controllers, I don’t think I should’ve mentioned those 2 but ykyk
  • FixedModules, aka constants, but constants didn’t work pretty well as they are more of pre-runtime configuration, meaning they NEVER get changed during runtime and don’t expose any functions.
  • Modules, these are ones that get changed during runtime, have no config (all in FixedModules!) and expose functions.

The init.client.lua is the “loader”, you probably know of that by now, it’s simply:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Knit = require(ReplicatedStorage.Packages.Knit)

Knit.AddControllersDeep(script.Controllers)

Knit.Start({ServicePromises = false}):andThen(function()

print("Knit Client Started")

end):catch(warn)

Now for pros and cons, again!

Pros

  • Very organized
  • Easy networking
  • Idk, I can’t think of stuff on the spot man :man_facepalming:

Cons

  • Farewell, intellisense. You completely lose it, well except if you’re crazy like me and edited a whole damn LSP just to add knit support :grin:

Pre ending, almost there!

You are writing with markdown, you can’t indent, except with black magic! Use:

  •  
  • or  

Yup, manually put these monstrosities! Don’t even question it.


Ending

I know you’ve been waiting for this one lmao, I didn’t even realize how much I wrote, but after entering, there is no going back.

I hope that I’ve explained everything you need to know.

1 Like

Sorry,

MSA - Multi-Script-Architecture

Basically means using more than one server or client script to make your game function, etc. It’s what most people use and what you probably imagine when you think of programming, use of modules here and there but mostly for utility and making processes easier.

SSA - Single-Script-Architecture

This is where there’s one script on the client and one script on the server and they initialize a framework and/or load modules. From this point when modules are loaded the source code of the game is stored in the modules, and everything is executed in the modules, you can probably imagine how that could be confusing or complex on it’s own.

By the way, for your “MSA” example, is this one part of your game or the entire game? Because in that sense it would also be considered SSA, just ordered differently.

I don’t hate Knit I just don’t want to use, Knit is just the only framework I’ve actually tried. Programming using SSA and module loaders just seems extra complex. Like for my state machine I really just don’t understand how to handle it at all.

MSA is what I used to do in my very very veeeeeryyyyyyy early days lol, I liked SSA and module loading more, also since I love (and use, quite a lot) Rust, it was easier to get used to writing Rust when my brain was already into SSA, and now here I am using it for everything.

1 Like

It’s more MSA, you will have 1 like that for the server, which is really SSA, but for the client you usually have one for UI, sounds, effects, StarterPlayerScripts, StarterCharacterScripts, etc. (or whichever ones you need), and also when a UI is complex, instead of doing that for the whole UI I break it down so complex ones can be handled alone, although I never had issues with 1 main loader only. So I would guess this is kinda between SSA and MSA.


That kinda proves my point of being too much into SSA, lmao. It’s way better than MSA in general, personal preference and opinion, of course.

1 Like

Yea, I understand it has great advantages and whatnot.

One of the biggest problems I’ve had is just having zero reference information of how people genuinely build games using SSA. I really want to try making this all work out the problem is there’s none really making any sort of complex tutorials on how frameworks are used.

If I had cancer, my make-a-wish would be to see all of the modules in some reasonably complex game that uses Knit, lol. It’s cool and all in theory seeing it in videos but like it’s so hard to apply the bare-bones skills taught with the videos to a real scenario like I said with the state machine.

I feel you, even I after watching those videos had basically no idea what to do. They aren’t descriptive, at all. I learned the idea from the documentation and followed my own path in organization. For your cancer wish, I can show you some of my projects if you want, with and without Knit.

1 Like

If you’re working alone, don’t worry so much about pretty code. As long as you can make sense of it, it’s okay.

Try using comments as much as possible. Comments are the most important thing when programming. Your code will work without comments -sure- but you won’t be able to adjust it in a reasonable amount of time.

Use a consistent coding style, and try to keep everything formatted nicely.

You don’t need a framework. If you don’t enjoy working with them, don’t use them. It’s better to make progress than to fight against a framework.

1 Like

I would say that frameworks add overhead and complexity, but in the long run help massively. Its not even an organization thing, its a standardization thing. Most people can work short-term in an ‘unorganized’ environment and be just fine because they remember how everything works. But you’ll regret coming back to a codebase a year later and see a mess of different styles and setups.

The other thing frameworks can do is speed up development because theres more features immediately available, and you can more quickly leverage previously written code. However the benefits of such only come after working with frameworks for a while and getting comfortable with them.

1 Like

truth be told, organizing is really good.

if you are going to use SSA (i highly recommend) and you just want to make a game, I suggest not using a framework. But you MUST use VSCode (in my opinion), it is insanely helpful for literally everything. If you are hellbent on using Knit, go ahead I can’t stop you. Make sure you at least TRY to format your code, keep a consistent style, probably use correct casings, etc.

And lastly, practice. Practice practice practice. One of the best ways to get accustomed to using SSA architecture and VSCode is to just practice making random junk. If it’s simple, repeat it until it’s absolutely perfect every time, and you’re fast at it. Or if it’s advanced go hog wild and refactor later. It’s all about learning. so go do it!!!

thanks for everyone’s help and i hope others find this useful in the future

Both of these are very wrong… the only difference is a text editor. Structure does not change

1 Like

Sorry, others mentioned this to me, it’s fixed now I just didn’t have time earlier to fix it, again sorry.

I recommended using VSCode with ssa, i know it might come across as me saying you have to, but in my personal trouble trying to make the architecture work for me, vscode worked much better than roblox studios script editor.

As for the stuff about msa in vscode… yea sorry I was tired when I wrote that.

1 Like

I agree, Rojo does make it easier to manage structure due it’s json nature. But it’s not needed

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.