Java is Pass-by-Value, Dammit - <AUTHOR> http://javadude.com/articles/passbyvalue.htm <comment><USER2> Well the way I've always thought of it is that Java passes "references by value". Meaning the target method receives a _copy_ of the pointer, not the actual pointer. So the result of newing up the parameter inside the target method doesn't affect the original, because you're just making the pointer point to a NEW memory address. On the other hand, mutating the parameter WILL affect the original object, because a copy of a pointer still points to that object from the caller.

<comment><USER3> > Java passes "references by value". Meaning the target method receives a > _copy_ of the pointer, not the actual pointer.

Which is exactly how C does it. I don't see how this is a difficult enough concept to grasp that we need an article explicitly pointing out how Java is just like C in this respect.

<comment><USER4> Not everyone knows C. A large percentage (maybe even the majority) of programmers who graduate from Java schools don't know C very well at all. For them, "it works just like C" is an insufficient explanation.

<comment><USER5> "It works just like Python"

<comment><USER6> Storically, python devs says the python language use "pass-by-name"

<comment><USER7> How so? Reading [1] on pass-by-name, I don't see how it applies to Python, which evaluates the function arguments before passing them.

The example given would be, in Python,

      def double(x):
        x *= 2
      a = [4]
      double(a[0])

If Python was pass-by-name, a would now be [8], but it's actually still [4].

[1] [http://www.cs.sfu.ca/~cameron/Teaching/383/PassByName.html](http://www.cs.sfu.ca/~cameron/Teaching/383/PassByName.html)

</comment></comment></comment></comment></comment></comment><comment><USER8> So to summarize, you have a Java function:

      public void f(Foo bar) { ... }

Which is the equivalent C++ function?

      void f(Foo bar) { ... }
      void f(Foo& bar) { ... }
      void f(Foo* bar) { ... }

It's the last one. Java passes everything by value, but non-primitive objects in Java are actually pointers (which Java inaccurately calls references), and the _pointer_ is passed by value.

<comment><USER9> Why is it inaccurate to call it a reference in Java?

You don't dereference a variable in Java to access it, so that would make me think reference, not pointer.

<comment><USER10> By you do deference object variables in Java. What do you think the "." operator does?

<comment><USER9> Ah, true... so what is the difference between a reference and a pointer then?

<comment><USER10> It depends on which definition of "reference" you are talking about.

Pass-by-reference and C++ references are basically the same - aliasing without requiring dereferencing via an operator.

Java object references are like C++ pointers.

Java is pass-by-value (no aliasing) for all values (ints, bools, object references etc). Java has no object values.

</comment></comment></comment></comment></comment><comment><USER11> Of course it is. It says so in the language spec, and even in the official tutorial here: [http://docs.oracle.com/javase/tutorial/java/javaOO/arguments...](http://docs.oracle.com/javase/tutorial/java/javaOO/arguments.html)

Swap is a nice litmus test.

To people who claim that Java doesn't have pointers, I counter-argument by the fact that you can make a circular doubly-linked list in Java. Thus, a reference is a pointer though with lesser capabilities than in C++. In contrast, you cannot make a circular doubly-linked list with C++ references which are object aliases.

Actually, I have the following analogy: pointer ~ symbolic link; reference ~ hard link.

Java's references are misnamed.

<comment><USER12> > Java's references are misnamed.

That's silly. Why should every other language adhere exactly to C++'s definition of a reference? 'Reference' as a concept exists outside of computer programming and Java isn't wrong to repurpose the term in a different way than C++.

Consider also that C++ has 'dependent types', despite pretty much no relationship to the more well-known definition of dependent types. There are only so many ways to name something.

<comment><USER13> There are also two uses of "dependent" in C++: the resolution of a name can depend on a type parameter, so you have to specify whether you want to treat it as a type name; and a type can depend on (compile-time) values. The former has nothing to do with dependent typing, but the latter does!

</comment></comment></comment><comment><USER14> This topic (I do not know why) raises some serious emotion-based responses on coders. The other topic I know will cause almost a religious flame-war is the philosophical meaning of "null" in the SQL arena.

I've tried to add some insight why the OP hears (so many) >folks (incorrectly) state "primitives are passed by value, objects are passed by reference"

What I believe was my constructive addition to the topic, seems to deserve only downvotes. I'll make a reminder to not participate again in this kind of topics.

<comment><USER15> > This topic (I do not know why) raises some serious emotion-based responses > on coders.

I saw the title on HN, and was like "uhhh, no shit, why is this here?". Then surprisingly, it all of a sudden it has 80 points and almost 50 comments debating the details. I don't think there's any actually real debate on how Java actually works, this must be a purely linguistic. Or as you say, "emotional".

SQL NULLs, on the other hand, is a real philosophical war. One which the wrong size is clearly wrong and need to be crushed into ashes underneath our boots. We are not debating jargon, we are defining databases which could certainly outlive our sons and daughters!!!! .. Ok, sorry. But I just don't think it's good comparison with students who just don't really get Java. Database design is largely a matter of opinion, Java method calls are not.

<comment><USER16> It is definitely emotional for me: I remember reading yet another of these "java is not pass by reference" posts, and the title stuck for some reason. So next time I wrote a Java function (long afterwards), I modified a list received as an argument inside a function, and could not understand why my original list was modified.

I honestly feel that these posts titles are just trying to pull my leg. "Java passes everything by value!" "Really? And which value is being passed?" "The reference, of course!".

<comment><USER10> So instead of programming based on vague recollections of blog titles, you should strive to understand the language you are writing in, so that you don't make those mistakes.

Reading the content of the articles, doing some research, and actually understanding what is happening in the language are all good steps to consider taking.

</comment></comment></comment></comment><comment><USER17> The confused terminology isn't related to function calls. In Java, objects are not values.

The confused terminology originates before you get to function calls -- you can't ask "are objects passed by value?" without first considering objects as values. Objects can't be stored in variables and objects cannot be the result of an expression. x = y does not copy an object y into an object x because objects are not values -- x and y are variables and they can only hold values, which objects are not.

</comment><comment><USER18> I work full-time in JavaScript and I've always thought of JavaScript as a pass-by-reference but this article made it clear that JavaScript is pass- reference-by-value. The `swap` function from the article doesn't swap the variables outside of the function.

<comment><USER19> javaScript != java...

<comment><USER20> The behaviour of JavaScript is equivalent for references. (Call by sharing)

</comment></comment></comment><comment><USER21>
      From: James Gosling
      Date: 1/13/11

      Don Hopkins wrote:

      >Hey I know it's 2011 and we're living in the future and all that, but
      >there still seems to be some confusion and debate about a matter I
      >thought was perfectly clear: Is Java pass by value or pass by
      >reference?

      Depends on your terminology.  But it's kinda both.  It's pass-by-value for
      everything, with the twist that for class instances, the thing that's
      passed-by-value is the pointer to the object, so it behaves like
      pass-by-reference.

      From: Don Hopkins
      Date: 1/13/11

      Reminds me of the controversy about Niklaus Wirth's name:

      "Whereas Europeans generally pronounce his name the right way
      ('Nick-louse Veert'), Americans invariably mangle it into 'Nickel's
      Worth.' This is to say that Europeans call him by name, but Americans
      call him by value." - Introduction by Adriaan van Wijngaarden at the
      IFIP Congress (1965).

      It seems to be a consequence of pretending pointers don't exist -- you
      also have to pretend you have variables with object values and
      references, but you still can't write a swap(a, b) function. If you
      think of Java object values as pointers, then it's obviously passing
      references by value. But if you don't believe in pointers and think of
      variables as containing objects, then it's obviously passing objects
      by reference, but your view of the world is an illusion, because it's
      really implemented with pointers.

      Or is it??? Someone suggested a Magic Elves theory, which helps a lot
      of other stuff to make more sense.

Here's the discussion from 2011 about this issue that prompted me to ask James Gosling for a clarification. You can see that many people were VERY confused, and extremely fanatical about maintaining and spreading their confusion, in spite of the fact that it directly contradicted the Java spec and the inventor of Java himself.

Java is PASS BY VALUE.

[http://www.theserverside.com/discussions/thread.tss?thread_i...](http://www.theserverside.com/discussions/thread.tss?thread_id=61622)

<comment><USER14> The man says:

>But it's kinda both. It's pass-by-value for everything, with the twist that for class instances, the thing that's passed-by-value is the pointer to the object, so it behaves like pass-by-reference.

So he's saying: We call them all "chickens", but some of them walk like a duck and quack like a duck, so they're basically ducks.

You can't extract from that quote "THEY ARE CHICKENS" (all in caps)

When he says "kinda both" and "it behaves like pass-by-reference" I read some "subtle" hints saying that he thinks that basically class instances are passed-by-reference.

<comment><USER10> Except they don't completely behave like they are passed by reference (see swap in the article). It is only ever correct to say "they behave like they are pointers which were passed by value".

Continuing to say "they act like references" is wrong and how this mess keeps perpetuating.

</comment></comment></comment><comment><USER22> I gave up on this... It's explicitly said in the Java standard that the language is pass-by-value. On one occasion I've been told that the standard must be wrong then. Some people just don't want to accept reality if it doesn't match their interpretation of definitions. :-(

<comment><USER23> Calling it "pass by value" without qualifying that, for objects, it passes the reference by value, is very confusing.

<comment><USER22> But these are completely separate things. You can have any mix of those (c# actually has all):

\- Pass by value, values hold object references. (java, c# objects)

\- Pass by value, values hold objects. (c# structs)

\- Pass by reference, values hold object references. (c# inout parameter, passing object)

\- Pass by reference, values hold objects. (c# inout parameter, passing struct)

<comment><USER24> I'm not really sure what point you are trying to make here.

In general, the whole thing about passing a reference by value is just BS. What you need to ask is, "What am I passing to the function?"

If you are passing an object, and Java (or whatever language you are using) determines a reference (memory address or whatever), then passes that reference to the function, then you are, by definition, passing an object by reference. The important thing to focus on in this argument is, "What am I passing?" The answer for this scenario is that the programmer is trying to pass the object itself. Who cares about the address / location of the object.

If you decide to pass the reference explicitly, then you are passing a reference, not the object. This would be like explicitly passing a pointer in c++, and is apparently a controversial topic when it comes to Java. A reference will nearly always (I can't actually think of a case where it isn't) be a primitive, and therefore, be passed by value.

For argument sake, say I'm wrong about all this. My question would be, "What would it look like to pass an object by reference, and how does that differ from what is currently happening?"

<comment><USER22> The point was, that there is a language close to java which can pass objects by value or by reference. (It passes object references by value or by reference if you want to call it like that)

To pass an object by reference, it looks exactly like C#'s out/ref parameter.

        void function(ref SomeClass arg) {
            arg=null;
        }

        var a=new SomeClass();
        function(a);
        // now a is null

Which is different from what happens without ref. (or by default in Java)

</comment></comment></comment></comment></comment><comment><USER25> Java hides the pointer, which is what confuses people.

Maybe we shouldn't be shitty about that, since it doesn't really matter too much.

Just a thought.

</comment><comment><USER26> This entire thread makes me want to die. Please, do not speak of this again.

<comment><USER10> Top notch contribution.

</comment></comment><comment><USER27> The terms are not precisely enough to give meaning to cross-language comparisons. Within a single language like C++, you can usefully differentiate the various ways to pass references and data.

<comment><USER28> I disagree. The question of whether or not you can write a _swap_ function as described in the article is fairly precise.

</comment></comment><comment><USER29> FWIW, in .NET land, we tend to say "pass-by-reference-by-value".

<comment><USER30> I call this "pass by pointer copy". Does anyone know if that's a term people use, or did I just invent it? I can only find one other person mentioning it when I google for "pass by pointer copy" (in quotation marks for the exact match).

<comment><USER31> No,that's completely natural (if verbose). This is from someone coming from a C background, FWIW.

</comment></comment></comment><comment><USER32> Novice Java programmer reads title, mutates Java object inside function, later notices side-effects, and curses author of the title.

Second novice Java programmer reads title, wants to pass objects into functions, wants to avoid expensive stack copy and writes &myObject, gets compiler error, Googles "Java pointer," and curses author of the title.

Lesson learned: author of title is either unaware of the consequences such an interpretation will cause or seeks cursing as a source of attention.

<comment><USER4> Novice Java programmer doesn't read title attempts to assign a new object to a variable inside a function, doesn't work, curses Java tutorial that said objects are pass by reference.

<comment><USER32> When in C, Python, Java, JS, or anything else does reassigning a variable from the function sig _ever_ work? The symbol is in-scope. Even when overwriting the pointer location in C, you don't just assign; you de-reference _and_ copy over the memory that was there. A novice _programmer_ would make this mistake, not a novice Java programmer.

</comment></comment></comment><comment><USER33> I remember this being a hot topic on usenet back in the '90s. It's great to see it getting an outing today, and inciting equally as vigorous argument!

<comment><USER34> Is there any _useful_ argument to be had around this, for pragmatic purposes?

No one disagrees about what Java is doing here (that I know of).

Naming is a problem if people are writing bugs due to the poor explanation.

But I can't think of the last time I've actually seen bugs caused because anyone who thought that, for example, a swap() method would work in Java.

It's something that brand-new developers might muddle up, but usually they'll learn how it works within the first year, no? If they keep track of how to treat primitives vs. objects in methods by saying "Java passes primitives by value, Objects by reference", and that works for them, that's okay. I think a senior dev should know a bit more about what's really going on, but I'm not waste the time of a mid-level programmer because, even though this code is correct, I want to talk for 20 minutes about the _reason_ why it's correct wasn't worded quite right.

I'm far more likely to see bugs caused by people misunderstanding Java's auto- boxing/unboxing of primitives for method calls ("how the _devil_ is this line throwing a NullPointerException?").

</comment></comment><comment><USER24> I think people are reading way too much into what a reference is. In c++, it has a very specific meaning, but in Java it has a slightly different definition.

In c++, the only difference between a reference and a pointer is in the dereference syntax, and that a pointer can be reassigned. In the background, the variable is a pointer in both cases. It is simply syntactic sugar.

Another thing some people are mixing up is the entire philosophy between pass- by-reference and pass-by-value. The ability to write a simple swap function does not accurately demonstrate what a language is doing. It is quite simply whether or not the compiler creates a copy of the ___object_ __(not a copy of the address / pointer / reference). If, in the background, Java passes an address / pointer / reference (the word makes absolutely no difference), when the programmer is attempting to pass an object, that is the definition of pass-by-reference regardless what arbitrary word I want to name the referencing value. Yes, the pointer is a copy of the previous pointer, but that's not the explicit value that the programmer cares about.

Yet another comparison to c++: the same thing happens with pass-by-reference in c++. If a function has the prototype:

        void foo(Dog& d);

and I pass a Dog object in a call similar to:

        Dog d("Spot");
        foo(d);

then, in the background, it is going create a reference (i.e. the address), and copy it on the stack. In my foo() function, the argument is simply already dereferenced (I don't have to treat it like a pointer).

TLDR...

If you pass an object to a function, and operations performed by that function affect the original object, it is pass-by-reference. Period.

</comment><comment><USER35> PHP unfortunately has the same issue because it copied Java's terminology to describe object reference values (introduced in PHP 5), yet it has always also had "references" which are _actually_ pass-by-reference.

To demonstrate, object references/pointers/whatever:

      $foo = new Foo(); // $foo
      $foo2 = $foo;
      $foo2->x = 3;
      // $foo->x is also 3 now, $foo and $foo2 point to the same Foo object
      // that is, $foo and $foo2 both contain an object handle/pointer/reference/whatever that points to the same Foo object

PHP references:

      function swap(&$a, &$b) {
          $temp = $a;
          $a = $b;
          $b = $temp;
      }
      $a = 3;
      $b = 2;
      swap($a, $b);
      // $a is now 2, $b is now 3

<comment><USER36> The only reason I use @-refs anymore is because of PHP copying arrays on assignment (shallowly, lazily.) In addition--unless you do everything in a super-functional way--you need to unset() each &-ref to prevent latent bugs later in the same scope.

It's an unfortunate situation, and it gets worse when you add array-like- objects into the mix, which look exactly like "normal" arrays up until the moment everything explodes into WTFs.

</comment></comment><comment><USER37> You can absolutely make a swap for reference types in Java. Here: [https://gist.github.com/anonymous/d3b4b3bcacb478896ef2](https://gist.github.com/anonymous/d3b4b3bcacb478896ef2)

This is analogous to a C++ swap(Type&,Type&). The main difference is that C++ provides a default assignment operator for types, meaning you don't have to provide _Assign_ yourself. A smaller difference is that the temporary instance can be created on the stack in C++ but not in Java.

For primitive types it's absolutely true that you cannot implement swap (unless you were to have created that value type in a reference-type wrapper). It's misleading to say you can't do so for reference types.

<comment><USER10> This is not the same swap.

The article (and the correct pass-by-reference litmus test) swaps the values of the variables as the caller sees them, using operations inside the swap routine.

Your example swapped the contents of the pointed-to objects, but did not change the values of the variables a1 and a2.

If you want to see the difference, assign a1 to a new variable a3 before the a1/a2 swap call. A real pass by reference swap will end up with a3 == a2, and your example ends up with a3 == a1.

<comment><USER37> Yes it is the exact same swap. Either behavior (what you call a3 == a2 and a3 == a1) is possible in either C++ or Java, depending on what you mean by "assign a1 to a new variable a3". Your confusion is surely that C++'s assign- by-value looks like Java's assign-by-reference. Again, either behavior is achievable

May I invite you to write some code and see for yourself? Here:

C++ Swap (what you and the article call the litmus test): [https://gist.github.com/anonymous/06b9251a37008d158f59](https://gist.github.com/anonymous/06b9251a37008d158f59)

Java Swap (exactly the same thing): [https://gist.github.com/anonymous/d57d272579079b4e9ee8](https://gist.github.com/anonymous/d57d272579079b4e9ee8)

These programs don't only output the exact same thing, they do exactly the same thing (except the differences I noted above, about the default copy assignment operator being implicit in C++, and about C++ putting the temp variable on the stack instead of the heap).

<comment><USER10> No, it isn't the same swap. If you actually understand what is going on, you'd realize it.

> May I invite you to write some code and see for yourself?

Sure. I've fixed your examples so they are analogous to each other and added the check that I described in my previous post.

C++: [https://gist.github.com/anonymous/9c66999844afcab15eeb](https://gist.github.com/anonymous/9c66999844afcab15eeb) Java: [https://gist.github.com/anonymous/bac324b3f3c13f263e14](https://gist.github.com/anonymous/bac324b3f3c13f263e14)

<comment><USER37> Edited because I responded before reading your "fixes" correctly.

<comment><USER37> Wait. This is even crazier than I thought. I just looked closer at your "fixes". You're passing a pointer by reference? You're really stretching.

Look at the article. It contains c++ code for a swap litmus test. It doesn't look like your "fix". Your swap is not the _traditional swap(a,b) method /function_ called for by the author.

Here is a traditional swap function: [http://www.cplusplus.com/reference/algorithm/swap/](http://www.cplusplus.com/reference/algorithm/swap/)

<comment><USER10> Yeah, no kidding. You can't write the C++ by-value swap (without pointers) in Java because Java is only pointers. It has no non-pointer objects.

The C++ version I posted shows you exactly what the Java object model is doing, except since you can't take in references to the variables (Java has no pass-by-reference), you can't do the pass-by-reference swap. The only swap you can do in Java is the pass-by-value swap.

The C++ pass-by-value swap (using pointers like Java requires) looks like this:

[https://gist.github.com/anonymous/73ccac277baee8841470](https://gist.github.com/anonymous/73ccac277baee8841470)

Note that this now prints "Fake pass-by-value swap" like the Java version.

There is no way to write a Java version that prints "Real pass-by-reference swap".

<comment><USER37> Are you making the argument that C++ has pass-by-reference and Java does not? No one disputes this. That's not my point. My point is whether the ability to write a traditional "swap" is a good litmus test.

I've proved that you can write "swap" in Java. This behavior is in all important ways equivalent to the basic, traditional C++ swap, even though Java passes references by value and C++ passes by reference. You're arguing, "Yeah but look, they look different! If you put the exact same comparison code afterward, they return different things!" Well... yeah... that's because Java and C++ are different! Apples and oranges. That has nothing to do with whether the ability to write "swap" is a good litmus test.

The article says you cannot write "swap" in Java, therefore Java doesn't have pass-by-reference. I'm saying "yes, you can write 'swap' in Java.. but still Java doesn't have pass-by-reference.. so it's a bad litmus test." And you're saying "Yeah but your swap looks different." And I'm saying "No shit, that's because Java doesn't have pass-by-reference." The article didn't say the litmus test is "can you write swap in a way that looks exactly like this C++ code?".

That's it for me, I'm bowing out!

<comment><USER10> You can't write swap in Java as defined by the article - one that changes the _values_ of the _parameters_. Your swap only follows the pointers and changes the pointed-to objects.

A valid, real "swap" in Java is one that passes my example code and prints "real pass-by-reference swap" and not "fake pass-by-value swap'.

</comment></comment></comment></comment></comment></comment></comment></comment></comment><comment><USER38> I asked a question some time ago on SO [1] where Scott Stanchfield - "The Java Dude" weighed in and it sparked quite a discussion. It is well worth reading the discussion there as well as this one.

[1] [https://stackoverflow.com/questions/934775/changing-value- af...](https://stackoverflow.com/questions/934775/changing-value-after-its- placed-in-hashmap-changes-whats-inside-hashmap)

</comment><comment><USER39> I had a similar frustration over JavaScript recently and wrote a very similar post: [http://www.mattgreer.org/articles/javascript-is-a-pass-by- va...](http://www.mattgreer.org/articles/javascript-is-a-pass-by-value- language/)

</comment><comment><USER40> A pointer in Java

        Dog d;

is exactly like C++'s

        Dog *d;

Following a pointer and calling a method

        d.setName("Fifi");

is exactly like C++'s

        d->setName("Fifi");

</comment><comment><USER41> The C++ implementation of swap given is wrong.

SomeType temp = arg1;

This would do a deep copy of the object pointed to by the ref arg1. What is intended is probably

SomeType& temp = arg1;

<comment><USER10> No, the article was right.

You can't do a generic swap without 3 deep copies.

If you change temp to be a reference, then once you do "arg1 = arg2", you just lost any way to get arg1's value back.

</comment></comment><comment><USER42> if you want pass a reference to a reference do

Dog dog[] = { new Dog };

void method( Dog dog[] ) { dog[0] = new Dog(); }

Having this of side effect as a default would be an insane idea ofc., so I am not sure what you are complaining about :-)

<comment><USER21> No, that's passing by value a reference to an object (Dog array) that contains a reference to another object (Dog). The variable "dog" that is the parameter to "method" is passed by VALUE, not by reference. Passing something by reference is NOT the same as passing a reference to something by value.

</comment></comment><comment><USER43> Java is Pass-By-Value for values and Pass-By-Copy-Reference for objects.

</comment><comment><USER44> Dear author: webhostinggeeks did not actually translate your article into Serbo-Croatian for free. They just ran a shitty automatic translation and added in links that boost their black hat SEO empire.

They target many people who host highly linked articles this way. They picked Serbo-Croatian because you're unlikely to verify it.

Do not post translations unless you trust the translator (perhaps because you paid them to do good work) or know the language.

</comment><comment><USER45> _In short: Java has pointers and is strictly pass-by-value._

It's a well know fact that Java has pointers given that you have NullPointerException as an exception.

<comment><USER46> The confusion around whether or not Java has pointers comes from people comparing it with C or C++. In Java, you can't dereference a pointer to an Object and get some sort of Object value. Similarly, you can't perform an "address of" operation on a primitive value and get a pointer to that value. Similarly, you can't pass-by-reference (in the sense of the parent article) or do pointer arithmetic in Java.

While Java technically has pointers (in the sense that it has pointer types), it has dulled them so that you can't hurt yourself with them the same way that C (and C++) permit.

</comment></comment><comment><USER47> You absolutely CAN write swap in Java:

        void <T> swap(T a, T b) {
            // use the Unsafe to copy a's memory to a temp buffer
            // then copy b's memory to a
            // then copy a's memory to b
            // Caution: Don't pass Integers or anything, okay
        }

Or, if the objects are Beans, just iterate the properties and swap them one by one. In fact, if you know you're dealing with beans, the two don't even have to be the same class, as long as their properties and types are the same.

<comment><USER48> No, it's not the same.

        X a = new X("foo");
        X b = new X("bar");
        X c = a;
        swap(a, b);
        // after this, a points to X("bar") and b points to
        // X("foo"), but c should remain pointing to X("foo").

If you swap the contents of the object, c would point to X("bar").

</comment></comment><comment><USER14> >Java is strictly pass-by-value, exactly as in C

In C you can pass a pointer, and a pointer to a pointer. I understand both cases are usually called "pass-by-reference". If you call "pass-by-value" to passing a pointer, then the notion of "pass-by-value" and "pass-by-reference" are not very useful.

IMHO "pass-by-reference" means you can mutate the attributes of the thing passed (as in java when you pass an object) and also means you can be operating on a "volatile" area of memory, meaning another thread can CHANGE the data while the function is executing.

OTOH "pass-by-value" means you get a "snapshot" of the value at the point of the function-call, the copy is normally on the stack, and no other thread will change the data while the function is running. Also you can mutate the area with gusto without worrying of data-races, side-effects or altering the calling function variables.

This two "definitions" of pass-by-value and pass-by-reference are the ones I find useful regarding concurrency and side-effects.

If you tell me that passing an integer and passing an object are both the same thing (pass-by-value) in Java, then I will tell you that pass-by-value and pass-by-reference are not very useful concepts.

<comment><USER49> It is a useful concept because there _are_ languages with pass-by-reference constructs. C++, Swift (sort of, with inout parameters), are two examples that come to mind. Java and C are simply not those languages.

<comment><USER50> You can pass double pointers in C so functions can change the original pointer's address value. You can't do that in Java.

<comment><USER28> Yes, you can do that in C, but that is still not pass by reference. In C you are not passing the variable you are trying to change, you are passing a _pointer to it_. You cannot write

      swap(a, b);

You have to write

      swap(&a, &b);

<comment><USER14> The problem is that you will label both cases as an example of "pass-by- value", while they're fundamentally different.

That's why people call "pass-by-reference" the second example.

<comment><USER28> They are both labelled pass-by-value because they are both pass-by-value. Yes, they are different, but that doesn't mean one is pass-by-reference and the other is pass-by-value.

The C example is equivalent to

      pa = &a;
      pb = &b;
      swap(pa, pb);

When _swap_ returns, the values of _pa_ and _pb_ are unchanged. Only the values or _a_ and _b_ are changed. But _a_ and _b_ were not passed to swap. Therefore this is not pass-by-reference, but rather passing a pointer to a variable by value.

<comment><USER14> I fully understand the difference, and I know that you're technically correct.

What I'm saying is that people tend to abbreviate "pass-a-reference-by-value" to "pass-by-reference" because the differences between passing a value (value snapshot) and passing a reference-value (passing the address-of) are way more important* than if the language syntax allows you to pass an "implicit" variable reference or not. (the swap example)

*"more important" for code-reading, code-analysis, code-safety analysis, and also even more important in a concurrent environment because of side-effects and data-races.

Maybe the feature should be called "pass an implicit reference", which describes better what Java does, instead of saying "everything is pass-by- value" which is correct but, as the evidence shows (the mere existence of the article), it is very confusing for "folks".

>I'm really tired of hearing folks (incorrectly) state "primitives are passed by value, objects are passed by reference".</comment></comment></comment></comment></comment></comment></comment>


Ask HN: What tools do you use for remote pair programming? - <AUTHOR>

<comment><AUTHOR> I found a a great article by Pivotal about how they use tmux recently [http://pivotallabs.com/how-we-use-tmux-for-remote-pair- progr...](http://pivotallabs.com/how-we-use-tmux-for-remote-pair-programming/) Anything else amazing that I'm missing?

</comment><comment> benji-york If you are a Linux console lover like me, I have a tool I've been working on for a while: Termbeamer (termbeamer.com). The win over screen/tmux is that it is much easier to set up (especially if you are behind NAT or a firewall).

</comment><comment><USER2> If you work on a mac, I have had some luck with ScreenHero <http://screenhero.com>

</comment><comment><USER3> <http://www.pairprogramwith.me/>

</comment><comment><USER4> In my case macfusión with st2</comment>


5 Freedoms That Just Died with Net Neutrality - <AUTHOR> https://www.tomsguide.com/us/net-neutrality-free-speech,news-18792.html <comment><USER2> Am I wrong in thinking that they're being a little hyperbolic with this?</comment>


How to find that perfect husband in college - <AUTHOR> http://m.redandblack.com/mobile/opinion/how-to-find-that-perfect-husband-in-college/article_8b6d38e2-c575-11e1-8ce5-0019bb30f31a.html

<comment><USER2> I don't think it's limited to frat girls when it comes to pulling to old bait n switch routine that girls do to get a man to marry them. Most girls do this by nature and you can spot this early on if you know how to look for it. Just talk about something controversial and if she always agrees with you that's a pretty good starting indicator.

</comment><comment><USER3> I go to UGA, and it's funny to see this on Hacker News.

Sad, but I swear this is how many of them think. (Male perspective, here.)

Yes, I'm in a fraternity. No, I don't date Greek girls, and it's precisely for attitudes such as this.

</comment><comment><USER4> Contingency Plan. All that comes to mind when I read this. Very nice writing and summarises the world it seems.

</comment><comment><USER5> seems like solid advice to me.

</comment><comment><USER6> Great post, but there is a lot more to finding that perfect husband. Assuming you have followed the given steps so far and some guys to chose from ...

1\. Have many common interests that will last a lifetime.

2\. Do not get in college debt yourself and do not marry someone with a big debt either. Your generation is way, way behind in terms of big debts coming out of school.

3\. Make sure your family approves fully of the guy - before you fall too far in love to back out. Your parents and siblings are likely to give you good advice.

4\. What makes a man attractive on the campus may not last beyond it... Women want powerful guys, and what defines power on campus mostly only works on the campus. You want an ambitious guy, one who will work hard for the family when school ends, not just a popular frat boy or middle of the road jock.

5\. Be prepared to find a guy after college. Especially when hooking up with older guys, its easier to do that around people you later work with and their connections. The prettiest women get married first, but they are not necessarily the happiest.

6\. Be ambitious yourself, and pursue a career that does not need the man to be the breadwinner. That way, your guy can spend time with the family too.

<comment><USER7> It's a satire piece.

<comment><USER3> You say this, but I assure you that, for many women at UGA, it is not. Men are right to be apprehensive, as there's nothing worse than being locked down by the "wrong" one. I'd swear to you, many women here date complete tools for fear of not having a boyfriend. They are, in effect, in love with the idea of being in love. No one wants that.

Satire aside, the author is correct about a happy marriage being important for one's future. Indeed, a good marriage is far less transient than one's career, and once kids arrive, you're financially tethered for 18 years+. Also, let us not forget studies showing the importance of a few meaningful relationships' effect on one's happiness.

<comment><USER7> That's not culturally unique to UGA or any specific region. I've met such women up here in the Northeast. It's still a satire piece; the author posted a poll a few hours later to clue in anyone that didn't see that right off the bat.</comment></comment></comment></comment>


Dialects of Lisp - <AUTHOR> http://programmers.stackexchange.com/questions/55284/is-lisp-still-useful-in-todays-world-which-version-is-most-used/188048#188048 <comment><USER2> I've seen Common Lisp start to make a great comeback in the past few years. I started programming in it seriously about a year and half ago, and since then the packaging system (quicklisp) and libraries for it are maturing very rapidly. A lot of people are making useful libraries for practical purposes.

A lot of people say the language's timing was off. I couldn't agree more. However, it's starting to get a second chance. There are several open-source implementations that compile to machine code and/or support threading/networking/etc. Deployment is essentially free. For every feature that an implementation has that's not in the standard, there's a library that creates a standard, cross-implementation interface for it (for instance threading and the "bordeaux-threads" library).

The language is screaming fast, extremely expressive and powerful (insert mandatory macro hype here), and becoming "standardized" all over again via its libraries. I use it (Clozure CL) in production and haven't ever had an issue.

<comment><USER3> > The language is screaming fast

I don't disagree, but that's an interesting change in the CW.

<comment><USER4> (CW == conventional wisdom?)

There are probably a few reasons for that. Many more programmers these days probably get their start with "scripting" languages like Python, Ruby, Perl, PHP, and JavaScript. Compared to these other dynamic, high-level languages, you probably could call Common Lisp "screaming fast". (Of course, I'm aware that there is very active implementation work going on for several of those languages that is probably doing a good deal to close the gap.) On average, though, CL is probably in the same ballpark as Java, and can sometimes be made as fast as C or C++ with a lot of effort.

Also, note that Common Lisp is very much a many-implementation language (in contrast to languages like the ones above that, for most of their history, were defined by their single implementation), and different implementations make difference performance trade-offs. For much of recent history, the very high performance CL implementations have been somewhat out of reach of the typical student, hobbyist, or other weekend hacker that probably makes up most of the Lisp community. Commercial CLs are quite expensive, and high- performance free CLs like CMUCL have historically not been too friendly to beginners. When I came to Lisp, it seemed much easier to get started with CLISP (an extremely portable bytecode-compiled implementation) than with CMUCL. More recently, SBCL (an offshoot of CMUCL) and Clozure CL have made a lot of progress towards providing a go-to open source CL implementation with very good performance.

</comment></comment></comment><comment><USER5> If I were to bet, I'd place my money on Clojure as the 100 year language. It is as unbound by hardware in regard to cross platform development as any other likely candidate, it has good access to libraries meeting contemporary expectations, and is likely to continue to have access to new libraries written to meet future expectations - all due to its interaction with the JVM (and .NET).

Of course I am adopting PG's premise that the 100 year language is a LISP while ignoring his premise that it is not a bit kludged up by practical considerations (i.e. the ugliness of its dependence on the JVM).

(/edit) Clojure also has an evangelist in Rich Hickey whom people seem to respect independently of Clojure.

<comment><USER6> Clojure is currently my favorite language, partly for the pragmatic choices it made, but these pragmatic choices will limit its continued use.

Hygienic macros often prevent one from shooting oneself into the foot, but they prevent also some truly elegant code. Having lists and vectors with a common interface is cool, but that the semantics of conj is different for both is annoying. Easy java interop is worth a lot, but it prevents call/cc.

It's probable that i will gladly use Clojure for the next 10, maybe even 20 years, but it won't be the programming language my grandchildren will ask me to shut up about.

<comment><USER7> I am curious, what do you think hygienic macros break? I'm a fan of Racket, and I haven't yet found anything that it's macros can't do.

<comment><USER8> I'm still too new to Lisp to answer this question, but I have seen the book Let Over Lambda recommended as having answers to that and similar questions.

</comment></comment></comment></comment><comment><USER9> I'm not familiar with a lot of other dialects, but the information on Racket is _terrible._ I wouldn't trust any of the other responses.

Racket is _not_ an R6RS scheme, it's... Racket. R6RS is an available language/library in Racket, but it's not what you usually use[1].

Racket has also _always_ been a language laboratory, not just a scheme. I'd also wager that it's the most popular scheme used today, maybe even the most popular lisp.

[1] The Racket primary language is specified with #lang Racket, R6RS is specified with #lang r6rs. R5RS is specified with #lang r5rs.

</comment><comment><USER10> This answer references Chicken Scheme, which compiles to C - I'm curious, is there any work on a Scheme that compiles to LLVM? (A brief search didn't reveal anything that's been updated in the last 4-5 years.)

<comment><USER11> Gambit is getting backends that include x86 and JavaScript Real Soon Now. There has been LLVM work, but I don't think it progressed very far.

<comment><USER12> +1 for mentioning Gambit-C. I don't use Gambit-C anymore, but I used to use it a fair amount for writing small utility programs. Gambit-C can be used to build very small and efficient executables. Gambit-C doesn't have the huge library that Racket or Chicken have but it is great for building small command line utilities, etc.

</comment></comment></comment><comment><USER13> I wonder if Arc is finished or dead. I like it it seems the ecosystem is missing.

</comment><comment><USER14> No mention of NewLisp?

<comment><USER15> NewLisp is to Lisp what ramen noodles is to Italian cuisine.

<comment><USER16> Urban Dictionary about Ramen Noodles: "Quite possibly one of the most all time best foods ever to be found in the United States of America."

</comment></comment></comment><comment><USER17> Why don't people do things like this for Dialects of Algol? Is it because most of them got new names, like Java, C, and so on?

<comment><USER18> I was actually thinking about this same question earlier. There are dialects of Lisp and dialects of BASIC, but most other languages are not considered dialects of anything similar. How different do two programming languages have to be before they're no longer considered dialects?

It seems like Scheme and Common Lisp, for instance, have more differences than Java and C# have from each other. Why wouldn't C# be considered a Java dialect? Visual Basic is very different from BASICA, yet they are both considered BASIC dialects. Why shouldn't Pascal and Ada be considered ALGOL dialects?

The line-drawing process seems completely arbitrary.

<comment><USER19> "The line-drawing process seems completely arbitrary."

The real world cannot be exhaustively described with a single taxonomy.

</comment></comment></comment><comment><USER20> The way is Scheme -> Common Lisp -> Arc.

Scheme comes first because it is more refined and there are excellent courses and books.

CS61A probably the best introductory course. After that it is good to watch original SICP lectures by the two magicians and read the book. Then it is necessary to take a look at what HtDP team is teaching.

 _After_ this there will be no trouble with Common Lisp. Classic books are these by pg and Norvig. CLtL is just a reference.

Then, with all the knowledge so far one could understand arc.arc and appreciate what have been done there.)

With this background you will understand what Clojure really is and why, or what is Haskell, and why there is nothing special in it.

btw, there is a brilliant course by Dan Grossman on coursera covering FP. He is very clever and consistent. After this you will smile at Haskell guys.)

Update:

I forgot Emacs Lisp. _An Introduction to Programming in Emacs Lisp_ is an excellent book that covers all the basic principles and gives a perspective how to use lisp in a real-world project.)

<comment><USER21> The idea that there is nothing special about Haskell, or that Haskell is all that closely related to lisp, is patently absurd. Haskell comes from a different, more mathematical background with a _much_ more extensive underlying theory than lisp.

I actually came from the background you advocate--61A (which really was an awesome class) was my first CS course in college. (Unfortunately, they have since ruined it.) I certainly appreciate lisp and have actually used Racket in a practical setting. That said, I've found Haskell and OCaml to stand out both from purely pragmatic and theoretical considerations.

Haskell is the only moderately popular language that lets you control side- effects globally. That by itself is extremely special. This makes writing maintainable code easier and gives the compiler considerable freedom in optimizing code.

Haskell has an incredible but also surprisingly simple type system. You can't just ignore that. There is nothing in lisp--not even typed Racket--that even comes close to Haskell's type system.

Even aside from language qualities that make Haskell special--which I haven't even come close to covering--it also stands out because of its community. Not only is the community particularly nice and welcoming, it's also special in not being afraid of a bit of math. This doesn't mean _you_ as a programmer have to know much math, but it does mean libraries tend to be simpler and more self-consistent because they rely on very well defined mathematical abstractions with simple algebraic rules. These abstractions also allow for significantly more general code.

Haskell comes from a different theoretical background and philosophy than lisp. It has different practical advantages and a very different philosophy. So claiming that it's nothing special and that you will understand all of it just coming from lisp is completely wrong.

<comment><USER22> I like having access to mathematical semantics, simple algebraic rules, and all the other things you mentioned but combining these features with a non- homoiconic syntax spoils the whole thing for me.

> _Not only is the community particularly nice and welcoming, it's also > special in not being afraid of a bit of math._

The Lisp community has never been afraid of math. John McCarthy had a PHD in mathematics and the earliest computer algebra systems were developed in Lisp. The Macysma computer algebra system (now developed as Maxima) predates Haskell by decades.

> _Haskell has an incredible but also surprisingly simple type system. You > can't just ignore that. There is nothing in lisp--not even typed Racket-- > that even comes close to Haskell's type system._

The most important thing for me is having the ability to describe cardinality (especially in terms of machine bits such as 2^8, 2^16, etc) and enumerations (like the ASCII character encoding). What aspect of Haskells type system is that Lisps need to "come close to"?

<comment><USER21> My point with math is that Haskell libraries and code use mathematical abstractions (like various sorts of algebraic structures) far more than lisp; I was not taking about what people do with Haskell but rather how they do it.

The type system does quite a bit more than just describe cardinality. The single most important feature is typeclasses; you simply can't replicate some of what typeclasses can easily do without a similar type system.

Apart from that, you also want the type system to let you control "effects"-- not just state and IO but also things like error management and non- determinism. You also want a good way to reuse the type system to enforce your own domain-specific invariants; this is what GADTs are for.

The only serious effort I know for adding a type system to lisp is typed Racket, and I don't think it does anywhere near as much as Haskell. It certainly does not have typeclasses, and I think it ends up having union types everywhere which are more awkward and bug-prone than the usual sum types languages have. (This is a necessary compromise to integrate well worth normal Racket, but it's still a compromise.)

Beyond that, most people don't use typed Racket at all, so I suppose the main way lisp can come close to Haskell's type system is in having one at all.

As far as homo-iconic syntax goes, I sometimes miss it, but not too often. Having a flexible syntax that can look like math is far more important usually, and Haskell gets most of the way there without being too complicated. I personally think that seething like Agda's mixfix syntax is the best option overall.

<comment><USER22> > _The type system does quite a bit more than just describe cardinality. The > single most important feature is typeclasses; you simply can't replicate > some of what typeclasses can easily do without a similar type system._

In the C programming language types are mainly used to describe cardinalities. For example, char is the cardinality of the smallest addressable unit of memory of the machine (often 256). We don't need more then machine cardinalities as entire operating systems have been written in assembly and C. What advantages do type classes and GADTS have that make them worth adopting? Is there any evidence that they make programs more safe and reliable?

> _My point with math is that Haskell libraries and code use mathematical > abstractions (like various sorts of algebraic structures) far more than > lisp; I was not taking about what people do with Haskell but rather how they > do it._

I am building a computer algebra system with Lisp in my free time. There are many Lisp computer algebra systems that I have learned a lot from like Maxima, Reduce, and Axiom. One of my favorite computer algebra systems is GAP and it is written in C and not Haskell. I am not convinced that Haskell uses more mathematical abstractions and algebraic structures and I am not familiar with any well maintained computer algebra system written in Haskell.

> _Having a flexible syntax that can look like math is far more important > usually, and Haskell gets most of the way there without being too > complicated._

Math doesn't look like anything. Mathematics is about abstract concepts (especially the natural numbers) not representations. You mean that Haskell is meant to look like math does on paper, but whats so important about using a paper syntax when we have keyboards?</comment></comment></comment></comment></comment>


Twitter is down - <AUTHOR> https://dev.twitter.com/overview/status <comment><USER2> Potentially related to this?

> Today we moved all of Twitter's mobile web traffic (that's like, a lot) to > our new web stack – Node.js, Express, React PWA.

[https://twitter.com/necolas/status/829128165314306048](https://twitter.com/necolas/status/829128165314306048)

<comment><USER3> Not at all related.

</comment></comment><comment><USER4> ... finally some peace. Hope this lasts for a while :)

<comment><USER5> Heheh, amen. Between Nigel Farage and Donald Trump's bloody tweets getting front page coverage in the papers it's becoming increasingly hard to detox from Twitter!

</comment></comment><comment><USER6> Just came back for me. How long has the fail whale graphic been gone? This is the first time I've seen the "something has gone wrong" devil graphic.

<comment><USER7> Did you (or anyone else) happen to grab a screenshot before the site came back up? I'm curious.

<comment><USER8> Here's a "quoted reply" tweet, where the frame that should contain the quoted tweet shows the error page. This is from a few minutes ago.

[http://www.mynameisneil.com/projects/chickenbucket/files/n_2...](http://www.mynameisneil.com/projects/chickenbucket/files/n_2017Feb07_twitter_down.jpg)

</comment></comment></comment><comment><USER9> Previous post: [https://news.ycombinator.com/item?id=13594657](https://news.ycombinator.com/item?id=13594657)

</comment><comment><USER10> Everyone is switching to Prattle anyway.

</comment><comment><USER11> For a brief period of time the world is safe- cant start a war or launch nukes.

</comment><comment><USER12> I feel a new executive order coming on...

</comment><comment><USER13> How will Donald Trump communicate with his people? Someone declare a national emergency!</comment>


Navigation App Is Making Traffic Unmanageable - <AUTHOR> https://spectrum.ieee.org/computing/hardware/your-navigation-app-is-making-traffic-unmanageable <comment><USER2> >Without the ability to invest in new technology, cities can't catch up with these big technology providers and instead fall back on regulation. For example, Portland, Ore., Seattle, and many other cities have lowered the speed limits on residential streets to 20 miles per hour.

Probably a minority view, but as a semi truck driver who is sometimes routed through residential streets that are nevertheless truck routes, I appreciate these low speed limits. Because I'm probably already going that slow, or slower, and these limits give me two benefits: cover for going that slow, and reducing motivation for people to try to zip around me.

EDIT: And hey, stop trying to zip around me. :-)</comment>


NSA Rejecting FOIA Requests by US Citizens - <AUTHOR> http://www.dailykos.com/story/2013/07/06/1221694/-NSA-Rejecting-Every-FOIA-Request-Made-by-U-S-Citizens <comment><USER2> In case you didn't read the whole letter, it basically tells him that the government makes the rules, that the rules say that these widely-publicized programs are classified, and that if he wants to know what they have on him he can f@@k off. We should be outraged by these responses, but not particularly surprised. They are taking the only stance they can take: you found us out, but you can't do anything about it. The only thing that we can do is assume that every electronic communication we make is being monitored, stored, and analyzed, and conduct ourselves accordingly.

<comment><USER3> One of the basic exceptions to FOIA is classified material. If that weren't the case, there would be no point in having classified material.

To my knowledge, every government in the world has some sort of state secrets program. If you are against this, then that is at least consistent. But it makes no sense to say that the NSA should be releasing classified information under FOIA.

<comment><USER2> I am not of the opinion that classified information should necessarily be disclosed under FOIA. However, one could make a strong argument that because these programs have been officially acknowledged (which is inconsistent with the procedures for handling classified information), that their existence is no longer classified. NSA didn't have to make any public comment on the leaks at all; nevertheless, they chose to not only acknowledge the programs but also release a fair number of details, which would seem to have the effect of declassification. There is a similar principle in trademark law: failure to enforce the trademark results in a waiver of any rights granted by it.

<comment><USER4> The fact remains that as more and more information about the programs is leaked to 'adversaries', the more pointless the program becomes. You wouldn't play hide and seek if everyone could see you, right? Or if anyone shouts "Marco, FOIA!" they have to respond "Polo, docs!"

Most of the specifics here are still under wraps (who's being targeted, what specific patterns they search, etc) so the programs are still in pretty good shape. It's far too early to throw in the everyone-knows-everything-already towel. What's maddening is that the leaks on Capitol Hill are exactly the same, criminally, but are usually pre-filtered, pro-US and condoned by the Administration.

<comment><USER5> If leaks are condoned by the administration, then it has to make you wonder how much of the professed value these programs actually have.

</comment></comment></comment></comment></comment><comment><USER6> What bothers me most is that Americans can actually file these petitions and receive answers. What about Europeans (and others) who have been spied on by a foreign state?

Not so long ago, this would've been considered an act of war, to spy on your allies on such a grand scale. The sad part is, that our governments or either in on it, or running their own spy programs.

I really don't feel like I am living in a "free world" any more.

<comment><USER7> The obvious question is you why you believed were living in a free world while the US was kidnapping and torturing foreigners, while threatening countries by telling them they'd be bombed back in to the stone age?

I do very much agree with your points, but I don't understand why this issues is a tipping point. Since I began to understand politics, I have been as wary and skeptical of the US government as I have been impressed by the good achievements of the US. I've not believed in the idea that the US leads any sort of free world for years.

Or, if you are honest, is this the first issue that you feel affects you? Were you confident that you wouldn't be rendered, bombed or drone struck? But now you can be sure the NSA have your data and that it might actually matter?

If so, Im not judging you in any way. Its just I think a lot of people are possibly in that boat too, and it also might highlight why still a most people seem to dismiss this. They think it isnt or wont be a problem for them.

What has been blown for me by all this is the notion of freedom of speech. While we in Europe seem to have given that up, I used to think the US hadn't.

<comment><USER8> For me, this actually _was_ the tipping point. In social groups I hung out I was usually the guy who'd defend America on numerous accounts, but in the last few weeks I've been bombarded by a load of information which I find to be truly chilling.

By the way, it is interesting to note how we separate our past history from our active perceptions of the place. America's early history is not too bright -- we did some of the most batshit evil stuff you could think of: _genocide_ of Red Indians, _slavery_ (which to me when I really sit down and think deep about, sometimes, seems worse than just killing a person -- it's fucking killing the very dignity and respect every human being is owed, it's depriving them of any and all pleasures to life). I don't think we've made much amends for it -- the cycle of poverty still persists for a lot of African American folks, there are rather few social programs that really try to help them in meaningfully substantive ways. There are folks alive to this very day who faced system institutional racism _from our government_.

We did some pretty evil stuff during and after the Cold war too -- someone linked this in another post yesterday: [https://en.wikipedia.org/wiki/Unethical_human_experimentatio...](https://en.wikipedia.org/wiki/Unethical_human_experimentation_in_the_United_States) \-- this one truly shocked me:

        Researchers in the United States have performed thousands of human
        radiation experiments to determine the effects of atomic radiation and
        radioactive contamination on the human body, generally on people who were
        poor, sick, or powerless.

It has suddenly become a lot more uncomfortable for me living in America in these few weeks after some reading (especially as I'm actually a foreigner to this land -- I escaped a different country through asylum some while back). It is apparently completely uncontroversial that United States experimented on poor people with radioactive contamination... how do I know the US won't poison me with some biological weapon as an experiment, or because I'm currently unemployed (and thus poor)?

<comment><USER3> The history of human civilization in general has been one of force and savagery, gradually (and not monotonically) becoming more civilized.

It's an interesting idea that a country (that is, the people living in a certain country) should have some kind of "original sin" for things that happened before they were born. Ask a German how they feel about that idea. Even so, there is nothing special about the United States in the respects that you mentioned. Learning about history is the antidote to that belief.

<comment><USER9> > It's an interesting idea that a country (that is, the people living in a > certain country) should have some kind of "original sin" for things that > happened before they were born.

Interesting, but not at all controversial, especially here.

</comment></comment></comment></comment></comment><comment><USER10> This sort of illustrates the striking difference between the American intelligence programmes and the European ones. While the Europeans are not necessarily better, they are at least public and - yes - you can request the information if you so please (of course, you cannot ask them to remove it).

I am not advocating the European logging of internet traffic, but I will give them the very least credit they deserve: Being public. The Swedish FRA, the Danish Logningsbekendtgørelse, the German Vorratsdatenspeicherung, etc.; while bad themselves, they are at least public knowledge.

<comment><USER11> Especially since the German Verfassungsgericht has ruled the 'Vorratsdatenspeicherung' to be unconstitutional and had ordered that saved data has to be deleted.

In many recent rulings we Germans have the impression that the Verfassungsgericht has defended and also slightly extended our basic law (Grundgesetz) against the politicians and in favour of people's rights. This gives the Verfassungsgericht high respect.

<comment><USER12> Yes. Sweden needs a constitutional court.

</comment></comment></comment><comment><USER13> "Trust us" will never be good enough. Not when accused are not able to know the charges against them. Not when you can be held indefinitely without judicial recourse. Not when prosecutors demand ludicrous sentences for accessing a public API. Not when the executive has the apparently legal ability to assassinate opponents without oversight.

No. Sorry, there can be no trust in such an arrangement. You want trust? Don't have secret courts.

<comment><USER14> What's even their reasoning for having the Court _secret_? That terrorists will threaten them or attack them? Come on, that has the be the fear every single judge has to live with, and I think a normal judge who has to decide on a drug lord's case has a lot more to fear than some random terrorists, just because they agree to letting the NSA spying on everyone.

I think being secret has a lot more to do with them being able to abuse the laws, and not letting the public know about it. There's no good reason to keep the FISA Court secret.

<comment><USER15> The court was created during the cold war. It has basically been repurposed for the war on terror. The original foe had sophisticated intelligence agencies and keeping the rulings secret was at least a plausible argument in the spy-vs-spy mindset of the era.

But the war on terror involves a handful of college kids and peasants. They don't have anything more than the ability to do google searches. Joe Paranoid doesn't need confirmation from guys like Snowden, he just assumes the worst and goes from there.

The massive secrecy around the war on terror (there are now over 4 million active clearances, nearly 1.5 top-secret clearances, that's twice the population of DC) is an artifact of the cold-war regulations that provides little to no tactical advantage but practically eliminate oversight.

<comment><USER9> > there are now over 4 million active clearances, nearly 1.5 top-secret > clearances, that's twice the population of DC

Clearances simply represent that someone was screened for access to national security information within the past 5/10/15 years. They are not all actively in use, and due to compartmentalization even the active ones do not mean that they are actually _doing_ work that involves national security.

For instance, the cook on a submarine? He has a SECRET clearance since he may come across information of that classification in the course of his duties, but frying eggs and standing "sump" watch does not mean he is personally oppressing the populace. :P

Likewise, merely _having_ a clearance doesn't eliminate oversight. That depends entirely on the job being done, and in any event has a simple answer: Just give whoever is providing oversight equivalent clearances.

Now, you might be thinking that means the whole public can't provide oversight that way, and you'd be right. But remember the division of responsibility rule: If _everyone_ is responsible for providing oversight on something, then _no one_ is responsible for oversight. It's easy for evil to lurk in plain sight when everyone thinks that someone else is responsible for spotting it.

<comment><USER15> RE: clearance vs use

Yes, that is correct, there are a small number of people who have clearances purely for mechanical reasons, like janitors and such. However, it is useful to recognize that the total number of clearances is at roughly the same level as at the peak of the cold war. When the enemy was entire countries, not a few thousand guys living in caves.

RE: secrecy

I was referring to the FISA court's secrecy being an artifact of the cold war, not the secrecy every single classified program. There is no reason beyond inertia and the ease that comes with lack of accountability for the FISA court to be so secretive. However, I am stunned by the leap of logic it requires to say that public knowledge results in no oversight.

<comment><USER9> > However, I am stunned by the leap of logic it requires to say that public > knowledge results in no oversight.

Is that what I actually said?

<comment><USER15> Please don't be the guy who hides behind literalist excuses.

The intent is clear - to reference the "division of responsibility rule" in this context and then deny the obvious intent is disingenuous. "I didn't say public knowledge results in no oversight, I was just randomly pointing out that if everyone is responsible than no one is responsible. Just throwing that out there, your conclusions are your own."

<comment><USER9> The "obvious intent" is to reinforce the idea that oversight is a _function_ like any other business process and there should be organizations whose _actual responsibility_ is to handle that function.

That doesn't have to mean another government office, it can mean something like the EFF, ACLU, or some other non-profit dedicated to performing that function on behalf of the people.

Simply making the glass transparent has no value if no one looks through it. If we as people don't setup some form of oversight or advocacy (and just wait for someone else to do it) then it doesn't matter how transparent the government is.

"If not now, when; if not me, who?"

</comment></comment></comment></comment></comment></comment></comment></comment><comment><USER16> I'm confused. The NSA has basically unlimited powers under the premise that it does not spy on US citizens. So if US citiziens ask what data the NSA has on them, what other legal answer could there be other than 'none'? And what secrets would be revealed in that answer, given that the NSA has been mandated not to spy on US citiziens?

<comment><USER17> The NSA can intercept US citizens' international communications under roughly the same theory that allows customs officials to search you at the border without probable cause.

</comment></comment><comment><USER18> I, for one, believe that this kind of tactic is detrimental to the country in the long run.

Their objective is clear and a "legitimate" even thus not "ethical" attempt to protect "the country".

However, this only works for a while. While nobody sympathize with your cause anymore, the artificial barriers and protection are useless, as information will leak literally everywhere, since everyone wants to you see you fall.

This seems to be a common way for countries to fall after reaching their apex.

</comment><comment><USER19> Oh man, this is easy. They denied his request because there was no confirmation that they did or did not have information.

send a "Hi how are you" letter to the NSA chief, naming him as a party, with an affidavit stating that the NSA does, in fact, have information on you. Give him 10 days to rebut it. Then give him a second letter, acknowledging his fault/acquiescence to the affidavit. then 10 days after that, send a third notice cementing his agreement to the affidavit's truth.

THEN you go do a FOIA request. Include your paperwork with the FOIA request. They can't refuse, because they'd have to contradict your private agreement with the NSA Chief first. if they do refuse, you now have legal recourse in (Secret) courts, because the NSA will now be proven to have obstructed process.

<comment><USER20> Child's play, really.

<comment><USER19> as my prof once said: "it ain't as easy as 1-2-3, but it is as easy as 1-2-3-4-5-6".

</comment></comment></comment><comment><USER21> We're posting and upvoting links to dailykos.com on HN now?

Flagged for linking to blogspam on a site filled with nonsense.

Is it that hard to click the "Originally published at" link? [http://www.tikkun.org/tikkundaily/2013/07/06/nsa- rejecting-e...](http://www.tikkun.org/tikkundaily/2013/07/06/nsa-rejecting- every-foia-request-made-by-u-s-citizens/)

<comment><USER22> David Harris-Gershon is a writer for both blogs. They were published to both sources on the same day. He is also following comments on the Daily Kos post, which is obviously targeted to a broader audience. I agree that original sources are best, but in this case there is no value lost.

</comment></comment><comment><USER23> I'm no fan of the recent fourth amendment violations, but the NSA's response is actually reasonable here given its proper mission. Re-read this section, but imagine the requester was asking for information on whether the NSA had collected information about his communications and movements during his recent trip to China:

        Any positive or negative response on a request-by-request basis
        would allow our adversaries [China] to accumulate information
        and draw conclusions about NSA's technical capabilities, sources,
        and methods.  Our adversaries are likely to evaluate all public
        responses related to these programs.  Were we to provide positive
        or negative responses to requests such as yours, our adversaries'
        compilation of the information provided would reasonably be expected
        to cause exceptionally grave damage to the national security.

This is completely accurate. If the NSA actually responded to these requests, it would be trivial for an adversary (e.g. China) to probe the extent and nature of the information the NSA collects, just by having their agents regularly file FOIA requests.

My main problem with these programs is the lack of oversight and any kind of public controls to prevent abuse by bad actors. I don't mind when judges issue warrants to gather private information; that's oversight, with a level of public visibility eventually involved. Warrants are accounted for right there in the fourth amendment.

But these programs are known, thanks to Edward Snowden, to have shoddy controls over individual analyst access to the information. That alone reveals an institutional bias inside the NSA against respecting citizens' privacy; if they treated it as a really big deal then Snowden wouldn't have been able to gain access to individual information as he has claimed. Consequently I have little faith that justice would be served on analysts or departments who use the information for their own purposes, and that's the core problem for me.

We know the FBI treated Martin Luther King as a potential terrorist. If the NSA's information had been available to them, why _wouldn 't_ they have asked for it, formally or otherwise, if there were no negative consequences?

What does that mean for political activism given today's more tightly integrated Department of Homeland Security?

<comment><USER24> The Glomar Response is getting a little tiresome given that nearly everyone is now aware of the surveillance program.

WRT China, the NSA has had a listening post inside China, in cooperation with the Chinese, ever since shortly after the 1979 Islamic revolution in Iran. While the missions are different, it should leave no doubts in the minds of the Chinese intelligence people as to the technical capabilities of the NSA. Between that and the fact that the Chinese are no slouches themselves in communications (their public communications infrastructure is vastly larger than in the US), or in spying on their citizens. I doubt the Chinese have much to learn from these press releases.

</comment></comment><comment><USER25> I agree with the NSA here. Any data they give you about yourself would necessarily tell you what sort of data collection methods they use, which would make it harder to collect data about anyone.

<comment><USER26> That's a feature, not a bug.

</comment></comment><comment><USER27> Sending a FOIA request is probably a nice way of guaranteeing you _will_ be given some special attention from now on, even if they didn't have a file of you beforehand.

<comment><USER28> Perhaps, but perhaps we should have a bunch of different types of people making these requests to add some noise to their filters.

<comment><USER29> I imagine most of the people who have sent FOIA requests are people who take their privacy seriously. Regular people don't 1) know that they can do this, 2) know the procedure for filing a request, 3) don't have time to do it, or think that they don't have enough time. Maybe a campaign could be organized to have hundreds or thousands of of regular people send requests. Get the required paperwork setup in an easy template, organize free postage for the letters, people just have to provide some basic information, sign a sheet of paper, and provide a return address. A lot more unrest would build up if the NSA refused to give information to more people, and their refusals could become big news.

<comment><USER30> Can anyone provide links for information about FOIAs... I know I know I should RTFM and Google it--but if someone has some knowledge about this already, I'd really appreciate it.

I'm interested in the possibility of working to set this up. This seems like a very very good idea. Nothing would be more glaring to me personally than to receive a letter back from the government saying I can't know what they have on me. I think many people would feel similarly.

But I think it will only work if it really is as easy as filling out a form or a fairly easy PDF/etc.

If so, perhaps something as simple as a nice domain and a pretty WP theme with some well-written copy could turn this idea to reality...

Any other takers?

<comment><USER31> A good place to start is [http://www.foia.gov/](http://www.foia.gov/)

The specific information required for a request varies by agency, as do any fees. Most of them now provide online forms on their sites.

While I was the FOIA/Privacy Act coordinator/liaison for one of the commands I was attached to while in the Navy, we generally accepted any form of written request, provided the person included their full name, postal address, phone number and a detailed enough description of the information they were requesting.

</comment></comment></comment></comment></comment><comment><USER32> I'm going to play devils advocate... if the NSA released what information they collect on me seeing that information might show more details on the manner that they collect the data. If more details on the manner that they collect data were to become public then the people the NSA should be targeting such as Al Queda and foreign countries might develop techniques to stop us from monitoring them.

The argument about we know it exists so tell us more because we already know its there really does not add up. I know that Obama's limo has some really cool protective measures, but you know very well that they won't tell me what they are or what they are not. Theres a reason for it.

<comment><USER33> Security through Obscurity? I thought we disliked that.

</comment></comment><comment><USER34> In spite of the outrage, where is the occupy NSA, occupy washington movements? States are not going to reduce surveillance - they have the power and means to do so - and would like to perpetuate the same. Want to preserve your privacy? "Come on!Get up, stand up: stand up for your rights!"

<comment><USER35> Did you attend the Restore the 4th protests on July 4th? That's the main movement right now to fight back.

</comment></comment><comment><USER36> When you write an authentication system with username and password you never display an error like "that password is incorrect", because then the attacker knows that the username is a valid one.

Why does everyone here assume that it's a vast conspiracy when, if they returned everything they had on you, it would be a giant red flag to anyone who was denied that they were being explicitly monitored?

The only way to guarantee secrecy for records that should rightfully be secret (whether you agree with the collection methods or not) is to deny everyone's request.

</comment><comment><USER37> I received the same rejection letter to my request. What's the point of being able to request it if they can arbitrarily reject it?

</comment><comment><USER38> So, NSA became a state within a state with no democratic oversight whatsoever. Is anyone surprised that they crave more and more power?

</comment><comment><USER39> Add usually "national security" is used to trump everything. How convenient for government agencies to hide behind this.

</comment><comment><USER40> In short: Entropy. Facebook, Microsoft, (admittingly have handed this information with ease), etc.... what we know is too much for you to handle so for your own protection and the protection drafted by a few is what now jurisdicts what we can and can not say. We (our govt / those granted amnesty ) can no longer divulge information.

What is key and what is troubling everyone since the jump is what 'they' are going to do with this information, and what 'they' have been doing.

For a lot of you it is easy hyphothesis what a person can do with this information, for instance it has made Mark a billioninaire and countless others rich. It would be a sad state to see this information fall into the wrong hand(s), so it is my hope that someone somewhere makes the decision that no one goverment should be privy to it for the true sake of this freedom we so vicariously fight for.

</comment><comment><USER41> I wish all the best for the U.S., but this country has only presented fear and obstacles to my family, and demands loyalty, recognition. I am a Citizen of the World, and it will be strictly incidental should I corroborate with the U.S. in any way. I bring peace and sharing —

But I will not be lied to, and I will not be coerced into a lifestyle not of my choosing, and I will not be intimidated. I deserve better. The United States has driven me to a life of constant fear, fear not based in delusion but in the severe mismanagement of its society. Daily I find myself at the mercy of its community, whose fear shake the seat of my soul: beliefs of technological domination, spying, etc. I will no longer provide free consultation, on doorsteps or coffeeshops; nor will I abide the complaints of American peoples.

Of this decaying society (U.S.), its peoples will manically accuse anarchism or even the grossest fictions, due to an untrained intellect. Of this decaying society (U.S.), its people must find someone to blame — at which point anarchism becomes indistinguishable from treason.

The United States has mismanaged not only its government; it has injected a venom against intimacy, intelligence, and true investigation. I cannot trust the United States to secure my freedom of intimacy, freedom of intelligence, nor can I trust its integrity or investigation.

I find it disrespectful to myself and undermining to my initiatives to qualify my identity with "U.S. Citizen."

In any event, most people who look at me assume I do not speak English. You cannot coerce someone into looking like an American, and a majority of Americans only look at me with abjection or fear since I have "wild" dreadlocks, which to them look unkept. In many cities, I am heckled on the street with terms like "nigger" and "faggot"; and in polite society, potential peers are taken aback at my personal history ("You can't REALLY be from there!") or even the mere fact that I am a trained philosopher and Web developer. In many ways I look like a "primitive" man largely on account of very matured dreadlocks, and this society is simply too naive, sexually repressed to allow for people who look like Russell Brand to walk the streets: [http://www.youtube.com/watch?v=ADJhErmJuoQ](http://www.youtube.com/watch?v=ADJhErmJuoQ).

Every one of my days in public with you Americans reminds me of that interview. Even yesterday some square approached me to ask if rolling up one pant-leg was a "new fashion thing." I will not be trapped in a country of style-vultures-spies-after-our-personal-brands XOR complaint-ridden-poverty- stricken. I deserve better.

<comment><USER42> You sound as close-minded as some of the people you're railing against.

A square? What does "an American" look like? I look pretty "normal" or at least my outward appearance is intentionally low-key and non-descript.

For me it is the internal that is important though someone who puts a high priority on external ornamentation as an indicator of personality and character would never know if you just went by my external appearance.

</comment></comment><comment><USER43> This isn't really that surprising, offensive, or disappointing. I wouldn't expect them to divulge specific data just because it was discovered that they were collecting it. In fact it could be a really, really bad idea. The best outcome here is to get them to stop collecting the data. Neckbeards sending FOIA requests isn't serving any purpose.

<comment><USER44> "Neckbeards sending FOIA requests isn't serving any purpose."

Could you be more judgmental? Whomever is sending these requests, shaving habits aside, may not adhere to your premise that 'The best outcome here is to get them to stop collecting the data'. It could very well be that they just want to know what has been collected _on them_.

<comment><USER43> >It could very well be that they just want to know what has been collected on them.

Sophistry. He says he can think of nothing that would require monitoring. So he's protesting. Nothing wrong with that, just be honest about it. IIRC there was at least one website set up to automate FOIA requests to the NSA after the Snowden info came out. Why is this guy's story special? It isn't. Why is this even a story?

I'm appalled by the NSA activity, I support Snowden, and I want change, but this story is designed to agitate for political effect and nothing more.</comment></comment></comment>


EMF blocking underwear is getting traction - <AUTHOR> https://www.indiegogo.com/projects/riparo-underwear-protect-your-manhood-gear-up

<comment><AUTHOR> I actually know the founder and he really knows his stuff when it comes to health & fitness. Also: A lot of Canadian entrepreneurs are backing him (incl. Dan Martell, co-founder of Clarity.fm).

EMF might be an actual danger going forward, so I'm curious to where this project will go.</comment>