Live data from Hacker News

OneLang – A tool to help writing code in multiple languages at the same time

ide.onelang.io

11–20 of 69 posts

Re: OneLang – A tool to help writing code in multiple languages at the same time

#11

It'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...

That 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;

      // ...
  }

Re: OneLang – A tool to help writing code in multiple languages at the same time

#13

How is this different to haxe? https://haxe.org/

I started to write a comparison page here, but missing a lot of important aspects: 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

- 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

Re: OneLang – A tool to help writing code in multiple languages at the same time

#14
post #6
post #4

If anybody is looking for something stable for years, have a look at haxe [1] [1] https://haxe.org

How classy of you

What's the problem? It's a related project for those people who are interested in this sort of thing.

Re: OneLang – A tool to help writing code in multiple languages at the same time

#16

It'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...

2008 to 2018 is 10 years last I checked.

Re: OneLang – A tool to help writing code in multiple languages at the same time

#17

It'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...

That 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; // ... }

Actually `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.

Re: OneLang – A tool to help writing code in multiple languages at the same time

#18

It'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...

2008 to 2018 is 10 years last I checked.

December 2008, not even 10 yrs yet.

Re: OneLang – A tool to help writing code in multiple languages at the same time

#19
post #6
post #4

If anybody is looking for something stable for years, have a look at haxe [1] [1] https://haxe.org

How classy of you

How 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.

Re: OneLang – A tool to help writing code in multiple languages at the same time

#20
Why not write one piece of code that is simultaneously valid in ~12 languages?

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), except it can actually be useful!

Post reply on HN