Multi-language programming staff

Source: Internet
Author: User
Tags joins

This column is devoted to programming languages, but you'll find it interesting to see that sometimes language ideas can be converted to other languages without having to modify them directly.

Microsoft language C-omega is an example of this, which is sometimes abbreviated to Cw because the Greek Omega symbol looks much like the lowercase letter W on the US keyboard layout. In addition to introducing a number of data unification and Code unification Concepts (which can eventually be converted as LINQ to C # and Visual Basic languages), C-omega provides a new concurrency method named "Chords", which saves C-omega to the joins library. Although the joins product has not yet been introduced at the time of this writing, the entire chords concurrency concept can be provided through a library, meaning that any ordinary C # or Visual Basic (or other. NET language) programs can take advantage of this concept.

In addition to this concept, a Code contracts tool is provided. Contract design is a language feature that plays a significant role in languages such as Eiffel, which were initially applied to. NET through the Microsoft study language spec#. Similar types of contract assurance systems are also introduced through Microsoft research, including one of my favorite products, fugue, which uses custom attributes and static analysis to check if the client code is correct.

Again, although Code contracts has not yet been released as a formal product or licensed for use in production software, its existence as a library rather than as an independent language implies two meanings. First, in theory, the code contracts can be written by any. NET developer as a library, which is sufficient to demonstrate similar functionality. Second, the features mentioned in the product (assuming they do) can be used in a variety of languages, including C # and Visual Basic.

If you smell a whiff of the subject, you guessed right! This month, I'm going to focus on a recently released library from the multilingual World: Software transaction Memory or STM. The Stm.net library can be downloaded via the DevLabs Web site, but unlike some of the other implementations I mentioned, it is not a stand-alone library that can be linked to a program or run as a static analysis tool, which is an alternative and complementary to the. NET base Class library as a whole.

Note, however, that the current implementation of Stm.net is not ideal for compatibility with current Visual Studio Beta, so in this case, you are concerned about the common disclaimers of installing the unfinished/BETA/CTP software on your computer, so be sure to pay extra attention. The product should be installed with Visual Studio 20,081, but I will not install it on your work machine yet. Here's another example, where Virtual PCs are the main tool you use.

Entry

Although Stm.net combines many different languages, the concept of STM is intuitive and easy to understand: instead of forcing developers to focus on methods that implement concurrency, such as locks, they allow them to mark which part of the code should be executed when they have specific supporting concurrency features. and use the Language tool (compiler or interpreter) to manage locks if necessary. In other words, stm.net, like the nature of database administrators and users, enables programmers to tag code with ACID-style transactional semantics and leave the tedious work of managing locks to the underlying environment.

Although Stm.net may appear to be just another attempt to manage concurrency, the fact that the STM works is far more than that, it tries to introduce the memory programming model to all four of the properties of the database ACID transaction. In addition to managing locks on behalf of programmers, the STM model also provides atomicity, consistency, isolation, and persistence, which can make programming simpler by virtue of the presence of multiple execution threads at the same time.

The following is an example of pseudocode (which is not uncommon), please note this:

BankTransfer(Account from, Account to, int amount) {
  from.Debit(amount);
  to.Credit(amount);
}

What happens if credit fails and an exception is thrown? If the borrower of the source account still has a record and the lender does not have the appropriate input, it is obvious that the user will be very unhappy and the developer will have to fix it:

BankTransfer(Account from, Account to, int amount) {
  int originalFromAmount = from.Amount;
  int originalToAmount = to.Amount;
  try {
   from.Debit(amount);
   to.Credit(amount);
  }
  catch (Exception x) {
   from.Amount = originalFromAmount;
   to.Amount = originalToAmount;
  }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.