Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> alphabet just prints the English alphabet in upper and lowercase. I use this surprisingly often (probably about once a month)

I genuinely wonder, why would anyone want to use this, often?



As a programmer, you sometimes want to make an alphabet lookup table. So, something like:

  var alpha_lu = "abcdefghijklmnopqrstuvwxyz";
Typing it out by hand is error prone as it's not easy to see if you've swapped the order or missed a character.

I've needed the alphabet string or lookup rarely, but I have needed it before. Some applications could include making your own UUID function, making a small random naming scheme, associating small categorical numbers to letters, etc.

The author of article mentioned they do web development, so it's not hard to imagine they've had to create a URL shortener, maybe more than once. So, for example, creating a small name could look like:

  function small_name(len) {
    let a = "abcdefghijklmnopqrstuvwxyz",
        v = [];
    for (let i=0; i<len; i++) {
      v.push( a[ Math.floor( Math.random()*a.length ) ] );
    }
    return v.join("");
  }
  //...
  small_name(5); // e.g. "pfsor"
Dealing with strings, dealing with hashes, random names, etc., one could imagine needing to do functions like this, or functions that are adjacent to these types of tasks, at least once a month.

Just a guess on my part though.


Personally I only ever needed it once. I was re-implementing javascript function doing some strange string processing by using characters in the input string to calculate indexes of alphabet array to replace them with. Since I was using Python I just imported string.ascii_lowercase instead of manually typing the sequence, and when I showed the code to someone more experienced than me, I was told it's base64, so all my efforts were replaced with a single base64.b64_decode() call.


In C I've personally always just done 'a' + x, no table needed


If your native language uses a different alphabet, you might not have been taught "the alphabet song". For example, I speak/read passable Russian, but could not alphabetize a list in Russian.


For me it's when I call customer service or support on the phone, and either give them an account #, or confirm a temporary password that I have been verbally given.


Are you referring to the nato alphabet utility? Or the alphabet script that prints

  abcdefghijklmnopqrstuvwxyz
  ABCDEFGHIJKLMNOPQRSTUVWXYZ


I imagine all of his passwords are abcdefghijklmnopqrstuvwxyz


Apologies, mistook for NATO. Maybe the alphabet is for fonts :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: