{"id":21412723,"url":"https://github.com/souris-dev/samosac-jvm","last_synced_at":"2025-07-14T02:32:18.067Z","repository":{"id":40385260,"uuid":"440540675","full_name":"souris-dev/samosac-jvm","owner":"souris-dev","description":"samosa - a statically-typed general purpose JVM-based programming language.","archived":false,"fork":false,"pushed_at":"2023-10-20T08:52:27.000Z","size":1232,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2023-10-20T15:45:04.826Z","etag":null,"topics":["compiler","java","jvm","kotlin","programming-languages"],"latest_commit_sha":null,"homepage":"http://samosa-lang.org","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/souris-dev.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}},"created_at":"2021-12-21T14:15:09.000Z","updated_at":"2023-07-21T08:47:25.000Z","dependencies_parsed_at":"2024-02-17T23:15:16.083Z","dependency_job_id":null,"html_url":"https://github.com/souris-dev/samosac-jvm","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souris-dev%2Fsamosac-jvm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souris-dev%2Fsamosac-jvm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souris-dev%2Fsamosac-jvm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/souris-dev%2Fsamosac-jvm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/souris-dev","download_url":"https://codeload.github.com/souris-dev/samosac-jvm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225942794,"owners_count":17549088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["compiler","java","jvm","kotlin","programming-languages"],"created_at":"2024-11-22T18:15:21.240Z","updated_at":"2024-11-22T18:15:22.408Z","avatar_url":"https://github.com/souris-dev.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"docs/images/samosa-lang-banner.png\" /\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003ca href=\"https://lgtm.com/projects/g/souris-dev/samosac-jvm/alerts/\"\u003e\u003cimg alt=\"Total alerts\" src=\"https://img.shields.io/lgtm/alerts/g/souris-dev/samosac-jvm.svg?logo=lgtm\u0026logoWidth=18\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://lgtm.com/projects/g/souris-dev/samosac-jvm/context:java\"\u003e\u003cimg alt=\"Language grade: Java\" src=\"https://img.shields.io/lgtm/grade/java/g/souris-dev/samosac-jvm.svg?logo=lgtm\u0026logoWidth=18\"/\u003e\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\u003ci\u003eWelcome, samosa lovers!\u003c/i\u003e\u003cbr\u003e\u003cbr\u003e\u003c/p\u003e\n\u003cb\u003eSamosa is a statically-typed general purpose programming language that runs on the JVM.\u003c/b\u003e\n\u003cbr\u003e\u003cbr\u003e\u003ci\u003eNote: Samosa - the programming language, is named after an Indian snack called \"samosa\", and is pronounced as \"some-o-saah\" (the part \"saah\" is pronounced like the word \"sour\", but without the \"r\").\u003c/i\u003e\n\u003cbr\u003e\u003cbr\u003e\n\n**NOTE: The online playground linked below is currently stopped due to budget constraints. It will be up soon. Meanwhile, feel free to download the compiler and give it a try!**\n\n\u003ca href=\"http://playground.samosa-lang.org\"\u003eTry it out\u003c/a\u003e or \u003ca href=\"https://souris-dev.github.io/samosac-jvm\"\u003eread the docs.\u003c/a\u003e\n\n\u003ch2 align=\"center\"\u003eInstallation\u003c/h2\u003e\n\u003ci\u003eThis section will be updated soon with the other alternatives for installing samosa.\u003c/i\u003e\n\n\u003ch3\u003eUsing a pre-built executable jar\u003c/h3\u003e\n\nYou really don't need to install anything if you already have JRE (minimum java version 11) installed. Otherwise, you'll have to install that first.\n\nHead over to \u003ca href=\"https://github.com/souris-dev/samosac-jvm/releases\"\u003ereleases\u003c/a\u003e to grab the latest version of the compiler (it is an executable JAR file, named in the format: `samosac-\u003cversion\u003e-full.jar`)\n\nYou now have the compiler, yay!\n\n\u003ch3\u003eBuilding from source\u003c/h3\u003e\n\u003cb\u003eNote: Ensure that you have the following installed (and in your PATH) before using the upcoming commands to build from source:\u003c/b\u003e\n\u003cul\u003e\n\u003cli\u003e\u003cb\u003egit\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003e\u0026ge; JDK 11 (the project was developed on JDK 17, but the code is compatible with java version \u003e= 11.)\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003cb\u003eApache Maven 3.1 or higher version\u003c/b\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\u003cbr\u003e\u003cbr\u003eTo download the source and build it using maven, run these in the terminal of your choice:\n\n\u003cbr\u003e\u003cpre\u003e\u003ccode\u003egit clone https://github.com/souris-dev/samosac-jvm.git\ncd samosac-jvm\nmvn compile\n\u003c/code\u003e\u003c/pre\u003e\n\nThen, to build the compiler jar, use (from within the project directory):\n\u003cbr\u003e\u003cpre\u003e\u003ccode\u003emvn package\u003c/code\u003e\u003c/pre\u003e\n\n\u003cbr\u003eThis will create a \u003ccode\u003esamosac-\u0026lt;version\u0026gt;-full.jar\u003c/code\u003e file in the \u003ccode\u003etarget\u003c/code\u003e folder. This is the compiler jar.\n\n\u003ch2 align=\"center\"\u003eUsage\u003c/h2\u003e\n\u003cb\u003eNote: Ensure that you have the JRE (minimum java version 11) installed before starting this section.\u003c/b\u003e\u003cbr\u003e\n\n\u003ch3\u003eCompilation\u003c/h3\u003e\nType your samosa program in a file, and name it something (for example samosa.samo).\nThen use the .jar file of the compiler to compile it \u003cb\u003e(ensure that you have java in you PATH)\u003c/b\u003e:\u003cbr\u003e\n\u003cbr\u003e\n\u003cpre\u003e\u003ccode\u003ejava -jar samosac-\u0026lt;version\u0026gt;-full.jar samosa.samo\n\u003c/code\u003e\u003c/pre\u003e\n\n(Replace \u003ccode\u003esamosac-\u0026lt;version\u0026gt;-full.jar\u003c/code\u003e with the relative path to the compiler jar file, and \u003ccode\u003esamosa.samo\u003c/code\u003e with the relative path to the file you wrote your program in.)\n\n\u003cbr\u003e\u003ci\u003eThis section will be updated.\u003c/i\u003e\n\n\u003ch3\u003eRunning the program\u003c/h3\u003e\n\nAs samosa compiles to JVM bytecode, a `.class` is generated, named as per your filename.\nSo for the above example, a file named `SamosaSamo.class` would be created in the `./out` directory.\n\u003cbr\u003e\u003cbr\u003eTo run it, do this \u003cb\u003e(ensure that you have java in your PATH)\u003c/b\u003e:\n\n```\ncd out\njava SamosaSamo\n```\n\n\u003ch2 align=\"center\"\u003eSyntax\u003c/h2\u003e\n\nAs samosa is still in its first release, it has limited features. More features will be added soon in upcoming releases.\n\u003cbr\u003e\n\n\u003ch3\u003eStarting a program\u003c/h3\u003e\nAny samosa program must start with \u003ccode\u003e\u0026lt;samosa\u0026gt;\u003c/code\u003e and end with \u003ccode\u003e\u0026lt;\u0026#47;samosa\u0026gt;\u003c/code\u003e.\n\u003cbr\u003eNote that statements in samosa end with a period (\u003ccode\u003e.\u003c/code\u003e).\nFor example:\n\n```\n\u003csamosa\u003e\n(\"Hello World!\") -\u003e putout.\n\u003c/samosa\u003e\n```\n(Note: in the example above, we are making a function call to \u003ccode\u003eputout\u003c/code\u003e, a built-in function. That line is equivalent to `System.out.println(\"Hello World!\")` in Java.)\n\n\u003ch3\u003eComments\u003c/h3\u003e\nComments in samosa can span multiple lines. They start with \u003ccode\u003e\u0026#47;\u0026#42;\u003c/code\u003e and end with \u003ccode\u003e\u0026#42;/\u003c/code\u003e.\nExample:\n\n```\n\u003csamosa\u003e\n/* This line is a comment and will not be executed. */\n(\"This line is executed.\") -\u003e putout.\n\u003c/samosa\u003e\n```\n\n\u003ch3\u003eVariables\u003c/h3\u003e\nVariables are declared with the keyword \u003ccode\u003ebro,\u003c/code\u003e \u0026nbsp;(yes, the comma is necessary :-)).\nCurrently, variables can be only of three types: \u003ccode\u003eint\u003c/code\u003e (for integers), \u003ccode\u003estring\u003c/code\u003e (for strings), or \u003ccode\u003eboolie\u003c/code\u003e (for boolean values).\n\nSome examples of declaration and initialization:\n\n```\n\u003csamosa\u003e\nbro, i: int = 0.\nbro, str: string = \"hello!\".\nbro, aBoolVal: boolie = true.\n\n/* Variables can also just be declared. */\nbro, j: int.\nbro, str2: string.\nbro, boolieVal: boolie.\n\u003c/samosa\u003e\n```\n\nIf a variable is only declared, the variable is assigned the default value for that type:\n1. for `int`, the default value is 57005 (in hex, `0xDEAD`).\n2. for `string`, the default value is `lawl`.\n3. for `boolie`, the default value is `true`.\n\nIf you're initializing a variable at the same time when you are declaring it, you can skip writing its type:\n\n```\n\u003csamosa\u003e\n/* Types will be inferred for these: */\nbro, i = 0.\nbro, str = \"string\".\nbro, aBoolVal = true.\n\u003c/samosa\u003e\n```\n\n\u003ch3\u003eExpressions\u003c/h3\u003e\n\nExpressions in samosa work in pretty much the same way as in Java/C++ or many other languages.\n\u003cp\u003eInteger literals allow digits from 0 to 9. Hex or octal number systems are not yet supported.\nIf your result is a floating point number, it will be converted to an int\nby taking off the part after the decimal point.\u003c/p\u003e\n\n\u003cp\u003eString literals start and end with double quotes. You can use the \u003ccode\u003e+\u003c/code\u003e operator for string concatenation.\u003c/p\u003e\n  Some example expressions:\n\n```\n\u003csamosa\u003e\nbro, str = \"string\" + \"literal\".\n\nbro, anIntVal = 3 + 4 / 4.\n\n/* Boolean expressions: */\nbro, aBoolVal = true or false.\nbro, anotherBoolVal = anIntVal \u003e 10.\nbro, someBoolVal = anIntVal == 10 and anotherBoolVal.\nbro, boolval = anIntVal != 100.\n\u003c/samosa\u003e\n```\n\nFor boolean expressions, any of `true`/`True`/`yes`/`TRUE` can be used for a truthy value.\n\u003cbr\u003eFor a falsy value, any of `false`/`False`/`nope`/`FALSE` can be used. \n\nIn boolean expressions:\n\u003cul\u003e\n\u003cli\u003e\u003ccode\u003e||\u003c/code\u003e or the keyword \u003ccode\u003eor\u003c/code\u003e stands for a \u003cb\u003elogical OR (not short-circuited)\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\u0026\u0026\u003c/code\u003e or the keyword\u003ccode\u003eand\u003c/code\u003e stands for a \u003cb\u003elogical AND (not short-circuited)\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e||!\u003c/code\u003e or the keyword\u003ccode\u003estrictor\u003c/code\u003e stands for a \u003cb\u003elogical XOR\u003c/b\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e!!\u003c/code\u003e or the keyword\u003ccode\u003enot\u003c/code\u003e stands for a \u003cb\u003elogical NOT\u003c/b\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003ch3\u003eConditional statements\u003c/h3\u003e\nSamosa supports \u003ccode\u003eif\u003c/code\u003e statements (and if-else if-else ladders). The syntax for \u003ccode\u003eif\u003c/code\u003e statements in samosa is similar to that found in many other languages:\nAn example:\n\n```\n\u003csamosa\u003e\nbro, i = 9.\n\nif (i == 9) {\n    (\"i is 9\") -\u003e putout.\n}\nelse if (i == 10) {\n    (\"i is 10\") -\u003e putout.\n}\nelse if (i == 11) {\n    (\"i is 11\") -\u003e putout.\n}\nelse {\n    (\"I dunno, I just like samosa.\") -\u003e putout.\n}\n\u003c/samosa\u003e\n```\n\n\u003cb\u003eDisclaimer: The example above is just for demonstration purposes. Please do not use such lame conditional statements. Thanks.\u003c/b\u003e\n\n\u003ch3\u003eLoops\u003c/h3\u003e\n\nSamosa currently supports only one kind of loops: `while` loops. It works in a similar way as in other languages:\n\u003cbr\u003eThe following example prints the numbers 3, 2, 1 sequentially on three lines. \n```\n\u003csamosa\u003e\n\nbro, i: int = 3.\n\nwhile (i \u003e 0) {\n    (i) -\u003e putout.\n    i = i - 1.\n}\n\n\u003c/samosa\u003e\n```\n\nOther kinds of loops will also be added in subsequent releases.\n\n\u003ch3\u003eFunctions\u003c/h3\u003e\n\nYep, samosa also supports functions!\n\u003cbr\u003e(\u003ci\u003eSamosa does not yet support first-class functions though, but support for the same is planned.\u003c/i\u003e)\n\u003cbr\u003e\u003cbr\u003e\n\n\u003ch4\u003eDefining a function\u003c/h4\u003e\nA function in samosa is defined using the keyword \u003ccode\u003elet\u003c/code\u003e.\nA function may declare some formal parameters, and can either return no value or return a value of a supported type (varargs are not yet supported).\n\nSome examples:\n\n```\n\u003csamosa\u003e\n\nlet function1(var1: int, var2: string): void {\n    /* do something here */\n}\n\nlet function2(var1: int): int {\n    return var1 + 3.\n}\n\n/* If your function returns nothing, you need not specify a return type. */\nlet function3(var1: int) {\n    /* do something */\n}\n\n\u003c/samosa\u003e\n```\n\n\u003ch4\u003eCalling a function\u003c/h4\u003e\n\nA function can be called as a standalone statement or within an expression, like in many languages.\nThe syntax for the same is: `(\u003carguments\u003e) -\u003e \u003cfunction name\u003e`, where `\u003cfunction name\u003e` is the name of the function to be called\nand `\u003carguments\u003e` is the list of passed arguments to the function, separated by commas.\u003cbr\u003e\n\u003cbr\u003e\u003cb\u003eNote: This syntax is will probably be changed as it sometimes causes readability issues.\u003c/b\u003e\n\u003cbr\u003e\n\u003cbr\u003eAn extended example of the program above would demonstrate this:\n\n```\n\u003csamosa\u003e\n\nlet function1(var1: int, var2: string): void {\n    /* do something here */\n}\n\nlet function2(var1: int): int {\n    return var1 + 3.\n}\n\nlet function3(var1: int) {\n    /* do something */\n}\n\n(10) -\u003e function3.\n\nbro, m = 7.\nbro, i: int = 3 + (5 + m) -\u003e function2.\n\n\u003c/samosa\u003e\n```\n\n\u003cb\u003eNote: To call a function, it must be defined before the point where it is being called. So, the following program will not work:\u003c/b\u003e\n\n```\n\nlet function1(var1: int, var2: string): void {\n    /* do something here */\n}\n\nlet function2(var1: int): int {\n    return var1 + 3.\n}\n\nbro, m = 7.\n\n/* The next line works as function2 is defined earlier. */\nbro, i: int = 3 + (5 + m) -\u003e function2.\n\n/* The next line does not work as function3 is defined later. */\n(10) -\u003e function3.\n\nlet function3(var1: int) {\n    /* do something */\n}\n\n```\n\nRecursion is supported, but the compiler does not currently perform tail-call optimization (support is planned for later releases).\nFunction overloading is not currently supported for user defined functions (but is supported for builtin functions).\n\n\u003ch4\u003eBuiltin functions\u003c/h4\u003e\n\nSamosa has a few builtin functions (more will be added soon, in addition to a small standard library).\nSome builtin functions have overloads.\n\n1. `putout`\n\n    This function takes a single argument and prints it to stdout, and prints a newline after it. It returns nothing.\n    \u003cbr\u003eThe argument can be a `string`, `int` or a `boolie` (three overloads).\n    \u003cbr\u003eExample:\n    \n    ```\n    \u003csamosa\u003e\n    \n    bro, i: int = 0.\n    bro, str: string = \"hello \".\n    bro, boolVal: boolie = \"boolieVal\".\n    \n    (i) -\u003e putout.\n    (str) -\u003e putout.\n    (boolVal) -\u003e putout.\n    \n    \u003c/samosa\u003e\n    ```\n\n2. `putinInt`\n\n    Takes in an `int` as user input (from stdin). Example: \n    \n    ```\n    \u003csamosa\u003e\n    bro, i = () -\u003e putinInt.\n    \u003c/samosa\u003e\n    ```\n\n3. `putinBoolie`\n\n    Similar to `putinInt` but inputs a boolean value.\u003cbr\u003e\u003cbr\u003e\n\n4. `putinString`\n\n    Similar to `putinInt` but inputs a string value.\u003cbr\u003e\u003cbr\u003e\n\n5. `stoi`\n    \n    Converts a `string` to an `int`. Takes a `string` as argument. Will throw an exception if the number is of the wrong format.\u003cbr\u003e\u003cbr\u003e\n\n6. `itos`\n\n   Converts an `int` to a `string`. Takes an `int` as argument.\u003cbr\u003e\u003cbr\u003e\n\n\n\u003ci\u003eThe above are a subset of the features of the language.\u003c/i\u003e\n\u003cbr\u003e\n\u003ci\u003eHead over to the \u003ca href=\"https://souris-dev.github.io/samosac-jvm/\"\u003edocs\u003c/a\u003e for more features of the programming language, like probable statements.\u003c/i\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsouris-dev%2Fsamosac-jvm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsouris-dev%2Fsamosac-jvm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsouris-dev%2Fsamosac-jvm/lists"}