0

Since all languages are finally compiled to JVM, can I freely mix all filetypes in one project?

For example, can I put all types of files in Eclipse project interchangeably? If I do so, how can I be sure that all files are compiled when I run some of my main classes?

Is here any guide how to embed Scala and Xtend portions into big Java project? Not guide to use from scratch?

Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385

1 Answers1

2

You can - just enable the relevant maven plugins/eclipse natures

The only problem I can think of is if you have circular dependencies between them. The scala compiler is smart enough to read and understand java source and resolve circular dependencies between scala and java, but I doubt it understand xtend - so you may have to avoid circular dependencies between scala and xtend classes, and pick one compile order (either xtend then scala, or scala then xtend). I assume similar reasoning would apply to xtend - circular dependencies between xtend and java are probably ok, circular dependencies between xtend and scala maybe not. Of course such circular dependencies are poor style in any case.

I would question why you would want to do this. Xtend is meant to bring you the most important advantages of scala without the complexity of the full language. But if you're going to learn and have your project depend on scala anyway, I can't see what benefit you get from writing part of it in xtend.

lmm
  • 17,386
  • 3
  • 26
  • 37
  • I am expecting this as the way of learning: to write in Scala or Xtend only some classes, leaving most of the project being normal Java. – Suzan Cioc Feb 08 '15 at 09:02
  • I really don't recommend trying to learn both at the same time; Scala is a complex language that will demand your full attention. – lmm Feb 08 '15 at 09:05