Close
  • Latest News
  • Artificial Intelligence
  • Big Data and Analytics
  • Cloud
  • Networking
  • Cybersecurity
  • Applications
  • IT Management
  • Storage
  • Sponsored
  • Mobile
  • Small Business
  • Development
  • Database
  • Servers
  • Android
  • Apple
  • Innovation
  • Blogs
  • PC Hardware
  • Reviews
  • Search Engines
  • Virtualization
Read Down
Sign in
Close
Welcome!Log into your account
Forgot your password?
Read Down
Password recovery
Recover your password
Close
Search
Logo
Logo
  • Latest News
  • Artificial Intelligence
  • Big Data and Analytics
  • Cloud
  • Networking
  • Cybersecurity
  • Applications
  • IT Management
  • Storage
  • Sponsored
  • Mobile
  • Small Business
  • Development
  • Database
  • Servers
  • Android
  • Apple
  • Innovation
  • Blogs
  • PC Hardware
  • Reviews
  • Search Engines
  • Virtualization
More
    Home Development
    • Development

    Inviting in the Auditor with Assert

    By
    Peter Coffee
    -
    March 11, 2002
    Share
    Facebook
    Twitter
    Linkedin

      I was looking over recent changes to Java and Visual Basic, and I found myself thinking about the meaning of the word, “assert.”

      Its not an academic question. Names matter. What we call something says a lot about what we think it is, how it works, and how it is different from other things. A “horseless carriage” lives up to its name if it only does the same things as a horse-drawn carriage, but without the horse; if we call the same thing an “automobile,” we invite discussion of greater capabilities.

      Id argue that most programming is “imperative”: we say, “Do this!” and the machine either does it or dies trying. Id also argue that this is the opposite of “non-procedural” programming, even though many people use “procedural” as the opposite of “object-oriented.” Object-oriented languages couple procedures closely to the data that they manipulate, but their logic is still imperative in tone; by contrast, a non-procedural system (such as Prolog or Aion—the latter now sold by Computer Associates as CleverPath Aion Business Rules Expert) states what is true and describes what is wanted and entrusts procedures under the hood—proven code, we hope—to do the work.

      Assertive programming is somewhere in between. When a programming language enables assertions, were neither giving orders to the machine nor leaving the whole task in the hands of someone elses code. Were saying, “If were right so far, then this condition will hold.” Were inviting an auditor, as it were, to check our work and to warn us if we may have made a mistake.

      This is where the differences arise. In Java 1.4, we make an assertion that results in a runtime check—and that throws an error, not just an exception, if the check fails. Unlike an exception, for which there may well be a workaround (hence the use of a “catch” clause), a violated assertion means that we dont really understand whats happening.

      Java puts a high priority on being safe, rather than being efficiently risky by leaving out runtime checks: The decision on whether to enable or disable runtime assertion checking is therefore made at run time, optionally on a package-by-package basis to reflect varying tradeoffs between performance and level of trust, with the additional option of a cautious developer writing code that checks to see if assertions are enabled (and perhaps complaining if they are not).

      In Visual Basic .Net, or in .Net managed code in general, theres a distinction between Debug.Assert (an assertion thats omitted from Release code) and Trace.Assert (which is checked at run time). With Debug assertions, its necessary to make sure that the assertion has no side effects: that it doesnt increment or decrement a counter, for example, which would mean that runtime behavior would differ from what a developer saw during debugging. Its also up to the developer to decide if the DEBUG symbol is defined in the release configuration: If its not, no one in the field can restore the safety mechanism.

      Adding assertions in Java 1.4 fulfills a goal that language designer James Gosling had reluctantly deferred from early versions. Having assertions available in .Net programming, whether in Visual Basic or in C#, encourages developers to think more about their code instead of just banging on it until it (apparently) works. Like all safety mechanisms, though, assertions have to be used if they are to add value.

      And thats where we come back to the meaning of the word, “assert.” The Oxford English Dictionary has the most colorful definition: the act of placing ones hand on the head of a slave, either to free him or to claim him for a task. Assertions in programming can have the same dual nature: we can put them to work until the job of development is done, and they can be freed when the code is ready to be deployed.

      E-mail eWEEK Technology Editor Peter Coffee

      Peter Coffee
      Peter Coffee is Director of Platform Research at salesforce.com, where he serves as a liaison with the developer community to define the opportunity and clarify developers' technical requirements on the company's evolving Apex Platform. Peter previously spent 18 years with eWEEK (formerly PC Week), the national news magazine of enterprise technology practice, where he reviewed software development tools and methods and wrote regular columns on emerging technologies and professional community issues.Before he began writing full-time in 1989, Peter spent eleven years in technical and management positions at Exxon and The Aerospace Corporation, including management of the latter company's first desktop computing planning team and applied research in applications of artificial intelligence techniques. He holds an engineering degree from MIT and an MBA from Pepperdine University, he has held teaching appointments in computer science, business analytics and information systems management at Pepperdine, UCLA, and Chapman College.
      Get the Free Newsletter!
      Subscribe to Daily Tech Insider for top news, trends & analysis
      This email address is invalid.
      Get the Free Newsletter!
      Subscribe to Daily Tech Insider for top news, trends & analysis
      This email address is invalid.

      MOST POPULAR ARTICLES

      Latest News

      Zeus Kerravala on Networking: Multicloud, 5G, and...

      James Maguire - December 16, 2022 0
      I spoke with Zeus Kerravala, industry analyst at ZK Research, about the rapid changes in enterprise networking, as tech advances and digital transformation prompt...
      Read more
      Applications

      Datadog President Amit Agarwal on Trends in...

      James Maguire - November 11, 2022 0
      I spoke with Amit Agarwal, President of Datadog, about infrastructure observability, from current trends to key challenges to the future of this rapidly growing...
      Read more
      Cloud

      IGEL CEO Jed Ayres on Edge and...

      James Maguire - June 14, 2022 0
      I spoke with Jed Ayres, CEO of IGEL, about the endpoint sector, and an open source OS for the cloud; we also spoke about...
      Read more
      IT Management

      Intuit’s Nhung Ho on AI for the...

      James Maguire - May 13, 2022 0
      I spoke with Nhung Ho, Vice President of AI at Intuit, about adoption of AI in the small and medium-sized business market, and how...
      Read more
      Applications

      Kyndryl’s Nicolas Sekkaki on Handling AI and...

      James Maguire - November 9, 2022 0
      I spoke with Nicolas Sekkaki, Group Practice Leader for Applications, Data and AI at Kyndryl, about how companies can boost both their AI and...
      Read more
      Logo

      eWeek has the latest technology news and analysis, buying guides, and product reviews for IT professionals and technology buyers. The site’s focus is on innovative solutions and covering in-depth technical content. eWeek stays on the cutting edge of technology news and IT trends through interviews and expert analysis. Gain insight from top innovators and thought leaders in the fields of IT, business, enterprise software, startups, and more.

      Facebook
      Linkedin
      RSS
      Twitter
      Youtube

      Advertisers

      Advertise with TechnologyAdvice on eWeek and our other IT-focused platforms.

      Advertise with Us

      Menu

      • About eWeek
      • Subscribe to our Newsletter
      • Latest News

      Our Brands

      • Privacy Policy
      • Terms
      • About
      • Contact
      • Advertise
      • Sitemap
      • California – Do Not Sell My Information

      Property of TechnologyAdvice.
      © 2022 TechnologyAdvice. All Rights Reserved

      Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.

      ×