Jump to content

Wikipedia:Reference desk/Archives/Computing/2014 July 21

From Wikipedia, the free encyclopedia
Computing desk
< July 20 << Jun | July | Aug >> July 22 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


July 21

[edit]

What is the difference between formulas and algorithms?

[edit]

If you take a formula, for example, Celsius Fahrenheit conversion, you can apply it step by step, and somehow fulfil the definition of algorithm (something that's finite and step by step to solve a problem). At least, with an intuitive interpretation that makes sense. Is the difference just the way you express things?OsmanRF34 (talk) 09:03, 21 July 2014 (UTC)[reply]

"Formula" usually means a mathematical equation or something similar. Evaluating a formula is indeed a simple algorithm, but algorithms can be more complicated: in particular, they can include ways to vary the sequence of actions, similar to "while" or "if" statements in a programming language. --50.100.189.160 (talk) 10:35, 21 July 2014 (UTC)[reply]
An algorithm is a series of steps to solve a problem or perform a task. A formula is a series of steps that takes an input and produces an output. In your example, the formula requires a Celsius input and produces a Fahrenheit output. The algorithm is the series of steps requires to solve the problem.
The articles on formula and algorithm should help. --  Gadget850 talk 12:18, 21 July 2014 (UTC)[reply]
A formula is a kind of minimalist algorithm - but it only encompasses arithmetic operations. An algorithm can be much more than that. For example, I can say that the algorithm for making a phone call is:
  1. Pick up your phone.
  2. Make sure it's turned on.
  3. Touch the phone button.
  4. Dial the number
  5. Wait for the caller to answer.
That's an entirely valid algorithm - but it would be impossible to express it as a formula. That said, as you pointed out, the Celsius to Fahrenheit conversion formula is indeed a very small algorithm.
So a formula is a kind of algorithm but an algorithm isn't necessarily a formula. There is another sense to it though. A formula can trivially be described as an equation 'F=Cx9/5+32' - and an equation can do something that an algorithm can't - you can use the standard rules of algebra to discover that 'C=(F-32)x5/9' - which means that you had a second algorithm (one that converts Fahrenheit into Celcius) contained within that very same formula. So in that sense, a formula (by it's very simplicity) is capable of conveying information that a generalized algorithm may not. This becomes increasingly clear as you consider equations with more unknowns in them. Ohm's law (I=V/R) effectively contains the description of three algorithms...I=V/R, V=IR and R=V/I.
The name of the FORTRAN programming language is short for "Formula Translation" - and it was first envisaged as a means to convert formulae into algorithms. That capability (to type in a formula into your computer program and have the compiler or interpreter of your software convert the formulae into algorithms) is now such a standard feature that we tend to forget that it's there. SteveBaker (talk) 14:37, 21 July 2014 (UTC)[reply]
  • There is obviously some overlap, and sometimes some ambiguity between the terms, as others have pointed out. One additional conceptual difference is that formulae are essentially declarative, while algorithms are essentially procedural. For example F=ma is a declarative statement, without any necessary action. Steve's example algorithm is a set of procedures, with no declarations. There is also an analogy to programming language paradigms, List_of_programming_languages_by_type has examples of declarative and procedural languages. SemanticMantis (talk) 15:47, 21 July 2014 (UTC)[reply]
It might be instructive to compare "equation" to "equation solving." These terms have a similar relationship like "formula" and "algorithm." Of course, in common parlance, these kinds of related terms can be applied in a variety of ways, blurring their dictionary-definitions and defying all efforts to draw a distinction among them. Nimur (talk) 16:41, 21 July 2014 (UTC)[reply]

Malware

[edit]

Some time ago, during the World Cup playoffs, I picked up a virus that keeps plaguing me with popups advertising all kinds of things. It also makes my browser, Firefox, go back TWO pages when I hit the back arrow, and throws up unwanted/weird pages on my screen. Fortunately, Wiki seems relatively unaffected by these ploys. But when I'm visiting other websites, such as Reuters, BBC, AP, AOL (mail) it drives me crazy.

I reloaded AVG, and it keeps killing malware, but that keeps coming back like a metastasizing cancer. I've done innumerable AVG scans, which have isolated such things as Malsign.Generic.6E2 and Trojan Horse, but the problem continues.

Suggestions? Should I remove Firefox and reload it? Help!

TNX. Sca (talk) 16:32, 21 July 2014 (UTC)[reply]

If your machine is compromised, you need to completely re-install it. There is no way to confidently assert that any type of anti-malware or anti-virus software can ever possibly restore the machine to proper working order. If you'd like to dive in to the technical details regarding why antivirus software is completely unable to confidently assert that the malware is gone, we can explain in more elaborate detail. But, as this 2012 StackOverflow discussion also emphasizes, it is better if we just phrase it this way. "It will take longer and cost more money and cause more collateral damage if you correctly run anti-malware software than if you cleanly wipe and re-install your machine." The most rational choice, to minimize your time, effort, and data loss, is to wipe the machine and re-install it. The next course of action is your choice. Nimur (talk) 17:05, 21 July 2014 (UTC)[reply]
I've heard this general advice from several sources — not only this time, but a couple years ago when a PC of mine got infected. At that time I considered buying a Mac (Apple) laptop, which though expensive avoids the whole problem of viruses written for (IBM-type) PCs and their ilk. However, a hand-me-down Toshiba laptop became available, and I've been using it for a year and a half in a stationary position with an external monitor and keyboard. Until now it was fine.
I've just finished running a Malwarebytes scan on it and now must decide whether to tell it to quarantine all the dozens of items it found. Any suggestions? Sca (talk) 21:25, 21 July 2014 (UTC)[reply]
Could you describe these weird/unwanted pages to us? We may able to determine what it's trying to do then. -- 140.202.10.134 (talk) 21:33, 21 July 2014 (UTC)[reply]

Method in Java

[edit]

I have a confusion with System.out.println() regarding its not taking methods with void return type. i mean why cant i call a method inside S.O.P that returns void.? i browsed it on web but did not come up with relevant answers.182.18.179.2 (talk) 19:18, 21 July 2014 (UTC) I got what Finlay Mcwalter pointed but what with the answer that Println has overloaded versions of object type.i need more clarity.182.18.179.2 (talk) 06:22, 22 July 2014 (UTC)[reply]

System.out.println() will only print java.lang.Strings, or things that can be converted into strings. For built in things like int, it knows how to do that itself. For everything else (things that are objects) they have to provide a toString() method. println calls that method to string-ify any objects it's passed; if those objects' classes don't themselves implement a custom toString, it falls back on the rudimentary one in java.lang.Object. A void function isn't returning anything, so there's nothing for println to ask to turn itself into a string. Javac's solution to this little kōan is to error with "void type not allowed here". -- Finlay McWalterTalk 20:10, 21 July 2014 (UTC)[reply]

Thanks very much@ Finlay Mcwalter.182.18.179.2 (talk) 06:22, 22 July 2014 (UTC)[reply]

A small correction to the above: println can print things other than Strings because it is overloaded. Such as println(boolean), println(double) and println(int). Your friendly documentation will give you a list of the overloaded versions. 88.112.50.121 (talk) 21:50, 21 July 2014 (UTC)[reply]
No, Finlay's answer was correct. Java does not use operator overloading. The argument will be converted to a String using its implementation of the toString method. Primitive data types, like boolean, are first promoted (for example, to java.lang.Boolean objects); and then the toString method is called. See, for example, Chapter 5 of the Java Language Specification.
Java's System.out object is a special instance of java.io.PrintStream object, and that object has no "overloaded" method for println( primitive data type ) : it only has the methods defined in its class definition. Nimur (talk) 22:49, 21 July 2014 (UTC)[reply]
Java's lack of operator overloading is obviously irrelevant since println isn't an operator. Java does support method overloading, and the page you linked shows that println has overloaded versions for primitive types as well as String and Object. So Finlay McWalter and 88.112.50.121 were both correct, but your reply seems to make no sense at all. -- BenRG (talk) 02:35, 22 July 2014 (UTC)[reply]
println does indeed work by method overloading (on call type signature). Latterly (in 2004) the language introduced autoboxing; where data of elementary types can be automatically autoboxed into a corresponding java.lang.Integer (etc.) object. That's what Nimur describes. They could now choose to implement println that way instead of all those different method signatures:
public class foo {
    static void print(Object o){
        System.out.println(o.getClass().getName() + " : " + o.toString());
    }

    public static void main(String[]args){
        print("hello");
        print(12);
        print(12.3);
        print(true);
        print('c'); 
    }
}
which works well. But println still has explicit methods for int, bool, etc., and we can verify that if they're found the compiler will preferentially use them, rather than autoboxing to an object, by adding:
    static void print(int i){
        System.out.println("native int : " + Integer.toString(i));
    }
...and we note that the int is printed by our new method rather than the Object one. There's a little wrinkle - so is the char (as its ASCII value 99) - because the compiler decided it was more appropriate to promote the char to an int rather than autobox it to a java.lang.Character -- Finlay McWalterTalk 09:28, 22 July 2014 (UTC)[reply]

thank u again @Finlay Mcwalter and Nimur.now,i can understand clearly.182.18.179.2 (talk) 17:09, 22 July 2014 (UTC)[reply]

There's no deep reason for it. There are languages (such as ML) whose equivalent of "void" is a type like any other: you can have variables of that type and print values of that type and so on. In ML the type is called "unit" and has a single value, written (). In Java the value could have been called void or something. Java copied the void quasi-type from C, which also treats it specially. C++ had to preserve the C behavior, which causes problems with templates (equivalent of Java generics). I can't see any reason why Java had to preserve it too; they probably just didn't think to change it, along with other questionable C design decisions, like the left associativity of ==. -- BenRG (talk) 04:03, 22 July 2014 (UTC)[reply]

Thanks everybody for the reply.182.18.179.2 (talk) 06:22, 22 July 2014 (UTC)[reply]

Java is a call-by-value language. You don't call anything "inside System.out.println" Asmrulz (talk) 16:47, 22 July 2014 (UTC)[reply]

Uexpress topics in URL

[edit]

I asked here why it was possible to access Dear Abby topics, and topics by other columnists on Uexpress with or without the URL that included the topic. In fact, I could change the date, with the topic left in, and I would still get the column for the particular date. The answer was that part of the URL at the end was always going to be ignored, but having the topic in the "official" URL would help in searches. This seems like something Wikipedia should address in one or more articles, so I was wondering where to do this and what the sources might be.— Vchimpanzee • talk • contributions • 19:21, 21 July 2014 (UTC)[reply]

As to the first part: the URL article discusses that part of the URL (the "path") and simply says it "is used to specify and perhaps find the resource requested". It's left implicit that the server has licence to interpret the path in whatever way it chooses. Some servers and websites may implement common ways of doing things, and some people may have formed the misapprehension that these are actually how all URLs must be interpreted (e.g. that HTTP URL paths necessarily relate to file paths on the server; or that all parts of the path are necessarily significant; or that different paths must reference different resources), but as your Dear Abby, and my Amazon, example shows, sites can (and do) choose do work in different ways. As to the second part: it'd like to see a reference that supports the claim (that path fragments actually have SEO value); I suspect that it is not true. -- Finlay McWalterTalk 21:00, 21 July 2014 (UTC)[reply]
So there's no Wikipedia article that actually states the last part of the URL is ignored. And I knew the SEO claim had to be controversial and would need a source before I added that.— Vchimpanzee • talk • contributions • 21:06, 21 July 2014 (UTC)[reply]
The part of the path is ignored specifically on the Dear Abby website only; the first part is ignored specifically on Amazon only. On most other sites, the whole path is significant. It doesn't seem like it's encyclopaedic for a Wikipedia article to enumerate how each individual website chooses to handle its own paths, any more than it would be to list what default fonts each website might elect to use. -- Finlay McWalterTalk 21:15, 21 July 2014 (UTC)[reply]
No, of course it's not encyclopedic to say this is done and this is done for each web site. I was thinking more about "some" web sites do this. Obviously it would have to be sourced.— Vchimpanzee • talk • contributions • 21:33, 21 July 2014 (UTC)[reply]

1 Facebook like? Rob Ford

[edit]

Hi all... I was on the official campaign website of Rob Ford, infamous Toronto mayor, and it links to a Facebook campaign page. It has one like. Is the Chromebook that I'm on acting up, or would that be true? I find that stunningly low. -- Zanimum (talk) 21:31, 21 July 2014 (UTC)[reply]

He has 2 likes just now. The Page was created on 2 Feb 2014, but appears to have been idle until 19 July 2014 (3 days ago). Still, I'd expect there to be more likes. CS Miller (talk) 10:57, 22 July 2014 (UTC)[reply]
Yes, if only from comedians, appreciative for all the material. StuRat (talk) 12:25, 22 July 2014 (UTC) [reply]

Thanks! Even the most random of no hope, non-notable mayoral candidates has more than Ford, I was sure that it was a glitch. -- Zanimum (talk) 19:08, 22 July 2014 (UTC)[reply]

It has four likes now. I don't see a FB page listed at Rob Ford mayoral campaign, 2014. I even searched the source text of the article thinking that it might be in some reference somewhere and didn't find mention of FB. My guess is that it's not actually his page and was just created by some fan of his who has done nothing to promote it to even their friends or relatives. As far as I know, FB has no "confirmed" status process to confirm that a page is actually run by the person or company that the page is about. So, there's nothing stopping everybody and their brother from creating a page for any celebrity or politician. Dismas|(talk) 03:16, 23 July 2014 (UTC)[reply]
Actually if you hover over the blue tick, it says it's a verified page (I don't know how long it's been verified). See [1] for Facebook's explaination of what this means and how it happens (it's basically up to Facebook, you can't request verification). Also AFAIK, our external link policy means we frequently only link to one official link Wikipedia:External links#Official links. I haven't checked our article, but the most logical place to link to would be the official website [2] which does link to the Facebook page, as well as Twitter, Google Plus and Youtube (I don't know for how long). BTW it's up to 7 likes now. Nil Einne (talk) 15:18, 24 July 2014 (UTC)[reply]