Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Yves Quemener
    @yquemener
    But the lib I am thinking about is a mathematical/geometry lib that only use very little external calls, so I think the amount of work could be minimal
    Tamás Koczka
    @koczkatamas
    oh, in that case there is a little chance that Onelang can help you even in its current state
    Yves Quemener
    @yquemener
    :+1:
    Alexandre Rocha Lima e Marcondes
    @arlm
    Hello. How do I change the source language to generate from C#?
    Tamás Koczka
    @koczkatamas
    You can change the languages by changing the layout parameter
    Alexandre Rocha Lima e Marcondes
    @arlm
    Thank you very much
    Great project!
    aolko
    @aolko
    hi there
    how can i swap the main window from typescript to php? Cos i'm getting errorTypeError: Cannot read property 'body' of undefined on https://ide.onelang.io/?input=MultiLangTest&layout=**php|*python,*ruby
    ...and echo() support seems to be missing
    Tamás Koczka
    @koczkatamas
    one asterisk (*) means it's an input language
    the following languages can be used as input languages: php, ruby, cs, ts
    almost nothing is implemented from language's StdLib's, onelang mostly focuses on converting syntax
    but you can implement what you need
    to do this, select the "Transforms" tab and add the following transform (sadly currently there is no more convenient solution for top-level functions yet):
      - description: "(PHP) echo($text)  =>  OneConsole.print($text)"
        langs: [php]
        input:
          exprKind: Identifier
          text: echo
        output:
          exprKind: PropertyAccess
          object:
            exprKind: Identifier
            text: OneConsole
          propertyName: print
    Tamás Koczka
    @koczkatamas
    image.png
    after doing that the code in the screenshot above compiles
    aolko
    @aolko
    (it can be used w/o brackets ;) (like py2))
    echo "that text";
    Tamás Koczka
    @koczkatamas
    well, currently you have to modify your code to make parse it, basically at every step the support is really lacking
    I wrote the PHP parser in a few hours, mostly copy-paste from other parsers
    but this is true for the C# and Ruby parser too
    I wanted to see what part is interesting for people: converting from one source lang to multiple target language (eg. TypeScript -> *)
    or converting from multiple languages (depending their preferences) to others, etc
    aolko
    @aolko
    ts and js are not very good src
    it's better to aim for python
    Tamás Koczka
    @koczkatamas
    well, people usually expect full grown products with support of big companies for free created by tens of developers for years and expect same quality from a hobby project created by a standalone developer in his free time
    and people with such attitude will usually always find problems in every project, it's impossible to satisfy them.
    of course he can edit the "one.hpp" and the code generation part, so he can fully control the generated code, but that would require effort on his part and he considers easier to spend this effort on salting ;)
    Tamás Koczka
    @koczkatamas
    is this post from a public forum?
    aolko
    @aolko
    no, "the coding den" discord server
    MIchael Solomon
    @mikicho
    Hm... did you heard about https://haxe.org ?
    MIchael Solomon
    @mikicho
    @GreyCat I use Haxe for some years and this comparison doing wrong to haxe... haxe is more than just trans-compile one lang to other, but also add a lot of really cool stuff to the basket like macros, pattern-matching, inline and much more.
    Also, Haxe have really smart and blazingly fast compiler that supply DCE, analyzers and more
    Although, it must to say, that Haxe have its own cons but it always getting better :)
    Tamás Koczka
    @koczkatamas
    That's why the disclamer is there:
    Disclamer: I don't know Haxe well, so if you know it better and you could improve the contents of this page, please tell me by opening an issue (but first check if there is one already).
    Most One features are implemented fully in templates and you can modify every character in the output if you want, including adding new features via attributes (like the way I added the preliminary reflection)
    So although currently One and Haxe are looking similar, they are really different internally
    IMHO
    MIchael Solomon
    @mikicho
    @koczkatamas I read that.. my words are not to criticize the compression, but to emphasize that Haxe is not only tran-compiler :)
    @koczkatamas BTW... why create brand-new lang instead of getting involve Haxe?
    Tamás Koczka
    @koczkatamas

    @mikicho mainly because I wanted to learn how to parse languages, generate syntax via templates, see the differences between languages first hand. Reading other's code is less fun for me than doing it actually from ground zero.

    Other reasons: I wanted to be able convert from one language's syntax to other and AFAIK Haxe only accepts Haxe as input language, so simply it would not work. Also one of the goals of the project to be able to compile Onelang itself to every supported language, which would be near impossible with Haxe

    One of the project where I thought One could come handy had to run in the browser, so I had to use a language which converts to JS.

    MIchael Solomon
    @mikicho

    to compile Onelang itself to every supported language

    what do you mean by that?

    Tamás Koczka
    @koczkatamas
    @mikicho create a package for C++, C#, Go, Java, ... which is generated by One and can be used for convert code from C++, C#, Go, Java, ... to C++, C#, Go, Java, ...
    Liu YuanYuan
    @mgenware
    Hi @koczkatamas , thanks for this great project. just found that onelang is smart enough to transform a small set of APIs to different languages, for example [1, 2, 3].push(4); in js gets converted to []int{1, 2, 3} = append([]int{1, 2, 3}, 4) in go and new List<int> { 1, 2, 3 }.Add(4);. while some funcs like Array.pop are not supported. so i'm wondering are there any docs on the list of APIs supported by onelang? thanks.
    Tamás Koczka
    @koczkatamas

    hi @mgenware ! Sadly Onelang does not really support language stdlib methods yet (there are a few exceptions, as you mentioned). I should've emphasized this point in my communication, sorry if I was not clear enough about this. You can view the currently supported methods here: https://github.com/koczkatamas/onelang/blob/master/langs/StdLibs/stdlib.d.ts

    Currently Onelang is a toolkit for converting syntax mostly. Although you can add any new methods even in the WebIDE, this is of course can be a lot of work. Here is the main issue about supporting libraries (not just syntax): koczkatamas/onelang#9

    My main focus is now to provide a public repository / plugin system, so if somebody implements something, then he/she can publish it immediately, others can use it. But there is no quality control. The goal of the project is to provide these main functionality of course, but I don't want to be a single blocker entity in the process, that's why I favor a community style solution.