• 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.
  • Posts

    • The core problem with Win 11 is much like Win 8 when Microsoft decided (in panic and incorrectly) that the iPad proved that the future was tablets and so redesigned the entire shell UI to be touch/tablet friendly - forgetting that 1.5 billion PCs are desktop systems without touch or pen support, Win 11 was the invasion of web apps and web tech into the shell because of course the future is the browser and making Windows as much like working in a browser as possible "just makes sense". Worse, they also got it into their heads that AI is the future and (as we saw with the thankfully discarded 2024 AI shell) that AI has to be the main front and center feature. Even if few wanted or needed it. And now they're realising again, that maybe their vision doesn't match reality. Maybe native apps built on .Net Framework and XAML based UI (which BTW, they tried to abandon with Win 8 and had to undo and restore - Microsoft really hates .Net, which they invented, for some reason) really are easier to write and maintain, more responsive and just better looking too? Maybe people really don't want to be forced to use AI all the time? Maybe change for change's sake isn't a good product strategy?
    • I think this could have better served as an editorial, I've passed the feedback on to the author. We'll do better!
    • Amazon Deal: This 850W ATX 3.1, PCIe 5.1 Gold PSU is only $68 for limited time by Sayan Sen Hardware prices are quite high nowadays and deals are hard to come by as they are few and far between, especially on components like RAM. If you are in the market looking to build a PC or upgrade, and wondering what to get, there is a great PSU deal at the moment that you can grab for just $68. For that price, you will get an 80+ Gold-rated ATX 3.1 and PCIe 5 SMPS. It's an amazing offer, but only for a very limited time, so do not miss it (purchase link under the specs table down below). The technical specs of the KN850 are given in the table below: Specification Value Model PCCOOLER KN850 (P3-KN850-G1F) Rated Power 850W Form Factor ATX ATX Standard ATX 3.1 PCIe Standard PCIe 5.1 Ready Efficiency Certification 80 PLUS Gold Modular Design Fully Modular Input Voltage 100–240V AC Input Frequency 50–60Hz Maximum Input Current 6A Cooling Fan 120 mm Hydraulic Bearing Fan Main Capacitors 105°C Japanese Capacitors Motherboard Connector 1 × 24-pin (20+4) CPU Power Connectors 2 × 8-pin (4+4) PCIe Connectors 3 × 8-pin (6+2) 12V-2x6 Connector 1 × Native 12V-2x6 (600W) SATA Power Connectors 7 Peripheral (Molex) Connectors 2 Protection Features OVP, UVP, SCP, OPP, OTP, OCP, SPD Hold-up Time >16 ms (at 80% load) Typical Efficiency >90% at 50% load MTBF >100,000 hours Dimensions (L × W × H) 140 × 150 × 86 mm Get it at the link below: PCCOOLER PSU Fully Modular, 850W, 5-Year Warranty (KN850): $67.99 (Sold by CPS Gaming, Shipped by Amazon US) ****[Limited Time] PCCOOLER PSU Fully Modular, 750W ATX, 5-Year Warranty (KN750): $64.59 (Sold by CPS Gaming, Shipped by Amazon US) ***[Limited Time] Good to know This Amazon deal is U.S. specific, and not available in other regions unless specified. We only use first-party seller links (at the time of article publishing); ensure that you purchase from a first-party seller link only. Check out Today's Deals on Amazon | or our recent tech deals. Become a Prime member (for Students or SNAP) via Neowin Get Prime Access - Prime for half price (for qualifying Medicaid, EBT, SNAP) Subscribe to Prime Video, Audible Plus, Music Unlimited or Kindle Unlimited via Neowin As an Amazon Associate, we earn from qualifying purchases.
    • The lack of good content sources is becoming very clear. Slow news day? Fine, let's fabricate another "X is happening because 3 randos on Reddit are complaining" article...
  • Recent Achievements

    • Reacting Well
      Gideon Waxfarb earned a badge
      Reacting Well
    • First Post
      NovaEdgeX earned a badge
      First Post
    • One Month Later
      pahariyaseo earned a badge
      One Month Later
    • Week One Done
      pahariyaseo earned a badge
      Week One Done
    • Week One Done
      hadiaali45 earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      427
    2. 2
      PsYcHoKiLLa
      144
    3. 3
      Nick H.
      90
    4. 4
      Steven P.
      81
    5. 5
      +Edouard
      80
  • Tell a friend

    Love Neowin? Tell a friend!