Like Tree3Likes
  • 2 Post By brewbuck
  • 1 Post By Cat

C on the web

This is a discussion on C on the web within the Tech Board forums, part of the Community Boards category; Has anyone tried to use C on the web? At this point in my class, we are doing web work. ...

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    68

    C on the web

    Has anyone tried to use C on the web? At this point in my class, we are doing web work. I am trying to get a program to run on my browser and it is not displaying the output. Instead, it is letting me download it.

    Code:
    main()
    {
        printf("content-type:text/plan\n\n");
    
         printf("...");
    }//end main
    Instead of downloading, I want it to run directly on the browser. I am running linux with the LAMP stack on. Help is appreciated. Thanks
    What am I doing wrong?

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,148
    What am I doing wrong?
    O_o

    You haven't correctly configured your environment to execute the binary, your CGI program, so your browser does what it does for the same MIME type. (The server is just telling the browser about the file and MIME type.)

    I don't run "LAMP" anymore so I have no idea where to get you started, but throwing "Apache CGI configuration" at your search engine of choice will do the job.

    [Edit]
    Also, this has nothing to do with programming.
    [/Edit]

    Soma

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    68
    Quote Originally Posted by phantomotap View Post
    O_o

    You haven't correctly configured your environment to execute the binary, your CGI program, so your browser does what it does for the same MIME type. (The server is just telling the browser about the file and MIME type.)

    I don't run "LAMP" anymore so I have no idea where to get you started, but throwing "Apache CGI configuration" at your search engine of choice will do the job.

    [Edit]
    Also, this has nothing to do with programming.
    [/Edit]

    Soma

    Thanks. Thought that that was the case. I think that there are much better solutions and better languages to interact with the web. Be honest. Would it be especially useful for me to use c towards this end?

  4. #4
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,230
    If you want to be a web developer, starting out by learning C makes almost no sense.
    rags_to_riches and Salem like this.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,831
    I think C could still be perfectly viable. If you can't parse your own environment variables (FORMs etc) or generate dynamic HTML using C then you shouldn't be programming. I was doing these things 20 years ago: back in 1993 to 2000. Before server-side what's-its and JAVA and such. Ran faster than any code cooked up today precisely because it was simple and straight forward. And get off my lawn.

  6. #6
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,148
    Ran faster than any code cooked up today precisely because it was simple and straight forward.
    I know what you are getting at, but it has to be said: my cellphone runs faster than anything you were doing in 1993.

    Anyway, using C, C++, or whatever for a living web isn't a bad choice because of that stuff.

    The languages you are playfully shooting down almost live for the web. (I certainly would have never learned PHP if it wasn't for my host supporting it so very many years ago.) The functionality, the libraries, the almost universal availability, and the simplicity of debugging them remotely without shell access (Rant: Hosts that don't offer shell access suck!) is worth the price of admission that is learning a new language.

    Example: I'd certainly be able to do the rewrite I'm working on in C++ faster than I'm managing it with Python, and it run a lot faster. (It has been over three months; I'd probably be done.) I unfortunately wouldn't be able to run it on a lot of cheap, or free, hosts because they forbid native code. It would also be less palatable to the community I'm targeting which means I'd have less interest so more work on my plate. It also means having to write more code than I'd have to write otherwise, or using third-party libraries and tools anyway, because such languages have a lot of the necessary functionality as core features.

    Soma

  7. #7
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,230
    Quote Originally Posted by nonoob View Post
    I think C could still be perfectly viable. If you can't parse your own environment variables (FORMs etc) or generate dynamic HTML using C then you shouldn't be programming. I was doing these things 20 years ago: back in 1993 to 2000. Before server-side what's-its and JAVA and such. Ran faster than any code cooked up today precisely because it was simple and straight forward. And get off my lawn.
    Depends what "viable" means. Using C for the web is viable technically, but not viable career-wise. You're not going to survive if your resume says "Experienced C Web Developer." People are going to think you're smoking crack.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  8. #8
    Cat
    Cat is offline
    Registered User
    Join Date
    May 2003
    Posts
    1,571
    Quote Originally Posted by nonoob View Post
    Ran faster than any code cooked up today precisely because it was simple and straight forward. And get off my lawn.
    Not necessarily faster in the way that actually matters - the user's perception of responsiveness. With techniques like AJAX you can do heavy lifting asynchronously, and handle data submission and page updates without having to reload a whole page. Even if it eats more server CPU, it presents a better user experience.

    I overcame my disdain for JavaScript purely because of how useful it can be for end user experience.
    laserlight likes this.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

Popular pages Recent additions subscribe to a feed

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