Тёмный

A "simplified" approach to Angular components? 

Joshua Morony
Подписаться 74 тыс.
Просмотров 14 тыс.
50% 1

My Angular course: angularstart.com/
What if Angular provided a component authoring experience similar to that of Svelte or Vue? This is likely completely possible today, and Brandon Roberts has created a hypothetical prototype demonstrating what that might look like.
My previous video on AnalogJS: • Things are getting ser...
More on AnalogJS: analogjs.org/
Get weekly content and tips exclusive to my newsletter: mobirony.ck.page/4a331b9076
Want to build mobile apps with Angular?: ionicstart.com
0:00 Introduction
0:38 Comparison
1:17 Supplying metadata
1:33 Benefits
3:51 Thoughts?
#angular #analogjs
- More tutorials: modernangular.com
- Follow me on Twitter: / joshuamorony

Опубликовано:

 

11 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 177   
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
POLL: Please do not reply to this comment directly, post a new comment beginning with your pick and then any comments you want to make (e.g. "1 - stay away from my classes") 1) This format should NOT be pursued at all 2) This format should be pursued, but only as something OPTIONAL through AnalogJS 3) This format should be pursued, and it should eventually become the DEFAULT for Angular itself 4) I don't know/I'm not bothered either way
@Daranix
@Daranix 5 месяцев назад
2- I think it could be a good syntax to attract people who use Svelte or Vue.js, you feel that what is inside the script tags is "a single execution to define all the logic of my component" and the mind thinks more in working in a declarative and not so imperative way, but at the same time I think that having things like metadata that appear in a "magical" way can be confusing, I think that one of the main benefits of annotations is that that metadata can be typed , and without having to go to the documentation you can know what options you have to add to the metadata, something similar happens with lifecycle hooks. I have mixed feelings XD
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
@@Daranix there has been some progress in this regard already, instead of exporting metadata the currently implementation now uses a defineMetadata({}) call that has typing
@sulaimantriarjo8097
@sulaimantriarjo8097 5 месяцев назад
2 - this is way great, it brings back developer to vanillajs-like. But, I think it should only be in analogJS. because analogJS is metadata framework for angular that can consist backend as well (cmiiw). this way looks cleaner and simpler. But I wonder how about the implementation of life cycle hooks, services, etc in this style.
@georgivasilev3417
@georgivasilev3417 5 месяцев назад
2. especially if u are used to the old way of creating components. and lets be honest about it. most of the time you would use ng g c rather than creating it from 0 .
@AllanLange
@AllanLange 5 месяцев назад
2 - when first transitioning to Angular two and half year ago I found the amount of boilerplate and setup intimidating. I came from a company that used Aurelia and as I recall, it was a bit more simple than Angular, however not to the degree of this format. I definitely think this format would help the adoption of Angular to grow as it makes it a lot simpler.
@nahuelleiva8460
@nahuelleiva8460 5 месяцев назад
I would go for 2. I like the idea that Svelte/Vue and Angular devs can (potentially) have the possibility to switch from one framework to another without too many complications. This can improve Angular's learning process for new devs, I like this.
@joshuadc316
@joshuadc316 5 месяцев назад
2 - Keep my ts/js, css and html separate, I prefer it this way. It follows the principle I like best which is, each file has a single purpose or responsibility. This kind of clutters them together, which really bothers my OCD lol
@codearmadillo
@codearmadillo 5 месяцев назад
Well like in Vue, you could just import CSS. To be honest as an Angular developer, it just becomes cumbersome after some time
@ImperiumLibertas
@ImperiumLibertas 5 месяцев назад
One of the greatest benefits of Angular is the strict adherence to separation of concerns. The class based approach, specifically the component selector and component logic existing in a separate file from the template offers massive advantages while maintaining code. Trying to make Angular templates more like React/JSX isn't going to help developers. I see this as arguing that we need to make Angular similar to other frameworks/libraries to appeal to more people without any other major benefit. We can explore ways to reduce boilerplate code which seems to be the main concern without losing one of the greatest features of Angular. If you want Angular features in React, go add them to React. Don't try to change what Angular is at it's core just to make it more like other frameworks.
@Karamuto
@Karamuto 5 месяцев назад
I agree. I already hate it when style/template/typescript are not divided into different files.
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
This is one of the sentiments I strongly disagree on - the idea that Angular at it's core is about its ability to separate logic/template/styles into separate files. I get that being a feature people like (personally I use SFC in Angular anyway, and preference it partially for the DX of the authoring experience and partially because I think it encourages better architecture). But I don't think that is the key part of this proposal anyway - it's not the plan at the moment but technically the new proposal *could* allow for separating code type by file. If that were the case, would you still not like the idea?
@bullettime2808
@bullettime2808 5 месяцев назад
Completely disagree, separating UI and logic was common in the old MVC days but this is not how a component-based framework should behave. In component-based frameworks, UI is derived from the logic which makes them highly related and should be placed together
@ImperiumLibertas
@ImperiumLibertas 5 месяцев назад
@@bullettime2808 they are tightly coupled but not derived.
@ImperiumLibertas
@ImperiumLibertas 5 месяцев назад
@@JoshuaMorony I work in a large enterprise environment with dozens of teams working on a single project. It would be a nightmare to get some of the less experienced developers to adhere to a separation of concerns pattern.
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
In the 2 days since I filmed this video massive progress has already been made here (including some changes to what was shown in the video) - it looks like this format is likely going to be added to AnalogJS (still no guarantees), join the discussion here: github.com/analogjs/analog/discussions/824
@deefdragon
@deefdragon 5 месяцев назад
2. as someone who prefers seperation of responsibility, this looks like a terrible alternative, but I also respect people who prefer this style getting to try it out.
@darwinwatterson1732
@darwinwatterson1732 5 месяцев назад
I would go for 1. If AnalogJS is focusing on providing a better DX for new developers, I think new developers should start learning Angular by learning Angular, not AnalogJS. If you use AnalogJS is because you already know Angular (at least the basics) but I don’t think it is a good idea to start learning Angular using AnalogJS, because if you want to work as an Angular dev you need to know the Angular syntax, so eventually you will still need to learn the Angular syntax, so you will have to learn 2 different syntaxes, it is easier to learn first the Angular syntax, and then learn the AnalogJS syntax if you want for a personal project or something like that.
@DavidSchmidt07
@DavidSchmidt07 5 месяцев назад
3. I love angulars architecture and sveltes component authoring and this seems like combining both would be a big win IMO
@chaos_monster
@chaos_monster 5 месяцев назад
I would like to quote Jay "I don't hate the angular authoring format. I can see why some want it changed or think it can be improved (everything can be improved!), I am just focused on other things. On the list of things that slows us down (generally) the authoring doesn't even register." This fits perfectly
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
I don't disagree with Jay, but it's also not how I view the motivation for this. I see the main goal of this to make the framework more appealing/approachable/marketable to new devs, not improve the productivity of existing Angular devs (although personally I feel like I would be more productive with the new format, but that's a much more marginal kind of benefit)
@chaos_monster
@chaos_monster 5 месяцев назад
​@@JoshuaMorony "to make the framework more appealing/approachable/marketable to new devs" you are not the first one with this argument. And as long as I do not see evidence (I am data-driven guy, so representative surveys in this case - not my "friends agree with me") for this I don't think it holds IMHO. Many of the "we need to improve Angular" topics (like this) stem from exactly this argument, but again I wonder where that comes from
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
​@@chaos_monster I think getting good data on this would be difficult - I do think it stands to reason though If we consider the target audience existing FE devs, then I think it's reasonable to assume most would prefer the syntax that is the same as/similar to basically every other popular FE framework right now If we consider complete beginners, then I think it's reasonable to assume they will find the syntax that basically looks like basic HTML/CSS/JS more approachable versus needing to understand the role of the class and the concept of a decorator Even if we consider backend/Java devs which would be a prime candidate for preferring the class approach, I doubt they are going to be confused/intimidated by the Svelte style Then we also have anecdotally the discourse about Angular (outside of Angular devs) which often centres around it being old/legacy/complicated. I think the component authoring has a lot to do with that perception (and yes, I know "I think" statements are not hard data)
@chaos_monster
@chaos_monster 5 месяцев назад
​@@JoshuaMorony here is where I strongly disagree with your chain of arguments. First all your statements are assumption, and I get that getting good data is hard, but you ignore the reason some frameworks have chosen certain ways and ignores the fact of compilation totally. You ignore that not even the popular frameworks share a common approach (vue and others vs jsx based vs function based components and so on). So which one is the "right" one? Secondly the current authoring format has a HTML and a CSS file, let's be generous and consider the TS file a JS file, so your only "problem" is the decorator (which by compilation is actually an annotation) and the class approach. I do agree that we could improve the metadata annotation, maybe with conventions. But the argument against the class approach is kind of weird as the custom element (a native JS API) is exactly the same...
@antjones2281
@antjones2281 5 месяцев назад
1 - I don't see the improvement. As it is when I generate a component I get an html file which is just html and my ts file looks the same as your new ts file minus the template tag. I agree for sfc's writing raw html is better than having to use a template string though. but I prefer to keep my templates separate anyway.
@sajon_
@sajon_ 5 месяцев назад
I am going with 2. If people prefer it, then this will give them a way to use it, but for my personal preference I like the current way Angular keeps the template and style files separate by default. I always disliked how Vue and react has all their HTML and JS/TS and sometimes styles in the same file. I would really hate it if Angular goes this direction.
@BrandonRobertsDev
@BrandonRobertsDev 5 месяцев назад
What if Angular changed the default to be inline styles and template? Having separate files will always still be an option
@sajon_
@sajon_ 5 месяцев назад
@@BrandonRobertsDev Same, would hate it if that happens. Obviously I can setup a project with different files for templates if that is an option, the problem will come when working with others. I personally like that there is very little variability in project to project in Angular.
@pankudev
@pankudev 5 месяцев назад
I want to say 3, but I also love my separation of concerns. It's one of my favorite things of Angular.
@jaredwilliams8621
@jaredwilliams8621 5 месяцев назад
1. The separate template and js files are one of my favorite things about Angular. I also feel like Angular doesn't need to be looking at another dramatic shift how it does things. At work, my team juggles around a dozen smaller Angular apps. We don't have time to update to use the latest template syntax, or switch over to use the newest revolutionary Angular feature. Rather than chasing after the next shiny thing, I would really appreciate if Angular slowed down and focused on more incremental upgrades. I would love to see more focus on supporting more ways to serve and deploy Angular code (ie allow more versatility in where files can be hosted, or allow for angular components to be added to non-Angular pages). I feel that there is a lot more value in these behind the scenes features than trying to make Angular feel more like React.
@Netrole
@Netrole 5 месяцев назад
1 - The clear seperation of code into HTML/TS/CSS/Tests has always been one of the key strengths of angular in my view. It helps keep large projects organized and clean even with juniors and inexperienced devs on the team and under time pressure. React on the other hand is the exact opposite, html and JS are mixed together and it takes a lot of conscious effort to keep it clean as projects grow. Then throw in inexperienced devs and some time pressure, and you start getting absolute spagetthi. This isn't as bad as the chaos in React, but it is a step in this direction, and i see no benefit to it. It is a bit less boilerplate code, that is generated by scripts anyway, and it might look neat in these small demo components, or small components like single buttons or core UI elements. But for large layout controlling components i can't imagine this to work out well. You could argue to switch between the styles based on the type of component and limit this to small basic components, but at that point I'd rather be consistent across the board and use the same style for all components. Same reasoning as with the seperate HTML file for me. Might be overkill on small components with 15 lines of HTML, but i rather keep it consistent across the project and i want the seperation on big components
@kaydenmiller8156
@kaydenmiller8156 5 месяцев назад
4 - only because there isn't a 5, I would be fine for this to be an option within core angular I just don't think it should be the default behavior when creating a component. I think it is a much simpler syntax for when working with small components but with larger HTML blocks I would prefer working in a separate file.
@nicoscarpa
@nicoscarpa 5 месяцев назад
That's a nice idea to lower the barriers for new Angular developers and for semplifying the construction of simple apps. It would be interesting to see how a "real life" component would look like with this approach. Though, I do like the structure Angular "suggests" (impose) for building components, since it forces the developer to organize the code in clearly defined building blocks, hence promoting discipline (which is very important in large-scale projects). I think that the classical approach might still be preferable for enterprise/highly-complex applications, but I can see this new approach fit into some areas of a large-scale app or being used for fairly simple components.
@AbhinavKulshreshtha
@AbhinavKulshreshtha 5 месяцев назад
I would love the .ng file for creating simpler UI components. This kind of component file is reason why I loved vue and svelte over react.
@giniedp
@giniedp 5 месяцев назад
I'm going with 3. Love the ease of svelte and dependency injection of angular. Actually something in between 2 and 3. It may not be the default for angular but still an option within angular core.
@paulh6933
@paulh6933 5 месяцев назад
3, maybe this isn't the final iteration of the new format, but it is a good start. Changes have already been made for standalone (which should be the default and only opt out if needed), template syntax (if, else, defer). So the journey has already started into making ng part of the crowd, not something that sits by itself. Ng already has it's distinguishing features, syntax does not need to one of them. Also one last comment, by making it optional, all we do is making the code base bigger.
@MonaCodeLisa
@MonaCodeLisa 5 месяцев назад
2) This format should be pursued, but only as something OPTIONAL through AnalogJS For people that have not used Angular - yes this probably will be a cool improvement and might make it easier for them. For those of us that have been using Angular for a while - maybe chilling for a bit would be nicer, taking the time to get used to all the current changes before considering the addition of even more changes... Dynamic is cool, until it gets a bit too dynamic... There are still plenty of Angular developers adjusting to v16 and v17... The video is very nice :)
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
I appreciate the "can we just chill for a minute" sentiment lol - but any chance of this (or something similar) landing in Angular any time within the next year is slim to none imo. Still good to know if people want it to be in Angular itself, but for now if it's anywhere it's definitely just going to be AnalogJS
@drsunshine5615
@drsunshine5615 5 месяцев назад
@@JoshuaMorony Check out the latest post in the official Angular Blog about the Angular Developer Survey 2023 results. Looks like the Angular team will continue focusing on the component authoring format in 2024.
@MonaCodeLisa
@MonaCodeLisa 5 месяцев назад
@@JoshuaMorony thank you, good :) glad to hear, it does seem like a good idea - for later on :)
@RodrigoSalesSilva
@RodrigoSalesSilva 5 месяцев назад
1 - I considered option 2, but there isn't enough reason to pursue this approach. I genuinely don't see a 'problem' that needs solving or a real improvement by adopting this approach, apart from just introducing another way to accomplish the same task. This would undermine the goal of 'simplification' because new users would encounter 2 or 3 different methods to achieve the same outcome, making everything more complicated.
@paragateoslo
@paragateoslo 5 месяцев назад
For the simple example shown here i definately agree that a script tag and template below is better. However the component decorator has quite a lot of config options, like onPush changeDetection, multiple css imports, selector name etc. So for a better discussion on if just scripts tags are better, we would first need to see solutions on how these configs options would work.
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
At the moment for any metadata that does need to be supplied you make a defineMetadata call within the script section - e.g. defineMetadata({ selector: 'p[highlight]' })
@boris8983
@boris8983 5 месяцев назад
2 - I really struggle with this approach since the separation of CSS, HTML and TS (logic) is a huge DX improvement for me. Now imagine this new approach with tailwind and a really big and complex component -> 1000+ lines of horror incoming You mentioned in one of your videos about declarative code that it looks more complex at first in little projects but at a bigger scale it shines (and i totally agree). IMHO this looks cool for small components but a soon as things get bigger the DX gets worse.
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
I don't see this aspect as a problem though (I already use SFC currently with Angular) - to me if a component feels too large as a SFC it implies that the component is doing too much and would be a good candidate for breaking it down into smaller parts (e.g. if you had hundreds of lines of tailwind classes it's probably a good idea to break that thing up into one or more separate ui components)
@alexx855
@alexx855 5 месяцев назад
would love to see that!
@TomOliverTurtle
@TomOliverTurtle 5 месяцев назад
How do the lifecycle-hooks work with the script-tag approach?
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
Currently it supports supplying an onInit() and onDestroy() hook, and you can also import things like afterRender/afterNextRender as normal - I believe the view with this approach is that everything else becomes unnecessary with signals
@artyomnomnom
@artyomnomnom 5 месяцев назад
Going with 3. I have a huge expecrience with Svelte and Vue and I really like the format.
@Kanexxable
@Kanexxable 5 месяцев назад
I'm pro 3). SFC's make it easier to do do compilation then classes do. It could lead to the point where people never have to do double imports ( Which is one of the great burdens of using the framework ). People don't have to be good OOP users to use the framework they can structure their logic the way they want.
@sebuzz17
@sebuzz17 5 месяцев назад
4 - I'm used to the Angular class declaration thing, it has become natural but I really love the simplicity of Svelte so either way I'd be ok with it. Now as you said, it's more about the new devs so I guess the Svelte-type experience would be a plus.
@peased22
@peased22 5 месяцев назад
2 - while I’m not huge on too much logic and template code in 1 file, this forces moving logic into services which is architecturally proper in my opinion but hated by some. Also being able to use effect outside a constructor feels so much cleaner this way. You’ve convinced me I’m trying it tonight
@WanderingCrow
@WanderingCrow 5 месяцев назад
2 - I thought about 3, but I think making it optional would avoid frictions with people really against it. But I definitely like such approach, which resonate more with me, as I've known the early structure of web pages (which is why Svelte and Vue tend to appeal to me too)
@elcocodriloazul
@elcocodriloazul 5 месяцев назад
If you are going to do this, you may as well switch to javascript/react.. 3:35 My biggest worry is CSS...is it going to be separated in a file or mixed with the code...It could be an improvement if the separation of CSS is achieved. An example of another method also within the code? Also why put "script" open and close tags. Not needed extras me think...I want to see several methods and how they get called and how the CSS is separated. I am all for improvement....
@aravindmuthu5748
@aravindmuthu5748 5 месяцев назад
vue or svelte, react is different
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
I have seen this a lot, but I really don't see why people say it (that a change like this would basically turn Angular into React/Svelte/Vue/etc). Let's assume Svelte/Vue instead since this format more closely resembles that, but even so the particular approach to component authoring is such a tiny fraction of what the framework provides overall. This change would make Angular like 1% more like Svelte/Vue.
@lukebennett3189
@lukebennett3189 5 месяцев назад
@@JoshuaMoronyfrom my perspective this seems like change for the sake of change, but I’m also a lover of OOP so I quite like the current syntax as it more closely fits the mental model I have around c# which is my preferred language. All the new improvements are nice but if this were to become the new default for angular then there is going to be a lot of waste / rework needed on older angular applications if all new devs only learn this “simplified” style
@ImperiumLibertas
@ImperiumLibertas 5 месяцев назад
​@@JoshuaMorony if you don't see why people say it then you need to look further into what makes Angular, Angular and why it's better/different from other frameworks. Changing something for the sole benefit of being similar to other things isn't a virtue. Angular components are superior because they offer something the others don't; separation of concerns.
@ImperiumLibertas
@ImperiumLibertas 5 месяцев назад
I love that you mentioned CSS. I've had conversations with developers in the past about HTML/CSS/JS and why each are separated into their own units. It's not just a language consideration since HTML can embed all of them. Separating the functional, view, and style code into their own parts defines clear responsibilities for each which is exactly what the components/template approach provides in Angular. It is the primary reason I dislike JSX based libraries like React. It's already difficult enough to try to get engineers in an enterprise setting to put code in the appropriate places let alone having everything share a single file.
@Edgars82
@Edgars82 5 месяцев назад
I don't like it. 1. Use schemantics to generate whatever you need and you don't have to write boilerplate on your own. 2. I prefer template(html) and ts(all the logic) file to be separate files.
@user-dq3zg6or2n
@user-dq3zg6or2n 5 месяцев назад
Yes I'm with it. It is a welcome development. Much more intuitive with regards to new learners.
@djbeallable
@djbeallable 5 месяцев назад
3 - I always liked/envied this approach in Vue and Svelte
@habibhadi
@habibhadi 5 месяцев назад
Main reason why I use angular because of separation of concerns which means html, styles and logics are in separate files. Also, class based component allows implement oop as well. This code looks like just react, vue. I have no hatred against them but I think only angular allows developers to use several design principles. They should keep it that way.
@xingfucoder2627
@xingfucoder2627 5 месяцев назад
I would like to maintain both options and only the 2) option OPTIONAL with AnalogJS. But seems like another framework is trying to remove TypeScript ???? And Joshua, what is your opinion about the standard we should follow to test this kind of new approach?
@CodeZakk
@CodeZakk 5 месяцев назад
Also in the .ts file you can't use angular service extension in vscode which leads to not knowing how to interpret html auto complete on the .ts file of angular.that's why i don't use analogjs. May be the .ng file will solve this problem❤?
@tanishqmanuja
@tanishqmanuja 5 месяцев назад
3 - Feeling excited about this much simpler syntax. But this should happen only after all the API's become functional (inputs etc etc) and Zoneless is introduced.
@jhadesdev9576
@jhadesdev9576 5 месяцев назад
I hope this goes forward, and hope that there will eventually be a CLI migration go convert to this format.
@blanktenshii_9554
@blanktenshii_9554 5 месяцев назад
I don't really like mixing HTML and logic in a single file, it makes it harder to read and maintain both
@JPeetjuh
@JPeetjuh 5 месяцев назад
I like the new syntax, but the one thing that stops me from being thrilled about it is UNIT TESTING. With Svelte, it's cumbersome *at best* to unit test components. Most articles/videos demonstrate unit testing by rendering the DOM, which is not UNIT testing. I want to call functions directly on my component. If this new Angular syntax supports this, then let's go. Until that time, I'm a class-syntax fan.
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
I don't think this will change anything in this regard - would need confirmation on that but this format works by converting the contents of the .ng file to a normal Angular component, so I assume you could just "import MyComponent from './wherever'" in your test and do whatever you usually do
@TayambaMwanza
@TayambaMwanza 5 месяцев назад
Can you put 5, that the Angular tean adopts it as an optional format, its a pipe dream but good to know the sentiment.
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
I wanted to avoid too many option, my thinking here was that the "optional" approach is through AnalogJS i.e. that if you want to use this approach you use AnalogJS, whereas Angular remains as is. Hypothetically (big hypothetically lol) if the Angular team did adopt this, I think it would go like everything else we have seen recently - it will be optional since that is how the Angular team approaches backward compatibility, but it would probably become the default (otherwise they probably wouldn't pursue it in the first place)
@toxaq
@toxaq 5 месяцев назад
I’ve always appreciated the separation of concerns of the angular way. I think having two ways to do things is more confusing than beneficial. I appreciate the “new dev” argument but in the time of AI writing code and talk of needing less developers, is lower the barrier to entry down that low a net gain for the industry?
@Maestro14Maiya
@Maestro14Maiya 5 месяцев назад
I will go with option 2. The current angular implementation is fine
@DerHerrGammler
@DerHerrGammler 5 месяцев назад
2 - I think it could be, as you already mentioned, a good starting point for new angular devs but I also think that its only veryn good usable for simple components. If you start writing bigger componnents where I like to also plit them up in ts/html/scss file I prefer the original Angular way of keep things in their own files. But when it is ready to use in analogjs at some point I will try it out to get a better image if how it looks and feels to write components in that way
@JakeArefyev
@JakeArefyev 5 месяцев назад
polymer is resurrected?
@alexpablo90
@alexpablo90 5 месяцев назад
4. I don't have a defined idea. I think is good for new devs and it becames easier for them but, maybe it'll lost the kind of 'structure'(not sure if it ttge best word). Also, having two different ways could be more complicated to migrate and keep it in a medium/long time. Summary: I need more info and experience with it. Great video 👍
@fahadgaliwango4502
@fahadgaliwango4502 5 месяцев назад
5) optional to angular
@adambickford8720
@adambickford8720 5 месяцев назад
I already code in java so angular becoming a 'late to the party w/a jankier offering than everyone else' framework feels poetic if not pre-ordained.
@Justjames283
@Justjames283 5 месяцев назад
3) I don't know about becoming the default in Angular but class based and this new format should both be supported in Angular core
@RaniLink
@RaniLink 5 месяцев назад
Discarding separation of concerns just so that some beginners could feel a bit less "intimidated" is crazy to me
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
I don't think that is the key aspect here (and personally I don't view separation of code by type to be the same thing as separation of concerns) because technically this approach *could* allow for multiple files. If that were the case, is there anything else about the existing approach you prefer?
@jerrytab4276
@jerrytab4276 5 месяцев назад
Angular just got really renaissance and now is the new Vue/Svelte 😂
@darthvader4899
@darthvader4899 5 месяцев назад
Like svelte?
@marflage
@marflage 5 месяцев назад
I would go for option 4. In my opinion, if there is a way to achieve separation of concerns by utilizing separate files for each responsibility then this syntax is the way to go. However, if separate file creation can not be achieved with this syntax, then this should not be introduced at all. I need more information on this. If the code for any of the .html, .ts, .css files increases, maintainability will become very difficult. Scalability is a real issue and should be accounted for every time a change is proposed. SFCs are already possible because of the meta data in the decorators. I believe the Angular team should focus on reducing the TypeScript code required for creating a component rather than merging the .ts, .html, and .css files' code. I do like the simpler syntax, but I can see the its limitations.
@Oelpfanne
@Oelpfanne 5 месяцев назад
Back to html-javascript/typescript-mix again :D
@tofraley
@tofraley 4 месяца назад
I've never really understood or agreed that the html, css and ts parts of a component can each constitute a single-responsibility. I feel like that's a hold-over from MVC frameworks (that often keep them in separate folders, yuck!). It's all a component. It's tightly coupled. I see two major downsides to keeping them separate: - It makes working on the component more of a hassle. - It low-key encourages devs to make bigger components that, ironically, have more than a single-responsibility. It seems to me like you should start with everything in a single file, and only move to multiple files if it gets too big and you can't justify splitting the component in some way. I strongly lean towards 3, but more options is good in this case, so I'll say 2.
@michaelsmall97
@michaelsmall97 5 месяцев назад
2. Seems like a nice option for smaller components.
@endlacer
@endlacer 5 месяцев назад
mh tbh, does anybody really write their components themselves? I only use cli commands for generating components services ect
@spencereaston8292
@spencereaston8292 5 месяцев назад
But I already learned how to do it the hard way...
@neociber24
@neociber24 5 месяцев назад
So don't change much to do it in a simplier way
@mfpears
@mfpears 5 месяцев назад
I'd like Astro-like syntax. Just separate them with a `---`. No need for indents
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
Interesting thought - haven't considered that, but my initial reaction is that I like it. It seems more "honest" in a sense (e.g. the script tag isn't serving an actual function in the end result). One argument I do find convincing about having a tag though is the potential to use it to specify other formats (e.g. ) - not sure if Astro or others have a convention for that sort of thing. Another potential though is using a separate naming convention for markdown (e.g. .ngx instead of .ng) Anyway, probably worth raising in the GitHub discussion if you're interested.
@lucaslevandoski2946
@lucaslevandoski2946 5 месяцев назад
that is just jsx with extra...
@yexiaorain
@yexiaorain 5 месяцев назад
Definitely 2. As someone who has spent some time writing .vue, for really less code writing it in one file is going to be cleaner, but can actually lead to disaster, most notably when used alongside git, and when using search text. And for the syntax of whether or not it's a class, preferring brevity, the experience of just writing 'this' would be poor, but it should be noted that if you go for brevity to 'make new concepts' is something that should be stopped, as in the case of react there are still all sorts of newbies who will be triggering multiple times by 2023 only needing to trigger code that triggers once. I don't want angular to have "problems that don't occur in other frameworks".
@boian-inavov
@boian-inavov 5 месяцев назад
Imo (3) is the most valid. As you mentioned it strips down the massive barrier to entry for newer devs, as until this point Angular has seemed as the big and chunky framework only enterprise uses, which shouldn’t be the case. I love the revival that it has had over the past few years and I hope that it can be brought back in alignment with all the rest modern front end frameworks. Funnily enough, this also means that Svelte was right all along 😅
@ImperiumLibertas
@ImperiumLibertas 5 месяцев назад
Why should Angular strive to be like other languages? Why can't Angular be it's own thing especially if there are benefits like clear separation of concerns when using the separate tempalte/component?
@radvilardian740
@radvilardian740 5 месяцев назад
so 'metadata' becomes a reserved keyword ? please try again..
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
Current implementation uses 'defineMetadata()' now
@sircharlesross537
@sircharlesross537 5 месяцев назад
Everyone here’s like “segregate my ts/html files, I don’t want no filthy file mixing!”, I say do it. It will allow us to compound the view and logic into one easily portable file that can be used when we need small components with only a few lines of code. Like, do we really need four files and a whole-ass folder for a footer component? Can’t we just leave the .ng and testing file?
@attoumak
@attoumak 5 месяцев назад
I hope to never see something like this happening! Someone can create another framework for this approach but not transforming angular !
@returncode0000
@returncode0000 5 месяцев назад
#2 because I need a framework which has no additional burden build in like React/Next.js. Keep AnalogJS seperately. There really is a need for clarity in the Angular landscape were companies can rely on. Look what happened to React/Next.js, you meanwhile need npx create-vite to build a pure client side React app without Next.js. In my opinion the Angular product team currently creates Angular 3 and all the discussions (e.g. functional vs OO) are really annoying. There is a big Java/Spring/Spring Boot community who are feeling very familiar with all the existing concepts in Angular (DI, OO, classes, decorators etc.), this community should be the target for new Angular developers. Keep things seperated. Angular 2.5 is ok but I don't need a completely new framework. Developers should choose Svelte/SvelteKit, there is no need to jump on this boat if there already exists a framework/library who has basically that kind of syntax.
@sebastianpaduch2527
@sebastianpaduch2527 5 месяцев назад
I believe that option 3 is the most valid choice, but retaining the possibility of splitting components into styles/template/logic could still be beneficial. In my opinion, the class approach tends to create more confusion than clarity.
@otonielguajardo
@otonielguajardo 5 месяцев назад
3. Everything Angular has being doing is perfect, and this component authoring strategy is the missing piece
@AmrouBouaziz
@AmrouBouaziz 5 месяцев назад
2 it should be an optional feature.
@StephenRayner
@StephenRayner 5 месяцев назад
I hate single file components, hate it. Forces me down a design pattern path which doesn’t help but hinders.
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
How would you feel about this proposal if it also allowed for separating code by type?
@o_glethorpe
@o_glethorpe 5 месяцев назад
angular is used considerably more in companies with large projects, business like projects, lots of cruds, etc... why is that? its because the way things get organized. every time they push something to look more like svelte, react, they will not bring more people, they will lose the user base
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
I've seen comments similar to this, e.g that the class/decorator approach is more organised, but what organisation would you be losing here (unless you are using OOP features for components which isn't particularly common)? In my view, all the big reasons why Angular is great at scale are still there with this format.
@o_glethorpe
@o_glethorpe 5 месяцев назад
Hi, thank you for responding, this is one more "feature" in a pool of features that imo is not good for angular, like for instance, single components, what are your experience using it so far? for me is not doing so great, the tooling is very bad, is like, every time, the intent was I imagine, was to apply the experience when creating a component in react, but is far inferior to tsx. I dont know man, I liked angular because of the "mvc" approach. I know I still can do the "old" ways, but it is clear that sooner or latter that will end. @@JoshuaMorony
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
​@@o_glethorpe not sure if you mean single file components or standalone components but either way I like/prefer both of those - the aspect of being averse to adding more things/options I can understand. Personally, I'm glad Angular is adding all of the things it has been adding, but as well as they have addressed backward compatibility there is no getting around the fact that having multiple ways to do things is awkward/confusing. If that is the objection I can understand that, but for the sake of argument what if we switch the situation - say we already have the Svelte/Vue style and there is a proposal to switch to the class/decorator style. In this scenario, do you want to stick with the Svelte/Vue style to avoid adding in more options/features? or is there some specific benefit that the class/decorator approach provides that you want?
@o_glethorpe
@o_glethorpe 5 месяцев назад
I would like that a framework would not change the way you should use it, particularly when is soo far from the way it was supposed to be used when it was conceived. If it was the other way around like you pointed out, I'd still think it is a mistake. I guess time will tell. @@JoshuaMorony
@altaron
@altaron 5 месяцев назад
It's amazing how often my brain stumbles over your line numbers. I routinely stop following whatever you are narrating while my brain tries to understand your line numbers until it eventuelly goes "Oh yeah, they are relative to the current line which keeps its original line number. got it. is that at all useful?" and then it's off on its own tangent pondering (and so far failing to find any) possible benefits. Why do you use that? What are the benefits?
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
haha I can see that being distracting - its for jumping around with vim motions, so if I want to jump to a specific point I can easily see that it is 10 lines up from where I am currently so I can just type "10k" to move there (which just feels a bit better to me than hitting say ":68")
@altaron
@altaron 5 месяцев назад
@@JoshuaMorony ah of course, with vim (bindings) it makes a lot more sense. Thanks for clarifying!
@zero14111990
@zero14111990 5 месяцев назад
2) This format should be pursued, but only as something OPTIONAL through AnalogJS. angular need to be angular. yes some times can be dificult to learm the syntax but this is how TS work. change the syntax will be a hard hit to the people. learn from scratch in a framework isnt good. the people need to learn the basics of the lenguaje before to start learning a framework.
@koles32
@koles32 5 месяцев назад
According to the heresy Josh says in the last videos, this is goning to be react channel very soon and i dont like that
@dimitrisdrosos245
@dimitrisdrosos245 4 месяца назад
3. Less boilerplate.
@chaos_monster
@chaos_monster 5 месяцев назад
2:50 your example is (on purpose?) overly complicated, as it fully ignores the CLI and instead of saying a component contains a ts file a html file and a css file you make it sound complicated
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
I've picked a scenario (yes on purpose because I'm trying to highlight where I think this is particularly relevant) where describing what is happening is awkward/complicated. In this sort of scenario (some kind of live coding demo/podcast interview/whatever introducing the framework) the component would typically be built out from scratch instead of using the CLI to generate it. Even if the CLI was used and you are just explaining what is happening in the .ts file its still more complicated than the alternative imo
@NoName-1337
@NoName-1337 5 месяцев назад
This would be very nice if Angular would implement it. Would love it. (Yes, i know, its like svelte. BUT, why shoulden't we implement such a low boilerplate code-style?)
@ImperiumLibertas
@ImperiumLibertas 5 месяцев назад
If we can lower the boiler plate while keeping the separation of concerns that would be great but this approach ruins that. Think it's difficult to explain that view goes in one file component goes into another? Now please explain that view and component logic need to be separate but in the same file. God what a nightmare managing templates would become when a junior dev writes a component with everything directly coupled.
@NoName-1337
@NoName-1337 5 месяцев назад
@@ImperiumLibertas For this: You could just put the content into one file (without the script-tag), the content into the style file (without the style-tag) and the rest into the template file. Would work, in my opinion. And the relation can be determined by the filename (like in the current state of angular). We could have some default configuration for changedetection and so on, so we do not need to add this option to every component. There are many thinks, which could lead to less boilerplate code.
@tibsou
@tibsou 5 месяцев назад
1) This format should NOT be pursued at all Not to mention the separation of concerns (which is already critical), the Angular framework has always been highly opinionated. There's generally an Angular way of coding things, and every Angular developer is capable of quickly adapting to any Angular project since they'll be familiar with common practices (which is particularly appreciated by large companies). It's for this very reason that NestJS is gaining in popularity among Angular developers for the backend. I don't understand why we need to change this way of doing things if it's just to conform to competing frontend frameworks. The concepts of classes and decorators are basic in programming, and if they scare young developers, it seems to me very worrying about their motivations, especially as this framework is generally chosen for complex business projects. Angular has already evolved a lot recently (standalone components, signals, new control flow...) and there's still a lot of work to be done to modernize it, but this proposal seems counterproductive to me. By the way, how can this component be used in another standalone component if it doesn't export any class?
@michaelrentmeister7693
@michaelrentmeister7693 5 месяцев назад
I had the same thoughts as well about using the components within other components..
@bartekaszczuk5201
@bartekaszczuk5201 5 месяцев назад
I don't see the improvement, quite the opposite. Now code is nicely separated from each other. One file is responsible for html and second for component logic - single responsibility principle. With this new approach everything would be in one cauldron.
@ImperiumLibertas
@ImperiumLibertas 5 месяцев назад
I think we should go one step forward. We need to remove the separation of html, css, and js. Why not? Less boiler plate. We can have everything in html anyway. It's simpler and therefor better right?
@martinlesko1521
@martinlesko1521 5 месяцев назад
You can do separation of concerns in Vue component too. You can import CSS and JS in and tags using src="" attribute
@bullettime2808
@bullettime2808 5 месяцев назад
Angular is a poor example of Single Responsibility Principle, in a component based framework the HTML and Logic are highly related and should be together, in component based frameworks the Single Responsibility Principle is applied to the components, React, Flutter, Swift UI and others did it right
@mfpears
@mfpears 5 месяцев назад
HTML and JavaScript are not separate responsibilities/concerns.
@darkopz
@darkopz 5 месяцев назад
It depends on the use cases. There are quite a number of cases where this would simplify things greatly. Overused and abused it can make the code harder to follow.
@niklasravnsborg
@niklasravnsborg 5 месяцев назад
2 - but maybe Angular could even provide support for JSX/TSX. This would be the most ergonomic development experience in my opinion.
@mac.ignacio
@mac.ignacio 5 месяцев назад
Let me make this clear. There are many new junior devs that more focus on the syntax than learning how things works. Those devs will soon realize DX is only 1% of the problem when it comes to software development. 99% of your will be going on problem solving, reading docs and managing existing code.
@lokukkendare3641
@lokukkendare3641 5 месяцев назад
3, standalone components would be great but the syntax is trash in my opinion and something like this would definitely improve the dev experience.
@TheSqdf
@TheSqdf 5 месяцев назад
2
5 месяцев назад
3.)
@ToJak91
@ToJak91 5 месяцев назад
Please tell me, why is it that people hate `this` ? I truly loves it, as it is a clear indication that something is related to my current scope, without being in my scope. Without this, it can either be in my current scope, which i should be able to find very easily, or it can be ANYWHERE in a globally exported field/function.
@user-ey2sw8wx7e
@user-ey2sw8wx7e 5 месяцев назад
1) split code, html, css is much better way.
@PauloSantos-yu1tn
@PauloSantos-yu1tn 5 месяцев назад
Why people want to remove something that gives structure and good code? Angular always was an enterprise solution, if someone wants to use something from almost no knowledge, use a simpler tool. To me this is not an improvement. When angular removes the class components i will switch to another tool, a modern one.
@additionaddict5524
@additionaddict5524 5 месяцев назад
I get kind of annoyed how every time someone explores these ideas the there's a small but vocal group bashing the idea of exploring this in the first place
@Dorchwoods
@Dorchwoods 5 месяцев назад
#3. This new format is SO MUCH BETTER. They really should strive to make that the default. Although I feel like there would be a lot of breaking changes potentially, and the upgrade path could be rough
@3pleFly
@3pleFly 5 месяцев назад
This format should NOT be pursued at all. I've seen how messy vue can look and it's not pretty. I think the class approach is the most organized
@JoshuaMorony
@JoshuaMorony 5 месяцев назад
In what way is it more organised?
@user-yv5vw8wc8q
@user-yv5vw8wc8q 5 месяцев назад
1) This format should NOT be pursued at all I don't feel Angular's class-based components are really a problem, especially now the standalone APIs have reduced the need for module boilerplate. It's not that I dislike the hypothetical format - it's just that I don't see the value in changing it. And I definitely don't think it's worth the effort to make everyone migrate from one to the other.
@adambickford8720
@adambickford8720 5 месяцев назад
We're already trending back towards PHP, why not jQuery too?
@g-luu
@g-luu 5 месяцев назад
3.
@knuppelwuppel
@knuppelwuppel 5 месяцев назад
i mean..sure wh not :D not a game changer imo
@coolguy0
@coolguy0 5 месяцев назад
3
@VinitNeogi
@VinitNeogi 5 месяцев назад
3) This format should be pursued, and it should eventually become the DEFAULT for Angular itself
@tomasbird
@tomasbird 5 месяцев назад
3 - let's get rid of classes all together, everytime I think about using inheritance with angular i end up shooting myself in the foot anyway
@John69
@John69 5 месяцев назад
It will look like Vue - like shit
@porcinetdu6944
@porcinetdu6944 5 месяцев назад
1) completely useless in my opinion. Angular should stay with classes
Далее