C Alive and Well Thanks to Portable.NET 582
rhysweatherley writes "So C is dead
in a world dominated by bytecode languages, is it? Well, not really.
Portable.NET
0.6.4 now has a fairly good C compiler that can compile C to IL bytecode,
to run on top of .NET runtimes. We need some assistance from the community to port glibc in the coming months, but it is coming along fast. The real
question is this: would you rather program against the pitiful number API's that come with C#, or the huge Free Software diversity that you get with C? The death of C has been greatly exaggerated. It will adapt - it always has."
What about C++? (Score:4, Informative)
Re:So... (Score:4, Informative)
C is neither bad nor dead (not that it doesn't have its problems). Whoever wrote this article and the previous one about it on slashdot is a moron.
Yup that exists (Score:5, Informative)
Re:Adaption, but.. (Score:2, Informative)
"Fortan is still an entry requirement to the California college system"
where can I get some of whatever you're smoking? there are classes where it's used, for sure, but "entry requirement"? no.
Re:Wow! (Score:5, Informative)
Takes compiled mips binaries and converts them to functional java classes.
Embedded/Real-time systems still need C (Score:5, Informative)
As an example, our lab works with humanoid robots that run in a 5ms control loop, which means that the next command (computation of inverse dynamics, etc.) has to be ready in that timeslice. If you want to do fancier stuff like machine learning and AI, you'll have to squeeze in many more operations into that tiny window. Sure, additional processors are a plus, but you still need very fast and memory efficient code.
Re:So... (Score:5, Informative)
Re:What about C++? (Score:4, Informative)
I'm not very familiar with KDE's language binding availability right now, but I know that being written in C++ would make it more difficult to provide alternate bindings. C, being the lowest portable denomiator of programming languages is simple to create alternate bindings for.
Re:C's not dead because nothing better.... (Score:3, Informative)
language bindings Re:KDE, language support (Score:3, Informative)
No pointer operations for JVM (Score:2, Informative)
Which means you get a set of pointers which play nice
I would take C++ over Java/C# anytime (Score:5, Informative)
The way I see it, the benefit of garbage collection is nearly canceled by the lack of stack variables and guaranteed destructor calls. I want to just declare a "Socket" variable in the middle of my function and have a guarantee that the socket will be closed when the block is existed in whatever way. finally or with just don't cut it. Say, I use 2 sockets, 1 file, a mutex and a temporary hash table entry at different points in a function. Imagine the mess of nested blocks, especially since Socket.close can actually throw an exception!
By contrast, memory management problems in C++ can be mitigated by destructors, reference counting and containers that automatically free members. Not ideal, but usually doesn't disfigure your code.
Now add other things missing from Java and/or C# - preprocessor, templates, multiple inheritence, operator overloading, unsigned types - and the new languages are really not that compeling for large projects that need heavy-duty, "dirty" features to manage complexity and can afford a regression suite that runs under Purify to fix memory corruption or leaks.
I know Java 1.5 has generics and C# has some more of C++ features compared to Java, but the matter of fact is that both languages are still tradeoffs compared to C++ in terms of productivity and stability rather than a clear step forward.
I would like to see a language that preserves as many features of C++ as possible while adding garbage collection, memory safety, language-based security and guaranteed binary compatibility between platforms/OSes. I don't think managed C++ is "it". Why can't a VM support multiple inheritence? Any pointers?
Re:Didn't RTFA but have some questions anyway :) (Score:3, Informative)
- Pointer arithmetic
A: YES
- Hardcoded type sizes instead of using sizeof() (i.e. assuming sizeof(int) == 4)
A: WTF ?
- Lax rules for casting
A: YES
- And so on
A: Hey, porting glibc
Re:Why C needs help (Score:2, Informative)
The thing that C zealots fail to recognize is the need for clean, standardized APIs (NOT implementations).
Ahh, but this is where you are wrong. C was initially written to be used for writing an Operating System - something above Assembly but a little more sophisticated.
The basic language needs to adhere to a standard ANSI C, or whatever - that is all. Which it does.
Now all other frills and bells and whistles cannot really be blamed squarely on C - its like blaming MFC and OWL and STL for being non-standardized in C++. APIs are not platform independent, and hence how can the implementations be different?
The thing is that, there is no real need for C in enterprise level applications until they have some kind of low-level interface.
But I do realize that most of your points are valid, however am just offering my 2 cents.
Just that when you use the wrong tool for the task, some problems are inevitable
Re:Wow! (Score:3, Informative)
C# is not run as interpreted bytecode (which would be slow); it is "compiled" to bytecode and then, when the program is first run, compiled to native code. It is about 10-20% slower than a similar program written in C++, but for most GUI apps on modern machines, this does not matter.
Of course, for "real programmers", C and C++ still grant you much more power. Function pointers, inline assembly, easy bitwise operations... C# is fine for many programs, but just TRY to implement a network protocol using it! MD5 is another good one. I haven't tried it myself, but have a friend that was forced to by a company thoroughly brainwashed by Microsoft.
Pain.
Re:What about C++? (Score:2, Informative)
I beg to differ [iu.edu].
At least, about the linear algebra part. There are some very fast numeric libraries [oonumerics.org] out there. I mean, its not like you are wroting the code to solve the equations in Fortran yourself.
Re:C is alive, not becoz of Portable.Net (Score:4, Informative)
Forth? OpenBoot? The currently alive OpenBIOS project?
QED
Re:Bug submission from banned contributor. (Score:1, Informative)
( I remember Miguel Kicking a guy out of the Mono lists just because he was working with the Portable.net team... IIRC, one the Qt# guys)
Re:Why C needs help (Score:2, Informative)
As a GNU project, we also want to make it easy for existing Free(dom) Software to be used with the CLR (common language runtime). At the very least, our portable managed C makes calling out to native C libraries easier. Rhys worked some magic and now the type sizes and layouts match those for the platform it's on, so data marshalling is greatly simplified (i.e. there's no more need to write a C wrapper of the native libs just to write a C# binding to that wrapper for wrapping native libs... cut out the middle man
As hackers who have had to dig into every corner of the ECMA and MS C# apis in order to implement them, we are very familiar with just how much they suck (e.g. most of the MS api designers seem to be incapable of writing anything even remotely OO).
By the way, there's absolutely nothing in the ECMA or MS apis related to sound. Rhys mentioned something about providing a portable sound api for managed code, though, not too long ago. He's probably got it on the back burner for now, but since he's a hacker god, it should come out great once he gets to it.
Rich
P.S. That whole problem with lots of GUI apis seems to be addressed quite nicely, imo, by the Y Windowing System.
Re:Bug submission from banned contributor. (Score:0, Informative)
I think it is very ontopic to point out the bug fixing policies of pnet/c. I am one of the *few* people who even uses pnetc and one of the *fewer* people who reports bugs on it. It would suprise me if anyone has reported more.
So, My complaint is ontopic, IMHO.
Re:What about C++? (Score:3, Informative)
Re:C's not dead because nothing better.... (Score:5, Informative)
Actually some of them that look like they're written in C are actually written in C++. They're just careful to make sure that all the public interfaces are extern "C". They can then use whatever fancy C++ features they want in implementing the library.
I think this is one of the real strengths of C: because the ABI is so simple, pretty much anything can link to C and almost anything can create C bindings.
Hi. You don't know what you're talking about. Bye. (Score:2, Informative)
Yes you can. There are several java-bytecode hardware microprocessors.
C and Assembler are what make the computer world run.
false. C and assembler are 20%-100% faster to execute, but 1000%-10000% slower to develop in.
You can't make Java in Java.
Yes you can. *and* you can make csc in c# (see here) [go-mono.org]
C turns directly into executable binary (or object files then linked into executables). Java cannot.
Look up gcj.
I suppose that if you were insane enough, you could make a bytecode to opcode converter, but then you lose 100% of the point of the langauge, probably a lot of the efficiency, and at that point you may as well use C.
As we were in the subject of python, look up psyco.
Man, this is the highest density of crap in the same paragraph I have ever read in
You Sound Like (Score:3, Informative)
C's only strengths are speed and easy access to hardware.
String boundary checking SHOULD be a feature of any modern language -- or do you enjoy buffer overflow exploits?
Re:Wow! (Score:1, Informative)
I've written computer vision / image processing algorithims in C# that were as fast as their C equivalents. It's just a matter of understanding what you are doing and what the underlying runtime is going to be doing.
Yes, you can use pointers - thats why there is the unsafe {} keyword. (Its still managed, unsafe != unmanaged).
I don't mind losing 5 or even 10% on my application if my development productivity is doubled.
Java vs C vs C# (Score:5, Informative)
C# whips the tar off of Java (and most non-optimized C code) in most benchmarks. Why? Because it's running on Windows only for these benchmarks. Anyone remember IIS running faster than Apache because of MS taking advantadge of undocumented platform APIs?
Do you think C# on Linux/BSD/*nix is going to be near as fast as C# on Windows? Think again. It may eventually catch up, but not before it gets a reputation for being dog slow. (See Java as an example).
C is really fast. If you know how to optimize it, nothing can beat it (except assember or some special Fortran routines, if it works for you project). If you ~don't~ know how to optimize C really well, Java (anywhere) and C# (on Win32) can be as fast or faster. Usually is much faster, these days.
Java runs, with very little effort, on every major OS and platform out there. (And yes, I do this for a living). I work at SAS (http://www.sas.com) and we ship the same codebase on Win32, HP-UX, HPi, Linux, Solaris, AIX, etc. The advances in the Just In Time compilers has made a huge difference in performance. (There are some differences in the major J2EE environments, but even that is addressable and minor compared to an entire product port).
Yes, it's still true that a programming guru can write some smoking C code, but Joe Sixpack Programmer usually can't beat Java's performance. And yes, I'm talking big number crunching. At a prior job (at a biotech), we crunched Big Numbers (two month runs on a grid of machines) and Java did a very respectable job. We spent our time improving algorythms (from a bio point of view, not a C/ASM point of view).
The C#/Mono crowd is spending a lot of mindshare in making sure that MS's latest language will run anywhere, and that's great. I am glad they are doing it and applaud the effort.
But Java is far and away the fastest true cross platform language out there right now. It's got the best cross platform enterprise environments available. If you are looking the most speed ~and~ portability, the King isn't dead yet. :)
Re:Wow! (Score:5, Informative)
You do know that the
One the app is running, the processor is dealing with native, optimised machine code rather than the IL bytecode.
Dan.
Re:What about C++? (Score:3, Informative)
Re:What about C++? (Score:3, Informative)
It gives the advantages of bytecode compilation (linktime & runtime optimization, JIT compilers, etc) to both C and C++ (using the GCC parsers). In addition it has a powerful interprocedural optimizer, so it generates code that truely thwomps GCC in some cases.
-Chris
Pitiful number of APIs? (Score:3, Informative)
Completely ignoring the fact that no APIs could "come with" C# because C# is just a one of many languages that compiles to
Re:Java vs C vs C# (Score:1, Informative)
Re:I would take C++ over Java/C# anytime (Score:2, Informative)
In both languages you can force a garbage collection of an object, and also specify code to be run att finalization.
By contrast, memory management problems in C++ can be mitigated by destructors, reference counting and containers that automatically free members. Not ideal, but usually doesn't disfigure your code.
Are you kidding me? Ugly hacks like refcounting doesn't make your code ugly? Heh, yeah, sure.
Now add other things missing from Java and/or C# - preprocessor, templates, multiple inheritence, operator overloading, unsigned types - and the new languages are really not that compeling for large projects that need heavy-duty, "dirty" features to manage complexity and can afford a regression suite that runs under Purify to fix memory corruption or leaks.
Seriously, do you have any clue what you're talking about? The need for preprocessor and templates are some of the largest faults with C++, introduced to try to keep backwards-compatability with C. A real OO-language as Java or C# doesn't need for example templates since all objects inherit Object as they should. They also both have usigned types. Multiple inheritance is usually seen as A Really Bad Idea and should be done with interfaces.
To conclude, you're a moron.
Re:Wow! (Score:2, Informative)
C# gives you access to function pointers, inline assembly and has the same friggin bitwise operators every other language in the world has. I've also implemented sockets encrypted at the sockets level which went just fine.
Re:C's not dead because nothing better.... (Score:5, Informative)
Hardly.
One of the problem with modern languages is, you can't write an operating system in them.
Sure you can, with little more ASM code than is required for a C-based operating system. Heck, lots of OSs have been written in things like Lisp. Actually, C is a terrible language for writing operating systems. Because its not safe, you have to have an MMU to protect programs from each other. This sucks for performance. Not only do you have the hit of memory protection, but you have to have bounderies between userspace and kernelspace, and between programs. That's why it takes 600(!) clock cycles on my P4 to do something trivially simple like gettimeofday()! If you use a safe language, you don't need memory protection, or even a kernel/userspace boundry for that matter. You get completely fine-grained protection for all objects. See this SF project [sourceforge.net] for an OS written in a safe language.
One of the problems is half the new languages are scripting perl/python like langauges and the rest compile to byte code.
I don't know what's the current fetish with VMs, but most of the really advanced languages (Lisp, ML) compile to well-optimized native code. Look at the recent comp.lang.lisp thread where they ported Almabench to CMUCL, and got within a few percent the performance of C.
Maybe C would go away if there was a compiled langauge that wasn't largely controlled by one company that produced fast code and was portable.
Common Lisp [cons.org]
Another Common Lisp [sourceforge.net]
Ocaml [ocaml.org]
Scheme [inria.fr]
Dylan [gwydiondylan.org]
Another Dylan [functionalobjects.com]
We have lots of languages that are much more powerful than C (hell, they're much more powerful than Java/C#), safer than C, and very close in performance. It is merely a failure of programmers and the software industry that we have not been able to utilize them.
Re: I find C++ very portable (Score:3, Informative)
VC 7.1 (finally), GCC 3.2, the new Intel compiler - these are all very compliant with the standard. And remember that GCC, though not yet well optimized, runs almost everywhere.
The C++ Standard Library, the boost libraries, wxWindows, Qt, + 100 other libraries are all cross-platform.
Now compare this to the huge amount of work required to 'port' #develop from Windows to Mono.
All that's missing with C++ is a processor independent intermediate code, and that's coming in GCC 4. It's called LLVM.
Tom.
Re:C's not dead because nothing better.... (Score:1, Informative)
a very good example of such a case is SGI's GLU library - internally it is written in C++ but none of its guts are exposed and nobody that hasn't looked at the code is aware that it is not C.
C isn't dead, but it should be (Score:2, Informative)