As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Today the Common Language Run Time Supports Many Languages including Iron Python and Iron Ruby. We can similarly can use J Ruby and J Python in Java Run Time environments . If so why the .net frame work common language run time cannot support for Java? Um just curious to know though u may see this as a dumb question .
The CLR was actually designed so that it could do everything required to run Java. (Indeed, there are some warts in the way IL is defined which are there specifically for compatibility with Java.) You just need a way of converting bytecode to IL, or compiling from Java source code to IL. J# was one way of doing this, but the limitation of using Java 1.1.4 was a pretty huge one.
I suspect the reason for not going further wasn't an issue with running Java as a language, but the fact that system libraries would need porting. If you were willing to write Java-like source code but target .NET framework libraries (and only .NET framework libraries), with a version of the JLS which switched java.lang.String to System.String etc, it would be doable. I don't think there'd be much benefit though, when C# is simply a nicer language in almost all ways.
You may be interested in looking at IKVM.NET though - an implementation of Java running on the CLI.
First of all, Java may only be called Java if it compiles to JVM bytecode and runs on a certified JVM (iirc), those were the reasons behind Microsoft's efforts being named J++ and J#.
Then there is still J#, which is something close to Java, running on the CLR.
Then there is IKVM which is an implementation of a JVM and the class library on top of the CLR.
Actually, the class library might be the most annoying thing in this case. J# comes with an own library containing the Java core classes just for that purpose and the language closely ties in with that class library (just as it does in .NET).
The final thing though is probably: Why bother at all? Java itself would be a sub-par language on the CLR, where careful effort is needed to recreate things like its not-actual generics. Due to this interoperability with other CLR languages will likely be limited, too. There are powerful translators from Java to C# if you have a large Java codebase and want to use .NET, but a CLR-native Java, compatible with SuOracle's would be a lot of effort for something that you'd only want to touch for compatibility purposes and which poorly interfaces with the CLR or other .NET languages.
CLR does support J#. In an utopian world CLR should have supported C# and Java, but Java is a competitor to Microsoft's C# and hence it won't support Java.
The way I see it, C# is a superset of Java, so you should technically be able to compile a Java class to CIL.
As others have pointed out, Microsoft has no intention of supporting their competition, however I see there have been some projects, such as Ja.NET, to compile Java code to the CLR. There's also IKVM.NET, which among other things seems to be able to translate Java bytecode to CIL, and includes the Java class library from OpenJDK compiled to .NET.
The respective Virtual Machines act on Intermediate Code in a different language (CIL for .net), and IL for .net and JVM are incompatible with each other.
The IL and Runtime features sometimes disallow a few things, for example Generics in C# are closely tied to how Generics in the .net Runtime work, while Java has a completely different implementation.
Still, there shouldn't be much technically preventing Java from running on .net, just no one did it yet. It's a massive effort, for what? Is there really enough money to make? If there is a business, someone will do it. But if you're in the business of Java, then most likely you are also tied closely to it's tools and environments, e.g. Eclipse and Tomcat, possibly Ant and Maven.
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm looking for general opinion about which language would be best. Best in regards to many considerations.
I have a pretty strong background in c, c++, and objective-c. I feel quite comfortable with those 3. I have used very little c#. I've worked in firmware and middleware for over a decade and have moved into mobile apps lately. Mostly iOS, but now expanding to Windows RT.
I am about to write a version of my company's app for Windows Store (or Metro depending on what you want to call it). I did a proof of concept a couple months back using C++/CX. There were are few hurdles learning it (the syntax for ref classes, and the heavy use of namespaces), but that is in the past and I feel quite comfortable with it at this point.
Some drawbacks that I found were that most of the examples (both MSDN and private) of .net are in c# with fewer in c++. It also seemed to be a little tougher to get questions answered concerning .net frameworks with c++. Most of the time people would post a c# answer and I'd need to port it to c++ equiv. Sometimes this is easy, sometimes more difficult.
My question is: Would it be worth my time and my company's time to start over with c# instead of continuing in c++? I'd need to pick up c#, but I don't consider that a huge burden (actually looking forward to it). Some concerns are:
* Acquiring an more engineers down the road to work on this code. Our company will grow shortly. Will it be easier to find an engineer that knows c# vs MS's specialized c++/cx?
* Ease of getting help though examples, articles, and forums. If c# is much more common, that's useful.
* Compatibility between 3rd party libraries (Seems like WinRT components can be used from any of the main languages)
* Advantages of C# over C++? They both offer everything I need for this app, at least that I can see. What are some pitfalls of C#?
* Does c# use the continution/lambdas for asych programming in the same manner as C++/CX?
Are there any other pros/cons that I'm not thinking of?
What do YOU think? Also, what do YOU have experience with? Why do you back your answer?
C# would have the better online support (code examples, answers to questions), and the stronger base of engineers. I mean that in this specific situation, for this kind of strongly Microsoft APIs reliant software development. Windows Store highly important in Microsoft's overall strategy and C# is more important in their language strategy than C++. Thus, C# is the right fit, IMO.
*EDIT (Filip Skakun) I know reopening the question might be hard, so I can't answer it separately but I typed in all this text that could be useful, so I thought I'd add it below:
It is up to you to decide of course and it might be a very subjective choice depending on what you believe in, like if you think the higher potential productivity and better tooling and documentation support of C# outweighs the benefits of a faster, closer to the metal and (slightly subjectively) more portable C++ that you already know. C++ is still almost twice as popular as a language based on the tiobe index, so getting C++ developers might be easier than C# ones. C++/CX is something you only need to use for cross-assembly communication and talking to the WinRT library, but anything else you code should be done in the standard C++ based on all expert recommendations. Also note that C++/CX is not a managed language and you don't use it with .NET. It is highly similar in syntax though to C++/CLI which is a managed language. The good thing about WinRT is that you can use both languages if you want or need to. I use C# for all the XAML UI, networking, business logic etc. There are tons of samples for using C# with XAML while limited range of ones for C++ since it only became available and recommended for XAML platforms with WinRT. On the other hand for anything lower level like working with DirectX or CPU intensive tasks I use C++, since there is more documentation for straight DirectX than the open-source .NET wrappers for it and it performs better when you want to squeeze out all the potential power of the CPU or use the least energy from the battery.
C# is a bit cleaner language than C++ with less punctuation, the new async/await keywords that make async calls (which you must use in Windows 8 apps) a lot cleaner. It is also a managed language so in most cases you might not need to care about when memory gets released, about buffer overruns etc. Debugging C# code yields more deterministic results than C++ (I just spent 2 days debugging some C++ code and I still don't know how far along I am in finding the bug). It is also easier to maintain legacy code since debugging is so much easier.
C++ is faster, so it also uses less battery, your application will start faster and possibly use less energy. If you already know it well then you might have an advantage over the managed development crowd building apps out there. Because it doesn't use garbage collection - memory management is more deterministic and lightweight, so your animations will be more fluid.
Then there is also the motivation factor. If you really want to learn C# - you might be more happy, motivated and productive learning C# than the language you already know and will happily spend more hours learning it than you would be willing to spend writing another C++ app.
The underlying WinRT libraries are the same regardless of which language you use, but the .NET libraries are only available in .NET code and the standard C++ libraries are only available in native code.
Finally - regardless of what decision you make - you can always mix both languages. That could add to maintenance costs since whoever maintains the code in the future might need to know both languages and also the mixed language platform is very young, slightly less supported by the tools (you can't do mixed managed+native remote debugging for example) and potentially more buggy. It is a very good choice in many cases for the reasons I stated earlier though.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm a teacher(instructor) of CS in the university. The course is based on Cormen and Knuth and students program algorithms in C++. But sometimes it is good to show how an algorithm works or just a result of task through GUI. Also in my opinion it's very imporant to be able to write full programs. They will have courses concerning GUI but a three years, later, in fact, before graduatuion. I think that they should be able to write simple GUI applications earlier. So I want to teach them it.
How do you think, what is more useful for them to learn: programming GUI with QT or writing GUI in C# and calling unmanaged C++ library?
Update.
For developing C++ applications students use MS Visual studio, so C# is already installed. But QT AFAIK also can be integrated into VS.
I have following pros of C# (some were suggested there in answers):
The need to make an additional layer.
It's more work, but it forces you
explicitly specify contract between
GUI and processing data. The border between GUI and algorithms becomes very clear.
It's more popular among employers. At least, in Russia where we live. It's rather common to write performance-critical algorithms in C++ and PInvoke them from well-looking C# application/ASP.Net website. Maybe it is not so widespread in the rest of the world but in Russia Windows is very popular, especially in companies and corporations due to some reasons, so most of b2b applications are Windows applications.
Rapid development. It's much quicker
to code in .Net then in C++ due to
many reasons.
And the con is that it's a new language with own specific for students. And the mess with invoking calls to library.
It is better to familiarize students with Qt, as Qt is actually C++. C# is a completely different beast, and if you use C#, you will very likely get your students confused about what things are Microsoft- or C#-specific vs. what is actually defined in the ISO C++ standard, whereas this will be more obvious with just C++. Moreover, Qt and C++ are portable, so your students who are using Mac OS X or Linux will thank you for choosing a cross-platform framework (Qt also works on Windows); whereas, if you use C#, you will force your students to use Windows (yes, there is Mono, but it doesn't work nearly as well as Qt does across platforms).
You might also be interested in using my C++ Project Template which provides sufficient infrastructure for devleoping a Qt GUI application in C++ using CMake, and has been tested and verified to work under Mac OS X and Ubuntu Linux (and, if I get feedback on Windows, I will ensure it works there too). The template includes code that brings up a "Hello World" GUI in Qt when run with the "--gui" commandline option.
I would recommend Qt simply because it is C++, and not C#.
Interfacing between C++ and C# can be messy, and in my opinion would distract students from the object of the exercise (the algorithms, as you said).
Qt -- P/Invoke to use a C++ library from C# adds a whole 'nother layer of nonsense you don't want to even think about. If you were going to use .NET, it might be worth considering using C++/CLI, which linking managed and native code much easier.
I would use C# for the GUI stuff.
There are way more C# jobs out there than C++ using Qt, so why not prepare them for what they are most likely to encounter after they graduate?
One problem I have seen with academia quite often is not teaching what is used in the real world. Sure, all that other stuff is cool, and I personally like it. Experience of real world use after school would be my priority though.
Also, I don't think asking a bunch of programmers is generally the best source of advice on this subject. I would look at what technologies most companies are hiring for in your location, very likely for most desktop GUI stuff it will be .NET or Java.
writing GUI in C# and calling unmanaged C++ library because VS is a good starting IDE and .NET is the most comprehensive set of libraries available. This assumes your students have access to Windows computers. If they are on linux, QT would be the way to go.
Here's a wild idea, (re)write the algorithm in C# for the GUI app. This serves too purposes, 1) it neatly sidesteps the whole mucking with P/Invoke, C++/CLI or COM just to draw some pretty pictures and 2) unlike using Qt it gives you the opportunity to emphasize the distinctions between an algorithm, a program and a programming language.
I don't think it makes any sense to start creating C++/C# unmanaged/managed hybrid applications here.
For teaching it will certainly be easier if the students don't have to learn a new programming language for the Gui. Also interfacing between managed and unmanaged code and the different types in the different languages will complicate things unnecessarily. Much time and effort will be wasted on these topics, not helping anybody to learn the algorithms that are the topic of the course.
Also for "real life" usefulness I think it's clear that only very few projects will use a C++/C# hybrid. If you do your GUI in C# you will also do the logic behind it in that language. I don't see what would be gained from creating the GUI of a C++ application in C#.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I've been getting into compiler creation. I've found some terrific beginner stuff and advanced stuff but nothing in the middle. I've created 3 different simple proof-of-concept compilers for toy languages but I want to expose myself to something real.
The most straight forward real language in terms of syntax seems to be C. Since the language I'm most comfortable with right now is C#, I'd love to study the source code of a real non-tutorial C compiler written in C#. Does one (with source code available) exist?
Ideally I'd like a C compiler, not a .NET or C# compiler, but with the source code written in C#.
I know C# --> C feels a little backwards but it'll allow me to ease deeper into compilers starting with a familiar language before I go changing that too.
Although I'm not looking for C#/.NET compilers, here are some in case someone sees this question who is looking for that:
Create a Language Compiler for the .NET Framework
Mono C# Compiler
Source for a C# compiler written in pure C# (.NET v1) (thanks Luiscencio)
You are going to have a hard time finding sample code. Compiler writers use bootstrapping. The first C compiler was written in B. Which was then used to write the first C++ compiler. Which was used to write the C# compiler. Which is very commonly used to write compilers for managed code.
This is not a process that ever goes backwards. Although side-ways was common, C compilers often were used to cross-compile a compiler for another operating system.
I think I used this book, it has terrific C compiler code in the appendices. Written in C. I used parts of it when writing a Basic compiler I needed in a large project. The expression parser is hard to get right, it has an elegant solution for the operator precedence rules.
Targeting a managed language is the easier way to get this going. The language shouldn't matter too much, it is getting it working that is the real challenge. Even though it is a lot easier to get managed code working. If you want to target C, you'll need black-belt machine code skillz and deep insight in the object file format and the linker.
The most straightforward real language in terms of syntax seems to be C.
I'm not sure what you mean by "real language", but whatever "real language" means, I cannot agree that C has a "straightforward" lexical or syntactic grammar, and its semantics are underspecified. If you want an extremely straightforward language with pretty well-defined semantics, why not go for Scheme? Scheme has a very easy grammar but is certainly not trivial to get its semantics right.
found this via google.
http://blogs.msdn.com/jmstall/archive/2005/02/06/368192.aspx
EDIT: and this (not exactly C):
http://msdn.microsoft.com/en-us/magazine/cc136756.aspx
I don't know of one that exists, but there's no reason one couldn't, or shouldn't.
Writing a compiler for a C-like language is a classic project for one-semester college compiler courses. If you know C# already, it provides a lot of features which will make your job easier than when I was in college! There are plenty of libraries sitting around which will make the job easier, without taking away the challenge, and you can always replace them with your own ad-hoc code if you need flexibility they don't provide.
The first C compiler was written in BCPL because it's what they had. Current C compilers are usually written in C because they aim to be portable. I don't think anyone would argue that C is a good language for writing compilers in. (C# isn't perfect but it's a lot better!) In a statically-compiled language like C, I don't think you get much benefit, if any, from using the target language to write the compiler.
A compiler in an HLL potentially has many advantages. It'd be shorter and simpler than one written in C. That alone could make a lot of things sufficiently easier that they could be pulled below the threshold of "too hard that nobody's ever going to do them". (GCC is kind of the poster-child for how a compiler written in a LLL can be so complex that it moves at a glacial rate.) Optimizations are basically graph transformations, which aren't exactly C's forte.
I don't consider it "backwards" at all to use C# to compile C. Unless somebody's proposing to rewrite all their C code in a higher-level language, it still needs to be compiled somehow, and that means you need a compiler. Shouldn't that compiler be written with tools that enable it to offer the best reliability and performance?
Good luck! I look forward to seeing what you write!
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 13 years ago.
I want my code to be as secure as possible.
I do not think that the security of your source code is a good reason to choose between C # and Delphi. if you create an .Net executable you can protect it with a tool like .Net Reactor, on the othe hand the win32 executables are by definition very difficult to disassemble (get the original source code) unless you include debug information in them.
You should compare other features, in my opinion you should use the language with which you feel more comfortable and you have more skills.
In my case it always chooses delphi, because it has an excellent and fast compiler and thousands of third party components and in addition to generating executables without dependencies. ;)
You can check this question
What language or RAD IDE do you recommend for building shareware?
Also you can check this list of applications built with Delphi
Good Quality Applications Built With Delphi
Among them Skype, TOAD, FL Studio.
It depends on your needs. But in the absence of additional information: If it's a shareware program, I'd go for Delphi, mainly because it compiles into relatively small and fast native code executables.
Should you be concerned about modern (Delphi 2010) apps being less secure than older ones because of the new, enhanced RTTI - that can be turned off with a compiler switch.
Delphi is your best choice for shareware software : you can distribute your app in a single exe file , you can embed whatever resource you want to : html pages, images, even your dbserver (look for firebird embedded).
Lots of shareware software was developed with delphi : EMS products (EMS SQL Manager for MySQL, IB, Oracle...), Skype, 7zip...
Have fun with DELPHI
Best Regards
Deleting this because everyone is down arrowing my response simply because their opinion is different than mine. It was an answer to his question, but an unpopular one, so people decided to start taking points away from me.
That's not the purpose of the down arrow, to remove points from people who disagree with you. Your childish and ingnorant actions will subtract from the quality of this site.
In Delphi, you can use pointers (and sometimes they are necessary, for API calls for example) - so you are closer to C than with C#. There is a reason why Java and C# do not have pointers: security.
"Most studies agree that pointers are
one of the primary features that
enable programmers to inject bugs into
their code."
http://java.sun.com/docs/white/langenv/Simple.doc2.html
In the C# programming language,
pointers are supported only under
certain conditions: any block of code
including pointers must be marked with
the unsafe keyword.
http://en.wikipedia.org/wiki/Pointer_%28computing%29#C.23
"Pointers are like jumps, leading
wildly from one part of the data
structure to another. Their
introduction into high-level languages
has been a step backwards from which
we may never recover."
— C.A.R.Hoare "Hints on Programming Language Design", 1973, Prentice-Hall collection of essays and papers by Tony Hoare
Use C# just because it has more mainstream support. Plus it is sure to be backed by Microsoft. Which adds incremental features to the language from time to time.
Also, the main architect of C# in Microsoft is Anders Heilsberg which was the co-creator of Turbo Pascal and Delphi of Borland before he got pirated by Microsoft.
It doesn't really matter in which programming language you create your "secure" application as long as you know what you want keep working until you get the result.
If you build an application in python or any other scripting language for instance you can still have good security.
As a good friend of mine told me few times "it's all you! programming language is just an extension of your mind!"
Both are good. Both are secure. Plenty of people are around who work with either of them.
The support for "enterprise" features like heavy Web services, distributed applications and componentized applications is better using the .NET Framework. Similarly there's no direct equivalent to the vector-based forms possible with WPF.
But if your application will never need them - then go with what you feel most comfortable.
As with most of the posts here, I would agree that security is in how you write the program. Not is what language you use.
I use several different languages, depending on the project.
On top of asking your self which you would be more comfortable with, you should ask your self if you want to support multiple platforms.
My company does a lot of cross-platform development, and as such, we don't use C# on those projects.
There is the mono project that aims to allow .net code to run on mac and Linux, but between the two, Delphi, being pascal is somewhat more portable.
( On our cross platform projects, we use either C or C++ )
Use the language you are most familiar with. That way you can hopefully avoid pitfalls and gotchas of using an unfamiliar language.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 13 years ago.
I need a programming language to make tiny applications. As a C++ programmer, I think C++ is not practical for this purpose, because it takes too much effort to create a new application from scratch and to deploy it. However, I'd like to use a language equally powerful, so I was wondering whether C# can be used as a scripting language?
Read this one
CS-Script - The C# Script Engine
CS-Script is a CLR (Common Language
Runtime) based scripting system which
uses ECMA-compliant C# as a
programming language. CS-Script
currently targets Microsoft
implementation of CLR (.NET
2.0/3.0/3.5) with limited support on Mono.
CS-Script is an open-source initiative
that is distributed under the license
agreement, which can be found here.
However commercial support is also
available.
CS-Script combines the power and
richness of C# and FCL with the
flexibility of a scripting system.
CS-Script can be useful for system and
network administrators, developers and
testers. For any one who needs an
automation for solving variety of
programming tasks.
and
Treating C# Like A Scripting Language
You could try Python, which is both a very understandable and powerful language.
It is possible to parse/execute Python from many languages.
For example: Use SWIG to use C++ code in Python or Boost to embed Python code in your C++ app.
I would say that the usual benefits of a scripting language are:
It normally has a command line interpreter
You don't necessarily have to compile it
It's easy to change the code - because the source file is the actual 'executable'
These are not features of C#, so a language that can do pretty much all that would be powershell, as it uses .net so it has access to all the features you might use in c#.
Edit: Just to resurrect this one from the dead...
Had a chat with a colleague, after thinking a bit about scripting languages that I have used like Ruby and Python.
One of the most important features for me in a scripting language is the ability to have code run directly in the script, without needing a main function. You don't do this in c#. However you do this in all the scripting languages that come to my mind:
eg, Ruby, Python, Javascript, Powershell
An other useful tool if you want to use C# for scripting is http://www.mono-project.com/CsharpRepl : a C# interactive prompt from the mono team.
I'd say that Mono in particular provides all of the tools to use C# as a very effective scripting language, and nearly anything you write in will run fine in .net if thats your main target environment.