4 ms·
Here is a direction if you are all ears : instead of a new language, add a new layer. I tried creating my own languages before, some 15 years ago. While I had
by hzhou321 8y ago
Here is a direction if you are all ears : instead of a new language, add a new layer.
I tried creating my own languages before, some 15 years ago. While I had fun writing compilers, I missed a lot more writing actual programs. One day I suddenly realized I don't really need new language, what I needed is simply context dependent syntax and code block organization, which can easily implemented on the spot. It become MyDef and I have been programing with it entirely for more than 10 years now and wondering how others don't go down the same path.
Actually in a broad sense, Knuth's literate programing adventure is very similar to mine. He also wondered how others were not as excited as he was.
So rather than a new language, try a new dimension.
- dajomu 8y agoThis sounds really interesting, can you provide a link so I can read some more about it?
- akuji1993 8y agoThis seems to be the Github repository for it: https://github.com/hzhou/MyDef https://github.com/hzhou/MyDef
- humanrebar 8y agoHow is MyDef not another language?
- hzhou321 8y agoBecause when using MyDef, you are still thinking in the end language -- how the function, variable, type, stack works are all defined by the end language. With MyDef, you are just changing the way of expressing them -- just like giving creatures different clothes, but they are not new creatures. Here is a short example: page: test, basic_frame module: c $local int A[3] $for i=0:3 A[i] = i $dump A[0], A[1], A[2] Despite the look, if you know c, you recognize it as c. And as you get familiar, you see it exactly as C. `basic_frame` is merely a custom template so one doesn't have to always write the main function signature. $for is shorthand for `for-loop`, `$dump` is simply printf with simple type translations. Now that you had this meta layer, there is no limit on how you want to dress up your code. Examples: $local A[3]: int $sumcode(3) A[i]=i+3 $foreach A $dump $(t) or page: test, basic_frame $call declare $call init $call report subcode: declare $local pn_A[3] = {1, 2, 3} subcode: init $foreach pn_A $(t) = $(t)^2 subcode: report $(set:print_to=stderr) $foreach pn_A $print "%d: %d", $(i), $(t) There are lots of idioms and conventions, but it is not a problem as long as you recognize them only as clothing. Lastly, when dressing up the code makes little sense or you simply don't know better way of dressing them, you can simply write vanila C (or any languages that you are writing). MyDef never tried to compile your language.
- co_dh 8y agoThe problem is, your coworker need to modify the generated code.
- hzhou321 8y agoJust share with coworkers the C (or whichever) code that MyDef translated. MyDef is not a language, it only dresses the code. So if coworkers don't like to work with the dresses, simply remove the dress.