VB haters, look away
-
Was happy that they finally updated the switch in C# to have be as flexible as the Visual Basic Select Case. Waited a long time for that one.
Why didn't they make it multivariable as well, like in CHILL? switch (a, b, c) { (1, 'a', 4.3): ...code; (2, 'A', 0.0): ...code; (2, ELSE, pi): ...code; (3, 'C', *): ...code; ELSE: ...code; } * for a value means "don't care". ELSE for a value means "any value not used in any other switch alternative for this variable. Yes, you CAN make it very messy if you exploit the flexibility for all that it is worth. But a diciplined use can be far more readable than a 20-way switch, each alternative with a 7-15 way (varying among the 20) switch, each of those again with a 2-15 way (varying) switch. Then I'd rather prefer the single, clean, 3-dimensional switch.
-
I'm reading a C# book that was recommended on here recently and found this gem in the beginning.
Quote:
The truth of the matter is that many of C#’s syntactic constructs are modeled after various aspects of Visual Basic (VB) and C++. TROELSEN, ANDREW; Japikse, Philip. C# 6.0 and the .NET 4.6 Framework (Kindle Locations 3123-3124). Apress. Kindle Edition.
:-\
There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.
-
Medical fact - quitting VB now will greatly increase your lifespan. No citations needed. :-D
Medical fact: Case sensitive languages that also require semicolons at the end of every line and do not know the difference between a functions and a property unless you add () to the end of a parameter-less function drives you crazy within hours. But seriously. I do not understand the rant against *any* language. Especially when it comes to VB.net and C#; they are almost the same languages. See: C# and VB.NET Comparison Cheat Sheet: ASP Alliance[^] I think people can build crappy software and good software in any language. ;P
-
I must say that a statement that says "C# is compiled to a type of bytecode (called CIL)" (my emphasis) makes me somewhat sceptical to the competence of the writer. I doubt very much that (s)he has implemented very many compilers :-)
Those who can, do.. those that can't, teach.. those that can't teach write Wikipedia articles :)
Now is it bad enough that you let somebody else kick your butts without you trying to do it to each other? Now if we're all talking about the same man, and I think we are... it appears he's got a rather growing collection of our bikes.
-
Medical fact: Case sensitive languages that also require semicolons at the end of every line and do not know the difference between a functions and a property unless you add () to the end of a parameter-less function drives you crazy within hours. But seriously. I do not understand the rant against *any* language. Especially when it comes to VB.net and C#; they are almost the same languages. See: C# and VB.NET Comparison Cheat Sheet: ASP Alliance[^] I think people can build crappy software and good software in any language. ;P
I really don't like those feature-vs-feature, mechanism-vs-mechanism, xxyzzy-vs-xyzzy style of comparisons. Looking at each single feature / mechanism / xyzzy in isolation tends to hide their intended use, or established use. It reveals nothing about the "ecosystem" around the language. It allows a Fortran programmer to program Fortran in any language, arguing that (s)he is just using the mechanism provided by the language in a perfectly correct way. Reducing the differences between two languages to mere syntax details can actually be very misleading.
-
I must say that a statement that says "C# is compiled to a type of bytecode (called CIL)" (my emphasis) makes me somewhat sceptical to the competence of the writer. I doubt very much that (s)he has implemented very many compilers :-)
Can you elaborate? I have to say that I agree. Isn't the .NET CLI a type of bytecode?
-
I really don't like those feature-vs-feature, mechanism-vs-mechanism, xxyzzy-vs-xyzzy style of comparisons. Looking at each single feature / mechanism / xyzzy in isolation tends to hide their intended use, or established use. It reveals nothing about the "ecosystem" around the language. It allows a Fortran programmer to program Fortran in any language, arguing that (s)he is just using the mechanism provided by the language in a perfectly correct way. Reducing the differences between two languages to mere syntax details can actually be very misleading.
-
Can you elaborate? I have to say that I agree. Isn't the .NET CLI a type of bytecode?
I haven't been working with compilers for a number of years, so maybe there are younger species out there that do things in a different way - I know the "classical" way of doing it, believing that today's compilers are roughly the same: First, you break the source text into tokens. Then you try to identify structures in the sequence of tokens so that you can form a tree of hiearchical groups representing e.g. functions at some intermediate level, statements at a lower level, terms of a mathematical expression even further down. The term DAG - Directed Acyclic Graph - is commonly used for the parse tree. Nodes in the DAG commonly consist of 3-tuples or 4-tuples in a more or less common format for all nodes: Some semantic / operation code, two or three operands, or whatever else the compiler writer finds necessary. Many kinds of optimisation is done by restructuring the DAG: Recognizing identical sub-trees (e.g. common subexpressions) that need to be done only once, identifying statements that within a loop will have identical effect in every iteration so that sub-tree can be moved out of the loop, etc. etc. Unreachable code is pruned off the DAG. All such operations are done on an abstract level - a variable X is treated as X without regard to its location in memory, number of bits (unless the language makes special requirements) etc. etc. The DAG is completely independent of the word length, byte ordering, 1- or 2-complement arithmetic, register ID or field structure of the instruction code of any specific machine architecture. You may think of variables and locations as sort of still in a "symbolic" form (lots of symbolic labels where never visible in the source code, so this certainly is "sort of"). Once you have done all the restructuring of the DAG that you care for, you may traverse the tree's leaf node to generate the actual machine instructions. (This part of the compiler is commonly called the "back end".) Now you assign memory addresses, use of registers, choose the fastest sequence of machine instructions for that specific machine. You can still do some optimization, e.g. keeping values in registers (now that you know which registers you've got), but it is essentially very local. The DAG indicates which sub-trees are semantically independent of each other, so that you may reorder them, run them in parallell, or e.g. assemble six independent multiplication operations into one vector multiply if your CPU allows. All internal symbolic rerferences can be peeled off; the only symbols retained are exte
-
Guilty. I once dropped the guts of a Fortran program into C#. Worked pretty good. Easier than building an interface in Fortran.
I once worked on a machine whose operating system was written in Fortran! Rumours are that when Nic Wirth were developing the very first Pascal compiler, they started out writing a bootstrap in Fortran. Or, they tried, before realizing that it was easier do do it in assembly code. Another sidetrack: I also worked a littel in a language whose compiler was written in itself, but without using a bootstrap. The compiler author (and language designer) wrote the compiler code "offline", and line-by-line mentally translated the code line into the machine instructions he knew that the compiler would have generated, typing the assebly instructions into the machine and assembled it. You could say that is having a bootstrap in assembly, but it wasn't a simple bootstrap - it was the complete compiler.
-
I once worked on a machine whose operating system was written in Fortran! Rumours are that when Nic Wirth were developing the very first Pascal compiler, they started out writing a bootstrap in Fortran. Or, they tried, before realizing that it was easier do do it in assembly code. Another sidetrack: I also worked a littel in a language whose compiler was written in itself, but without using a bootstrap. The compiler author (and language designer) wrote the compiler code "offline", and line-by-line mentally translated the code line into the machine instructions he knew that the compiler would have generated, typing the assebly instructions into the machine and assembled it. You could say that is having a bootstrap in assembly, but it wasn't a simple bootstrap - it was the complete compiler.
-
[Anders Hejlsberg - Wikipedia](https://en.wikipedia.org/wiki/Anders\_Hejlsberg) - he didn't work for Sun but he worked on Microsoft's J++ language.
Quote:
In 1996, Hejlsberg left Borland and joined Microsoft. One of his first achievements was the J++ programming language and the Windows Foundation Classes; he also became a Microsoft Distinguished Engineer and Technical Fellow. Since 2000, he has been the lead architect of the team developing the C# language. In 2012 Hejlsberg announced his new project, TypeScript, a superset of JavaScript.
Now is it bad enough that you let somebody else kick your butts without you trying to do it to each other? Now if we're all talking about the same man, and I think we are... it appears he's got a rather growing collection of our bikes.
And this move KILLED Borland. Anders was the key behind Delphi, which I still use and enjoy. He made Delphi and C++ Builder produce interchangeable object files (compile in one, use in the other), which also helped him with C# and VB. Same trick. I used to have a Quick XXX and a Turbo XXX of just about everything back in the day. $99.00 bought you a lot! Dang I feel old...
-
There we go. The index values range from 0 to (n-1), as they should. Now at which point did they start with 1? Every early home computer had a BASIC interpreter in a ROM, which in most cases was a customized Microsoft BASIC. Atari developed the BASIC from scratch, and was zero based. Look here.[^] It has been some time since I used that manual, but I should still have it somewhere. :-)
You may have misread the spec; page 38 says it's 0 to n inclusive. I expect that's why so many developers chose to use 1 to n inclusive and ignore element zero. Show me a BASIC implementation that has 1-based indices (by default). I have never encountered one. I do see that Turbo BASIC has an OPTION BASE statement that allows a developer to choose to differ from the default of zero. Turbo BASIC also extends the DIM statement to allow the developer to specify a range, similar to Pascal --
DIM b(50:60)
. But the default behaviour is for 0 to n inclusive. -
To me, as a mathmatically inclined person, it really hurts taking the elevator in our new office building down to the basement: It goes: 4, 3, 2, 1, -1 ...!!! HEY! You dropped something! There is supposed to be something in between there! I am equally upset about Christian churches - I don't know if it applies to all, but at least the Protestants in Europe and the Catholics officcialy number years "..., -2 (i.e 2BC), -1, +1, +2...). There are years before Christ and years after Christ, but no year "of Christ", i.e. the year of of his birth. This hurts my mathematical feelings.
Year Zero is a also a Leap Year. :-D
-
And this move KILLED Borland. Anders was the key behind Delphi, which I still use and enjoy. He made Delphi and C++ Builder produce interchangeable object files (compile in one, use in the other), which also helped him with C# and VB. Same trick. I used to have a Quick XXX and a Turbo XXX of just about everything back in the day. $99.00 bought you a lot! Dang I feel old...
Yep, I remember using C++ Builder back in the 1990's - it was a demo application I wrote in C++ Builder that landed me my first professional programming job (after spending about 12 years in electronics) :)
Now is it bad enough that you let somebody else kick your butts without you trying to do it to each other? Now if we're all talking about the same man, and I think we are... it appears he's got a rather growing collection of our bikes.
-
You may have misread the spec; page 38 says it's 0 to n inclusive. I expect that's why so many developers chose to use 1 to n inclusive and ignore element zero. Show me a BASIC implementation that has 1-based indices (by default). I have never encountered one. I do see that Turbo BASIC has an OPTION BASE statement that allows a developer to choose to differ from the default of zero. Turbo BASIC also extends the DIM statement to allow the developer to specify a range, similar to Pascal --
DIM b(50:60)
. But the default behaviour is for 0 to n inclusive.PIEBALDconsult wrote:
0 to n inclusive
Ok, but what's the reasoning behind that? You dimension an array to n elements and get an array with n + 1 elements. This really is interesting. Back in the day I did not use BASIC very much. The interpreters were too slow, especially for graphics. When finally a C compiler fell into my hands (on the Atari ST), I never looked back. The whole thing sounds like a misunderstanding that came when everyone and their dogs started to write BASIC programs on their TRS-80s or later on their C64s.
-
I haven't been working with compilers for a number of years, so maybe there are younger species out there that do things in a different way - I know the "classical" way of doing it, believing that today's compilers are roughly the same: First, you break the source text into tokens. Then you try to identify structures in the sequence of tokens so that you can form a tree of hiearchical groups representing e.g. functions at some intermediate level, statements at a lower level, terms of a mathematical expression even further down. The term DAG - Directed Acyclic Graph - is commonly used for the parse tree. Nodes in the DAG commonly consist of 3-tuples or 4-tuples in a more or less common format for all nodes: Some semantic / operation code, two or three operands, or whatever else the compiler writer finds necessary. Many kinds of optimisation is done by restructuring the DAG: Recognizing identical sub-trees (e.g. common subexpressions) that need to be done only once, identifying statements that within a loop will have identical effect in every iteration so that sub-tree can be moved out of the loop, etc. etc. Unreachable code is pruned off the DAG. All such operations are done on an abstract level - a variable X is treated as X without regard to its location in memory, number of bits (unless the language makes special requirements) etc. etc. The DAG is completely independent of the word length, byte ordering, 1- or 2-complement arithmetic, register ID or field structure of the instruction code of any specific machine architecture. You may think of variables and locations as sort of still in a "symbolic" form (lots of symbolic labels where never visible in the source code, so this certainly is "sort of"). Once you have done all the restructuring of the DAG that you care for, you may traverse the tree's leaf node to generate the actual machine instructions. (This part of the compiler is commonly called the "back end".) Now you assign memory addresses, use of registers, choose the fastest sequence of machine instructions for that specific machine. You can still do some optimization, e.g. keeping values in registers (now that you know which registers you've got), but it is essentially very local. The DAG indicates which sub-trees are semantically independent of each other, so that you may reorder them, run them in parallell, or e.g. assemble six independent multiplication operations into one vector multiply if your CPU allows. All internal symbolic rerferences can be peeled off; the only symbols retained are exte
That was a lovely, clear and comprehensive elaboration. Thank you (assuming of course, that it is correct!).
-
Funny, C# was modeled mostly after Java and C++, but no one ever mentions the Java part.
C# is Java with all the stupid sucked out.
-
Who cares as long as they don't model anything after time honored VB practices. Variants, anybody?
Oh, you mean boxing? Because that is exactly what VARIANT does in COM and VB....
-
It looks like it was more of a legal thing with Sun.. from 2002, [Sun, Microsoft settle Java suit - CNET](https://www.cnet.com/uk/news/sun-microsoft-settle-java-suit/)
Quote:
A Microsoft representative said the dispute lingered for too long. "We don't think anyone wins, but considering the lawsuit has been ongoing for three years, this is a good conclusion to this controversy," said Microsoft spokesman Jim Cullinan. With the deal struck, Cullinan said Microsoft will be allowed to continue to offer its existing Java products, including its popular J++ development tool, for the next seven years. Microsoft product manager Tony Goodhew said the company will include J++ as a separate CD with the next version of Visual Studio.
Now is it bad enough that you let somebody else kick your butts without you trying to do it to each other? Now if we're all talking about the same man, and I think we are... it appears he's got a rather growing collection of our bikes.
Brent Jenkins wrote:
It looks like it was more of a legal thing with Sun
One of the points of java was that you were supposed to be able to run it on any VM on any supported OS. Microsoft made specific changes to their java that made it impossible to run on different VMs or even compile. CNN - Sun alleges new Java violations by Microsoft - July 13, 1998[^]
-
I'm reading a C# book that was recommended on here recently and found this gem in the beginning.
Quote:
The truth of the matter is that many of C#’s syntactic constructs are modeled after various aspects of Visual Basic (VB) and C++. TROELSEN, ANDREW; Japikse, Philip. C# 6.0 and the .NET 4.6 Framework (Kindle Locations 3123-3124). Apress. Kindle Edition.
:-\
There are two kinds of people in the world: those who can extrapolate from incomplete data. There are only 10 types of people in the world, those who understand binary and those who don't.
I always considered C#'s syntax moving backward in programming language design. Really, the only reason it exists is to appeal to legacy C and C++ programmers and programmers of any other language built on that ancient syntax like Java. People too lazy to learn a better, more modern syntax designed for more modern IDEs and compilers. Visual Basic is far more elegant and intuitive in it's syntax. Simple things like using "End While" or "End Function" rather than generic "}" lets you quickly see what functional block is what. LINQ is another example of being far more elegant in VB. I don't doubt that quote in the slightest.