Will there be a swift based shading language for Metal API?

I love to use just one language for all. Swift enables scripting as well. I would like to see it as Metal shading language as well apart from using it as a Shell. C++ based Metal is great but I don't want to mix it with Swift.

Replies

I would expect the answer to that is: no.

the only reason it's a C++ derivative language, is because it has to be as close to the GPU as possible. Swift is a high level language.


in short... if they could have made it with swift, they would have. speed is the scarce resource here.

I think Swift didn't exist (to the world at large and most people within Apple) when Metal was created. However, there is no reason why a Swift-dialect couldn't be created that can be used for GPU programming. It wouldn't be 100% the same as regular Swift but MSL also isn't 100% the same as C++. Is it worth doing so? Probably not.


By the way, h t t p s://twitter.com/warrenm/status/1009646623431876613


Something along these lines (though not specific to Metal) was floated as an aside in last year's concurrency manifesto (see part 5, "The crazy and brilliant future") but that isn't an indication of any concrete plan at Apple. Maybe something like this will happen eventually, but I wouldn't hold my breath.


Also, in case it's helpful to anyone…I want to note that, while there are syntactic differences between Swift and the Metal Shading Language, they have a lot of underlying concepts in common. The concepts specific to GPU programming are well explained by the spec, and you can start writing Metal shaders without needing to define the render pipeline using APIs like

SCNProgram
or shader modifiers—getting a project set up where you can make changes and quickly see visual feedback eliminates a lot of barriers to learning.

I'm a Python numba.cuda user, I think this is the end of my exploration. It's quite disappointing that Apple doesn't care about non-apple researcher at all. PyTorch and Tensorflow are two high-level language for any specific calculations, while C++/OC-based GPU coding is too much for non-CS engineering student. Swift-based metal shader language would be a brilliant idea. I will keep using my 3090 for GPU calculations and leave the M1 Max for lighting up the displays only.