In order to motivate myself to work on my programming language, Kitten, I’ve decided to publish my notes on various aspects of the design as I figure them out. This is partly to solicit comments and drum up interest in the project, but mostly an exercise in ensuring my ideas are solid enough to explain clearly.
In these articles, “Kitten” will refer to the “ideal” language and the new work-in-progress compiler that approximates it.
Explicitness
In non-generic definitions, it should always be evident from the code what type of data you’re using. As such, the type of integer and floating-point literals can be specified with a type suffix: i8
, i16
, …, u8
, …, f32
, f64
; the unadorned integer literal 1
is equivalent to 1i32
, and the float literal 1.0
is equivalent to 1.0f64
. I think signed 32-bit integers and 64-bit floats are reasonable defaults for common use cases.
In the future, we could relax this by allowing the suffix to be inferred, or by allowing the default suffix to be locally changed.
// Currently fails to typecheck; 3 could be deduced to mean 3i64.
(2i64 + 3)
// Currently not valid syntax; 2 and 3 could be defaulted to Int64.
assume (Int64)
(2 + 3)
Uniformity
Because overloading interacts rather poorly with type inference, it would be easiest for me to provide different operators for different types, such as +
for integer addition and +.
for floating-point addition, as in OCaml. I did this in the old compiler, and it wasn’t great for usability. I solve this through the use of traits—for each operator there is a single generic definition, with instances provided for all the common arithmetic types.
trait + <T> (T, T -> T)
instance + (Int32, Int32 -> Int32):
_::kitten::add_int32
instance + (Float64, Float64 -> Float64):
_::kitten::add_float64
Traits work like template specialisations in C++: if +
is inferred to have the type Int32, Int32 -> Int32
at a given call site, then the compiler will emit a call to that particular instance; no generic code makes it into the final executable. And if no such instance exists, you’ll get a straightforward compilation error.
These traits will generally need to be inlined for performance reasons. Luckily, Kitten’s metadata system allows us to specify this easily enough:
about +:
docs: """
Adds two values of some type, producing a result of the same type.
"""
inline: always
The about
notation is a dumping ground for all metadata: documentation, examples, tests, operator precedence information, and optimization hints. The idea is that it’s better to have all of this information in a single structured format than to use some combination of magical comments, pragmas, attributes, and otherwise special syntax.
Safety
We want arithmetic operations to be safe, meaning that failure modes such as implicit overflow and trapping should be opt-in.
Therefore, we should provide an arbitrary-precision integer type (Int
) as a sane default, as well as an array of signed and unsigned fixed-precision integer types in common sizes: Int8
, Int16
, Int32
, Int64
, and their UIntN
counterparts.
Kitten has a permission system for reasoning about the permitted side effects of functions. Operations on fixed-precision integers (both signed and unsigned) are checked by default, requiring the +Fail
permission to allow them to raise assertion failures in case of overflow.
instance + (Int32, Int32 -> Int32 +Fail) { … }
However, if most arithmetic operations can fail, then +Fail
will proliferate through all the type signatures of calling code, which is a real drag, and might encourage people to use unchecked types more liberally than they should. We can solve this in two ways:
- Make
+Fail
implicit in type signatures, and introduce a notation-Fail
for removing it. This speaks to a more general notion of implicit permissions, which I think would be really valuable: it would let us introduce new implicit permissions in a backward-compatible way, allowing new code to opt out. For example, if we implicitly grant+Alloc
to all functions, then they’re permitted to allocate memory on the heap—lists, closures, bignums, and so on. But for performance-critical code, you may want a static guarantee that your code performs no heap allocations, so you can opt out by specifying-Alloc
. - Introduce a wrapper type,
Checked<T>
, which provides arithmetic operations that don’t require+Fail
, but instead return anOptional<T>
as the result. This would mean making the signatures of the arithmetic traits more general, or inlining theOptional
into the representation ofChecked
.
Neither is unequivocally better, and they have different use cases, so I think it makes sense to provide both.
Modifiers
In addition to Checked<T>
, Kitten provides wrapper types for different arithmetic modes:
Wrapped<T>
is aT
where overflow is defined to wrap modulo the range ofT
.Unchecked<T>
is aT
where overflow is implementation-defined. I’m tempted to make this type require the+Unsafe
permission, but that’s intended for operations that can violate memory safety, whichUnchecked<T>
cannot.Saturating<T>
is aT
where overflow results in clamping to the range ofT
; this is useful in some signal-processing applications.
Platform Independence
All the basic arithmetic types should be provided on all platforms. That may require emulation in some cases, such as 64-bit arithmetic on a 32-bit processor. Implementations can provide additional platform-specific types such as Int128
or Float80
.
SIMD operations are implemented on container-like types such as Vector4<Float32>
; naïve-looking code such as:
vec { (* 2) } map
Should be lowered to the single instruction:
addps %xmm0, %xmm0
This is subtle, and I haven’t worked out all the details yet, but SIMD operations are important enough for performance-critical code that it seems worthwhile to consider them early on.
Licensing Problems
For arbitrary-precision types, I’m in a bit of a bind. I’m not equipped to write a native Kitten bignum library with performance on par with GMP, but because GMP is licensed under LGPL, it can’t be used freely. For instance, we can’t statically link it into generated executables, making distribution more difficult and negatively impacting performance.
TL;DR
- Kitten has all the usual machine integer and float types that systems programmers love.
- Literal types are explicit, with some sane defaults: signed
Int32
andFloat64
. - Overflow is checked by default, with various type-system features for more control.
- The standard library provides arbitrary-precision and SIMD operations.
ReplyDeleteI have clarified my doubts through this. Everyone will benefit and thankyou so much for this article.
core java training in chennai
Best core java Training in Chennai
core java Training in OMR
best c c++ training in chennai
javascript course in chennai
Drupal Training in Chennai
Photoshop Classes in Chennai
core java training in chennai
Great Article Artificial Intelligence Projects
DeleteProject Center in Chennai
JavaScript Training in Chennai
JavaScript Training in Chennai Project Centers in Chennai
I think this is the best article today about the future technology. Thanks for taking your own time to discuss this topic, I feel happy about that curiosity has increased to learn more about this topic
ReplyDeleteC and C++ Training Institute in chennai | C and C++ Training Institute in anna nagar | C and C++ Training Institute in omr | C and C++ Training Institute in porur | C and C++ Training Institute in tambaram | C and C++ Training Institute in velachery
I am a new user of this site, so here I saw several articles and posts published on this site, I am more interested in some of them, hope you will provide more information on these topics in your next articles.
ReplyDeleteBusiness Analytics Course in Bangalore
I will very much appreciate the writer's choice for choosing this excellent article suitable for my topic. Here is a detailed description of the topic of the article that helped me the most.
ReplyDeleteData Analytics Course in Bangalore
Thanks, this is generally helpful.
ReplyDeleteStill, I followed step-by-step your method in this Python Online Training
Python Online Course
Attend The Data Analyst Course From ExcelR. Practical Data Analyst Course Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Data Analyst Course.
ReplyDeleteData Analyst Course
wonderful article contains lot of valuable information. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
ReplyDeleteThis article resolved my all queries.good luck an best wishes to the team members.learn digital marketing use these following link
Digital Marketing Course in Chennai
Thanks for sharing this in here. You are running a great blog, keep up this good work.
ReplyDeleteOnline degree courses
Distance education
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors.
ReplyDeletedata analytics courses in bangalore
i am glad to discover this page : i have to thank you for the time i spent on this especially great reading !! i really liked each part and also bookmarked you for new information on your site.
ReplyDeletebest data science courses in bangalore
I am glad to discover this page. I have to thank you for the time I spent on this especially great reading !! I really liked each part and also bookmarked you for new information on your site.
ReplyDeleteData Science Training in Chennai
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors.
ReplyDeletedata analytics courses in bangalore
Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such amazing content for all the curious readers who are very keen on being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in the future too.
ReplyDeleteDigital Marketing Training in Bangalore
I found Habit to be a transparent site, a social hub that is a conglomerate of buyers and sellers willing to offer digital advice online at a decent cost.
ReplyDeleteArtificial Intelligence Training in Bangalore
I really enjoyed reading your blog. It was very well written and easy to understand. Unlike other blogs that I have read which are actually not very good. Thank you so much!
ReplyDeleteData Science Training in Bangalore
The Extraordinary blog went amazed with the content that they have developed in a very descriptive manner. This type of content surely ensures the participants explore themselves. Hope you deliver the same near the future as well. Gratitude to the blogger for the efforts.
ReplyDeleteMachine Learning Course in Bangalore
one funnel away challenge
ReplyDeleteone funnel away challenge
one funnel away challenge
one funnel away challenge
one funnel away challenge
one funnel away challenge
one funnel away challenge
one funnel away challenge
one funnel away challenge
one funnel away challenge
I am glad to discover this page. I have to thank you for the time I spent on this especially great reading !! I really liked each part and also bookmarked you for new information on your site.
ReplyDeleteData Science Course Syllabus
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors.
ReplyDeletedata science course in jaipur
I am glad to discover this page. I have to thank you for the time I spent on this especially great reading !! I really liked each part and also bookmarked you for new information on your site.
ReplyDeleteData Science Training in Chennai
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors.
ReplyDeletedata science course
Informative blog
ReplyDeleteai training in hyderabad
this is really nice to read..informative post is very good to read..thanks a lot!
ReplyDeletedata scientist training and placement in hyderabad
A good blog always contains new and exciting information, and reading it I feel like this blog really has all of these qualities that make it a blog.
ReplyDeleteArtificial Intelligence Training in Bangalore
It is late to find this act. At least one should be familiar with the fact that such events exist. I agree with your blog and will come back to inspect it further in the future, so keep your performance going.
ReplyDeleteDigital Marketing Training in Bangalore
I wanted to leave a little comment to support you and wish you the best of luck. We wish you the best of luck in all of your blogging endeavors.
ReplyDeleteData Science Training in Bangalore
I am more curious to take an interest in some of them. I hope you will provide more information on these topics in your next articles.
ReplyDeleteMachine Learning Course in Bangalore
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors.
ReplyDeletebusiness analytics courses
I am glad to discover this page. I have to thank you for the time I spent on this especially great reading !! I really liked each part and also bookmarked you for new information on your site.
ReplyDeleteData Science Course in Delhi
The article posted was very informative and useful. You people are doing a great job. Keep going.
ReplyDeletedata science training
I am looking for and I love to post a comment that "The content of your post is awesome" Great work!ethical hacking course in patna
ReplyDeletei am glad to discover this page : i have to thank you for the time i spent on this especially great reading !! i really liked each part and also bookmarked you for new information on your site.
ReplyDeletedata analytics course in patna
I am overwhelmed by your post with such a beautiful subject. I usually visit their blogs and update myself through the information they contain, but today's blog would be most appreciated. Well done!
ReplyDeleteMachine Learning Course in Bangalore
Great Information sharing .. I am very happy to read this article .. thanks for giving us go through info.Fantastic nice. I appreciate this post. data science course in delhi with placement
ReplyDeleteThis post is good enough to make somebody understand this amazing thing, and I’m sure everyone will appreciate this interesting things. data science training institute in gurgaon
ReplyDeleteI want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors
ReplyDeletedata science training institute in noida
Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!best data science course in bhubaneswar
ReplyDeleteExtremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting. A debt of gratitude is in order for sharing.data science training in gwalior
ReplyDeleteI really appreciate this wonderful message you have given us. I assure you that would be beneficial for most people.
ReplyDeleteData Science Course in Nagpur
Impressive. Your story always bring hope and new energy. Keep up the good work. Data Analytics Course in Chennai
ReplyDeleteI want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors
ReplyDeletedata analytics course in trivandrum
Impressive. Your story always bring hope and new energy. Keep up the good work. Data Analytics Course in Vadodara
ReplyDeleteMelayu 4D Slot | Online Slots Casino fun88 soikeotot fun88 soikeotot dafabet dafabet 911Golden Race Virtual Racing Experience | Shootercasino
ReplyDeleteDigital Marketing Course can be a vital tool to cultivate your career and business. In this course work, you will discover what is online marketing, why it is significant, how all businesses are turning from traditional marketing to this online branding.
ReplyDeleteFor more details, visit our website -
Best & Affordable Digital Marketing Course in Chennai
I love this. It is soo informative. Are you also searching for cheap assignment help we are the best solution for you. We are best known for delivering the best services to students without having to break the bank
ReplyDeleteYour way of telling everything in this article is genuinely pleasant, all can easily understand it, Thanks a lot 온라인카지노
ReplyDeleteThis is an awesome article, Given such an extraordinary measure of data in it, These sort of articles keeps the customers excitement for the site, and keep sharing more ... favorable circumstances. 스포츠토토
ReplyDeleteI will really appreciate the writer's choice for choosing this excellent article appropriate to my matter.Here is deep description about the article matter which helped me more.
ReplyDelete온라인카지노
What an incredible message this is. Truly one of the best posts I have ever seen in my life. Wow, keep it up.
ReplyDeleteData Scientist Training in Bangalore
Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting. A debt of gratitude is in order for sharing.data science course in rohtak
ReplyDeleteI curious more interest in some of them hope you will give more information on this topics in your next articles.
ReplyDeletefull stack development course
Are you searching for the best AWS Training in Chennai Here is the best software training Institute in Chennai. Infycle Technologies gives you finest courses such as Power BI, Cyber Security, Graphic Design and Animation, Block Security, Java, Oracle, Python, Big data, Azure, Python, Manual and Automation Testing, DevOps, Medical Coding etc., and we also provide best technical trainers with best training 100+ Live Practical Sessions with Real-Time scenarios at the end of the course the freshers, experienced, and Tech professionals will be able to obtain more knowledge of the course and be able to crack interviews on top MNC’s with an amazing package. For more details ring us up on 7504633633, 7502633633.
ReplyDeleteReally impressed! Everything is a very open and very clear clarification of the issues. It contains true facts. Your website is very valuable. Thanks for sharing.
ReplyDeleteBest Data Analytics Courses in Bangalore
I want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors
ReplyDeletedata scientist course in faridabad
Very informative message! There is so much information here that can help any business start a successful social media campaign!
ReplyDeletedata science training in london
If you are searching for the best shopping platform, visit our website. Your article is so good to read waiting for the next update. Keep updating.
ReplyDeleteOnline shopping Platform in chennai
Hosted Ecommerce Platform
Build Your Own e Commerce Web site
It is perfect chance to make a couple of game plans for the future and the opportunity has arrived to be sprightly. I've scrutinized this post and if I may I have the option to need to suggest you some interesting things or recommendations. Perhaps you could create next articles insinuating this article. I have to examine more things about it!
ReplyDelete360DigiTMG, the top-rated organisation among the most prestigious industries around the world, is an educational destination for those looking to pursue their dreams around the globe. The company is changing careers of many people through constant improvement, 360DigiTMG provides an outstanding learning experience and distinguishes itself from the pack. 360DigiTMG is a prominent global presence by offering world-class training. Its main office is in India and subsidiaries across Malaysia, USA, East Asia, Australia, Uk, Netherlands, and the Middle East.
ReplyDeleteI want to leave a little comment to support and wish you the best of luck.we wish you the best of luck in all your blogging enedevors
ReplyDeletedata scientist course in delhi
I was curious if you ever thought of changing the layout of your site? Its very well written; I love what youve got to say. But maybe you could a little more in the way of content so people could connect with it better. Youve got an awful lot of text for only having 1 or 2 pictures. Maybe you could space it out better?|data analytics course in jodhpur
ReplyDeleteI see the greatest contents on your blog and I extremely love reading them. Data Scientist Course in Dombivli
ReplyDeleteExtremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting.
ReplyDeleteA debt of gratitude is in order for sharing.business analytics course in kolhapur
It is perfect time to make some plans for the future and it is time to be happy. I've read this post and if I could I desire to suggest you some interesting things or suggestions. Perhaps you could write next articles referring to this article. I want to read more things about it! data science course in mysore
ReplyDeleteI’m excited to uncover this page. I need to to thank you for ones time for this particularly fantastic read!! I definitely really liked every part of it and i also have you saved to fav to look at new information in your site. data science training in kanpur
ReplyDeleteHappy to chat on your blog, I feel like I can't wait to read more reliable posts and think we all want to thank many blog posts to share with us.
ReplyDeleteData Science Training Institutes in Bangalore
I truly like your style of blogging. I added it to my preferred's blog webpage list and will return soon…https://360digitmg.com/course/certification-program-on-digital-marketing
ReplyDeleteThe blog and data is excellent and informative as well your work is very good and I appreciate well hopping for some more informative posts.
ReplyDeleteBusiness Analytics Course in Gurgaon
Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one.
ReplyDeleteContinue posting. A debt of gratitude is in order for sharing.data science course in warangal
I'm genuinely getting a charge out of scrutinizing your richly formed articles. Apparently you consume a huge load of energy and time on your blog. I have bookmarked it and I am expecting scrutinizing new articles. Continue to do amazing.business analytics course in ghaziabad
ReplyDeleteInformative Post. The information you have posted is very useful and sites you have referred was good. Thanks for sharing.
ReplyDeleteData Science Course with Placement
Everything is very open with a clear clarification of the issues. It was truly informative. Your site is useful. Thank you for sharing!|data analytics course in jodhpur
ReplyDeleteGoing to graduate school was a positive decision for me. I enjoyed the coursework, the presentations, the fellow students, and the professors. And since my company reimbursed 100% of the tuition, the only cost that I had to pay on my own was for books and supplies. Otherwise, I received a free master’s degree. All that I had to invest was my time. data science training in surat
ReplyDeleteI just got to this amazing site not long ago was actually captured with the piece of resources you have got here and big thumbs up for making such wonderful blog page!
ReplyDeleteData Scientist Course
I want to thank you for your time in this wonderful read which is really appreciable and put you in your favorites to see new things on your blog, a must-have blog!
ReplyDeleteBusiness Analytics Course in Noida
i found your this call despite the fact that searching for a few related reference concerning blog search...Its a nice publicize..store posting and update the mention. NordVPN Crack Pc
ReplyDeleteYour article looks really adorable, here's a site link i dropped for you which you may like. 스포츠토토
ReplyDeleteI really like it when people come together and share ideas.
ReplyDeleteGreat website, keep it up! 경마
I love your blog.. very nice colors & theme. 파친코사이트
ReplyDeleteGreat web site you have got here.. It’s hard to find quality writing like yours these days. I really appreciate individuals like you! Take care!! 토토사이트
ReplyDeleteI like to view your web site which is very useful and excellent resource and truly adored reading your posting. Thank you!
ReplyDeleteData Science Course in Gurgaon
I read your excellent blog post. It's a great job. I enjoyed reading your post for the first time, thank you.
ReplyDeleteData Science Institutes in Bangalore
They need to be good in python and other programming skills and modern AI tools to develop a website whose success is guaranteed.
ReplyDeletedata science training in shimla
ReplyDeleteThis is an informative and knowledgeable article. therefore, I would like to thank you for your effort in writing this article.
Data Science Course in Bangalore
Well done for this excellent article. and really enjoyed reading this article today it might be one of the best articles I have read so far and please keep this work of the same quality.
ReplyDeleteData Analytics Course in Noida
ReplyDeleteWhen you have understood the basic concepts of data science, you must choose a path to move in data science. You need to learn the following courses to be an expert in the field of data science.
data science course in gorakhpur