From 610d1f02dd57cbaeccd076ad14ee9efacc5954a5 Mon Sep 17 00:00:00 2001 From: Kumar Damani Date: Tue, 3 Jan 2023 13:13:10 -0500 Subject: prog as art post draft --- content/post/programming-as-art/index.md | 67 +++++++++++++++++++ public/categories/index.html | 2 +- public/index.html | 4 +- public/index.xml | 11 +++- public/post/index.html | 16 ++++- public/post/index.xml | 11 +++- public/post/programming-as-art/index.html | 106 ++++++++++++++++++++++++++++++ public/post/programs/index.html | 2 +- public/post/self-host/index.html | 4 +- public/series/index.html | 2 +- public/sitemap.xml | 13 ++-- public/tags/index.html | 2 +- public/tags/index.xml | 6 +- public/tags/index/index.html | 2 +- public/tags/index/index.xml | 2 +- public/tags/personal/index.html | 5 +- public/tags/personal/index.xml | 11 +++- public/tags/tech/index.html | 5 +- public/tags/tech/index.xml | 11 +++- 19 files changed, 257 insertions(+), 25 deletions(-) create mode 100644 content/post/programming-as-art/index.md create mode 100644 public/post/programming-as-art/index.html diff --git a/content/post/programming-as-art/index.md b/content/post/programming-as-art/index.md new file mode 100644 index 0000000..1be9cb5 --- /dev/null +++ b/content/post/programming-as-art/index.md @@ -0,0 +1,67 @@ ++++ +author = "Kumar Damani" +title = "Romanticism in Programming" +date = "2022-11-29" +draft = true +description = "How programming is romantic." +tags = [ + "personal" +] ++++ + +Why there is art in programming. + + +During the early days as a CS student we were learning about loops, +and saw "Hello World!" getting printed out to the console N-thousands of times +in just 3 functional lines of code. + +for 1 to 1000: + print "Hello World!" + +This felt like having the Elder Wand at the time. + +But there was more to our lesson. +The TA then asks us to put our newly found power to use by computing the +sum of 1 to 100. Of course, it was a natural application of our topic: + +sum = 0 +for i in 1 to 100: + sum = sum + i + +Sure enough we saw the answer 5050 in the console. +But then the TA reminds us that we are making our computers work too hard. +It needs to do 100 basic ADD instructions in order to make this computation happen. + +What if it the number was a million? How well would our method scale? +Well then it would take a million basic ADD instructions. +Seems like this scales with "linearly" with the input size. +Later we would formalize this to O(n). + +The TA hinted that there is a better way, and that we already know of the better way in math. + +sum = n(n+1)/2 + +With this we are no longer using loops, but a known mathematical fact about sequences. +This one-liner solves our problem with 3 basic (ADD, MULTIPLY, DIVIDE) instructions. +It does not depend on the size of the input like our previous solution, thus +no matter the input, it always takes 3 instructions to compute! +This is a HUGE win! +Later we would formalize this to O(1), or "constant" scaling. + +> IRL the complier would optimize the loop solution such that it does not take N instructions +but for the purposes of learning we were not allowed to depend on that. + +Looking back at it now, +Both solutions are equally correct, and modern compilers would optimize the first solution +in the final instructions such that any performance differences would be negligible. +Objectively, the first solution is more readable, and friendly to a new observer than the second. +Yet I am still so drawn to the second solution. + +The first solution reminds me of the saying "to a hammer, eveything looks like a nail". +Its a brute force approach. +In comparison, with the second solution, using the exact tool for our particular problem +somehow feels personalized and even "romantic". + +Most often in programming, we don't have such clear optimizations. It often comes down to +using the correct data-structures for the correct situation, and elegance emerges as a result. diff --git a/public/categories/index.html b/public/categories/index.html index 3c25e13..b07f4d4 100644 --- a/public/categories/index.html +++ b/public/categories/index.html @@ -79,7 +79,7 @@ diff --git a/public/index.html b/public/index.html index 6d00e1f..47501c0 100644 --- a/public/index.html +++ b/public/index.html @@ -2,7 +2,7 @@ - Kumar Damani - Home + Kumar Damani - Home @@ -244,7 +244,7 @@ years in between semesters. diff --git a/public/index.xml b/public/index.xml index a0e494d..c474b88 100644 --- a/public/index.xml +++ b/public/index.xml @@ -6,7 +6,16 @@ Recent content on Kumar Damani - Home Hugo -- gohugo.io en-us - Mon, 12 Sep 2022 00:00:00 +0000 + Tue, 29 Nov 2022 00:00:00 +0000 + + Romanticism in Programming + https://kumardamani.net/post/programming-as-art/ + Tue, 29 Nov 2022 00:00:00 +0000 + + https://kumardamani.net/post/programming-as-art/ + <p>Why programming I see programming as an art form.</p> + + Why do I self-host? https://kumardamani.net/post/self-host/ diff --git a/public/post/index.html b/public/post/index.html index 524f518..12a4c71 100644 --- a/public/post/index.html +++ b/public/post/index.html @@ -43,6 +43,20 @@ +
+
+

Romanticism in Programming

+ +
+ +
+

Why programming I see programming as an art form.

+
+
+

Why do I self-host?

@@ -105,7 +119,7 @@ diff --git a/public/post/index.xml b/public/post/index.xml index 8451bdc..117b024 100644 --- a/public/post/index.xml +++ b/public/post/index.xml @@ -6,7 +6,16 @@ Recent content in Posts on Kumar Damani - Home Hugo -- gohugo.io en-us - Mon, 12 Sep 2022 00:00:00 +0000 + Tue, 29 Nov 2022 00:00:00 +0000 + + Romanticism in Programming + https://kumardamani.net/post/programming-as-art/ + Tue, 29 Nov 2022 00:00:00 +0000 + + https://kumardamani.net/post/programming-as-art/ + <p>Why programming I see programming as an art form.</p> + + Why do I self-host? https://kumardamani.net/post/self-host/ diff --git a/public/post/programming-as-art/index.html b/public/post/programming-as-art/index.html new file mode 100644 index 0000000..691abf4 --- /dev/null +++ b/public/post/programming-as-art/index.html @@ -0,0 +1,106 @@ + + + + Romanticism in Programming – Kumar Damani - Home + + + + + + + + + + + + + + + + + + + + +
+ + + +
+
+

Romanticism in Programming

+
+
+

Why programming I see programming as an art form.

+

It started off in my first year as a CS student during a lecture about loops. +It was mind-bending to see “Hello World!” getting printed out to the console N-thousands of times +in just 3 functional lines of code.

+

But there was more. The TA then asks us to put our newly found power to use by producing the +sum of 1 to 100. Ofcourse, it was a natural application of our topic. We simply set the limit, +and do an increment a sum in the loop’s body.

+

Sure enough we saw the answer 5050 in the console. +But then the TA reminds us that we are making that computer work too hard. +It needs to do 100 basic ADD instructions in order to make this happen. +What if it was a million? +Is there a better way?

+
+
+ +
+ +
+
+
+ +

Links

+

Git, email, resume etc.

+
+ + + +
+
+
+

Why I see programming as an art form.

+ +

+ By Kumar Damani, + 2022-11-29 +

+ + +
+
+ + + +
+ + + diff --git a/public/post/programs/index.html b/public/post/programs/index.html index fb13c1a..8d27d54 100644 --- a/public/post/programs/index.html +++ b/public/post/programs/index.html @@ -142,7 +142,7 @@ suffice it to say I will not endorse the usage of proprietary software.

diff --git a/public/post/self-host/index.html b/public/post/self-host/index.html index 723ce2f..cdc2049 100644 --- a/public/post/self-host/index.html +++ b/public/post/self-host/index.html @@ -161,7 +161,7 @@ Short of this, you can only limit your usage.
  1. -

    Smartphones and dompanime ↩︎

    +

    Smartphones and dopamine ↩︎

  2. Mental health and social media ↩︎

    @@ -215,7 +215,7 @@ Short of this, you can only limit your usage.
  3. diff --git a/public/series/index.html b/public/series/index.html index f1b97df..1dd6c3d 100644 --- a/public/series/index.html +++ b/public/series/index.html @@ -79,7 +79,7 @@ diff --git a/public/sitemap.xml b/public/sitemap.xml index 8ff01db..a034c96 100644 --- a/public/sitemap.xml +++ b/public/sitemap.xml @@ -3,20 +3,23 @@ xmlns:xhtml="http://www.w3.org/1999/xhtml"> https://kumardamani.net/ - 2022-09-12T00:00:00+00:00 + 2022-11-29T00:00:00+00:00 0 https://kumardamani.net/tags/personal/ - 2022-09-12T00:00:00+00:00 + 2022-11-29T00:00:00+00:00 https://kumardamani.net/post/ - 2022-09-12T00:00:00+00:00 + 2022-11-29T00:00:00+00:00 + + https://kumardamani.net/post/programming-as-art/ + 2022-11-29T00:00:00+00:00 https://kumardamani.net/tags/ - 2022-09-12T00:00:00+00:00 + 2022-11-29T00:00:00+00:00 https://kumardamani.net/tags/tech/ - 2022-09-12T00:00:00+00:00 + 2022-11-29T00:00:00+00:00 https://kumardamani.net/post/self-host/ 2022-09-12T00:00:00+00:00 diff --git a/public/tags/index.html b/public/tags/index.html index 66b6307..ed7f494 100644 --- a/public/tags/index.html +++ b/public/tags/index.html @@ -88,7 +88,7 @@ diff --git a/public/tags/index.xml b/public/tags/index.xml index 57f2072..e50ba59 100644 --- a/public/tags/index.xml +++ b/public/tags/index.xml @@ -6,11 +6,11 @@ Recent content in Tags on Kumar Damani - Home Hugo -- gohugo.io en-us - Mon, 12 Sep 2022 00:00:00 +0000 + Tue, 29 Nov 2022 00:00:00 +0000 personal https://kumardamani.net/tags/personal/ - Mon, 12 Sep 2022 00:00:00 +0000 + Tue, 29 Nov 2022 00:00:00 +0000 https://kumardamani.net/tags/personal/ @@ -19,7 +19,7 @@ tech https://kumardamani.net/tags/tech/ - Mon, 12 Sep 2022 00:00:00 +0000 + Tue, 29 Nov 2022 00:00:00 +0000 https://kumardamani.net/tags/tech/ diff --git a/public/tags/index/index.html b/public/tags/index/index.html index 92ab33d..5557e2f 100644 --- a/public/tags/index/index.html +++ b/public/tags/index/index.html @@ -82,7 +82,7 @@ diff --git a/public/tags/index/index.xml b/public/tags/index/index.xml index 56bc695..78403f7 100644 --- a/public/tags/index/index.xml +++ b/public/tags/index/index.xml @@ -9,7 +9,7 @@ Posts https://kumardamani.net/post/ - Mon, 12 Sep 2022 00:00:00 +0000 + Tue, 29 Nov 2022 00:00:00 +0000 https://kumardamani.net/post/ diff --git a/public/tags/personal/index.html b/public/tags/personal/index.html index 0a62c8a..54f34b3 100644 --- a/public/tags/personal/index.html +++ b/public/tags/personal/index.html @@ -43,6 +43,9 @@
      +
    • Romanticism in Programming
    • + +
    • Why do I self-host?
    • @@ -85,7 +88,7 @@ diff --git a/public/tags/personal/index.xml b/public/tags/personal/index.xml index 311fe6d..1de66fc 100644 --- a/public/tags/personal/index.xml +++ b/public/tags/personal/index.xml @@ -6,7 +6,16 @@ Recent content in personal on Kumar Damani - Home Hugo -- gohugo.io en-us - Mon, 12 Sep 2022 00:00:00 +0000 + Tue, 29 Nov 2022 00:00:00 +0000 + + Romanticism in Programming + https://kumardamani.net/post/programming-as-art/ + Tue, 29 Nov 2022 00:00:00 +0000 + + https://kumardamani.net/post/programming-as-art/ + <p>Why programming I see programming as an art form.</p> + + Why do I self-host? https://kumardamani.net/post/self-host/ diff --git a/public/tags/tech/index.html b/public/tags/tech/index.html index d75ea3a..a83daac 100644 --- a/public/tags/tech/index.html +++ b/public/tags/tech/index.html @@ -43,6 +43,9 @@
        +
      • Romanticism in Programming
      • + +
      • Why do I self-host?
      • @@ -85,7 +88,7 @@ diff --git a/public/tags/tech/index.xml b/public/tags/tech/index.xml index 7bf143b..39ddf39 100644 --- a/public/tags/tech/index.xml +++ b/public/tags/tech/index.xml @@ -6,7 +6,16 @@ Recent content in tech on Kumar Damani - Home Hugo -- gohugo.io en-us - Mon, 12 Sep 2022 00:00:00 +0000 + Tue, 29 Nov 2022 00:00:00 +0000 + + Romanticism in Programming + https://kumardamani.net/post/programming-as-art/ + Tue, 29 Nov 2022 00:00:00 +0000 + + https://kumardamani.net/post/programming-as-art/ + <p>Why programming I see programming as an art form.</p> + + Why do I self-host? https://kumardamani.net/post/self-host/ -- cgit v1.2.3