When writing the following today in C#
DateTime.Now.AddYears(-60)
I wondered whether there are any languages that allow a more natural syntax with units:
DateTime.Now - 60years
Does anyone know of any? Specifically, I'm interested in the presence of unit operators(?) that turn "60years" into e.g. "TimeSpan.FromYears(60)". It'd also be neat to be able to define your own unit operators, similar to how you can write conversion operators in C#
(Yes, I know TimeSpan doesn't cater for years -- it's an example.)
There are three types of programming languages: machine language, assembly language, and high-level language. Machine language is easier for the computer to understand but harder for the programmer to understand.
The language that's used in Unity is called C# (pronounced C-sharp). All the languages that Unity operates with are object-oriented scripting languages. Like any language, scripting languages have syntax, or parts of speech, and the primary parts are called variables, functions, and classes.
In addition to these four widely available, multilingual programming languages, there are several dozen, maybe a hundred or so, programming languages that are available in a language or two other than English, such as Qalb (Arabic), Chinese Python, farsinet (Persian), Hindawi Programming System (Bengali, Gujarati, and ...
F# has units of measure. Some examples from
http://blogs.msdn.com/andrewkennedy/archive/2008/08/20/units-of-measure-in-f-part-one-introducing-units.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With