Everyone knows such progressive novices in programming as “Go, Rust, Nim, Crystal” and they are all very cool in their specific areas.
For example:- Go was born as a super simple and industrial language for quickly solving assigned tasks with ideas that are beautiful to everyone, but some of them are nailed to other languages (5mm).
- Our second opponent is Rust, the winner in life, but because of his difficult life in development, he has become for the community as a future and fashionable replacement for C ++. For me, his fate is not yet clear, because with green streams and IO under them there is still tight, then I put it in place in a row with C for microcontrollers, drivers and operating systems.
- Crystal ... Directly and clearly I say that this is a super productive Ruby clone. There is nothing more to say, he is all imbued with his spirit.
- Nim (He is Nimushka or Nimrod) and his similarity to scripting languages create a special atmosphere for him, but inside he is a rather complex organism and for me this is an entity like Haxe with the same sensations when programming on it.
And Pony is my favorite and little pony. With the appearance and the name of the language, you can famously pass by ... In general, I invite you under the hood of the article.
This is just the beginning.
Preliminary I will tell a little about myself in order to create a special atmosphere for you to understand the language and its possible applications.
')
- I am Nyarum, known as a simple user of the Go language. Often I push the irony with Rust and co-author the Slack gopher community.
- My petprojects are always associated with the emulation of online games. From reverse to playback of the server part.
- And I love Anime.
Now you know all my secrets, you can continue our interesting story in the world of beautiful Pony.
Language and brief educational program
This is the very cheerful breadwinner and he looks more like a rabbitPony is an object-oriented programming language built primarily on the model of actors and transparent competitiveness. In its additional advantages, such concepts as “Open-source, performance, interesting ideas” rub. The main focus is on a multi-core system, modern development without thinking about the low level and very productive competitiveness.
Opportunities
- Type Safety. Confirmed by the mathematical background.
- Safe work with memory. Although this is a consequence of type safety, this item should not be overlooked. In it, you will not find dangling pointers, buffer overflow or, in the most frequent case, you will not have to know what null is.
- Safe work with actions. All of them are defined at the semantic level and there are no runtime surprises.
- Say no to race data! No atomics, mutexes or timers. A type system with checks at compile time gives a high guarantee of this concept. Write a competitive code and do not worry about the rest.
- No deadlocks. The consequence of the absence of any operations with locks.
Language Brief
Type system:
- Class, standard from the PLO world. Fields, constructors and functions at your disposal.
class Habra let _name: String new create(name': String) => _name = name' fun name(): String => _name
- Actor, identical to the class, but has the ability to define asynchronous functions. This refers to transparent competition.
actor Habro let name: String var _hunger_level: U64 = 0 new create(name': String) => name = name' be eat(amount: U64) => _hunger_level = _hunger_level - amount.min(_hunger_level)
- Primitive is also identical to the class with the 2nd differences. It cannot have fields and in the course of the program’s operation only 1 instance is created for the primitive you defined. It is used for many things, but more often, as a special kind of generic with the ability to type in None, to check the values coming from the FFI world if it is not equal to emptiness.
primitive _Habras
- Trait and interface (They are subtypes, however they are defined in the same way as a class). Many PLs have only 1 of them at a time, but they are both involved in Pony. The difference is that the trait is a conditional membership test, and the interface checks for structural compliance.
- Aliases for types. I will not talk about them much here, a powerful system and requires independent study.
- A tuple is a sequence of types that can be defined in one variable.
var x: (String, U64) x = ("hi", 3)
- Union is very similar to a tuple, only used to summarize possible types. A special kind of generic.
var x: (String | U64) x = "hello habr"
- The intersection is almost the opposite of a union and can describe one value for several types at the same time. In the example below, you can see how the card can simultaneously contain a key of two different types.
type Map[K: (Hashable box & Comparable[K] box), V] is HashMap[K, V, HashEq[K]]
- All of the above type expressions can be combined.
Standard expressions:
- These are all very familiar to everyone - “Variables, operation signs, checks, cycles, methods, operations, etc ..”. Leave for independent study.
Opportunities:
- Object - Low-level ownership is limited for you, FFI is an exception and can break your code, but it is controllable. No global variables and functions.
- Reference - built on several basic concepts and for control ( Warranty ) 3-letter keywords are used.
- iso - Full isolation, other variables will not be able to access this data. It can be changed as your soul pleases and transferred to other actors.
- val - Immutable data, respectively, the variable under this protection is available for reading and can be transferred to other actors.
- ref - Variable data, you can rotate in any direction and have several variables for this data, but transfer to other actors is not possible.
- box is a combination of val and ref, as the case may be. If the data is used only for reading, then the variable behaves on them as val and can be transferred to other actors. However, if you try to write new data into it, you get a ref and not the ability to use between several actors.
- trn - Data that can be written permanently, but given to other variables as box. Subsequently, you can change the limiter to val and transfer to other actors.
- tag - Identification of data, you can not write to them or read, but it is quite possible to store and compare to determine the type of data. Transfer to other actors is possible.
String iso
The attractiveness of the language
Garbage collector
On board, we have a very cool GC, which is completely competitive and does not have Stop the World. In fact, there are 2 of them, one is a link collector for each created actor and one is global.
Actor speed
Thanks to a guy like Dima Vyukov, who made a huge contribution to the lock-free algorithms and Go, a base appeared, which Pony focused on when developing the communication of actors. And that is why now the transfer rate between actors reaches 20kk per second, and the creation can reach 1kk per second.
Transparent competitiveness
I gave this concept myself and was surprised when, in order to make the code competitive, we would only need to change the name of the function. This method is even more modern than provided by Go with its own gorutines.
Peaper
Status and additional links
The language is in the status of a distant beta, now the language version is 0.2.1. The developers are currently completing the remaining planned features, fix bugs and stabilize the language. There are plug-ins for almost all popular editors.
Thank you for reading the article and may be interested in the language.