It will generally depend on the technical aspect of your application.
If the only thing that's public in the app is the log in page, having a separate domain name (
app.example.com) is a good idea because that way you can prevent the entire app website from being indexed by search engines.
If you think you'd have many public pages, then having them on the same website is a good idea SEO wise, because Google is going to see
www.example.com as one website and
app.example.com as another website (unless you 301 everything, but then what's the point of having a sub-domain?!)
For example, your app. may come with a documentation which you want to make public (after all, it's a good idea to have the documentation searchable, google is likely going to be better at finding the right page for your users than your own search capability.) That being said, you could have the doc on
www.example.com and still have the app on
Technically, though, it may be useful if you are going to use "strange" backends such as Tomcat. Personally, I still don't understand what problems Tomcat solves because all my systems never require it. Yet I know that to setup your server(s) it could make it a lot easier. Not only that, you could have one server for the website (
www.example.com) and another for the application (