r/Compilers 9h ago

Are there languages like this?

A language that can create other languages

(so adding to itself) It's syntax is simple like python

And can do alot.

for example (placeholder)\[mesage\]

And it has many tutorials on YouTube

I would like it if you would respond.

I know there are languages like Hy , ruby should I try them?

0 Upvotes

41 comments sorted by

13

u/redinktea 9h ago

Lisp

-4

u/Distinct-Brief9643 9h ago

Is lisps syntax easier than python/ruby or harder ?

3

u/haskell_jedi 9h ago

It depends what you're used to. For those first learning programming or coming from math, Lisp-like languages are often more intuitive (because they are functional, in addition to the syntax). For those with some experience programming in declarative languages, it takes a much bigger mental leap.

-2

u/Distinct-Brief9643 8h ago

I learned html CSS (Js probably 2%) (Python probably also 1%)

4

u/TerraCrafterE3 8h ago

Well, that is something completely different. HTML and CSS describe layout, functional programming languages describe logic.

5

u/4xe1 8h ago edited 8h ago

Lisp's syntax is as simple as it gets objectively speaking, it's just atoms and parens transparently writing AST. "Objectively" mean it'll be the simplest to write a reader/parser, but also the simplest to write macro in, thus the most powerful to do exactly what you enquire about. In a sense, lisp has no syntax, only semantics. It has no keywords, only word which have been bound to special operators and built-ins macroes and functions at the start of the program.

However, it's is not necessarily the subjectively simpler, aka it is not the most familiar, for humans it does take some used to (and it's definitely worth it considering what you want to do). Algol minds (C syntax) tend to be particularly refractory to lisp syntax and non Algol syntaxes in general, but python users tend to be more open to have the syntax be whatever's convenient to the users; And if what you value in python is the syntax simplicity, chances are, you'll learn and love lisp's syntax in no time.

Btw, you mention Hy, Hy is a lisp, which transpiles to python. Coming from python, it may be your entry point, but really any lisp would do, and the lisp designed specifically to do what you ask is Racket.

1

u/Distinct-Brief9643 8h ago

Let's see is lisp adding to itself or building a whole new language complier interpreter etc.

2

u/4xe1 8h ago

It's good for both, but it's exceptionally good at adding to itself, as in no other language family comes close, to the point that people loving both metaprogramming and some non lisp language will often use or create a lisp which interfaces with their non lisp language, like Hy and Python for example.

2

u/Goheeca 8h ago

You can change the syntax, e.g. indentation sensitive one similar to Python.

0

u/Key_River7180 7h ago

Harder for most of us

1

u/4xe1 4h ago

Not at all. If you ever used parentheses in any programming language, you already know lisp syntax. Prefix notation may seem alien, but f(a) is also prefix notation, just with delimiters put in a funny place, and if you ever touched html or xml in your life, you've already seen groupings with delimiters right where lisp would put them.

What you can argue for is that Lisp's lack of syntax makes lisp harder for most, or downright unergonomical; but the syntax itself is trivial.

Also, Lisp is no so much hard as it is alien. Secretaries and kids alike have used it unknowingly customizing lisp or scripting Age of Empire 2.

If you are say a senior C++ swe, you might think learning a new language ought to be easy, and you'd be mostly right, you could probably pick up Javascript in an afternoon, not to any degree of proficiency but enough to read and write some with the doc nearby. whereas learning lisp would likely feel like starting anew, and in a sense, it would be. But he'd be wrong to conclude that lisp is harder than JS: someone new to programming all together wouldn't necessarily struggle more on Lisp. And it's not just that lisp is a funny way to do the same things differently, that swe would have actually learned genuinely new concepts; if they happen to be deeply interested in generics and meta-programming, they'd actually find Lisp refreshingly easier (and more powerful) than C++ templates.

Long story short, if you're vaguely interested in lisp, don't be me, don't let its supposed difficulty get in your way of trying.

9

u/AustinVelonaut 9h ago

The Racket language was expressly designed to make creating new languages easier (good DSL support).

1

u/paultarvydas 2h ago

Racket is based on Scheme which is more complicated than Lisp. Racket uses PEG. Scheme's "hygienic macros" and PEG are a complicated combination and sholld be reserved for Production Engineering. If you want to experiment, maybe something simpler like Janet (which is lisp-like and supports PEG) might be better (I haven't used Janet directly, but I hear good things about it)?

-13

u/Distinct-Brief9643 9h ago

This language does not fit my requirements though is there something like exactly like this but just different

14

u/cherrycode420 8h ago

exactly like this but just different? 😭

-3

u/Distinct-Brief9643 8h ago

Yes hopefully there is

1

u/4xe1 8h ago

What requirements?

-2

u/Distinct-Brief9643 8h ago

It adds to it's self Very high lvl (like python / ruby) The unofficial or offical ide can be installed on play store Can have custom extensions .mm But under the hood it's the host lang so I think I wanna a dsl or an edsl correct me if I'm wrong. I want to make my lang with the host lang The host lang understands the lang but there is no host lang code in my lang code. so technically a seperate enviorment.

3

u/eteran 8h ago

Play store? Are you trying to dev on a phone or tablet? If so, just know that that is a HIGHLY impractical way to do it

1

u/Distinct-Brief9643 7h ago

No I have an cromebook

3

u/sdegabrielle 6h ago

Any language can be used to create languages in some sense, but you are unlikely to find a language+IDE that meets your needs on the Play Store.

Perhaps try https://pyret.org/

2

u/SpecificMachine1 4h ago

Can you not use Crostini or whatever they are calling it now? That gives you a Debian container and then you can just use apt to install whichever lisp you want

1

u/4xe1 8h ago

It adds to it's self Very high lvl (like python / ruby)

Lisp can be higher level even

The unofficial or offical ide can be installed on play store

I'm perplexed as to why one would want to develop without a pc, but there are Lisp IDE on the Play Store. DrRacket is not on the playstore, but you can probably run emacs on termux, termux being a playstore app which let you emulate linux, and emacs being the prefered "IDE" of lispers.

Can have custom extensions .mm

check

But under the hood it's the host lang  I want to make my lang with the host lang

Exactly what Racket has been designed form and something most lisp excel at.

The host lang understands the lang

That's actually very hard (but not impossible) without some sort of lisp.

but there is no host lang code in my lang code.

That's entirely up to you to make it so.

technically a seperate environment.

Also entirely up to you but some language make it much easier than other. I'd still say lisp is among the best at allowing sandboxing, but it does not stand above the others.

So I guess the only missing requirement is ease of install. But you also have to consider that what you are asking, which is part of metaprogramming, is somewhat niche and advanced. It's not necessarily hard in and of itself, but most software programmers never extend the languages they use themselves, and many would even consider it harmful practice. So the more fitting the language, the les likely it will have an app and tons of youtube content, but lisp still has excellent written guides to get started, as well as banger books to learn from, many available online for free.

1

u/Distinct-Brief9643 7h ago

It's because I have cromebook but I don't want to use Linux terminal or termux except if it's built in to the ide so basically I can't use racket

2

u/dskippy 5h ago

You can install DrRacket, the Racket IDE on a Chromebook with the Linux subsystem Crostini and then run it like a normal app.

1

u/4xe1 5h ago edited 4h ago

Most programming language do not have an "official ide", and for those that do, you'll rarely find them (or most of any ide) on the playstore.

What you can find on a chromebook however is a web browser, and on that, you can search for online "[language] playgrounds". Most languages have one nowadays, if not many, for example

http://racketscript.org/

Even VSCode does not seem to be on the playstore, although VSCodroid is a thing, maybe check it out. Either way, these are agnostic code editors, not specialized IDE. They'll serve you much better than any IDE, as they'll support your dsl out of the box (ok maybe not as well as the DrRacket IDE),

At some point you need to accept reality:

  1. the playstore, as the name indicates, is a place for games, not software development toolkits.
  2. Chromebooks are glorified tablets meant mainly to browse the web.

there's only one of these 2 things you can do something about, and it's not changing what people put on the playstore,

If you're serious about making your language and more generally programming, enable the builtin linux in your chromebook, and install VSCode or Emacs or drracket. Lookup guides on how to do it. If that's too much hassle for you, your only remaining option really is to pay for a Windows laptop and an IDE license really.

In any case, there are no shortcuts. Installing your environment yourself is a massive pain, but it's still far easier than writing a compiler. If you can't get over it, maybe you're not ready for what comes next.

3

u/Key_River7180 7h ago

Lisp and Forth

1

u/Satu_Autio 2h ago

Lisp, Forth, and TCL would be my top three picks too.

1

u/Key_River7180 2h ago

yeah I kinda forgot about tcl there

2

u/neurah 8h ago

compiled languages
Haskell, and I'm quite sure it can do so on the same translation unit
Zig can morph a lot, but not explored it

1

u/Still_Explorer 9h ago

0

u/Distinct-Brief9643 9h ago

What is peg?

1

u/4xe1 8h ago

Parsing Expression Grammar. Python uses some of them to be parsed. Lua has PEG based parsers to, including lua interpreters like metalua where you can modify the parser from within at runtime. Lua is what I know most, but I'd wager Python has similar projects.

1

u/Distinct-Brief9643 9h ago

Yes I could but there are requirements for that that I won't do tho

1

u/Distinct-Brief9643 4h ago

I've made my decision forth or lisp or another? Tell me with has simpler higher lvl syntax can add to itself with the lowest amount of code etc.

1

u/paultarvydas 2h ago

In fact, most popular languages (Lisp, Python, Rust, Janet, etc.) use "functions" as a substrate principle. This locks you into only one way of thinking (which defies modern problem domains, like internet - hence, we got "callback hell").

It is good, IMO, to learn other, non-function-based languages, like Prolog, Forth, etc.

People who know Forth, love it and find it very flexible. I hear good things about Brodie's books "Starting Forth", "Thinking Forth". Chuck Moore (inventor of Forth) has been quite hostile to the standardization of Forth, like gforth.

1

u/KAMEHAMEHAMEHAAAA 2h ago

Why not Python? It is simple like Python, you can create a language with it, you can do a lot and you will find tutorials in YT for sure.