Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

October 21, 2022

Is C# obsolete?

 

In the history of programming language there is a tendency available from low level- towards high level languages. From the perspective of the C language all the programs written in Assembly are outdated. The reason is that the source code can be written in a shorter amount of time. Because of this reason the C# language has replaced the former C++ language entirely.
On the long hand the transition towards high level language will make even c# obsolete. The reason is, that in comparison to scripting languages like Python, C# can be called a low level language. There is need to use datatypes like int and string and many class initialization will need a lot of boiler plate code. Without any doubt the Python interpreter is more high level than C# so the C# language is outdated.
Writing a simple hello world gui app with C# will take around 30% more lines of code than the same app written in Python. Such an overhead is difficult to maintain and it will increase the time to market time.
According to the Rosetttacode website, the string append problem can be solved with many programming languages. The low level C language will need the most amount of written lines, then comes C# and the shortest code can be written in Python.

// c
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

char *sconcat(const char *s1, const char *s2)
{
  char *s0 = malloc(strlen(s1)+strlen(s2)+1);
  strcpy(s0, s1);
  strcat(s0, s2);
  return s0;
}
int main()
{
  char str1[]="Hello ";
  char str2[]="World";
  char *str3=sconcat(str1,str2);
  printf("%s\n",str3);
  return 0;
}


// c#
class Program
{
    static void Main(string[] args)
    {
        string x = "foo";
        x += "bar";
        System.Console.WriteLine(x);
    }
}

// python
str = "12345678";
str += "9!";
print(str)

 

The difference between C# and Python is not huge, but C# will need around 30% more space for writing the semicolon, the datatypes and lots of extra code for anything. This additional effort has to be written by the programmer which reduces the productivity. Basically spoken, C# is outdated because it not high level enough.
Let us take a closer look into the C program. First thing to mention is, that the string concat method was implemented safe and is one of the easiest to understand. It is using in addition external routines to make things easier. It is possible to create more advanced string concat routines. Nevertheless the lines of code are difficult to understand. For C programmers it makes sense to use three different commands like malloc, strcpy and so on only to add str1 with str2 but from an outside perspective, the source code is a bit hard to read.
Such situation is available for many problems which should be implemented in the C language. In most cases, there are at least 40 different ways available how to solve it, and all of them have to do with pointer manipulation and manually typing in lots of code lines. In contrast, the written code in the python language is much easier to type and to understand. All what is needed is a statement like “str1+str2” without further subroutines.
The advantage is not located in Python directly, because string manipulation is also easy going in languages like PHP and Ruby. But it has to do with low level vs high level languages.


 

 

September 27, 2022

Programming in C# on a Linux desktop

Since many years, the Linux community is asking how and when the Linux desktop will become a mainstream ecosystem. The answer is always disappointing, that this is not the case and nobody knows the reason why. The underlying reason isn't located in the technology but it has to do with the Open Source ideology which prevents that Linux will become the default desktop PC.
Let us investigate the subject in detail and ask a simple question: which IDE (programming environment) is available under Linux which allows to program in the C# language? Somebody may argue, that this question is not important because nobody likes to do so, and in addition all the major IDEs are supporting of course all the programming languages. The surprising insight is, that this is not the case. Let us take a look on some major IDE in Linux which are code:lite, code:blocks, kdevelop and netbeans. It is possible to use these IDE for any language e.g. php, python, C/C++, java and even Lisp. So it would be naturally, that the major C# language which in the top 10 of the TIOBE index is supported as well.
According to the forum postings this is not the case.[1][2][3][4] The interesting situation is, that the answer for C# support or maybe a simple third party plugin is always answered very short with something like “nope” and “we don't have it and there is no plan in that direction” without giving a further explanation. The only IDE which is available for Linux is Eclipse which has at least a third party plugin for C# ("aCute"). But it is poor documented and the user is encouraged to not use the language at all.
So the question is, why is C# not liked by Linux enthusiasts? At first, we have to make clear that Linux is open to different programming languages. All the important languages like C/C++, java, php, python, TCL and of course Forth are accepted and it depends on the individual programmer if he likes the language or not. The only exception is the C# language. Here, the user is not allowed to use the language. The only way in doing so is to install a complete different IDE. That means the user has to leave the normal IDE community and search for a visual studio like software which is available for Linux or not.
References
[1] Feature Request - C#, 2016 #1448 https://github.com/eranif/codelite/issues/1448
[2] Does CodeBlocks support C#, 2014 https://forums.codeblocks.org/index.php?topic=18740.0
[3] KDevelop C# Language Support?, 2016 https://forum.kde.org/viewtopic.php?f=218&t=136944
[4] C# in Netbeans?, 2010 https://www.codeproject.com/Questions/85177/C-in-Netbeans