
One of the signs that a programming language is a success is the emergence of new languages based on it. A famous example is javascript. On its basis, languages such as TypeScript, GorillaScript, Kaffeine, Sweet.js, and so on.
Over time, the Go programming language, developed by Google, will be able to compete with JavaScript in the number of add-ons and dialects.
')
The world has already been introduced to
Oden , a functional language with static typing developed within the Go ecosystem. At the same time, it was created as a Go superstructure and absorbed its best sides.
And now there is a new language -
Have , which has all chances to become an improved and augmented version of Go.
At least, the author thinks so - Polish developer Marcin Vrohniak.
He admits that while this is a hobby project, he hopes to reach a serious level and take an honorable place in the Go ecosystem. In his blog, he
spoke about some of the features of the language and its differences from Go.
First, Have is clearly different in formatting: Go uses curly braces (as in C):
if a() { b() } else { c() }
Have gone the way of Python in this regard:
if a(): b() else: c()
Another style difference is the way of declaring variables, structures and interfaces.
Declaring a structure and its method in Go:
type A struct { x int } func (a A) String() string { return fmt.Sprintf("x:%d", ax) }
Vrohnjak believes that this ad style will help avoid annoying mistakes:
struct A: x int func String() string: return fmt.Sprintf("x:%d", ax)
interface Reader: func Read(p []byte) (n int, err error)
In Have work with templates. Google developers didn’t add it to Go for simplicity. Nevertheless, Vrohniak believes that this is an important and powerful tool that must be present - must have, as they say:
struct SampleStruct[T]: func Method(p T) T: return p
T is the name of the data type.
var a SampleStruct[int], b SampleStruct[string] var x int = a.Method(1), y string = b.Method("one")
Similarly, templates are used in functions:
func SampleFunc[T](p T) T: return p
The developer did not stop at this and added so-called specializations. Depending on the type inside the function, for example, one or another data processing can be performed. Branching is done using the “when” keyword:
func SomeFunc(): when int is int: print("int is int, who would've thought?") is string: print("int is string, better report a compiler error!")
The substitution of one type or another occurs at compile time. Vrohnjak notes that outside the context of “when” templates have no practical application.
func CopyBytes[T, K](src T, dst K): when T, K is []byte, implements io.Writer: # pass is []byte, []byte: # pass implements io.Reader, is []byte: # pass implements io.Reader, io.Writer: # pass default: # - pass
Since Have is at the initial stage of development, many Go problems are not solved in it. For example, the implementation of error handling in Go requires a waste of time for writing code of the same type.
The author has big plans, but as always, little time. In the near future the language will be improved. A significant amount of Go functionality is not yet implemented in Have. This will be given priority in the foreseeable future, Vrohniak notes.
The second most important task is to ensure compatibility with Go: so that you can program on Go in projects written in Have.
Go was developed internally by Google. The initial development of Go began in September 2007, and its direct design involved Robert Grizmer, Rob Pyke and Ken Thompson. Officially, the language was introduced in November 2009.
The Go language was developed as a system programming language for creating highly efficient programs running on modern distributed systems and multi-core processors. It can be considered as an attempt to create a replacement for the C language. At least the Go developers believe in this.