Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • About the "No Side Effects" you say "This is a very uncommon behavior among software languages" - I am a bit surprised at this. Can't Java and C# do this today? What languages do you know that has to have side effects when calling a function? Commented Sep 12, 2012 at 2:59
  • 3
    @EmmadKareem It's not a question of whether you can write a program without side-effects; as you noted, you can do this in Java or C#. It's whether the default is side-effect free, and whether there is compiler support for this. In Java you cannot, for example, tell the compiler "this method doesn't have side effects". This in turn means the compiler cannot warn you when you're breaking the rules! Commented Sep 12, 2012 at 3:27
  • @EmmadKareem I'm not saying it's impossible to write C# or java without side effects (though extremely rare), rather I'm saying that very few programming languages have strict policies built into the language that segregate functions with side effects from those without. Commented Sep 12, 2012 at 3:34
  • It would be great if Java had a @NoSideEffects annotation to put on a method to tell the compiler to enforce no-side-effects for that method. In my own code I like to think it's common for methods to have no side effects. Sure, some methods have to be mutators in a language like Java, but many don't. Especially if you prefer immutable objects in your designs. Commented Sep 12, 2012 at 4:08
  • Jimmy Hoffa and @AndresF., thanks for your clarifications. Commented Sep 12, 2012 at 4:12