top of page

About Sing

How is sing better than C++ ?

​

Sing is safer.

  • very limited use of pointers

  • no pointers arithmetic

  • no dangerous implicit conversions

  • indices out of range are checked

  • no undefined behaviours

  • no uninitialized variables

  • no names shadowing

  • no function and operators overloading. (they partially break type safety)

  • no manual memory management 

  • better control on dependencies

  • no warnings, only errors

  • simpler operators precedence

  • = is not an operator and can't be confused with ==

​

Sing guides your choices in a sensible way.

  • no inheritance from concrete classes. I seldom found inheritance used well and not causing problems. (I'm willing to revise this choice if I'm offered evidence of the contrary)

  • embedded UTF-8 dynamic strings. Because you don't want to discover you need to migrate your 2000 static ascii strings to another encoding.

  • dynamic vectors. Again, because trying to anticipately guess the size of your vectors is a recipe for disaster. (but static arrays are there too, when you are absolute sure of the size and you need speed).

​

Sing is more readable

  • simpler types declarations

  • named function arguments

​

Sing is more concise (even if this is not its main goal)

  • no includes

  • type inference

​

Sing has all the basic stuff done for you

  • maps and dynamic arrays are part of the language and use the standard syntax

  • sized types

  • a multiplatform library which, despite being smaller, better covers the application needs. (for example covers sockets, threads, processes, directories scan...)

​

And again, sing is an easy choice

  • At any time, if you fill sing is not for you, you are left with the c++ code from sing. (and a dependency from the SMALL sing library - to be 100% honest)

  • It blends nicely with your existing c++ code.

​

​

​

What sing is missing with respect to c++

 

  • generics

  • closures / lambdas

  • inheritance

  • All that 90% of fine details which only 5% of the code benefits of.

​

I'm 80% incline to add closures in future releases. For now you can replace them with runnable classes which are a little bit more verbose but do the same job.

​

I think generics easily break the readability and increase the complexity of a language.
Generics are great to build basic language structures like strings, dynamic vectors and operation common to all the types, like max() and abs().
Sing takes care of all this stuff at the language level for the most common cases (has built in dynamic strings, vectors, maps, operators).
For other cases you can use, with some little penalty in speed, dynamic polymorphism (interfaces). 
I'm waiting for a stronger evidence of the need of generics before putting them in the language. 

​

Inheritance is a strange confused feature, because it is pretty difficult to say what it is for and when to use it.
As a matter of fact public inheritance has three unrelated effects:
- recycles the implementation of the base class
- inherits the interfaces of the base class
- allow the base and derived classes to be used in a polymorphic way
Sing has three different constructs to deal with those three different needs.
Should be in the future clear that missing inheritance is a language flaw, I'm ready to add it. 


Sing design choices

​

Value types

Sing uses only value types (not reference types, like in java/c#). This has some advantages:

​

Clarity: the assignment operator always writes a variable, never builds an alias.
Efficiency: If object A incorporates B, this means that in the A layout there is space for a whole B (not just a reference),  in this way you get many less allocations and more locality and cache friendliness.

​

Parameter passing by reference

Function parameters are always passed by reference, this makes it possible to return values and to pass big objects without the need for explicit reference types or pointers.

​

Automatic memory management

Smart pointers are only used to keep references to dynamically allocated objects. Sing uses reference counting to deallocate objects automatically.
With respect to garbage-collection oriented languages this has the advantage of preventing very long interruptions in the execution of the program.

​

Minimality

Sing has those 10% of the features that make it possible to develop 98% of the codebase of an high performance application, the rest is left to C++. This is just another advantage of not giving up the king of all the languages.

​

how is sing better tan c++
what is missing
designchoices
bottom of page