I was curious regarding what is happening in memory when we execute a Java program, so I have watched some short tutorials just to have a basic understanding.
Those 'tutorials' are talking about heap and stacks and how those works and what are their purpose.
Java SE as an OOP language is defined as stateful which means that variables changes in function of time ( example x = x + 1 ).
Considering that variable are 'spread' across heaps and stack I can understand why Java is stateful and why we can fall on concurrency issue.
However seems like functional programming languages doesn't suffer of those issues cause they are stateless (with all the benefit which I am not going to list here)..
However Scala, which is defined as functional programming, is build upon the JVM, so I believe it has the same memory management of Java (SE).
1) Is the memory management a peculiarity of the JVM or of the Java SE?
2) if the memory management is a peculiarity of the JVM, how come that Scala is defined as a functional programming language?