{"id":4279,"date":"2024-04-27T12:39:48","date_gmt":"2024-04-27T07:09:48","guid":{"rendered":"https:\/\/cthecosmos.com\/?p=4279"},"modified":"2024-04-27T12:39:48","modified_gmt":"2024-04-27T07:09:48","slug":"%f0%9d%91%bb%f0%9d%92%89%f0%9d%92%86-%f0%9d%91%ad%f0%9d%92%90%f0%9d%92%93%f0%9d%92%83%f0%9d%92%8a%f0%9d%92%85%f0%9d%92%85%f0%9d%92%86%f0%9d%92%8f-%f0%9d%91%aa%f0%9d%92%90%f0%9d%92%8f%f0%9d%92%95","status":"publish","type":"post","link":"https:\/\/cthecosmos.com\/?p=4279","title":{"rendered":"\ud835\udc7b\ud835\udc89\ud835\udc86 \ud835\udc6d\ud835\udc90\ud835\udc93\ud835\udc83\ud835\udc8a\ud835\udc85\ud835\udc85\ud835\udc86\ud835\udc8f \ud835\udc6a\ud835\udc90\ud835\udc8f\ud835\udc95\ud835\udc93\ud835\udc90\ud835\udc8d \ud835\udc7a\ud835\udc95\ud835\udc82\ud835\udc95\ud835\udc86\ud835\udc8e\ud835\udc86\ud835\udc8f\ud835\udc95: \ud835\udc6e\ud835\udc90\ud835\udc95\ud835\udc90"},"content":{"rendered":"\n<p class=\"has-black-color has-white-background-color has-text-color has-background has-link-color wp-elements-9df8d76d079e112de4f1aa293594c33c\" style=\"font-size:17px;line-height:1.8\">The `goto` statement has been a topic of debate among developers for decades. While it provides a straightforward way to jump from one point to another in code, the potential pitfalls associated with its use can be severe. Let\u2019s explore this topic in-depth<br><br><strong>\ud835\udc7e\ud835\udc89\ud835\udc82\ud835\udc95 \ud835\udc6c\ud835\udc99\ud835\udc82\ud835\udc84\ud835\udc95\ud835\udc8d\ud835\udc9a \ud835\udc8a\ud835\udc94 \ud835\udc6e\ud835\udc90\ud835\udc95\ud835\udc90?<\/strong><br>`goto` is a control statement that instructs the program to jump to a specific point in the code, bypassing any intermediate steps. While it sounds simple, its consequences are profound.<br><br><strong>\ud835\udc7b\ud835\udc89\ud835\udc86 \ud835\udc77\ud835\udc8a\ud835\udc95\ud835\udc87\ud835\udc82\ud835\udc8d\ud835\udc8d\ud835\udc94 \ud835\udc90\ud835\udc87 \ud835\udc6e\ud835\udc90\ud835\udc95\ud835\udc90<\/strong><br><br><strong><em>1.Breaking the Structure:<\/em><\/strong><br>Programming paradigms have evolved towards structured programming. This is a design that encourages linear progression with loops and conditionals. `goto` disrupts this flow, making code harder to understand and maintain.<br><br><strong><em>2. The Spaghetti Code Phenomenon:<\/em><\/strong><br>Goto can lead to code where the flow of execution jumps around, much like spaghetti strands intertwining. This makes debugging a nightmare as tracing code becomes a maze-like endeavor.<br><br><strong><em>3.Optimization Challenges:<\/em><\/strong><br>Modern compilers optimize code for performance. When `goto` is used excessively, it becomes challenging for compilers to predict the flow, leading to sub-optimal execution.<br><br><strong><em>4. Error-Prone<\/em><\/strong>: With goto, it&#8217;s easy to create unintended infinite loops or skip essential parts of the code accidentally. This can lead to unexpected behaviors and bugs.<br><br>To truly understand the impact of `goto`, we can inspect the assembly code generated from a C program. The image on this post consists of assembly code generated for with goto and without goto statement for a factorial problem. To summarize the image:<br><br>With Goto:<br><br>.L4:<br>\/\/ Some operations<br>Jump directly back to .L4<br><br>Without Goto:<br>.L4:<br>\/\/ Some operations<br>.L6:<br>\/\/ Additional operations or a structured loop back to .L4<\/p>\n\n\n\n<figure class=\"wp-block-image alignfull size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"463\" data-attachment-id=\"4282\" data-permalink=\"https:\/\/cthecosmos.com\/?attachment_id=4282\" data-orig-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2024\/04\/pongoto.png?fit=4414%2C2044&amp;ssl=1\" data-orig-size=\"4414,2044\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"pongoto\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2024\/04\/pongoto.png?fit=1000%2C463&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2024\/04\/pongoto.png?resize=1000%2C463&#038;ssl=1\" alt=\"\" class=\"wp-image-4282\" \/><\/figure>\n\n\n\n<p class=\"has-black-color has-white-background-color has-text-color has-background has-link-color wp-elements-a198ada018ef383d1a0b5f936c0cc4a4\" style=\"font-size:17px;line-height:1.8\"><br>The `goto` version creates an endless loop, continually repeating the operations in `.L4`. In contrast, the structured version can either move forward to `.L6` or loop back to `.L4` based on a clear condition. This structured approach provides context, making the code&#8217;s intention clear.<br><br>There was this letter Published by Edgar Dijkstra &#8221; <strong>Go To statement Considered Harmful<\/strong>.&#8221;<br><br>The letter had a profound impact on the software development community. It led to a shift towards structured programming, where control structures like loops and conditionals are preferred over goto. As a result, many modern programming languages either restrict the use of goto or omit it entirely.<br><br>The Letter: <a href=\"https:\/\/homepages.cwi.nl\/~storm\/teaching\/reader\/Dijkstra68.pdf\">https:\/\/homepages.cwi.nl\/~storm\/teaching\/reader\/Dijkstra68.pdf<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p class=\"has-black-color has-white-background-color has-text-color has-background has-link-color wp-elements-1c5c35a166a8d9deba3cd4a98becb1ee\" style=\"font-size:17px\">LinkedIn post: <a href=\"https:\/\/www.linkedin.com\/posts\/t-yashwanth-naidu_earlycareerembedded-earlycareer-embeddedsystems-activity-7113027707260567552-4LMb\/?utm_source=share&amp;utm_medium=member_desktop\">https:\/\/www.linkedin.com\/posts\/t-yashwanth-naidu_earlycareerembedded-earlycareer-embeddedsystems-activity-7113027707260567552-4LMb\/?utm_source=share&amp;utm_medium=member_desktop<\/a><\/p>\n\n\n\n<p class=\"has-white-color has-text-color has-background has-link-color has-medium-font-size wp-elements-486e7799b35920eece0029316d5e98bd\" style=\"background:linear-gradient(135deg,rgb(35,23,11) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%)\">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br><strong>An Article by: <\/strong>Yashwanth Naidu Tikkisetty<br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The &#8216;goto&#8217; statement in programming has sparked long-standing debate due to its ability to disrupt code structure. It can lead to spaghetti code, hinder optimization, and cause errors. This has prompted a shift toward structured programming. A letter by Edgar Dijkstra further solidified the move away from &#8216;goto&#8217; in favor of control structures. [Read more](<a href=\"https:\/\/homepages.cwi.nl\/~storm\/teaching\/reader\/Dijkstra68.pdf\" rel=\"nofollow\">https:\/\/homepages.cwi.nl\/~storm\/teaching\/reader\/Dijkstra68.pdf<\/a>)<\/p>\n<a href=\"https:\/\/cthecosmos.com\/?p=4279\" class=\"more-link\">Read More <span class=\"screen-reader-text\">\ud835\udc7b\ud835\udc89\ud835\udc86 \ud835\udc6d\ud835\udc90\ud835\udc93\ud835\udc83\ud835\udc8a\ud835\udc85\ud835\udc85\ud835\udc86\ud835\udc8f \ud835\udc6a\ud835\udc90\ud835\udc8f\ud835\udc95\ud835\udc93\ud835\udc90\ud835\udc8d \ud835\udc7a\ud835\udc95\ud835\udc82\ud835\udc95\ud835\udc86\ud835\udc8e\ud835\udc86\ud835\udc8f\ud835\udc95: \ud835\udc6e\ud835\udc90\ud835\udc95\ud835\udc90<\/span><\/a>","protected":false},"author":120055267,"featured_media":4280,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":false,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_wpas_customize_per_network":false},"categories":[769112296,36985,28627,30181,952411],"tags":[772321195,772321193,36931137,1354040],"class_list":{"0":"post-4279","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-c-concepts-hub","8":"category-c-programming","9":"category-embedded","10":"category-embedded-systems","11":"category-short-articles","12":"tag-c-programming","13":"tag-embedded-systems","14":"tag-goto-statement","15":"tag-short-article","17":"fallback-thumbnail"},"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/cthecosmos.com\/wp-content\/uploads\/2024\/04\/chjpdmf0zs9sci9pbwfnzxmvd2vic2l0zs8ymdiylta1l25zmtq0mdktaw1hz2uta3d2d283nhkuanbn.webp?fit=1024%2C683&ssl=1","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8CiEf-171","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts\/4279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/users\/120055267"}],"replies":[{"embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4279"}],"version-history":[{"count":6,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts\/4279\/revisions"}],"predecessor-version":[{"id":4287,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/posts\/4279\/revisions\/4287"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=\/wp\/v2\/media\/4280"}],"wp:attachment":[{"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cthecosmos.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}