Web Hosting How-Tos
  Home arrow Web Hosting How-Tos arrow 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


    (Page 1 of 7 )

    Syntax differences aren't always the hardest part of learning a new language, but they can be an issue. In part 3 of my three part series on learning a new programming language, we examine syntax differences in many of the more common languages you may want to learn.

    Code Comments

    The character used for commenting code can vary. Many languages use C type comments. In C, a single line comment uses two forward slashes "//" while a multiline comment uses a forward slash followed by an asterisk, followed by the comment text, and then an asterisk and forward slash.

    /*This is an example of

    a multiline C comment*/

    Other languages, such as Perl and Ruby, use a "#" character for single line comments. Multiline comments for both these languages end with "=end". Perl starts multiline comments with "=cut" while Ruby uses "=begin".

    Comments can also be useful for documentation outside of the source code. There are applications for several languages that capture comments from code and automatically generate documentation from it. This can save a lot of time in developing documentation, provided the output makes some sense to those that don't know anything about the code ahead of time.

    There is a lesson to be learned about comments. Not long ago you may have heard that some source code for Microsoft's Windows 2000 was leaked onto the Internet. There was talk of how this might affect Microsoft's trade secrets and what not, but what garnered the most attention were the comments contained in the code.

    The comments did not contain any important secrets but many comments contained potentially embarrassing language as well as revealing the concern from Microsoft developers that the operating system was being patched and hacked together to make up for serious coding flaws in other Microsoft products, in order for them to run as advertised.

    The lesson here? Never put anything in code comments that you wouldn't want your boss, the client or the general public to see.

    Other Syntax Differences

    Many procedural and OO languages have minor differences in syntax. Though they may be minor, if you are used to the syntax of one language to the point where you could practically write it in your sleep, getting used to another may cause some snags.

    A good example is line endings. Languages that use C type syntax require code lines to end with a semicolon. In Javascript this can be optional, though it is good practice to include them. If you leave them out in PHP, the interpreter will throw an error.

    Some languages, such as Python and Ruby, don't require line ending characters. In fact, in Python, where a block of code begins and ends is determined by the indentation. If you are used to logically indenting your code in another language, you will likely be able to write blocks of code in Python without error.

    Other languages use begin and end keywords to mark the boundaries of blocks of code, such as in if and else constructs. If you're not used to this, you will see errors.

    More Web Hosting How-Tos Articles
    More By Chris Root


     

    WEB HOSTING HOW-TOS ARTICLES

    - Choosing a Web Host for Your WordPress Blog
    - 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






    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek