Friday, February 28, 2025

The Go language creator mindset


  1. Let's take C and move the argument type to the back, because pointers to pointers are cumbersome to read. This makes the syntax of a defined array: var primes := [6] int {2, 3, 5, 7, 11, 13}
  2. While we're moving things to the back, let's also move the function's return arguments to the back too. That way, all those C programmers start to appreciate their dyslexia.
  3. Let's have pointers, but we're all about safety, so no pointer arithmetic.
  4. Since we don't have pointers to arrays, let's create slices. You update one slice and it updates all the slices of that array! But hey, no pointer arithmetic, so we're preventing programmer created bugs.
  5. And we want all the goodies from a Python list, so let's make slices dynamically sized. For some reason, we still need arrays.
  6. And we love Python so much, we'll add the ability to iterate over a range and have a dictionary type called map.
  7. Let's rename typedef as type, because we save 3 characters and we're all about efficiency. But let's leave struct in, we're not just changing keywords for the sake of it are we? And struct members are accessed  with a dot even when the variable is a pointer to a structure. Let's add arbitrary syntax since we're just making things up a this point.
  8. And let's get rid of breaks in case blocks, because we're all about efficiency.
  9. While we're at it, let's introduce a "naked" return that magically returns all the named arguments. Readability guy took the day off when this was added.
  10. And let's start time 0 on the day Go went open source - acknowledging the momentous day that must take precedence over UNIX's, Python's and every other major language's well established start time.
  11. Let's import "import" from Python, but let's add the option to import multiple modules using a parenthesis, because ... efficiency.
  12. Let's take the package concept from npm, but let's add our nifty touch to it by having a "tidy" keyword to updated dependencies.
  13. Let's solve those pesky multiple returns in a function by adding a defer keyword, because readability is important, but not that important. And did the readability dude resign or something?
  14. The parenthesis around for need to be DOGE'ed too - programmers can save a whole of 3 seconds per day skipping the typing. It's OK to spend a few minutes deciphering the for intent - makes you understand the code better. And while was such a burden on C programmers - let's just get rid of it. After all, what could while do that for couldn't?
  15. C++ is admittedly a complex language. Let's avoid classes in Go and instead add a receiver that lets one add a method to a type. And let's make the syntax: func <pointer to receiver> <method> (<method arguments>) <return type>. See, the syntax in #1 now makes total sense. 
  16. And breaking with the random logic that drives the rest of the syntax, let's constrain the receiver restricted to the same file as the method. The "pointer to receiver" part is important, without which the method behaves as a function that operates on a value and not the reference.
But Go isn't alone in creating garbage syntax. Here's some incomprehensible JS code:
net.createServer(stream => {
  stream = toPull.duplex(stream) //turn into a pull-stream
  //connect the output of the net stream to the muxrpc stream
  //and then output of the muxrpc stream to the net stream
  pull(stream, server.stream, stream)
}).listen(8080)
//connect a pair of duplex streams together.

const stream = toPull.duplex(net.connect(8080))

pull(stream, client.stream, stream)

Let's deconstruct:

First, the problems as seen by a C programmer

  1. stream is used before it's defined
  2. The anonymous arrow function takes one argument stream and returns a closure that uses and initializes the same argument, stream.
  3. The function pull has 3 arguments out of which 2 are the same. This is reasonable - if stream is input at one spot and output at another. 
Here's why it works:
  1. The function call inside createServer is a CALLBACK. It is not immediately called.
  2. The listen on port 8080 starts immediately.
  3. Once the client connects using toPull.duplex, the server calls the function inside createServer with stream being initialized to the server side of the connected stream.
Callbacks are the bane of programming. ISRs are perhaps the only legitimate usage for callback constructs. For all other purposes, I would recommend using OS IPC primitives for asynchronous code.

Well, we started with Go and ended up with callbacks. Clearly, I got into the Go spirit of things too deeply.


Wednesday, February 26, 2025

My Uncle's Magical Printer

My uncle's health and happiness was the envy of the extended family and neighbors. Growing up, I would wonder how one man could be clever, strong, funny and creative! The kids would sing the songs he'd write, the grown ups would watch the movies he was in, and on and on.

It turns out, the reason he was so happy, all the time, is that he had a magical printer at home. It printed crisp color photos and laser sharp documents like any other printer, but the real magic was when it printed green. Whenever he needed to buy something, he'd simply make up a number, print the number in green and that's it - he could use that printed sheet to buy anything in the world!

Over time, I could see that age was catching up with my uncle. He had become less dashing, his steps appeared unsure, his machismo was lost. He was softer, kinder and sadly weaker.  But now, he's passed on and I have inherited the printer. I start to examine it closely. From external appearances, the printer doesn't seem magical. It's designed by regular Americans - not just coastal elites. It needs an electrical motor, that's made in Germany. It needs ink that I get from Japan. The paper itself comes from Canada. The software is written in India. And the whole thing is assembled in China. Pretty much like any other printer I can buy from BestBuy. The exceptional thing about my printer is that I pay for all that it needs, and all that I need, with the same printed sheet that comes from my printer! That's some real magic right there.

Now you might say that such perpetual machines always turn out to be fake in the mechanical world. But this is different in a very subtle way. This printer is powered by a source that's endless. Well, it's lasted for approximately 250 years already! Sure, the printer has been abused by past generations and its power source has dimmed and flared, but so far it has all held up reasonably well.

Now you might say, "What's the catch? Why let the world on to this secret? Just let the good times roll."

Well, here's the problem, I don't feel good. People don't laugh at my jokes like they used to when my uncle cracked them, they don't ask my opinion on any movie they're making, I'm mocked and ignored all the time, ... I think that if I fix the printer, I'll restore myself to my uncle's past glory. 

Today, every time I print, I need to follow the user manual. This 4,543 word-long manual doesn't have simple steps like "insert paper in tray and hit the print button." Instead, it has complex instructions that amount to getting permission from regular people. Not directly - I talk to their reps, who're already in my pocket, but still... I have to write down exactly why I need to print, provide details of how the money will get spent, blah, blah, blah... All this due process really slows me down. Without that permission slip, somehow the magical green sheet stops working. It's as if the entire world needs to know that this pesky crowd, albeit 300 million strong, has endorsed this sheet. It's time to make changes, big changes.

First, I'm going to buy Bitcoin with the green sheets that still work. Since I don't understand money and a whole lot of people think Bitcoin is going up, it seems like a good way to diversify my holdings. Then, and this is my most genius idea, I'm going to stop swapping my magical green sheets for finished goods and material from countries around the world. I'll force them to buy goods that I make, because I make the best stuff. As for all those pesky rules about getting permission - I'm going to ignore them and let my friends take over the printer while I own it. Let's see how it goes. See you in 2028, or 2032, or never. Heh, heh.

Saturday, September 14, 2024

Intel on the brink?

 It is sad to see a technological stalwart like Intel reduced to the state that it is now - directionless and hiving off parts of itself to keep either the process or the processor at its core alive. Taking a look at its board of directors, 6 of its 12 directors have been on the board for less than 5 years. Of the 5 that have been with the company long enough to be responsible for its direction, one has antecedents from VC land, two are from the medical devices field, one is a dean at Berkeley and one is from Boeing. The last one is the CEO. While they all seem distinguished on paper, let's parse through them a little bit. 

Medical devices are embedded systems - with microcontrollers, tiny memories and proprietary OSes. Such a market is best served by NXP / ST-Micro. Someone with that experience may not be the best to set the direction for high performance computing, ADAS or FPGAs. The VC guy seems to have led a tiny, nondescript SW company before joining Intel's board of directors. The Boeing guy is a finance guy and his experience should be valuable at these times, unless his time did not overlap with Alan Mullaly. The dean seems to be a great asset to provide direction to the process side of the business. Of all the directors, it seems only one - Barbara Novick appears to have exactly what the company needs. Her company (BlackRock) is one of the main investors and she's herself eminently qualified.

The rest of the board of directors' careers or income do not depend on the company's performance, so the headless meandering of Intel comes as no surprise to me. Others have written about this before [1, 2].  

I'm wondering how INTC's other institutional investor Goliaths like Vanguard, State Street Corp, etc. will handle this situation since there's no public evidence of a proxy fight. It appears as if institutional investors were hardly concerned about Intel's stock performance all these years. The HBR says [3] that only 17% of board changes happen with proxy fights (dated data), and that too when hedge funds are involved, so I think this slate of directors will be the ones driving the company aground.

One might say that a well functioning board needs to have independent directors. There's plenty of evidence available to counter that. And who has the time to make a well researched argument when all my searches will have algorithmic responses that strengthen my bias anyway.

I firmly believe that a new corporate structure for companies is needed. Here are my suggestions that still stay true to the legal requirement that the board acts in the best interests of the investors:

  1. The board must be made of representatives of the key investors. Investors must commit to hold their shares for 5 years to discourage short-sales.
  2. The 5 year period for major shareholders should be offset by 1 year, to emulate a bond-ladder kind of approach.
  3. Market-wide events must also have repercussions in terms of a change of the board-of-directors.
  4. The board must attend employee all-hands meetings and answer open-mic questions.
  5. Layoffs must have consequences - at both the board of directors level and at the company executive management level. This will discourage hire-and-fire and encourage more investment in employee training.
  6. An employee representative must be at every board of directors' meeting. This could be a rotating position at a certain title so that the board hears a diversity of voices.
I wish Intel all the best in its restructure efforts and hope it emerges stronger. A la https://x.com/michaelharriot, this post isn't about Intel.

 Further reading

1. https://www.linkedin.com/pulse/go-hard-home-why-board-directors-need-have-skin-game-kylie-hammond/

2. https://www.reuters.com/breakingviews/european-boards-have-too-little-skin-game-2024-07-17/

3. https://corpgov.law.harvard.edu/2021/06/11/the-directors-guide-to-shareholder-activism



Wednesday, December 13, 2023

Protestors

 सलाम उन लोगों को, जिनहोने उठाई अपनी आवाज़

सड़क पर आए और नारे लगाए बिना कोई आराम

COP28 दुबई तक पहुँची लिसिप्रिय कंगूजाम

बोली बंध करो जीवाशम ईंधन, १२ वर्षीय जाँबाज ।


Monday, November 27, 2023

डरे हुए लोग

जो मूह नहीं खोल पाते, वह क्या चलाएँगे ज़बान

वह उखड़ेगा परचम, जिसने बेच दिया हो ईमान?

जो सीधे खड़े नहीं हो पाते, वह कैसे तानेंगे सीना

इन लोगों के लिए, झुकने का नाम ही है जीना

डरे हुए लोगों की आँखें मीची है मंदिर के बाहर

लड़ते रहो बे उम्र उमर, शीघ्र समाप्त हो यह ग्रीष्म लहर ।  


Saturday, September 23, 2023

In my most ideal life, I'd

  1. be a manager
    • of a Premier League football team.
  2. be a hooligan,
    • a local at any one of the English football clubs, know all the songs, and travel with the team.
  3. bat, chew gum and not wear a helmet,
    • like Vivian Richards.
  4. get cast as the youngest son. 
    • Michael Corleone.
  5. not be named Kuntal.
    • Bond, James Bond.
  6. like mushy tomatoes, 
    • but only when avoiding bulls in La Tomatina in Buñol.
  7. have a milk mustache
    • and live on a quiet farm in the Italian Alps.
  8. run
    • and bike and swim like a triathlete.
  9. work remotely
    • on clever things on an Apple laptop.
  10. fight injustice 
    • by telling bullies over the phone "you'll hear from my lawyer."
  11. have no quiet celebrations
    • and do dandiya on every Indian festival.
  12. say "kai po chhe" every Sankrant,
    • when flying a kite strung with glass-covered manja.
  13. be witty
    • and get published in The New Yorker as a short story writer.
  14. be a purveyor of fine writing instruments
    • and write cursive as neatly as my dad would, with a smooth Hero fountain pen.

Wednesday, March 8, 2023

Standardized tests, affirmative action and government jobs

 The elite colleges of the country have deviously contrived to keep their admission policies beyond scrutiny by lumping standardized tests with affirmative action. They are, in fact, separate and you can have both in place. Affirmative action must continue and be given a growing proportion of admission spots until there is meaningful race equality. For all the spots, standardized tests must be one of the inputs. The final admitted class must mirror the racial distribution of scores on standardized tests.

Let's work through some examples of the proposal, in parts

Growing proportion of affirmative action spots

  1. Say the percentage of affirmative action spots is 5% today. In the next 5 years, it must change to 50%. 5 years because corrective action requires immediacy, otherwise it becomes like the Brown vs the Education board - the students who petitioned did not benefit from desegregation. 50% because meaningful change requires substantial numbers.
Standardized tests
  1. From personal experience with GRE, and my son's experience with SAT, I can say that you can prepare very well just with free material. I studied from an old book that was used by my friend and my son studied off the ETS website. ETS is the administrator for the tests. Public libraries have test prep books.
  2. Within the affirmative action spots, students with the highest scores should be preferred.
  3. Say the race distribution of the highest quartile is: 30% A, 30% B, 40% C, then even after all factors such as extracurricular activities have been considered, the final admitted class should have the same distribution of races.

Government jobs

Finally, the government can do more in ensuring that diversity of thought is engrained in every institution of the country. There is no reason that the Secretary of the Treasury comes from Goldman Sachs, the head of the Federal Reserve comes from Harvard and the Supreme Court Judges come from Yale.

I think socially aware companies such as Apple should withdraw its Amicus Brief here:

Documents Archive - Harvard Admissions Lawsuit

legal_-_filing_-_200521_-_businesses_-_2020.05.21-16_brief_for_amici_curiae_amgen_et_al_.pdf (harvard.edu)