Young people who only talk to other young people, who work in a technical field and only hang out with their tech-geek friends, get a very distorted view of what "most people" know/think/believe/care about. Sure, their mom may know about some tech issues - because they told their mom, and mom said "yes, dear, that's nice". Or maybe mom is a tech-geek herself.
Someone with that mindset just will not believe you that MOST people are clueless. Even most young people. Young people, as a group, are certainly more comfortable with lots of gadgets than "old" people, but that doesn't mean they know how it works or understand any of the issues involved.
Only the very small "gee whiz" early adopters care at all about, the majority don't see what's wrong with their DVD players. The VAST majority.
You could say the same thing about the "worst public relations disasters in a long time". Very few people know about "DRM rootkits", no one buys their laptop batteries directly from Sony, it's Dell and Apple that they got bad batteries from.
You make it sound as if all of TN and all of CA is just one simple market, and the only distinguishing feature is that one has Walmart and the other doesn't. Surprise, Walmart exists in California too! It's not like the reason California gas prices are so high is because they don't have enough Walmarts compared to the rest of the country.
Small towns with one or two gas stations don't have much incentive to lower prices, depending on how close the next nearest place is. Lots of places have LOTS of gas stations, though, and price competition is quite high. In fact, your description of price variations being no more than 2 cents is quite common, and indicates that there IS competition. Sure, Walmart coming in and trying to be disruptive will shake things up for a bit, but not for long, just until a new equilibrium comes along.
Prices here have dropped about 70 cents over the last 3 or 4 weeks, and it isn't because of Walmart moving in, they've been here all along, and their prices have been about the same as everyone else's, usually 1-2 cents less than most, about the same as a couple. Then there are those stations that charge 10-15 cents MORE than everyone else, and you wonder who's buying there.
Using an instance of "well, in my hometown, Walmart came there and now prices are 30 cents less than they are more than halfway across the country" just doesn't stand up. There are way too many variations for way too many reasons to be able to just look at a few cases and think you understand what is going on.
There already is a "new kind of license for flying cars". It's called a pilot's license (or more properly, certificate). There's a category of aircraft called "powered lift" that covers the flying-car type of device (e.g. Moller Skycar). Needless to say, there aren't a whole heck of a lot of people who have that certificate yet!
Walmart may sell 40% of ALL DVDs sold in the US, but that doesn't mean that if they stop selling all or a subset of DVDs, sale of those DVDs will drop by 40%. It will certainly drop some, but if that is offset by the on-line distribution sales, so what? Walmart's prices on DVDs aren't that good; they beat Amazon by about 11 cents per title. If Walmart isn't carrying a movie, people will just buy it somewhere else. People who aren't looking for a specific title, are just browsing for "a DVD", will probably either be buying the bargain basement titles or renting them. Walmart may even lose sales on the DVDs they do choose to carry, from the people who are no longer coming in to get those titles they no longer offer. Amazon may be the big winner here, not from Unbox, but from selling DVDs that Walmart won't carry.
It's extremely unlikely that Walmart is responsible for a $0.60/gallon price differential in the cost of gasoline, or even a $0.30/gallon difference. Sure, they put some pressure on lowering prices, but not that much. There's plenty of competition between gas stations, Walmart doesn't have that kind of pricing power in that field.
Around here, Sam's Club is usually about a penny cheaper than the Walmart pumps (but Sam's Club is member's only now), and Meijer (across from the Walmart) is usually a penny or two higher. Other gas stations still do plenty of business, with prices 2-10 cents higher. In other nearby towns, without a Walmart or Sam's Club, prices are sometimes higher, sometimes lower.
Plenty of small town economies crash because of Walmart. Read The Walmart Effect for some interesting studies.
No, that has nothing to do with region coding. Most DVD players now can play PAL or NTSC and convert them to either. The region coding is because they want to avoid people being able to buy a DVD wherever it is being sold at the lowest price, and thus be able to price it high in one country, and low in another country, depending on local demand and economy. It is also used to manage release windows - a movie may still be in theaters or first-run TV release, and they don't want DVD sales to interfere.
You do realize that PAL and NTSC are very similar in terms of color, right (except PAL has lower resolution for color information)? The difference with alternating phases is pretty much irrelevant when connected directly to a DVD player, and quality is much lower than with S-Video or component anyway. The other main difference is that PAL is normally used with about 19% more scan lines, but NTSC refreshes about 20% more often.
Of course, there are differences when converting from 24-fps film, where PAL often just speeds it up a little bit. Like your films fast, do you? Converting between NTSC and PAL can lead to artifacts which can make for remarks like "rubbish NTSC standard", if the only NTSC you've seen has been converted to PAL, or vice-versa.
With digital television, of course, you eliminate all of that. And guess what? It isn't going to eliminate region coding!
Depends on if you want to call the operating system a "library", and if so, if it is an "external" library. You're right that "ANSI standard C/C++" doesn't include sockets. It also doesn't include a whole lot of things that any program that wants to do anything other than manipulate stdin/stdout/stderr and regular files would need. There are, however, a whole lot of standards. In a POSIX environment, using the "standard C library" for that system would not be an "external" library. Depending on the system call interface, there may not even be any of those POSIX calls implemented, even as wrappers, in a loadable library.
First, this was presented as a programming exercise, not producing something useful. Regardless, a simple web server can be just that, one that doles out static pages, maybe has the capability of executing external processes, with or without POST. It doesn't have to do multi-hosting. It doesn't have to support in-process scripting (although adding Tcl would be trivial). Using multi-threading to allow multiple connections is slightly easier than using select, and certainly less resource intensive than using fork (or inetd, which is practically the same thing). That "all the good web servers don't use it" is not an argument against using multi-threading.
It is also not difficult to make it secure, not leak memory, and not crash. Sometimes tedious, but not difficult.
Parsing HTTP headers is not rocket science. The link you gave is a good one, but using the specs is all you need to implement a correct implementation. Now, what you DO with the parsed headers is another matter, but fortunately HTTP/1.0 is fairly generous in not requiring you to implement much. When I said that someone who can't parse a GET request is pretty lame, I didn't mean that all they need to do is look for GET, one space, a bunch of non-space characters, one space, "HTTP/???", and a CRLF and they're done. What I meant was that parsing it doesn't require you to use some HTTP library because doing it yourself is just oh too difficult for mere mortals.
And yes, it can be done in 3-4 hours. Much shorter if the only requirement is that it work with one or a few specific browsers that don't send in deliberately weird cases of legal-but-ridiculous HTTP headers.
Sorry, I was merging in someone else's thread where they were saying that since they couldn't use even the standard libraries (like malloc, or the wrapper interfaces to system calls), the job obviously couldn't be done and that's what they'd tell them. You, on the other hand, would write your own equivalent to crt1.o, your own wrappers to read/write/close/exit (exit per se isn't needed in the program, but the run-time setup/exit code would still need to use the exit system call), all because you discount the meaning of "external library", and instead seem to think that "of any kind" trumps it. Presumably you're going to copy in all the constants out of the kernel that you'll need, as well, since using the standard system include files would seem to fall under "using" that library.
I don't disagree that one can write a simple web server in 3-4 hours, even if you're only going to use read/write/open/close/exit (and, if not using inetd, socket, bind, listen, accept, and either fork or select if you want to handle multiple connections), maybe a few others like stat, setsockopt, dup, pipe, and write all of your own string manipulation routines. But unless the position includes working with implementing glibc, a compiler, the operating system, an interpreter run-time or something at that level, the interpretation of "no external libraries" to include the standard C/C++ libraries is rather extreme. It's possible that what they wanted was what you think, it's possible that what they wanted was to be told "your specifications are inadequate, your requirements are untenable, I can't do the job without more information". The original poster said "the specs were extremely vague", but didn't indicate if the requirement "no external libraries of any kind" was explained in more detail. Given NO other information, you have to make a reasonable guess as to what they meant. I think that thinking they meant you couldn't use anything in crt/libc/libstdc++ is going way overboard. When you produce a program that has all your own system-call wrappers, is called from inetd, and has minimal functionality, and I produce in the same time something that properly uses the standard system library routines, is more efficient (because I didn't use inetd), maybe has more features (I added in the ability to run programs/scripts), which one do you think is going to show a more productive programmer?
BTW, I wasn't saying that your interpretation of the requirements meant you'd have to write your own C compiler, but certainly a reasonable interpretation of "external library", given your interpretation of it, includes most of the code in an operating system - after all, what's a TCP stack but a standard set of routines, with a standard calling interface, that performs a well-defined task. Just because it uses a different calling mechanism doesn't mean it isn't a library. If the socket system call isn't a library call, then characterizing a wrapper routine as a library routine would also be wrong, especially as it wouldn't even be implemented that way on all systems. What I was saying was that if you're going to start throwing stuff away, why stop there, why not go whole hog and implement everything but the BIOS? That'll really show them what you can do. As I said, I'D be impressed, even if it turned out that you were completely misinterpreting the requirements.
If they wanted to know if you knew the difference between calls (explicit or implicit) to standard libraries, what generates those calls, how C++ dynamic overloading works, how calls to the operating system work, what kind of things get in-lined, I'd think they'd just ask you, not see how you interpret "no external libraries of any kind". If they wanted to see if you could write a fairly small program that deals with sockets, strings, file I/O, maybe multiple processes, multiplexing, pipes, and follow a relatively simple well-known specification without a lot of hand-holding, they'd ask you to write a simple web server in 3-4 hours, using only the standard librari
A more obvious meaning for their request is that they want you to write a simple web server without pulling in a bunch of libraries already written that implement a web server so that you can write "HTTPserver server = new HTTPserver(localhost, "http"); return server.process("/usr/local/http");" and claim you know how to implement a webserver in C++. "of any kind" simply means that they include string parsing libraries, socket handling libraries, error logging libraries, or anything else. "external" is much more the relevant phrase, and OBVIOUSLY means "not part of the actual implementation of the C/C++ compiler suite". So yes, "new", "malloc", "printf" would be allowed. "3-4 hours" is also a pretty big clue as well - since that's a reasonable estimate of the time it would take to write something like that using only the language-standard facilities.
Saying "well, you SAID no external libraries of ANY KIND, so I took that to mean whatever would get me out of having to do it" certainly wouldn't impress me, unless you then went on to implement your own C compiler, operating system, Ethernet drives, TCP/IP services, wrote the web server for that, installed the whole thing as a boot block and brought it up by booting it straight from the BIOS. That would probably take a bit more than 3-4 hours, though, so it probably isn't what they meant.
Your approach is basically saying "hahaha, you guys suck, you don't even know what's implemented as libraries in a C++ program, so I'm going to show you up by saying it can't be done". You've shown that you'd be very difficult to work with.
The words used by the poster were "no external libraries of any kind", not "no libraries of any kind". All that stuff in the standard C/C++ libraries is PART OF THE LANGUAGE, you don't have to care whether it is implemented as libraries or compiled into your program with in-lining, it isn't an "external library". Your code might be running in a C byte-code interpreter, with all of the standard routines implemented inside the interpreter. Being pig-headed literal in a job interview is no way to impress them with your ability to get things done. Communication skills are important!
The code emitted by a C compiler is going to assume at least a FEW things that the entry stub code has to set up, so you can't really just make main your program entry point, in most cases. Depends on the OS environment, of course.
Using inetd is a good solution, eliminates the need to do any of your own socket programming. I'd do that, then write another version that does it without inetd, but is limited to one connection at a time; then go ahead and modify THAT to do a select-based dispatcher to handle multiple connections; then integrate in the ability to run scripts in separate processes, managing the pipes and sockets and connections all through that one select. Submit all four versions, with the original inetd-based one mostly implemented as a library that is used by all 4 versions. If you end up with a nice generic library to handle processes, pipes, sockets and connections as well, so much the better.
Of course it was the wrong answer. The ability to analyze a bit of C code (whether or not you think it's "abberent") is an important skill, when determining what a piece of code IS doing as opposed to what it APPEARS to be doing or is DOCUMENTED as doing.
Or they hire someone who enjoys programming and would find the minor challenge of writing a simple web server in 3-4 hours to be fun. In fact, I may just go write a simple web server in 3-4 hours right now, just for the fun of it.
You can obviously use the libraries defined by standard C/C++, they are part of the language, they are NOT "external libraries". Look to the standard to figure out what you can and can't use. Just because most implementations of C/C++ link in the standard libraries dynamically doesn't mean they are "external libraries". You obviously aren't right for the job if you're going to take a dumb hard-line hyper-literal attitude like that.
Writing a simple web server is trivial. It doesn't even need to be multi-threaded, though it wouldn't be difficult to make it serve multiple connections at once with select.
Someone who can't write the code to parse out a GET request is pretty lame. Heck, you SHOULD be able to write it all in 3-4 hours using nothing but system calls, no section (3) library calls at all. That is, you get to use socket, select, open, read, write. Write your own damned string parsing routines, most of them are about 3-15 lines long. No, you don't get to use malloc; include (and check) reasonable limits on string lengths, simultaneous connections, etc, then you won't need to dynamically allocate memory. If you insist, create your own memory allocator, using anonymous mmap to get more raw memory, but it won't be worth it. Might impress them, though.
Suggestion: create an index file mapping URL to static file to return. Look up the URL, return the file. Manage the index file manually, with Perl, with shell scripts, whatever, they didn't tell you how to administer the server. If you're feeling slightly ambitious and want to impress them, include the ability to run programs with simple arguments passed in on the command line. Heck, you could even include POST and PUT support without too much trouble, but that might take more than 3-4 hours to get it all working just right, dealing with multiple processes and pipes that can block, etc, all while also dealing with multiple sockets, any of which can close or die unexpectedly, can be a bit tricky. I'd start off writing a generic process-handler library and integrate it with the socket handler so everything can be run off of one select (or poll) call. But, if you do that, come up with a better solution than CGI.
Specifications? All you need to do is implement a subset of HTTP. If you can't look up the specs to that, I certainly wouldn't hire you. Since they didn't give you any other requirements, I'd consider the job done when a standard web browser (your choice) can connect to it and follow links. It's not like you have to implement PHP or JSP or whatever for the thing! I think 3-4 hours is reasonable. If you don't, you obviously weren't the right person for the job.
In the "real" world, I've seen people jump through so many hoops to use some pre-written poorly-defined-and-implemented library that it would have been easier to just write the damned code in the first place. That includes using C++ in the first place, when just using C would have been more appropriate.
So, in the casino, when you're playing poker, and you make people think you have a full house when you have a busted straight, should the cops come in and arrest you for fraud? After all, you took someone else's money from them by tricking them into believing something that wasn't true!
If a game allows for killing someone and robbing items off the dead body, or a "thief" type who can steal items from someone, and that's totally within the accepted rules of the game, should the cops be called in for murder and theft when someone does it? Why should a Ponzi scheme be any different?
Now, when you pay someone real money to transfer you items inside a game, if that person fails to transfer the items it would be breach of contract. That was a transaction that occurred outside the game, requiring performance inside the game.
Where things get sticky is when the game allows for transfers back FROM game money to real money. If some of that game money came from what would be an illegal source in the outside world (Ponzi scheme, gambling), then changing the game money for real money would be the illegal act, I think. Where it REALLY gets sticky is in trying to track the movement of such tainted game money. I'm very uncomfortable with the idea of someone who is running a game having to track all transactions between players to prevent money laundering and such, whether or not they themselves support the exchange back to real money in the first place.
Here's a point to ponder as well. If I say "if you don't give me xxxx game dollars, I'm going to kill your puppy", that's clearly extortion. If I say "if you don't give me xxxx game dollars, I'm going to destroy your castle", is that illegal? Even if the game money is exchangeable for real money? How about "... I'm going to tell all your friends lies to trash your reputation"?
There's no such thing as a "more energy-dense ethanol". Ethanol is ethanol. It may be more efficient to produce using sugar cane or beets than corn, but the end product is identical.
You have to be careful when looking at such figures - some of them include the solar energy input as part of the "input" side of the equation, some of them make unwarranted assumptions about how far you have to transport items, some of them don't look at the byproducts as being anything but waste, nor look at what might have otherwise been waste being used in the process.
Actually, it doesn't function like a control-click, it actually sends in "button 2" (and you can configure button1-button4, no action, or various things like Exposé, for any of the four "buttons": left, right, scrollball, and side button). Control-click is taken to mean the same thing as "button 2" in most places, but the difference can be clearly determined in the software.
I've seen a few people have problems with the Mighty Mouse - they rest both fingers on both sides of the mouse, sometimes lifting one or the other, so have problems with consistently left-clicking. I've had no problems at all with it, other than the scroll ball sometimes failing to respond in one direction (rollers get dirty, no way to take it out to clean it, but a cotton swab and a touch of isopropyl alcohol and swirling the ball around a little, seems to clear it right up).
The Cyber architecture had typically two main CPUs (60-bit), and 12-20 "Peripheral Processing Units", which were much lower capacity, 12-bit processors. The CPUs were started and stopped by the PPUs, and had no interrupt architecture. Control of the system was actually in the PPUs, they loaded programs into memory, set up memory mapping, handled context switches and system requests. PPUs themselves were implemented as shared hardware with multiple contexts, and control actually changed after each instruction to the next PPU (which lead to certain deterministic behavior which was sometimes exploited to bypass the need for interlocks in certain cases). In later versions, there was a CPU instruction "Exchange Jump", which saved the current program context and loaded the system monitor context, which could start up the next process that was ready, but that was used mostly for requesting immediate processing of a system request (normally you stuck a request in your (relocated) memory location 1, then waited for a bit to change in that word to indicate the request had been processed. Most system requests themselves also had provision for asynchronous processing of requests; you didn't have to wait until it was complete, you just continued on and checked later to see if it was done. System requests were picked up by one of the PPUs scanning each process (if you didn't do an exchange jump).
Although their primary purpose was to control the details of running the CPU, and (as evidenced by the name) control peripheral devices, they could also be used to do additional processing in parallel with the main CPU. Remember, the main CPU was faster, and instruction execution time was on the order of a microsecond; given that these processors are on
the order of a 1000 times faster, I think that all you need to get good performance out of it is good bit-banging programmers who aren't afraid of getting down and dirty with the hardware. Lunar lander on a vector graphics display was pretty amazing.
Transfer, as I'm using it, is the creation of a new copy, while simultaneously destroying the old copy. It is clearly a fair use copy in the situation where I've paid for said copy to an authorized distributor. The initial copy, that I bought, was created in their server as they transferred it to the network. That copy disappears as it is sent, and the copy on my hard drive is created. The bits on the network are not a copy, that's true enough, but irrelevant. They ARE sending me a copy, and it IS very much like a teleporter.
Court cases have covered the situation where the initial copy was not authorized, hence distribution of that copy (which, by the way, DOES include magically making bits appear on the other end of a wire, such as a TV broadcast) is also not authorized, hence the copy that shows up on my hard drive is infringing (regardless of who is doing the copying). When the initial distribution IS authorized, I do not need a license to make a copy of it. It isn't any different from recording a TV show over the air, I don't need a license to do that. The court cases are assigning liability for the fact that an infringing copy was made. There's nothing to exclude the ability of an authorized distributor to cause an authorized copy to be made on my computer.
If I connect to an FTP server and copy some content from my computer to the server, did I create a copy on that server? If I own the copyright, can I sue the person who owns the server for having made an unauthorized copy? If he requested that I send it to him by sending me e-mail, now is he the one doing the copying? If instead of me doing the transfer, I've set things up so an automated process reads his e-mail, then does the transfer, is he now liable for making an unauthorized copy? How is that any different from having my e-mail processor automatically burn a CD, label a package and cause it to be mailed? How, in ANY sane interpretation of the law, would the person who sent the e-mail be found liable for having made an infringing copy? So how is that ANY different from my clicking a button in iTunes and Apple sending me a copy of a song? iTunes and the iTMS are very tightly coupled, a very good argument can be made that they constitute a single distributed application. Since I obviously don't own their servers, it must be Apple doing the copying, at my request. If the resulting copy were to be infringing, I might be found liable for copying, sure, but since the resulting copy IS AUTHORIZED, I don't need a license, any more than I need a license to buy a CD from Best Buy and then play it on my CD player (where multiple non-infringing copies get made in the course of playing it).
Young people who only talk to other young people, who work in a technical field and only hang out with their tech-geek friends, get a very distorted view of what "most people" know/think/believe/care about. Sure, their mom may know about some tech issues - because they told their mom, and mom said "yes, dear, that's nice". Or maybe mom is a tech-geek herself.
Someone with that mindset just will not believe you that MOST people are clueless. Even most young people. Young people, as a group, are certainly more comfortable with lots of gadgets than "old" people, but that doesn't mean they know how it works or understand any of the issues involved.
You could say the same thing about the "worst public relations disasters in a long time". Very few people know about "DRM rootkits", no one buys their laptop batteries directly from Sony, it's Dell and Apple that they got bad batteries from.
You make it sound as if all of TN and all of CA is just one simple market, and the only distinguishing feature is that one has Walmart and the other doesn't. Surprise, Walmart exists in California too! It's not like the reason California gas prices are so high is because they don't have enough Walmarts compared to the rest of the country.
Small towns with one or two gas stations don't have much incentive to lower prices, depending on how close the next nearest place is. Lots of places have LOTS of gas stations, though, and price competition is quite high. In fact, your description of price variations being no more than 2 cents is quite common, and indicates that there IS competition. Sure, Walmart coming in and trying to be disruptive will shake things up for a bit, but not for long, just until a new equilibrium comes along.
Prices here have dropped about 70 cents over the last 3 or 4 weeks, and it isn't because of Walmart moving in, they've been here all along, and their prices have been about the same as everyone else's, usually 1-2 cents less than most, about the same as a couple. Then there are those stations that charge 10-15 cents MORE than everyone else, and you wonder who's buying there.
Using an instance of "well, in my hometown, Walmart came there and now prices are 30 cents less than they are more than halfway across the country" just doesn't stand up. There are way too many variations for way too many reasons to be able to just look at a few cases and think you understand what is going on.
There already is a "new kind of license for flying cars". It's called a pilot's license (or more properly, certificate). There's a category of aircraft called "powered lift" that covers the flying-car type of device (e.g. Moller Skycar). Needless to say, there aren't a whole heck of a lot of people who have that certificate yet!
Walmart may sell 40% of ALL DVDs sold in the US, but that doesn't mean that if they stop selling all or a subset of DVDs, sale of those DVDs will drop by 40%. It will certainly drop some, but if that is offset by the on-line distribution sales, so what? Walmart's prices on DVDs aren't that good; they beat Amazon by about 11 cents per title. If Walmart isn't carrying a movie, people will just buy it somewhere else. People who aren't looking for a specific title, are just browsing for "a DVD", will probably either be buying the bargain basement titles or renting them. Walmart may even lose sales on the DVDs they do choose to carry, from the people who are no longer coming in to get those titles they no longer offer. Amazon may be the big winner here, not from Unbox, but from selling DVDs that Walmart won't carry.
It's extremely unlikely that Walmart is responsible for a $0.60/gallon price differential in the cost of gasoline, or even a $0.30/gallon difference. Sure, they put some pressure on lowering prices, but not that much. There's plenty of competition between gas stations, Walmart doesn't have that kind of pricing power in that field.
Around here, Sam's Club is usually about a penny cheaper than the Walmart pumps (but Sam's Club is member's only now), and Meijer (across from the Walmart) is usually a penny or two higher. Other gas stations still do plenty of business, with prices 2-10 cents higher. In other nearby towns, without a Walmart or Sam's Club, prices are sometimes higher, sometimes lower.
Plenty of small town economies crash because of Walmart. Read The Walmart Effect for some interesting studies.
No, that has nothing to do with region coding. Most DVD players now can play PAL or NTSC and convert them to either. The region coding is because they want to avoid people being able to buy a DVD wherever it is being sold at the lowest price, and thus be able to price it high in one country, and low in another country, depending on local demand and economy. It is also used to manage release windows - a movie may still be in theaters or first-run TV release, and they don't want DVD sales to interfere.
You do realize that PAL and NTSC are very similar in terms of color, right (except PAL has lower resolution for color information)? The difference with alternating phases is pretty much irrelevant when connected directly to a DVD player, and quality is much lower than with S-Video or component anyway. The other main difference is that PAL is normally used with about 19% more scan lines, but NTSC refreshes about 20% more often.
Of course, there are differences when converting from 24-fps film, where PAL often just speeds it up a little bit. Like your films fast, do you? Converting between NTSC and PAL can lead to artifacts which can make for remarks like "rubbish NTSC standard", if the only NTSC you've seen has been converted to PAL, or vice-versa.
With digital television, of course, you eliminate all of that. And guess what? It isn't going to eliminate region coding!
Depends on if you want to call the operating system a "library", and if so, if it is an "external" library. You're right that "ANSI standard C/C++" doesn't include sockets. It also doesn't include a whole lot of things that any program that wants to do anything other than manipulate stdin/stdout/stderr and regular files would need. There are, however, a whole lot of standards. In a POSIX environment, using the "standard C library" for that system would not be an "external" library. Depending on the system call interface, there may not even be any of those POSIX calls implemented, even as wrappers, in a loadable library.
First, this was presented as a programming exercise, not producing something useful. Regardless, a simple web server can be just that, one that doles out static pages, maybe has the capability of executing external processes, with or without POST. It doesn't have to do multi-hosting. It doesn't have to support in-process scripting (although adding Tcl would be trivial). Using multi-threading to allow multiple connections is slightly easier than using select, and certainly less resource intensive than using fork (or inetd, which is practically the same thing). That "all the good web servers don't use it" is not an argument against using multi-threading.
It is also not difficult to make it secure, not leak memory, and not crash. Sometimes tedious, but not difficult.
Parsing HTTP headers is not rocket science. The link you gave is a good one, but using the specs is all you need to implement a correct implementation. Now, what you DO with the parsed headers is another matter, but fortunately HTTP/1.0 is fairly generous in not requiring you to implement much. When I said that someone who can't parse a GET request is pretty lame, I didn't mean that all they need to do is look for GET, one space, a bunch of non-space characters, one space, "HTTP/???", and a CRLF and they're done. What I meant was that parsing it doesn't require you to use some HTTP library because doing it yourself is just oh too difficult for mere mortals.
And yes, it can be done in 3-4 hours. Much shorter if the only requirement is that it work with one or a few specific browsers that don't send in deliberately weird cases of legal-but-ridiculous HTTP headers.
Sorry, I was merging in someone else's thread where they were saying that since they couldn't use even the standard libraries (like malloc, or the wrapper interfaces to system calls), the job obviously couldn't be done and that's what they'd tell them. You, on the other hand, would write your own equivalent to crt1.o, your own wrappers to read/write/close/exit (exit per se isn't needed in the program, but the run-time setup/exit code would still need to use the exit system call), all because you discount the meaning of "external library", and instead seem to think that "of any kind" trumps it. Presumably you're going to copy in all the constants out of the kernel that you'll need, as well, since using the standard system include files would seem to fall under "using" that library.
I don't disagree that one can write a simple web server in 3-4 hours, even if you're only going to use read/write/open/close/exit (and, if not using inetd, socket, bind, listen, accept, and either fork or select if you want to handle multiple connections), maybe a few others like stat, setsockopt, dup, pipe, and write all of your own string manipulation routines. But unless the position includes working with implementing glibc, a compiler, the operating system, an interpreter run-time or something at that level, the interpretation of "no external libraries" to include the standard C/C++ libraries is rather extreme. It's possible that what they wanted was what you think, it's possible that what they wanted was to be told "your specifications are inadequate, your requirements are untenable, I can't do the job without more information". The original poster said "the specs were extremely vague", but didn't indicate if the requirement "no external libraries of any kind" was explained in more detail. Given NO other information, you have to make a reasonable guess as to what they meant. I think that thinking they meant you couldn't use anything in crt/libc/libstdc++ is going way overboard. When you produce a program that has all your own system-call wrappers, is called from inetd, and has minimal functionality, and I produce in the same time something that properly uses the standard system library routines, is more efficient (because I didn't use inetd), maybe has more features (I added in the ability to run programs/scripts), which one do you think is going to show a more productive programmer?
BTW, I wasn't saying that your interpretation of the requirements meant you'd have to write your own C compiler, but certainly a reasonable interpretation of "external library", given your interpretation of it, includes most of the code in an operating system - after all, what's a TCP stack but a standard set of routines, with a standard calling interface, that performs a well-defined task. Just because it uses a different calling mechanism doesn't mean it isn't a library. If the socket system call isn't a library call, then characterizing a wrapper routine as a library routine would also be wrong, especially as it wouldn't even be implemented that way on all systems. What I was saying was that if you're going to start throwing stuff away, why stop there, why not go whole hog and implement everything but the BIOS? That'll really show them what you can do. As I said, I'D be impressed, even if it turned out that you were completely misinterpreting the requirements.
If they wanted to know if you knew the difference between calls (explicit or implicit) to standard libraries, what generates those calls, how C++ dynamic overloading works, how calls to the operating system work, what kind of things get in-lined, I'd think they'd just ask you, not see how you interpret "no external libraries of any kind". If they wanted to see if you could write a fairly small program that deals with sockets, strings, file I/O, maybe multiple processes, multiplexing, pipes, and follow a relatively simple well-known specification without a lot of hand-holding, they'd ask you to write a simple web server in 3-4 hours, using only the standard librari
A more obvious meaning for their request is that they want you to write a simple web server without pulling in a bunch of libraries already written that implement a web server so that you can write "HTTPserver server = new HTTPserver(localhost, "http"); return server.process("/usr/local/http");" and claim you know how to implement a webserver in C++. "of any kind" simply means that they include string parsing libraries, socket handling libraries, error logging libraries, or anything else. "external" is much more the relevant phrase, and OBVIOUSLY means "not part of the actual implementation of the C/C++ compiler suite". So yes, "new", "malloc", "printf" would be allowed. "3-4 hours" is also a pretty big clue as well - since that's a reasonable estimate of the time it would take to write something like that using only the language-standard facilities.
Saying "well, you SAID no external libraries of ANY KIND, so I took that to mean whatever would get me out of having to do it" certainly wouldn't impress me, unless you then went on to implement your own C compiler, operating system, Ethernet drives, TCP/IP services, wrote the web server for that, installed the whole thing as a boot block and brought it up by booting it straight from the BIOS. That would probably take a bit more than 3-4 hours, though, so it probably isn't what they meant.
Your approach is basically saying "hahaha, you guys suck, you don't even know what's implemented as libraries in a C++ program, so I'm going to show you up by saying it can't be done". You've shown that you'd be very difficult to work with.
The words used by the poster were "no external libraries of any kind", not "no libraries of any kind". All that stuff in the standard C/C++ libraries is PART OF THE LANGUAGE, you don't have to care whether it is implemented as libraries or compiled into your program with in-lining, it isn't an "external library". Your code might be running in a C byte-code interpreter, with all of the standard routines implemented inside the interpreter. Being pig-headed literal in a job interview is no way to impress them with your ability to get things done. Communication skills are important!
The code emitted by a C compiler is going to assume at least a FEW things that the entry stub code has to set up, so you can't really just make main your program entry point, in most cases. Depends on the OS environment, of course.
Using inetd is a good solution, eliminates the need to do any of your own socket programming. I'd do that, then write another version that does it without inetd, but is limited to one connection at a time; then go ahead and modify THAT to do a select-based dispatcher to handle multiple connections; then integrate in the ability to run scripts in separate processes, managing the pipes and sockets and connections all through that one select. Submit all four versions, with the original inetd-based one mostly implemented as a library that is used by all 4 versions. If you end up with a nice generic library to handle processes, pipes, sockets and connections as well, so much the better.
Of course it was the wrong answer. The ability to analyze a bit of C code (whether or not you think it's "abberent") is an important skill, when determining what a piece of code IS doing as opposed to what it APPEARS to be doing or is DOCUMENTED as doing.
Or they hire someone who enjoys programming and would find the minor challenge of writing a simple web server in 3-4 hours to be fun. In fact, I may just go write a simple web server in 3-4 hours right now, just for the fun of it.
You can obviously use the libraries defined by standard C/C++, they are part of the language, they are NOT "external libraries". Look to the standard to figure out what you can and can't use. Just because most implementations of C/C++ link in the standard libraries dynamically doesn't mean they are "external libraries". You obviously aren't right for the job if you're going to take a dumb hard-line hyper-literal attitude like that.
Writing a simple web server is trivial. It doesn't even need to be multi-threaded, though it wouldn't be difficult to make it serve multiple connections at once with select.
Someone who can't write the code to parse out a GET request is pretty lame. Heck, you SHOULD be able to write it all in 3-4 hours using nothing but system calls, no section (3) library calls at all. That is, you get to use socket, select, open, read, write. Write your own damned string parsing routines, most of them are about 3-15 lines long. No, you don't get to use malloc; include (and check) reasonable limits on string lengths, simultaneous connections, etc, then you won't need to dynamically allocate memory. If you insist, create your own memory allocator, using anonymous mmap to get more raw memory, but it won't be worth it. Might impress them, though.
Suggestion: create an index file mapping URL to static file to return. Look up the URL, return the file. Manage the index file manually, with Perl, with shell scripts, whatever, they didn't tell you how to administer the server. If you're feeling slightly ambitious and want to impress them, include the ability to run programs with simple arguments passed in on the command line. Heck, you could even include POST and PUT support without too much trouble, but that might take more than 3-4 hours to get it all working just right, dealing with multiple processes and pipes that can block, etc, all while also dealing with multiple sockets, any of which can close or die unexpectedly, can be a bit tricky. I'd start off writing a generic process-handler library and integrate it with the socket handler so everything can be run off of one select (or poll) call. But, if you do that, come up with a better solution than CGI.
Specifications? All you need to do is implement a subset of HTTP. If you can't look up the specs to that, I certainly wouldn't hire you. Since they didn't give you any other requirements, I'd consider the job done when a standard web browser (your choice) can connect to it and follow links. It's not like you have to implement PHP or JSP or whatever for the thing! I think 3-4 hours is reasonable. If you don't, you obviously weren't the right person for the job.
In the "real" world, I've seen people jump through so many hoops to use some pre-written poorly-defined-and-implemented library that it would have been easier to just write the damned code in the first place. That includes using C++ in the first place, when just using C would have been more appropriate.
So, in the casino, when you're playing poker, and you make people think you have a full house when you have a busted straight, should the cops come in and arrest you for fraud? After all, you took someone else's money from them by tricking them into believing something that wasn't true!
If a game allows for killing someone and robbing items off the dead body, or a "thief" type who can steal items from someone, and that's totally within the accepted rules of the game, should the cops be called in for murder and theft when someone does it? Why should a Ponzi scheme be any different?
Now, when you pay someone real money to transfer you items inside a game, if that person fails to transfer the items it would be breach of contract. That was a transaction that occurred outside the game, requiring performance inside the game.
Where things get sticky is when the game allows for transfers back FROM game money to real money. If some of that game money came from what would be an illegal source in the outside world (Ponzi scheme, gambling), then changing the game money for real money would be the illegal act, I think. Where it REALLY gets sticky is in trying to track the movement of such tainted game money. I'm very uncomfortable with the idea of someone who is running a game having to track all transactions between players to prevent money laundering and such, whether or not they themselves support the exchange back to real money in the first place.
Here's a point to ponder as well. If I say "if you don't give me xxxx game dollars, I'm going to kill your puppy", that's clearly extortion. If I say "if you don't give me xxxx game dollars, I'm going to destroy your castle", is that illegal? Even if the game money is exchangeable for real money? How about "... I'm going to tell all your friends lies to trash your reputation"?
There's no such thing as a "more energy-dense ethanol". Ethanol is ethanol. It may be more efficient to produce using sugar cane or beets than corn, but the end product is identical.
You have to be careful when looking at such figures - some of them include the solar energy input as part of the "input" side of the equation, some of them make unwarranted assumptions about how far you have to transport items, some of them don't look at the byproducts as being anything but waste, nor look at what might have otherwise been waste being used in the process.
For making ethanol, you don't want "oily", you want sugar or cellulose or starch (depending on the process). For biodiesel, you want oily.
Even if there is no solution to that issue, that only rules it out in some parts of the country, during some parts of the year. Same worldwide.
Actually, it doesn't function like a control-click, it actually sends in "button 2" (and you can configure button1-button4, no action, or various things like Exposé, for any of the four "buttons": left, right, scrollball, and side button). Control-click is taken to mean the same thing as "button 2" in most places, but the difference can be clearly determined in the software.
I've seen a few people have problems with the Mighty Mouse - they rest both fingers on both sides of the mouse, sometimes lifting one or the other, so have problems with consistently left-clicking. I've had no problems at all with it, other than the scroll ball sometimes failing to respond in one direction (rollers get dirty, no way to take it out to clean it, but a cotton swab and a touch of isopropyl alcohol and swirling the ball around a little, seems to clear it right up).
The Cyber architecture had typically two main CPUs (60-bit), and 12-20 "Peripheral Processing Units", which were much lower capacity, 12-bit processors. The CPUs were started and stopped by the PPUs, and had no interrupt architecture. Control of the system was actually in the PPUs, they loaded programs into memory, set up memory mapping, handled context switches and system requests. PPUs themselves were implemented as shared hardware with multiple contexts, and control actually changed after each instruction to the next PPU (which lead to certain deterministic behavior which was sometimes exploited to bypass the need for interlocks in certain cases). In later versions, there was a CPU instruction "Exchange Jump", which saved the current program context and loaded the system monitor context, which could start up the next process that was ready, but that was used mostly for requesting immediate processing of a system request (normally you stuck a request in your (relocated) memory location 1, then waited for a bit to change in that word to indicate the request had been processed. Most system requests themselves also had provision for asynchronous processing of requests; you didn't have to wait until it was complete, you just continued on and checked later to see if it was done. System requests were picked up by one of the PPUs scanning each process (if you didn't do an exchange jump).
Although their primary purpose was to control the details of running the CPU, and (as evidenced by the name) control peripheral devices, they could also be used to do additional processing in parallel with the main CPU. Remember, the main CPU was faster, and instruction execution time was on the order of a microsecond; given that these processors are on the order of a 1000 times faster, I think that all you need to get good performance out of it is good bit-banging programmers who aren't afraid of getting down and dirty with the hardware. Lunar lander on a vector graphics display was pretty amazing.
Transfer, as I'm using it, is the creation of a new copy, while simultaneously destroying the old copy. It is clearly a fair use copy in the situation where I've paid for said copy to an authorized distributor. The initial copy, that I bought, was created in their server as they transferred it to the network. That copy disappears as it is sent, and the copy on my hard drive is created. The bits on the network are not a copy, that's true enough, but irrelevant. They ARE sending me a copy, and it IS very much like a teleporter.
Court cases have covered the situation where the initial copy was not authorized, hence distribution of that copy (which, by the way, DOES include magically making bits appear on the other end of a wire, such as a TV broadcast) is also not authorized, hence the copy that shows up on my hard drive is infringing (regardless of who is doing the copying). When the initial distribution IS authorized, I do not need a license to make a copy of it. It isn't any different from recording a TV show over the air, I don't need a license to do that. The court cases are assigning liability for the fact that an infringing copy was made. There's nothing to exclude the ability of an authorized distributor to cause an authorized copy to be made on my computer.
If I connect to an FTP server and copy some content from my computer to the server, did I create a copy on that server? If I own the copyright, can I sue the person who owns the server for having made an unauthorized copy? If he requested that I send it to him by sending me e-mail, now is he the one doing the copying? If instead of me doing the transfer, I've set things up so an automated process reads his e-mail, then does the transfer, is he now liable for making an unauthorized copy? How is that any different from having my e-mail processor automatically burn a CD, label a package and cause it to be mailed? How, in ANY sane interpretation of the law, would the person who sent the e-mail be found liable for having made an infringing copy? So how is that ANY different from my clicking a button in iTunes and Apple sending me a copy of a song? iTunes and the iTMS are very tightly coupled, a very good argument can be made that they constitute a single distributed application. Since I obviously don't own their servers, it must be Apple doing the copying, at my request. If the resulting copy were to be infringing, I might be found liable for copying, sure, but since the resulting copy IS AUTHORIZED, I don't need a license, any more than I need a license to buy a CD from Best Buy and then play it on my CD player (where multiple non-infringing copies get made in the course of playing it).