Re: neonumeric - C++ arbitrary precision arithmetic library
On 2021-03-08 09:29:31 +0100, Mirko via Python-list wrote: > Am 07.03.2021 um 21:52 schrieb Avi Gross via Python-list: > > The precedence example used below made a strange assumption that the > > imaginary program would not be told up-front what computer language it was > > being asked to convert from. That is not the scenario being discussed as we > > have described. In any particular language, there usually is a well-known > > precedence order such as "*" coming before "+" unless you use something like > > parentheses to make your intent clear and over-ride it. > > Well, no I did not assume some kind of magical universal translator > ala Star Trek. ;-) > > The OP seems to claim, that he could compile any language by just > providing a JSON schema file which describes the language. Right. Using JSON is probably not the best choice (20 years ago everybody was using XML for everything, now everybody uses JSON for everything), but that's merely a question of readability. The functionality doesn't depend on the (meta-)syntax. > I assumed that those who tried this before did something similar. And > that is what sounds logically impossible (or at least unfeasible) to > me. How can one write a comparatively small descriptive schema that > covers all of a language's subtleties in syntax, grammar, semantics > and behavior? How does one design a programming language which covers all the subtleties in algorithms? I think these are quite similar problems. Except that it has already been proven that a very primitive programming language (the Turing machine) is sufficient to describe all algorithms, and I'm not sure that a similar prove exists for formal languages. Still, I think that the latter can be reduced to the former (I compiler is essentially such a description, so you could just use any programming language). (Such formal languages exist, for example, for formal verification of programs. I don't think any of these is truely universal, but I suspect that the restrictions are more caused by having to be "provable" in the mathematical sense and less with the variety in possible semantics.) Where the OP is wrong, IMHO, is the "comparatively small" aspect. A formal description of C will not fit into a few lines. The C standard is 670 pages, about 150 pages of which are the language proper (the rest is library, concepts, etc.) All that information has to be expressed in that formal language. Depending on the expressiveness of the language such a formal description might be quite a bit shorter (or much longer) than English prose, but it won't be dramatically shorter. And C is a relatively small language ... > I agree that my example wasn't good, since it would be just a matter > of specifying operator precedence. But there are numerous little and > large aspects to cover for any language. In the end, one would have > to write a more or less full blown parser. Yes, but writing a parser is (comparatively) easy. Parser generators have existed for decades. It's the semantics that are difficult. I'm not saying that you are wrong. I am saying that you haven't even looked at the real problems yet. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Description: PGP signature -- https://mail.python.org/mailman/listinfo/python-list
Re: neonumeric - C++ arbitrary precision arithmetic library
Am 07.03.2021 um 21:52 schrieb Avi Gross via Python-list: > The precedence example used below made a strange assumption that the > imaginary program would not be told up-front what computer language it was > being asked to convert from. That is not the scenario being discussed as we > have described. In any particular language, there usually is a well-known > precedence order such as "*" coming before "+" unless you use something like > parentheses to make your intent clear and over-ride it. Well, no I did not assume some kind of magical universal translator ala Star Trek. ;-) The OP seems to claim, that he could compile any language by just providing a JSON schema file which describes the language. I assumed that those who tried this before did something similar. And that is what sounds logically impossible (or at least unfeasible) to me. How can one write a comparatively small descriptive schema that covers all of a language's subtleties in syntax, grammar, semantics and behavior? I agree that my example wasn't good, since it would be just a matter of specifying operator precedence. But there are numerous little and large aspects to cover for any language. In the end, one would have to write a more or less full blown parser. Or at least a schema that is so long, that all advantages of this approach go away. -- https://mail.python.org/mailman/listinfo/python-list
Re: neonumeric - C++ arbitrary precision arithmetic library
Am 07.03.21 um 20:42 schrieb Peter J. Holzer: The second part is converting a parse tree into code. I am quite sure that it is possible to devise a formal language to specify the semantics of any programming language and then to use this to generate the code. However, I strongly suspect that such a language would be comparable in expressiveness and ease of use to other programming languages - or in other worlds it would be just another programming language. As far as I understand the idea, Leigh (aka Mr Flibble) thinks that he can create a "library" of code translators that translate the individual pieces of the parse tree into some intermediate code, and by specifying these codelets within the grammar the semantics of a language can be fully described. My argument against this whole thing is that the library would be enormous. He seems to think that big chunks can be reused for different languages, but I don't believe this. A simple example: int a = -3 unsigned int b = 5; in C: a < b is false. This is insane but follows from the type casting rules in C. in Python or any other language with sane integers, -3 < 5 will always be true. For large enough values you must convert them to big integers. CPython simply uses big integers for everything, but that obviously slows down the whole thing. If you want to compile that to fast machine code, you need to do the computation in fixed integers and check for overflow *after every single step*. And there are myriads of differences. Introducing JavaScript again will bring myriads of differences and so on. The closest thing to such a project I can think of is LLVM. It still requires you to write the actual code generator, but features many intrinsics and libriaries that could be reused and therefore it is easy to add a new language. The approximate value of LLVM is estimated here: https://chriscummins.cc/2019/llvm-cost/ It's over 5000 man years of work. There is no way a single developer, regardless how brilliant he may be, can recreate this in his lifetime. Maybe focussed to a single language or two, but not "universal" in any sense. Christian -- https://mail.python.org/mailman/listinfo/python-list
RE: neonumeric - C++ arbitrary precision arithmetic library
The precedence example used below made a strange assumption that the imaginary program would not be told up-front what computer language it was being asked to convert from. That is not the scenario being discussed as we have described. In any particular language, there usually is a well-known precedence order such as "*" coming before "+" unless you use something like parentheses to make your intent clear and over-ride it. But it makes me think of a related question. Assume you are writing code in a language like Python and the language has been analyzed and all kinds of info stored that describes it and that includes things like precedence rules for operators. Suppose it works fine and YOU want to break it. Could you? If your language supports constructs like creating what looks like new infix operators as an example, or overloading existing ones, could you write expressions this mystical product would interpret differently than the original compiler or interpreter? As an example, what does this simple statement mean: A + B I mean A can be an integer or floating point number or character string but can also be a complex number or a data.frame or just about any arbitrary object. So can B. And in many cases, the operation is not at all Abelian and B+A is something else. In many cases, the logic is to look at the right-hand or left-hand variable and see if it has a method defined to be called such as __ADD__ or __RADD__ or maybe inherited such a method from another class perhaps using some specific method with complicated multiple inheritance scenarios. Or the language may choose to convert either A or B or both to some other format and perform some kind of addition and maybe convert the result to something. Lots of work is in the Python interpreter to deal with this and some of it has to be flexible enough to deal with times when a class or object is changed as the program runs. Might it be possible to create edge cases that break a static set of description files? If not, how much more complex must the imaginary program get to handle these challenges and what might that do to the purported gains in efficiency claimed? I am currently studying a language called Kotlin. They, like some other languages, allow the creation of new infix operators and once I have defined "myplus" I can write code like: A myplus B What if it would also allow me to specify dynamically what the priority of "myplus" is? Clearly it cannot be a reserved keyword in some table loaded in the language in advance. R lets me do something similar like create "%myplus%" as an operator and even weirder things like rebinding "+" to mean something else that no longer has a particular priority that was pre-ordained. So if we had a contest on finding ways to break a sort of general purpose customizable any-language mangler, I wonder if it might be easy to mangle it at first. To get around that, you might have to not handle languages you declare as misbehaving, or make a more complex system that handles all known cases. But even then, can we design a new language for the express purpose of exposing some hidden flaw and make them deal with that? New languages keep popping up, some with no prior intent on breaking anything, but I think a universal translator may not be imminent. -Original Message- From: Python-list On Behalf Of Peter J. Holzer Sent: Sunday, March 7, 2021 2:43 PM To: python-list@python.org Subject: Re: neonumeric - C++ arbitrary precision arithmetic library On 2021-03-06 23:41:10 +0100, Mirko via Python-list wrote: > I even wonder why they have tried. Writing a universal > compiler/interpreter sounds logically impossible to me, Here's a > simple Python expression: > > >>> 3+3*5 > 18 > > And here's the same expression in (GNU) Smalltalk: > > st> 3+3*5 > 30 > > > How would such a universal compiler know which evaluation strategy to > follow, if not by writing a parser end evaluator for every supported > language? That depends on what you mean by "writing". If we stick to your example, you would need to specify in some way that in Python * has higher precedence than +, while in Smalltalk it doesn't. You could write some code in Python or Smalltalk or C or Assembler or even for a Turing machine to do that. Or you can write the grammar in some formal language (e.g. BNF) and let the compiler interpret that (or generate native code from it and run that). The latter is what a "universal compiler" would do and parser generators have been around for a long time (they were nothing new when I studied CS in the 1980's). While there is still progress here (I've come across a few interesting papers over the last year or so), I'd say that part of the problem is solved. The second part is converting a parse tree into code. I am quite sure that it is possible to devise a
Re: neonumeric - C++ arbitrary precision arithmetic library
On 2021-03-06 23:41:10 +0100, Mirko via Python-list wrote: > I even wonder why they have tried. Writing a universal > compiler/interpreter sounds logically impossible to me, Here's a > simple Python expression: > > >>> 3+3*5 > 18 > > And here's the same expression in (GNU) Smalltalk: > > st> 3+3*5 > 30 > > > How would such a universal compiler know which evaluation strategy > to follow, if not by writing a parser end evaluator for every > supported language? That depends on what you mean by "writing". If we stick to your example, you would need to specify in some way that in Python * has higher precedence than +, while in Smalltalk it doesn't. You could write some code in Python or Smalltalk or C or Assembler or even for a Turing machine to do that. Or you can write the grammar in some formal language (e.g. BNF) and let the compiler interpret that (or generate native code from it and run that). The latter is what a "universal compiler" would do and parser generators have been around for a long time (they were nothing new when I studied CS in the 1980's). While there is still progress here (I've come across a few interesting papers over the last year or so), I'd say that part of the problem is solved. The second part is converting a parse tree into code. I am quite sure that it is possible to devise a formal language to specify the semantics of any programming language and then to use this to generate the code. However, I strongly suspect that such a language would be comparable in expressiveness and ease of use to other programming languages - or in other worlds it would be just another programming language. Certainly better suited to compiler construction (otherwise why would you use it?), but probably not massively so (unlike writing a Yacc grammar is a lot easier/quicker than writing a top-down parser), So there wouldn't be a huge incentive to use it unless you plan to write compilers for lots of languages. On the other hand there are downsides: Such a generic system might be slow and/or memory-hungry, it might not run on every platform, it might have a steep learning curve, and it's probably not so well-suited for non-compiler programs. > And if it's hard for this simple problem, how about more complex > cases. For this simple problem it's easy :-) hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | h...@hjp.at |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Description: PGP signature -- https://mail.python.org/mailman/listinfo/python-list
Re: neonumeric - C++ arbitrary precision arithmetic library
On Sun, Mar 7, 2021 at 9:42 AM Mirko via Python-list wrote: > I even wonder why they have tried. Writing a universal > compiler/interpreter sounds logically impossible to me, Here's a > simple Python expression: > > >>> 3+3*5 > 18 > > And here's the same expression in (GNU) Smalltalk: > > st> 3+3*5 > 30 > > > How would such a universal compiler know which evaluation strategy > to follow, if not by writing a parser end evaluator for every > supported language? And if it's hard for this simple problem, how > about more complex cases. There are two ways in which "universal compiler/interpreter" can definitely make sense, but neither of them is what he's trying to do. 1) A bytecode or machine code that all other languages can be compiled to. For example, I'm running an amd64 CPU, so on this computer, everything ultimately gets executed as amd64 bytecode. It's also possible to have higher level bytecodes, or even textual languages (Asm.js can be used as a compilation target). 2) "Compiler compilers" and grammar parsers. These are an excellent tool for people designing programming language compilers, as they make it a lot easier to describe the syntax and semantics for the language. Both of them are tools that programming language developers use. They don't replace language interpreters any more than a JSON parser replaces the need to open files. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: neonumeric - C++ arbitrary precision arithmetic library
Am 06.03.2021 um 22:24 schrieb Ben Bacarisse: > Mr Flibble writes: > >>> Someone who says that he is capable of writing a compiler that >>> translates every language has megalomania. No one can do this. >> >> Just because you can't make one it doesn't follow that nobody else >> can. > > True, but lots of very knowledgeable people have tried and failed. I even wonder why they have tried. Writing a universal compiler/interpreter sounds logically impossible to me, Here's a simple Python expression: >>> 3+3*5 18 And here's the same expression in (GNU) Smalltalk: st> 3+3*5 30 How would such a universal compiler know which evaluation strategy to follow, if not by writing a parser end evaluator for every supported language? And if it's hard for this simple problem, how about more complex cases. -- https://mail.python.org/mailman/listinfo/python-list
Re: neonumeric - C++ arbitrary precision arithmetic library
On 3/5/2021 8:51 AM, Mr Flibble wrote: neonumeric - C++ arbitrary precision arithmetic library with arbitrary precision integers, floats and rationals: https://github.com/i42output/neonumeric It hasn't been formally released yet as it still requires more extensive testing. It will be used as part of my universal compiler, neos, that can compile any programming language and will be used for the neos implementation of Python (Python has big integers). Message ends. Get atan2, cos and sin, and I have some code to run it against. https://github.com/ChrisMThomasson/fractal_cipher/blob/master/RIFC/cpp/ct_rifc_sample.cpp It needs arbitrary precision! :^) -- https://mail.python.org/mailman/listinfo/python-list
RE: neonumeric - C++ arbitrary precision arithmetic library
Just to be clear, and luckily the person who posed such boasts is luckily gone and I AM NOT interested in having the discussion again here, I have a point to make. He did not suggest a magical compiler that could translate any language. Not exactly. I think he suggested that if all languages share a large set of paradigms related to what methods we have for computing, then there may be a way to capture and store some description of any new language that defines it well enough. He proposed a sort of universal program, indeed, that would read the description files and then actual programs and generate something that ultimately would be runnable. Of course, he basically ignored any little details along the way and even insisted it would be easy and the result would be much more efficient in every case. So, I suggest he is not as bright as he thinks. I, on the other hand, think it is a hard problem but in some abstract sense doable given infinite resources and time. Translation, not a worthwhile quest for NOW. There are accepted theorems that suggests a fairly simple Turing Machine can solve any problem computable on our current (non-quantum) generation of computers. The programs would be very far from efficient and in some cases would require an infinitely long tape and more states than our universe can accommodate. But in principle, it can do anything as stated above. So, any program in any language can theoretically be rewritten as a Turing Machine version. But that would not be done by a universal translator. I assume you could do it from say a compiled machine language version for some languages but it would require access to anything modern programs get from all kinds of libraries out there that extend the program and if it spawns other processes or has things run in parallel it gets more and more complex. But why do it at all? Sure, translating parts of some programs in one language to another can make sense. But why a goal to have a sort of Unified Programming Language Theory other than as an academic exercise? Having said that, I keep looking at how languages like Python and R grow and how they keep adding features including many borrowed or imitated from elsewhere and I conclude you can just put everything imaginable into Python and the rest become superfluous! Problem solved. -Original Message- From: Python-list On Behalf Of Bonita Montero Sent: Saturday, March 6, 2021 2:12 PM To: python-list@python.org Subject: Re: neonumeric - C++ arbitrary precision arithmetic library >> There is no projection. >> _You_ have megalomania, not me. >> And there's also no Dunning Kruger effect. >> You can't assess your capabilites, not me. > no u Someone who says that he is capable of writing a compiler that translates every language has megalomania. No one can do this. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: neonumeric - C++ arbitrary precision arithmetic library
Mr Flibble writes: >> Someone who says that he is capable of writing a compiler that >> translates every language has megalomania. No one can do this. > > Just because you can't make one it doesn't follow that nobody else > can. True, but lots of very knowledgeable people have tried and failed. And although you use the present tense "my universal compiler, neos, that /can/ compile any programming language" (emphasis mine) you currently have nothing to show -- no compiler for any language, no paper outlining how you plan to overcome the problems that stumped others, nothing but what appears to be a false claim about neos can do. If you want this project to be taken seriously, you are going about it the wrong way. -- Ben. -- https://mail.python.org/mailman/listinfo/python-list
Re: neonumeric - C++ arbitrary precision arithmetic library
On 3/6/2021 11:35 AM, Mr Flibble wrote: On 06/03/2021 19:11, Bonita Montero wrote: There is no projection. _You_ have megalomania, not me. And there's also no Dunning Kruger effect. You can't assess your capabilites, not me. no u Someone who says that he is capable of writing a compiler that translates every language has megalomania. No one can do this. Just because you can't make one it doesn't follow that nobody else can. I remember when Bonita tried to convince me that a mutex must use an atomic counter. -- https://mail.python.org/mailman/listinfo/python-list
Re: neonumeric - C++ arbitrary precision arithmetic library
There is no projection. _You_ have megalomania, not me. And there's also no Dunning Kruger effect. You can't assess your capabilites, not me. no u Someone who says that he is capable of writing a compiler that translates every language has megalomania. No one can do this. -- https://mail.python.org/mailman/listinfo/python-list
Re: neonumeric - C++ arbitrary precision arithmetic library
On Sun, Mar 7, 2021 at 4:51 AM Bonita Montero wrote: > > > Whilst you need to read the following: > > * https://en.wikipedia.org/wiki/Psychological_projection > > * https://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect > > There is no projection. > _You_ have megalomania, not me. > And there's also no Dunning Kruger effect. > You can't assess your capabilites, not me. Ignore this guy. He produces nothing, insults everyone, and just gets himself banned from places. He is nothing more than a troll and a waste of everyone's time. His posts do not reach the mailing list, only your replies do. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: neonumeric - C++ arbitrary precision arithmetic library
Whilst you need to read the following: * https://en.wikipedia.org/wiki/Psychological_projection * https://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect There is no projection. _You_ have megalomania, not me. And there's also no Dunning Kruger effect. You can't assess your capabilites, not me. -- https://mail.python.org/mailman/listinfo/python-list
Re: neonumeric - C++ arbitrary precision arithmetic library
It hasn't been formally released yet as it still requires more extensive testing. It will be used as part of my universal compiler, neos, that can compile any programming language ... You will get the same room in the same psychiatric ward like Amine Moulay Ramdane. -- https://mail.python.org/mailman/listinfo/python-list