Hello Everybody,
I am 100% new to Nim (I programmed exclusively in Java and a bit of Python before) the only thing I did was Hello World and now I have a question to the set up of a "real" project:
Do you write all code in one file or do you use multiple files for different things (like class files in java)? And if you do so how do you reference other files/classes/whatever? Is there something like packages? How is it all structured? Do I have to use CMD/BASH to set it all up?
Thanks in advance :)
Have you tried reading some tutorials?
https://nim-lang.org/learn.html
There are also videos at youtube.
Generally in Nim we do not but all objects in its own source file as it is common in Java. So generally You just create one single text file for your code, and you import modules like strutils, sequitils, tables or whatever you need. Many stuff is already available without import from system module. For libraries not directly available in Nim we have external packages and the nimble or nimph package manager. Of course when your own code grows it may make sense to divide it in multiple modules. For a chess game you may have your module engine for the chess algorithm, and your module board for the display. Maybe one more for saving games to disk.
The official tutorial has section about modules:
https://nim-lang.org/docs/tut1.html#modules
I have also written something about modules:
http://ssalewski.de/nimprogramming.html#_modules
The other tutorials may contain more details.
There's the Nim package manager Nimble and its README has a section on project structure.
Also, if you use nimble init on the command line, it will create the structure for you to have an easy start. :-) The example files also have imports so you see how a file references others.
something compiled successfully
win7
nim.cfg line 163
@end
@end
how i feel - https://www.youtube.com/watch?v=ogUQ5eGFvuw