This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
oeed's profile picture

ComputerCraft Standards

Started by oeed, 30 November 2013 - 10:43 PM
oeed #1
Posted 30 November 2013 - 11:43 PM
As a few were starting to discuss here (which lead the thread off topic, hence this topic), it would make sense to collectively create standards for common things in ComputerCraft. For example, quite a few people make OSs and need a way to get the program icon, or check whether it's safe to close (such as when you close Word it asks if you want to save changes). To do this they have to make their own API, which barely anyone would/could use. After all, who wants to add 10 different methods to a program for one simple task. It's not only limited to OSs, for example file types and Rednet communication.

For this reason, I believe that we should all agree on ways and formats to achieve these tasks. Where possible we should use methods or formats already part of ComputerCraft for obvious reasons, for example using .nfp for images. The methods should be as easy and short to use as possible without (if possible) having to include an API. Most importantly, people should use them, if they are hard to include or understand that isn't going to happen.

Below are all the things I believe we need standards for, as we agree on standards I will put the full documentation in a spoiler for each one or a link to a topic/wiki page about it. If you disagree with a standard before it is fully agreed on please voice your issues. Additionally, if you think that there is something that needs/shouldn't have a standard say that too.

List of Standards

Images - The nitrogenfingers formats are probably the best ones to use here.

'Can Close' methods/event - As mentioned above, checking if it's safe to close

Screen Resizing - I believe that this is already part of CC, but many programs don't follow it

Rednet File Transfer - For being able to send files between programs made by different people

Wireless Peripheral/Term - A common protocol for wrapping and redirecting peripherals connected to other computers.

There are certainly more, if you have any more please post. Also, if you have any thoughts about this please say. This will only work if everyone agrees and accepts.
CoderPuppy #2
Posted 01 December 2013 - 12:24 AM
There's monitor_resize in CC but that's just for monitors.
Things to consider for resizing:
  • Should there be a resize event when the redirect is changed?
  • Should the event include the new size and/or old size?
jay5476 #3
Posted 01 December 2013 - 01:21 AM
No one will stick to a set of standards( people dont stick to the standard of indendation) the way that works for you is the way you use.
theoriginalbit #4
Posted 01 December 2013 - 01:33 AM
Images - The nitrogenfingers formats are probably the best ones to use here.
There is better. This standard is fairly limited to the abilities of the image!
apemanzilla #5
Posted 01 December 2013 - 01:49 AM
I think the only standard we could all agree on is Lua. And only because there's no other built-in language available.
D3matt #6
Posted 01 December 2013 - 03:19 AM
Standards doesn't have to mean there's only one. Look at how many standards there are on your computer just for images. Hell, paint alone has at least 10, let alone something more advanced like GIMP.
jay5476 #7
Posted 01 December 2013 - 03:39 AM
Well if there was a standard for everything wouldn't it just be perfect… but there isn't, take minecraft for an example forge is having trouble porting to minecraft 1.7 because mojang changed a lot of its coding and then forge has to be familiarised with it same as al minecraft modders. people cant just stick to one thing… you tell someone to do it there not exactly going to do it, so what about all the people that coed before coming on this forum how are they supposed to know
GravityScore #8
Posted 01 December 2013 - 04:40 AM
Standards probably won't work. They either just won't be adhered to, or they won't fit everyone's needs.

The simplest way (I can see) is to just make an API that has a set of functions covering these things, which simply call the native function on the OS depending on which OS is installed.

So say there is an api.minimizeWindow() in this API. If the OS were ThisIsAFakeOS, it might call window.getCurrentWindow().minimize(), but if it were BlahBLahBLahLBahOS, it might call win.minimize(). To the developer developing the application, it would then make no difference which OS the program was used on. You might also want the function to return true if the operation was successful or false if the operation isn't supported - or find some way to tell the application using it if a certain operation is supported or not.

Sort of like a cross platform graphics framework.
oeed #9
Posted 01 December 2013 - 05:03 AM
Standards probably won't work. They either just won't be adhered to, or they won't fit everyone's needs.

The simplest way (I can see) is to just make an API that has a set of functions covering these things, which simply call the native function on the OS depending on which OS is installed.

So say there is an api.minimizeWindow() in this API. If the OS were ThisIsAFakeOS, it might call window.getCurrentWindow().minimize(), but if it were BlahBLahBLahLBahOS, it might call win.minimize(). To the developer developing the application, it would then make no difference which OS the program was used on. You might also want the function to return true if the operation was successful or false if the operation isn't supported - or find some way to tell the application using it if a certain operation is supported or not.

Sort of like a cross platform graphics framework.

Actually, in terms of solving the OS based issues atleast (other would fit too) this is actually a very good system. I do agree that standards, unfortunately, probably won't be used. But a 'coversion' API's probably the next best thing
Bomb Bloke #10
Posted 01 December 2013 - 05:29 AM
http://xkcd.com/927/

That said, a sharing of ideas as to what encompasses "good coding practise" isn't a bad thing. Sure, no standard is likely to "stick" in the long term, but so long as everyone you're working with sticks to it that's good enough.
Edited on 01 December 2013 - 04:41 AM
theoriginalbit #11
Posted 01 December 2013 - 05:42 AM
Couldn't have summed it up better!
Symmetryc #12
Posted 01 December 2013 - 09:56 PM
Haha, nicely put :P/>
Cranium #13
Posted 02 December 2013 - 10:48 AM
Yep, nobody is going to agree on a standard here. Least of all for a videogame mod.
nitrogenfingers #14
Posted 02 December 2013 - 07:16 PM
Is there a great need for standardization? There are some competing programs on the forums with the same sort of capabilities but to be honest, not many, and if developers want cross-compatibility they can just choose to add support for specific protocols or file formats. Easier than reviewing published programs or expecting developers to conform to something they may consider arbitrary.

That said, an API with some of these general functions may not be a bad idea (assuming one does not already exist, which it probably does). Billing a tool like that and keeping track of programs that use it may make it easier for developers to collaborate with related but divergent projects and avoid the tedium or either developing a fresh protocol/format or scouring through someone else's code looking for something related.

OS Standardization is an entirely different kettle of fish, and the desire to have people to do THAT consistently is nothing more than the fevered dream of a madman.
Edited on 02 December 2013 - 06:16 PM