Does the Go language have a future in machine learning?

Go is an open-source programming language originally designed by Google to optimize the building and consumption of system-level services, work easily on large code bases, and take advantage of multi-core networked machines. Launched in 2009, Go is a statically typed and compiled programming language, heavily influenced by C, with a focus on simplicity, safety, and concurrency.

Go is primarily used to create large-scale applications such as Docker and Kubernetes. Furthermore, Go is widely used by companies such as Netflix, PayPal, and Uber due to low latency, efficient cross-platform performance, and easy scalability. But despite its many advantages, Go is not commonly used in machine learning (ML).

This article explores the challenges of actively using Go in ML, and the ways in which Go can gain a foothold in the ML space.

PS: GoLand  makes it very easy to read, write and change Go code. Instant bug detection and fix suggestions, fast and safe refactoring with one-step undo, smart code completion, dead code detection, and documentation hints help all Go developers, from novice to seasoned pros, create fast, efficient, and reliable code.

Download the official version of GoLand

Key Challenges of Using Go for Machine Learning

Go is a powerful and efficient programming language that is fast and high-performance to meet the CPU-intensive, computationally-intensive computing needs of AI solutions. It is faster than Python and has many advantages such as ease of use, efficiency and concurrency, and in some cases better than other languages ​​​​used in ML.

Go has the potential to create robust and scalable ML applications, and even outperform some competitors, but it remains an overlooked choice in ML. The low adoption rate of Go in ML is mainly due to some significant challenges it faces, which are already solved by older programming languages ​​in the ML field. Challenges for Go include lack of high-level libraries, no native bindings for CUDA, and poor statistics and rendering capabilities.

Missing high-level library

As a relatively new language, Go has far fewer tools and libraries than other languages ​​that have been around for decades and have well-established ML ecosystems and libraries. As a result, Go has fewer high-quality libraries and tools available for ML tasks.

This means that developers who want to use Go for ML must spend more time building custom solutions or integrating with existing libraries and frameworks that were not designed for Go.

The Go library has received several significant improvements over the years: GoLearn provides scikit-learn-style fit and predict functions, as well as test-split and cross-validation utility functions, and GoMind provides neural network functions, similar to TensorFlow's computational graphs Gorgonia, a computational ML learning library, provides zooming capabilities.

But overall, these libraries are still not as deep as Python-centric libraries that have evolved over decades. And in some functionalities, Go also exhibits significant gaps, such as natural language processing (NLP) tasks, especially compared to spaCy and NLTK.

Native bindings without CUDA

Unified Computing Device Architecture (CUDA) is a parallel computing platform and programming model developed by NVIDIA for graphics processing unit (GPU) programming, which allows developers to leverage the high-performance computing capabilities of NVIDIA GPUs to accelerate applications such as ML, scientific computing , image and video processing, etc.

Accelerating parallelizable computations with the massive parallelism of GPUs is a major benefit of CUDA, however Go does not have native bindings to CUDA like Python does.

To use CUDA in Go code, you first need to import and utilize C functions to create CUDA bindings. To be fair, C code is embedded in Go via the cgo command, making it possible to create Go packages that call C code. But only a good command of C language can rely on C code and cgo for efficient coding and debugging, which incurs huge overhead, and also creates C language-specific problems, such as memory safety situations and security vulnerabilities.

There are also third-party code packages with utility functions for the Go bindings for CUDA, such as  cuda .

experimental constraints

Go, by its nature, is not particularly suitable for experimentation. Go code is a compiled language that is converted into machine code that can be directly executed by the CPU, instead of being interpreted by the runtime environment at runtime. This feature contributes to the speed and efficiency of Go, but it is impossible to write and execute Go code without first compiling it. So it's relatively difficult to try out different ideas and test different solutions to problems in Go compared to interpreted languages ​​like Python and R.

Go does not abstract from the underlying hardware like other languages, which can be an advantage for tasks that require low-level optimization or tight control over hardware resources, but it can also make Go code more verbose and require more up-front setup and configuration, while Python In some cases, it is relatively more flexible and easier to use. Given the depth of libraries and frameworks like scikit-learn and TensorFlow, and the availability of simpler solutions in one package for tasks like feature extraction, clustering, and dimensionality reduction, Go isn't the most ideal choice for ML experiments.

Compiled languages ​​like Go are often preferred for high-performance tasks, such as server-side programming and real-time application optimization.

Insufficient math and statistics

As mentioned earlier, Go lacks the depth of industry heavyweights such as Python, and it only has a small number of proprietary libraries and packages focused on statistics, calculus, and matrix operations, which are not enough to meet the needs of ML and artificial intelligence development.

This is not necessarily a disadvantage for everyone, some developers are happy to actively write code for ML algorithms or mathematical logic. However, this also means that Go is still less easy to use than Python for the same data manipulation, analysis and prediction algorithms.

In general, Python, R, and Julia were the first to launch and are firmly established in the ML community. Go still has a long way to go before it becomes a viable alternative, especially as these existing programming languages ​​continue to evolve to make their ML and AI capabilities better, simpler, and more effective.

High-level libraries in Go

High-level libraries like Gonum , Gorgonia  , and  GoLearn in Go   provide tools for building and training neural networks, performing numerical computations, and other ML tasks.

While they are not as feature-rich as the Python library options, Python libraries and frameworks such as TensorFlow, scikit-learn, and spaCy were created and iteratively developed to meet the needs of ML developers and are popular in the ML industry, providing Features suitable for natural language processing, image embeddings, neural networks, and other ML essentials.

The same functionality is possible in Go, and they may be more powerful and efficient thanks to Go's advantages over other programming languages, such as networking, concurrency, and data processing.

However, creating these functions is currently only useful in the Go community, as Go is not as popular in the ML community as languages ​​like Python or R. There is also a huge gap in the number of contributors compared to earlier counterparts, resulting in a relatively small ecosystem of libraries and tools, making it harder to find established solutions to certain problems.

Are things changing?

Go is growing in popularity and the community is growing. Currently, according to  StackShare  , 2,751 companies use Go, including Uber, Twitch, Shopify, and Slack. Also, according to  the 2021 Stack Overflow Developer Survey , around 9.55% of developers use Go, making it the 14th most popular programming language.

While this is great news for the Go community, it doesn't really translate to the ML world. Go is best known for its ability to create scalable servers and large-scale software systems, write concurrent programs, and launch fast and lightweight microservices, and even the official Go website doesn't list ML as a typical use case.

Does the Go language have a future in machine learning?

This shows that Go is currently moving away from the ML field and also lacks a foothold in the ML community.

future example

Go has no notable highlights in ML, but considering the advantages of the language, instead of viewing Go as a language for developing ML models, it is better to regard it as a language for ML model services.

Go can be used to build ML model servers, allowing models to be accessed and used by other applications or systems. This is useful for deploying ML models in production or building ML APIs that can be accessed by other developers or users. It can be used to build ML applications such as ML-powered recommendation engines or natural language processing tools. It can also be used to build back-end infrastructure or user-facing interfaces for these types of apps.

For the Go community, creating more toolkits and frameworks for faster and more efficient server-side ML may effectively open up the codebase for more experimentation in the ML space.

Guess you like

Origin blog.csdn.net/AABBbaby/article/details/132662419