{"id":46535775,"url":"https://github.com/mittelmark/fusion-tutorial","last_synced_at":"2026-03-06T23:34:25.014Z","repository":{"id":334518028,"uuid":"1141207541","full_name":"mittelmark/fusion-tutorial","owner":"mittelmark","description":"Tutorial for the Fusion Programming Language","archived":false,"fork":false,"pushed_at":"2026-02-16T12:05:25.000Z","size":405,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-16T15:58:23.447Z","etag":null,"topics":["programming-language","swig","transpiler","tutorial"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mittelmark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-24T12:58:38.000Z","updated_at":"2026-02-16T12:05:29.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mittelmark/fusion-tutorial","commit_stats":null,"previous_names":["mittelmark/fusion-tutorial"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mittelmark/fusion-tutorial","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittelmark%2Ffusion-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittelmark%2Ffusion-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittelmark%2Ffusion-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittelmark%2Ffusion-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mittelmark","download_url":"https://codeload.github.com/mittelmark/fusion-tutorial/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mittelmark%2Ffusion-tutorial/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30203384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"ssl_error","status_checked_at":"2026-03-06T18:57:34.882Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["programming-language","swig","transpiler","tutorial"],"created_at":"2026-03-06T23:34:24.278Z","updated_at":"2026-03-06T23:34:24.995Z","avatar_url":"https://github.com/mittelmark.png","language":"HTML","readme":"# Tutorial and Code examples for the Fusion Programming Language\n\nThe [Fusion programming language](https://www.fusion-lang.org/) allows you to\nwrite code which can be transpiled to code for other programming languages\nlike C, C++, Java and others. The generated C or C++ code can be then used in\nscripting languages like Tcl, R or others using the\n[Simplified Wrapper and Interface Generator (Swig)](https://swig.org). \n\n## Links\n\n__This site:__\n\n- [Fusion Tutorial (WIP)](http://htmlpreview.github.io/?https://github.com/mittelmark/fusion-tutorial/blob/master/tutorial/tutorial.html)\n- [GetMessage Example 1](https://github.com/mittelmark/fusion-tutorial/blob/master/samples/hello) - hello world example for the nine programming languages and as well for using Go, Lua, Octave, Tcl, and V with Fusion\n- [GetMessage Example 2](https://github.com/mittelmark/fusion-tutorial/blob/master/samples/hello2) - hello world example with Main function as well for the 9 languages and examples using the code with Tcl via [Swig](https://swig.org)\n- [Fibonacci Example](https://github.com/mittelmark/fusion-tutorial/blob/master/samples/fib) - function for Fibonacci numbers as well use examples for Go, Lua, Octave and Tcl\n\n__External:__\n\n- [Fut Project Page](https://github.com/fusionlanguage/fut)\n- [Getting Started](https://github.com/fusionlanguage/fut/blob/master/doc/getting-started.md)\n- [Fusion Reference](https://github.com/fusionlanguage/fut/blob/master/doc/reference.md)\n- [Fusion Playground](https://www.fusion-lang.org/playground)\n\n\n\nBelow you see a list of programming languages which you can target directly\nusing using the [fut - command line tool for Fusion](https://github.com/fusionlanguage/fut/)\nor, indirectly, using the `fut` generated C code and with [Swig](https://www.swig.org). See the Tcl section below for that approach.\n\n\n![Diagram](https://kroki.io/graphviz/svg/eNp1UU1PGzEQvfMrRu6lFW4CCKRKyL0stFWFCgq5RTl47Ul2FMdebG_SLeK_4_UaGlRqWf6aec9v3mhae9k2cAWPR5BGvi2M7F0XRdy7lrh3Lorq-tf8erbMOYH-oGBfLs_ZZb5bp3ERYm9QrMgY1HzYlDPOiyDN1lkeGtmiqN1vvicdG3E6ORm5UK8RCjg4Q5pvyRq04nSMe2k3AVtxBtMpBIzpQVMXOJBNUzUYctr9ntbw-StUZwtNXtRSbZZvAmN1acyV4XDTSQ6zNLu653Crotwhhzv05oLDd5eOP-44sMlkwjLu6ZUrWVOjEWw4s1KWIq8MHhTNwqavTYdsmVAZmnQVYMXeTRyL_es0DPViiLI2FBqIDcJHsjsKVBv8BAptRJ-dz8jp9NDInDhSjmzl829doNdm_KO6aFkWwgJ9h7N0Ah860pQkWoUgjclqAqy82xbsgYI3PWDV8TFL_lYf0nrF4afcST4s98pTG5P9fWySUKj4YPoqvcz7Fl-ity3a6ubF2rE3UC3-Z-vR0zNEI-MK)\n\n## Example\n\nHere is the classical \"Hello World\" example:\n\n```csharp\npublic class Hello\n{\n    public static string GetMessage()\n    {\n        return \"Hello, world!\";\n    }\n}\n```\n\nThe folder [samples/hello](samples/hello) contains a Makefile which shows how\nto translate this code into these various programming languages as well as\none example to use Swig to generate a Tcl library based on the Fusion output.\n\n## Python example\n\nIf you put the code above into a file `Hello.fu`, you can translate this file into a Python source file with this command:\n\n```\nfut Hello.fu -o hello.py\n```\n\nThe contents of that file would then look like this:\n\n```python\n# Generated automatically with \"fut\". Do not edit.\n\nclass Hello:\n\n\t@staticmethod\n\tdef get_message() -\u003e str:\n\t\t\"\"\"Returns a greeting message.\"\"\"\n\t\treturn \"Hello, world!\"\n\n```\n\nThe Fusion language is not meant to be used to write applications directly.\nIt is possible to some extent and we will show it later. However, Fusion is focused on\nwriting libraries which can be then used within the mentioned languages. To\ntest the example code above, you can create a small file which contains code\nto use the generated Python file with following content.\n\n```python\n#!/usr/bin/env python3\nimport hello\nh=hello.Hello()\nprint(h.get_message())\n```\n\nSo the full procedure to create and run the Python code is as follows:\n\n```bash\nfut -o hello.py Hello.fu\npython3 run-hello.py\n```\n\n## C example\n\nSimilarly, you can transpile the Fu-file into a C-file like this:\n\n```\nfut Hello.fu -o hello.c\n```\n\nThis will create two files \"hello.c\" and \"hello.h\".\n\n\nTo run the generated method in a C program, you might create a C file\nwith a `main` function like this:\n\n```c\n// file: run-hello.c\n#include \u003cstdio.h\u003e\n#include \"hello.h\"\n\nint main (int argc, char * argv[]) {\n    printf(\"%s\\n\",Hello_GetMessage());\n    return(0);\n}\n```\n\nYou can then compile your _fut_ generated hello files and the run-hello.c file\nto an executable like this:\n\n```bash\ngcc hello.c run-hello.c -o hello\n```\n\n## Tcl example\n\nUsing the Swig tools, we can additionally take the generated C or C++ code and wrap\nit into a Tcl, R, Perl, Ruby or many other language libraries by creating a Swig interface file which looks like\nthis:\n\n\n```\n%{\n#include \"hello.h\"\n%}\n%include \"hello.h\"\n```\n\nThe pipeline to create and test the code using a shared library on a Debian\nsystem looks like this (using the Tcl programming language):\n\n```bash\nfut -o tcl/hello.c Hello.fu                     ## generate hello.c and hello.h\nswig -tcl8 -module hello hello.i                ## create the interface C code\ngcc -fPIC -c hello.c                            ## compile the FU generated code\ngcc -fPIC -c hello_wrap.c -I/usr/include/tcl8.6 ## compile the SWIG generated code\ngcc -shared hello.o hello_wrap.o -o hello.so    ## combine both to a Tcl library\necho \"load ./hello.so; puts [Hello_GetMessage];\" | tclsh    ## execute the code using Tcl\n```\n\n## Other Language Examples\n\nThe file [samples/hello/Makefile](samples/hello/Makefile) contains\nexamples to translate and compile the [Hello.fu](samples/hello/Hello.fu) file shown above to C++, C#,\nD, Java, JavaScript, Python, Swift and via Swig to Tcl, R, Lua, Go or Octave programs.\n\nThe file [samples/hello2/Makefile](samples/hello2/Makefile) contains\nexamples to translate and compile a [Hello2.fu](samples/hello2/Hello2.fi) file shown above to C++, C#,\nD, Java, JavaScript, Swift and Tcl programs. In contrast to the example shown above,\nthis one shows how to use a `Main` method within your class to create a terminal application.\n\n## Standalone applications\n\nEven if the main target of the Fusion language is writing libraries, for testing purposes\nyou can also write simple standalone applications, in order to directly test\nyour code. This avoids a second source file to run the library code which we have shown before.\nOur \"Hello World!\" example show above would\nlook then like this:\n\n```csharp\n// file Main.fu\npublic static class Main {\n    public static void Main() {\n        Console.WriteLine(\"Hello World!\");\n    }   \n}\n```\n\nThat file can be then transpiled and executed as a Python program like this:\n\n```bash\nfut -o main.py Main.fu \npython3 main.py \nHello World!\n```\n\nThe generated output file main.py looks like this:\n\n```python\n# Generated automatically with \"fut\". Do not edit.\n\nclass Main:\n\n\t@staticmethod\n\tdef main() -\u003e None:\n\t\tprint(\"Hello World!\")\n\nif __name__ == '__main__':\n\tMain.main()\n\n```\n\nYou can as well execute this translation as an one liner:\n\n```bash\nfut -o main.py Main.fu \u0026\u0026 cat main.py | python3 \nHello World!\n```\n\nUsing Python as the target language allows for fast development without extra compilation steps.\n\n## Tutorial\n\nThere is a more extensive tutorial as a WIP project which you can view here\n\n[![Fusion Tutorial](https://img.shields.io/badge/Fusion-Tutorial-blue)](http://htmlpreview.github.io/?https://github.com/mittelmark/fusion-tutorial/blob/master/tutorial/tutorial.html)\n\n## See Also\n\nHere are three other programming languages which transpile to several other programming languages:\n\n- [Haxe](https://haxe.org/) - C++ and Java like language, transpiles to C++, C#, JVM, PHP, Lua, Python, Neko\n- [Temper](https://temperlang.dev/) - C++ and Java like language - transpiles to C#, Java, JavaScript/TypeScript, Python, Lua\n- [Wax](https://github.com/LingDong-/wax) - Lisp like language - transpiles to C, Java, Typecript, Python, C#, Swift, Lua \n\nThe main __advantages__ of Fusion seem to be its easy-to-learn language,\nwhich is closely similar to C#, and its clear and small implementation. It\nhas a reasonable set of target languages, covering the top six programming\nlanguages from the TIOBE index. The installation size is less than 1 MB and\neasy to accomplish.\n\nThe main __disadvantage__ seems to be the smaller core library, which results\nin fewer string or list functions, for example. However, this is the price we\nhave to pay for a small, clean core. However, we can implement missing\nfunctionalities by using native blocks to add more features in a language-\nspecific manner or by writing utility classes that provide the necessary\nfunctionality for a specific project.\n\n## Summary\n\nThe Fusion programming language allows you to implement libraries and\nalgorithms usable for many widely used programming languages in a C#-like\nsyntax. This syntax is therefore easy for many programmers to comprehend.\n\nWith the SWIG interface generator, you can target even more languages,\nincluding scripting languages such as Tcl, Perl, Lua, and Octave, as well as\ncompiled languages such as GO.\n\n## TODO\n\n- adding swig/R examples (done - [src](https://github.com/mittelmark/fusion-tutorial/tree/main/samples/hello/R), [Makefile r-run section](https://github.com/mittelmark/fusion-tutorial/blob/main/samples/hello/Makefile))\n- adding swig/Go examples (done [src](https://github.com/mittelmark/fusion-tutorial/tree/main/samples/hello/goswig))\n- fibonacci examples for return an integer and recursive programming\n\n## Author\n\nDetlef Groth, University of Potsdam, Germany\n\n## License\n\nThe Fusion transpiler \"fut\" is released under a GPL license, the documents on\ncode examples used in this Github repo are released under a BSD 3 license.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmittelmark%2Ffusion-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmittelmark%2Ffusion-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmittelmark%2Ffusion-tutorial/lists"}