# The alphabet in programming languages

Our task is to, for each letter of the (English) alphabet, write a program that prints the alphabet, in a language whose name starts with that letter.

Input: none

Output:

abcdefghijklmnopqrstuvwxyz


uppercase and trailing newline optional

Rules:

• The scoring metric is the length of the programming language name, plus the length of the code. Hence, C will be assessed a "penalty" of 1, while GolfScript will be assessed a penalty of 10.
• If a programming language name's first letter is not an English letter, it should not be coerced into one. It will be treated as a separate letter (meaning less competition).
• No answer will be accepted until every English letter has a solution.

Current rankings:

Tell me if I'm missing anybody.

var QUESTION_ID=2078;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&r.indexOf('non-competing')===-1&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],lang:/<a/.test(a[1])?jQuery(a[1]).text():a[1],link:s.share_link})}),e.sort(function(e,s){var d=e.lang[0].toLowerCase(),a=s.lang[0].toLowerCase();return(d>a)-(d<a)||e.size-s.size});var s={},a=null,n="A";e.forEach(function(e){n=e.lang[0].toUpperCase(),a=e.size;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+" is for").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.lang,p=o[0].toUpperCase();s[p]=s[p]||{language:e.language,lang:e.lang,letter:p,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return(e.letter>s.letter)-(e.letter<s.letter)});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.language).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),jQuery("#languages").append(jQuery(i))}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*(?:<[^>]+>)?(?:[^]+?for )?((?:<a[^>]*?>)?(?:(?! [(=→-])[^\n,:])*[^\s,:])(?:[,:]| [(=→-]).*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px} /* font fix */ body {font-family: Arial,"Helvetica Neue",Helvetica,sans-serif;} /* #language-list x-pos fix */ #answer-list {margin-right: 200px;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Winners by Letter</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <h2>Everything</h2> <table class="answer-list"> <thead> <tr><td></td><td>Language</td><td>Author</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>

• Are we allowed to print junk to stderr? – Peter Taylor Apr 18 '11 at 22:02
• @Peter Taylor: Go nuts. To answer your question, yes, printing junk to stderr is fine (as long as stdout is correct). – Joey Adams Apr 18 '11 at 22:05
• Is it OK to print the alphabet IN BIG LETTERS? – dorukayhan Jun 21 '16 at 18:25
• Funge is distinct from Befunge. Surely my pedanticism will be rewarded on a site dedicated to feats of it! – tngreene Mar 23 '17 at 19:53
• Is *0*5AB1E the same as *o*sabie :P? – Magic Octopus Urn Jun 6 '19 at 14:58

## Q is for QBasic, 29 characters → Score: 35

?"abcdefghijklmnopqrstuvwxyz"


Untested, but programming is like riding a bike, right?

• You can get injured while riding a bike. I dare you to drop that space before the quotation mark. – Joey Adams Apr 18 '11 at 22:38
• Nah, that would look too much like "optimized" BASIC programs... – ninjalj Apr 18 '11 at 22:43
• You can use ? instead of print ... – Joey Apr 18 '11 at 23:06
• Feel free to edit, I haven't programmed in BASIC for more than a decade. – ninjalj Apr 18 '11 at 23:11
• You can drop the last quotation mark - QBasic will fix that for you! – steenbergh Dec 23 '18 at 9:07

## S is for Scheme, 37 -> Score: 43

(display"abcdefghijklmnopqrstuvwxyz")


L is for LUA: 3 + 40 = 43

repeat n=1+(n or 96)print(("%c"):format(n))until(n>122)


-> 55

repeat n=1+(n or 96)print(string.char(n))until(n>122)


-> 53

for i=97,122 do print(string.char(i))end


-> 40

• Please keep the code blocks clean, so user scripts like Code Golf UserScript Enhancement Pack which insert code block sizes in the document can show correct values. I mean, please post separate solutions in separate code blocks and specify the code length outside the code block. – manatwork Oct 20 '14 at 10:17
• Thanks. This way is much easier to spot out count mistakes: i.stack.imgur.com/qezQZ.png Seems you included in both cases the final newline character in the count. That is unnecessary. – manatwork Oct 20 '14 at 10:29
• @manatwork do you happen to have that userscript lying around anywhere...? the dl link is borked :/ – cat Dec 23 '15 at 19:20
• Sorry @cat, I used to mention that one in the comments, as I consider it the official one, but I use a simple one written for my own need. – manatwork Dec 23 '15 at 19:34
• You can remove 2 bytes (and obfuscate) by using ("").char in place of string.char. – cyclaminist Dec 23 '18 at 12:52

# I is for International Phonetic Esoteric Language (IPEL), 19 bytes + 4 characters = 23 score

{97}{q}0ɑbesχue1søɒ


Score can be is 24 if since IPEL is acceptable.

## Explanation

{97}{q}0ɑbesχue1søɒ
{97}                (push ord of "a")
{q}0            (push loop bounds: 0 to 26. Q == 26 in base36)
ɑ           (start loop)
besχu      (print chr[65+index])
e1sø  (increment index)
ɒ (end loop)


# I is for International Phonetic Esoteric Language (IPEL), 20 bytes + 40 4 characters = 60 24 score

{97}{26}0ɑbesχue1søɒ

• "IPEL" is acceptable in my opinion. I'm only disappointed that the numeric literals keep the entire script from having a standard pronunciation. – Joey Adams Jun 22 '20 at 14:44
• hmm maybe i should allow letters in multi-digits and make it base 36 if it has a letter – bigyihsuan Jun 22 '20 at 14:51

## P is for PostScript, 29 chars → Score: 39

(abcdefghijklmnopqrstuvwxyz)=


## B, 45 -> Score: 46

main(){auto i;i=95;while(i++<122)putchar(i);}


## E, 28 characters → Score: 29

for x in 0..25{print('a'+x)}


# N is for newLISP, 35 characters -> Score: 42

(print"abcdefghijklmnopqrstuvwxyz")


## L#, 28 characters → Score: 30

"abcdefghijklmnopqrstuvwxyz"


# Z is for zsh, 31 characters -> Score: 38

echo abcdefghijklmnopqrstuvwxyz


# F is for False, 17 characters -> Score: 22

97[$123\>][$,1+]#


## U is for Unicon, 50 + 6 = 56

procedure main();every writes(char(97 to 122));end


## c,34 characaters -> score : 35

main(a){for(;a++<27;putch(95+a));}

• putch isn't in standard C, and isn't present on my system. Thus, I'm not going to add this to the rankings, at least not under C. Arguably, you could change the language name to "VC" (for (Microsoft) Visual C) and put it under V ;-) – Joey Adams Apr 20 '11 at 16:35
• @Joey: Shouldn't any C example be classified under the compiler name, then? – Joey Apr 24 '11 at 21:11
• @Joey, @avinashse: I went ahead and reluctantly added this to the scoreboard. – Joey Adams Apr 25 '11 at 18:10
• talking about vc++... if you set the entry point to f and the subsystem to console, you get a breathtaking 1 + 30 = 31 f(a){26-a&&f(putch(a+97)-96);} :) – bebe Jul 14 '14 at 20:13

# V is for VBA - 43 (40+3) or 32 (29+3)

(formatted to run in the immediate window)

40 chars

For b=65 To 90:c=c & Chr(b):Next:Print c


And shorter, but no thinking involved:

29 chars

?"abcdefghijklmnopqrstuvwxyz"

• You can crunch the loop method to 27+3 by using ? for print and ; to make it not insert a newline. for i=65to 90:?chr(i);:next – JesterBLUE Jul 15 '14 at 12:57

## A is for awk: 37 characters -> score 40

BEGIN{for(i=96;i++<122;)printf"%c",i}


C++, 32 + 3penalty = 35

I could not find C++. So this is my option for it:

char a=96;while(a++<122)cout<<a;


the output is:

abcdefghijklmnopqrstuvwxyz


PS. It's my first golf, pls comment if i did something wrong

Forth, 29 + 5 Score: 34

: a 123 97 do i emit loop ; a


Previous (Forth, 48 + 5 Score: 53 (unclean score = 48))

: a 97 begin dup emit 1 + dup 123 = until drop ;


This is the clean version.

: a 97 begin dup emit 1 + dup 123 = until ;


The second one leaves stuff on the stack.

a
abcdefghijklmnopqrstuvwxyz  ok

• Or even : b ." abcdefghijklmnopqrstuvwxyz" ; at 36 characters – leancz Dec 16 '13 at 12:17
• If uppercase output were permitted then you could drop a character with 91 65 do ... I have to say you should probably include the word a (+2 chars) at the end of your line for these to be "programs", otherwise nothing is actually executed or printed. :( I do like golfing in Forth but it often carries that penalty! – Darren Stone Dec 17 '13 at 9:46
• @DarrenStone OK, I've changed it - I do wonder about that though as I see, for example C source code in code golf that would also not print anything without being compiled and executed at a command line. I'm just starting out at code golf and trying to remember Forth from my youth. It is fun. – leancz Dec 17 '13 at 10:12
• Yeah, it sucks that control structures (IF, LOOP, etc.) can't be used in interpreted mode, only in a word definition. Shaving down your string constant idea, the following would be a program and requires no word definition/execution penalty. ." abcdefghijklmnopqrstuvwxyz" Unfortunately, it's 30 chars! Happy Forthing! – Darren Stone Dec 17 '13 at 10:21

# A is for APL, 9 characters → Score: 12

17↓43↑⎕av


Take the first 43 characters from ⎕av, then drop the first 17 of those.

(Tested in Dyalog APL)

• Are you sure this works in a version of Dyalog that predates the question? – lirtosiast Feb 3 '16 at 20:53
• I checked via archive.org what the current version was in February, 2011, which was 12.1. Checking the manual for that shows that ⎕av was a feature, so it should work. – Koneke Feb 3 '16 at 21:30
• Sounds good; I'd appreciate if you test it though. – lirtosiast Feb 3 '16 at 21:38
• Couldn't get hold of a 12.1 myself, but I asked the developers of Dyalog, and they tried it and confirmed that it worked the same all the way back to 10.0, which should be well before the question was posted :) twitter.com/dyalogapl/status/695184773266960384 – Koneke Feb 4 '16 at 12:20

# G is for GP, 30 characters -> score 32

Strchr(vectorsmall(26,i,96+i))


If I stole the 36-character C code I could submit it as a score-40 submission for PARI -- though maybe at that point I'd be required to #include <pari/pari.h> at the painful cost of an additional 23 characters.

I'm too embarrassed to submit

"abcdefghijklmnopqrstuvwxyz"


which would be printed in gp.

# A is for APL, 2 → 5

⎕a


Works on MicroAPL's APLX.

# L is for Lua, 49 bytes → Score: 52

Previous answer for Lua had each letter printed on a new line. All on one line:

s=""for i=97,122 do s=s..("").char(i)end print(s)


Try it online!

## m4, 26 characters -> Score: 28

abcdefghijklmnopqrstuvwxyz


(Hey, shinh lists it as a supported language)

# Xtal, 31 characters -> Score: 35

"abcdefghijklmnopqrstuvwxyz".p;

• Awesome, thanks for filling in X with something interesting! I guess you mean Gnu Xtal System (found with a Google search), but I'm not sure. Could you add a link? – Joey Adams Apr 18 '11 at 23:37
• It's actually Xtal as used in golf.shinh.org: code.google.com/p/xtal-language , you can see some post-mortems at golf.shinh.org/l.rb?xtal – ninjalj Apr 18 '11 at 23:48

## V is for Vim, 9+3 → Score: 12

:h<_<CR>LY<C-^>P


The screen must be exactly 66 characters wide, and 8 lines high. You can check this with tput cols and tput lines.

The program should be executed with:

echo>file.txt && /bin/vim -u NONE \$'+normal :h<_\xALYZQP' '+wq' file.txt && cat file.txt


As discussed in this vim scoring meta post

• Since a trailing newline is optional, you might as well drop the V to save a byte, and replace the p by P – oktupol Jan 25 '18 at 9:48

## G is for Groovy, 25 -> Score: 31

('a'..'z').each{print it}


# B is for Brainfuck, 42 Bytes + 9 = Score 51

+++++++++[>+++++++++++>+++<<-]>-->-[-<.+>]


## Ungolfed and commented

+++++++++[>+++++++++++>+++<<-]  Leaves the tape with the values 99 and 27.
>--                             Subtracts 2 from 99 to make 97, the ASCII Code for an "a".
>-                              Subtracts 1 from 27 to make 26, the number of letters in the alphabet.
[-<.+>]                         Outputs the letter, adds 1 and decrements from the number of letters remaining.
When no letters are remaining, the loop Exits.


# brainfuck, 60 -> 69

+++++[>+++++<-]>+>++++++++[>+++[>++++<-]<-]>>+<<<[>>>.+<<<-]


Try it online!

-2 bytes thanks to Dust

• Consider doing the addition at the beginning (the first 3 chars) later in the code. You could golf 2 bytes with +++++[>+++++<-]>+>++++++++[>+++[>++++<-]<-]>>+<<<[>>>.+<<<-]. – Dust Jan 28 '18 at 9:09

# B is for brainfuck, 32 31 + 9 = 40

-1 byte thanks to Jo King

-[>++>+<<-----]>----->+[<.+>--]


Try it online!

-[>++>+<<-----]> is derived from the initialization part for 51 and generates the following layout: 102|51. The next part >----->+ changes this to 97|52 where 52 is double the amount of letters in the alphabet and 97 is the charcode of a. The final loop [<.+>--] prints a letter and increments the charcode and decrements the counter twice.

# X is for x86, 9 bytes + 3 -> score 12

(or "x86 machine code" for 9 + 16 = 25)

b0 61 aa 40 3c 7a 76 fa  c3


This is a function, callable with void alpha(char edi[26]), like the x86-64 System V calling convention but in 32-bit mode. Or 16-bit mode (where 40 decodes as inc ax, otherwise the same).

The question says "program" that "prints", and this is neither of those things. I'm not sure this should count. Making a DOS .com executable out of this would take a few extra bytes, or the .text section of a Linux executable, including print and exit system calls. But there are several other answers (like some C++ ones) that are merely snippets that wouldn't even compile without #include<iostream> and int main(){.

I'm just going to follow modern codegolf defaults for I/O methods (Default for Code Golf: Input/Output methods) which include returning a string in the caller's buffer.

An x86-64 version would cost 1 extra byte for inc al or inc eax, and 3 extra characters in the language name. I could call it x64 but that implies Windows where the standard calling convention doesn't use RDI. But that's irrelevant, this is an asm / machine-code answer which doesn't care about being called from other languages. So anyway, I could say "x64" for a 10 + 3 = 13 version, but I hate that name because it goes with using "x86" to mean specifically 32-bit, instead of the whole ISA.

Ungolfed:

                machine code     NASM/FASM source
1                         alpha:
2 00000000 B061               mov  al, 'a'
3                         .loop:               ; do {
4 00000002 AA                 stosb              ; *edi++ = al
5 00000003 40                 inc  eax           ; more compact than inc al
6 00000004 3C7A               cmp  al, 'z'
7 00000006 76FA               jbe  .loop       ; }while(al<='z')
8 00000008 C3                 ret


Try it online! with a FASM _start caller.

Justification: "x86 machine code" is as much a description as a name. Machine code is something you can program in and can be considered a family of languages. But those languages don't usually have names other than the ISA. I'd usually say "x86 32-bit machine code" when posting an answer like this, but that's just to make it clear the answer is the machine code, not the asm source text in the same listing.

Out of all ISAs, x86 is clearly recognizable as the name of this one. It's not a language that people regularly program in directly; usually we generate it from assembly language (or higher level languages).

"IA" (Intel Architecture) or "IA-32" are other common names for the ISA, so I could argue for a score of 11 in the letter "I". (But the only "x" answer is xtal at 35, so posting this as x86 is a more useful answer for reducing the total sum length across all letters.

Of course "x86" can be considered ambiguous between the machine code and assembly language. And without context it's not obviously a programming language because it's better known as the name of an ISA.

• I like this answer, it's a great intro to x86 assembly. I can't believe how few bytes each instruction takes. – Joey Adams Oct 7 '19 at 16:39
• @JoeyAdams: There are special-case short forms for the accumulator (EAX / AX / AL), and instructions with implicit operands like stosb. In "normal" 32-bit code most instructions are 2 to 4 bytes long, or longer with larger addressing modes or SIMD opcodes... And 64-bit code needs a REX prefix on many instructions, making the avg instruction length more like 4 in compiler output. See Tips for golfing in x86/x64 machine code I just updated the source version with comments for the benefit of people who don't know x86 asm, since you mentioned it :P – Peter Cordes Oct 7 '19 at 16:44
• But yes, ISAs with variable-length instructions optimize for the most common cases. Original 8086's main bottleneck was code-fetch from memory so they put some care into that design. It's evolved over time into an ugly Frankenstein's monster though, with much lack of long-term thinking about ISA extensions. :( See Agner Fog's 2009 blog post, Stop the instruction set war – Peter Cordes Oct 7 '19 at 16:50

## PHP, 26 characters -> Score: 29

abcdefghijklmnopqrstuvwxyz