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 Reviews  
Web Hosting Security  
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
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
     
     

    SEARCH WEB HOSTERS

    TOOLS YOU CAN USE

    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

    - Phishing Scams: An Overview and How to Detec...
    - Tips for Safe Downloading Online
    - How To Avoid Spam
    - How to Get Into Ethical Hacking
    - How to Prevent Drive-by Downloads
    - Facebook Timeline Tips and Tricks
    - How to Keep Up with Facebook`s Changes
    - Wi-Fi Network Security Tips
    - Tips for Safe Online Holiday Shopping
    - Facebook Privacy: Keeping Up with the Const...
    - Tips for Facebook Privacy
    - How to Cover Your Tracks on the Web
    - SSH Keys for FileZilla and Putty in Cpanel
    - How to Create a Filezilla FTP User
    - How to Install FileZilla Server

    Developer Shed Affiliates

     




    © 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap