title: Scala PlayFramework and Angular JS - too much effort in terms of duplication and mixing concetps
body: <p>I tried to write an application on <code>playframework</code> + <code>scala</code> + <code>Angular JS</code>.
  The purpose was to create an web app that would work either good when JavaScript is OFF or ON in the browser. This is usual requirement when one writes Public Site (which should be good for people and for Google that would index it)</p>
  
  <p>So I ended up with <strong>~50%</strong> code written in <code>JavaScript</code>, having two(2) folders named <strong>"controller"</strong> - one for <code>Scala</code> code, one for <code>JS</code> code (since AngularJS uses controller concept as well). </p>
  
  <p>Also, since <code>JS</code> code is supposed to use <code>Ajax</code> calls, I had to create <strong>one more</strong> scala-controller that returns <code>json</code>, but not <code>html</code> back to client's request. And.. this all I do not like. This seems as too much effort. </p>
  
  <p>On <code>playframework</code> template side, I should think how to combine <code>Scala</code> with <code>JavaScript</code>, passing parameters from one language to another. Using some tricks like showing <em>that</em> when JS would be processed, showing <em>that</em> when it is supposed to be off. </p>
  
  <p>This all makes my template <strong>less understanable</strong>, and one day, when I have huge code base, I may come up with a solution to duplicate my templates as well (js templates + scala templates) - to use proper template when <code>JS</code> is off/on. Then amount of JS code could rise up to <strong>60%.</strong>. </p>
  
  <p>And then it seems that I'm going to <strong>duplicate everything</strong>, like having <strong>two different application</strong> - for <strong>Google</strong> and for <strong>people</strong>. What would be common (only) is my data themselves in my database, I have not to duplicate data. But.. there we might have a different issue with a format of that data (and most likely would be json-based [because I do not wasting processor time to do table-object transformation], but not table based - NoSQL.. then again we come to JS like DB -  like to <strong>MongoDB</strong>), and <code>JS</code> works very good with Json, <strong>natively</strong>.</p>
  
  <p>Then question, why not use 100% of <code>JS</code> for <strong>simple</strong> things like: <strong>request-response</strong>, <strong>forming a page</strong>, <strong>layouts</strong>. Server side <code>JS</code> controller could form my templates - then I do not need to switch from one language to another and be even more productive in this sense.</p>
  
  <p><strong>Question:</strong>
  Do you have any suggestions? Best practices about this? I'm not that guy who want to end up using <code>NodeJS</code> to use<code>JavaScript</code> as ONE languages for everything - for server and client. But let's speak about productivity and business needs.</p>
  
  <p>There is an example (not mine) of AnjularJS controllers, how much JS I have to write:
  <a href="https://github.com/tastejs/todomvc/tree/gh-pages/architecture-examples/angularjs/js" rel="noreferrer">https://github.com/tastejs/todomvc/tree/gh-pages/architecture-examples/angularjs/js</a></p>
  
  <p>and just imagine that I have to keep PlayFramework controllers along with that - for HTML and AJAX calls, mixing things in scala/playframework templates with JavaScript.</p>