• Apathy Tree@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 months ago

    This makes me really curious in a way I’m not really sure how to search for (and I certainly don’t expect you to have an answer, but maybe someone does)…

    How does one actually go about developing a new coding language? I assume it’s something that you need to…… translate to assembly in some way (I’m not advanced techie, but my understanding is that at core everything is assembly, and code languages are on top of that)? And what’s the purpose of developing more languages anyway?

    • ayyy@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      2 months ago

      Edit: TL;DR look up “toy languages” to see people experimenting and trying shit.

      This is an entire branch of computer science that people dedicate their lives to, called language design. You’re correct that we use software to translate a programming language into assembly language. That software is called a compiler.

      As far as developing new languages, typically one starts by defining a “formal grammar”, typically in the .lex format. Since writing a whole compiler can be complicated and time consuming, most people just build off of the work of others and adapt an existing compiler such as “LLVM” to understand the grammar of their new language.

      It sounds crazy to the uninitiated, but the best way to start learning about how to make computer languages is to learn about what a Turing tape machine is, and what it’s capable of. Then you will be able to understand what the difference between a “context-free” grammar and a “stateful” grammar.

      • Apathy Tree@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 months ago

        Excellent thanks, I’ll look into that, and thank you for the information :)

        You say “we” which hints that you have (some?) experience in the field, do you have any insight as to why one would want to create a new language rather than just helping to refine an existing one or something? Do they end up too bloated or do they function inherently differently or some other thing I haven’t thought of…?

    • Otter@lemmy.ca
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      2 months ago

      While I don’t have a direct answer, I know that my university had some courses dedicated to this topic. I think these are some of them:

      https://www.students.cs.ubc.ca/~cs-311/2025W1/nav/goals.html

      https://www.cs.ubc.ca/course-section/cpsc-411-201-2020w

      https://www.cs.ubc.ca/~rxg/cpsc509-spring-2024/

      The second one is described as

      The goal of this course is to give students experience designing, implementing, and extending programming languages. Students will start from a machine language, the x86-64 CPU instruction set with Linux system calls (x64), and incrementally build a compiler for a subset of Racket to this machine language. In the process, students will practice building, extending, and maintaining a complex piece of software, and practice creating, enforcing, and exploiting abstractions formalized in programming languages.

      The course assumes familiarity with basic functional programming in Racket, and some simple imperative programming in assembly.

      Those links might give you something to search off of?

      And what’s the purpose of developing more languages anyway?

      At some level, I think it’s this:

      https://xkcd.com/927/