Go or Angular as the web layer?

I am in the process to choose tools for a 3-tier web application. Limited knowledge of both Angular and Go, I have found at least two main ways to look at this:

1. The Angular way
Angular needs AFAIK a web server (nginx) to work. The upside is tons of modules that extends Angular. Dependencies both to other modules and correct version seems to be the downside.

nagp

2. The Go way
Go does not need a separate web server but could be used to create at website according to this this site

ggp

My questions are:

  1. Am I correct assuming that both will work?

  2. Any pros and cons with each way? Speed? Complexity? Maintainability?

  3. Any other tips creating a web application (Basically CRUD)?

Any input are welcome!

You can use Go as backend and Angular on the frontend. Why do you consider Go and Angular as separate ways? And of course using Go in backend you don’t need another web server.

Use Go as backend for endpoints, database operations and templates to serve web pages containing HTML, JS (with Angular code) and CSS. For making web services are tons of resources on the net.

2 Likes

As I am no expert, I consider Go used as frontend and Angular as frontend as two different paths. I am just curious if this is possible to use Go as frontend as well.

How should I interpret this? Using one layer Go for both frontend and rest? Or use separate layers? Or the Angular way?

The aim with the question was to figure out if the Go way is possible or / and benefits with each path…

You should interprete this as "just use go as your nginx.

My original question was about Go as frontend OR Angular as as frontend. Is it a good choice to also use Go as a frontend?

I didn’t work with, but i think is possible to use Go on frontend as WebAssembly.

Write in go your own web server and endpoints. Writing a web server is a very easy task in Go. Some endpoints can expose data some of them returns web pages coresponding to some templates. The web pages will contain HTML, CSS, JS and Angular code. Also with Angular $http you can easy call other enpoints from your program.

Not at all. Angular can be downloaded and included in your web project but also can be used online from cdn.

If you really want an honest advice then i will suggest you to use VUE.js over Angular for frontend and go for backend

3 Likes

Hi,

The simple answer is that yes, you can use either method. I’ve been trying out the Go WebAssembly support, and although it’s very new, it does work … with some caveats.

If you want to try it, my app is online already on my website: http://jayts.com/vp/

(I’ll have some directions for playing the game later, but for now you can just search for “video poker strategy” or the like if you are not familiar with this popular casino game. One thing I’ll say for now is that you can also play using the keyboard, and if you open Developer Tools, you can play the game in the debug console. keys A-I choose different variants of video poker. A manual page for the console version of the game is here: https://github.com/Yaoir/Go-VideoPoker.)

I’m working to get the source code together enough to publish on GitHub. I hope it will help other Go programmers learn about Go’s WebAssembly support and motivate them to try it.

I’m excited about Go and WebAssembly because now it’s possible to do both client- and server-side development (“full stack”) in Go, without writing a single line of JavaScript! And it’s clear that things will only improve (probably quickly) in the future. That’s really cool. But to be realistic, what we have right now is this:

JavaScript: It’s been around since the 1990s, every browser has a good JavaScript engine that can be counted on, and it’s a lot faster (due to compilation of JavaScript code) than it used to be. Virtually all of the documentation on DOM manipulation, event handlers, and such gives examples in JavaScript because for so long, that was the only way to do it. And over the past 2 decades, all sorts of frameworks and libraries have been written for JavaScript programmers, including Angular, Vue, React, and so on.

Go: WebAssembly support is only a couple of months old, and it’s documented like this:

This package is EXPERIMENTAL. Its current scope is only to allow tests to run, but not yet to provide a comprehensive API for users. It is exempt from the Go compatibility promise.

There are limited or no frameworks or libraries available, so it’s like being limited to just plain JavaScript. I’ve seen a few companies developing web apps in plain JavaScript (with no framework), but it is rare.

Having said that, I am really enjoying writing web apps in Go. It seems possible (although more complicated) to do anything with Go that can be done with JavaScript, and for anyone starting off developing a site right now, it would be a bold move to choose Go for both server-side and client-side programming. The whole project can be done in one language that’s far better than JavaScript in so many ways, and in the future, as WebAssembly develops, it could turn out to really pay off.

So it’s the usual situation that early adopters take risks, but if things work out, get the most rewards.

3 Likes

Should I interpret that WebAssembly is a Go compiler sort of? Like TypeScript compiles to JavaScript in Angular?

It’s the other way around. The Go compiler compiles Go code to WebAssembly.

WebAssembly is supplied to the web browser, which compiles it to native executable code.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.