9 ms·
OneLang – A tool to help writing code in multiple languages at the same time
- EtDybNuvCu 9y agoFrom https://github.com/koczkatamas/onelang/wiki/FAQ https://github.com/koczkatamas/onelang/wiki/FAQ it is clear that this tool falls far short of actual polyglottery.
- diyseguy 9y agoI have wanted this for such a long time. How can I make python the main typing window instead of Typscript?
- tpetry 9y agoIf anybody is looking for something stable for years, have a look at haxe [1] [1] https://haxe.org https://haxe.org
- platz 9y agoHow classy of you
- Stratoscope 9y agoI realize it's sometimes not considered cool to point out competing projects, but the OneLang project FAQ explicitly says that it's a proof of concept, not ready for production use, with no documentation, and may never be finished. https://github.com/koczkatamas/onelang/wiki/FAQ https://github.com/koczkatamas/onelang/wiki/FAQ OneLang does seem like a nifty project, but given its current state, it seems pretty reasonable to point toward Haxe for anyone interested in something similar that has been around for years, well documented, and used in production by many teams.
- fao_ 9y agoWhat's the problem? It's a related project for those people who are interested in this sort of thing.
- Cyph0n 9y agoHow so? Haxe is the de facto king of the compile-to-everything space. Therefore, it's inevitable that Haxe will be mentioned on a submission like this.
- platz 9y agoalso consider https://blog.plan99.net/graal-truffle-134d8f28fb69 https://blog.plan99.net/graal-truffle-134d8f28fb69 > Truffle is a framework for writing interpreters with annotations and small bits of extra code in them which, when Truffle is paired with its sister project Graal, allow those interpreters to be converted into JIT compiling VMs … automatically. > If Truffle is a framework for writing AST interpreters, then Graal is the thing that makes them fast. > Truffle provides a language interop framework called Polyglot that allows Truffle languages to call each other
- bringtheaction 9y ago> Haxe is the de facto king of the compile-to-everything space. Indeed, I remember stumbling across it years ago while looking for a way to develop Flash games without Adobe Flash Professional. I never got around to actually try it but I keep seeing it every now and then, even saw a couple of books about it in a physical bookstore some years ago. It was the first thing that popped to mind for me as well when I saw that OP title mentioned write code in multiple languages at the same time.
- NicoJuicy 9y agoDo you have an example on how to use Haxe for a cross platform API client? Eg. Develop once, use in 12 different programming languages? The first requirement seems to be a go ( https://api.haxe.org/haxe/Http.html https://api.haxe.org/haxe/Http.html ) but i'm not sure of other variables for implementing this Other sources: - https://github.com/tbrosman/haxe-rest-client https://github.com/tbrosman/haxe-rest-client - https://github.com/tnwinc/rehx https://github.com/tnwinc/rehx
- simonpantzare 9y agoNot sure if it helps, but have a look at Swagger/OpenAPI if you haven't already.
- NicoJuicy 9y agoGood call, installed it in the past for trying the exact same thing :)
- MikeTheGreat 9y agoCan I ask how Haxe is connected to Flash? For some reason, the first time I looked at Haxe I got the impression that Haxe is an open-source Flash / Flash successor. (Mostly, I think, because Flash keeps getting mentioned with projects associated with Haxe, like OpenFL and Flambe, and several times in the Haxe Wikipedia article). Clearly Haxe isn't "just" an open Flash, but how is Haxe related to Flash?
- sshine 9y agoHaxe can compile to Flash, which is such a distinguishing feature that people actually use it to write Flash applets: https://haxe.org/manual/target-flash-getting-started.html https://haxe.org/manual/target-flash-getting-started.html If you have ever tried to write Flash applets the old-fashioned way, it feels more like a scriptable paint program.
- damoebius 9y agoHaxe is a programming language and should be compared to as3. It is much more powerful and can compile to 12 targets including JavaScript,php, c++, and as3. OpenFL is a cross-plateform port of the flash API in Haxe. All this flash stuff are just a part of an amazing technology.
- ahauxuueei 9y agoHow is this different to haxe? https://haxe.org/ https://haxe.org/
- koczkatamas 9y agoI started to write a comparison page here, but missing a lot of important aspects: https://github.com/koczkatamas/onelang/wiki/OneLang-vs.-Haxe-comparison https://github.com/koczkatamas/onelang/wiki/OneLang-vs.-Haxe... Tl;dr: you cannot use One in production now, but the grand plan is to make One as hackable and flexible as I can. So here is the plan: - the compiler does not contain any target language-specific part, you can add a new language by creating a few hundred lines of template file (this actually works already, it is not just a plan) - rewrite One in One, so you can convert from any language to any language in any language - there is no StdLib, but libraries can be created by anyone. We publish interface and implementation definition separately, and you can eg. implement a Web client interface for PHP and Node, while somebody else can implement it for C# and Swift. Behaviour defined by interface tests, if your implementation passes interface test => good. If there is no test for an edge-case => undefined behaviour. Read more here: https://github.com/koczkatamas/onelang/issues/9 https://github.com/koczkatamas/onelang/issues/9 - you write a library in One and it helps you to publish to every language's package manager (npm, pip, NuGet, etc). You can reach much more developer with your library compared to targeting only one lang's developer base
- ghthor 9y agoThis idea has been ronning around in my head, paired with a mining and crypto element. The language specific implementations of those interfaces could be mined(by hand or automated) for coins to directly incentivise engineering effort. The block acceptance would be based on the universal tests/benchmarks passing.
- SlowRobotAhead 9y agoHow to do one thing ok, and 10 things strangely.
- Iv 9y agoMy sex life in one sentence.
- mpweiher 9y agoIsn't it more an indication of how little substantial difference there is between most mainstream languages?
- ksherlock 9y agoYou can write Typescript in any programming language.
- koczkatamas 9y agoIn the demo video (https://youtu.be/Rwo6KJ_Pa9Q https://youtu.be/Rwo6KJ_Pa9Q) there is a part where I am editing the same code in 4 languages (C#, TypeScript, Ruby and PHP) simultaneously. But yeah, generally only a limited subset of a language is supported. This is the price of writing code targeting multiple language. That's why you cannot (and probably won't be able to) convert existing code.
- sametmax 9y agoIt's fun but breaks very quickly. One simple line such as "console.log(Math.random(10));" will fail. Amusing anyhow. Also: please make it python 3. It's been 13 years...
- Stratoscope 9y agoThat would fail to compile in TypeScript as well, and you should get a red squiggly or other syntax error indication in most IDEs. Math.random() takes no parameters. From lib.d.ts: interface Math { // ... /** Returns a pseudorandom number between 0 and 1. */ random(): number; // ... }
- koczkatamas 9y agoActually `Math.random()` will fail too. I am probably not emphasizing this enough, but One is currently a "toolkit" for converting syntax between languages. `Math.random()` is ~a standard library function. One has limited knowledge about language's StdLibs. But you can make `Math.random` (or any method) work without modifying the compiler, only by adding the appropriate implementation and StdLib definitions to appropriate files. (Even now only using the WebIDE). The plan is to make One plugin-able and create a "package" manager infrastructure, so anybody can implement `Math.random()` or any other methods, publish it and then you can just download that package. Implementing every language's StdLib is not a one-man job, so I've always considered this out-of-scope. Sorry if any published information regarding this was misleading.
- Iv 9y agoOh, ok I think I understand it better. That sounds like a really useful tool. Actually in a project I was in last year we really hesitated between writing a lib in C++, C# or Java (Native android, Unity3D lib, Android java) and had good arguments for either but no budget for maintaining all three. I would have seriously considered your option at the time. I have no time to dive into this now but I'll bookmark it and come to wave at your gitter. Is it realistic to contribute to it with knowledge of C++/C#/Java/Python but a pretty poor grasp of JS?
- deleted 9y ago[deleted]
- zbentley 9y agoWhy not write one piece of code that is simultaneously valid in ~12 languages? https://github.com/stephane-chazelas/misc-scripts/blob/master/which_interpreter https://github.com/stephane-chazelas/misc-scripts/blob/maste... I know it takes advantage of some technicalities (end-of-input separators and such), but it's still a remarkably impressive piece of engineering. I put that up there with some really hairy quines (https://github.com/mame/quine-relay https://github.com/mame/quine-relay), except it can actually be useful!
- btilly 9y agoWhat are the 12 languages? I already tried: node perl python ruby bash tcsh From the code it is obvious that DOS and php are on the list, but I don't happen to have them. What are the others?
- zbentley 9y agoI'm counting different editions of POSIX-compliant shell languages (e.g. ksh93, zsh, bash, [t]csh) as different, as well as massively different editions of DOS (freeDOS, MSDOS). Hence the approximating tilde on "~12". Reasonable minds may consider there to be many fewer, or many more, compatible interpreters. EDIT: There also appear to be multiple compatible JavaScript interpreters--browser V8 (though not Node, oddly--it's detected as generic; I may send a PR sometime), SpiderMonkey, and older IE. I'm no expert on JS runtimes, though, so the differing results I'm observing may be due to something else.
- awwaiid 9y agoSee also http://cdent.org/ http://cdent.org/
- rwx------ 9y agoWent to github to see the project maturity and "OneLang is the love child of @koczkatamas and it was not a planned child. .... OneLang is six months old at the time of writing and it already speaks, but don't expect any comfortable conversation with it yet. It cannot grow without a loving family, and as a single dad I cannot take care of it alone. It needs more mommies and daddies who can help raise it up."
- ASalazarMX 9y agoWow, sounds real mature.
- koczkatamas 9y agoAt least I am not lying... ;)
- hitekker 9y agoConsider changing "mommies" and "daddies" to "mothers" and "fathers".
- BartBoch 9y agoDisregard them, they expect corporate style language even for a side project. Cool concept and I actually like the wording, it hints the user, that this is a personal project.
- warent 9y agoI thought it was funny and unique. Don't worry about people who can't get with your style
- madez 9y agoI liked the style. It was entertaining, informational, clear, and unique.
- mathgladiator 9y agoindeed, I like your project. Negativity of the community can be discouraging. I stopped a project of mine because of a combination of the negativity and from the reality of having to hiring and train people to use my language. Here is _some_ of the negativity I got: https://www.reddit.com/r/programming/comments/6ori0/kira_is_a_programming_language_that_compiles_to/ https://www.reddit.com/r/programming/comments/6ori0/kira_is_... What excites me about your project is the possibility to write core math or business logic once and then expose to multiple environments.
- jdonaldson 9y agoFor anyone interested in cross platform development, check out Haxe and its testing process. Writing a target that passes those tests is like finishing Dark Souls. The level of effort here is about on par with finishing the character selection screen.
- marknadal 9y ago@koczkatamas this is mindblowingly awesome! Keep it up and ignore the haters. Question: Can it support plain JS -> other languages? Or does it have to be TypeScript? How could plain JS support be added?
- BillinghamJ 9y agoIt seems like a really strange choice for the "source" language to be JS - a language without any real static typing capability (even with TS). The most limited & basic kinds of static analysis are technically possible, but why not just start with an entirely static language and translate from that to dynamic languages? Would seem much simpler...
- ghthor 9y agoYeah, Id choose an ML as the root language.
- smt88 9y ago> It seems like a really strange choice for the "source" language to be JS I can't speak for the author, but I can think of several reasons I might choose JS: 1. Almost everyone working on the web knows it, so not knowing the source language won't be a roadblock right away. 2. Precisely because of the issues you mentioned, JS is a lot easier to translate with perfect (or close to perfect) fidelity. If the source were something like Haskell, every translation would be very lossy. 3. JS has no boilerplate, like setting up a class or something. You can just type statements. 4. OneLang itself is written in TS, which means working with JS as the source might be easier than, say, C#.
- yorwba 9y ago> 2. Precisely because of the issues you mentioned, JS is a lot easier to translate with perfect (or close to perfect) fidelity. If the source were something like Haskell, every translation would be very lossy. On the contrary, the fewer restrictions a language has, the more difficult it becomes to translate it into languages with stricter requirements. If this were built on JavaScript and not TypeScript, it couldn't even generate the correct type annotations for the other languages that require them. I doubt that this project is going to grow a Haskell backend anytime soon.
- deleted 9y ago[deleted]
- HasbroMurderer 9y agoOpening the site on my 3GB RAM laptop froze it - could you please not pile web frameworks atop one another? Being able to translate between languages in all cases is intrinsically impossible because of the halting problem; that this works is a testament to how restrictive and bland the Von Neumann language paradigm is, seeing as these languages aren't terribly different and all have ridiculously long specs. The closest you could get to doing this for most languages would be to specify sets of composable, first-class macros in a purpose-written Lisp (almost certainly a Scheme derivative) and write FFIs to port in standard libraries around the core languages made from macros.
- yorwba 9y agoThe halting problem has nothing to say against translating between languages. A non-terminating program will simply be translated into another non-terminating program. In fact, Turing completeness is all about the fact that a program in any language can be translated into an equivalent program in another. Some languages can't be parsed without solving the halting problem, but even in such cases, you can simply bundle it with an interpreter in the target language. And the subset of programs humans are actually likely to write should be much saner.
- deleted 9y ago[deleted]
- everdev 9y agoProgramming language translation has to be on the horizon. The cost of switching is currently too high. I got into a project years ago with this ambition using an AST and allowing each language to provide their own translation for each syntax element or block of code. It also had the unique benefit of being able to take larger blocks like a function and allowing the translator to provide a full function in some native programming language so that a login or Fibonacci function could have multiple translations in the same language allowing the translation to evolve and adapt to use the most efficient one as new translations were introduced.
- maruhan2 9y agoHey I'm curious about your journey than the final result. I only skimmed through the code, so I don't understand everything, but it seems that the list of things it will identify is in the "yaml" files. Did you write out all of them or was there a pre-existing database somewhere?
- lozzo 9y agoit does not work on my first test: My program is i=1 and the Java program it produces is: class Program { public static void main(String[] args) throws Exception { i = 1; } } which is wrong because "i" must be defined in java as in "int i;"
- yorwba 9y agoTry writing "let i = 1". I think the assumption is that if you use undeclared identifiers, you'll provide them to the generated code in some other way.
- rqs 9y agoRather, I think it's a good tool that could help people who already knew a programming language to learn a new one.