开发者

What does .net source (C#, VB.net) look like in other (non-english) languages?

开发者 https://www.devze.com 2023-01-17 03:46 出处:网络
As the title says, I am just a little curious...I have seen some European open-source projects post the source, but it was all syntactically identical. 开发者_StackOverflow中文版 What about Chinese or

As the title says, I am just a little curious...I have seen some European open-source projects post the source, but it was all syntactically identical. 开发者_StackOverflow中文版 What about Chinese or Japanese or other more complex character-based languages?

UPDATE: This was a little misleading I guess. I was asking about the "traditional" .Net languages like C#, VB.net, maybe even F# etc. I understand now that there are newer .Net languages that are being create primarily to support non-English written and spoken languages and that they appear very dissimilar to similar source written in VB.net and C#.

I will try to up vote a few people and mark the answer to my intended question as the answer.


The keywords are in english, so most of the code is the same in any language. Some people use local languages for identifier names, others keep the names in english too.

Here's an example of how some code would look like with swedish identifiers:

public class StenSaxPåse {

  public enum Värde { Papper = 0, Sten = 1, Sax = 2 }

  private Värde _värde;

  public StenSaxPåse(Random slump) {
    _värde = (Värde)slump.Next(3);
  }

  public bool SammaSom(StenSaxPåse andra) {
    return _värde == andra._värde;
  }

  public bool Slår(StenSaxPåse andra) {
    return
      (_värde == Värde.Papper && andra._värde == Värde.Sten) ||
      (_värde == Värde.Sten && andra._värde == Värde.Sax) ||
      (_värde == Värde.Sax && andra._värde == Värde.Papper);
  }

  public override string ToString() {
    switch (_värde) {
      case Värde.Papper: return "PAPPER";
      case Värde.Sten: return "STEN";
      default: return "SAX";
    }
  }

}


This, of course, depends on the language.

The individual language syntax and rules will not change. For example, C# will still use the same characters and keywords, no matter what language is being developed. However, variable names and the like are allowed to use (nearly) any unicode characters, which means people in other languages can use non-English naming.

That being said, there is nothing preventing people from making a new .NET language with identifiers that are not English in nature - Examples include Lexico, the Hindi Programming Language, and Farsi.NET.

Here's some sample code from the Lexico site:

incluya "System.Windows.Forms" 
clase ventana derivada_de "System.Windows.Forms.Form" { publicos: mensajes: ventana copie "Este es el título de mi primera ventana" en ventana.text }


Syntactically identical. A programming language should be syntactically universal.

0

精彩评论

暂无评论...
验证码 换一张
取 消