lpetrich
Contributor
Here are some new programming languages that were created over the last decade.
Rust was created by the Mozilla team, as an alternative to C/C++ that is designed to have similar high performance while having much greater safety. Like most high-level languages, Rust does array accesses with a bounds-checked array object, rather than with pointer offsets as in C/C++. Rust goes a further, with explicit control of an object's mutability, so as to prevent unwanted changes. One defines an object with "let", and it may be the result of something done in run time. But after that, it is fixed. C++ "const" is similar, but it works in compile time and not run time. To make it possible to change that object, one needs to do "let mut". When passing an object as an arg, one has to make it "mut" to allow the function to change it. The Rust compiler also enforces a rule that there may be only one reference to each object that will allow making changes to it, though there can be several that will not allow such changes. This helps suppress multiple-change bugs.
However, Rust makes declarations easier with type inference, inferring a variable's type from how it is defined. One can override a type inference if one wishes, like giving a floating-point number an integer initial value.
Rust also does safe nullable or optional variables. A nullable variable is one that can be set to "no data". This is familiar from C/C++ and Java as null pointers, and Python as the "None" variable value. But none of them are completely safe, because attempting to work with the contents of a null variable will cause an exception condition. In plain C, it will cause a crash, in C++, it will do also, because it does not support catching that kind of exception, and in Java and Python, one can catch that kind of exception. But in Rust, when one wants to work with the contents of a nullable variable, one must check to see if it has data, and give what to do if it is null.
Rust also has type traits, a facility similar to Java interfaces or Objective-C protocols. In all three, one can define a set of methods that an object must implement. But Rust type traits allow for default implementations, like (say) is_unequal() in terms of is_equal().
Swift was created by Apple as an alternative to Objective-C, to get rid of the annoying C-ness in it. It has ideas in it "from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list". Ideas like nullable variables, type inference, protocols, and "categories", methnds that can be added to object classes at runtime.
Apple has implemented Swift interfaces for its Cocoa and Cocoa Touch standard libraries.
Kotlin was created as an alternative to Java, but one that can work with the Java standard libraries and runtime. Kotlin allows top-level functions rather than making every function an object method, what Java does. However, Kotlin has a behind-the-scenes container class for such functions so that they will be visible to Java code. Kotlin also makes every non-abstract object class final by default, meaning that such a class cannot be inherited from unless one defines it with "open". Like Rust, Kotlin makes every variable immutable or mutable.
Google now supports Kotlin for Android development.
From Google itself has come the Go programming language. Something like C, but careful about pointer safety. It has what its three main developers could agree on, meaning that it omits generics (C++ templates, Java, Kotlin, Rust, Swift), and inheritance of implementations.
There is a JavaScript front end called TypeScript that adds variable types. This is so that type errors will be caught in compile time, like in C/C++, Java, Rust, Swift, Kotlin, and Go. I'm reminded of this from David Gerrold's "The World of Star Trek":
C++ itself has had continued development. The C++11 release of it has introduced some nice features: type inference with "auto", reading off other variables' types with "decltype", a foreach construction with syntax much like Java's:
for(type variable: list) {...}
anonymous functions or lambdas that can be inlined, "constexpr" for functions, meaning that they can be calculated at compile time if possible, initializer lists for container classes much like for plain-C arrays, and hashed associative arrays and unique-member arrays: "unordered_map" and "unordered_set" in addition to "map" and "set", which need ordering and which build data trees.
Hash best case: O(1), Tree best case: O(log) for n items in a balanced tree
Rust was created by the Mozilla team, as an alternative to C/C++ that is designed to have similar high performance while having much greater safety. Like most high-level languages, Rust does array accesses with a bounds-checked array object, rather than with pointer offsets as in C/C++. Rust goes a further, with explicit control of an object's mutability, so as to prevent unwanted changes. One defines an object with "let", and it may be the result of something done in run time. But after that, it is fixed. C++ "const" is similar, but it works in compile time and not run time. To make it possible to change that object, one needs to do "let mut". When passing an object as an arg, one has to make it "mut" to allow the function to change it. The Rust compiler also enforces a rule that there may be only one reference to each object that will allow making changes to it, though there can be several that will not allow such changes. This helps suppress multiple-change bugs.
However, Rust makes declarations easier with type inference, inferring a variable's type from how it is defined. One can override a type inference if one wishes, like giving a floating-point number an integer initial value.
Rust also does safe nullable or optional variables. A nullable variable is one that can be set to "no data". This is familiar from C/C++ and Java as null pointers, and Python as the "None" variable value. But none of them are completely safe, because attempting to work with the contents of a null variable will cause an exception condition. In plain C, it will cause a crash, in C++, it will do also, because it does not support catching that kind of exception, and in Java and Python, one can catch that kind of exception. But in Rust, when one wants to work with the contents of a nullable variable, one must check to see if it has data, and give what to do if it is null.
Rust also has type traits, a facility similar to Java interfaces or Objective-C protocols. In all three, one can define a set of methods that an object must implement. But Rust type traits allow for default implementations, like (say) is_unequal() in terms of is_equal().
Swift was created by Apple as an alternative to Objective-C, to get rid of the annoying C-ness in it. It has ideas in it "from Objective-C, Rust, Haskell, Ruby, Python, C#, CLU, and far too many others to list". Ideas like nullable variables, type inference, protocols, and "categories", methnds that can be added to object classes at runtime.
Apple has implemented Swift interfaces for its Cocoa and Cocoa Touch standard libraries.
Kotlin was created as an alternative to Java, but one that can work with the Java standard libraries and runtime. Kotlin allows top-level functions rather than making every function an object method, what Java does. However, Kotlin has a behind-the-scenes container class for such functions so that they will be visible to Java code. Kotlin also makes every non-abstract object class final by default, meaning that such a class cannot be inherited from unless one defines it with "open". Like Rust, Kotlin makes every variable immutable or mutable.
Google now supports Kotlin for Android development.
From Google itself has come the Go programming language. Something like C, but careful about pointer safety. It has what its three main developers could agree on, meaning that it omits generics (C++ templates, Java, Kotlin, Rust, Swift), and inheritance of implementations.
There is a JavaScript front end called TypeScript that adds variable types. This is so that type errors will be caught in compile time, like in C/C++, Java, Rust, Swift, Kotlin, and Go. I'm reminded of this from David Gerrold's "The World of Star Trek":
Languages like Python catch type errors at run time, meaning that one can develop with them faster, and that they look less cluttered.... Gene L. Coon, line producer for STAR TREK, and the only man other than Roddenberry who could make the show work on a regular basis, has said, “All of your production problems can be solved best in the typewriter. They can be solved a lot cheaper and faster than they can on the set.”
C++ itself has had continued development. The C++11 release of it has introduced some nice features: type inference with "auto", reading off other variables' types with "decltype", a foreach construction with syntax much like Java's:
for(type variable: list) {...}
anonymous functions or lambdas that can be inlined, "constexpr" for functions, meaning that they can be calculated at compile time if possible, initializer lists for container classes much like for plain-C arrays, and hashed associative arrays and unique-member arrays: "unordered_map" and "unordered_set" in addition to "map" and "set", which need ordering and which build data trees.
Hash best case: O(1), Tree best case: O(log) for n items in a balanced tree