Replies: 4 comments 10 replies
-
Another Fut-like feature would be that a similar syntax could allow one to drop to a "general language" as opposed to remembering the syntaxes of target languages. So one could want to write:
which is translateable to e.g. C++, Java or Python at least. The benefit here is that we don't care how classes or public and static functions, in this case, are declared in a target language, but we just use a general expression for what we mean. |
Beta Was this translation helpful? Give feedback.
-
Mixing different programming languages within a single function is a crazy idea. What is the advantage of that? What is the expected result? (a standalone executable?)
This is basically what Fut does now, but your syntax is more verbose. |
Beta Was this translation helpful? Give feedback.
-
A single executable in the host language (in the example it would be C) or a collection of interconnected modules from different language targets (in the example we would have a C "host" program that calls a Python module generated from the global program. However, based on where Fut is, I speculated that the host language could be any language that Fut already supports. And naively the modification I am proposing only requires "modularizing" the other targets. The advantages are similar to as when using FFIs or other languages, we can use a better or easier abstraction for something. The benefit of having these in the same file is that we don't need to search through large text files in other languages to look for the particular thing that we are using, but rather we can see that particular thing right where it's used, mixed into the host language we are working with.
Not exactly, because using e.g. list notation [] we don't need to even care about the order of things, just that they're mentioned. |
Beta Was this translation helpful? Give feedback.
-
My understanding is that you want FFI as a single-source file, much like what SYCL does compared to OpenCL. This is an interesting idea, but very loosely related to Fusion. Fut only accepts Fusion as input while C, Python etc. are its outputs. Someone suggested translating to Fusion, which would open possibility for more transpilations. You should not expect that we can translate any language into another one, as some statements cannot be directly translated, for instance pointer arithmetic in C. There was also an earlier attempt to transpile C# to Fusion (then called Ć). Note that Fusion is designed specifically to be transpiled to mainstream imperative languages, not from them. |
Beta Was this translation helpful? Give feedback.
-
I have been thinking about this idea for a while, and I noticed that it could complement Fut or be implementable based on Fut.
The idea is to be able to interleave code from multiple programming languages into "global programs". For example, consider if we wanted to write while we are writing a C program, then we could want to do e.g.:
or, for using nice idioms from other languages, we would want to do:
Now these are just very naive and probably non-reasonable examples, but I wanted to give the ideas. So what if one wanted to write different languages in the same file (and not using FFI or the sorts) and use suitable idioms from other languages that are smarter than those of the host language. So that one may mix different abstractions in the same language.
I am, at this point, not exactly sure, how one would implement such, but based on Fut, my naive idea points to e.g. translating what's between # -statements to modules that can be compiled using the target language (e.g. #lang.C scopes can be compiled using gcc/clang). In short one-liners it might be possible to just statically infer what the corresponding host-language statement is and then do text replacement.
Further questions would be about type conversions needed to switch from another scope to another scope.
Beta Was this translation helpful? Give feedback.
All reactions