到目前为止,我们已经讨论了几种编程语言(programming languages),但到目前为止,Go编程语言或Golang还没有进入讨论范围。是的,它不是最常用的语言,但它越来越受欢迎,尽管速度很慢。
Go 很有可能会大受欢迎,因为Google在许多领域都在大力推动它,但它也有其缺点,因此除非这些问题得到纠正,否则它可能不会获得非常强大的追随者。一些最常用的。
谷歌 Go 编程语言
你听说过过程式编程吗?Google Go就是其中一种语言。它由Google工程师Robert Griesemer、Rob Pike和Ken Thompson于 2007 年创建,然而,它于 2009 年推出并开源。
Golang背后的主要思想之一是易于学习和使用。此外(Furthermore),开发人员阅读该语言应该没有问题。现在,与 C++ 不同,我们知道 Go 没有大的功能集,这对某些人来说可能是个问题。
在语法上,Go 与 C 非常相似,所以如果你是一名长期的 C 开发人员,那么通过 Go 创建内容应该是轻而易举的事。尽管如此,我们应该注意到它的许多特性都可以追溯到诸如Erlang之类的语言,它已经存在了 34 年。毫无疑问,我们将在未来的一集中讨论它。
此外,很多没有 Go 经验的人不知道它与Java有很多共同之处,这就是为什么Google一直试图在服务器端 Web 应用程序领域积极推动它的原因。Java至高无上的空间。
Google Go 是跨平台的吗?
如果要成功,跨平台对于所有编程语言都非常重要。值得庆幸的是,我们可以肯定地说 Go 可以在Windows、Linux、Unix、BSD和移动设备上使用。就目前而言,无论您使用哪种操作系统,在 Go 中执行代码都应该没有什么问题。
阅读(Read):什么是用于 Web 开发的 Angular JavaScript 框架(What is Angular JavaScript Framework for web development)?
虫子呢?
Golang的一个令人印象深刻的事情是代码中的 bug 不容易出现。您会看到,它依赖于强类型化,这意味着开发人员在编写代码时必须专心且准确,以确保其安全。
如果所有编程语言都保持这样就好了,但事实并非如此。然而,事情正在向好的方向发展。
使用 Google Go 的缺点
虽然我们可以同意 Go 是一个令人印象深刻的工具,但它也有其缺点。你看,这门语言很容易掌握和学习,这是一件好事。然而,对于一些程序员来说,它过于简单,与类似的工具相比,这使得它没有那么通用。
我们不喜欢 Go 的另一件事是它不支持虚拟机。为了简单起见,谷歌(Google)的人们有意识地选择了这一点。由于这个决定,Go 文件的大小通常比竞争服务大。更不用说,Go 会像万圣节(Halloween)吃糖果的孩子一样吃掉你的RAM。
最后,如果你是泛型的粉丝,那么你很不走运,因为 Go 不支持这些东西。对此进行了很多讨论,但到目前为止,这方面还没有发生任何事情。
Google Go 编码示例
像所有其他人一样,我们将专注于运行Hello World!因为这是标准,似乎。
好的,所以首先你必须创建一个名为studyGo的文件夹。在这个文件夹中,将创建我们的Hello World!程序。
接下来,创建一个名为 first.go 的文件,然后将以下代码添加到该文件中:
package main
import ("fmt")
func main() {
fmt.Println("Hello World! This is my first Go program\n")
}
在您的终端中,导航到该文件夹,然后运行以下命令:
go run first.go
您现在应该看到以下输出:
Hello World! This is my first Go program
就是这样。现在继续增加你的知识。
What is Google Go Programming Language - Requirements, FAQ
So far, we have talked about several programming languages, but until now, Go Programming Language, or Golang, has yet to fall into the discussion. Yes, it is not the most used of the languages, but it is growing in popularity, albeit slowly.
There is a good chance Go might catch on a great deal as Google is pushing it aggressively in many areas, but it has its downsides so unless these problems are rectified, then there is a chance it might not garner a very strong following when compared to some of the most used.
Google Go Programming Language
Have you ever heard of procedural programming? Google Go is one of those languages. It was created by Google engineers, Robert Griesemer, Rob Pike, and Ken Thompson back in 2007, however, it was launched in 2009 and made open-source.
One of the main ideas behind Golang is for it to be easy to learn, and simple to use. Furthermore, developers should have no problem reading the language. Now, unlike the likes of C++, we understand that Go does not have a large feature-set, which might be a problem for some.
In its syntax, Go is quite similar to C, so if you are a long-term C developer, then creating content via Go should be a breeze. Nevertheless, we should note many of its features hearken back to languages such as Erlang, which has been around for 34-years. We will no doubt discuss it in a future episode.
Also, a lot of folks with no experience with Go has no idea that it has much in common with Java, which is why Google has been trying to push it aggressively in the server-side web apps space for quite some time; a space where Java reigns supreme.
Is Google Go cross-platform?
Cross-platform is very important for all programming languages if they are to succeed. Thankfully, we can say for certain that Go can be used on Windows, Linux, Unix, BSD, and mobile devices. So as it stands, no matter which operating system you’re using, you should have little problems executing a code in Go.
Read: What is Angular JavaScript Framework for web development?
What about bugs?
An impressive thing about Golang is the fact that it is not easy for bugs to strive in a code. You see, it relies on strong typization, which means, developers are required to be attentive and accurate when writing code in order for it to be safe.
It would be nice if all programming languages stay like this, but that is not the case. However, things are changing for the better.
Disadvantages of using Google Go
While we can agree that Go is an impressive tool, it has its shortcomings. You see, the language is very easy to pick up and learn, and that’s a good thing. However, to some programmers, it is too simplistic and this makes it not as versatile when compared to similar tools.
Another thing that we do not like about Go is the fact that it does not support a virtual machine. The lack of this was a conscious choice by the folks at Google for the sake of simplicity. Because of this decision, the size of a Go file is usually larger than competing services. Not to mention, Go will eat through your RAM like a child devouring candy on Halloween.
Finally, if you are a fan of generics, well, you’re out of luck because Go does not support these things. There have been quite a lot of discussions about this, but nothing has happened on that end so far.
Google Go coding examples
Like all others, we will focus on running Hello World! because this is the standard, it seems.
OK, so first you must create a folder called studyGo. From within this folder, will be creating our Hello World! program.
Next, create a file called first.go, then add the following code to that file:
package main
import ("fmt")
func main() {
fmt.Println("Hello World! This is my first Go program\n")
}
From within your terminal, navigate to the folder, then run the following command:
go run first.go
You should now see the following output:
Hello World! This is my first Go program
That’s it for that. Now go ahead and increase your knowledge.