Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming IT Technology

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."
This discussion has been archived. No new comments can be posted.

C Alive and Well Thanks to Portable.NET

Comments Filter:
  • What about C++? (Score:4, Informative)

    by ace123 ( 758107 ) on Monday March 15, 2004 @03:07AM (#8566322) Homepage
    Isn't C++ widely portable while giving mast if not all of the features of C# (except for being interpreted)
  • Re:So... (Score:4, Informative)

    by Zardus ( 464755 ) <yans@yancomm.net> on Monday March 15, 2004 @03:18AM (#8566376) Homepage Journal
    Linux is written in C, SDL is written in C, X (I think) is written in C. The gimp is written in C (along with GTK). Gaim is written in C. There are almost 13000 projects [sourceforge.net] on sourceforge that are registered as being written in C.

    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)

    by Julian Morrison ( 5575 ) on Monday March 15, 2004 @03:26AM (#8566407)
    http://cat.nyu.edu/~meyer/jasmin/
  • Re:Adaption, but.. (Score:2, Informative)

    by stephentyrone ( 664894 ) on Monday March 15, 2004 @03:28AM (#8566413)

    "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)

    by tupshin ( 5777 ) <tupshin@tupshin.com> on Monday March 15, 2004 @03:36AM (#8566435) Homepage
    http://www.xwt.org/mips2java/

    Takes compiled mips binaries and converts them to functional java classes.
  • by aarondsouza ( 96916 ) on Monday March 15, 2004 @03:36AM (#8566436)
    There are a huge number of applications that have very stringent time constraints, especially in real-time control. Other than coding in assembly, there isn't any other language out there that is as efficient (both size *and* speed count) as well optimized C code.

    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)

    by Foole ( 739032 ) on Monday March 15, 2004 @03:38AM (#8566450) Homepage Journal
    Whoever wrote this article and the previous one about it on slashdot is a moron.
    No one in this article or the other one actually said that C is dead. This is another case of a quote being taken out of context. The original quote was "To me C is dead." which has a very different meaning.
  • Re:What about C++? (Score:4, Informative)

    by H4x0r Jim Duggan ( 757476 ) on Monday March 15, 2004 @03:56AM (#8566499) Homepage Journal
    One of the design goals of GNOME was to support as many programming languages as possible.

    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.
  • by Ambassador Kosh ( 18352 ) on Monday March 15, 2004 @04:00AM (#8566508)
    Python does compile to bytecode. It just does not require a separate step to compile to bytecode like java does. If the bytecode is out of date it will be recompiled and used automatically.
  • There are python bindings for kde, as well as many others.
  • by Gopal.V ( 532678 ) on Monday March 15, 2004 @04:23AM (#8566582) Homepage Journal
    JVM doesn't have any pointer operations ... IL does .
    Which means you get a set of pointers which play nice ...
  • by iamacat ( 583406 ) on Monday March 15, 2004 @04:26AM (#8566589)
    ... if I had an equivalent set of class libraries. Haven't actually seen one for C++, but Cocoa for Objective C is pretty good and there is an ObjC++ compiler.

    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?
  • by Gopal.V ( 532678 ) on Monday March 15, 2004 @04:27AM (#8566594) Homepage Journal
    Does this include *all* of C? How do they compile the following C features into VM bytecode?

    - Pointer arithmetic
    A: YES
    - Hardcoded type sizes instead of using sizeof() (i.e. assuming sizeof(int) == 4)
    A: WTF ? .. C never had that ... C never had a fixed size for integers ... anyway malloc(20) will work
    - Lax rules for casting
    A: YES .. had to work a lot to get those function pointers castable !!
    - And so on
    A: Hey, porting glibc ... remember
  • Re:Why C needs help (Score:2, Informative)

    by Temporal Outcast ( 581038 ) on Monday March 15, 2004 @04:28AM (#8566595) Journal
    I agree with some of your points, but I will have to disagree on some.

    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)

    by Sivar ( 316343 ) <charlesnburns[@]gmail...com> on Monday March 15, 2004 @04:37AM (#8566626)
    Have you used C#?

    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)

    by Yokaze ( 70883 ) on Monday March 15, 2004 @04:57AM (#8566673)
    > And for the anti-FORTRAN fraction. It is still the fastest thing out there!!! Anyone who tried solving a system of linear equations containing 1000 equations knows what I mean.

    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.

  • by jhoger ( 519683 ) on Monday March 15, 2004 @04:58AM (#8566676) Homepage
    > You cant write OS/Drivers in bytecodes

    Forth? OpenBoot? The currently alive OpenBIOS project?

    QED
  • by Anonymous Coward on Monday March 15, 2004 @05:00AM (#8566678)
    Read the mailing list archives [dotgnu.org] ... there seems to be enough reason to kick this guy...

    ( 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)

    by Anonymous Coward on Monday March 15, 2004 @05:16AM (#8566721)
    DotGNU Portable.NET has a C# compiler and a C# class library which can be called from managed C (and vice-versa). Managed C in pnet is the first step towards a _portable_ managed C++ (MS's managed C++ is completely unportable). DotGNU is all about Free(dom) Software for webservices and fighting against vendor-lockin traps. Portable.NET is DotGNU's way of providing reasonably easy migration away from MS.NET, by providing a compatible C# library and IL runtime system.

    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.
  • by mdupont ( 219735 ) on Monday March 15, 2004 @05:52AM (#8566806) Homepage Journal
    BTW,
    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)

    by condensate ( 739026 ) on Monday March 15, 2004 @06:08AM (#8566852)
    Ever compared LAPACK to some other oonumeric library? I mean one that does NOT rely on LAPACK by itself. Check oonumerics [oonumerics.org] again. Most of the linear algebra libraries rely in some way on the basic linear algebra subprograms, which are of course FORTRAN subroutines. There are ports to C++ that are as fast, but you have to code quite efficiently to actually top FORTRAN. Personally, I prefer C++ and link against the subroutines by the extern "C" directive. This involves finding the appropriate libraries, but as soon as the whole thing links, no problem. Check Todd Veldhuizens page again, and you will see a graph that shows that his Blitz++ librariy equals FORTRAN. But Blitz++ relies on expression templates in C++ which are widely known to drive you mad when you encounter them the first time. The technique Veldhuizen uses is quite complicated and relies on the fact that C++ templates are evaluated by the compiler and subsequently inlined in the code. Compared to that , even FORTRAN code is very readable.
  • at least in the Unix world, is that pretty much every library is written in C

    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.

  • by hummassa ( 157160 ) on Monday March 15, 2004 @07:18AM (#8567025) Homepage Journal
    Uh, you can't run bytecode on a raw machine.
    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)

    by Mark_MF-WN ( 678030 ) on Monday March 15, 2004 @07:44AM (#8567079)
    You sound like an assembly-language advocate. They too are known for praising the silliest qualities of their chosen language.

    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)

    by Anonymous Coward on Monday March 15, 2004 @08:30AM (#8567194)
    C# doesn't suck for performance. It's actually a quite performant language and the overhead versus straight tuned native code is quite small - on the order of 5% or so. The DirectX .NET libraries show only a 2% performance loss over the native C++ thanks to their skill at understanding how the runtime works - even with all that underlying marshalling going on.

    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)

    by jarich ( 733129 ) on Monday March 15, 2004 @08:34AM (#8567203) Homepage Journal
    A few thoughts....

    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)

    by actiondan ( 445169 ) on Monday March 15, 2004 @09:22AM (#8567407)

    You do know that the .NET runtime uses JIT compiling rather than interpreting to actually execute applications, don't you?

    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)

    by sbrown123 ( 229895 ) on Monday March 15, 2004 @09:43AM (#8567511) Homepage
    Ive seen too many benchmarks that show Fortran dusting every other high level language out there when it comes to math. C++ is almost at a tie with Java outside using floating point.
  • Re:What about C++? (Score:3, Informative)

    by sabre ( 79070 ) on Monday March 15, 2004 @10:25AM (#8567777) Homepage
    Check out LLVM: http://llvm.cs.uiuc.edu/ [uiuc.edu]

    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
  • by BRSQUIRRL ( 69271 ) on Monday March 15, 2004 @10:36AM (#8567872)
    would you rather program against the pitiful number API's that come with C#

    Completely ignoring the fact that no APIs could "come with" C# because C# is just a one of many languages that compiles to .NET CLR bytecode (thanks once again for showing your complete ignorance of .NET)...I have written a lot of .NET apps and have yet to find myself needing some functionality not already provided somewhere in the .NET class library. It is (by far) the richest set of application APIs I have ever developed with.
  • Re:Java vs C vs C# (Score:1, Informative)

    by Anonymous Coward on Monday March 15, 2004 @10:57AM (#8568072)
    Care to point us to a credible set of benchmarks for a real application or semi-realistic application that isn't bought by Microsoft or Sun? From my own benchmarks comparing java vs C#, I see jdk1.4.2 30% faster on real applications.
  • by Caine ( 784 ) on Monday March 15, 2004 @11:14AM (#8568211)
    The way I see it, the benefit of garbage collection is nearly canceled by the lack of stack variables and guaranteed destructor calls.

    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)

    by Caine ( 784 ) on Monday March 15, 2004 @11:26AM (#8568342)
    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!

    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.

  • by be-fan ( 61476 ) on Monday March 15, 2004 @12:01PM (#8568699)
    You could complain about C all day, the problem is, it's the best thing we have right now.
    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.
  • by Qwavel ( 733416 ) on Monday March 15, 2004 @12:58PM (#8569276)
    C++ is very portable if you choose compilers and libraries that are standards compliant and portable, which is now easy.

    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.
  • by Anonymous Coward on Monday March 15, 2004 @02:18PM (#8570140)
    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.

    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.

  • But it ain't happening any time soon. Nevertheless: D, anybody [digitalmars.com]?

He has not acquired a fortune; the fortune has acquired him. -- Bion

Working...