└── readme.md /readme.md: -------------------------------------------------------------------------------- 1 | This document has tips for getting started using the language in its current beta version, 2 | that aren't currently covered in the official distributed documentation. 3 | The distributed README.txt and the core programs in the how_to/ folder should be read first! 4 | 5 | Also check out the [Jai-Community-Library wiki](https://github.com/Jai-Community/Jai-Community-Library/wiki). 6 | 7 | Last updated 2021-10-21 8 | 9 | 10 | 11 | # Getting started info 12 | 13 | ## Navigating and finding functionality 14 | 15 | * Read the names of all the included modules in the distributed modules/ folder, 16 | to get a sense of what's available. 17 | 18 | * Check out this [Jai Awesome List](https://github.com/Jai-Community/awesome-jai) 19 | which has community-made modules. 20 | 21 | * Using grep-like tools to search the distributed code is a useful and common way to "get around" 22 | and find what you're looking for in the language. Some examples: 23 | 24 | * If I want to find where the string-related functions are, I might search for "string_". 25 | * If I want to find some example usage of a certain module, function, or keyword, I might search for "#import "Module\_Name"" or "function\_name" or "keyword". 26 | * If I want to find the definition of a function, I might search for "function_name ::". 27 | 28 | * These are some grep-like tools: 29 | 30 | * [ripgrep (Windows, Mac, Linux)](https://github.com/BurntSushi/ripgrep) 31 | * [BareGrep (Windows)](https://www.baremetalsoft.com/baregrep) 32 | 33 | * These are modules I recommend looking at when starting out: 34 | 35 | * Basic 36 | * String 37 | * Hash_Table 38 | * Math 39 | * File 40 | * Compiler 41 | 42 | ## Directory organization and custom modules 43 | 44 | You can organize your directories however you like. One format some people use is: 45 | 46 | jai/ 47 | jai/ - The distributed compiler folder. For compiler updates, just replace this folder. 48 | bin/ 49 | examples/ 50 | ... 51 | jai_modules/ - Downloaded modules and your own modules. Use the compiler's -import_dir command line flag for it to find your custom modules folder. 52 | my_project_1/ 53 | my_project_2/ 54 | ... 55 | 56 | ## Debugging 57 | 58 | You can use a debugger with an exe and the generated .pdb file. 59 | For example, in Visual Studio, open the .exe file using File -> Open -> Projects/Solution, and you can set breakpoints and run. 60 | 61 | ## Crashes 62 | 63 | If your program crashes, as of the time of this writing, the program will stop 64 | and nothing will be printed out. This can be confusing! 65 | You can use the Debug module to print the stack trace on crashes: 66 | 67 | Debug :: #import "Debug"; 68 | 69 | main :: () { 70 | Debug.init(); 71 | 72 | a := 0; 73 | b := 1 / a; // Cause a crash 74 | 75 | write_string("done\n"); // The execution will not reach this point 76 | } 77 | 78 | ## Pointer operators 79 | 80 | a: int; 81 | b: *int = *a; // address-of 82 | c: int = <