Showing posts with label advantages of golang. Show all posts
Showing posts with label advantages of golang. Show all posts

Tuesday, October 13, 2020

What’s New In Golang 1.15?

 

What's new in Golang 1.15

Since its delivery, Golang has increased popularity in the developer community. Till the year 2016, it was crowned as the language of the year and holds 11th position in the TIOBE programming community index. Golang is used for all types of software development solutions like general programming language, system programming language or general support. It has the ability to handle heavy server-centric web services, text processing problems and heavy distributed apps. Since its release, the language has been constantly revised and improved over the years. Before proceeding for the new features and updates in Go 1.15, let us have a quick look at Golang.

What Is Golang?

Golang is also known as Go. It is an open source programming language developed by Google in the year 2007. Golang’s creators want to make a statically typed compiled language that would be as simple to use as dynamically typed languages and have a similar level of expressiveness. In short they want to include C++  with Java and Python while including the best features of them. So, Golang has elements from statistically and dynamically typed languages. Golang syntax was designed to allow virtually everything to be programmed using less syntax. Even though the language has been available for longer than 10 years, it hasn’t introduced any serious syntax modifications that could make the code over-compiled. Recently, on 11th August 2020, it has released version 1.15. Let us see some amazing updates of Golang 1.1.5.

What’s New In Golang 1.15?

1. Compiler-

  • Package unsafe’s safety rules allow you to convert an unsafe.Pointer into uintptr when calling certain functions. Earlier, the compiler allowed different chained conversions. The compiler now requires precisely one conversion.
  • Golang 1,15 includes a -spectre to both compiler and assembler.
  • Now, the compiler rejects //go: compiler directives that does not have any meaning for the declaration they are applied to with “misplaced compiler directive” error.
  • Now, the compiler’s -json optimization logging reports large copies( >=128) and provides explanations of escape analysis decisions.

2. Linker-

Completely rewritten linker is the largest tooling change in 1.15. Have a look at the three major structural changes in new linker-

  • Moving from the linker to compiler, this enables parallelization as compiles are done in parallel across multiple CPUs, but the link step mostly be done in sequential at the end of the build. Also the results of the compiler are cached by Golang tooling.
  • Improving key data structures, primarily by avoiding strings. The recent linker makes use of large symbol table indexed by string; the new design avoids strings however much as possible by using a  symbol numbering technique.
  • Avoiding loading all input object files into memory at once: this makes the new linker use less memory for large programs, and allocates less memory.

3. Tools-

  • Vet- Now, this tool warns about form string(x) conversions where x has integer type other than rune or byte. It also warns about type assertions from one interface type another interface type when the type assertion will always fail.
  • Go command- The GOPROXY environment supports skipping proxies that return errors. Now, Proxy URLs can be separated with commas or pipe characters. Various flag parsing issues in go test and go vet have been fixed.

4. Runtime-

  • For runtime, now allocation of small objects works more efficiently at high counts and has lower worst-case latency. Further, non-blocking receives on closed channels now perform and also non-blocking receives on open channels.

5. Standard Library Additions-

In every new version release, Go comes with various minor changes and updates to the library. Here we’re including some useful and significant changes-

tzdata Package-

A new embedded tzdata package was included that allows embedding the timezone database into a program. Importing this package allows the program to find timezone information without timezone database on local system. Also you can embed timezone database by building with -tags timet/zdata. This increases the size of the program by about 800 KB. This might be helpful and can test some code with the virtualized environments like Go playground.

X.509 CommonName Deprecation-

Older versions of Go use CommonName field on X.509 certificates as a hostname if there is no Subject Alternative Names, would be disabled by default. If Still need to use this legacy behavior, at that point you need to include x509ignoreCN=0 in the GODEBUG environment variable.

net/url Package-

The net/url package adds a new URL. The method redacted() returns the URL as a string. This is proposed in the Issue 34855. It is an extremely helpful improvement for audit logging and security. It’s a simple derivation from the URL.String() which masks the password if exists from the string being passed. It doesn’t modify at all to the URL itself yet a copy of it.

6. Minor Changes To The Library-

1. context-

While creating a derived context by using a nil parent is now disallowed. 

2. bufio-

When a Scanner is used with an invalid io.Reader that incorrectly returns a negative number from Read, the Scanner will not panic, yet will rather restore the new error ErrBadReadCount. 

3. crypto-

The PublicKey and PrivateKey types in the crypto/rsacrypto/ecdsa and crypto/ed25519 packages now have an Equal method to to make type-safe interfaces for public keys or to compare keys for equivalence. The method signature is viable with go-cmp’s definition of equality. Now, Hash implements fmt.Stringer.

4. crypto/ecdsa-

New VerifyASN1 and SignASN1 functions allow generating and verifying ECDSA signatures in standard ASN.1 DER encoding.

5. crypto/elliptic-

New UnmarshalCompressed and MarshalCompressed functions allows encoding-decoding NIST elliptic curve points in compressed format.

6. crypto/rsa-

According to RFC 8017, now, VerifyPKCS1v15 rejects invalid short signatures with missing leading zeroes

7. crypto/tls: 

New Dialer type and its DialContext method allows use of context to both connect and handshake  with TLS server.

8.crypto/x509/pkix: 

Now, Name.String prints non-standard attributes from Names if ExtraNames is nil. 

9. database/sql-

New DB,SetConnMaxIdleTime method allow  to remove a connection from connection pool after it has been idle for some time, regardless of the total lifespan of the connection.

The DBStats.MaxIdleTimeClosed field shows the total number of connections closed due to DB.SetConnMaxIdleTime. New Row.Err allows query error checking without calling Row.Scan

10. database/sql/driver-

New Validator interface may be implemented by Conn to allow drivers to signal if a connection is valid or if it should be discarded. 

Know more at- https://solaceinfotech.com/blog/whats-new-in-golang-1-15/


Monday, November 4, 2019

Golang vs Rust- Which One To Choose And Why?

In the course of recent decades, programming languages have risen the prime alternatives for big business development. Rust was produced at Mozilla, while then again, Golang was created at Google. These programming languages give indispensable features for developing advanced software including, memory security, incorporated tool chain, open-source development model, wide communities for modern users and the likes.
Golang and Rust have many similarities but they are different from one another. They were developed for solving various complexities, meeting various necessities, and writing various types of programs. Drawing a comparison between Golang and Rust is not about analysing which programming language can perform better. Instead, it is about figuring out which language can perform great at a given programming task. Remembering that, we should discover the primary ways Golang and Rust vary from one another and the kind of responsibilities each is satiable for.
First of all go through overview of each language.  

What is Golang?

Go was presented in the year 2007 by Google. It was considered as a riposte to some of the issues that a few associations were found in building software infrastructure.
Certain issues like computation clusters, web programming models, and so forth were dealt with by workarounds as opposed to getting fixed straightforwardly. Golang was conceptualized and built to bring greater productivity middle such situations. Aside from its notable angles like garbage collection, built-in concurrency, the design consideration of Golang likewise incorporate a thorough dependency management, robustness crosswise over various boundaries between components, and software architectures’ flexibility as advanced systems. Presently, contrasted with other server- side programming dialects, Golang shares the most noteworthy market position as far as both traffic and ubiquity. You can also go through the comparison of Python and Go at- Python vs Go : Which one to choose?

Advantages of using Golang-

  • It is easy to handle.
  • Golang is IDE-supported and is also very fast. It is statically typed programming language that can compile to machine code. Golang can work faster than other programming languages like Python, JavaScript, Java, C#, etc.
  • It’s code is simple.
  • Its problem-solving approach is predominantly accentuated on a developer’s efficiency crosswise over various programming development cycles.
  • Biggest strength of Golang is Flexibility.
  • Golang is known to be a pragmatic, concise and efficient language
  • Golang’s explicit focus is to streamline the way toward coding. In the documentation of Golang, it is depicted as an ‘open-source project’ for making software engineers increasingly productive.
  • This language is focused on concurrency as a top-tier concept
  • It is simple as well as extremely safe to use. It will not tolerate unprotected memory access

Disadvantages of Golang-

Despite the fact that Golang has earned a lot of recognition from the developers around the world, it has various disadvantages also. Let’s see which are those disadvantages.
  • This is not a system language
  • It forfeits a couple of aspects of performance to put an emphasis on its target of simplicity.
  • This language allows some interoperability by means of cgo. It isn’t the foreseen route for Golang projects to be written.
  • Golang lacks generics to a great extent.
  • There is not enough immutability in this programming language

What is Rust?

Rust is an advanced extension of the ML language. Mozilla was the real underwriter of Rust. The Servo browser engine which is supported by Mozilla was created with the assistance of Rust. Some of the major goals of the Servo project which influence the ownership and concurrency of Rust incorporate better security, improved parallelism, better execution, and expanded modularity. The 1.0 version of Rust was presented in 2015 and the 1.33 version of Rust was built in 2019. There is a strong community  support for Rust. A couple of instances of the community projects incorporate Redox, which is an OS developed in cgmath, Iron, and a linear computer and algebra graphics library.

Biggest Advantages of Rust-

  • Rust has an astonishing run speed. In some cases, Rust has effectively outperformed Golang.
  • Rust is best in class for achieving certain tasks in which high performance, safety and concurrency are required.
  • Rust is honored with the complexity of code. It has empowered some fine-grained system controlling features like novel embeddings, rich examples, rich syntax extensions, and the preferences.
  • It is most loved programming language by millions of developers with a community of experts expressing they need to continue managing it.
  • This programming language is interoperable with FFI, C, and a few different languages
  • It has a zero-cost abstraction
  • Rust has strong supportive community.
  • It has a strong support for generics in various types of trails.
  • Rust does not tolerate unprotected memory accesses.
  • It has an entirely predictable runtime conduct. This implies there is neither a garbage collector, nor any cost abstraction.
  • It saves a lot of time from debugging, crashing, and testing

Disadvantages of Rust-

  • Rust has a steeper learning curve than Golang.
  • It is little bit complex programming language. It requires learning and mastering it before people can handle it. 
  • The old habits ought to be unlearned before the most recent ideas are presented.
  • It can be a tad slower than C++ and C in analogous situations.

Which is Better and Why?

Both Rust and Golang can spell benefits in designing a web service, which requires managing a high volume of traffic. Be that as it may, according to the modern developers, Golang is significantly faster than Rust. It is superior to the last particularly on the off chance that you are working with a large team of developers or have a variety of services to compose. Rust has been depicted as an amazingly superior programming language by numerous different developers also. As per them, it is relatively safer than some other programming languages. Be that as it may, the overall popularity of Golang is somewhat higher mainly because of its low ramp up and less complexity.
Rust can compete for space with C++, and so on in a circumstance where developers need to deal with complex syntax for ensuring an ideal performance in various fields like a game engines, microcontrollers, web rendering engines etc. Since the days of yore, both these languages have been considered as contenders because they were introduced simultaneously. Golang is planned for keeping up simplicity and letting the developers a superior experience of programming. It likewise makes a large programming team significantly more productive by means of an application of simplicity. In the meantime, Rust can empower developers in assuming responsibility for a granular level, directly from managing how their threads behave with the system of their variables. Starting now, Golang might ruling the boost, however this image may change sooner rather than later with Rust topping the developers’ priority lists. Till at that point, Golang is expected to continually reign supreme.
Are you looking to develop a software for your business using golang or rust? Then solace experts are there to help you with their advanced knowledge for development. They are dedicated to work with golang and rust  languages. Get a free quote for software development that will boost your business to the next level.