Good language for metaprogramming?

  • 8 Replies
  • 1716 Views
*

Zero

  • Eve
  • ***********
  • 1287
Good language for metaprogramming?
« on: September 18, 2018, 10:13:52 am »
What programming language has good metaprogramming capabilities in your opinion?
(Preferably not s-exp based ;) )

*

ivan.moony

  • Trusty Member
  • ************
  • Bishop
  • *
  • 1723
    • mind-child
Re: Good language for metaprogramming?
« Reply #1 on: September 18, 2018, 11:56:06 am »
Javascript has that `eval` function that compiles a sring into code at runtime. And I thik assembler is a king of metaprogramming.

*

Zero

  • Eve
  • ***********
  • 1287
Re: Good language for metaprogramming?
« Reply #2 on: September 18, 2018, 02:24:58 pm »
Yes, you can also retrieve the source code of a function, by calling its toString() method.
There's also Reflect and proxies... Javascript is not bad at all :)

Assembler? That's an unexpected answer! but I can see what you mean...

*

Ultron

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 471
  • There are no strings on me.
Re: Good language for metaprogramming?
« Reply #3 on: September 20, 2018, 12:21:48 pm »
I mentioned this previously however I concluded there is no interest on the topic. Check out my reply at

http://aidreams.co.uk/forum/index.php?topic=13359.msg54760;topicseen#new

I personally work with Javascript in various project with various requirements but would never use it for the discussed application.
Software and Hardware developer, and everything in between.

*

Zero

  • Eve
  • ***********
  • 1287
Re: Good language for metaprogramming?
« Reply #4 on: September 20, 2018, 02:44:48 pm »
... which makes Julia sexy again! Thanks for the link, I'll look into Julia's metaprogramming capabilities. :)

*

ranch vermin

  • Not much time left.
  • Terminator
  • *********
  • 947
  • Its nearly time!
Re: Good language for metaprogramming?
« Reply #5 on: September 21, 2018, 02:05:41 am »
truth table masks.

//A B C  S  C
//0 0 0  0  0
//1 0 0  1  0
//0 1 0  1  0
//1 1 0  0  1
//0 0 1  1  0
//1 0 1  0  1
//0 1 1  0  1
//1 1 1  1  1

the output is just as much data as the input is.
« Last Edit: September 21, 2018, 08:09:04 am by ranch vermin »

*

Zero

  • Eve
  • ***********
  • 1287
Re: Good language for metaprogramming?
« Reply #6 on: September 21, 2018, 08:41:09 am »
Homoiconicity is a funky thing. After all, every language has a source code made of strings, and every language can manipulate strings. However, closures are usually not accessible - as data - from the runtime.

In Javascript, I'd like a function to be able to refer to itself without knowing its own name. Before, there was "callee", but now you're supposed to give it a name and access it using its name, which is less powerful. They say it's because doing otherwise makes a lot of optimizations impossible.

You're maybe wondering the why of all this.

The other day, I was thinking about... some kind of world of functions. Building a system not as a whole, but rather as a landscape. You see Tron, the movie? There are programs running everywhere, living out their lives. I thought, what would it look like, for real?

Imagine a person is a Javascript function. There are two things we need first:
- It has to be currently "somewhere" geographically, and
- It has to move.

The "somewhere" is easy: some object, or some array (which are objects in Js) holds a reference to it. The landscape, so to speak, is an object, which has roots in "window" in the browser, or "global" in node.

It also has to move. So it must be executed, every now and then. There could be a "world scanner", that loops through every object, executing every function.

The closure of the function would represent its "mind". It is a part of a person that other persons cannot see.

It would have been neat to just call functions, and let them be able to access their own source code, to modify it when needed, but you can't in Javascript. So the simplest way to achieve this, is to call these persons-functions with an argument pointing to themselves (meaning these functions would have a "me" parameter). Their "this" would point to where they are, as usual.

That's a starting point.  :idiot2:

*

Korrelan

  • Trusty Member
  • ***********
  • Eve
  • *
  • 1454
  • Look into my eyes! WOAH!
    • YouTube
Re: Good language for metaprogramming?
« Reply #7 on: September 21, 2018, 10:17:48 am »
It seems to me you are describing a type cellular automation (Conway’s Game Of Life).

Homoiconicity is not a native function of modern computers, therefore languages that can leverage Homoiconicity like Lisp where written in standard languages that can’t… if you get my drift.

My point being that even though Java does not have the functionality you require you can still write a language/ interpreter that does.

 :)
It thunk... therefore it is!...    /    Project Page    /    KorrTecx Website

*

Zero

  • Eve
  • ***********
  • 1287
Re: Good language for metaprogramming?
« Reply #8 on: September 21, 2018, 11:00:26 am »
Sure... I get it.

But there are Javascript parsers written in Javascript, and you can get the source code of a function using its toString() method, so it's not direct homoiconicity, but we're still dealing with code as data. Which is pretty cool!

 


OpenAI Speech-to-Speech Reasoning Demo
by ivan.moony (AI News )
Today at 01:31:53 pm
Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am
Nvidia Hype
by 8pla.net (AI News )
December 06, 2023, 10:04:52 pm
How will the OpenAI CEO being Fired affect ChatGPT?
by 8pla.net (AI News )
December 06, 2023, 09:54:25 pm
Independent AI sovereignties
by WriterOfMinds (AI News )
November 08, 2023, 04:51:21 am
LLaMA2 Meta's chatbot released
by 8pla.net (AI News )
October 18, 2023, 11:41:21 pm

Users Online

316 Guests, 0 Users

Most Online Today: 343. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles