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 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


    (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

    - 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