Sorry C#

A place for Ogre users to discuss non-Ogre subjects with friends from the community.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

syd wrote:
blutzeit wrote:No C# is not a dynamic language. It's statically typed and linked just as C++. I have spent numerous years with both and have to admit I love them both.
So...how do you explain the Reflection library, that allow to create types, add methods and so on at runtime?
Reflection does not make a dynamic language. A dynamic language is one that can create code at runtime. Python for example. C# can't do that -- it has to compile code into an assembly and load that assembly.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
syd
Gnome
Posts: 362
Joined: Thu May 01, 2008 1:55 am
Location: Paris, France

Post by syd »

blutzeit wrote:With libtcc/tinyc I belive you can compile and execute C++ in C++, does that make C++ dynamic? ;)
got it :)
so it compiles from inside too. i would never have though of such a thing.
exciting =)
User avatar
syd
Gnome
Posts: 362
Joined: Thu May 01, 2008 1:55 am
Location: Paris, France

Post by syd »

Reflection does not make a dynamic language. A dynamic language is one that can create code at runtime. Python for example. C# can't do that -- it has to compile code into an assembly and load that assembly.
you can create code at runtime in c#, with the CodeDom library :D
okay it's compiled at runtime.
I've just got all that notion of "compilation at runtime", I must say I keep having that amazed feeling :)
jjp
Silver Sponsor
Silver Sponsor
Posts: 597
Joined: Sun Jan 07, 2007 11:55 pm
Location: Cologne, Germany
Contact:

Post by jjp »

syd wrote:I've just got all that notion of "compilation at runtime", I must say I keep having that amazed feeling :)
It has a performance implication as compilation at runtime does one slightly different requirement; it must be really fast. I guess a runtime compiler can't do some optimizations simply because they would take too much time.
Enough is never enough.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

Bear in mind that the entire .NET Framework, CodeDom included, was designed specifically for SOAP XML RPC. In other words, for generating serialization binary code from XML Schema specifications. The fact that it generated actual runnable code modules that could be linked at a command line was really a side-effect, and was put to use in the compilers as well.

The way .NET serialization works is that when you call Serialize() or Deserialize() on an XmlSerializer instance, it looks up an existing serializer assembly for the class in question, or compiles one if needed and maps the class type to that serializer, so that serialization can run as fast as possible. XML serialization parses text XML in .Net in only a few, well-documented cases; for the most part, it's running a binary assembly that was created and loaded at runtime.

So no, C# itself is not a dynamic language; functions, for example, are not first-class objects in C#. CLR ports exist for dynamic languages, however; it's not a limitation of the .Net Framework, it's just not part of the C# design or intent.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
syd
Gnome
Posts: 362
Joined: Thu May 01, 2008 1:55 am
Location: Paris, France

Post by syd »

Bear in mind that the entire .NET Framework, CodeDom included, was designed specifically for SOAP XML RPC. In other words, for generating serialization binary code from XML Schema specifications. The fact that it generated actual runnable code modules that could be linked at a command line was really a side-effect, and was put to use in the compilers as well.
well, Xml is indeed a convenient way to store metadata, but I wouldn't believe that the core of the framework is "designed specifically for SOAP XML RPC"; but that's a detail.

I was just thinking for quite a while about the meaning of a dynamic language.
you talked about python which is a dynamical language because "it generates code at runtime". I'm far from being a Python expert, as I never used it, but I though that it's an interpreted language, just like PHP, Javascript...
In other words a scripted language parsed by an engine that implements smart behavioral patterns, without generating anything really.

The question that pops up then is what is the difference between an interpreted and a dynamical language?
I saw C# as a dynamical language because the Metadata are available and modifiable at runtime. Python, is a scripted language parsed to feed an underlying engine, am I right?
So the whole concept of static /dynamic language can be summered by compiled/interpreted?
To me that concept was more about the availability or not of metadata at runtime. I mean this is how I see it...
TG_Jones
Halfling
Posts: 53
Joined: Thu May 29, 2008 4:05 pm

Post by TG_Jones »

I see most of you confused about the "dynamic" language. I may help.

First of all, nothing called a dynamic and static language. These terms are applicable to libraries, and linking modules.

We classify languages mainly and very basically as follows:

Compiled
Interpreted

Interpretation does not mean compilation at all, otherwise we would classify C or Pascal as interpreted. Java is considered interpreted and it compiles into bytecode, and run by the VM. So what does interpreted imply? I tell you.

Whenever there are two stages or more in the code generation and execution, or in other words, intermediate code involved, then the language is interpreted, whether we liked the term or not.

C/C++ ==> compiled into machine

Java/Python/C# ==> compiled into intermediate language ==> compiled into machine or even executed by VM.

The stop in the middle there for intermediate language is what we call dynamic, because there the language can figure out things such as type safety, ...etc. and scarifies performance of course, and by force, whether it optimizes the final code or not.

Hope this helped.
User avatar
syd
Gnome
Posts: 362
Joined: Thu May 01, 2008 1:55 am
Location: Paris, France

Post by syd »

First of all, nothing called a dynamic and static language. These terms are applicable to libraries, and linking modules.
looking at the description of the D language, it seems that the distinction does exists, and seems related to the types:
The D language is statically typed and compiles directly to machine code
To me, this implies that a "dynamically typed" language provides at least RTTI, and likely Type manipulation at runtime, just like C#.

Edit: I would add, referring to the question if a dynamic language can get as fast as a static one, that D is meant to reach the performances of C++; I believe that they made the choice of static for this reason.

C/C++ ==> compiled into machine
In appearance, C/C++ compiles directly to machine code, but from the dragon book (Compilers: principles, techniques and tools) it is mentioned that internally, a compiler usually converts to intermediate code in order to perform optimizations. now it's all about defining what is an intermediate language =)
A compact language designed to be interpreted at runtime, or an intermediate version of the source meant to be compiled?
The importance of the intermediate language in the Dot Net technologie is, I think, more a matter of a common base to handle many language at the same time.
Java/Python/C# ==> compiled into intermediate language ==> compiled into machine or even executed by VM.
The difference with C# is that it gets finally compiled, there is at first a compilation, linking process and so on. It's specificity is that it's compiled at the last minute into machine code, at the first execution (I think). What makes it similar to interpreted language is that it's dll form (executable maybe also) keep the form of an intermediate language until the compilation at execution.

if there's anything wrong in what I've said, i'm aware it's a possibility =)
and glad to see you finally in the discussion :)
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

syd wrote:
Bear in mind that the entire .NET Framework, CodeDom included, was designed specifically for SOAP XML RPC. In other words, for generating serialization binary code from XML Schema specifications. The fact that it generated actual runnable code modules that could be linked at a command line was really a side-effect, and was put to use in the compilers as well.
well, Xml is indeed a convenient way to store metadata, but I wouldn't believe that the core of the framework is "designed specifically for SOAP XML RPC"; but that's a detail.
It actually is -- it's the primary reason it's called ".Net". ;)
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

TG_Jones wrote:I see most of you confused about the "dynamic" language. I may help.
I don't think it's us who are confused:

http://en.wikipedia.org/wiki/Dynamic_language
Dynamic programming language is a term used broadly in computer science to describe a class of high level programming languages that execute at runtime many common behaviors that other languages might perform during compilation, if at all. These behaviors could include extension of the program, by adding new code, by extending objects and definitions, or by modifying the type system, all during program execution. These behaviors can be emulated in nearly any language of sufficient complexity, but dynamic languages provide direct tools to make use of them.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
TG_Jones
Halfling
Posts: 53
Joined: Thu May 29, 2008 4:05 pm

Post by TG_Jones »

I don't think so, sorry! 8) Wikipedia is a collection of information around, not a reliable reference.

D language? What about E? F G H I J...

C# = ActionScript = Java = JavaScript = "D" = CShell they all borrowed the syntax from C. Why the heck? Cannot they figure out their own syntax?

Anyway again the term dynamic is not applicable to programming language, otherwise an expert IT professional will think you mean something else :D

It happened at one interview that a person started explaining the difference between C++ and Java using dynamic and static...then I had to interrupt him and asked "so the C language cannot allocate memory dynamically? I would call C dynamic then, it can allocate mem, it links to shared/dynamic libs, while Java cannot. :) " Yeah it's confusing I know, but if you have a good reference let me know.

Hope this helped.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

TG_Jones wrote:if you have a good reference let me know.
I just did. I can't help that you won't take a source complete with references as a valid rebuttal to your incorrect claim.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
User avatar
Borrillis
Kobold
Posts: 27
Joined: Mon Sep 27, 2004 5:44 pm
x 2
Contact:

Post by Borrillis »

syd wrote: So...how do you explain the Reflection library, that allow to create types, add methods and so on at runtime?

To me, it sounds like only native types are static, but it's just a speculation...
That is incorrect, all types in C# are static. Reflection is a read-only type inspection API. Emiting code causes the CLR to recompile the type to ensure type safety. There are also rules regarding what you can emit and when as well to make sure that the Code Access Policies are not violated.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 538

Post by Kojack »

To me, this implies that a "dynamically typed" language provides at least RTTI, and likely Type manipulation at runtime, just like C#.
Dynamic typing generally is for languages which don't do type checking at compile time. You don't specify types for variables or function arguments, they change to fit whatever data you give them.
Languages like Ruby and Lua are dynamically typed.
D language? What about E? F G H I J...
D is a great language. The experimental version 2.0 has some cool changes which make it more appealing (improved overloading, struct handling, interfacing to c++, etc).
E is a very fast and powerful language by Wouter van Oortmerssen. It was the first OO language I learned, about 15 years ago. It had a pascal like syntax (but didn't suck), with faetures of C, Lisp, Prolog.
I used J a little bit. It was kind of a more human readable version of APL, made by the creator of APL.
I don't know any F, G H or I languages, but somebody's probably made them. :)
Interpretation does not mean compilation at all, otherwise we would classify C or Pascal as interpreted.
Although some Pascals can go to P-Code, so then we could classify it as interpreted. :)
User avatar
Borrillis
Kobold
Posts: 27
Joined: Mon Sep 27, 2004 5:44 pm
x 2
Contact:

Post by Borrillis »

TG_Jones wrote:I don't think so, sorry! 8) Wikipedia is a collection of information around, not a reliable reference.

D language? What about E? F G H I J...

C# = ActionScript = Java = JavaScript = "D" = CShell they all borrowed the syntax from C. Why the heck? Cannot they figure out their own syntax?

Anyway again the term dynamic is not applicable to programming language, otherwise an expert IT professional will think you mean something else :D

It happened at one interview that a person started explaining the difference between C++ and Java using dynamic and static...then I had to interrupt him and asked "so the C language cannot allocate memory dynamically? I would call C dynamic then, it can allocate mem, it links to shared/dynamic libs, while Java cannot. :) " Yeah it's confusing I know, but if you have a good reference let me know.

Hope this helped.
Not at all, please provide a reliable, verifiable resource for your definitions of Static and Dynamic, Compiled and Interpreted. Unless you can, unfortunately, your word alone is not enough to make your argument. You seem to think that by simply providing us with your twisted defnitions in order to prove your point make it true, yet you require we provide sources to disprove your statements.

sine qua non.
blutzeit
Gnoblar
Posts: 10
Joined: Tue Jun 26, 2007 11:00 am

Post by blutzeit »

The wikipedia article gives a pretty accurate picture of the problems with the term "dynamic language". It's a bit like calling a language "fast". C++ is a "fast" language, right? ;)
User avatar
Klaim
Old One
Posts: 2565
Joined: Sun Sep 11, 2005 1:04 am
Location: Paris, France
x 56
Contact:

Post by Klaim »

About "dynamic" languages, the Dragon book, compilers and static typing etc, this is a (long but) good lecture :
http://steve-yegge.blogspot.com/2008/05 ... -back.html
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 51

Post by madmarx »

1/
sorry people but when I speak with my guys and researchers it's clear that I never say "we need a dynamic langage" or " which static language will we choose for next project".

I just say :
"you should use Prolog. Look for lasts versions and other language with backtracking abilities"
"you would gain productivity if you do that in F#, it's done in 3 lines. But before choosing this one, have a look at OCaml and Haskell : Functional programming is here the deal".
"I want to be able to write behaviours without huge compile. Please have a look at scripting languages."

Of course we never use "dynamic and static" : we talk more instead of saying things that can be bad interpreted (proof is that everyone understand what 's B method, and not the "french refinment language...").

lol
2/
by the way, C# is ok. I think first AAA game was released in 2004. (read it in a mag).
User avatar
epopov
Halfling
Posts: 85
Joined: Tue Jun 10, 2003 2:57 pm
Contact:

Post by epopov »

Somewhat related to this discussion is this interesting article:

Strong Typing vs. Strong Testing: http://mindview.net/WebLog/log-0025
TG_Jones
Halfling
Posts: 53
Joined: Thu May 29, 2008 4:05 pm

Post by TG_Jones »

Just to be within my original post topic.

Do you think ECMA C# specification is really a decent specification? It's merely a quick reference guide, nothing more. Just compare it to Java specification. And one thing I cannot understand, why do we need "override" keyword if we have the function virtual? Make no sense.

C++/CLI sucks too. The are monsterizing the GREATEST C++ Language, by ugly OO Pascal keyword like ^ and %...what the hock? None sense guys come on, give me a break, please, give me a break... :lol:
User avatar
madmarx
OGRE Expert User
OGRE Expert User
Posts: 1671
Joined: Mon Jan 21, 2008 10:26 pm
x 51

Post by madmarx »

I know a language that would please you :
- compilation is direct (no intermediate language),
- can be used to script,
- 7 keywords,
- include full turing machine,
- there are also a lot of tools to parse it (whereas C++ has very few).
You should try it, it's called BF.

:twisted: :twisted:
jjp
Silver Sponsor
Silver Sponsor
Posts: 597
Joined: Sun Jan 07, 2007 11:55 pm
Location: Cologne, Germany
Contact:

Post by jjp »

TG_Jones wrote:Do you think ECMA C# specification is really a decent specification? It's merely a quick reference guide, nothing more. Just compare it to Java specification.
Looking at both specifications I see they are very similar in style and length. Honestly, what do you want? You have so far not made a single valid argument, you are just bringing up one random, uninformed, unsupported claim after the other. I think no one here wants any part of a flame war you are (unsuccessfully) trying to start.
Enough is never enough.
TG_Jones
Halfling
Posts: 53
Joined: Thu May 29, 2008 4:05 pm

Post by TG_Jones »

Yes that's what I said before I want to start a flame war.

None is valid argument? Then you are a C# scriptor upset of what I'm saying.

What do I want? A burger king. :lol:
jjp
Silver Sponsor
Silver Sponsor
Posts: 597
Joined: Sun Jan 07, 2007 11:55 pm
Location: Cologne, Germany
Contact:

Post by jjp »

TG_Jones wrote:None is valid argument? Then you are a C# scriptor upset of what I'm saying.
"Makes no sense" and "Give me a break" are no arguments. And for the rest you could use Google to tell you what the reasons behind the C# syntax are. Every point you made here follows the pattern: it isn't the way I'd expect it to be, it is different from some other language, so it is bad design and makes no sense. That is no way to reason.
Enough is never enough.
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

TG_Jones wrote:Yes that's what I said before I want to start a flame war.
Well, that's not what this forum is for. Locked.
Do you need help? What have you tried?

Image

Angels can fly because they take themselves lightly.
Locked