Web Hosting How-Tos
  Home arrow Web Hosting How-Tos arrow Page 4 - Learning a New Programming Language Pa...
Web Hosting Articles  
Web Hosting FAQs  
Web Hosting How-Tos  
Web Hosting News  
Web Hosting Security  
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
ASP Web Hosting  
ASP.NET Web Hosting 
Budget Hosting 
Coldfusion 
Colocation 
Mobile Linux 
APP Generation ROI 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Reseller Web Hosting 
Shared Hosting 
Small Business Hosting 
Virtual Private Servers 
Windows Web Hosting
 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WEB HOSTING HOW-TOS

Learning a New Programming Language Part 3: Syntax Differences
By: Chris Root
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 8
    2005-05-11

    Table of Contents:
  • Learning a New Programming Language Part 3: Syntax Differences
  • Defining Variables
  • Variable Syntax
  • Defining Functions
  • A Few Words About C and C related languages
  • Let the Parrot Speak
  • A Summary

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Learning a New Programming Language Part 3: Syntax Differences - Defining Functions


    (Page 4 of 7 )

    Declaring functions is yet another thing that varies from language to language. In Python the keyword "def" is used.

    def myfunction(argument):

    Python functions also have a unique feature called a "doc string" that is the first thing defined in a function.

    """this function returns a number"""

    Doc strings are triple quoted and can be used as a property of the function (in Python functions are objects just like everything else). This allows Python IDEs, for instance, to use the doc string for context sensitive help.

    Both PHP and Javascript use the "function" keyword when defining functions. In Visual Basic a function returns a value. Any function that does not return a value is a procedure; the rest of the syntax is the same. TCL also uses procedures, which are the equivalent of functions.

    Ruby does not have functions, just methods. The syntax is not that dissimilar to functions in other languages.

    Objective C Message Passing

    Objective C is an object oriented subset of the C language. It was originated by the NEXT computer company as part of their Nextstep and Openstep operating systems. NEXT was bought by Apple, who made Objective C the foundation of it's cocoa programming environment. There is also a multi-platform open source implementation of Objective C called GNUStep.

    There are just as many concepts to learn about Objective C as any other object oriented language, but it does have a unique syntax for calling methods that will take some getting used to. Objective C code does not so much call methods as send messages to objects. A message is contained in square brackets.

    int result = [myObject mymethod:myvalue:myothervalue];

    Inside the brackets is the name of the object we are sending the message to, then the name of the method. After the method name is a colon, followed by an argument to the method, and in this example, another colon and argument.

    Finally, Objective C, unlike most compiled languages, has some control over code execution at run time similar to interpreted languages.

    More Web Hosting How-Tos Articles
    More By Chris Root


     

    WEB HOSTING HOW-TOS ARTICLES

    - Connecting to a Server using SSH: the Fundam...
    - How to Expand a Simple Website
    - Practical Virtualization with VirtualBox
    - Other Uses for Your Web Hosting Server
    - Hosting Your Own Website: Reliability
    - Introduction to Hosting Websites
    - Choosing a Website Host
    - How to Choose a Budget Web Host
    - URL Redirection
    - How to Link a Domain Name to a Dynamic IP
    - How to Set up a Simple Website
    - Choosing the Right Kind of Web Hosting
    - Introduction to Choosing the Right Web Host
    - Strategies for Creating Domain Names
    - How to Pick Domain Names






    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT