# 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.

• 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? – user8397947 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

## 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.

## PHP, 26 characters -> Score: 29

abcdefghijklmnopqrstuvwxyz

Ạẉ

Try it online!

# C is for Cubix, 15 bytes, Score -> 20

uo)U"z"-?@./;/

Try it online!

Cubified

u o
) U
" z  " - ? @ .
/ ; / . . . . .
. .
. .

Watch it run