It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
Let's define languages like c,c++,java as code
Python,PHP as script.
Is c# code or script, and reason?
The most similar language to C# from your list is Java, so if you think Java is "code" then I guess C# is too.
But the idea that languages can be divided into "code" or "script" is a huge oversimplification in my opinion. For example, PHP can be either interpreted or compiled. Java can be compiled to bytecode which is then interpreted, or it can be compiled directly to native code. Python can be useful for small "scripting" tasks, but it can also be used to write enterprise class web applications.
C# is a compiled language like java, C, and C++. C# is code
C# is code, compiled and strongly typed, very similar to Java in that respect.
C# is compiled to an intermediate language (MSIL), which in turn is compiled to machine code on a just-in-time basis.
By that definition, it's "code" - as it's compiled, where as PHP / Python are interpreted at run time.
Code - you compile C# code into binary executable files.
C# is code (along with C, C++, Java, etc.). It gets compiled to CIL and then JIT compiled to machine code when you run the application.
Scripting languages are interpreted as they run. Think of Javascript running in the browser. As it is executed, it is interpreted by the Javascript engine that is executing it.
Code.
Scripts can be interpreted (compiled) on the fly at runtime. C# can't (well, that can and may change one day).
C# is a .NET programming language, quite similar to Java.
I don't understand the purpose of your question.
C# would be closer to Java than C or C++. But it's not a script language that is run through an interpreter like PHP. But it's not a purely compiled language either, like C/C++ typically are. C/C++ are compiled down to machine code that is executed directly by the CPU it's compiled for. C# and Java are compiled down to an intermediate language (MSIL and Java byte code respectively) and are then run by a VM which usually JIT compiles it to the final CPU code.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have a Delphi program consisting of mostly Visual Interface(Buttons, TextBoxes etc.) and a little bit business logic.
The business logic is mostly included in Pl-Sql of Oracle Database running by Delphi.
I want to carry the project in Delphi to C Sharp but i want to do this part by part.
What i think is to create a C Sharp project in Visual Studio and to run it with Delphi code(including Visual Interfaces) and part by part replace the code and the Visual Interface in Delphi with C Sharp.
Is it possible?
Mixing Delphi and C# GUI in the same application is possible, but hard to achieve. You'll need to set up a whole infrastructure to organise interop between the two languages. You'll end up creating a huge amount of interop code that you will subsequently abandon. Even worse, the interop code will need to be two way. You'll sometimes have C# visual code talking to Delphi non-visual. And vice-versa. The idea of converting the code module by module sounds good, but I predict it will entail vast amounts of interop scaffolding.
It would be easier to slice it along the visual/non-visual divide, but that's not what you are proposing. So frankly I think your current plan is far from optimal. I would not entertain it. I think a clean port is the best option.
Remobjects Hydra seems to be exactly what you are looking for.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
how to create a file DLL, so all language dev can used it
i think, if use C++ to created , then language .Net can used it.
however, how about JAVA ??? and a few other language
The only guaranteed way to make a DLL that is consumable by other platforms and languages is to write it a language/platform that exports static C functions; the easiest way is to write in C and C++ directly, though other languages can too. That way you can call it from C, C++, .NET/C#/VB (using DllImport P/Invoke), and Java (using JNI). Other languages also support importing C functions.
(Generally) you cannot export classes or other types. If your C functions use structs then you must document those in a header file or other definition for your DLL's consumers to use.
There are other approaches, including COM (which supports exporting interfaces and other types) and the new WinRT Metadata format, but this is new and has not seen wide deployment. And COM is an exercise in pain.
Java and other languages other than C#, C, and C++ can't use dlls made as C code. They're completely different languages, with Java using a Java Virtual Machine to run just-in-time bytecode, and Ruby/Python/other scripting languages using an interpreter. In fact, dlls themselves are only part of C/C++/C#. C# only is able to use C/C++ dlls because Microsoft intended compatibility.
On the other hand, you might try creating wrappers so other languages can use the code you created.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
So this is the situation right now:
I have a C# GUI project combined with a C# Engine project in the same solution. The GUI allows interaction with the user, some high level stuff etc. The functionality of the Engine is to communicate with another third-party application. The Engine has sockets that connect to the third-party application as well has methods to convert a message into an object, send it to the third-party application, and listen for a response from the third-party application and react accordingly. Data to be communicated between the Engine and the Third-party application are packaged into objects.
The problem with the C# engine is that it's too slow. So the idea is to convert the engine to unmanaged C++ for speed.
This is my plan of attack:
Translate the entire C# engine by hand into C++ (which is already pretty daunting because the C# engine includes threads and hashtables)
Have the following to substitute for constructors, accessors, and mutators in C++:
void* CreateInstance()
{
MyClass* p = new MyClass();
return p;
}
void ReleaseInstance(void* pInstance)
{
MyClass* p = (MyClass*)pInstance;
delete p;
}
int GetData(void* pInstance)
{
MyClass* p = (MyClass*)pInstance;
return p->GetData();
}
void SetData(void* pInstance, value)
{
MyClass* p = (MyClass*)pInstance;
p->SetData(value);
}
(The reason why I can't use real classes in C++ is because you can't instantiate C++ objects in C#)
Then build a C++ unmanaged DLL, use P/Invoke within the C# GUI project ([DllImport etc.]) to access all the C++ methods, and use that to replace the C# engine. Objects will be simulated using methods and passed back and forth between the C# GUI and C++ Engine.
Before I embark on this time-consuming task, is there any C# code that would be impossible to translate into C++ and then re-imported back into the C# GUI through this method?
There's not going to be any C# code that's impossible to translate into C++. You might want to look into if there are any library functions in .NET that aren't covered by the C++ libraries you'll be working with, though. Make sure you aren't getting stuck with any wheels to reinvent.
That said, in my practical experience real-world C++ code is not naturally faster than real-world C# code. It's true that a C++ programmer has more available tricks that can allow them to get better performance, but the effort involved in getting to that point can often be quite formidable. Consider the famous case of the competition between Rico Mariani and Raymond Chen. The advantage Chen's final version enjoyed over Rico's was ultimately down to just the time the .NET run-time needed to bootstrap itself. That's a bit of overhead that's negligible for a longer-running process.
So I would strongly encourage you to try spending some time with a performance profiler to see why the C# code is slow first, and what you can do to speed it up. It may very well be that by going that route you can get the code running fast enough for your needs with a fraction of the effort. It's amazing how impressive you can look just selecting better data structures.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I am assigned a project in which there are two parts :
Database Programming
Game Programming
I am incharge of Database programming and my partner the later. But I am friendly with C-sharp Database programming as it is very efficient using Visual Studio. But he has a Game experience in C++.
Our target system is Windows 7,database will be Sql Server Database, and game can be in C or C++.
We will have a link in Windows forms that starts the Game.
How do we solve this problem without changing our partners?
From a technical point of view it is possible to write a project in multiple languages. From a practical standpoint it is not a good idea.
If this is a small project that will not be enhanced and will be write once and forget then it is fine, otherwise not.
You don't necessarily need to change partners, one of you just needs to step up and say they will jump the learning curve. As a programmer you need to be able to work in whatever language is required.
There are many factors that decide which language/library to use. Write them down with the pros and cons and decide which makes the most sense for your application. Agree that once this is settled then the topic will not come back up. Maybe find an neutral arbitrator that you can both elect to decide for you.
A partner is more than their ability to write code in a given language. The coding part is a small part of the project.
I suggest looking at Managed c++ and the /clr compilation switch for c++. Using managed c++ you can expose what you need to the .net world using .net objects where appropriate, but use native c/c++ code internally.
Managed c++ also have alot of ways to integrate efficiently with .net, such as object pinning (no relocation by the gc)
c++ compiled with /clr can be consumed from any .net language like a regular .net assembly. c++ code compiled this way can also consume any .net assembly much like the other .net languages do.
You haven't provided much details about this game but can't you Process.Start the Game from your WinForms application and passing it the necessary parameters that you fetched from the database?
Another option would be to wrap the database in a COM object developed in .NET that the game, if written in C++ can consume.
I am working on a project right now (and recently completed a similar one) that combined C#, and C++ libraries using C++/CLI. The data collection and signal processing were all written in C++ (your game piece) and the forms, xml and plotting was all done in C# (your db piece). C++/CLI handled the impedance mismatch between the two languages. I actually ended up writing little more than a mediator class in C++/CLI (I find it much more pleasant to write in C#). I think this would work for you too. The only issue is that C++/CLI is not C++. In fact I would suggest that the C# programmer learn C++/CLI rather than the C++ programmer. My reasoning is that syntactical differences between the languages are rather trivial and the C# programmer can probably learn those faster than the the C++ programmer coming to grips to what managed code and .NET is all about. That said, if you both took responsibility for the C++/CLI piece you would have all the skill sets needed to tackle it with the minimum amount of pain.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have always had an interest in coding, and a while back a started to learn C#. Since I only do this as a hobby, i have been learning it very slowly and don't know too much yet, but when I started to read about C++ and how it runs closer to the OS, I started to wonder if I should start learning C++ instead. I know html and JavaScript pretty well and to me C# seemed to be somewhat similar to js, so it wasn't to hard. I just downloaded C++ Express and noticed it is in a very different style than what I'm used to. I'm wondering if I should stick with c# or try c++ (especially if I want to start playing with Arduino sometime in the future). What are some advantages/ disadvantages to both?
As a person who has done all of these languages professionally, I would say that C# is probably the easiest to learn while still being very powerful. There is a lot of help for the .NET platform both from the libraries standpoint and from the community as well. Unless you really want to get down and dirty with a language, stick with C#.
The bigger answer, however, is "it depends". If you are looking to learn a language for the sake of learning one, C# is the way to go. However, if you are thinking about possibly using this new skill in a job setting, look for what type of job you want and decide from there. If you are looking to build applications for yourself and your friends, stick with C#. You can build a Winforms app in about five minutes and you can scale to larger and more professional apps easily from there. C++ will be much more difficult to do the same with.
Coming from Javascript, I would probably recommend staying with C# if you don't want to get down and dirty with details. It will take care of memory management and several other low-level concerns that C++ makes you deal with manually, so it's a little less of a shock to go from an interpreted scripting language like Javascript or Python or Ruby to C#. It's kinda half-way between them and C++.
That said, if you want to learn more of how programming languages and computers in general work, go for C++. It's more complicated than C#, but learning C++ very well makes any language you learn after that easy. Plus with C++, there's virtually no limit to what you can do (C# imposes a few limits), and you pretty much have the entire computer with all its speed and resources at your disposal.
That said, C++ usually takes longer to do the same thing in. For instance, creating a Windows application with a GUI and everything would take a considerable amount of time in C++, but in C# it's trivial. It's a tradeoff you have to deal with, but like I said, if you learn C++ first, C# is cake. The converse is not necessarily true though.
If you want to work with Arduino, go for C++ (never worked with Arduino but the code snippets looked like C so..). C++ is very similar to C, and most C will compile as C++ with very little modification.