Slashdot Mirror


C Alive and Well Thanks to Portable.NET

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

17 of 582 comments (clear)

  1. What about C++? by ace123 · · Score: 4, Informative

    Isn't C++ widely portable while giving mast if not all of the features of C# (except for being interpreted)

    1. Re:What about C++? by H4x0r+Jim+Duggan · · Score: 3, Informative

      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.

    2. Re:What about C++? by condensate · · Score: 3, Informative

      Ever compared LAPACK to some other oonumeric library? I mean one that does NOT rely on LAPACK by itself. Check oonumerics 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.

      --
      Black holes were created when god tried to divide by zero
  2. Re:So... by Zardus · · Score: 4, Informative

    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 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.

    --
    You can mod your friends, you can mod your nose, but you can't mod your friend's nose.
  3. Yup that exists by Julian+Morrison · · Score: 4, Informative

    http://cat.nyu.edu/~meyer/jasmin/

  4. Re:Wow! by tupshin · · Score: 4, Informative

    http://www.xwt.org/mips2java/

    Takes compiled mips binaries and converts them to functional java classes.

  5. Embedded/Real-time systems still need C by aarondsouza · · Score: 4, Informative

    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.

    --
    "In mathematics, it's not enough to read the words -- you have to hear the music"
  6. Re:So... by Foole · · Score: 5, Informative
    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.
    --
    This is not a turnip.
  7. language bindings Re:KDE, language support by aaron_pet · · Score: 3, Informative

    There are python bindings for kde, as well as many others.

    --
    Please use [ informative / summarizing ] SUBJECT LINES
    Flame me here
  8. I would take C++ over Java/C# anytime by iamacat · · Score: 5, Informative

    ... 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?

  9. Re:Didn't RTFA but have some questions anyway :) by Gopal.V · · Score: 3, Informative

    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

  10. Re:C is alive, not becoz of Portable.Net by jhoger · · Score: 3, Informative

    > You cant write OS/Drivers in bytecodes

    Forth? OpenBoot? The currently alive OpenBIOS project?

    QED

  11. Re:C's not dead because nothing better.... by Imperator · · Score: 4, Informative
    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.

    --

    Gates' Law: Every 18 months, the speed of software halves.
  12. Java vs C vs C# by jarich · · Score: 5, Informative
    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. :)

  13. Re:Wow! by actiondan · · Score: 4, Informative


    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.

  14. Re:C's not dead because nothing better.... by be-fan · · Score: 4, Informative

    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 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
    Another Common Lisp
    Ocaml
    Scheme
    Dylan
    Another Dylan

    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.

    --
    A deep unwavering belief is a sure sign you're missing something...
  15. Re: I find C++ very portable by Qwavel · · Score: 3, Informative

    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.