-4

For some reason, I absolutely HAVE to use paths like src/main/kotlin/com/martmists/... etc, why can I not just use src/...? This annoyance is the only thing keeping me from studying jvm languages, and I have yet to find a way to simplify these paths.

Martmists
  • 152
  • 1
  • 6
  • 1
    you mean why do we use packages? – Stultuske Feb 22 '18 at 13:39
  • 2
    You don't *have to*, it is just best practice and has quite a lot advantages... – Timothy Truckle Feb 22 '18 at 13:40
  • I don’t know why *you* “absolutely HAVE to use paths like” written in your question. If you explain what your “for some reason” are, you already have the answer to your question. Since I don’t need to use paths like that, I don’t know why you need. – Holger Feb 22 '18 at 13:41
  • no one forces you to use these paths, but using simply the default package, comes with problems: https://stackoverflow.com/questions/7849421/is-the-use-of-javas-default-package-a-bad-practice – Emerson Cod Feb 22 '18 at 13:44
  • Any why did you tag the question with `[jvm]`? The JVM doesn’t care about how you organize your source code that the JVM will never see. – Holger Feb 22 '18 at 13:44
  • Of course you are free to work along your own, preferred conventions. But be prepared to throw out a lot of tools that rely on the "standard" conventions. You decide what's less annoying. – Ralf Kleberhoff Feb 22 '18 at 14:30
  • So far every IDE and/or compiling tool I've tried uses this path structure, which ones works with my preferred structure? – Martmists Feb 23 '18 at 14:05

1 Answers1

2

Look, I just created a Kotlin project with the default settings:

Simple project

There were no forces compelling me to create the structure you describe.

Neither long package names, nor the src/main/kotlin/ structure are mandatory, but you'll fight an uphill battle if you avoid them. The reason is that JVM languages target large-scale projects, where organization into meaningful subunits (packages), as well as the division between production code and test code, is beneficial and not detrimental to its success.

In some other languages you get a cozy feeling of a lightweight start, but as your project grows towards 10,000 lines of code and beyond, you realize that you've been reinventing this structure all along to keep you afloat.

I can attest from personal experience that the IDEs take away most/all the pain of dealing with nested directory structures and allow your project to scale up gracefully, with no need to reinvent best practices.

On the other hand, if your use case for a programming language is writing one or two screenfuls of script code, then the JVM ecosystem is probably not a good fit for you.

Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436
  • I just personally think having a structure like that is bad design, why have so many (otherwise empty) folders, if it could easily fit in one or two folders just below top level? I do build a lot of applications, but people keep telling me to move from python to JVM languages. I'm interested in them, but if I have to deal with such a structure I'd rather go for the C family or something – Martmists Feb 23 '18 at 14:09
  • What exactly do you think is forcing you to use this structure? Write code in `vi`, put everything in one directory and compile with `javac` from the command line. It will work. – Marko Topolnik Feb 23 '18 at 14:10