Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you create front end in Golang? and other questions [closed]

I started learning programming sometime ago and started with HTML & CSS, finally mastered both of them, now I started using Javascript and learning Javascript. In my learning path I came across Node.js a runtime environment for javascript which basically allows me to have my Html , Css and Javascript into the Node.js environment. Translate to react native and finish coding the whole thing and have a working Web, iOS and Android app. (Haven't done this yet but this is my small understanding about how all this works)

Today I stumbled across Golang...

Loved how simple Golang looks and how easier it is to read than Javascript. I read the differences and similarities , also some tutorials. Now for you Golangers (Gophers?) I have multiple questions.

If I make my app in Golang how do I do the front end? Do I implement html and css? Do I do something else as a visual editor (like Adobe XD as a banal example) ? Do I use React to create the iOS,Android app? Can I use mongoDB(I assume yes as mongoldb was done on Golang, but I still rather ask)?

How does the typical steps in creating an application look like in go?

(Example as with Nodejs web app) 1.Create an Html and CSS UI 2.Add javascript for functionality of the app 3.run on node 4.import into React for iOS and Javascript 5.finish app and deploy

Thank you very much in advance! Golang community seems like a much nicer community than Nodejs community in my opinion.

Ps. Should I drop learning javascript and completely switch to Golang or finish learning Javascript and then learn Golang?

like image 279
Juan Pablo Gaviria Avatar asked Feb 08 '20 18:02

Juan Pablo Gaviria


People also ask

Can Golang be used for front-end?

Golang is used for the frontend and backend development of applications. The frameworks make it quite easy to develop apps in a short period.

Is Golang a frontend language?

Becoming Go Go, also called Golang, is an open source, statically typed, compiled, cross-platform, and lightning fast programming language first introduced by Google in 2009. Go is multi-purpose, it is a good language for backend development.


2 Answers

If I make my app in Golang how do I do the front end?

I would create the front end using React (note that this is different from React Native) and then use Go as your back-end to serve up this React app. You could then also port the front-end to React Native in order to have it on iOS and Android.

I have also recently discovered Go and enjoy it, which is why I'd recommend using Go as the back-end and serving up the React front-end.

Another note on the front end, if you are making it in React I strongly recommend using Create React App - this takes all of the hard work out of configuration, makes it super easy to develop (in development mode it auto-updates the app when you save any changes to source files - super fast). Create React App also then outputs a simple bundle of files which you can then easily serve up with a Go or Node.js or any other back-end.

Hope this helps.

like image 150
calarin Avatar answered Oct 22 '22 15:10

calarin


Front-end needs to be written in JavaScript (and HTML and CSS), there is usually no way around it. The only way you can possibly run Go in the front-end is if you manage to somehow compile Go to JavaScript(or a compilation stack that compiles Go to WASM). I know it's possible to compile C, C++, Rust and C# to JavaScript.

Edit: It's indeed possible to compile Go into JavaScript: https://github.com/gopherjs/gopherjs

like image 44
FlatAssembler Avatar answered Oct 22 '22 17:10

FlatAssembler