Good language for metaprogramming?

  • 8 Replies
  • 429 Views
*

Zero

  • Trusty Member
  • ********
  • Replicant
  • *
  • 732
    • Thinkbots are free
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 ;) )
Thinkbots are free, as in 'free will'.

*

ivan.moony

  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1109
    • Some of my projects
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.
Dream big. The bigger the dream is, the more beautiful place the world becomes.

*

Zero

  • Trusty Member
  • ********
  • Replicant
  • *
  • 732
    • Thinkbots are free
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...
Thinkbots are free, as in 'free will'.

*

Ultron

  • Trusty Member
  • *******
  • Starship Trooper
  • *
  • 472
  • 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

  • Trusty Member
  • ********
  • Replicant
  • *
  • 732
    • Thinkbots are free
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. :)
Thinkbots are free, as in 'free will'.

*

ranch vermin

  • Not much time left.
  • Terminator
  • *********
  • 958
  • 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

  • Trusty Member
  • ********
  • Replicant
  • *
  • 732
    • Thinkbots are free
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:
Thinkbots are free, as in 'free will'.

*

korrelan

  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1087
  • 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!

*

Zero

  • Trusty Member
  • ********
  • Replicant
  • *
  • 732
    • Thinkbots are free
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!
Thinkbots are free, as in 'free will'.

 


Users Online

64 Guests, 0 Users

Most Online Today: 116. Most Online Ever: 208 (August 27, 2008, 09:36:30 am)

Articles