Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: The delay of printing encountered using loop

by Diamondust (Novice)
on Jun 26, 2012 at 12:24 UTC ( [id://978404]=note: print w/replies, xml ) Need Help??


in reply to Re: The delay of printing encountered using loop
in thread The delay of printing encountered using loop

That's very interesting.
I guess my initial experience on Turbo C gave me this opposite feeling.
#include <stdio.h> /* #include <unistd.h> */ main(){ while(1){ sleep(1); printf("123"); } return 0; }

The above code, when running on Windows Turbo C, it prints 123 every second without the necessity of a NL character. But when compiled on g++ on Unix, it never prints anything because of no NL for the stream to be flushed.

But ActicePerl on Windows has the same behavior as on Unix, i.e. it prints nothing without seeing an NL character.

Is this because Perl tries hard to make itself platform independent, or it's because that Turbo C is archaic and has such different behavior than every one else?

Replies are listed 'Best First'.
Re^3: The delay of printing encountered using loop
by Anonymous Monk on Jun 26, 2012 at 21:24 UTC

    I would guess it's Turbo C being not so turbo...

    (It's not g++'s fault. It's the C library's fault. Back in DOS-land, compilers actually came with their own C libraries.[citation needed] Perl emulates its own print commands, and with it, has its own output buffers.)

      I see.
      I don't bother to install Visual C++ and test the result then -- it's too large.
      Maybe Microsoft decides to write its own library in a complete different behavior.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://978404]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (12)
As of 2024-04-16 07:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found