How to use RequireJS in AngularJS Application?

Javascript gurus convince me that I should use javascript over compile to js languages like Dart or Typescript?

  • Hello I am about to start developing massive frontend application and I researching what is my best option for client side ecosystem. I am a guy with Java background, doing Spring applications for some time and during my spare working on my private project that most of it's logic parts reside in browser. It's a web based image processing and diagramming application that requires lot of graphic processing, advanced user interactions like drag and drop and I expect codebase will be large enough. I had dealt with poorly written large js codebase. It's quite headache to me. Then I have developed bad reputation for javascript. Initially I was looking at Google web toolkit. But i found it's not suitable to my application, cost of developing in GWT was very expensive because of it's complex abstraction. I finished research and planning phase. Also recently I switching to Ruby for my day to day work. I'm tracking http://www.dartlang.org/ development since it's inception and very impressed with it. I love the features like classes, mixin, built in approach of library(For me it's the huge benefit over Javasript), Stream/Promise and Web Components. I like the it's nature of it's strictness. Optional static typing of dart language minimizes misbehavior of the application and help me write more effective/optimized code. Importantly I can apply familiar design patterns and programming techniques used in Java world. Right now I'm decided with go with it or gave more points to it. More recently I spent a lot of time in discovering more advanced usage of Javascript. Just finished reading John Resig's "Secrets of the JavaScript Ninja" and quite opened my eyes. I can see using RequireJS and Grunt can manage my large codebase. I read the arguments of people saying long time risks of using Dart. Concerns are: Compiled javascript source code can have unexpected bug and it can possibly to affect application behavior. Javascript is evolving. Ecma.next promises nice features like modules, maps and classes. And even right we can write Ecma.next code using traceur. If Google shipped native dart vm in chrome. Performance of my application will differ in other browsers. It's not good. It's not widely adopted so when your application grow it's hard to find good people who code in Dart. For me these are not convincing enough to give up on Dart. So if you have some interesting point on both Dart and Javascript side please tell me. This may sound like I'm confusing but it's just a part of my research. Of course there's other parts of development like app architecture/design and patterns in addition to particular programming language or technology.

  • Answer:

    As a famous quote in Computer science goes. All problems in computer science can be solved by another level of indirection Except problems caused by too many levels of indirections. Let me elaborate on a previous experience that I hope will be useful in this instance. I worked on a project that used Hibernate 3 when it initially came out. The team members were Java veterans. Hibernate enabled us to Avoid the syntactic mess that was JDBC. i.e. avoid all the prepared statements and setters of JDBC and use annotations instead. The resulting code was concise and modeled our application accurately. Allowed us to deliver a complex app in a short timeframe. Ensured (in part) that our code was maintainable. Functional and load testing went well and was deployed to production. As soon as we hit approximately 10% the expected load the application slowed down to a crawl. Turns out the load tests were not representative of read and write operations. As you may have guessed we got so lost in the abstract Hibernate layer and how it solved all our problems that we forgot that it was backed by a relational database with locks, keys and indexes. When we turned on SQL logging it became apparent that the SQL being generated had too many joins and our (hibernate generated) DB schema was a detailed guide of what not to do when designing a performant Database schema. Each of us understood SQL enough to never have come up with the schema that resulted. The reason that schema came to be was our reliance on our ORM to do a job that we should have done. Here are a few questions I would ask when adding a layer of abstraction to any real world projects I work on now. Does it have a large enough support and adoption to easily troubleshoot complex problems which I do not anticipate? For the features that this abstraction promises are there enough developers in the team who truly understand those features? And what happens when we bring in a new team member? How easy would it be to ramp up a fresh college grad to an acceptable level of proficiency such that their code does not bring the whole system down? This is a measure of how easy is it to mess up when using this abstraction. Given the above can I afford that risk to the project at hand? If I can answer those questions satisfactorily,only then will I use the abstraction :-)

Deep Joy Majumdar at Quora Visit the source

Was this solution helpful to you?

Other answers

Customers rule the world, having said that implies that customers do not care if you use Dart or Typescript and they want a working application. And they expect to spend less money on any device. Regardless of Pro JS or Pro Compile to JS opinions, we have to adopt way that works well. If I am paying you the money then my demand is biggest convincing point to choose I want. Compile to JS will fade out easily, try looking at history of open source projects, languages etc. Many platforms, tools, languages came and vanished. Few lines of code/library hosted on site does not make it something great to switch onto. Each compile to js tool is somewhat changing behaviour of code itself, like dart compare operator behaves little differently then JS. You can check Dart JS compatibility. This leads to hours of debugging for no error in code. The reason Java became Successful because it was truly system independent and each developer could communicate and work in team easily. JS still has cross browser issues. And imagine what will happen with different browsers, different compile to JS tools with same logic executing differently.

Akash Kava

I’ve written a not insignificant amount of vanilla JS. But I’ve written far more in Dart, but client and server side. Rather than say why you should use Vanillia JS, or Dart, either way, I will address some of your concerns you mention. Dart has been around for a few years now. It would be extremely difficult to find a bug in Dart’s compiled to JavaScript sources. And the wonderful thing about Dart is it will help you much more efficiently find the bugs in your Dart code. JavaScript is evolving, and if you have another 5 years to start your project you’ll be able to use a totally different version of Javascript than you’re likely to start with now. So many new features that are constantly being added. Sadly support is not across the board as new features are added so many cannot be used without a library or polyfill. They won’t. Google has already come forth and said rather than continuing to push for Dart VM in Chrome, they will focus on their compile-to-JS game to make Dart code compile more efficiently and run better in all browsers and interop better with existing JavaScript libraries. Dart is ‘Familiar’. A new Dart developer can pick up code in a couple of hours, especially developers from Java or C# areas, the same developers who will be able to understand your design patterns that you take from Java. I also extensively use Dart on the Server side in as well as the client side. Often reusing the same code on both sides. Dart does do some since things for you on the compile-to-js side. It takes into account browser differences for you (unless specifically noted). While not as serious as it was several years ago, there are still a number of areas where some browsers implement things slightly differently or possibly not at all.

Matthew Butler

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.