Writing portable code...

Discussion in 'C Programming' started by jacob navia, Sep 2, 2007.

  1. jacob navia

    jacob navia Guest

    There are some people here (let's call them "regulars" for short)
    that are always giving lessons to people about how easy is to
    write portable code, etc. They always point fingers at you telling you
    how bad you write code.

    One of them (I would say the prototype of them) is Heathfield.

    Here is an exchange that happened just a few hours ago, that
    demonstrates my point:

    WRITING CODE IS HARD. And regulars aren't better at it than everybody
    else...

    Ed Jensen wrote
    > There are very few regulars here in comp.lang.c that'll admit that
    > writing 100% portable C code is non-trivial.


    Then, Heathfield answered:

    > I'm one of them, however.
    > I think it's easy to write *very* portable code, but difficult to write
    > 100% portable code. Consider, for example, this simple program:


    [code snipped]

    Harald van Dijk answered:

    >> I can see one very obvious bug: you're using a file after closing it.
    >> That's not the way you should be writing code even if it's not meant
    >> to be portable.

    >


    And Heathfield had to acknowledge...

    > Oh, stupid stupid stupid (me, not you). You're right, of course. That

    was unintentional, by the way!
    >
    jacob navia, Sep 2, 2007
    #1
    1. Advertising

  2. jacob navia

    Army1987 Guest

    On Sun, 02 Sep 2007 10:52:51 +0200, jacob navia wrote:

    > There are some people here (let's call them "regulars" for short)
    > that are always giving lessons to people about how easy is to
    > write portable code, etc. They always point fingers at you telling you
    > how bad you write code.
    >
    > One of them (I would say the prototype of them) is Heathfield.
    >
    > Here is an exchange that happened just a few hours ago, that
    > demonstrates my point:
    >
    > WRITING CODE IS HARD. And regulars aren't better at it than everybody
    > else...

    If you mean that regulars are human, they are, but your statement
    with its verbatim meaning is only true for sufficiently small
    values of "everybody else" <flame>(e.g. you shouldn't be included
    in it)</flame>.

    > Ed Jensen wrote
    > > There are very few regulars here in comp.lang.c that'll admit that
    > > writing 100% portable C code is non-trivial.

    >
    > Then, Heathfield answered:
    >
    > > I'm one of them, however.
    > > I think it's easy to write *very* portable code, but difficult to write
    > > 100% portable code. Consider, for example, this simple program:

    >
    > [code snipped]
    >
    > Harald van Dijk answered:
    >
    > >> I can see one very obvious bug: you're using a file after closing it.
    > >> That's not the way you should be writing code even if it's not meant
    > >> to be portable.

    > >

    >
    > And Heathfield had to acknowledge...
    >
    > > Oh, stupid stupid stupid (me, not you). You're right, of course. That

    > was unintentional, by the way!
    > >

    If someone has anything to say about that, they'll answer on that
    thread. And your question about C was?
    --
    Army1987 (Replace "NOSPAM" with "email")
    No-one ever won a game by resigning. -- S. Tartakower
    Army1987, Sep 2, 2007
    #2
    1. Advertising

  3. "Army1987" <> wrote in message
    news:p...
    > On Sun, 02 Sep 2007 10:52:51 +0200, jacob navia wrote:
    >
    >> WRITING CODE IS HARD. And regulars aren't better at it than
    >> everybody else...

    >
    > If you mean that regulars are human, they are, but your statement
    > with its verbatim meaning is only true for sufficiently small
    > values of "everybody else" <flame>(e.g. you shouldn't be included
    > in it)</flame>.
    >

    A C compiler is quite a difficult piece of software to write. I planned to
    write one as a followup to MiniBasic, but shrank from the challenge.

    --
    Free games and programming goodies.
    http://www.personal.leeds.ac.uk/~bgy1mm
    Malcolm McLean, Sep 2, 2007
    #3
  4. jacob navia

    Richard Guest

    jacob navia <> writes:

    > There are some people here (let's call them "regulars" for short)
    > that are always giving lessons to people about how easy is to
    > write portable code, etc. They always point fingers at you telling you
    > how bad you write code.
    >
    > One of them (I would say the prototype of them) is Heathfield.
    >
    > Here is an exchange that happened just a few hours ago, that
    > demonstrates my point:
    >
    > WRITING CODE IS HARD. And regulars aren't better at it than everybody
    > else...
    >
    > Ed Jensen wrote
    >> There are very few regulars here in comp.lang.c that'll admit that
    >> writing 100% portable C code is non-trivial.

    >
    > Then, Heathfield answered:
    >
    >> I'm one of them, however.
    >> I think it's easy to write *very* portable code, but difficult to write
    >> 100% portable code. Consider, for example, this simple program:

    >
    > [code snipped]
    >
    > Harald van Dijk answered:
    >
    >>> I can see one very obvious bug: you're using a file after closing it.
    >>> That's not the way you should be writing code even if it's not meant
    >>> to be portable.

    >>

    >
    > And Heathfield had to acknowledge...
    >
    >> Oh, stupid stupid stupid (me, not you). You're right, of
    >> course. That

    > was unintentional, by the way!
    >>


    Was it? Wow. If all of us neglected to make the unintentional mistakes I
    fee sure the standards of our code would greatly improve.....
    Richard, Sep 2, 2007
    #4
  5. jacob navia

    santosh Guest

    Malcolm McLean wrote:

    >
    > "Army1987" <> wrote in message
    > news:p...
    >> On Sun, 02 Sep 2007 10:52:51 +0200, jacob navia wrote:
    >>
    >>> WRITING CODE IS HARD. And regulars aren't better at it than
    >>> everybody else...

    >>
    >> If you mean that regulars are human, they are, but your statement
    >> with its verbatim meaning is only true for sufficiently small
    >> values of "everybody else" <flame>(e.g. you shouldn't be included
    >> in it)</flame>.
    >>

    > A C compiler is quite a difficult piece of software to write. I planned to
    > write one as a followup to MiniBasic, but shrank from the challenge.


    Indeed. However jacob has, to my knowledge, written only the machine code
    generating and optimising portions of lcc-win32. The front-end is mostly
    lcc. But I'm not deprecating his efforts.
    santosh, Sep 2, 2007
    #5
  6. jacob navia

    Tor Rustad Guest

    jacob navia wrote:
    > There are some people here (let's call them "regulars" for short)
    > that are always giving lessons to people about how easy is to
    > write portable code, etc. They always point fingers at you telling you
    > how bad you write code.
    >
    > One of them (I would say the prototype of them) is Heathfield.



    If I post code, I like to get it corrected. Don't you?

    Sometimes, the mistakes are rather uninteresting, typos that would be
    detected by a compiler anyway, but in other cases the experts do teach
    me something new.

    Regulars that post solid code, are a great asset, "anybody" can post a
    quote from the standard.


    My PB for a clean compile in C, is ca a 1600 liner... that don't mean it
    was bug-free.

    --
    Tor <torust [at] online [dot] no>
    Tor Rustad, Sep 2, 2007
    #6
  7. jacob navia

    Martin Wells Guest

    On Sep 2, 9:52 am, jacob navia <> wrote:
    > There are some people here (let's call them "regulars" for short)
    > that are always giving lessons to people about how easy is to
    > write portable code, etc. They always point fingers at you telling you
    > how bad you write code.
    >
    > One of them (I would say the prototype of them) is Heathfield.


    I wuda used a word something like apotheosis.


    > Here is an exchange that happened just a few hours ago, that
    > demonstrates my point:
    >
    > WRITING CODE IS HARD. And regulars aren't better at it than everybody
    > else...



    It's piss easy really.

    Still preaching about your own incompetence.

    Martin
    Martin Wells, Sep 3, 2007
    #7
  8. On Sun, 02 Sep 2007 19:12:34 +0530, santosh wrote:

    > Malcolm McLean wrote:
    >
    >>
    >> "Army1987" <> wrote in message
    >> news:p...
    >>> On Sun, 02 Sep 2007 10:52:51 +0200, jacob navia wrote:
    >>>
    >>>> WRITING CODE IS HARD. And regulars aren't better at it than
    >>>> everybody else...
    >>>
    >>> If you mean that regulars are human, they are, but your statement
    >>> with its verbatim meaning is only true for sufficiently small
    >>> values of "everybody else" <flame>(e.g. you shouldn't be included
    >>> in it)</flame>.
    >>>

    >> A C compiler is quite a difficult piece of software to write. I planned to
    >> write one as a followup to MiniBasic, but shrank from the challenge.

    >
    > Indeed. However jacob has, to my knowledge, written only the machine code
    > generating and optimising portions of lcc-win32. The front-end is mostly
    > lcc. But I'm not deprecating his efforts.


    Frankly, if the generation and optimization portions are any good, that'd
    be quite a feat in and of itself.
    Kelsey Bjarnason, Sep 3, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eli Bendersky
    Replies:
    1
    Views:
    1,162
    Mike Treseler
    Mar 1, 2006
  2. Replies:
    7
    Views:
    916
  3. Jason Curl

    Writing portable software

    Jason Curl, Mar 14, 2005, in forum: C Programming
    Replies:
    10
    Views:
    690
    Flash Gordon
    Mar 15, 2005
  4. Richard Giuly
    Replies:
    5
    Views:
    2,755
    Noah Roberts
    Jul 31, 2006
  5. ArifulHossain tuhin

    Writing "absolutely" portable code

    ArifulHossain tuhin, Jan 9, 2012, in forum: C Programming
    Replies:
    62
    Views:
    1,223
    Ian Collins
    Jan 21, 2012
Loading...

Share This Page