Are there any languages especially good at ASCII art?

20

4

I was wondering if there are any esoteric or golfing languages which specifically target text output and ASCII art?

For example, 05AB1E at least started by targeting base conversions. Are there any golfing languages targeting text output and text output art?

If so, do they have tip pages here, and are they in common use?

Note: I'm not looking for languages that are able to output ASCII art, but rather ones intentionally designed to be able to complete challenges in a relatively short and concise way.

Socratic Phoenix

Posted 2016-09-20T21:42:18.590

Reputation: 1 629

1Since you mentioned it, in my experience 05AB1E is very good at ascii art challenges. – James – 2016-09-20T22:38:28.330

1I'd like to see a ASCII-art language called "ASC and II shall receive." (Seriously though, if one doesn't already exit, there's quite a bit of potential there.) – Hactar – 2016-09-20T22:42:01.803

I've designed a language called Crayon which is made specifically for creating ASCII art, but unfortunately I haven't had the time to implement it yet.

– ETHproductions – 2016-09-20T23:50:50.527

@ASCII-only and I have been working on an ASCII-art language. It's still in the design phase, but we'd love your (or anyone's) input. Join us in chat if you're interested.

– DLosc – 2016-09-21T02:38:09.003

Well here I was thinking my idea was unique... I asked this question because I wanted to write a CharMatrix based language. No one's mentioned one of the features I wanted though, so I might go ahead and do it anyway. All the answers and comments have been great by the way, thanks everybody – Socratic Phoenix – 2016-09-21T10:35:33.383

@SocraticPhoenix what features do you want? – ASCII-only – 2016-10-13T23:34:54.663

@MarsUltor I was specifically thinking about reflections, with reflectable characters swapping (\ -> /) ({ -> }) – Socratic Phoenix – 2016-10-14T02:19:57.350

@SocraticPhoenix Yeah, we (DLosc and I) will have that in the language we're creating, we just haven't decided on the command character yet – ASCII-only – 2016-10-14T05:49:34.247

@SocraticPhoenix I've done all the boxchars, but I'm too lazy to do the brackets, you could help group them into horizontal reflection pairs (as a JSON dictionary e.g. "[": "]", "]": "["), also vertical reflection and 180 degree turn (you may need to put some of them in multiple of the dictionaries

– ASCII-only – 2016-10-14T12:11:39.957

@ASCII-only potentially.... I'm quite busy at the moment, with school, etc. If I get a chance I'll try and do some, but I probably won't be able too – Socratic Phoenix – 2016-10-14T13:57:09.610

@Dennis https://esolangs.org/wiki/Bubblegum I want to see a short post explaining Bubblegum ;).

– Magic Octopus Urn – 2017-02-10T18:41:09.020

You should check out Charcoal also, if I had the knowledge I'd write up an answer about it

– nmjcman101 – 2017-07-13T23:54:39.143

Answers

15

Well, as a matter of fact, there is! One such language is one I have been working on for a while called V.

Under the hood, V is just vim, but all of the keystrokes are run automatically, and the contents of the vim buffer are printed to STDOUT when the program is over. This just makes running it more convenient.

Some history on the language. When I started using the vim text editor for code-golf, I discovered that it's actually pretty good at it, but has some annoying features that make it more difficult to compete it. For example, you can set up a "while loop" of sorts by doing

qq<foobar>@qq@q

which will repeat <foobar> until an error happens. This has 7 bytes of boilerplate code. In V, this is shortened to ò<foobar>ò.

Some of the things that make V great for ASCII-art:

  • It is 2d by nature. One feature is that is has a "cursor" position, where most of the commands do something based on where the cursor is in the text. The other commands move the location of the cursor. For example, x deletes a single character, but Wx moves forward a word and then deletes a character. Since most other languages are not intentionally 2 dimensional, this offers a nice edge when the challenge is about positioning text in 2D space

  • It is entirely string based. You can use some mathy operations, but these are usually the longer way to achieve things.

  • It uses regex compression to quickly change text.

  • All of it's internal memory, which is just a 2d array of characters, is implicitly printed when the program ends. Additionally, all inputs is implicitly added into it's internal memory, which is nice when most of the challenge is about changing the input in a certain way.

So I really enjoy using this language, and if you are looking for a specifically language, I highly recommend it. However, I would also give a few disclaimers.

  • It is very confusing to learn. It's also very powerful, but because it's based on a very popular text editor that is 30 years old, there are lot's of obscure features that could very easily confuse new users.

  • Even though it is better at handling numbers than vim, it's number support is still not great. Personally, I think this makes it more fun to work in (kind of like using retina for tasks regex was never intended for). :D

  • It is still a WIP. There are some bugs, and some things I haven't gotten around to adding yet.

  • It doesn't have very many users. (Current number of users: 1).

If you are interested in learning more, here are some good resources:

  • A chat room where I would be happy to answer any questions you have, and help explain how it works to you.

  • A tips thread for golfing in vim, but most of the tips carry over.

  • A meta post describing V in some more detail.

James

Posted 2016-09-20T21:42:18.590

Reputation: 54 537

8

I recently made a new programming language, called Turtlèd, which operates on a grid of characters with a turtle, which moves around the grid, writes to the grid, and has control flow with the grid. The grid is implicitly printed at the end. By this fact that it does not have to write spaces, and that it can write the text spatially, rather than left to right, up to down, it probably makes it meet the definition given, being good at ascii art.

Currently, there are not any docs, so you probably will not be able to use it, unless you want to read my interpreter, which is probably not something you want to do. I think there may also be bugs in the interpreter, but the spec is not developed enough to say if it is a bug. Turtlèd will probably be finished soon, with docs and all, though

Destructible Lemon

Posted 2016-09-20T21:42:18.590

Reputation: 5 908

3

Intro to ASCII-Golfing for 05AB1E (Base Conversion [Simple])

While 05AB1E isn't intended for ASCII-Art directly, I've won 2 challenges with it. The best thing about 05AB1E is that, even with the simple base conversion there's often tricks you can use to extend and even halve your byte-count. Often in ASCII challenges there are repitition tricks you can utilize to only draw half the pattern then flip and concatenate. If it's a four way pattern you can do things like zip and bifurcate to only draw a corner of the pattern. There's plenty of data-structure manipulation techniques to use in conjunction with this simple base compression idea.


Here's a quick crash-course on a base conversion tactic:

In 05AB1E I enumerate all of the characters used in the ASCII-art, for instance:

--===___===--

Would result in:

-
=
_

I then assign them numbers starting with 1 then 0 then 2:

- is 1.
= is 0.
_ is 2.

I replace the characters in the original string with the numbers:

1122200022211

I convert to decimal using the lowest possible base (3):

879412

(How to do this using 05AB1E)

I then convert it to base 214:

Jh]

(How to do this using 05AB1E)

I then wrap it in the following code:

05AB1E, 16 bytes

•Jh]•3B…102…-_=‡

Try it online!

Or try it with intermediate steps displayed.

Final explained:

•Jh]•            # Push the compressed ASCII integer.
     3B          # Convert it to base 3.
       …102      # Push the keys to the conversion.
           …-_=  # Push the values to the conversion.
               ‡ # Transliterate, replace 0, 1 and 2 with the symbols.

Now, with this specific challenge the string is so short it doesn't make sense to do. I'd probably just push half the string and Palindromize for 10 bytes "--===__"û or golf it like Adnan did in the comments using factorial, smart man •Jh]•3B5!…-=_‡. He's also (one of?) the creator (s?) of 05AB1E.


More complex example:

https://codegolf.stackexchange.com/a/106621/59376


Also, maybe try Dennis' kolmogorov-complexity language: Bubblegum; no idea how to use this.

Magic Octopus Urn

Posted 2016-09-20T21:42:18.590

Reputation: 19 422

2

Bubblegum isn't really a good lang for ASCII-art, since it cannot possibly take input (except for the two examples), which is required for most ASCII-art challenges. Cinnamon Gum might be a better option, though I don't know much about it and to my knowledge there aren't docs

– ETHproductions – 2017-02-10T18:43:41.750

1Not really important, but you can golf this down to: •Jh]•3B5!…-=_‡ – Adnan – 2017-02-10T19:50:29.680

1@Adnan "--===__"û for 10 ;). – Magic Octopus Urn – 2017-02-10T19:57:05.243

2

Paintbrush

Paintbrush is a recreational programming language created by myself, Hyper Neutrino, for the purposes of being good at ASCII-Art. It doesn't compete well with Charcoal in many cases, but it can take input and do a variety of other things. It operates on a 2D grid of characters and is able to manipulate the background character, manipulate what is considered a background character at the time, shift rows and columns, move rows and columns, copy rows, columns, or the entire grid, etc.

Some examples may be found in the GitHub repository.

HyperNeutrino

Posted 2016-09-20T21:42:18.590

Reputation: 26 575