odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.4k stars 562 forks source link

Regarding C compatibility #7

Closed flplv closed 3 years ago

flplv commented 7 years ago

Hi Bill,

I've watched your videos and read part of your code, I have to say, it is a very nice proposal this language of yours, I'd be happy to experiment with it.

I'd like to know what are your thoughts about C compatibility. I know it sounds strange this question, let me put my rationale to your judgment.

Assembly programming was successfully replaced by the C programming language, as we know today, yet, it is observable that you can still write assembly inside C code. C compilers support it since there's always a corner situation that developers might want to write assembly, such as optimization, integrating old code base or dealing with platform specificities. I anxiously wait for the day that C will be replaced, and the Odin programming language seems to be a competent candidate for that, but as we can learn from C vs assembly, I believe the the replacement will have to support C in a very considerable extent to make the replacement more likely to happen. We have already a lot of code written in C, even more that we had with assembly, also we live in times where there's really a huge amount of different platforms and providers where C runs, creating a very segmented ecosystem that relays on C as its foundation, which will impose even more resistance to a language migration. In face of that facts, I believe that we cannot simply replace C, but we'd have to embrace it in order to later replace it.

That's why I wonder how Odin is stands on this matter.

Best, Felipe

gingerBill commented 7 years ago

Odin can already interface with static and dynamic library very easily. It's how it interfaces with win32, opengl, and numerous other APIs. See sys/windows.odin for a big example. (The only thing not supported is C-style varargs in the calling conventions but that's due to numerous reasons).

I do think C can be replaced, but you are correct that there will be a transition period where you want/have to use existing C code. I want this language to replace my needs for C, completely, and I think it is already very possible to do so.

n.b. I already use Go(lang) for a lot server work and I don't need to interface with C at all as its libraries and tooling is so good that I don't need to interface with C (i.e. cgo).