• 0

Cobra programming language


Question

I've recently discovered this gem of a programming language:

class SmallSample

	var _random = Random() 

	def randomString(length as int, alphabet as String) as String
		require
			length > 0
			alphabet <> ''
		ensure
			result.length == length
		test
			u = Utils()
			assert u.randomString(5, 'ab').length == 5
			s = u.randomString(1000, 'a')
			for c in s, assert c == 'a'
		body
			sb = StringBuilder()
			for i in length
				c = alphabet[_random.next(alphabet.length)]
				sb.append(c)
			return sb.toString

	def main
		alphabet = 'abcdefghijklmnopqrstuvwxyz'
		for i in 10, print .randomString(10, alphabet)

As you see from the sample:

  • Integrated pre and post-condition checking
  • Integrated unit testing
  • Python-like syntax (it's actually much cleaner than Python)

What you don't see from the sample:

  • Performance similar to Java, C#
  • Seamlessly supports both static and dynamic typing (favors static typing)
  • CLI-compliant, compiles to .NET assemblies, currently runs on Mono and .NET (JVM port in the works). So you get to use all the .NET framework libraries and awesomeness just like under C# or your favorite .NET language.
  • Debugging and syntax highlighting under Visual Studio 2010

http://cobra-language.com/

I've been messing around with it for a few days now, and I'd say that if they can get Intellisense working in VS2010, I could very well switch from C# to that for my personal projects.

Edited by Dr_Asik
Link to comment
https://www.neowin.net/forum/topic/957422-cobra-programming-language/
Share on other sites

12 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.