• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Is C a 'good' programming language?

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Originally posted by zeitghost
    Mmmmmmm...

    Hand coded 32 bit assembler

    Mmmmmmmm....
    At my first job in IT they had a clankety clank Burroughs system which unfortunately they never let me near, but they'd got good enough at it over the years to bash machine code straight onto punch cards.
    Behold the warranty -- the bold print giveth and the fine print taketh away.

    Comment


      Just found a bug:

      Code:
      // borked
      AutoInterface<T> r(reinterpret_cast<T*>(Base::RemoveTail(), true));
      // fixed
      AutoInterface<T> r(reinterpret_cast<T*>(Base::RemoveTail()), true);
      Spotted the difference yet?

      Although this is C++, it's thanks to C's stupid comma operator that this compiles. What's passed into the reinterpret_cast is not the result of the function call, but second expression (true). It happily casts true into a T* whose value is 0x00000001 with hilarious results.

      (AutoInterface's constructor has an optional second parameter, so that doesn't cause an error either).

      I take it back. Tis a stupid lanugage.

      Last edited by VectraMan; 1 September 2009, 20:32.
      Will work inside IR35. Or for food.

      Comment


        Originally posted by OwlHoot View Post
        At my last permie position I had to write a shed load of cleanup code to remove blemishes etc from signature image thumbnails for a building society (actually a shareholder vote for privatization).

        I started out writing it in C, but as there were half a million of the brutes, which all had to be tarted up by a certain date, performance was imperative and we worked out that at the rate the code was chugging through them it would never be done in time.

        So I started embedding assembler bit blitters into the code, small sections at first but of course getting more ambitious as time went on, and sure enough it started speeding up significantly.

        At the same time, I was writing an Intel disassembler as a personal hobby, and so had a pretty intimate knowledge of all the prefix codes that specify a 32-bit operand etc, and I found that using these operands speeded things up even more.

        In the end, the 16-bit C code went like the clappers, but was a mere shell and comprised mostly hundreds of lines of 32-bit assembler much of it hand-coded using numeric values (as the 16-bit compiler didn't support 32-bit).

        When I was due to leave, to start my first contract, my magager asked the project leader about this code, and the project leader assured him it would be no problem as it was C. Although I had mentioned the assembler, he luckily had no conception of the untold horrors awaiting anyone who ventured to change it.
        I guess these days, that might be one task you could still hand-write assembly... the difference being you would be hand-crafting the SSE/MMX to parallelise it, image data being friendly in this regard. It's quite a fun area to play with IMO, especially since modern compilers (some anyway) expose intrinsics to use ASM ops directly from C++.
        Originally posted by MaryPoppins
        I'd still not breastfeed a nazi
        Originally posted by vetran
        Urine is quite nourishing

        Comment


          Originally posted by d000hg View Post
          I guess these days, that might be one task you could still hand-write assembly... the difference being you would be hand-crafting the SSE/MMX to parallelise it, image data being friendly in this regard. It's quite a fun area to play with IMO, especially since modern compilers (some anyway) expose intrinsics to use ASM ops directly from C++.
          I've done a load of stuff like that. C++ functions containing _asm statements to do the work. As you say MMX/SSE can make graphics operations run many times faster than you could ever acheive in a higher level language.
          Will work inside IR35. Or for food.

          Comment

          Working...
          X