Does roblox api run in C?

well, my question is: what is the api that runs in C
does roblox api run in C, such as Instance:FindFirstChild or Instance:Destroy(), or only the lua api does run in C?

I want to know this so I can realize does it worth to make my own custom functions
e.g. Instance:FindFirstChildOfClassAndName – a function I wanted to make since a while

or just the normal roblox api is way faster & performant – C code runs faster than lua code

as if the roblox api runs in luau then I should be able to create my custom function that helps me without losing performance.

4 Likes

Probably icalls, so written in C++

1 Like

Built-in methods and functions run in C++.

2 Likes

It doesn’t matter if luau runs in c or not. That function doesn’t exist, so you still have to implement it yourself.

Also I believe both languages (if compiled) are the same speed, that’s why big o notation exist, They focus on algorithms rather than languages.

The only reason why luau is slower in this case is because it is interpreted and not compiled.
Also @native exists. Also the performance lost is probably negligible.

Lastly I don’t know if it runs on c or not, it might be cpp.

1 Like

even luau ones right? because i know that lua methods like table.insert run in C

Yes (if you mean functions that’re embeded within the Luau C++ side)

1 Like

yes i know that but i wanted to ask so that some functions won’t be worth it to make if they’ll run slower than the normal api, thank u for the response!

1 Like

You wanted to make something like

function FFCOCAN(self, class, name)
  local k = self:FindFirstChild(name)

  if self:FindFirstChildOfClass(class) == k then
    return k
  end

  return nil
end

?

Or you wanted to manually cycle through the children list to check both class and classname?

PS: The code I sent doesn’t work in some cases, just a quick example

1 Like

manually probably, also note that this is just an example but i don’t need this function now, i already know how to make it
but i wanted to know if it’ll be faster than the normal api or slower by much

If you’re really worried about your code not running in machine code you can use @native

2 Likes

so this will make it as much speed as the api?

I see, well I agree with the fact that, so far Luau is quite fast, and I absolutely think that the difference in terms of time execution would be absolutely negligible ! I don’t think you have millions of children to check, the server would lag out before reaching this specific amount :joy_cat:

2 Likes

Depends on how it is compiled and type annotations etc.

But probably yes, at least faster than luau, but use it sparingly, best for huge calculations.

1 Like

so the difference between the roblox api and my custom functions won’e be that huge, and i can use @native if i wanted to boost the performance a bit
alright that makes sense, thank u!

1 Like

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