Maple differentiation syntax? If you have assigned a function to a label, how can you take it's derivative? For example I defined fun2 as $x^3$ but doing diff(fun2, x) gives 0.

 A: fun2:=x -> x^3 assigns a "name" for your function that you can reach by writing fun2(x). This is your functions' name from now on, including the (x). Differentiation goes like this:
diff(fun2(x),x)

A: Your fun2 name has been assigned an operator. So it makes sense to produce an new operator which computes the derivative. The command for doing that is D.
fun2:=x -> x^3;

                                         3
                           fun2 := x -> x 

dfun2 := D(fun2);

                                          2
                         dfun2 := x -> 3 x 

Above, I've assigned the result to the name dfun2. Notice that I can then apply that to some argument.
dfun2(4);
                                 48

In contrast, diff acts on expressions (not operators) and returns an expression. So what it gets out cannot be immediately applied to an argument. (And it acts on the result of fun2(x) which evaluates to the expression x^3. It doesn't act on fun2 itself.)
diff(fun2(x),x);

                                   2
                                3 x 

You could turn the expression back into an operator. But it's so much simpler to just use D, which was designed for this.
unapply( diff(fun2(x),x), x );

                                   2
                           x -> 3 x 

There are other more subtle issues that can arise when forcing using of diff on a call to f(x). It could be that f is not prepared to accept a nonnumeric argument. D can still handle this case (and is useful in other corners, too).
f := proc(x) if x>2 then x^2 else x^3; end if; end proc:

diff(f(x),x);
  Error, (in f) cannot determine if this expression is true or false: 2 < x

D(f);

         proc(x) if 2 < x then 2*x else 3*x^2 end if; end proc;

