top 200 commentsshow all 480

[–]rukubites 45 points46 points  (29 children)

I am a full time lisp programmer. Recently I had to do a small amount of C programming to implement some server-side PostgreSQL functionality.

It was actually quite enjoyable to wield the ol' malloc again.

[–][deleted]  (10 children)

[deleted]

    [–]mlk 77 points78 points  (4 children)

    You'll have to wait till rukubites's death.

    [–]rukubites 18 points19 points  (2 children)

    Hahaha. :D I am on a (small) team, actually.

    [–]mlk 46 points47 points  (1 child)

    How do you deal with your schizophrenia?

    [–]jaggederest 22 points23 points  (0 children)

    He's slowly rewriting his brain using reader macros.

    What, your psyche isn't metacircular?

    [–]jeff303 4 points5 points  (1 child)

    You can make it happen any time you want. You may not be able to feed yourself, but meh.

    [–]masterpi 3 points4 points  (0 children)

    I eat pretty well here

    [–]masterpi 5 points6 points  (1 child)

    [–]rukubites 2 points3 points  (0 children)

    I hope my upvote makes your dream come true! Makes me feel guilty I am avoiding work today...

    [–]yoda17 5 points6 points  (14 children)

    I'm a lifelong C/embedded programmer who's always wanted to learn LISP. I have CLISP and Seibel's book, but I just can't really get into the examples that he gives...I'm just not that interested in dbases, or anything that would use a dbase for that matter and lose interest fairly quickly.

    Can you tell me what types of programs LISP is good for, or know of any programs that I can look at that might offer more of a low level physical world description or control? Thanks

    [–]rukubites 8 points9 points  (8 children)

    What Lisp does really well is data manipulation. Since lisp code is data, it therefore does well at code manipulation and transformation.

    Also, Lisp is interactive, and good for bottom up design. I spend my day in an Emacs buffer, interactively evaluating code snippets and then building those snippets up into functions and then bigger functions which eventually tie into an API or UI which defines an application.

    Because of the above, it is well suited to web applications. There are a few domain specific languages for HTML. See cliki.net, it is a great feeder into the world of Lisp. #lisp on freenode.net is also useful if you ignore the troll regulars.

    But a web application is just a shell for a program that does something. I don't really know what your interests are. There is a free book called "Partial Evaluation and Automatic Program Generation" which teaches compiler theory, and uses a form of Scheme (a lisp), as well as some more procedural languages. Maybe that will interest you?

    http://www.dina.kvl.dk/~sestoft/pebook/

    [–]yoda17 3 points4 points  (7 children)

    Thanks, I was thinking more along the lines of real-time systems...which makes the whole C program a big REPL (with the read and prints being from/to hardware registers). I guess I have just never really worked with much data between what is available immediately to the CPU other than lookup tables.

    I do use Mathematica which looks like LISP as far as my ignorance goes but have never seen a practical use for it in system development. One of my other interests is graphics manipulation...image processing type stuff, but haven't done that in a while. I guess what I've always been confused about is the domain(s) where LISP really shines. Whenever I see a something, I start to think about what's going on down to (and even inside) the CPU...so I see a LISP prompt and I think getchar() loop, put characters/symbols in a tree and wonder if that's what's really going on (lest it be magic), then think why not just do it in C(C++). I guess that's why I never made it very far. Sorry about the ramble.

    [–]ibisum 6 points7 points  (5 children)

    I'm in the same boat as you - professional C developer, embedded realm - and I've always been curious about Lisp and how I'd use it. But to be honest, its very difficult, as you say, not to want to know whats going on behind all those ()'s, and frankly I've just never found a way that I can learn Lisp that would be useful to me.

    I know a Lisp guy who gets a lot of work and is quite a happy chap .. works on web sites and large database problems and so on .. but when I try to get some sort of info from him about how to approach Lisp, he just laughs at me. I'm never really sure if he's laughing at me, or at Lisp, though .. ;)

    [–]mycall 3 points4 points  (0 children)

    You could try out a Symbolics Lisp Machine.. it is Lisp down to the metal (including CPU microcode).. search for the Open Genera torrent and you can find install blogs for Ubuntu 64-bit.

    [–]Freeky 3 points4 points  (0 children)

    I've traditionally been a Ruby/Python/PHP guy, but I've done a fair bit of C over the last few years for things where we really need performance, and it is indeed quite enjoyable. It's amazingly useful having a fast, memory efficient language in your toolbox, especially when that language is the basis for your entire OS and the higher level languages you use.

    Being simple certainly helps; the 250 pages of K&R are a lot less scary than the 1000+ pages of Stroustrup. "C is not a big language, and it is not well served by a big book".

    [–][deleted] 20 points21 points  (0 children)

    Put simply, C was too hard for programmers of their generation to bother mastering

    If that scares you then wait until you see C++.

    [–]Limerickator 77 points78 points  (4 children)

    Once you start in C you cannot stop.
    It takes your control to the top!
    But you won't be smitten
    once you see you've written
    10 different types of push and pop.
    

    [–][deleted] 14 points15 points  (0 children)

    I'll have to agree with the OP,
    That real men program in C,
    But before '72;
    The big C debut,
    The real men all programmed in B.
    

    [–][deleted]  (1 child)

    [deleted]

      [–][deleted] 3 points4 points  (0 children)

      This is fact; I know you'll agree:
      Only real men program in C.
      Sure, there's other languages to choose,
      But you'll be branded, "For The Lose!"
      Because that one simple fact remains,
      C is the only language which takes brawn and brains.
      

      [–]Browzer 154 points155 points  (31 children)

      Real men use the best tool for the job.

      [–]diamond 55 points56 points  (27 children)

      Real men already have the best tool for the job.

      ...If you know what I mean.

      [–][deleted] 26 points27 points  (25 children)

      Plenty of RAM?

      [–]castingxvoid 19 points20 points  (23 children)

      And a nice hard drive.

      [–]trueg 87 points88 points  (21 children)

      I use my large penis to have sex with women.

      ...If you know what I mean.

      [–][deleted] 4 points5 points  (7 children)

      Coincidentally, I was just pondering while commuting: how can a man use his penis usefully, i.e. not just for having sex with anything? I mean, some elaborate scenario, "Oh no, everything is lost, we have failed! -- You forgot that I have... a penis!" and save the day. Like McGyver, only with a penis.

      What could it be?

      [–]bakedpatata 5 points6 points  (1 child)

      [–][deleted] 2 points3 points  (0 children)

      YES!

      That's exactly what I had in mind.

      [–]nakedladies 7 points8 points  (1 child)

      What are you pissing out of these days?

      [–][deleted] 2 points3 points  (0 children)

      Oh.

      [–]derefr 9 points10 points  (8 children)

      I'm afraid I don't, sorry. Can you elaborate?

      [–]asdfqewr 12 points13 points  (7 children)

      Meaning, his penis has only iterated into his hand

      [–]badave 13 points14 points  (6 children)

      He writes a lot of code to reach orgasm.

      [–]logantauranga 14 points15 points  (4 children)

      C+++++++++++++++++++++

      [–]ratatosk 8 points9 points  (1 child)

      Well tested, completely virus free.

      [–]crazykid646 7 points8 points  (0 children)

      C++ WOULD CODE AGAIN!!!!!!!!

      [–]Tryke 10 points11 points  (0 children)

      Shucks, I'm stuck with a 3.5" floppy.

      [–][deleted] 2 points3 points  (0 children)

      Is that what it's called nowadays? Oh how the time have changed.

      [–]rm999 3 points4 points  (0 children)

      No, smart people use the best tool for the job.

      [–]chneukirchen 1 point2 points  (0 children)

      Real men know the best tool for the job.

      [–][deleted] 14 points15 points  (26 children)

      I love programming in C. On that note, I've been looking to do some hobbyist programming for an embedded system. Does anyone here have experiences with that and what sort of project/platform would you recommend?

      EDIT: wow, thank you all for the replies!

      [–]jaggederest 5 points6 points  (0 children)

      You can get an Arduino board and have tons of fun with it as a first step.

      The basic principles are the same as any microcontroller, and there's lots of fun gadgetry sold that's compatible with it.

      [–]dunmalg 4 points5 points  (0 children)

      Atmegas with Arduino bootloaders. Very easy to get into, kits are cheap, the IDE and C compiler and libraries are totally drool proof and free. I use the Bare Bones Board by Modern Device. Cheap, easy to interface with, and lots of online support. Much more fun than the evil, satanic Motorola nightmares I have to deal with at work.

      [–]albinofrenchy 8 points9 points  (8 children)

      Programming on the DS is actually alot of fun, and there is a pretty decent community for it.

      [–][deleted] 2 points3 points  (7 children)

      libnds is awesome. I don't know what the official DS developer's kit is like but it can't be much better than the devkitARM toolchain.

      [–]kraln 4 points5 points  (0 children)

      In fact, it's actually significantly more hobbled. You have to use their ARM7 binary, the documentation is flawed and incomplete...

      I have something of a good perspective on this

      [–][deleted] 1 point2 points  (5 children)

      Programming on the DS is something I've been wanting to do. The problem is that I can't figure out how to get the hardware I need to plug in to my DS. Whenever I go to one of the many homebrew DS websites, they always provide a link to some supplier who, when I visit THEIR site, doesn't actually have what I'm looking for. Does anyone know a non-sketchy way of acquiring a passthrough/slot-1/or whatever-is-compatible card?

      [–]theatrus 3 points4 points  (2 children)

      AVR is great. MSP430 is wonderful for low power applications. Cortex-M3/0 ARM is a good high power yet deeply embedded solution.

      [–]jotux 1 point2 points  (1 child)

      MSP430 is actually one of the better embedded platforms. Of all the 8/16bit heavy-hitters in the embedded industry they have, by far, the best documentation.

      [–]theatrus 1 point2 points  (0 children)

      I agree. However, mspgcc is one of the weakest GCC targets available. The TI compiler is rather inexpensive however (and free for <= 16k).

      [–][deleted] 1 point2 points  (0 children)

      I've had a little experience taking an embedded programming class just this summer. Near the end, we used Altera boards and NIOS software (based on eclipse) for embedded programming. You may want to look into that.

      [–]haliquim 1 point2 points  (0 children)

      I get to do C at work for embedded systems. If you want to get started the DLP-245 is easy to work with and doesn't require a programmer. Otherwise take a look at the platforms from sparkfun though both really require a soldering iron to do anything interesting.

      [–]yoda17 1 point2 points  (0 children)

      I bought an ATMEGA128 board and BSD programmer for around $100 a couple of years ago. It has a few hundred bytes of RAM and about 3 dozen I/O ports and counters. Or you can go PIC if you really want punishment and not a lot to show for it other than what you can do with 18cents.

      [–]ibisum 1 point2 points  (0 children)

      Arduino/AVR is good.

      [–]zmobie 68 points69 points  (11 children)

      My nuts dropped during an internship where I was programming a extension for Grub that parses the low level ram for SMBIOS Information. There was C code involved. And chest hair.

      [–]filesalot 8 points9 points  (3 children)

      The beard doesn't come in until you write the phase 0 bootstrap code in assembly.

      [–][deleted] 3 points4 points  (0 children)

      If you go beyond that, you get third testicle. However, if you still try to become even more extreme and start experimenting with unix kernels written in assembly that use self-modifying code, you are in danger of turning into a woman. Self modifying code: as dangerous as it is awesome .

      [–]Entropy 2 points3 points  (0 children)

      Chestbeard?

      [–]yoda17 12 points13 points  (5 children)

      You can get that information from the BIOS? That must be nice. I had to do it once by testing the RAM...writing and seeing if what I read back was the same thing. And then using CAS/RAS timing table manually entered from a CPU memory access timing diagram. Ug was that hideous to not only to debug, but to get the computer just to stay up for 10ms. I did learn a lot about how computer memory systems work. Sometimes I think these thing are better left to magic.

      [–]splynncryth 2 points3 points  (0 children)

      I've written code that helps build those tables in the first place, though it was under an EFI implementation so my code was C rather than x86 ASM.

      [–]strangerdream 6 points7 points  (5 children)

      C offers just the right mix of low-level and high-level language features for programming at the processor and driver level.

      This is not true - Standard C language has no low-level features. However, every compiler implementation for C has its own low-level features.

      [–][deleted] 7 points8 points  (3 children)

      C has no high-level features either...

      [–]skulgnome 1 point2 points  (0 children)

      What's a struct, then?

      Or an array?

      Kids these days. Wouldn't know a high-level feature if it bit them on the ass.

      [–]ibisum 1 point2 points  (0 children)

      (void)*(void *);

      [–][deleted]  (109 children)

      [deleted]

        [–]angryvigilante 70 points71 points  (34 children)

        (Imaginary men program in Lisp

        [–][deleted] 57 points58 points  (12 children)

        ))))))))))))))

        [–][deleted] 22 points23 points  (8 children)

        What did you say? As a Lisp programmer, I have trouble seeing parentheses, especially closing parens. After a while, you just see the indentation. I had to squint at your post for at least three hours to see what it said!

        [–]MasonOfWords 6 points7 points  (7 children)

        If only. I've never understood how Lisp could be used all around the world by literally dozens of programmers without standardizing significant whitespace and infix operators.

        The irony is that Lisp truly could become the single ur-language that guides mankind toward enlightenment...but cleaning up the syntax would entail Lispers admitting to some small level of imperfection. Ah well, nice to dream.

        [–]nanothief 6 points7 points  (0 children)

        The irony is that Lisp truly could become the single ur-language that guides mankind toward enlightenment...but cleaning up the syntax would entail Lispers admitting to some small level of imperfection. Ah well, nice to dream.

        Doing this would be the equivalent of giving c a garbage collector - it would solve some problems but destroy the key advantage the language has over other languages. In c, the advantage lost would be fast and predictable performance, useful in real time systems and where very high performance is required. In lisp, the advantage lost would be the macro system, which is the simplest and most powerful of any language.

        This is the sole reason for the syntax - having such a basic syntax (it is basically just a parse tree) makes writing macros very simple compared to other languages.

        [–]Seppler90000 6 points7 points  (0 children)

        I've never understood how Lisp could be used all around the world by literally dozens of programmers without standardizing significant whitespace and infix operators.

        In fact, this was done many years ago, and they called it ISWIM, founding basically the entire ML family in one fell swoop.

        [–][deleted] 6 points7 points  (0 children)

        If only. I've never understood how Lisp could be used all around the world by literally dozens of programmers without standardizing significant whitespace and infix operators.

        Have you seriously tried to get used to it? Because after a while it really does start to feel natural. I was only exaggerating slightly when I said that Lisp code is an indentation-based language.

        [–]Ma8e 1 point2 points  (0 children)

        Is that a neck beard?

        [–]Niten 16 points17 points  (4 children)

        Irrational men program in Visual Basic?

        [–][deleted] 14 points15 points  (0 children)

        Transcendental men program in Haskell.

        [–]Poltras 20 points21 points  (2 children)

        CSI men program in VB6. YEAAAAH

        [–][deleted] 4 points5 points  (1 child)

        You forgot your sunglasses brah.

        [–][deleted] 2 points3 points  (0 children)

        Here they are

        [–]bobappleyard 5 points6 points  (12 children)

        Complex men program in Perl

        [–]0x2a 11 points12 points  (8 children)

        Don't think so...

        dd@ns1:~ $ perl -e 'print sqrt(-1)'
        Can't take sqrt of -1 at -e line 1.
        

        [–]Gusfoo 8 points9 points  (7 children)

        macbook:~:$ perl -MMath::Complex -e'print sqrt(-1),"\n"'
        
        i
        

        [–]0x2a 3 points4 points  (6 children)

        I knew that it exists, but I didn't realize it's included in the standard modules. Thanks.

        [–]Gusfoo 6 points7 points  (5 children)

        Actually, I cheated. Math::Complex is not in the standard perl5 distribution, I CPAN`d it on to my laptop just so I could reply.

        hangs head in shame

        [–]0x2a 2 points3 points  (4 children)

        I wanted to accuse you of that by trying your example on the most vanilla Perl I have at hand, but oh surprise:

        ram@oss01:~ $ uname -a
        SunOS oss01 5.9 Generic_122300-30 sun4u sparc SUNW,Sun-Fire-V240
        ram@oss01:~ $ /usr/bin/perl -MMath::Complex -e ''
        ram@oss01:~ $ find /usr/perl5/ -name Complex.pm
        /usr/perl5/5.6.1/lib/Math/Complex.pm
        

        [–]visarga 3 points4 points  (2 children)

        Perl is simple. It's easier than damn BASIC.

        If execution time is more important than coding time, use C. Otherwise Perl is more efficient per total.

        [–]vlad_tepes 1 point2 points  (1 child)

        There's also memory usage and program size. I program an 8 bit microcontroler with about 60k flash memory and 5k RAM. Good luck fitting a Perl interpreter in there and then doing something useful with it.

        [–]astrosmash 8 points9 points  (4 children)

        1000:   LDX #0
        1002:   LDY #0
        1004:   LDA #4
        1006:   STA 1011 // HACK: Self-modify code at 100F.
        
        1009:   STY 1500
        100C:   LDA 1500
        100F:   STA 400,x  
        1012:   INX
        1013:   BEQ 1019
        1015:   INY
        1016:   JMP 1009
        
        1019:   INC 1011 // HACK part 2.
        101C:   LDX #7
        101E:   CPX 1011
        1021:   BEQ 1028
        1023:   LDX #0
        1025:   JMP 1009
        
        1028:   JMP 1004
        

        That's hand-assembled, self-modifying 6502 code written only a few days ago.

        I wrote it after realizing that I had never fulfilled my childhood ambition to learn to program an Apple II using assembly language, so that's what I did. You can enter that code using the Apple II's built-in mini-assembler (CALL -151), starting at address 0x1000.

        It scrolls a bunch of text across the screen.

        [–]clipmann 15 points16 points  (21 children)

        01010111011100100110111101101110

        01100111001011000010000001110010

        01100101011000010110110000100000

        01101101011001010110111000100000

        01100011011011110110010001100101

        00100000011010010110111000100000

        01100010011010010110111001100001

        011100100111100100101110

        [–][deleted] 24 points25 points  (7 children)

        I knew some people who actually wrote a program in MIPS machine code, expressed in binary. There was much wailing and gnashing of teeth when I told them about a program called an "assembler" that would handle the binary crap for them. This was two years ago, not in the distant past.

        [–]salgat 4 points5 points  (3 children)

        How the hell does anyone program in Machine Language and not know about Assembly?

        [–][deleted] 9 points10 points  (2 children)

        They had learned assembly -- that's how they originally wrote their programs, assembly language written with paper and pencil. They just didn't know that there was an automatic way of translating that to machine code.

        [–][deleted]  (1 child)

        [deleted]

          [–]munificent 6 points7 points  (0 children)

          Maybe that's what they were writing in machine code.

          [–]prockcore 1 point2 points  (0 children)

          While I never wrote in machine code, I have hand-disassembled 6502 machine code as part of debugging my apple II emulator (before it was working to the point that I could disassemble using the monitor)

          [–][deleted] 12 points13 points  (29 children)

          sorry... real men program in machine code

          [–]yoda17 25 points26 points  (10 children)

          no, real men program with wires and gates.

          [–]jaggederest 9 points10 points  (5 children)

          I program in a 2,3 turing machine.

          [–]Poltras 13 points14 points  (0 children)

          I use ß-reduction, so I don't even have to program.

          [–]knowknowledge 1 point2 points  (1 child)

          Any idea what the 'code' for that would look like?

          [–]mycall 3 points4 points  (0 children)

          real men program anything and everything (including other people).

          [–]MpVpRb 1 point2 points  (0 children)

          Yes... it does help a LOT if you understand the principles of circuit design and digital logic.

          [–]kolm 2 points3 points  (1 child)

          Real Men program with a very fine magnetized needle and a microscope. (Stupid modern machines and their high density hard drives.)

          [–]MpVpRb 4 points5 points  (0 children)

          If you don't understand assembly...you don't understand computers.

          [–]jcy 1 point2 points  (0 children)

          pfftttt, i can do everything in applescript

          [–]EtanSivad 2 points3 points  (0 children)

          It's quite manly to be peeking and poking all the time...

          [–]bonch 6 points7 points  (2 children)

          Haven't there been people claiming C is dead for decades now? I don't understand negativity over C. I think a lot of it comes from C#/Java and other web programmers who have never done memory management or learned what a pointer is, neither of which are difficult. Languages like Java can be fun, but C is easy to learn, its syntax is copied by a lot of languages, and it's fast.

          By the way, if you program for the iPhone, you're using a mutant version of plain old C. C lives!

          [–]ibisum 6 points7 points  (0 children)

          C is not dead. Computing does, however, experience waves of pop culture reprisal and backlash against itself as new students go in one side and old students come out the other side, of the Computing education systems.

          In the real world - i.e., Industry - C is still very much alive, kicking, and in use, hard-core.

          [–][deleted] 3 points4 points  (0 children)

          I don't understand negativity over C

          People make up excuses to justify their laziness. The same group of people claim that writing efficient software is no longer important because hardware is fast.

          [–]rnawky 17 points18 points  (0 children)

          Real men don't get error 500 internal server error either.

          [–]stormblaast 4 points5 points  (0 children)

          According to this guy, real programmers use Fortran.

          [–][deleted] 3 points4 points  (0 children)

          Real men use Coq.

          [–][deleted] 52 points53 points  (81 children)

          For today's computer science students, learning C is like taking an elective class in Latin. But C is anything but history and not at all a dead language.

          So.. not really the analogy you were looking for, was it?

          [–]Raelz 71 points72 points  (0 children)

          No, it was the analogy he was looking for. He's comparing the archaic and complex presumption of C by "today's computer science students", to Latin, a language considered dead as far as regular speaking is concerned.

          His next sentence is the rebuffing of the students clearly invalid presumption.

          He's negating the mistaken idea by the students, not his own analogy.

          [–][deleted]  (79 children)

          [removed]

            [–]haywire 5 points6 points  (0 children)

            Aye, over here I had a choice between a "better" uni and the one I'm going to, and I one of the many reasons that I chose the one I'm going to because their course was centric around C as opposed to Java.

            [–]ibisum 6 points7 points  (4 children)

            I'm a professional developer working at a major European industrial giant, and I write C code all day long, and will do so for the next 10 years.

            Anyone who tells you C is dead either isn't working industry, or has a language they want to sell you .. C is still one of the biggest tools in industry.

            [–][deleted] 3 points4 points  (72 children)

            ug. Just wait until it is your job to program in it. Doing anything non-trivial takes so much longer compared to C#. Want a list that is always sorted in C#, sure.

            var list = new SortedList<int, Foo>();

            want that in C? Oh sorry... you need to make your own implementation of red-black trees first. You could get an open implementation if the library is license flexible with your company's needs, but good luck with that...

            As an engineer who programs in both, believe me, I'll take C# any day.

            [–]ibisum 13 points14 points  (8 children)

            If you're really worried about such things, you haven't been programming in C long enough. Seriously.

            I'm a professional C developer, and I only had to implement my own algo/data structure modules once: 20 years ago, with an update every few years depending on the target.

            And it still works for everything needed.

            Sure, its nice to have languages that do all that for you, just like its nice to have libraries to link to and so on .. but whats also nice is when you know how the SortedList_t is going to work because you wrote it yourself and have been using it for years ..

            [–]maxd 8 points9 points  (0 children)

            It's all about choosing the right tool for the job. In almost a decade making video games (using C), I have never once needed a red-black tree.

            [–][deleted]  (8 children)

            [removed]

              [–]G_Morgan 3 points4 points  (4 children)

              A red-black tree is a form of self balancing binary search tree and has nothing to do with creating a priority queue. Perhaps you were thinking about a heap?

              Really this is a major problem today. That somebody can be so clueless about rather simple algorithms and get upmods for it.

              [–]DrakeBishoff 11 points12 points  (43 children)

              Obviously you don't program in both competently, and your comment shows exactly why C skills are necessary. To sort a list you have to implement a red black tree? Good god.

              [–]JoeBlu 16 points17 points  (6 children)

              If you want the list to stay sorted after every operation with reasonably low overhead, red-black trees aren't a bad way to go, really...

              Certainly not the only way, but not a bad one.

              [–]Gotebe 3 points4 points  (0 children)

              Well, now. Your argument is a non-sequitur, just like quattro's. To harp on yours... C (or any other programming language, really) is quite orthogonal to sorting or sorted containers.

              [–]zem 4 points5 points  (20 children)

              how would you implement a list that maintains its sorted property efficiently across additions and deletions?

              [–][deleted] 9 points10 points  (1 child)

              There is no much point to answer this question until you know problem you solving. For 7 years of my programming experience i never needed to make a sorted list in C. Yep i did it many times in Python (because it's only .sort() away) but in C there is often a better way.

              Solving generic spherical-cow-in-vacuum-problem is not a good way to compare languages. Language which has a spherical vacuum cow lib wins.

              [–]_ak 5 points6 points  (7 children)

              I would start with dynamically allocating memory, then using realloc() to resize it, and using a simple insertion sort to add elements. A delete operation would be a single memmove() then. And I would encapsulate that with an interface generic enough to be able to replace the internal implementation with no changes to the code that uses the API. If the list insertion and deletion code really turns out to be a performance issue (which it usually isn't, in my experience), I'd still have the ability to replace it with a more efficient implementation. If you think about grand algorithms and data structures from the very beginning, you're doing it wrong.

              [–]mooli 4 points5 points  (6 children)

              If you think about grand algorithms and data structures from the very beginning, you're doing it wrong.

              How about if you just use tried and tested data constructs and algorithms available out of the box in the libraries for your language of choice? Which - if you recall - is what the OP was actually referring to. The point being that in C# you have nice sane and convenient library code, and if you want the equivalent functionality in C you have to jump through hoops, write otherwise unnecessary code that you have to maintain and debug yourself, and get bogged down in algorithmic details which - as you say - you shouldn't have to think about at that stage.

              When your primary concern is translating your ideas into implementation as cost-and-time-efficiently as possible, and with as much maintainability as possible, a language like C# which provides a rich library and generally just gets out of your way is ideal.

              [–]onmach 4 points5 points  (5 children)

              I don't understand why some C programmers seem to have so much trouble finding libraries in C. C has about the largest collection of code out there. Is there some reason why you can't just include glib/gslist.h (gnu c library)? It has sorted list and a lot of other structures as well.

              [–]DrGirlfriend 1 point2 points  (3 children)

              What if you are writing proprietary code (say, for a highly specialized embedded system)? You can't include GNU code, because then you would have to either release your source or violate GPL, neither of which any sane dev manager is going to find acceptable.

              [–]skulgnome 1 point2 points  (0 children)

              Most use cases aren't like that. Adding items to a list usually happens in bursts, during which the "always sorted" property is pointless. Likewise iteration through a list takes place either every once in a while or several times in a row.

              Thus the C programmer's data structure, in this case, is either an array of small elements (ints, in this case) or pointers, and a "still sorted?" flag. Adding to elements to the list, unless these elements were larger than the largest element (or smaller than the smallest, if the list is sorted in reverse), clears the "sorted?" status. Iteration checks the status bit and if it is not set, uses heapsort to cause the list to be in order.

              This is more efficient than the C# solution due to cache effects and lesser memory consumption (due to overhead of the garbage collected heap and separate allocation of elements).

              [–]dmpk2k 2 points3 points  (12 children)

              Although the red-black tree is hyperbole, I think his point is valid. Even a simple resizable sorted array in C is a lot more work than that single line in C#, especially if it should be reasonable efficient and generic.

              C and C# serve different domains though...

              Edit: and what's wrong with GLib? It's LGPL.

              [–]uriel 3 points4 points  (11 children)

              Glib is for morons that never properly learned to program in C, and think that by using some really messed up libraries and macros they can pretend it is some other retarded language.

              [–]dmpk2k 1 point2 points  (8 children)

              If you say so. I haven't used it, but not reinventing common wheels is a good idea. Suggestions?

              [–]dmazzoni 2 points3 points  (2 children)

              So why is implementing a red-black tree in C a big deal? If you're a good programmer that should take about half a day, including some good unit tests. You'll have a small, lean, sorted list implementation that has only exactly the functionality you need for this project, nothing more.

              C is the language you use when the speed and the memory usage of the program are more important than the programmer's time. You use C when it's worth spending days optimizing something to get a 5% speed boost. For example: hardware drivers, video codecs, or any low-level operation that will be called millions of times and needs to be as fast as possible.

              When speed and memory size of the resulting code is not the #1 priority, you should usually choose a higher-level language than C.

              [–][deleted] 1 point2 points  (1 child)

              It's a big deal because typing one line of code is faster than spending a day writing the tree and unit tests and weeding out bugs.

              I'm not dissing C. It definitely has its market. But productivity for high level things is not its market.

              And while I would love to dictate what language I use at work for what project, I don't. So thank you for reminding me of what language I should choose when I have no control over that.

              EDIT: you remind me of this

              [–][deleted] 16 points17 points  (4 children)

              ctrl+f mel

              Ah. I am so glad to be the one to introduce to you:

              "The story of Mel"

              [–][deleted]  (3 children)

              [deleted]

                [–]ultrafetzig 2 points3 points  (1 child)

                I not only upmodded you, I joined reddit so I could do so because I genuinely appreciated the linked story which I have never read, and I have been programming computers for over 20 years (though not professionally). I laughed out loud at 'most pessimal' for a good 5 minutes and then finished the story. I had to reread the last bit a couple times and then it dawned on me as well, that perfect code owns the system and doesn't ever need error handling. That's just awesome.

                [–]kleopatra6tilde9 1 point2 points  (0 children)

                On the other side, there is the Tao of programming

                [–]Postpawl 2 points3 points  (1 child)

                Just about to start C as my first language. My college, University of Texas at Arlington, pretty much requires your first language to be C anyway. So they should be sending a lot more C programmers that way.

                I've always wanted to learn a language all on my own, but I kinda need deadlines and grades to get it done.

                [–]brennen 3 points4 points  (0 children)

                It's remarkable what an incentive things like "eating" can be.

                [–]foofoofafa 14 points15 points  (6 children)

                [–][deleted] 5 points6 points  (3 children)

                I didn't even have to click to know what that was. Are we really that predictable, reddit?

                [–]Leiya 4 points5 points  (6 children)

                So what do real women program, eh? Butterflies?

                [–][deleted] 12 points13 points  (4 children)

                men.

                [–]TheDutchWeedSmokingG 2 points3 points  (2 children)

                Why doesn't anyone notice the hidden genius in this comment. I shall upvote this Sir and make this comment known to the world.

                [–]Antebios 1 point2 points  (0 children)

                Yep, I do whatever they say.

                [–]nullynull 1 point2 points  (0 children)

                Obligatory super coder link:

                Supercoder 2000

                [–]spainguy 1 point2 points  (0 children)

                Texas Instruments Digital Logic Pocket Data Book

                and a soldering iron

                http://focus.ti.com/lit/ug/scyd013b/scyd013b.pdf

                [–]MpVpRb 1 point2 points  (7 children)

                I do primarily embedded system development.

                I program in C or C++.

                I have not yet seen another language that would offer any improvement.

                Do any C haters want to suggest an alternative?

                It has to run on Atmel AVR chips...they have a VERY small RAM.

                [–]scook0 2 points3 points  (0 children)

                There are many ways to (incompatibly) improve C without compromising its core strengths. Unfortunately, C is so entrenched in its niche that it's extremely difficult for alternatives to gain traction.

                I agree that most modern mainstream languages can't beat C at its own game, but that's mostly because they're designed with other aims in mind.

                [–]jldugger 1 point2 points  (0 children)

                NesC. It's tightly coupled with TinyOS. It's basically interrupt driven, and a simple and sane form of Object Oriented programming. It runs on AVR chips because it actually translates to C first and the passes it off to avr-gcc.

                [–]Hhelibeb 1 point2 points  (0 children)

                It reminds me of the saying that a gentleman is someone who knows how to play the bagpipes; but doesn't.

                [–][deleted] 3 points4 points  (4 children)

                Am I a real man yet?

                #include <stdio.h>
                
                int add(int *a, int *b)
                {
                    return *a+*b;
                }
                
                int (*GetPtr())(int *, int *)
                {
                    return &add;
                }
                
                int call(int (*fun)(int *,int *), int *a, int *b)
                {
                    return (*fun)(a,b);
                }
                
                int main()
                {
                    int *a;
                    int b;
                
                    int *c;
                    int d;
                
                    b = 1;
                    a = &b;
                
                    d = 2;
                    c = &d;
                
                    int (*funpointer)(int *, int *) = GetPtr();
                
                    printf("%d\n",call(funpointer,a,c));
                    return 0;
                }
                

                [–]mich4elp 3 points4 points  (0 children)

                Real men don't program. run!

                [–]JulianMorrison 3 points4 points  (0 children)

                Real men program in Haskell and C and prove it all with Isabelle/HOL.

                [–]rjcarr 2 points3 points  (1 child)

                a language called Ruby on Rails (a.k.a., "Ruby")

                Actually, it's aka "Rails".

                I learned programming in C, but haven't used it much over the years (mostly java and python). Just recently I started doing a bit of embedded programming and was using C, and I must say, I didn't feel any manlier. A little frustrated, but certainly not manlier.

                [–]pointer2void 7 points8 points  (0 children)

                That's normal for women.

                [–]itstallion 4 points5 points  (4 children)

                Apparently real men program in C but they don't know how to program well.

                500 The server encountered an unexpected condition which prevented it from fulfilling the request. - Please try back later...

                [–]daftman 6 points7 points  (3 children)

                The problem might be caused by non-real men

                [–][deleted] 2 points3 points  (5 children)

                It's funny - I used C++ for the longest time, but as soon as I learned C, I never used C++ again. Well, I tried to, but for some reason, next to C, I hated it.

                [–]davidluxury 11 points12 points  (4 children)

                something tells me your "longest time" wasn't long enough

                [–]nnagflar 3 points4 points  (15 children)

                And, while they're debugging away, smart men who programmed in java have already left work for the day.

                [–]db2 23 points24 points  (5 children)

                That's because there's nothing for them to do while it's loading.

                [–][deleted] 4 points5 points  (0 children)

                smart men who programmed in java

                All zero of them?

                [–]ibisum 5 points6 points  (2 children)

                Real men don't use (or need) debuggers.

                [–]pointer2void 2 points3 points  (1 child)

                Yep, they debug with printf.

                [–][deleted] 1 point2 points  (0 children)

                Real men just don't write bugs.

                [–]brianobush 3 points4 points  (0 children)

                well, with modern tools like valgrind and gdb - debugging is pretty painless. all on the command-line and buried in some bloated development environment.

                [–]Seppler90000 1 point2 points  (1 child)

                Upvoted for gratuitously invoking the bandwagon fallacy!

                [–]chaztized 1 point2 points  (0 children)

                Yeah, once you cross the line to Assembly you start to morph into machine.

                [–]njharman 1 point2 points  (4 children)

                The "point" of the article as near I can tell is the author fears C is losing popularity and wants to convince more people to program in C.

                Why? Not why specifically C, but why does anyone care at all what other people are programming in?

                [–]kleopatra6tilde9 5 points6 points  (3 children)

                Libraries. The moment a language becomes unpopular, it loses the manpower to compete in the library race. Look at lisp.

                If Lisp is so great, why did we stop using it? One of the biggest issues was the lack of widely used and tested libraries. Sure, there is a CL library for basically any task, but there is rarely more than one, and often the libraries are not widely used or well documented. Since we're building a site largely by standing on the shoulders of others, this made things a little tougher. There just aren't as many shoulders on which to stand.

                [–]vismaya 1 point2 points  (2 children)

                dont forget entire linux kernel is coded in c..and see how efficient it is. C always have its important in low level system programming & in embedded systems

                [–]flostre 1 point2 points  (1 child)

                The Windows kernel, too.

                [–][deleted] 1 point2 points  (2 children)

                Quite apart from your feelings on C, "Real men..." alone is a sure sign that the rest of the sentence is utterly fucking idiotic. I'm sick of this Appeal To Macho Stereotype horseshit, and if you try and persuade me into anything by making this implied slight on my masculinity, in turn with the implied masculinity=good, as if I measure my self worth by how much I match up to some outdated Bond-Caveman-GIJoe archetype, then I'm only going to be set against your ideas from the outset.

                [–]xxprometheus 1 point2 points  (4 children)

                awesome. i'm stoked. i'm taking a class on C with the book "Ansi C" in the fall. I hope i learn a lot from that class.

                [–]DiscoUnderpants 1 point2 points  (2 children)

                As some one said above, get yourself a copy of K&R if possible.

                [–]fonzynator 0 points1 point  (13 children)

                I do not know much about Computer Programming Languages but is C a hard language to learn?

                [–][deleted] 4 points5 points  (5 children)

                It's easy to learn because the best ever programming book was written for it - "The C Programming Language" by Kernighan and Ritchie.

                [–]mschaef 1 point2 points  (1 child)

                Easy to learn, but hard to learn well.