Check out a free preview of the full Basics of Go course

The "Multi Platform & Common Use Cases" Lesson is part of the full, Basics of Go course featured in this preview video. Here's what you'd learn in this lesson:

Maximiliano explores the multi-platform capabilities of Go, highlighting its ability to generate executable binary files for various platforms and operating systems. The discussion further covers common use cases for Go, such as web services, DevOps, desktop UI, and machine learning.

Preview
Close

Transcript from the "Multi Platform & Common Use Cases" Lesson

[00:00:00]
>> Let's talk a little bit about multi-platform. So we mentioned that we are going for deployment, we're going to build an app, a binary file, okay? And for that, we can select different platforms and different operating systems. What's the difference between an OS and a platform? The platform typically is an architecture, can be the CPU.

[00:00:20]
For example, now we have on the Mac two different architectures. We have Intel based Max and we have ARM, like the M1 chip, the Apple Silicon chips, that it's a different architecture, the same OS but different architecture. And because we are not creating apps for a virtual machine, we are creating app for a platform, we need to pick both DOS and the architecture.

[00:00:47]
Also Go can compile to WebAssembly. Does anyone know what WebAssembly is? Have you ever heard about WebAssembly? No, WebAssembly is an ability of the web platform, so on browsers, talking about browsers, to execute native code that you can write from different languages such as Go. So today it's being used for, typically for games when you have games on the web for compression, decompression, cryptography.

[00:01:27]
It can also be used for cryptocurrencies if you wanna connect to a blockchain. All that stuff, it's better to write that in native code. Now, it's being used also for machine learning, deep learning. So artificial intelligence, if you want to run AI models, client-side, you can also do that with WebAssembly.

[00:01:47]
Meaning that, for example, if you want to do AI on the web today, most of the time you don't wanna do that directly with JavaScript you want to do that with a low-level language and then create a WebAssembly module also known as WASM. And Go can compile those modules that then you can execute in a web app from JavaScript.

[00:02:09]
I will update this because it's not transpire, it's transpile. So, it can even transpile to frontend JavaScript. Remember I mentioned that you can do frontend with Go? I don't know who will do that, actually. But, first, what's a transpilation? Actually, it takes one source code. And it converts that source code into another source code.

[00:02:37]
So for example, TypeScript takes TypeScript and the output of TypeScript is JavaScript. Well with Go, you can also write, Go and get JavaScript in as the output. It's not being used, okay? It was an experiment or something like that. There is a list and you have the link here.

[00:02:59]
You don't need to follow the link, but I just wanna show you. All the operating systems and architectures compatible with Go right now. So you will find a lot of operating systems freebsd, iOS, can you create iOS applications with Go? Well, yes and no. Let me explain what that means.

[00:03:21]
You can create a library of code that can be executed on that OS on that platform. But for creating the user interface to connect to the iOS SDK and actually talk to the, to the touch screen, it's not going to be available from Go. So it's more for creating a library or creating low level code that then can be linked from Swift on iOS.

[00:03:49]
Similar that to WebAssembly, when you create a module that then you need to link from JavaScript. Also Android is here. But it doesn't mean that you can create fully an application for Android in Go. It's more for libraries like it can be logic libraries, it can be something again, you're the new Netflix, and then you have your own video encoder and decoder while all the parts that encodes the video receives the bytes and the fan compress can be done in Go.

[00:04:20]
And then you can compile the iOS version, the Android version, the WebAssembly version for the web, and so on, okay? So here you have all the operating systems, and here all the architectures. So this has to do with the CPU. So amd, arm, mips, there are some mobile Android devices using mips, risks, and here is wasm.

[00:04:46]
So wasm, that's WebAssembly, is one architecture. So actually, from any computer, you can create binaries for each combination of OS and platform. So when you make a compilation, you need to pick your architecture and your operating system. By default, when you're building an app, it's using My Architecture and MyOS.

[00:05:11]
So I'm on a Mac with an Apple Silicon chip, it's going to create an executable for my Mac. But also for my Mac, I can create a .executable.exe for Windows. I won't be able to run it. But I will be able to create it, to build it. So I can build iOS, Android.

[00:05:33]
You can build Mac binary from Windows just by using the Go [INAUDIBLE] just by picking the architecture. So common use cases for Go, we want cover in this course, all the UC cases, but the language is just the same language. Web services, so you can create restful services or microservices to provide services to frontend.

[00:05:58]
The frontend can be a website, can be a mobile app, whatever. Web applications, so you can actually serve web application. You can actually create a web server directly Go. It's not common for everything for every website but for some situations, it's been used for some micro websites micro solutions is used for DevOps.

[00:06:20]
For creating dekstop apps, you can create desktop application like Windows or Mac applications that you open you have a window. It's not like the most common use case these days, but you can still use that for that. Machine learning, so Go is really fast for machine learning. Probably if you have get into AI and how to execute models and train models most of the time, we're talking about Python.

[00:06:44]
But Python is really slow, okay? So that's okay for learning and for initial part. But when you have really big models that you need to train or you need to execute, it's better to use Go or other languages, not Python, okay? And much more, because it's multipurpose. We will focus here on learning the fundamentals that then you can apply everywhere and then on web services and web applications.

[00:07:14]
So we'll focus on that. That is one of the most used use cases today.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now