Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Part 01: Why should we understand compilers?

Posted on Oct 20 "Knowledge is not power, it is potential. Only when one applies that knowledge, it is power."As developers, we use compilers every. single. day.The limitation is that we are only taught to comprehend programming languages without a deep understanding of how our Code functions. This series of articles will guide you through the inner workings of the compilers that we use so that we can become more proficient developers.So, let's dive in and code like a wizard. 🧙‍♂️Considering you (the reader), you probably already know what a compiler is, but in the case of newer developers, I'll explain it in one sentence."A compiler is a tool that translates human-readable code into machine-readable code."This definition shows us three things about ourselves.In this series, we will be writing our own compiler from the ground up as a learning experience. On the road to that destination we'll learn the basics of low-level operations, compiler parts, and a broader understanding of other compilers.We will:So, buckle up and get ready to take this journey with me. Let's dive into the world of compilers together as we become stronger developers. 🪄The most basic compilers are created in stages.Semantic Analysis - This stage makes sure that the AST actually makes sense. It may check types, proper declaration of variables, and dead code elimination.Code Generation - The compiler translates the AST representation into the syntax of another language (usually lower level). That outputted code will eventually be compiled down to binary operations (ASM, x86, HLC...) by similar compilers.It may take some source code like this (written in Zep, my language)And translate it into the corresponding WAT (A language to represent WebAssembly)All computers utilize hardware and software to function. Your processor hardware understands a language (Machine Code) that is hard for us to grasp as humans. Instead, we code in high-level "languages" that eventually become Machine Code.Stage 01 (8,000m Mt. Everest): Too-High Level LanguageToo-High Level Languages include block coding, scratch, or drag-and-drop style "languages". The best example here is Scratch. This is understood by young children.Stage 02 (0m Sea Level): High Level LanguageHigh Level Languages, abbreviated HLL, are understandable by humans. Some examples are Rust, C++, JavaScript, or WAT. This is understood by all developers.Stage 03 (-300m deep mineshafts): Assembly LanguagesOnly the brave adventurers delve this deep. Assembly is neither a HLL or actual Machine Code, but resides in the no man's land between the two. Not commonly used by humans. Low-level developers or those interested in isoteric languages (Brainf***) understand this.Stage 04 (-65636m Edge of Hell): Machine CodeNearly nobody goes this deep, yet it is still important to understand. Machine Code represents the actual operations performed by the CPU and is understood by the Processor. (As well as minecraft redstoners who design their own computers @mattbattwings). All programming languages are compiled to Machine Code and finally executed by the machine.That's all for now. In future articles, we will begin to build our own compiler and eventually achieve "Hello World".If you would like to see more articles in this series, feel free to comment below, provide suggestions for future articles, and discuss questions. As always, thanks for reading! ✌️Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse Zafar Urakov - Sep 25 Rama Reksotinoyo - Oct 8 InterSystems Developer - Oct 16 Aniket - Sep 25 Once suspended, jairussw will not be able to comment or publish posts until their suspension is removed. Once unsuspended, jairussw will be able to comment and publish posts again. Once unpublished, all posts by jairussw will become hidden and only accessible to themselves. If jairussw is not suspended, they can still re-publish their posts from their dashboard. Note: Once unpublished, this post will become invisible to the public and only accessible to JairusSW. They can still re-publish the post if they are not suspended. Thanks for keeping DEV Community safe. Here is what you can do to flag jairussw: jairussw consistently posts content that violates DEV Community's code of conduct because it is harassing, offensive or spammy. Unflagging jairussw will restore default visibility to their posts. DEV Community — A constructive and inclusive social network for software developers. With you every step of your journey. Built on Forem — the open source software that powers DEV and other inclusive communities.Made with love and Ruby on Rails. DEV Community © 2016 - 2023. We're a place where coders share, stay up-to-date and grow their careers.



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

Part 01: Why should we understand compilers?

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×