C/C++: Variable number of arguments to a function(2)
This is my second post on the topic. If you dont know how these va_* macros work, you may want to read my previous post on this topic. When you learn the concept for the first time, you are tempted to believe that its a great idea to have a lot of functions of this type. Wont that be a great flexibility to have all the time? Unfortunately, thats not true. The problem is:
- va_arg() assumes the elements in va_list object to be of a given data type. So, you must know the types in advance to be able to extract the values from the va_ist object.
- Once you have traversed a va_list object, you can not get the first element again by resetting the pointers in for the same object.
Lets talk about the possible problems with (2). Lets try out various ways of getting the pointers reset to the beginning of the va_list object. Lets assume we have va_list “src” as the given list which we have traversed and “dest” as a copy of the same list. We want to be able to get the first element of the va_list after src has traversed the complete va_list object once. On that route, lets first think what a possible implementation of va_list would do. The first thing that comes to mind is that a va_list object could be a pointer to the stack frame of the variadic function. In this situation, it seems perfectly alright to make an assignment say,
va_list dest = src;
Unfortunately, that doesnt work all the time. The next possibility could be that the va_list object is an array of pointers pointing to individual arguments in the variable argumet list , So, we can do a
va_list dest; *dest = *src;
But that is also not the foolproof way because, on certain systems where arguments are passed in registers, it may be necessary for va_start() to allocate memory, store the arguments there, and also an indication of which argument is next, so that va_arg() can step through the list. Now va_end() can free the allocated memory again. So, there is no way you will be able to access that element again. But all is not gloomy my friend for the standard thus defines an interface in the name of va_copy() , so that the above assignments can be replaced by
va_list dest;
va_copy(dest, src);
…
va_end(dest);
And this is a foolproof way !!! Finally ![]()
Note that the compiler wont complain about the wrongdoings in the methods discusses above. The compilation and linking will all pass fine, only when you see the outputs they will appear weird. The good news is, you can always use va_copy() function to get a replica of a va_list object at that instant of time. So, if you want to use the variable argument list a second time, just use this function. The prototype is:
void va_copy (va_list destination, va_list source);
Just remember that each invocation of va_copy() must be matched by a corresponding invocation of va_end() in the same function. Lets now look at a small code to see va_copy() in action.
#include<stdio.h>
#include <stdarg.h>
/* The sum() function can accept variable number of arguments.
In the function declaration "..." at the end means that the
number and type of the arguments may vary. The marker ... can
only appear at the end.
*/
int sum(int num_of_arguments, ... )
{
/* A list to store the aruements. In example, this may contain
1,2,3 and 4 elements on successive calls from main()
*/
va_list args;
int sum= 0, i;
/* Directing the va_list args initialized above to start storing
all parameters folloowing the first parameter 'num_of_arguments'
*/
va_start (args, num_of_arguments );
va_list args_copy; //initialize a copy of va_list to be used
va_copy(args_copy, args); //copy args to args_copy
for (i= 0; i< num_of_arguments; i++ )
/* We add 5 to each element in variable argument list and
print it.
*/
printf("%d ", va_arg (args_copy, int) + 5);
va_end(args_copy); //destruct args_copy
printf("\n");
/**** Next, we use args as in previous post ****/
/* Loop until all parameters are seen. */
for (i= 0; i< num_of_arguments; i++ )
/* Extract the next value in argument list and add it to sum. */
sum += va_arg (args,int);
/* Signal that we are done with our usage of the list */
va_end (args);
return sum; /* Returns the calculated sum.*/
}
int main()
{
int result;
result=sum (4,1,2,3,4);
printf("result of sum() with 5 arguement: %d \n", result);
return 0;
}
Play with the above code on ideone. Change a few things here and there and see how it works.
Happy coding !!!
References:
C/C++ – Variable number of arguments to a function
Ever wondered how printf() in C would be implemented ? If you are a C-lover, I guess you would have, for its a function that looks pretty different from the other library functions, consumes tons of options and its very powerful. If you are not a C-fan and do not know much of it, you may want to have a look here . Well, one of the great flexibility of printf() comes from the fact that it can consume variable number of arguments. If you are scratching your head about how it does that, hold on, you will know it in a minute. That is what this post aims at
. Lets look at some examples to understand what ‘variable number of arguments’ means.
#include<stdio.h>
int main()
{
char * string = "with";
printf("printf with 1 arguement\n");
printf("Printf with %d arguements\n", 2);
printf("Printf %s %d arguements", string, 3);
return 0;
}
Note that the first version takes one argument, the second version takes two arguments and the third takes three. Have you ever written a function definition in C that can be invoked with any number of arguements 1…N ? If not, lets write one. But on the way we need to learn a couple of things as ingredients to it. We need to know of four simple things. The definitions have been taken from cplusplus.com. If you dont understand what they mean, you may first want to see how they are used ( see the code below) and believe me, its very simple to understand them from the usage.
- va_list: Type to hold information about variable arguments.
Objects of this type can only be used as argument for the va_start, va_arg, va_end and va_copy macros, or functions that use them, like the variable argument functions in <cstdio> (vprintf, vscanf, vsnprintf, vsprintf and vsscanf).
-
void va_start (va_list ap, paramN)
Initialize a variable argument list. Initializes ap to point to the first unnamed argument. It retrieve the additional arguments after parameter paramN. A function that invokes va_start(), should also invoke va_end() before it returns.
-
type va_arg (va_list ap, type)
Retrieve next argument. This macro expands to an expression of type type with the value of the current argument in the variable arguments list identified by ap. -
void va_end (va_list ap);
Each invocation of va_start() must be matched by a corresponding invocation of va_end() in the same function.. It performs the appropriate actions to facilitate a normal return by a function that has used the va_list object ap .
Pheww thats a lot of technical Jargon !! Lets revert to some simpler words now. In short, you need to first define a list of type va_list by saying something like.. va_list args. Next, invoke a call to va_start() to indicate where the variable list of arguments starts from, extract each argument from the variable list (args in our case) using va_arg() and finally dont forget calling va_end().
Note that apart from va_ag(), a va_list object (named ap in declarations below ) can also be consumed by versions of printf() that are preceded by ‘v’, for example:
- int vprintf ( const char * format, va_list ap ); – Prints formatted data from variable argument list to stdout,
- int vfprintf ( FILE * stream, const char * format, va_list ap ); – Writes formatted data from variable argument list to stream and
- int vsprintf (char * s, const char * format, va_list ap ); – Writes formatted data from variable argument list to string s.
Lets look at an example that uses the a va_arg(). For the above mentioned printf versions, you can find a C program for each of the 3 functions listed above in the links in the “References” section (#2, #3, #4 respectively) at the end of this post.
#include<stdio.h>
#include <stdarg.h>
/* The sum() function can accept variable number of arguments.
In the function declaration ... means that the number and
type of the arguments may vary. The marker ... can only
appear at the end.
*/
int sum(int num_of_arguments, ... )
{
/* A list to store the aruements. In example, this may contain
1,2,3 and 4 elements on successive calls from main()
*/
va_list args;
int sum= 0, i;
/* Directing the va_list args initialized above to start storing
all parameters folloowing the first parameter 'num_of_arguments'
*/
va_start (args, num_of_arguments );
/* Loop until all parameters are seen. */
for (i= 0; i< num_of_arguments; i++ )
/* Extract the next value in argument list and add it to sum. */
sum += va_arg (args,int);
/* Signal that we are done with our usage of the list */
va_end (args);
return sum; /* Returns the calculated sum.*/
}
int main()
{
int result;
result=sum (1,1);
printf("result of sum() with 2 arguement: %d \n", result);
result=sum (2,1,2);
printf("result of sum() with 3 arguement: %d \n", result);
result=sum (3,1,2,3);
printf("result of sum() with 4 arguement: %d \n", result);
result=sum (4,1,2,3,4);
printf("result of sum() with 5 arguement: %d \n", result);
return 0;
}
Time to see what the function outputs. Here you go:
result of sum() with 2 arguement: 1 result of sum() with 3 arguement: 3 result of sum() with 4 arguement: 6 result of sum() with 5 arguement: 10
And as always play with the above code on ideone. Change a few things here and there and see how it works. Done with this? Lets try and implement our own version of printf().
References:
C++ : The good old thing
Today, I remember a comment from a friend of mine when I started into the world of programming taking up a course in C++. He said “Dude, C++ is an old thing. Who uses it today? Arent there fancier suff out there? And why would someone take a C++ route?” That was my first day at programming. I didnt know much about these languages to have a good answer to that. But, 8 years later I have an answer to it. Yes, Thats a pretty long time. But I know what I like now and that is what the title of the post says. Yes, To me, it comes as a trade off between the needs to prioritize development speed over execution speed, which is where all these “fancy” languages tend to shine. In my experience, these other languages execute fast enough on smaller projects, but start to break down on larger ones. If you still dont agree look at the list of software written in C. Thats a big fat list with some of the most used software out there. Here is a list on the same. Pheww thats loooong. Isnt it? Well, I cant guarantee the authenticity of each and every item on that list but I see names of which I know that they are written in C++. So, I do trust it.
As much as C++’s large feature set and “strict” syntax may be seen as a complex thing for newbies to master, it is about giving the power to express everything one wants directly, unlike any other “simpler” language. I cant stop myself from throwing out something I read on wiki recently.
A widely distributed “satirical” article portrayed Bjarne Stroustrup confessing that C++ was deliberately designed to be complex and difficult, weeding out amateur programmers and raising the salaries of the few programmers who could master the language
.
Yes, thats the challenge. You have all the design tools and if you have the expertise you will definitely love C++. As a matter of fact, I love C for that matter because it gives all the more development speed but then I think its incomplete without all the features and libraries C++ offers on top of it. C++ with its object oriented capability and STL looks a lot more powerful. And with the latest addition being C++11 it adds to the power. Here is a list of things I see in C++11 which excites all the more. Though I am not sure about the stability of all these set of features, it definitely pleases me on the first look. Its time to get your hand dirty trying out all these. Lets have a look at the list:
1) Important Syntax cleanup
2) Automatic type deduction with Auto
3) Range Based for loops
4) Lambda Functions
5) standardized support for multithreaded programming.
6) regex support
7) Chrono library to deal with time duration and points
8) Containers such as unordered_map, unordered_set and Tuples etc
9) Headers for random number generation and ration class templates.
I will try and cover a post on each of these in future. But for now, lets play around with these
new tools. And once the tools are sharpened lets discus them.
Cheers !!!
Preparing for an online test for placement !
The anxious evenings, the nights when you know you should be sleeping but you just dont, the nervous mornings – must admit those were some of the best days of my life. Don’t you agree ? I guess I can safely assume, almost all of us have been told by our parents that we should have a sound sleep when we have an exam/interview or any such thing the next day. The fact is we never do
. After all, we engineers are habituated to working only at nights! My juniors at college have their first exam relating to placement tomorrow. A few of them have been in contact and it was a pleasure helping out some of them. I hope it helps
. Whatever it be, I am able to live my own life an year earlier through them! And I am really thankful to them for that.
Getting back to point, this blog is meant to be a guideline for some of them. These days I have been getting a lot of e-mails regarding what one should study when an “xyz” company visits college and things like that. Hence, I decided to come up with this post to share my own experience of it. I would further like to add that I was always aiming to become a software developer and I guess the contents mentioned below would better suit someone like that. I understand that this is not the best and also welcome better points from some of my colleagues ! Trust me I am not diplomatic about that
. Here are a few things I did the night before a written exam (relating to placement) in my college days :
- Almost all firms, for some reason, go for an aptitude test. And it is a very good practice to have some practice of it before you appear for a written exam. I personally had solved R S Agrawal’s text. I also loved taking a few aptitude tests at indiabix.com on the eve. They offer you a certain number of questions and put a clock with 30 minutes of time up and running . This helps simulate an exam like atmosphere and identify any issues relating to management of time. I definitely had issues with that !
- Next comes the MCQs(multiple choice questions) based on understanding of C/C++. I would suggest doing “Test your C skills”. Its an excellent text and I would suggest you to grab a copy of it.
- Sometimes, pointers are an issue. Actually most of the time they are! I personally used “Understanding Pointers in C” for that. The exercises for that.
- Kerninghan & Ritchie (K & R)’s text called – “The C programming language” is something you just cant miss out.
- I am also a cormen fan, but I wont suggest that for the night before. Its voluminous! Though I used to go through some sorting algos sometimes.
- Operating System Concepts next- I would say- Its not possible to go through it the night before. I personally loved two textbooks. First, the Galvin’s and then Tennenbaum’s. I had finished the first one cover to cover in my summer vacations. Plus, if you are a video lecture fan, you may also opt for lectures of Prof P.K.Biswas (from IIT KGP) or video lectures of Berkley University. I had gone through both these videos lecture series. But I guess this was too much for I was really interested. For the night before I would suggest two questions. First, what is the difference between a process and a thread. Study it in detail. Secondly, have a good understanding of semaphore variables. Additional topics include memory management, the concept of virtual memory, paging segmentation etc. and deadlock if time permits.
- Networking Concepts – Try to remember all 7 layers in OSI protocol and 2 protocols that operate in each one of them. Additionally one may also go through routing, IPv4, IPv6 etc.
- If it is a database related company, I would suggest going through the following topics:
- Basic SQL queries,
- Joins on tables,
- Normalization,
- ACID property (These look simple, but there is no end to it.)
The above points have been written keeping in mind that the applicants are freshers. I am myself just that and thus cant say anything for those who have some experience in the software industry and want to apply for a job. Last, but not the least, If you have reached this point of the post, you deserve a best of luck too! And yes, above all a sound sleep is really helpful.
Wireless charging of mobile phones !
With the Samsung’s new release Galaxy S3 , a lot has been going on in the news. Though being an undergrad, I find it a little difficult to fit into my budget there is no denying that it is a beautiful device. If Samsung is to be believed this device is “inspired by nature – it sees, listens, responds, and allows one to share the greatest moments.” You can find a look and feel of it here. They have also given a lot of snapshots and performed many a comparisons with galaxy S and S2. Have a look at the features yourself.
One talking point about the device has been the support for wireless charging. Dont you hate the mass of wires that comes out of the plug-point from a corner of your room? I’m personally annoyed with it. Not only it occupies some space in my room, I have also stepped on the pin of my mobile charger that gets into my phone a couple of times and trust me it cant take any more blows now. Is there a way out ? Well,now there is ! It may soon be a thing of the past. Coming back to S3, it doesnt provide you with the wireless charger, they ship the device with the normal wired charger we have been using. But, you can get a wireless charger separately and your phone will support it.
Lets get to some technical stuff now. How does it work actually ? Among the engineers and scientists, its called inductive charging. Below is a picture from wiki to illustrate the same.
There are two smart coils namely- primary and secondary. The primary coil is associated with the charger and a magnetic field is set up around this. When a mobile device is present in the area with magnetic field generated from the primary coil, electricity is transferred to the secondary coil available in the phone and this power is used to charge the battery of the device.
If you think this is a completely new idea, you might be mistaken, for it is not a new innovation by samsung. It has been used in past as well. According to times of India, Palm adapted the technology three years ago and sold a charger called Touchstone that allowed phones like Pre and Pixi to be charged wirelessly. They used it in a large number of their products. Powermat too sells such chargers that can be used with iPhone. You may wonder, if this technology is three years old, shouldnt it be very famous by now? Actually, its a little under-developed. The range covered is not great and people are forced to place their mobile phones on top of the wireless chargers as shown in the picture below:
Mobile phones are not the only device that can be charged this way. Its a long list. Recently, Telegraph reported the following:
Fujitsu, the Japanese technology company, has created a system capable of simultaneously charging multiple portable electronic devices such as mobile phones, digital cameras and laptop computers without the need for cable connections.Electric cars users may also eventually be able to charge their vehicles wirelessly using the same technology
A faster approach to YOUTUBE
Its a common issue for we guys at college in our part of the world to see our Youtube video streaming at a very slow speed. Youtube, no doubt, is an excellent platform but a slow connection hampers the experience by a great deal. Its frustating to wait for the video to buffer. The Youtube page contains a lot of information such as similar videos, comments, likes plus a few thing relating to privacy, safety, bug report etc at the bottom. Thumbs up for that for I love having options at hand.
But then, I sometimes wonder- “Are we the only people with a slow connection ?”. Wont it be nice in such a case to limit some of the youtube features to get the video buffered better ? After all, its the video which one tunes into Youtube for, others just play a supporting role. I , for sure, maintain that, for these features are of no value to me if I cant get the feel of a video and I expect Google to understand that and give me some control over this issue. I am a big Google fan and always expect their products to be of excellent quality with a lot of power to the users. But then do I have an option here ? Yes, I do !! I was just going through web trying this afternoon and came across something called Youtube Feather.
Have you heard of it ? If not, spare a minute. Give it a try. You can try it out here. If you want to know more, you can also look at a 1 minute video of it at youtube itself. But then, what goes on at the back is just what I mentioned earlier. Its a trade-off between the speed at which your video loads and the features you want. Youtube feather limits the video suggestions to 5 as opposed to 21 normally and the number of loaded comments to 10. The video is of standard quality (no option to upgrade to High quality exists). In addition to these, Video replies, real-time sharing, and auto-suggest from YouTube’s search bar have also been cut down. And the biggest trouble I think is that it cant play all the videos. Though I have not found such a video yet, I have read the same.
Probably, that is the reason its not very popular as of now, but then as always I am excited about this feature from Google. Take a tour of the Google blog though if you want to have a look at the figures on how effective is it after all.
The SIMPLE homepage @google.com, why is it so designed ?
White, to me, is the favourite colour for it projects purity, cleanliness, and neutrality. Doctors don white coats, brides traditionally wear white gowns, and a white picket fence surrounds a safe and happy home. White is clean, neat and classy and looks pleasing to the eye. But is it the reason why the google homepage is also white in background. What does it project about Google ? What message does it convey ?
Ever Wondered why the google homepage is such a simple one ? No flashy looks, nothing moving here and there, no ads, absolutely nothing more than the simple plain search! You would probably guess that its a well thought move , definitely a deliberate decision. Of course, we dont expect the big G to be casual about it for its an unmatched web giant. Is it because they didnt have people to design it more elegantly/appealing ? Sounds kind of funny ! Right ? Well, it isnt !
If Google’s vice president of local, maps and location services, Mayer is to be believed, this is a result of the limited knowledge of the co-founders of Google. This is what Sergey Brin had to say to Mayor when enquired about it. His own knowledge of HTML was not that great and they did not have webmasters, plus they wanted to test their search technique quickly which they were pretty confident about.
Some argue that it could have been more user friendly and needed less clicks had they put more options , more graphics on their homepage. To some extent I do agree with them, but then i personally feel its an iconic page with a neat look. Almost all other pages on web are a little more cluttered and most importantly we are used to this plain simple look which by now looks so pleasing to the eye. To me its a classy choice to keep it this way. What do you think though ??
Internship or no internship ??
“Should I go for an internship ? ” – I have been asked this question a number of times these days and I could never reply it as a yes/no. Probably it depends. But depends on what ? To some I replied – “Yes go for one if you find an opportunity “, to some I could not give a concrete answer. Probably I was not sure. The reason is – my friends and colleagues have a divided opinion on the matter. One thinks, “Why go for an intern ? Instead one should sit at home and enhance his skills.” Other said, “why cant one enhance his skills while he is an intern ?” And many others are not that clear about it. So you see that is the problem !!
Interns can sometimes be very useful. There is no denying the fact if you get to intern with an excellent firm. If not, you got to think hard and decide. Interns can be rewarding or sometimes not, sometimes they are paid, sometimes not. But I personally think the money factor should not be a very big role in this decision. It should be more about the time you devote and things you learn. Here is a small story.
Have you heard of Wes Cherry? Probably not ! Have you played Solitaire on windows ? I think I can safely assume you have. If not, find a computer near you that has windows. Go to start up ->games-> solitaire. This is it !! It has been a part of windows operating system since windows 3.0 itself. Windows 3.0 was released in 1990 and I guess it has always been a part of it since then. Why are we talking about though ? Yes, lets get back to the point. Solitaire was wrote (developed) by Wes Cherry in 1989 while he was an intern at microsoft. At that time there were few games and this became immensely popular. To verify how popular and tempting it has been let me tell you that people have also been caught playing Solitaire in their offices and some of them fired too
. Dont believe that ? Look here yourself. To his misfortune though Wes received no royalties for Solitaire. So internships can sometimes be not rewarding at all . But then they are pretty useful. In wes’s case itself, he later got an opportunity to write some code for the “microsoft Excel” and yes he was highly rewarded for this.
The moral of the story is – though you could not be rewarded for your work as an intern it gives you a great opportunity to get a full time job with the same firm and enhances your chances to get selected into some other firms as well.
I myself did an internship at IIT Bombay in 2010. It was a 6-week internship and to this day I cant believe I wrote such a huge volume of code. I was a part of the team (of 5 people) who developed an excellent software. It was there that I realized how much I loved this field of software development. Not only that, I realized for the first time how important testing and UI (user interface) design are !! Though I can still not decide whether I should advice you to go for an internship or not, I think you should go for it. Take a chance, work hard, put in extra hours and I bet it will definitely benefit you in the long run
Last, but not the least, if you dont get an opportunity dont be disheartened. Trust me, I have seen a number of people bagging an excellent offer inspite of no internship/good projects. But yes, in that case you will have to work just a little harder.
The encyclopedia or wiki, the text or the e-book ?
Its been just a few days since I appeared for a job at amazon, and as usual I went about reading a lot about the company. One interesting product of theirs which specially captured my interest was kindle, the e-book reader which enable users to shop for, download, browse, and read e-books, newspapers, magazines, blogs, and other digital content. Look at the contents in bold once again. A few years ago, we were so used to the hard copies of these. An amazing sale of the amazon kindle made me think twice about the digitization of all the information around us today. It has occurred so rapidly that we could never sit back and admire it. So what ? Whats new then ? Here it is..
The encyclopedia called Britannica has decided to stop the release of its printed versions. Its going completely digital now.
And this makes me think of the future of libraries. What will be the most important sources of information in future? I can already see a trend in my friends. People seeking knowledge no longer visit libraries, they no longer refer the Encyclopedia placed at a shelf in the library. Wikipedia and co I think has brought about this change. The online tool and e-content is so comfortably accessible, maintained and updated which probably beats the feeling of having a book in your hand !!
To many, it would be a shocking news, and I can understand that for I too love the feeling of having a printed book in my hand as opposed reading an e-book. But, in life the only thing thats constant is “the change”. And I think we are moving towards an age where most (if not all) of the information will only be available in the digital form !! The printed pages of Britannica have been a great companion to many for over 244 years and so this change will surely bring sadness to some. But with the tremendous rate at which digitization is taking place it’s an inevitable move in this golden age of Internet and technology. If you are a Britannica fan and not the print form itself, nothing is going to change. Its only going to get better, at least in terms of regular updation. Jorge Cauz, the president of Encyclopaedia Britannica, Inc. put it like this -
it [the digital form] is now a better tool since the website is updated on a regular basis and is integrated with multimedia. Their online offerings are more expansive which will make it even more convenient when doing researches.
Lets now look at the other side of the story. With this move, is it justified enough say that wikipedia is going to rule the world of information soon ? Thats probably debatable !!
The wikipedia contents can be very easily changed into a nonsense. Though generally not the case, its still possible. Add to that the censhorships, Is wikipedia really as reliable as an encyclopedia ?? Not exactly, but studies have shown that its not far behind. For more on this comparison, you may look at a report on the comparison between wikipedia and Britannica. To me it appears that Wikipedia is a definitely a good starting point for an introduction into any topic, to say the least. If you still doubt the credibility of the contents at wikipedia, it does provide you with links to outside sources. It also saves a lot of time compared to going through a gazillion Google hits for something useful. All these references on wikipedia are mostly excellent ones.
Five years ago, I lived with my uncle. When he got up in the morning in winter, my aunt used to place a cup of coffee and the “Times of India” newspaper near him. As soon as he got up he would pick up the two and then start with his normal routine. For some reason though, I started dreaming of it for myself
but in my case I guess it will be a little different to say the least, for I have already stopped the subscription of Times of India (the newspaper) and moved to the e-version. Whats your take though ? Do you think the feeling of having a text in hand will be obsolete soon ?
Wikipedia NOT with Go daddy now !
How often do you visit wikipedia ? Have you heard of SOPA/PIPA ? Did you notice the wikipedia blackout on January 18 ? Do you know what the reason was ? Here it is – the full story on why wikipedia took this bold step, what followed and what has changed !!
What is SOPA/PIPA ?
SOPA stands for “Stop online Piracy act” and PIPA represents “ The PROTECT IP Act “, with PROTECT meaning Preventing Real Online Threats to Economic Creativity and Theft of Intellectual Property Act. SOPA is a bill introduced in US to expand the ability of their laws to fight online trafficking in copyrighted content on web. Under this act if a person/organisation finds that a website on internet is using its content without a legal permission from them, they can approach a court and get orders to stop the advertising networks and payment facilities from conducting business with this websites. They can get the site blocked and search engines will thereby stop linking to that site. Not that there were no such laws earlier but SOPA strengthens them by a fair magnitude. PIPA is a similar bill. Like SOPA, PIPA too gives the the copyright holders a strong tool to stand against a dishonest website.
Piracy indeed is a big concern but whether or not this is the right way to curb it, is debatable. Some have lauded it, others have deemed it too harsh on the websites involving user generated data. Some have welcomed it with both the hands open. But it is not short on the criticism too. You can find a list of Congresspersons from US on each side and their views on these bills here. Eric Schmidt , the Google chairman, put it as an “overly simple solutions to a complex problem”.
The case of websites with user-generated data:
Though piracy, no doubt, deserves a strong fightback and copyright holders have been crying for long asking for a strict rule to help them curb this dreadful virus, people have found the above laws a little ambiguous to say the least. The case of websites such as Facebook, Youtube, Vimeo, twitter etc is interesting. Users leave a lot of content on these websites and users, I am not sure ought to be restricted . Let us take the most familiar example of Youtube. People post a lot of videos on Youtube. It may be the video of an artist who performed at their college and they would love to share that with their friends through youtube or probably Facebook. “Jal- the band” , performed at my college recently (by the way, thanks to those who organised it
) and would you not love to share such a thing on your Facebook profile ? But wait a minute, should I get a legal permission from the officials at “JAL” before I post a video of it on my Facebook wall ? Now suppose, I always go that way. Will I post as many videos as I normally do ? Will I not sometimes think – “what drama man !! Who will do all that ? I am feeling quite lazy about it” (Well, I am a lazy person by the way !!). Will that not be a setback for Facebook ??
Now suppose one posts such a thing on his Facebook wall or may be writes something on Wikipedia which should really require a copyright. What do you think the result should be ? Should he be banned from using the respective site ? Or do you think thats a little too harsh ? If you do, this is going to be a surprise for you. Now look at the underlined text above. Yes, the organisation with the copyright can get facebook (Youtube or wikipedia) blocked. Its not mendatory that this will happen but there is a chance (even though slim) that this can happen.
What happened between Wikipedia and GO Daddy:
Wikipedia blackout on January 18,2012 was a firm stand by wikipedia against SOPA. Now, look at the image below. This is a snapshot showing a tweet by Jimmy wales (the wikipedia co-founder) himself:
As the above text suggests Go daddy seems to have supported SOPA and Wikimedia could not digest this. Wikimedia legal counsel Michelle Paulson put the transfer of its domain registry like this:-
After months of deliberation and a complicated transfer, the Wikimedia Foundation domain portfolio has been successfully transferred from GoDaddy to MarkMonitor [a U.S.-based domain registry and trademark ]. The portfolio transfer was formally completed on Friday, March 9th, 2012. The transfers were done seamlessly and our sites did not experience any interruption of service or other issues during the procedure.
Here is the official blog post covering the transfer. Wikipedia is not alone on this. If VentureBeat is to be believed, Go daddy has lost more than 37,000 domains as a result of its support for SOPA . Though, Go daddy realised this and softened its stand on SOPA, it was just a little late. I am not completely against SOPA. I completely agree that piracy need to be fought and fought very strongly but i think the bill just passed needs to be edited a little.
Related Articles:





