<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>aayush pal</title>
<link href="https://pal.codes/"/>
<link rel="self" href="https://pal.codes/feed.xml"/>
<id>https://pal.codes/</id>
<updated>2024-02-10T00:00:00Z</updated>
<entry><title>Why Read?</title><link href="https://pal.codes/words/why-read/"/><id>https://pal.codes/words/why-read/</id><updated>2024-02-10T00:00:00Z</updated><summary>My original idea was to share my opinions on why everyone should write. But then I don’t have many blogs of mine to showcase and it would be impractical to pr</summary><content type="html">&lt;p&gt;My original idea was to share my opinions on why everyone should
write. But then I don’t have many blogs of mine to showcase and it
would be impractical to preach what I don’t practise. So I turned
towards what I do a lot of i.e. I read a lot. Reading is very natural
to humans. We share &amp;amp; perceive information in text. But this is
definitely not so natural for everyone, just like going to the gym
regularly is not natural for everyone either. But I was an avid book
reader back in the school, picking up whatever titles would be
available back then in a pretty common convent school. Reading as many
as I could in an academic year, hoping to go big the next one was my
chime.&lt;/p&gt;
&lt;p&gt;I don’t read as many books today. But I still do a lot of reading
everyday. Mostly in the form of articles, writings, blogs, by people I
follow or come across on social media. These could be all about things
like life, engineering to travel, health, finance, etc.&lt;/p&gt;
&lt;p&gt;What does reading give you? Reading builds a perspective. Reading
allows you to understand society’s opinions on topics of matter.
Reading can be a calming activity for our ever-active brains. It truly
feels therapeutic to be completely drawn in on a white page with some
text on it, that somehow seems to build a bridge between you and the
writer. With above point in context, reading makes you relate to the
writer - who could be someone more experienced in a specific art,
skill and that allows you to be inspired and create something of your
own. (Which is why this article exists).&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Reading is what eventually brought me to writing this article. I have
come across so many interesting engineers who write to express their
views and share their experiences. I would like to achieve a similar
glimpse through my writing and become part of the community that loves
to give back.&lt;/p&gt;
</content></entry>
<entry><title>Routine</title><link href="https://pal.codes/words/routine/"/><id>https://pal.codes/words/routine/</id><updated>2023-11-12T00:00:00Z</updated><summary>I have been fortunate enough to have worked with and met a lot of great engineers in my life, and would love to meet more. I have written some personal logs on</summary><content type="html">&lt;p&gt;I have been fortunate enough to have worked with and met a lot of
great engineers in my life, and would love to meet more. I have
written some personal logs on what I have learnt from each experience,
but this article captures a singular pick that I have noticed with
almost everyone I have met, that they all have a routine, a system.
Not a timetable, not a specifically defined set of hours where they
work in focus. But it’s a system they have kept or built for
themselves over time where they have now become immune to changes in
their environment, days and other parameters. Nothing can break their
focus, their processes and their productivity.&lt;/p&gt;
&lt;p&gt;I believe I have been able to achieve some of that myself. Here goes:&lt;/p&gt;
&lt;p&gt;I wake up anywhere around 4 to 6 AM, that gives me a lot of control on
how I steer my day ahead. Then I work on the most primary task for the
day. But making sure that it needs to be wrapped up with a run before&lt;/p&gt;
&lt;ol&gt;&lt;li&gt;I allow myself to be creative during these hours.&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Then I return home, making myself some coffee. During this hour, I
talk to my partner due to time difference. And then I get back to plan
for the day, this is where I have set a strict time rule for 10AM to
4PM - no unnecessary social interactions or other dopamine hits unless
for work or pre-decided. This is the time that I believe allows me to
build patience and discipline. A lot of distraction due to mobile
usage, social media, videos can happen during this time if not curbed.&lt;/p&gt;
&lt;p&gt;Usually end my day after this with some logging about the day, and
some light exercise, or yoga. I do some reading wherever I walk to,
usually to a cafe nearby. Sometimes I like to code a little more
before I sleep, but I have noticed that destroys my ability to sleep
then.&lt;/p&gt;
&lt;p&gt;Anyway, this is my process. I could wake up a little bit later, but
that really doesn’t do any harm. I get right to what I would do. Maybe
I will miss a focus session, I could pull that in later.&lt;/p&gt;
&lt;p&gt;I don’t remember where I read this “To be able to do a certain thing,
you have to be a certain person” or something along the lines.&lt;label for=&quot;sn1&quot; class=&quot;sn-toggle&quot;&gt;&lt;sup class=&quot;sn-ref&quot;&gt;1&lt;/sup&gt;&lt;/label&gt;&lt;input type=&quot;checkbox&quot; id=&quot;sn1&quot; class=&quot;sn-check&quot;/&gt;&lt;span class=&quot;sidenote&quot;&gt;&lt;sup class=&quot;sn-num&quot;&gt;1&lt;/sup&gt; If I find out where I read it, I will add it here.&lt;/span&gt;
But this is basically what brought me to thinking about building my
routine and sticking to it.&lt;/p&gt;
</content></entry>
<entry><title>Notes from 2023 India FOSS</title><link href="https://pal.codes/words/2023-india-foss/"/><id>https://pal.codes/words/2023-india-foss/</id><updated>2023-10-29T00:00:00Z</updated><summary>This is most probably the only event I have attended this year and it was fun as always. Met some cool people, had some interesting conversations with students</summary><content type="html">&lt;p&gt;This is most probably the only event I have attended this year and it
was fun as always. Met some cool people, had some interesting
conversations with students in college and how they are promoting
using Linux &amp;amp; BSD systems within the institution. Which I like a lot.
I remember my time in college, where I would introduce people around
me to linux and how they would all look so baffled as to what that
was. My college was third tier, that means there were not a lot of
good and interested kids around me in the classes. But I would always
find people like me interested in tech, met some AI people, some
blockchain people throughout my college. I digress,&lt;/p&gt;
&lt;p&gt;This year’s IndiaFoss started with the presenter talking about her
personal experience with the FOSS community and how it has been a
wonderful experience for her to lead the IndiaFoss movement just an
year in. All the things she got to learn and other things she helped
improve within the operations and tech side of things.&lt;/p&gt;
&lt;p&gt;Then she moved on to talk about some of the technical debt that the
IndiaFoss organization’s tech platform had accumulated over time due
to improper management and not having enough resources to do a look
back and clear things out.&lt;/p&gt;
&lt;p&gt;Then an engineer came on-stage to talk about exactly what the
organization has been upto in the last few months leading up to this
event. He mentioned they have been simplifying, open sourcing the code
for the main website and moving away from the frappe’s closed
ecosystem for hosting that landing page, I guess. He also announced:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Foss Profile: This is kind of IndiaFoss’ version of read.cv or bento.me platforms. A collection of the digital footprint of a person to maybe build a job profile. Which can be a great talent pool considering this community has a lot of extremely excited and hardworking people.&lt;/li&gt;&lt;li&gt;Newsletters will be hosted on the new frappe platform. Listmonk is being used other ways unmentioned.&lt;/li&gt;&lt;li&gt;They are starting an ecommerce store for selling Merchandise by Jan 2024.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;There were two tracks distributed in 2 auditoriums.&lt;/p&gt;
&lt;h2 id=&quot;session-1-akash-talks-about-vyaakaran&quot;&gt;Session 1: Akash talks about Vyaakaran&lt;/h2&gt;
&lt;p&gt;He talks about his own programming language in 2021. Mentions compiler
design course in his college. Lots of free time. A language to
understand formal languages and automata theory. The course this was
in is called Theory of Computation.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;What is Formal Language and Automata theory? A branch of CS that deals
with abstract machines (Automata) that can understand a pattern
defined by a set of rules (language).&lt;/p&gt;&lt;/blockquote&gt;
&lt;ul&gt;&lt;li&gt;Real world applications&lt;ul&gt;&lt;li&gt;Regular expressions, state machines&lt;/li&gt;&lt;li&gt;Compilers, parsers&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;No practical, visual tools for learning about automata and formal language. Theory can feel limiting.&lt;/li&gt;&lt;li&gt;Why?&lt;ul&gt;&lt;li&gt;Small niche&lt;/li&gt;&lt;li&gt;Can be extended&lt;/li&gt;&lt;li&gt;Would be useful in learning compiler design&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;What is Vyaakaran? A tool to visualize formal grammar, and state machines. Learn about context-free grammar.&lt;/li&gt;&lt;li&gt;This could be a great REPL kinda tool while making a programming language.&lt;/li&gt;&lt;li&gt;How?&lt;ul&gt;&lt;li&gt;Built with typescript in 2022. But learnt a lot, and helping a lot of other students to learn as well.&lt;/li&gt;&lt;li&gt;Vue 3 for interactive editor&lt;/li&gt;&lt;li&gt;Svelte - for static&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;The new version could run a Turing machine.&lt;/li&gt;&lt;li&gt;Things he learnt&lt;ul&gt;&lt;li&gt;It’s ok to reinvent the wheel.&lt;/li&gt;&lt;li&gt;People will stop you. When you build, you learn more about the underneath of how things work.&lt;/li&gt;&lt;li&gt;Peeling a layer of abstraction.&lt;/li&gt;&lt;li&gt;Take things like a challenge. Very rewarding, even if you fail, it still makes you a better engineer.&lt;/li&gt;&lt;li&gt;A FOSS project is not just a collection of files. It’s an emotion of the developers.&lt;/li&gt;&lt;li&gt;Vyaakaran is a manifestation that came out of learning.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;DSLs are fun&lt;ul&gt;&lt;li&gt;Domain specific languages&lt;/li&gt;&lt;li&gt;Used by both programmers &amp;amp; non-programmers.&lt;/li&gt;&lt;li&gt;Can be more powerful and easier than complex UI.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;Vyaakaran has it’s own DSL: Lexico (search library with operators). He made Vyaakaran open source on stage. Very good stage presence and work.&lt;/li&gt;&lt;/ul&gt;
&lt;h2 id=&quot;session-2-arpit-tripathi-on-private-5g-with-open-source-5g-cores&quot;&gt;Session 2: Arpit Tripathi on Private 5G with open source 5G cores&lt;/h2&gt;
&lt;p&gt;He was a part of the first 5g usecase lab to be awarded. Yesterday
Modi awarded 100 more labs.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;What was the motivation?&lt;ul&gt;&lt;li&gt;General usage: WiFi&lt;/li&gt;&lt;li&gt;Handover between two devices is better in 5g&lt;/li&gt;&lt;li&gt;Security: WPA. Uses AKA protocol.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;Deployment: types&lt;ul&gt;&lt;li&gt;Not every enterprise has the resources to invest. Therefore there are certain deployment models like 3gpp.&lt;/li&gt;&lt;li&gt;1st: exclusively inside the premises.&lt;/li&gt;&lt;li&gt;2nd: cloud native core functions over cloud&lt;/li&gt;&lt;li&gt;3rd: the RAN is shared. Look out for RAN?&lt;/li&gt;&lt;li&gt;4th: enterprise slice model: mentioned 5g network slicing.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;Industry 4.0 goals.&lt;/li&gt;&lt;/ul&gt;
</content></entry>
<entry><title>Notes about the C language</title><link href="https://pal.codes/words/c-lang/"/><id>https://pal.codes/words/c-lang/</id><updated>2023-10-26T00:00:00Z</updated><summary>Notes taken while reading Beej’s guide to C. About Originally created to construct programs for the Unix operating system, and a flavor of C called ANSI C was</summary><content type="html">&lt;p&gt;Notes taken while reading &lt;a href=&quot;https://beej.us/guide/bgc/&quot;&gt;Beej’s guide to C&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;about&quot;&gt;About&lt;/h2&gt;
&lt;ul&gt;&lt;li&gt;Originally created to construct programs for the Unix operating system, and a flavor of C called ANSI C was also used in Plan9.&lt;/li&gt;&lt;li&gt;Also was then used to rewrite the Unix kernel.&lt;/li&gt;&lt;li&gt;Compilers for C come built in with most operating systems, eg: gcc, clang.&lt;/li&gt;&lt;/ul&gt;
&lt;h2 id=&quot;language&quot;&gt;Language&lt;/h2&gt;
&lt;ul&gt;&lt;li&gt;Anything between the digraphs &lt;code&gt;/*&lt;/code&gt; and &lt;code&gt;*/&lt;/code&gt; is a comment. Also &lt;code&gt;//&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;&lt;code&gt;#include&lt;/code&gt; tells the C Preprocessor to include a specified file.&lt;/li&gt;&lt;li&gt;Two stages in compilation of C code:&lt;ul&gt;&lt;li&gt;Preprocessor: anything that starts with the pound sign &lt;code&gt;#&lt;/code&gt; or “octothorpe” is handled by the Preprocessor (common /preprocessor directives/). Preprocessor processes code starting with &lt;code&gt;#&lt;/code&gt;, output goes to the Compiler, which compiles it down to assembly.&lt;/li&gt;&lt;li&gt;Compiler: rest all will be handled by the compiler.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;Basic point but the &lt;code&gt;stdio.h&lt;/code&gt; header file allows to perform bunch of I/O functionality.&lt;/li&gt;&lt;li&gt;The main function is called automatically when the program starts executing. Nothing else will be executed before &lt;code&gt;main()&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Languages that typically aren’t compiled are called &lt;em&gt;interpreted&lt;/em&gt; languages. But as we mentioned with Java and Python, they also have a compilation step. And there’s no rule saying that C can’t be interpreted. (There are C interpreters out there!) In short, it’s a bunch of gray areas. Compilation in general is just taking source code and turning it into another, more easily-executed form.&lt;/li&gt;&lt;/ul&gt;
&lt;h2 id=&quot;variable&quot;&gt;Variable&lt;/h2&gt;
&lt;ul&gt;&lt;li&gt;A variable is a name for some data that’s stored in memory at some address. Looking at variables this way helps to understand pointers better (later).&lt;/li&gt;&lt;li&gt;Variable type needs to be defined when declaring, and that type will stay unchanged until it falls out of scope.&lt;/li&gt;&lt;li&gt;Always explicitly initialize variables to some values before you use them.&lt;/li&gt;&lt;li&gt;&lt;code&gt;printf()&lt;/code&gt; format specifiers:&lt;/li&gt;&lt;/ul&gt;
&lt;table&gt;&lt;tr&gt;&lt;th&gt;specifier&lt;/th&gt;&lt;th&gt;type&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;%d&lt;/code&gt;&lt;/td&gt;&lt;td&gt;integer&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;%s&lt;/code&gt;&lt;/td&gt;&lt;td&gt;string&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;%f&lt;/code&gt;&lt;/td&gt;&lt;td&gt;float&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;%zu&lt;/code&gt;&lt;/td&gt;&lt;td&gt;size_t&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;&lt;code&gt;%p&lt;/code&gt;&lt;/td&gt;&lt;td&gt;pointer&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;ul&gt;&lt;li&gt;C originally did not have boolean. In C, &lt;code&gt;0&lt;/code&gt; means false, and any other number, for eg. &lt;code&gt;1&lt;/code&gt; or &lt;code&gt;-44&lt;/code&gt;, means true. If you &lt;code&gt;#include &amp;lt;stdbool.h&amp;gt;&lt;/code&gt; you can also use the &lt;code&gt;bool&lt;/code&gt; keyword.&lt;/li&gt;&lt;li&gt;C has a ternary operator: &lt;code&gt;y += x &amp;gt; 10 ? 17 : 37;&lt;/code&gt; means&lt;/li&gt;&lt;/ul&gt;
&lt;pre data-lang=&quot;c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;if (x &amp;gt; 10)
    y += 17;
else
    y += 37;
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;&lt;li&gt;&lt;code&gt;i++&lt;/code&gt; &amp;amp; &lt;code&gt;i--&lt;/code&gt;: the value of the expression is first computed with the value as-is. &lt;code&gt;++i&lt;/code&gt; &amp;amp; &lt;code&gt;--i&lt;/code&gt;: this happens before the expression is evaluated.&lt;/li&gt;&lt;li&gt;&lt;code&gt;sizeof&lt;/code&gt; operator is used to get the size (in bytes) of a particular expression.&lt;ul&gt;&lt;li&gt;C has a special data type to represent the return value of &lt;code&gt;sizeof&lt;/code&gt;. It’s &lt;code&gt;size_t&lt;/code&gt;. All we know is that it’s an unsigned integer type. &lt;code&gt;%zu&lt;/code&gt; is the format specifier for &lt;code&gt;size_t&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;Also this is a compile-time operation.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;&lt;code&gt;switch&lt;/code&gt; only works with equality comparisons with constant numbers.&lt;ul&gt;&lt;li&gt;Evaluates an expression to an integer value, jumps to the case that corresponds to that value. Execution continues from that point.&lt;/li&gt;&lt;li&gt;If a &lt;code&gt;break&lt;/code&gt; statement is encountered, then execution jumps out of the switch. If no break is applied, it will &lt;em&gt;fall through&lt;/em&gt; and execute all the cases without a break.&lt;/li&gt;&lt;li&gt;Is switch faster? Maybe, maybe not. But switch cannot do things like &lt;code&gt;&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;=&lt;/code&gt; and floating point and other types.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;A not-uncommon use of &lt;code&gt;while&lt;/code&gt; loops is for infinite loops where you repeat while true:&lt;/li&gt;&lt;/ul&gt;
&lt;pre data-lang=&quot;c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;while (1) {
    printf(&amp;quot;1 is always true, so this repeats forever\n&amp;quot;);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;&lt;li&gt;All three parts of a &lt;code&gt;for&lt;/code&gt; loop are optional. An empty for loop &lt;code&gt;for(;;)&lt;/code&gt; will run forever.&lt;/li&gt;&lt;/ul&gt;
&lt;h2 id=&quot;functions&quot;&gt;Functions&lt;/h2&gt;
&lt;ul&gt;&lt;li&gt;Arguments and return value types have to be predeclared.&lt;/li&gt;&lt;li&gt;A parameter is a special type of local variable into which the arguments are copied. Thus, a parameter is a &lt;em&gt;copy&lt;/em&gt; of the argument, not the argument itself.&lt;/li&gt;&lt;li&gt;Functions will be defined before being called.&lt;/li&gt;&lt;li&gt;Passing by value basically means we copy the value of the argument into the parameter of the function. Unless returned, no value in the parent, for eg. &lt;code&gt;main&lt;/code&gt;, changes.&lt;/li&gt;&lt;li&gt;Function prototypes look something like &lt;code&gt;int foo(void);&lt;/code&gt; where we have created a prototype before defining the function and it’s okay to call it before definition.&lt;/li&gt;&lt;li&gt;Use the &lt;code&gt;void&lt;/code&gt; keyword as parameter instead of an empty parameter list for function definitions.&lt;/li&gt;&lt;/ul&gt;
&lt;h2 id=&quot;pointers&quot;&gt;Pointers&lt;/h2&gt;
&lt;ul&gt;&lt;li&gt;When you have a data type (like your typical &lt;code&gt;int&lt;/code&gt;) that uses more than a byte of memory, the bytes that make up the data are always adjacent to one another in memory. Sometimes they’re in the order that you expect, and sometimes they’re not.&lt;label for=&quot;sn1&quot; class=&quot;sn-toggle&quot;&gt;&lt;sup class=&quot;sn-ref&quot;&gt;1&lt;/sup&gt;&lt;/label&gt;&lt;input type=&quot;checkbox&quot; id=&quot;sn1&quot; class=&quot;sn-check&quot;/&gt;&lt;span class=&quot;sidenote&quot;&gt;&lt;sup class=&quot;sn-num&quot;&gt;1&lt;/sup&gt; See &lt;a href=&quot;https://en.wikipedia.org/wiki/Endianness&quot;&gt;endianness&lt;/a&gt; — byte order is a property of the platform.&lt;/span&gt; While C doesn’t guarantee any particular memory order (it’s platform-dependent), it’s still generally possible to write code in a way that’s platform-independent where you don’t have to even consider these pesky byte orderings.&lt;/li&gt;&lt;li&gt;A pointer holds the address of a data. It tells us where in memory a data point is stored.&lt;/li&gt;&lt;li&gt;A dereference operator is used to get the original data indirectly from the pointer variable.&lt;/li&gt;&lt;li&gt;&lt;code&gt;&amp;amp;i&lt;/code&gt; ampersand will get the address of the variable &lt;code&gt;i&lt;/code&gt;, it cannot be on the left side of a statement.&lt;/li&gt;&lt;li&gt;The main use of pointers is when you might want to return more than a single value from the execution of a function (while we know functions don’t allow multiple returns like in Go). Pointers will allow you to point to that address, data and be able to mutate it.&lt;/li&gt;&lt;li&gt;A question: do we always use pointers in case of complex functions? (mutating multiple values for eg.)&lt;/li&gt;&lt;li&gt;When using pointers, &lt;code&gt;j&lt;/code&gt; for eg. is the address while &lt;code&gt;*j&lt;/code&gt; will give the value at that address.&lt;/li&gt;&lt;li&gt;Any pointer variable of any pointer type can be set to a special value called &lt;code&gt;NULL&lt;/code&gt;. This indicates that this pointer doesn’t point to anything.&lt;/li&gt;&lt;/ul&gt;
&lt;pre data-lang=&quot;c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;int *p;
p = NULL;
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;&lt;li&gt;Despite being called &lt;a href=&quot;https://en.wikipedia.org/wiki/Null_pointer#History&quot;&gt;the billion dollar mistake by its creator&lt;/a&gt;, the &lt;code&gt;NULL&lt;/code&gt; pointer is a good &lt;a href=&quot;https://en.wikipedia.org/wiki/Sentinel_value&quot;&gt;sentinel value&lt;/a&gt; and general indicator that a pointer hasn’t yet been initialized. (Of course, like other variables, the pointer points to garbage unless you explicitly assign it to point to an address or &lt;code&gt;NULL&lt;/code&gt;.)&lt;/li&gt;&lt;/ul&gt;
&lt;h2 id=&quot;array&quot;&gt;Array&lt;/h2&gt;
&lt;ul&gt;&lt;li&gt;Array length can be read inside a function with the array passed as an argument.&lt;/li&gt;&lt;li&gt;&lt;code&gt;sizeof(int)&lt;/code&gt; is basically calling the sizeof fn to check on the size of the int array without creating an array.&lt;/li&gt;&lt;li&gt;When initializing an array you don’t need to fill the array to the size. But you definitely can’t add more.&lt;/li&gt;&lt;/ul&gt;
&lt;h2 id=&quot;strings&quot;&gt;Strings&lt;/h2&gt;
&lt;ul&gt;&lt;li&gt;&lt;code&gt;char *s = &amp;quot;Hello, world!&amp;quot;;&lt;/code&gt; is a pointer initialization to the first character in the string, but is immutable. &lt;code&gt;s[0] = 'z';&lt;/code&gt; is not allowed. Quite the opposite when you ~char s[] = “Hello, world!”;~.&lt;/li&gt;&lt;li&gt;C follows a different route with implementing strings in the language, wherein it stores the bytes of a string, and marks the end of a string with a special byte called the terminator.&lt;ul&gt;&lt;li&gt;A pointer to the first character in the string.&lt;/li&gt;&lt;li&gt;A zero-valued byte (or &lt;code&gt;NUL&lt;/code&gt; character) somewhere in memory after the pointer that indicates the end of the string.&lt;/li&gt;&lt;li&gt;A &lt;code&gt;NUL&lt;/code&gt; character can be written in C as &lt;code&gt;\0&lt;/code&gt;.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;/ul&gt;
&lt;h2 id=&quot;structs&quot;&gt;Structs&lt;/h2&gt;
&lt;ul&gt;&lt;li&gt;Structs is a convenient way to handle data. Multiple parameters can be replaced with a single type. It basically allows a user to create types, to define data models.&lt;/li&gt;&lt;li&gt;&lt;code&gt;struct car { ... }&lt;/code&gt; is how you define a struct type. ~struct car honda~ is how you define a variable of struct type car.&lt;/li&gt;&lt;li&gt;&lt;code&gt;struct car honda = {&amp;quot;honda city&amp;quot;, 123, 44}&lt;/code&gt; — you could initialize it this way but imagine if the order of the struct’s data is changed, that would break the whole code. Instead you could write &lt;code&gt;struct car honda = {.name=&amp;quot;honda city&amp;quot;, .speed=123, .price=44}&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;There are basically two cases when you’d want to pass a pointer to the struct as the argument to a function:&lt;ol&gt;&lt;li&gt;You need the function to be able to make changes to the struct that was passed in, and have those changes show in the caller.&lt;/li&gt;&lt;li&gt;The struct is somewhat large and it’s more expensive to copy it onto the stack than it is to just copy a pointer.&lt;/li&gt;&lt;/ol&gt;
&lt;/li&gt;&lt;li&gt;We just need to write the body. One attempt might be:&lt;/li&gt;&lt;/ul&gt;
&lt;pre data-lang=&quot;c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;void set_price(struct car *c, float new_price) {
    c.price = new_price;  // ERROR!!
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That won’t work because the dot operator only works on structs — it
  doesn’t work on &lt;em&gt;pointers&lt;/em&gt; to structs.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Ok, so we can dereference the struct to de-pointer it to get to the struct itself, which we should be able to use the dot operator on:&lt;/li&gt;&lt;/ul&gt;
&lt;pre data-lang=&quot;c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;void set_price(struct car *c, float new_price) {
    (*c).price = new_price;  // Works, but is ugly and non-idiomatic :(
}
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;&lt;li&gt;So this is where the arrow operator comes in. The arrow operator helps refer to fields in pointers to structs:&lt;/li&gt;&lt;/ul&gt;
&lt;pre data-lang=&quot;c&quot;&gt;&lt;code class=&quot;language-c&quot;&gt;void set_price(struct car *c, float new_price) {
    c-&amp;gt;price = new_price;  // This looks so much better!
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;file-i-o&quot;&gt;File I/O&lt;/h2&gt;
&lt;ul&gt;&lt;li&gt;Before diving into anything else:&lt;ul&gt;&lt;li&gt;&lt;code&gt;stdin&lt;/code&gt;: Standard Input, generally the keyboard by default.&lt;/li&gt;&lt;li&gt;&lt;code&gt;stdout&lt;/code&gt;: Standard Output, generally the screen by default.&lt;/li&gt;&lt;li&gt;&lt;code&gt;stderr&lt;/code&gt;: Standard Error, generally the screen by default, as well.&lt;/li&gt;&lt;li&gt;These are the core I/O streams assigned to all programs or processes running on a Unix system.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;Reading text files:&lt;ul&gt;&lt;li&gt;Streams are generally categorized in two different ways: &lt;em&gt;text&lt;/em&gt; and &lt;em&gt;binary&lt;/em&gt;.&lt;/li&gt;&lt;li&gt;There is a special character defined as a macro: &lt;code&gt;EOF&lt;/code&gt;. This is what &lt;code&gt;fgetc()&lt;/code&gt; will return when the end of the file has been reached and you’ve attempted to read another character.&lt;/li&gt;&lt;li&gt;&lt;code&gt;fgetc&lt;/code&gt; — to read a character at a time. &lt;code&gt;fgets&lt;/code&gt; — to read lines.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;li&gt;Writing files:&lt;ul&gt;&lt;li&gt;&lt;code&gt;fputc&lt;/code&gt;, &lt;code&gt;fputs&lt;/code&gt;, &lt;code&gt;fprintf&lt;/code&gt; are basically the one-to-one similar to the readers.&lt;/li&gt;&lt;/ul&gt;
&lt;/li&gt;&lt;/ul&gt;
</content></entry>
<entry><title>Year in review, 2021</title><link href="https://pal.codes/words/yir-2021/"/><id>https://pal.codes/words/yir-2021/</id><updated>2022-01-21T00:00:00Z</updated><summary>This is a collection of my learnings &amp;amp; experiences throughout the year 2021 and the processes I want to see myself building through 2022. Just got back from</summary><content type="html">&lt;p&gt;This is a collection of my learnings &amp;amp; experiences throughout the year
2021 and the processes I want to see myself building through 2022.&lt;/p&gt;
&lt;p&gt;Just got back from a run. I’ve been in Pune about a month now for work
and this is sort of my first experience living away from the family.
After having been stuck at home turning 21 in the middle of a
pandemic, this felt like a great getaway. And it is. Learning so much
about myself, through the habits I’ve built over the two weeks to let
myself focus and form a good balance between life and work here.&lt;/p&gt;
&lt;p&gt;It’s October, and now I have an M1 MacBook Air, my first ever Apple
product. God! How are they so good with building laptops! Sitting at a
cafe in Mumbai and trying to switch to this app called Bear notes for
writing my blogs and I’m already loving it. It’s minimal, clean and
allows me to focus on my process of writing without having to switch
context too often. I can work with MarkDown, so instead of having to
move my cursor to different places around the interfaces, I can very
easily just keep typing in a WYSIWYG manner.&lt;/p&gt;
&lt;p&gt;This was originally supposed to be a recording of my thoughts
throughout the year, but seems like I didn’t come back very often to
this page. But I still wanna include a few things I wanna reflect back
on and what how I see myself moving along in 2022. As an engineer I
never over-estimate or over-promise. I’ve learnt this lesson through
some very practical bad experiences in product management. This keeps
me and the people working with me happy and on track. I don’t plan to
change my thinking about this as this has greatly benefited me in
terms of my work-life balance. I’ve very rarely had to wake up until
late to finish up on some work throughout 2021.&lt;/p&gt;
&lt;p&gt;Here at the Araku Cafe in Indiranagar, Bangalore at the time of
writing this para. People all around me chatting and enjoying their
cups of coffee. I love being in cafes and sometimes just being an
observer. Interesting how everyone sitting there is present at the
same time in the same city at the same place, even though having lived
completely unique lives before that point. In Bangalore, I am here to
meet my team members. I personally find it refreshing to join my team
and work with them in person as opposed to sitting at home at my
table, with nothing but Alexa to notify me about my day. Currently, I
handle the product related work. Anything from deciding what goes in
and what needs to be fixed on a daily basis. What’s very new in this
for me is the backend is a blockchain. Yes it’s a web3 startup and
definitely wasn’t on my plan. All of it happened over a quick call
with a friend and me showing interest in this ever-growing community.&lt;/p&gt;
&lt;p&gt;Apart from learning new things, meeting new people, visiting new
cities, one other thing I’ve made consistent efforts for is to be fit.
I was overweight a year ago. I achieved my target weight in 2021, and
I plan to keep this on and keep improving on my form and agility. I
run very regularly, but recently sort of added working out and HIIT
exercises to the jam. Let’s see how this goes in 2022. I will write
another piece about this later, because I do have come across many
engineers/designers (including all sedentary jobs) facing similar
fitness issues, because of the nature of our work.&lt;/p&gt;
&lt;p&gt;I’m still learning to make better use of my time. I’ve never really
planned my days, weeks. I learnt the real value of time this year. I
had never really given so much thought to my schedules, things I do in
a day. But I want to, why, because I feel planning ur day sort of
slows down the pace and presents the day in front of you with usually
a doable enough list of tasks to get away with. You have more granular
view of your day, allowing you to add slots where you can take a break
every now and then, do more than just work in a day.&lt;/p&gt;
&lt;p&gt;One more thing! I want to write more. I keep saying this and keep
missing out the point, but I feel like I’ve found a rhythm and a
reason now to write more about what and how I am learning things, my
experiences meeting new people, traveling to new cities.&lt;/p&gt;
</content></entry>
</feed>
