Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

What is the size of an Integer<-128..+127>?

40 views
Skip to first unread message

Zing Chen

unread,
Mar 16, 2019, 2:55:25 PM3/16/19
to ParaSail Programming Language
Hello,

As stated in tiitle, what is the size of an object declared as Integer<-128..+127> ?

a) one byte, as expected for Ada's range -128..+127 or C/C++'s int8_t.

b) two bytes, because ParaSail's Integer<-128..+127> needs 257 distinct bit patterns. The extra bit pattern is to represent *null*.

I've read the article [S. Tucker Taft 2019], but without a compiler (I'm a Windows user) I can answer questions like this with only 50% certainty.

I set to find out myself how well is ParaSail suitable for low-level stuff such as embedded programming. A few years ago, a group of young and determined friends (engineers in electronics and mechanics) has asked me "which programming language is safe, fast, easy, rich, and neat"? I answered, to my best knowledge there's no such thing.

Then I "discovered" ParaSail. It's not so easy because of the Ada-like syntax. Syntax is the first reason to refuse, but (fortunately) the last reason to adopt a language. It''s safe, as opposed to Ada. It's fast, as opposed to Java. It's neat, as opposed to C++. It's rich, as opposed to Pascal or C. Thus it has almost all quality to become the first programming language to learn for general audience. So, I wonder if it's rich enough to serve as the _single_ general-purpose programming language to complete a real-world engineering project.

Thank you.

Tucker Taft

unread,
Mar 17, 2019, 1:24:34 AM3/17/19
to ParaSail Programming Language
On Sat, Mar 16, 2019 at 2:55 PM Zing Chen <tranng...@gmail.com> wrote:
Hello,

As stated in tiitle, what is the size of an object declared as Integer<-128..+127> ?

All stand-alone objects are 64-bits in ParaSail.  However, when an object is a component of a larger object, you can "pack" several objects into a single 64-bit word.  The ParaSail library has a module for doing a "packed word" where you can pack multiple fields together into a single word.  It also has a module for defining a "packed array" where you can define a packed array of n-bit objects.  See lib/aaa.psi which contains the ParaSail library, and look for PSL::Containers::Packed_Word and PSL::Containers::Packed_Array.  In both cases, you can decide whether you want to Allow_Null, indicating whether you want to reserve a bit pattern to represent "null" for each component, or if you want to disallow storing null values.


a) one byte, as expected for Ada's range -128..+127 or C/C++'s int8_t.

b) two bytes, because ParaSail's Integer<-128..+127> needs 257 distinct bit patterns. The extra bit pattern is to represent *null*.

As indicated above, with Packed_Word<..., Allow_Null => #false>, it would occupy 8 bits, whereas with Packed_Word<..., Allow_Null => #true>, it would need a 9th bit.  Ditto for Packed_Array<..., Allow_Null => (#false or #true)>


I've read the article [S. Tucker Taft 2019], but without a compiler (I'm a Windows user) I can answer questions like this with only 50% certainty.

We are working on producing a release that will allow you to build a Windows compiler.


I set to find out myself how well is ParaSail suitable for low-level stuff such as embedded programming. A few years ago, a group of young and determined friends (engineers in electronics and mechanics) has asked me "which programming language is safe, fast, easy, rich, and neat"? I answered, to my best knowledge there's no such thing.

Then I "discovered" ParaSail. It's not so easy because of the Ada-like syntax. Syntax is the first reason to refuse, but (fortunately) the last reason to adopt a language. It''s safe, as opposed to Ada. It's fast, as opposed to Java. It's neat, as opposed to C++. It's rich, as opposed to Pascal or C. Thus it has almost all quality to become the first programming language to learn for general audience.

Very flattering!  Would you mind if I mentioned this comment in a talk I am giving?

So, I wonder if it's rich enough to serve as the _single_ general-purpose programming language to complete a real-world engineering project.

It was certainly designed to support embedded programming, but currently you have to do some of the work yourself using the Packed_Word and Packed_Array modules.  At some point the compiler will be smart enough to insert packing automatically.


Thank you.

Sincerely,
-Tuck

--
You received this message because you are subscribed to the Google Groups "ParaSail Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to parasail-programming...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zing Chen

unread,
Mar 18, 2019, 1:26:55 AM3/18/19
to ParaSail Programming Language
Great. I'm glad to hear that, contrary to my original belief, null-ability is optional at least for simple types in arrays and records and working with it can be further simplified in future. This was defined reasonably. Can't wait to see more Windows supports in the next release.

I've been working as a programmer for my entire 30-year career, of which 5 years as a student, 10 years in using Ada (83) and C. In the recent 10 years also as occasional teacher, lecturer and consultant in CS (but not SE) and as such I will use it instead of Ada in my presentations once I finish learning it and when the choice of language is up to me. So, I hope this adds some credit to my otherwise zero-cent comment on (as I'm still learning) ParaSail. Honor is on my side, of course, if you'd cite it.

However, please take that as an analysis rather than a compliment. Most, if not all, of my students, despite having been explained from a well-informed source (me), have objection on Ada for the syntax. I believe some of their arguments apply to ParaSail as well.

To quote a 16-year-old boy, one of my [high school] students, "I dislike Ada because of many keywords and yet more contexts requiring/allowing a keyword, especially at the start of a source line of code. I dislike Ada for *end*, and infinitely many of its variations. I dislike Ada for *begin*, *else*, *then* and *loop*. Even *and*, *or*, *not*, are keywords! What is so interesting in *any* (he means probably *all*) or *null* for being keywords? I dislike Ada because *access* and Access, or *range* and Range, are both identical and distinct. I dislike Ada because "+"(x,y) and x + y are both distinct and identical. I dislike Ada because universal_integer both exists and does not exist. I dislike Ada because it's poorly readable."

"Programming is like solving a math puzzle. Source texts are like math texts. Keywords are very eye-catching and should be use selectively, just like *definition*, *theorem*, *proof* or *abstract*, *introduction*, *conclusion*. Identifiers should be high-lighted only at the first occurrence. Every word and symbol in each notation should have one and only one meaning. Every concept should be embodied by one and only one word or symbol. Who likes _quod erat demonstrandum_, in clear and in full, at the end of every six sentences? Who trust you adding in infix once the addition was defined as a prefix? Who believes "+" and + are one and the same? If concept matters, why universal_integer and not *universal* Integer or *any* (again, he probably means *all*) Integer?"

Thank you.

Tucker Taft

unread,
Mar 20, 2019, 2:16:20 AM3/20/19
to ParaSail Programming Language
There are three "variants" of ParaSail -- Parython, Javallel, and Sparkel, which have a syntax analogous to Python, Java, and SPARK, respectively.  In fact, ParaSail itself actually permits using Python-like syntax, e.g. using ":" instead of "then" with an "if" statement, and omitting the "end if" so long as you obey Python-like indenting conventions.  I have attached the "hippo_game.psl" from the "examples" directory included with the release.  It illustrates using Python-like syntax.

From the beginning I realized programmers have strong feelings about syntax, so ParaSail was designed so that the lexer and parser are separable from everything else, and it is relatively easy to connect a new lexer/parser onto the "front" of the ParaSail interpreter and compiler.  Python seems to be growing in interest, so I plan to spend more time on productizing "Parython" over the next six months.

Take care,
-Tuck


hippo_game.psl

Zing Chen

unread,
Mar 20, 2019, 11:38:38 AM3/20/19
to ParaSail Programming Language
My personal preference would be something C++-like (for brevity), not Python-like (for safety concern). But it has little to do with my choice. I choose ParaSail (in the usual, not Python-like, syntax) to learn and possibly to present later on because it is obviously the most accomplished variant (most presented, discussed, documented, code samples, etc).

For the Python-like syntax embedded in ParaSail syntax, I don't see much coherency in e.g.

def Place_Hippos():

...

end func Place_Hippos

But thank you anyway.

For all four variants (ParaSail, Sparkel, Javallel, Parython), I see little difference. For example, the Ada-ish notation "indexing"(a,i) in operator definition. I can speak only for myself, I know. But out of curiosity, any chance that one day, one could define it "naturally", i.e. as a[i] instead? That's what is expected from a "natural" language, as seen by one of my [high-school] students.

Programmers who thinks in transparent hyper-intensional logic and speaks the language of typed lambda calculus (what is it, after all?) don't mind "indexing"(a,i) or a[i]. For a newcomer and with modest training in mathematics however, seeing a[i] and "indexing"(a,i) as one and the same [function] is quite challenging.

Thank you very much.


On Wednesday, March 20, 2019 at 1:16:20 PM UTC+7, Tucker Taft wrote:
There are three "variants" of ParaSail -- Parython, Javallel, and Sparkel, which have a syntax analogous to Python, Java, and SPARK, respectively.  In fact, ParaSail itself actually permits using Python-like syntax, e.g. using ":" instead of "then" with an "if" statement, and omitting the "end if" so long as you obey Python-like indenting conventions.  I have attached the "hippo_game.psl" from the "examples" directory included with the release.  It illustrates using Python-like syntax.

From the beginning I realized programmers have strong feelings about syntax, so ParaSail was designed so that the lexer and parser are separable from everything else, and it is relatively easy to connect a new lexer/parser onto the "front" of the ParaSail interpreter and compiler.  Python seems to be growing in interest, so I plan to spend more time on productizing "Parython" over the next six months.

Take care,
-Tuck


On Mon, Mar 18, 2019 at 1:26 AM Zing Chen wrote:
Great. I'm glad to hear that, contrary to my original belief, null-ability is optional at least for simple types in arrays and records and working with it can be further simplified in future. This was defined reasonably. Can't wait to see more Windows supports in the next release.

I've been working as a programmer for my entire 30-year career, of which 5 years as a student, 10 years in using Ada (83) and C. In the recent 10 years also as occasional teacher, lecturer and consultant in CS (but not SE) and as such I will use it instead of Ada in my presentations once I finish learning it and when the choice of language is up to me. So, I hope this adds some credit to my otherwise zero-cent comment on (as I'm still learning) ParaSail. Honor is on my side, of course, if you'd cite it.

However, please take that as an analysis rather than a compliment. Most, if not all, of my students, despite having been explained from a well-informed source (me), have objection on Ada for the syntax. I believe some of their arguments apply to ParaSail as well.

To quote a 16-year-old boy, one of my [high school] students, "I dislike Ada because of many keywords and yet more contexts requiring/allowing a keyword, especially at the start of a source line of code. I dislike Ada for *end*, and infinitely many of its variations. I dislike Ada for *begin*, *else*, *then* and *loop*. Even *and*, *or*, *not*, are keywords! What is so interesting in *any* (he means probably *all*) or *null* for being keywords? I dislike Ada because *access* and Access, or *range* and Range, are both identical and distinct. I dislike Ada because "+"(x,y) and x + y are both distinct and identical. I dislike Ada because universal_integer both exists and does not exist. I dislike Ada because it's poorly readable."

"Programming is like solving a math puzzle. Source texts are like math texts. Keywords are very eye-catching and should be use selectively, just like *definition*, *theorem*, *proof* or *abstract*, *introduction*, *conclusion*. Identifiers should be high-lighted only at the first occurrence. Every word and symbol in each notation should have one and only one meaning. Every concept should be embodied by one and only one word or symbol. Who likes _quod erat demonstrandum_, in clear and in full, at the end of every six sentences? Who trust you adding in infix once the addition was defined as a prefix? Who believes "+" and + are one and the same? If concept matters, why universal_integer and not *universal* Integer or *any* (again, he probably means *all*) Integer?"

Thank you.


On Sunday, March 17, 2019 at 12:24:34 PM UTC+7, Tucker Taft wrote:
On Sat, Mar 16, 2019 at 2:55 PM Zing Chen wrote:
Hello,

As stated in tiitle, what is the size of an object declared as Integer<-128..+127> ?

All stand-alone objects are 64-bits in ParaSail.  However, when an object is a component of a larger object, you can "pack" several objects into a single 64-bit word.  The ParaSail library has a module for doing a "packed word" where you can pack multiple fields together into a single word.  It also has a module for defining a "packed array" where you can define a packed array of n-bit objects.  See lib/aaa.psi which contains the ParaSail library, and look for PSL::Containers::Packed_Word and PSL::Containers::Packed_Array.  In both cases, you can decide whether you want to Allow_Null, indicating whether you want to reserve a bit pattern to represent "null" for each component, or if you want to disallow storing null values.


a) one byte, as expected for Ada's range -128..+127 or C/C++'s int8_t.

b) two bytes, because ParaSail's Integer<-128..+127> needs 257 distinct bit patterns. The extra bit pattern is to represent *null*.

As indicated above, with Packed_Word<..., Allow_Null => #false>, it would occupy 8 bits, whereas with Packed_Word<..., Allow_Null => #true>, it would need a 9th bit.  Ditto for Packed_Array<..., Allow_Null => (#false or #true)>


I've read the article [S. Tucker Taft 2019], but without a compiler (I'm a Windows user) I can answer questions like this with only 50% certainty.

We are working on producing a release that will allow you to build a Windows compiler.


I set to find out myself how well is ParaSail suitable for low-level stuff such as embedded programming. A few years ago, a group of young and determined friends (engineers in electronics and mechanics) has asked me "which programming language is safe, fast, easy, rich, and neat"? I answered, to my best knowledge there's no such thing.

Then I "discovered" ParaSail. It's not so easy because of the Ada-like syntax. Syntax is the first reason to refuse, but (fortunately) the last reason to adopt a language. It''s safe, as opposed to Ada. It's fast, as opposed to Java. It's neat, as opposed to C++. It's rich, as opposed to Pascal or C. Thus it has almost all quality to become the first programming language to learn for general audience.

Very flattering!  Would you mind if I mentioned this comment in a talk I am giving?

So, I wonder if it's rich enough to serve as the _single_ general-purpose programming language to complete a real-world engineering project.

It was certainly designed to support embedded programming, but currently you have to do some of the work yourself using the Packed_Word and Packed_Array modules.  At some point the compiler will be smart enough to insert packing automatically.

--

Reply all
Reply to author
Forward
0 new messages