Angular is Much Better, But is Angular Universal?

Jonathan Gamble - Nov 18 '23 - - Dev Community

Angular is Amazing in 2023!

Angular has recently added an amazing amount of features. It has become a real competition to React again. Signals are absolutely incredible, they are working on new hydration techniques, and the control flow syntax is freaking amazing.

THANK YOU ANGULAR TEAM!

Frankly, you were stagnant for years. It is good to see you are listening to all communities. The work you have done and continue to do is amazing, and the new surprises you gave us (like the new control structure syntax) have been superb.

BUT... and a BIG BUT...

Angular Universal is NOT ready for any real app IMHO.

Angular still does not understand why React has been so great over the years. In my opinion, it is two main reasons:

  1. Functions (vs Classes) - Creating Functions is extremely easy, and they don't require a lot of overhead. If programmers can use their brains on more important things, they can theoretically have more time to be creative and productive. Unfortunately though, as we know, easier means there is more room for crappy coders as well. Either way, there is another reason people switched away from Classes...

Tree Shaking!!!

Tree Shaking gets rid of dead code. This cannot be done with classes because it is almost impossible for a compiler to know which methods in a class are not being used etc. Nevertheless, in Angular, a good programmer could extrapolate their code in a good way so that Tree Shaking can still happen.

 2. NextJS (and Remix) - React meta frameworks have become so popular because they are easy to use on the server! Sure, File Based Routing is easy, but creating endpoints, server only code, mixing code, etc has become the norm.

Angular Universal

So that leaves Angular Universal. What does it need?

Let me ask you a question. Maybe I am ignorant on this fact. How would you connect to a database using Angular Universal? Angular Universal mixes the server code with the client code by if statements. You simply can't create a REST endpoint without manually hacking the server.ts file. This is not impossible, and works fine, but it is not built into the framework.

Server Actions

What Others are Doing

  • Server State Management
  • Server Actions
  • Streaming (Although I did see this on the Roadmap)
  • Server Components (like PHP)
  • File Based Routing
  • Automatic TransferState
  • Resumability
  • Hosting Adapters
  • Automatic Lazy Loading Techniques

(See my previous post for more on this list)

Analog

I could be wrong, but I think Brandon created AnalogJS to fulfil some of these needs. First it was just an experiment to use Vite, then it became File Based Routing, then SSR, then it was a full Meta Framework!

But... Analog doesn't even use Angular Universal. If Angular can do some of these things out of the box, it could really help the community.

What Angular Universal Really Needs

File-based routing is polarizing, Resumability is for a Qwik only technology, and Server Components are still being adopted. But you know what is a standard and already widely accepted?

  1. Rest Endpoints - We need the ability to create server side only code to do things like connect to a database. It needs to be built into the framework. It should share state through services to avoid prop drilling, and maybe even through sessions. I don't know what this would look like, but it needs to be the "Angular Way." Right now, you need to use a hack or external framework to do this. This is freakin important.
  2. Adapters - Google just wants to support Google Cloud it seems. Right now Angular Universal cannot run on any server that does not support Express. This means Deno and Bun are out. More importantly, Edge Computing is out.

Support these Github Issues with Up Votes:

I love what Angular is doing. As soon as ZoneJS is completely optional, I will probably build my next app with it. I'm just not sure Angular Universal is where it needs to be if you want to build a full stack app. Maybe we can get it there! I would like to see Angular's way of server development!

J

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .