portability

This is a discussion on portability within the C Programming forums, part of the General Programming Boards category; I'm thinking of learning C (or C++, or Java). I don't like OO, I want to do text processing, I ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    3

    portability

    I'm thinking of learning C (or C++, or Java). I don't like OO, I want to do text processing, I like security, and I'd like to develop stuff on my Windows computer that I could then use on my web host's Apache server, and I want a language more marketable than Python, Haskell, etc. I know I'm not going to get everything.

    Anyway, the thing I'm thinking of now is how portable C is from one Windows OS to another and from one Linux distro to another. Is that an issue at all, or is the only portability issue between Windows and Linux?

  2. #2
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,627
    The answer depends on the application. If you just want an application that compiles anywhere then there are plenty of cross-platform libraries that will help you manipulate sound and graphics and so forth but it depends on what the application exists to do. The things I mentioned may not even be important to a given program's problem domain.

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Portability is dependant on writing good code:
    1. Uses standards compliant code and no compiler implementation specifics.
    2. Doesn't make assumptions about any aspect of the architecture, such as where memory is located, what size or byte order data is stored as, etc.
    3. Doesn't use any specifics of the underlying OS. This means not only avoiding using OS system calls directly, but also avoiding such things as putting "c:\\mydir\\somefile.txt" as a hard-coded path, because in Linux, that path would probably be "/home/matsp/somefile.txt".

    If you MUST use some OS or compiler specifics, make sure you put those functions on the side somewhere so that they are both easy to find and easy to replace.

    The standard C library has many functions to support text manipulation in itself (such as strtok, strcmp, and all the other strXXX functions). Likewise, file handling can be done (with the exception of locating files) in a portable way.

    So as long as you have code that is written with portability in mind, then it's usually easy to make it work on multiple architectures. It helps to set the compiler (for your main portions of code at least) to use "strict standards compliance", so for example, if you use gcc, use "-ansi -pedantic -Wall -Werror", and you will have a good chance of porting the code to other OS's simply because you do not have any non-portable bits of code in your source-files (because it wouldn't build if you did).

    As citizen says, there are cross-platform libraries that are written to "hide" all the nasty details of for example graphical user interfaces, networking or other aspect that otherwise tend to be sensitive to moving between OS's.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by BarryII View Post
    I don't like OO, I want to do text processing
    Well there's a career limiting statement if I ever heard one.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  5. #5
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > Well there's a career limiting statement if I ever heard one
    My CS professor hates OO and Software Engineering . He's doing fine.

  6. #6
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,831
    He's a professor. Those who can't do, teach. LOL

  7. #7
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by zacs7 View Post
    > Well there's a career limiting statement if I ever heard one
    My CS professor hates OO and Software Engineering . He's doing fine.
    Well I said career limiting, not career ending.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  8. #8
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    I'd recommend you look into Perl. It's known for text processing, fairly portable, and used for web things often. It's also fairly marketable.

  9. #9
    Registered User
    Join Date
    Oct 2008
    Posts
    3
    Quote Originally Posted by robwhit View Post
    I'd recommend you look into Perl. It's known for text processing, fairly portable, and used for web things often. It's also fairly marketable.
    When Perl 6 comes out, Perl 5's usage will drop even faster than it's been dropping, and what happens with Perl 6 remains to be seen.

    Also, I already know Perl. It's all I know, and I'm tired of the poor community-written documentation, even in published books. I've been told I use Perl as if it were a low level language. That's partially because I often avoid modules because of poor documentation and questionable stability, and because I avoid OO because I don't like it, and I avoid short but unreadable constructs.

    Also, I may want to compile it and create software with an installer. I've looked into that with Perl and I don't like the options.

  10. #10
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by BarryII View Post
    When Perl 6 comes out, Perl 5's usage will drop even faster than it's been dropping, and what happens with Perl 6 remains to be seen.
    That's ridiculous, guy. It's not like they will be that much different.

    Quote Originally Posted by BarryII View Post
    Also, I already know Perl. It's all I know, and I'm tired of the poor community-written documentation, even in published books. I've been told I use Perl as if it were a low level language. That's partially because I often avoid modules because of poor documentation and questionable stability, and because I avoid OO because I don't like it, and I avoid short but unreadable constructs.
    I "came from perl" (but remain there too) and I totally agree, altho what you say about documentation applies at least as well in C.

    I won't try to talk you out of the choice you seem to have made, tho. The two languages are a very interesting contrast. I've definately come to understand perl better by learning C.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  11. #11
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Quote Originally Posted by BarryII View Post
    I avoid OO because I don't like it
    I'd actually like to know what it is about OO that you don't like?
    For me, it just makes life so much easier...
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  12. #12
    Registered User
    Join Date
    Oct 2008
    Posts
    3
    Quote Originally Posted by cpjust View Post
    I'd actually like to know what it is about OO that you don't like?
    For me, it just makes life so much easier...
    I don't see how it could make anything easier, but I'm not really clear on the idea behind it. From my vague idea of what it does, it's not the kind of thing I need. I think it requires better code organization, which makes things more organized, but I figure I could do that myself in other ways if and when I want to. I also get the idea that it's a drawback for talented programmers, especially for programs under tens of thousands of lines. When I've worked with Perl modules that use OO for configuration, it's like I'm referring to the documentation not to learn what a function does with the data but to learn a required sequence or something, and I'm saying to myself "I've always been able to do so much the normal way, why do I need this?"... or something. I don't get it and I don't want to get it because I don't think I need to get it. I put it in the same category as Perl's strict pragma and localizing variables. I've looked into those more carefully and I don't like them.

  13. #13
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,428
    Just as suggestion, but if you're planning on developing for PCs and so, I wouldn't recommend C.
    Seeing as you're no fan of OOP, I couldn't recommend C++ either. I'm sure there are other, better languages out there suited for the task.
    C is not completely up to the job for modern applications. Nor is it that easy to do text processing in C. There are better languages for that...

    Btw,
    Quote Originally Posted by BarryII View Post
    I also get the idea that it's a drawback for talented programmers, especially for programs under tens of thousands of lines.
    This is completely untrue.
    OOP does not hinder development. Mostly it actually helps development.
    Last edited by Elysia; 10-02-2008 at 08:50 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. COM application portability
    By Opariti in forum Windows Programming
    Replies: 3
    Last Post: 11-21-2008, 12:17 PM
  2. Portability
    By rwmarsh in forum C++ Programming
    Replies: 2
    Last Post: 07-04-2006, 10:36 PM
  3. Replies: 1
    Last Post: 10-24-2005, 06:35 AM
  4. Program Portability (code portability)
    By Perica in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2002, 09:03 AM
  5. what does portability mean?
    By elad in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 10-03-2002, 02:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21