News for hackers. Stuff that matters.
Re:Angular 2 Style Guide by gremy0 on Thursday May 05, 2016 @11:25AM (#11636903)
"Write Angular 2 with style"

> Request javascript version

"This chapter is not yet available in JavaScript. We recommend reading the TypeScript version."

LOL

Re:Angular 2 Style Guide by spriggan3 on Thursday May 05, 2016 @11:32AM (#11636975)
Same with their tutorials on angular.io .

Angular2 is a framework build for Typescript and Dart, barely for Javascript and certainly not for ES5.

Re:Angular 2 Style Guide by zip1234 on Thursday May 05, 2016 @11:45AM (#11637105)
TypeScript is fantastic. Maybe it will be the undoing of Angular2 but I doubt it. The Angular2 team chose TypeScript because writing large applications using the limitations of ES5 is extremely difficult. TypeScript makes the task manageable and compiles back into ES5 (or whatever you want). The tooling is lightweight and freely available. Give it a try!
Re:Angular 2 Style Guide by spriggan3 on Thursday May 05, 2016 @11:53AM (#11637176)
Typescript isn't Javascript. I gave it a try already,for 2 years, and I used Angular 1 in production, I'm moving to something else like React or Vue.js, both supporting actual Javascript (even JSX isn't necessary). Good luck with your non standard syntax like decorators... Angular 1, despite its internal complexity, was just one file dropped in an html page and you're ready to go. There was nothing that mandated a complete rewrite with breaking APIs at first place. I complained to Igor 3 years ago about it. Well let's see how it goes.
Re:Angular 2 Style Guide by radicalbyte on Thursday May 05, 2016 @12:28PM (#11637507)
Typescript is ES with totally optional type information, which protects you from a whole lot of bugs and for javascript bad API design (i.e. horrors like APIs which return different types with different input).

I can understand that it feels strange, especially to someone who has had little exposure to languages outside of Javascript. However it is very much worth investing the time in learning it.

15 years ago I was making the same argument to Visual Basic developers about C#..

Re:Angular 2 Style Guide by gshulegaard on Thursday May 05, 2016 @01:34PM (#11638121)
I'm sorry but I will never use Angular 2.0 unless it can be used with straight JavaScript. I am a backend developer that, for personal projects, needs to do small amounts of front-end work. Anything that potentially increases complexity or involves a redundant learning curve (learning yet another _imperative_ language that compiles into JavaScript anyway) is not something I am going to invest time in.

It's a shame too, I was a pretty big Angular fan. I used Angular, Ember, and even React and for several reasons I ended up settling on Angular as my favorite SPA framework (back in 2014 and 2015). Back when they announced Angular 2.0 would be TypeScript based, I felt like it was a mistake and that feeling has only gotten stronger as TypeScript has continued to fall behind EMCAScript (http://kangax.github.io/compat-table/es6/).

If TypeScript adopts compilation down to WebAssembly, that would be a reason to learn it/give Angular 2.0 a chance for me, but until then I will stick to Angular 1.0 or move towards React for my next project...which is a shame because I really don't like Reacts focus on the V of MVC. Maybe I will go back and check on Ember, but I wasn't a fan of it's tight binding of Models to Views (sometimes I just need a VC or a V and not a full MVC)...but maybe it has changed.

Re:Angular 2 Style Guide by squeaky-clean on Thursday May 05, 2016 @02:31PM (#11638615)
> I'm sorry but I will never use Angular 2.0 unless it can be used with straight JavaScript.

It can. Typescript is just optional information added to your Javascript. All Javascript is 100% compatible TypeScript. You can use TS extensions anywhere you like, your whole codebase, only certain function APIs, or nowhere at all.

Re:Angular 2 Style Guide by Roboprog on Thursday May 05, 2016 @11:09PM (#11641419)
Ugh, I'm tired of mandatory "OOP for dummies" a la Java (and C# to a lesser degree). I've been programming since the early 80s, and I have been exposed to more than just Javascript, or Java/C# for that matter. (BASIC, Fortran, Pascal, Lisp, some assembler, xBASE, C, some C++, Shell, Perl, Java, C#, Ruby, Javascript, some Python, some Objective C, some Scala, Groovy and smatterings of other proprietary / DSLs)

My first job in the mid 80s was in a language with runtime typing. My experience is that "strong" (compile/parse time) typing is not the panacea that many say it is. I've seen far more damage caused by C style "operator precedence stew" issues (vs Lisp style all funcs w/ parens). It's like the Type Police have to punish us for the dark era of C/++ Play-dough Pumper byte molding the industry had to put itself through in the 90s.

In fact, I would much rather see a language that forced modules/data/functions to be flagged which were not immutable/idempotent (which should be an enforced default), rather than an even-trade-at-best static type feature. Yes, that means your "main" would be flagged as "dirty", so it could do I/O, but your library modules (lang; 3rd party; app) would mostly be pure functions.

Anyway, I much prefer dynamic (runtime) types and FP with an occasional dash of OOP style Javascript to the "Let's be like Java!" cult. As Douglas Crockford likes to say "Those people will go to their graves, never knowing how miserable they are". Ironic, considering how the coming holy grail of ADTs/Objects was beaten into us in Uni in the 80s, and FP all but ignored.

Re:Angular 2 Style Guide by Roboprog on Thursday May 05, 2016 @11:26PM (#11641479)
As long as I'm peeving at length about the Java meme plague, I wish the whole MashedUpCamelCraps identifier style would just die, already, vs you_can_skim_this style.
Re:Angular 2 Style Guide by Touche on Thursday May 05, 2016 @01:34PM (#11638120)
You're wrong, there are various other differences. Some of what TypeScript implements isn't supported by JavaScript yet (like import/export for example). It's very much a different language, which is fine, but it is annoying to constantly hear "it's just JS with optional types".
Re:Angular 2 Style Guide by pfooti on Thursday May 05, 2016 @01:48PM (#11638247)
I use import / export in my regular javascript. I just use babel and browserify for it. I am sure that there are typescript language features that aren't "just optional types", but I don't think import / export is so far outside the normal ES/next kind of norm that you'd call it some kind of MSbomination.
Re:Angular 2 Style Guide by Touche on Friday May 06, 2016 @11:15AM (#11644518)
Babel is not "regular JavaScript", your import/export statements won't work when browsers and Node support them (you are required to include the .js extension and Babel doesn't enforce that). Babel also supports things like JSX and Flow.
Re:Angular 2 Style Guide by plexicle on Thursday May 05, 2016 @01:40PM (#11638183)
"both supporting actual Javascript (even JSX isn't necessary)."

Oh, come on now. If JSX isn't necessary, then neither is TypeScript. Have you tried writing React components without JSX? Angular2 in ES5 is saner.

I get that neither is ideal, but let's be real here.

Re:Angular 2 Style Guide by Roboprog on Thursday May 05, 2016 @10:46PM (#11641348)
I loved the way you could start with a static HTML mockup with Angular, then add the boilerplate in a single .js file, then define a simple data model in the js, slap in some curly braces and ng-model attributes hit "reload" and try it out, lather, rinse, repeat -- all without any build (transpile, concat) step.

Angular 2 looks like a JEE "inspired" nightmare.

Re:Angular 2 Style Guide by Roboprog on Thursday May 05, 2016 @11:11PM (#11641425)
Of course, by the time you get to event handlers and REST calls, you need a back end, but you could mock up an awful lot in 1.x without ever worrying about a "build".
Re:Angular 2 Style Guide by AshleyGrant on Thursday May 05, 2016 @02:21PM (#11638542)
"non standard syntax like decorators"????

decorators are a TC39 proposal from Yehuda Katz and Jonathan Turner...

Re:Angular 2 Style Guide by spriggan3 on Thursday May 05, 2016 @04:01PM (#11639250)
proposal =/= in the spec. Typescript used to have a module implementation that was not compatible with ES6 modules. Guess what happened for Typescript developers.
Re:Angular 2 Style Guide by Roboprog on Thursday May 05, 2016 @10:42PM (#11641328)
Remember GWT? We were all going to write client-side widgets in Java.

Turned out, that was a nuisance.

Re:Angular 2 Style Guide by paulddraper on Thursday May 05, 2016 @04:34PM (#11639468)
I'm using it with ES5 only.
Re:Angular 2 Style Guide by spriggan3 on Friday May 06, 2016 @11:37AM (#11644664)
Why don't you post some snippets or gists so that everybody can get a mesure of what a large app looks like with Angular 2 ? that's right, it is not designed to be used with ES5.
Re:Angular 2 Style Guide by paulddraper on Sunday May 08, 2016 @03:00AM (#11653003)
Well, the project is not open source :(
Re:Angular 2 Style Guide by Roboprog on Thursday May 05, 2016 @10:33PM (#11641297)
You should put up some examples on github and post a link.

TIA