473,795 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Language to replace C

Antti & all interested,

The draft description of my language to replace C is available at:

http://nahas.is-a-geek.com/~mike/MyC.pdf
I am a long time C programmer (I read the old testament in 1987) and
I've tried to keep the spirit of C and make as few changes as possible.
I was mostly driven by the bloat of C++ and, now, C99. I was also
driven by the gcc extensions, which provide needed features that aren't
present in ANSI C.
(http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html)
The things people will most hate are:
1) new keywords (fun, var)
2) changed type declarations
3) changed variable and function declarations
3) @ as the array operator, instead of []

The things people will most love are
1) multiple return values made easy
2) function pointers easier to declare and read
3) exact specifications of types
4) no forward declarations
This language doesn't add any power over C because it is designed to be
able to link to C files. It is just trying to do what C does with a
better type system and a better syntax for some things.

I know I am going to get flamed for this. I'd appreciate it if replies
contained constructive comments ("I'd rather have seen ...") rather than
destructive comments ("What you have sucks!"). Second, make sure to
mention what you like about it (if there is anything) rather than only
things that you hate. Lastly, if you think it violates the spirit of C
(a valid complaint in my mind), then try to state as clearly as you can
the principle that C embodies and then an example of how my language
violates it. E.g., "C uses minimal keywords. Your language has two new
keywords, 'fun' and 'var', all over the place."

As a final note, I have not written a replacement for the C
pre-processor yet. It's affect on C is much stronger than many people
believe. I have a few ideas floating around, but nothing solid yet.
Some involve using the [] symbols, which I would like to use for
polymorphic types, similar to C++'s templates. (Which use < and >, the
ugliest thing in C++.)

Let the flames begin...
Mike


For Torben:
I agree with most of your suggestions, but I didn't think that this
was the language for all of them. I wanted a language that was
linkable with C and didn't require anything else. I basically
wanted C with a clearer type system and a nicer interface to a few
features. Thunks, overloading, and polymorphism didn't fit.
(Although, polymorphism may come through type macros.) After I
finish the design of this language and write a compiler, I'm going
to look at designing a higher-level language. I've come to like
OCaml, but dislike a few hickups (naming especially) and it's
syntax. I think there could be a market for a type-safe language
that could easily link to C and use a conservative garbage
collector.

Mike

Subject: Re: a language to write an OS with ???
From: to*****@diku.dk (Torben Ægidius Mogensen)
Newsgroups: comp.lang.misc

Antti Sykäri <js*****@gamma. hut.fi> writes:

Nowadays it's all too common for language designers to design high
level, garbage-collected, object-oriented, bigger-is-better like
languages (witness C++ since addition of multiple inheritance and
exception specifications, Java, C#, and now D). To strive for an
efficient, clean, and "light-weight" language -- a language that would
be just appropriate to create a modern operating system in -- doesn't
seem to be very fashionable.
I wouldn't say that there is less interest in designing such
languages, I would rater say that the "market" for such languages is
more entrenched than for higher-level languages, especially scripting
languages. One reason may be that an OS is a major undertaking and
likely to be in use for a long time. So OS writers want a language
that they know will be around for a long while and which will be
ported to a large range of platforms (allowing their OS to do the
same).
My own hobby language is about creating a better C/C++, with cleaner
syntax, more extensibility, more transparency, better metaprogramming
facilities and ultimately, the ability to go as close to the hardware
as possible when needed. (Yes, it's likely to be a long road.)

In essence, it's about taking C and evolving it in the same direction
as C++ did, emphasizing the "what you don't use, you don't pay for"
rule and paying less attention to backwards compatibility.


In designing a C replacement, I wouldn't start from C. Even without
the C++ additions etc., C is a horrible language, with highly
complicated and somewhat ambiguous syntax, underspecified semantics
and lacking in features necessary for OS writing (such as jumping
through a pointer).

What I would do was (among other things):

- Have well-defined syntax and semantics.

- Ensure that the sizes of all types are specified by the language,
so it would, e.g., be explicit if an integer or pointer is 32 or 64
bits long. Memory layout would also be explicit, so big-endian or
little-endian numbers and strings would have explicitly different
types (and both would be present).

- Make it explicit in the type of a pointer if it can be null.

- Make it explicit in the type of a value if it can be modified after
creation and initialization. Integrate creation and
initialization.

- Allow pointer-arithmetic only on pointers to arrays. Doing it on
other pointers should give type errors. You can have fields
offsets and such, and they can even be negative (a record/struct
pointer type can specify to which field the pointer points). Allow
all/several components of a record to be accessed at once, using a
kind of pattern-matching.

- Have no implicit casts, even between integer sizes.

- Have parametric polymorphism, implemented by
replication/specialization.

- Overloading via (Haskell-style) type classes, not by ad-hoc
overloading or OO-style virtual methods.

- Have type-safe closures/thunks.

- Allow programmer to specify pointer to address at which a record,
array or other structure is built. Issue compile-time warning if
the type of the pointer does not ensure sufficient space.

- Allow compile-time warnings to be supressed individually, but not
en-masse. I.e., when the programmer gets a warning, he can check
if there really is a problem, and if not insert an assertion at the
relevant place in the code to supress the warning.

- Drop macros and instead require the compiler to inline definitions
that are marked as such.

Torben
Nov 14 '05
22 2882
In article <ca**********@n ewsg1.svr.pol.c o.uk>, Malcolm wrote:
"Gustavo Cipriano Mota Sousa" <gu*********@in f.ufg.br> wrote

Quite a lot of languages have been named "D", but as far as I know none has
caught on to any extent.
C++ already provides OO and, with the standard template library, garbage
collection, and has facilities to link C functions, and it is a
well-established language. "D" doubtless implements things much better, but
the advantage would have to absolutely overwhelming (or you would have to
have the marketing muscle of a big company behind you) to have any hope of
dislpacing C++ as language of choice.


D has the advantage of the having most of the advantages of C++ but not
too many of its weaknesses. In addition, it has features that make
programming just so comfortable that having to switch back to C++ makes
me cringe.

This has made D *my* language of choice when picking a language for my
hobby projects, and I don't find it at all unlikely if other people
eventually arrive at the same decision.

While D is not perfect (it's still in development and is still missing a
good part of its standard library) it's one of the best there is.

In summary, there is a gap between "good old" languages (C and C++) and
"fancy new" languages (Java and C#). The former are simple, fast, and,
to a certain degree, crude; are compiled to machine code; and have C
linkage. The latter are designed by large corporations, for large
corporations; have nice features that boost productivity; are run on a
virtual machine; and, therefore, can be perceived as having a certain
overhead.

D aims to fill that gap, and I hope it succeeds.

-Antti

--
I will not be using Plan 9 in the creation of weapons of mass destruction
to be used by nations other than the US.
Nov 14 '05 #21

"Michael Nahas" <mi************ ***@deletethis. com> wrote in message
news:dN******** *********@twist er.rdc-kc.rr.com...
Antti & all interested,

The draft description of my language to replace C is available at:

http://nahas.is-a-geek.com/~mike/MyC.pdf
I am a long time C programmer (I read the old testament in 1987) and
I've tried to keep the spirit of C and make as few changes as possible.
I was mostly driven by the bloat of C++ and, now, C99. I was also
driven by the gcc extensions, which provide needed features that aren't
present in ANSI C.
(http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html)
The things people will most hate are:
1) new keywords (fun, var)
2) changed type declarations
3) changed variable and function declarations
3) @ as the array operator, instead of []

The things people will most love are
1) multiple return values made easy
2) function pointers easier to declare and read
3) exact specifications of types
4) no forward declarations
This language doesn't add any power over C because it is designed to be
able to link to C files. It is just trying to do what C does with a
better type system and a better syntax for some things.

I know I am going to get flamed for this. I'd appreciate it if replies
contained constructive comments ("I'd rather have seen ...") rather than
destructive comments ("What you have sucks!"). Second, make sure to
mention what you like about it (if there is anything) rather than only
things that you hate. Lastly, if you think it violates the spirit of C
(a valid complaint in my mind), then try to state as clearly as you can
the principle that C embodies and then an example of how my language
violates it. E.g., "C uses minimal keywords. Your language has two new
keywords, 'fun' and 'var', all over the place."

As a final note, I have not written a replacement for the C
pre-processor yet. It's affect on C is much stronger than many people
believe. I have a few ideas floating around, but nothing solid yet.
Some involve using the [] symbols, which I would like to use for
polymorphic types, similar to C++'s templates. (Which use < and >, the
ugliest thing in C++.)

Let the flames begin...
Mike


For Torben:
I agree with most of your suggestions, but I didn't think that this
was the language for all of them. I wanted a language that was
linkable with C and didn't require anything else. I basically
wanted C with a clearer type system and a nicer interface to a few
features. Thunks, overloading, and polymorphism didn't fit.
(Although, polymorphism may come through type macros.) After I
finish the design of this language and write a compiler, I'm going
to look at designing a higher-level language. I've come to like
OCaml, but dislike a few hickups (naming especially) and it's
syntax. I think there could be a market for a type-safe language
that could easily link to C and use a conservative garbage
collector.

Mike

Subject: Re: a language to write an OS with ???
From: to*****@diku.dk (Torben Ægidius Mogensen)
Newsgroups: comp.lang.misc

Antti Sykäri <js*****@gamma. hut.fi> writes:

Nowadays it's all too common for language designers to design high
level, garbage-collected, object-oriented, bigger-is-better like
languages (witness C++ since addition of multiple inheritance and
exception specifications, Java, C#, and now D). To strive for an
efficient, clean, and "light-weight" language -- a language that would
be just appropriate to create a modern operating system in -- doesn't
seem to be very fashionable.


I wouldn't say that there is less interest in designing such
languages, I would rater say that the "market" for such languages is
more entrenched than for higher-level languages, especially scripting
languages. One reason may be that an OS is a major undertaking and
likely to be in use for a long time. So OS writers want a language
that they know will be around for a long while and which will be
ported to a large range of platforms (allowing their OS to do the
same).
My own hobby language is about creating a better C/C++, with cleaner
syntax, more extensibility, more transparency, better metaprogramming
facilities and ultimately, the ability to go as close to the hardware
as possible when needed. (Yes, it's likely to be a long road.)

In essence, it's about taking C and evolving it in the same direction
as C++ did, emphasizing the "what you don't use, you don't pay for"
rule and paying less attention to backwards compatibility.


In designing a C replacement, I wouldn't start from C. Even without
the C++ additions etc., C is a horrible language, with highly
complicated and somewhat ambiguous syntax, underspecified semantics
and lacking in features necessary for OS writing (such as jumping
through a pointer).

What I would do was (among other things):

- Have well-defined syntax and semantics.

- Ensure that the sizes of all types are specified by the language,
so it would, e.g., be explicit if an integer or pointer is 32 or 64
bits long. Memory layout would also be explicit, so big-endian or
little-endian numbers and strings would have explicitly different
types (and both would be present).

- Make it explicit in the type of a pointer if it can be null.

- Make it explicit in the type of a value if it can be modified after
creation and initialization. Integrate creation and
initialization.

- Allow pointer-arithmetic only on pointers to arrays. Doing it on
other pointers should give type errors. You can have fields
offsets and such, and they can even be negative (a record/struct
pointer type can specify to which field the pointer points). Allow
all/several components of a record to be accessed at once, using a
kind of pattern-matching.

- Have no implicit casts, even between integer sizes.

- Have parametric polymorphism, implemented by
replication/specialization.

- Overloading via (Haskell-style) type classes, not by ad-hoc
overloading or OO-style virtual methods.

- Have type-safe closures/thunks.

- Allow programmer to specify pointer to address at which a record,
array or other structure is built. Issue compile-time warning if
the type of the pointer does not ensure sufficient space.

- Allow compile-time warnings to be supressed individually, but not
en-masse. I.e., when the programmer gets a warning, he can check
if there really is a problem, and if not insert an assertion at the
relevant place in the code to supress the warning.

- Drop macros and instead require the compiler to inline definitions
that are marked as such.

Torben

Nov 14 '05 #22

"Michael Nahas" <mi************ ***@deletethis. com> wrote in message news:dN5yc.1086 6
What I would do was (among other things):

- Have well-defined syntax and semantics.

- Ensure that the sizes of all types are specified by the language,
so it would, e.g., be explicit if an integer or pointer is 32 or 64
bits long. Memory layout would also be explicit, so big-endian or
little-endian numbers and strings would have explicitly different
types (and both would be present).


I'm curious as to how you would handle these explicitly defined integers on a 36-bit
machine with 9-bit bytes as I'm having to deal with these questions myself. Explicit is
good in being repeatable but it is not necessarily fast. ANSI C defines arithmetic and
logical operations on integers and explicitly allows some operations to be implementation
defined. In other words all C integer operations are fast, most are the same on all
architectures (eg shifting a small positive integer), and some are to be avoided on
transportable code - at least within defined parameters.

What would you do on machines using 1's complement representation? You could put tests
around the code manipulating these but that would result in a performance hit. C avoids
this by calling shifts and suchlike on negative integers implementation defined. Have you
a fast way to avoid all such uncertainties? (To quote K&R C 2nd Ed sec 2.9, "Right
shifting a signed quantity will fill with sign bits ... on some machines and with 0-bits
.... on others.")

Also, would not explicitly stating whether an integer is to be stored as little-endian or
big-endian cause a massive performance hit on a machine for which that was not the native
format, eg. PowerPC supports both, IIRC, but Intel doesn't support big-endian. I think the
PDP architecture uses a mixed-endian representation of 4-byte ints.

--
Cheers,
James
Nov 14 '05 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

49
2876
by: Ville Vainio | last post by:
I don't know if you have seen this before, but here goes: http://text.userlinux.com/white_paper.html There is a jab at Python, though, mentioning that Ruby is more "refined". -- Ville Vainio http://www.students.tut.fi/~vainio24
105
5211
by: Peter Hickman | last post by:
Well after all this discussion it would appear that a 'Python like' language has appeared => Prothon. http://www.prothon.org/index.html Very alpha, sort of like Python (if you consider the indenting is what makes Python unique) and sort of Ruby in its use of prefixes to define scoping etc (although there is no reference to this trait being borrowed from Ruby). It also quotes Self as being an influence.
7
1884
by: Erwin Moller | last post by:
Hi group, I am a bit cconfused with the different tags I encounter to start a script. I used to use: language="Javascript" Nowadays I use: type="text/javascript" I did see some javascript1.2 (i think) too, but never used that. But when I let my favorite editor (Eclipse) do some codecompletion I get:
4
2002
by: David Pratt | last post by:
Hi. Is anyone aware of any python based unacceptable language filter code to scan and detect bad language in text from uploads etc. Many thanks. David
134
8047
by: evolnet.regular | last post by:
I've been utilising C for lots of small and a few medium-sized personal projects over the course of the past decade, and I've realised lately just how little progress it's made since then. I've increasingly been using scripting languages (especially Python and Bourne shell) which offer the same speed and yet are far more simple and safe to use. I can no longer understand why anyone would willingly use C to program anything but the lowest...
5
2194
by: Hannes Schmiderer | last post by:
We have to support different languages in our application. We do not want to compile the whole application if anything changes in the text of the pages. With satellite assemblies this is possible easily. We change the .resx XML-resource-file, run resgen.exe and al.exe and we have a new dll. But how is this possible with the neutral/default/fallback language resource which is integrated in the main assembly?
2
1354
by: Sandy | last post by:
Anyone have suggestions regarding a third-party tool that can filter out obscene language . . . or is it best to construct your own? Doesn't seem like it would be too difficult, although I'm not sure my obscenities vocabulary can imagine all of the possibilities. Any advice will be appreciated! -- Sandy
2
1176
by: Chance Ginger | last post by:
I am rather new at Python so I want to get it right. What I am doing is writing a rather large application with plenty of places that strings will be used. Most of the strings involve statements of one kind or another. I would like to make it easy for the support people to port the application from one language to another, German, Spanish, etc. Rather than make them search all over for the strings to replace is there a library that I...
3
9111
by: nickyeng | last post by:
i was wondering how to replace a word in a line. i search in google.com and thescipts.com, i hardly to find what i want. for example this line, "I like his daughter" replace his with "her".
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9522
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10443
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10216
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9044
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7543
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3728
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.