tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Speed of development of a compiler.


From: AlexandreFressange
Subject: Re: [Tinycc-devel] Speed of development of a compiler.
Date: Wed, 25 Nov 2015 10:07:10 +0100

Yes you are right,
 
And I though about this by defining behabior. In my case, an empty string is always equal to \0.
 
So
string s1 = "foo";
string s2; // will be initialized to \0 or..
print s1 + s2;// print will be replaced by print s1 only. Anyway, it always prints "foo".
 
Actually, this language is very restrictive to have one way and one way only to do something. So the result is always expectable.
 
I guess I should prepare something I can show you (language->compiler). Then, we will have factual material to talk about.
At this stage, I expect the compiler to fail on heavily cryptic C notations, but handle pointers to pointers just fine.
 
Let me a few days to pack it up properly guys.
 
@Basile, ok I may have a misconfiguaration with the mail settings. Will look into it.
-- 
Alex
 
 
 
25.11.2015, 08:57, "Christian JULLIEN" <address@hidden>:
I fully second Basile, semantic is much more important than syntax.
It took us more than 10 years to normalize ISO ISLISP semantic which consists in only 25 special forms which fully describe semantic of the language (C. Queinnec was convenor of this ISO group and a great help to define semantic).
During this normalization process, syntax was never really discussed (or so).
With the exact same syntax, Lisp language family can behaves very differently whether it is dynamically V.S. lexically scoped, Lisp-1 V.S. Lisp-2.
With Lisp and without precise semantic you can't predict a result just reading the code.
Now, with precise semantic, I can implement ISLISP semantic using C syntax, Python syntax, xxx syntax and all my programs should compile to a native implementation (C or asm) that, when run, will produce the same result.

Take another example. If I have 10 CS students and I ask them to write a compiler that accepts:

string s1 = "foo";
string s2 = "bar";
print s1 + s2;

which obviously should print "foobar"

With no doubt, after few days all the students will succeed with this exercise.

Now what happens if I change the source code with:

string s1 = "foo";
string s2 = s1;
print s1 + s2;

string s1 = "foo";
string s2;
print s1 + s2;

string s1 = "foo";
print s1 + 1;

string s1 = "foo";
print s1 + "bar";

string s1 = "foo";
print s1 + s1;

etc...

I'm sure the 10 programs will print different results.


----- message d'origine -----
De : "Basile Starynkevitch" <address@hidden>
date mer. 25/11/2015 07:51 (GMT +01:00)
À : "address@hidden" <address@hidden>, "address@hidden" <address@hidden>
Objet : Re: [Tinycc-devel] Speed of development of a compiler.

On 11/24/2015 09:13 PM, AlexandreFressange wrote:


Now, I am about to finish my OS that will not be open source (no need, not a community project), I was working on some performance optimizations for memory management. I have been coding for 15 years now, but my initial formation is unrelated with CS. This OS is for very specific purposes that are currently being developed for a startup (I won't say much more right now, right here, but will happily do in a few time). The language resembles python but is even simpler (but has pointers; we always need them :) ),



This is problematic, and you are making a confusion. You are thinking
that since the syntax is similar to Python, your language is Python-like.

But what matters in a programming language is not its syntax, but its
semantics. For example, _javascript_ & Scheme have somehow similar
semantics (with of course very significant and profound differences) but
very different syntax.

So, if you don't know it, learn a bit of Scheme (using the SICP book I
mentioned) then read Queinnec's book (Lisp in Small Pieces) which
explains various way of coding Lisp interpreters and compilers.

Notice that Scheme specifications (e.g. R5RS, R6RS) have formalized most
of the semantics, and that is extremely useful. Explaining what
operators like call/cc do without formal semantics is error-prone.
https://en.wikipedia.org/wiki/Call-with-current-continuation

A language with explicit pointers cannot resembles python, since adding
explicit pointers changes the semantics profoundly.


So you should write a web page describing your language in details
(giving the syntax, and explaining, at least in English, the semantics)
to get more help.

Wikipedia (and the Web) have useful pages about semantics, operational
semantics, denotational semantics, etc.

If you think in C (which is a language with a rather simple syntax but a
difficult semantics, and whose undefined behaviors are painful), look at
least inside X.Leroy's papers about CompCert and also inside Frama-C
(http://frama-c.com) and its ACSL annotation language.

The notion of undefined behavior in C is tricky (and it is semantical).
Read http://blog.regehr.org/archives/213 &
http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html


Trust me, semantics matters more than syntax. If you can afford it, have
a extremely simple syntax: the Lisp s-expressions could be inspirational.

And please, write and publish some web page somewhere about your
language. Take a few days to write that (some EBNF syntax, several
examples, many English paragraphs to explain informally some of the
semantics).
It probably might start as an ill-defined specification (in English)
and we'll be able to discuss more precisely.

You'll go nowhere if you don't explain your thing.

Read many papers from the PLDI conferences.
http://www.sigplan.org/Conferences/PLDI/

Regards.

PS. It looks like your emails are incorrectly encoded in KOI-8. I have
to correct the encoding in every of my answers. Please change your MUA
encoding to UTF8

--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***


_______________________________________________
Tinycc-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]