The Artima Developer Community
Sponsored Link

Java Buzz Forum
X = X + 1 Is Evil

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Weiqi Gao

Posts: 1808
Nickname: weiqigao
Registered: Jun, 2003

Weiqi Gao is a Java programmer.
X = X + 1 Is Evil Posted: Sep 22, 2009 8:01 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Weiqi Gao.
Original Post: X = X + 1 Is Evil
Feed Title: Weiqi Gao's Weblog
Feed URL: http://www.weiqigao.com/blog/rss.xml
Feed Description: Sharing My Experience...
Latest Java Buzz Posts
Latest Java Buzz Posts by Weiqi Gao
Latest Posts From Weiqi Gao's Weblog

Advertisement

(Not via Twitter.)

Rich Hickey (in an Artima interview): For example, take a mutable Date class that has year, month, and day. To me, changing a date is like trying to change 42 into 43.

This is as close an elevator pitch for pure functional programming as I've ever seen.

Rich's analogy reminds me of the most painful experience I had when I started programming. So painful that I suppressed that memory ever since. That was when I first saw

x = x + 1;

That's impossible, I thought. That's plainly wrong. It took me days or weeks to "get over" it. My mind fought the rationalization for such stupidity:

  • The equal sign is not a mathematical equal sign but an assignment. (What?)
  • The read x and the blue x means different things. (What?)
  • The blue one is the value before the assignment, and the red after. (Before?)
  • It's really the location. (Location or value, which is it?)

Of course, given no other practical alternatives, I gave in just like everyone else. And now we are in this concurrency crisis. For countless times, we've been called to "look at" problems where a program is not "working" because the assignments are not happening in the order the programmer envisioned. There clearly is a systemic problem.

Rich Hickey's solution is his clojure programming language. I dabbled with it a bit in the past year. I have gotten tremendous value out of Mark Volkmann's write ups on Clojure and STM.

In Mark's latest tweets and emails, he often mentions these three things in one breath:

  • Immutable objects
  • Persistent data structures
  • Transactional software memory

I wonder if that will become the rallying cry for Clojure and Clojure-like alternatives to main stream languages. If so, a paradigm shift is afoot.

Remember OO got traction after its "encapsulation, inheritance, and polymorephism" motto was coined.

Read: X = X + 1 Is Evil

Topic: IBS ties up with British firm to develop transport solutions Previous Topic   Next Topic Topic: EBay calls on EU to change rules restricting online sale of luxury brands

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use