The title would probably be confusing, but I could not make it better than this. I noticed that most programming languages are limited to the alphanumerical set along with the special characters present in a general keyboard. I wondered if this posed a barrier for developers on what characters they were limited to program in, or if it was intentional from the start that these keys would be the most optimal characters for a program to be coded in by a human and was later adopted as a standard for every user. Basically, are the modern keyboards built around programming languages or are programming languages built around these keyboards?

  • marcos@lemmy.world
    link
    fedilink
    arrow-up
    22
    arrow-down
    1
    ·
    1 year ago

    It was a noisy co-evolution where both languages and keyboards keep changing to best fit each other.

    While the letter layout of our keyboards is heavily influenced by typewriters, the set of symbols on them changed a lot with times, and for some times there was a lot of diversity on them. Our current design is as much a result of languages like MPL never really popularizing as much as the lack of adoption of those languages is a result of the popular keyboard designs.

    • Vashti@feddit.uk
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      Yeah. 7-bit ASCII goes back to what, the 60s? But computers still used different encodings and so different keyboards for A While.

  • fubo@lemmy.world
    link
    fedilink
    arrow-up
    20
    ·
    edit-2
    1 year ago

    C supports alternate ways of typing some of its punctuation, for programmers whose keyboards didn’t support them all. For example, if you can’t type [ ] you can use ??( ??) instead. (There are other ones that use angle brackets, but I can’t type them here because Lemmy escapes them incorrectly. Irony.)

    https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C


    The usual example of a programming language using especially unusual characters is APL, where all built-in functions are all represented by single characters, mostly drawn from mathematical notations, Greek alphabet, and so on. For example, is the “sort” function.

      • fubo@lemmy.world
        link
        fedilink
        arrow-up
        5
        ·
        1 year ago

        The core of that Life expression works by taking the array of cells and shifting it in the eight different directions, then summing those arrays to get the population counts.

        I tried translating this into Python — but I’ve never written numpy code before, so this is probably less efficient than it could be. But it does work and you can see a glider move through a few generations.

        The array-shifting logic is in the populations function, with np.roll being the equivalent of the APL rotate operation (written as and in the original).

        import numpy as np
        
        def alive(popu, cell):
            return int(popu == 3 or (popu == 4 and cell))
        alive = np.frompyfunc(alive, 2, 1)
        
        def populations(grid):
            return np.array(
                    [ np.roll(r1, shift, 1)
                        for shift in [-1, 0, 1]
                        for r1 in (np.roll(grid, shift, 0) for shift in [-1, 0, 1]) ]
                    ).sum(axis=0)
        
        def nextgen(grid):
            return alive(populations(grid), grid)
        
        grid = np.array([[0, 0, 0, 0, 0, 0],
                         [0, 0, 1, 0, 0, 0],
                         [0, 0, 0, 1, 0, 0],
                         [0, 1, 1, 1, 0, 0],
                         [0, 0, 0, 0, 0, 0],
                         [0, 0, 0, 0, 0, 0]])
        
        for gens in range(5):
            print(grid)
            grid = nextgen(grid)
        print(grid)
        
  • Turun@feddit.de
    link
    fedilink
    arrow-up
    17
    ·
    1 year ago

    Not only do the Languages orient themselves to fit to the keyboard, they pretty much only consider the English keyboard layout.

  • OOFshoot@beehaw.org
    link
    fedilink
    arrow-up
    15
    ·
    1 year ago

    Programming languages are build around the standard keyboard. Keyboards had most of the symbols you’re thinking of from their typewriter days. You can see most of the special characters in these small typewriters from the mid 1900s.

    https://dealdashreviewed.com/wp-content/uploads/2015/02/typerwriter.jpg

    https://3.bp.blogspot.com/-gdj1kOXgkTY/UqYxNGAxBBI/AAAAAAAA8T0/DTeg3C_ydXM/s1600/71-6zsvcleL._SL1500_.jpg

    With things like electric Wheel Writer typewriters, adding extra keys and symbols were less of a complexity issue and you started to see a few more extra symbols.

    https://www.imagine41.com/wp-content/uploads/2016/07/ibm_wheelwriter_2500_002_1.jpg

    Recognize that there never has been a hard standard for layouts and symbols, just the industry copying and converging on systems that became popular.

  • Die4Ever@programming.dev
    link
    fedilink
    arrow-up
    12
    ·
    edit-2
    1 year ago

    I won’t consider any keyboard to be designed for programming unless it has dedicated keys for characters like {}() < >_+| & !*:" without needing to hold shift for them (Lemmy seems to be improperly escaping my less-than sign and ampersand)

  • BradleyUffner@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    arrow-down
    2
    ·
    1 year ago

    Some of the “toy” languages used for code-golf can use some very non standard characters. Saying “all programming languages” is going to be very restrictive.

    • sylowosa@lemm.eeOP
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      Fixed ‘all’. I tried to acknowledge that there may be other languages that may not follow this rule, but I seem to have not noticed this mistake.

      • BradleyUffner@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Ohh very much so. This wasn’t meant as a criticism of OP’s question. I was just trying to make sure they were aware of all the niche programming languages out there, especially the ones that use some rather exotic character sets.