Go vs C: Why Choose Go in 2023?

Why Should You Learn Go Over an Older But Similarly Performant Language Like C?

Choosing between programming languages can be a heated debate, especially when comparing modern languages like Go to classic favorites like C. This article will examine the pros and cons of using Go compared to C, highlighting the importance of context and the role of an ecosystem in your decision-making process.

The Quandary of Language Choice

The question, 'Why should I learn Go over an older but similarly performant language like C?' doesn’t make sense without context. This ambiguity is by design, fostering intense discussions and debates that make it a popular topic on platforms like Quora.

Ecosystem and Use Cases

A programming language alone does not tell the whole story. The ecosystem that accompanies it can significantly impact your choice. For example, if you are developing applications that require a user interface for Windows, choosing Go would be quite unusual. Therefore, without context, it's almost impossible to answer such a question without discussing the specific use cases.

Business Applications and APIs

With business applications, Go excels in developing APIs with complex business logic, full-stack development, and worker processes. It also shines in tooling, devops, network messaging, and more. Here, it is essential to consider the specific needs of your project and the ecosystem that supports these needs.

Comparison with C

C: Three years ago, the future of C and the .NET framework seemed uncertain, given the overall IT trend. However, the move towards .NET Core, which performs well, combined with the possibility to use functional languages like F# and robust standard libraries, makes C a viable option for modern development.

Go: Initially, Go attracted attention due to its simplicity and the claim of having a 'one way to write things.' However, upon closer inspection, several issues were discovered:

Clarity and Expressiveness

Go simplifies variable declaration, but this comes at the cost of expressiveness. For example, `var i 5` and `var j 6` can be written as `var i, j int 5, 6` or `i, j : 5, 6` or `var i int 5; var j int 6`. This raises doubts about the 'one way to express things' claim.

Moreover, expressions must often be written using loops, which can become complex. The language's loop constructs combine traditional C loops with set operations, leading to convoluted constructs that are not straightforward.

Ecosystem Issues

Go's ecosystem also faces several challenges:

No versioning Difficulty with package management (though there are some attempts) A monolithic development environment that consolidates projects and libraries Limited generics, often requiring the use of empty interfaces

These limitations make Go less appealing in terms of modern development practices.

Development Simplicity vs. Language Evolution

While the language creators claim a 'simple' approach, many languages are bloated because they retain compatibility with previous versions. In reality, if the latest version of the language were retained, it would result in a more expressive and elegant language. Go is not immune to this pressure; as it gains popularity, it may be forced to add features, compromising its initial simplicity.

Language Strengths

Despite these shortcomings, Go offers several advantages:

Cross-compilation capabilities Simplification of build processes (compilation to a single table instead of multiple files) Ease of learning the basics Support and backing by Google Robust concurrency model A vibrant community

However, the question remains: can Go offer a better language in 2023 compared to today? An ideal language should be expressive, performant, and bring other valuable features like Go's appeal.

Conclusion

In summary, while C and Go are both powerful languages for certain applications, the choice ultimately depends on the specific use case and the ecosystem that supports it. Without clear context, it is difficult to make a definitive recommendation. As technology evolves, it will be interesting to see how Go and C continue to develop and whether a more ideal language emerges in the future.