473,785 Members | 2,768 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 #1
22 2879
Michael Nahas wrote:
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++.)


Great idea!

I think that you should start your own newsgroup

comp.lang.myc

right away. :-)
Nov 14 '05 #2
[fu-t set -- cross-posted articles should have one of these, yours did not]

in comp.lang.c i read:
Antti & all interested,

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

http://nahas.is-a-geek.com/~mike/MyC.pdf Let the flames begin...


okay. it's off-topic. please don't pollute.

--
a signature
Nov 14 '05 #3
In article <dN************ *****@twister.r dc-kc.rr.com>, Michael Nahas wrote:
The draft description of my language to replace C is available at:

http://nahas.is-a-geek.com/~mike/MyC.pdf
I'll give some general impressions first and then proceed to comment on
smaller details.

Firstly, I notice that you have abandoned a lot of C's syntax. May I ask
the reason for that? I've been pondering language design issues for some
time and currently my view is that syntax is as important, if not more
important, than other substance. Ideal syntax is just great for the
coder-in-the-trenches who faces it 8 hours a day, but it also attracts
new programmers that have never seen the language before. And when it
comes to attracting new programmers, nothing is as good a weapon as
familiarity. Syntax that most programmers are familiar resembles C.

Therefore, if I'd make a language, it would definitely have a syntax
that would be quite similar C.

When I first saw the "Hello World" in MyC, I was a bit startled since I
actually expected to see something like C. Instead, there was this:

[Page 2]

const main = fun(int)(argc: int, argv: @@char) {
printg("hello, world\n");
return 0;
}

1) function declaration syntax is different (it has the keyword "fun"
not familiar to a c programmer, and "const" looks odd in a function
declaration, actually reminding of C++'s const member functions)
2) argument list has a pascal-like syntax (argc: int instead of int
argc). Most C programmers hate pascal-like syntax.
3) instead of char* argv[], there's @@char. Probably pointer-to-pointer,
or perhaps array-of-arrays, all right, but this syntax just reminds
of objective-C or some other obscure language.

I strongly suggest taking a look at each of the differences above and
thinking hard whether the value brought by the syntactic outweighs its
cost in familiarity to C programmers.

In fact I was expecting something like:

int main(int argc, char[][] argv) {
print("hello, world\n");
return 0;
}

But well, I think you saw it coming:
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 []
(and how well you said it yourself:)
E.g., "C uses minimal keywords. Your language has two new keywords,
'fun' and 'var', all over the place."
The thing is, people love to invent new syntax. But new syntax has the
downside of steeper learning curve, smaller target audience, and most
importantly the creeping feeling that something isn't just right with
this language. Best language designers take the syntax of a commonly
used language and slip their own language under it, making their target
audience feel as if they were right home.

Now that I finished the syntax rant, I have some actual things to say.

[Page 3]
const main = fun(int)(argc: int, argv: @@char) {
for var fahr = 0; (fahr <= 300) fahr += 20;
// ^--- A missing semicolon here?
printg(.%d\t%d\ n., (&fahr, &(5*(fahr-32)/9)));
return 0;
}

Is this one a typo or are semicolons really not required inside for
loop? Also, I believe you use the banned ";" statement as the main
statement of the for loop instead of "{}".

I really like how MyC unifies structs, tuples, and function arguments.
I'm not sure if it works at all, but it feels somehow good. One thing
that left me wondering, by the way:

[Page 4]

About tuples - it seems that you can have lvalues in them. This means
that every other person tries to use it to swap values like this:

var x int = 1;
var y int = 2;

(x, y) = (y, x);

The question is, whether this will translate into

x = y; y = x;

or

temp_x = x; temp_y = y;
y = temp_x; x = temp_y;

It seems that it would be useful to sometimes leave a value in a tuple
unassigned. Underscore is used in languages with some kind of
unification:

(x, _) = swap(2, 3); // assign 3 to x, dump 2

[Page 4 again]
Note that the value 5 may have type union(char,int) , but
that the value 'e' probably does not, because the lengths would be
different.

I don't understand this - isn't type of value 5 int? (Or int8, or
whatever) Doesn't it depend on the type of the variable it's assigned
to? Clarification please.

[Page 5]

Bool has values 0 (false) and 1 (true) and has a machine-dependent
size.

Wouldn't it be wise to nail down the size of bool, since the sizes of
other basic types have been specified as well? Size of one byte is not
probably a bad one...

switch is the same.

Did you consider fixing switch (that is, making it break by default and
falling through only if specified?)

[Page 6]

I like the integer naming and integer constant syntax. I doubt that
types of non-local endianness are used that often, though, but as they
are straightforward to implement, why not.

Char constants are the same as in C, with the exception \o### is an
octal char value (similar to the newer \x## used for hex). '\0' is
still the nul that terminates strings.

I suppose that binary char should also be \b####? Since you have
0xb#### as well.

Do you mention the type char in section "Types" somewhere? I suppose its
size is 1 and it's unsigned? (Though that doesn't matter, does it...)

Are integer promotions done automatically?

IMHO it would make sense, only conversions that destroy information
should be explicit.

Can you convert between bool and other basic types?

How do you declare an array of constant size?
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++.)


Do you consider them ugly because they complicate the parser, or because
of the First<Second<Th ird<int> > > syndrome? Or "just because"? (Which
would be the reason why I consider syntax "x: int" ugly...)

Java and C# have fixed this so you can now say First<Second<in t>>. I
think.

IMHO <> make a nice syntax, [] is not bad either, () would be OK as
well; the only truly abominable template syntax would be {}.

-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 #4
On Thu, 10 Jun 2004 23:03:37 GMT, Michael Nahas
<mi************ ***@deletethis. com> wrote in comp.lang.c:
Antti & all interested,

The draft description of my language to replace C is available at:
As one other reply already mentions, completely off-topic in
comp.lang.c.

I am a long time C programmer (I read the old testament in 1987)


"long time C programmer" == "1987"???!! !

ROTFLMAO!

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 14 '05 #5

"Jack Klein" <ja*******@spam cop.net> wrote in message
news:5s******** *************** *********@4ax.c om...
On Thu, 10 Jun 2004 23:03:37 GMT, Michael Nahas
<mi************ ***@deletethis. com> wrote in comp.lang.c:
Antti & all interested,

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


As one other reply already mentions, completely off-topic in
comp.lang.c.


I know C.L.C. is about the C language only, but I can't think of a more
appropriate group to discuss a modification of C than in this group. Who
else is going to give better feedback on such a language?
I am a long time C programmer (I read the old testament in 1987)


"long time C programmer" == "1987"???!! !

ROTFLMAO!


I would consider programming a certain language for 17 years pretty long.
Why is this so funny?
Dan
Nov 14 '05 #6
those who know me have no need of my name wrote:

[fu-t set -- cross-posted articles should have one of these,
yours did not]


FYI there was no follow-up set on your article.

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!

Nov 14 '05 #7
[fu-t set]

in comp.lang.c i read:
those who know me have no need of my name wrote:

[fu-t set -- cross-posted articles should have one of these,
yours did not]


FYI there was no follow-up set on your article.


damn. fingers slipped. *sigh*

--
a signature
Nov 14 '05 #8
[fu-t set]

in comp.lang.c i read:
I know C.L.C. is about the C language only, but I can't think of a more
appropriate group to discuss a modification of C than in this group.


if you were interested in modifying c then comp.std.c would be the
appropriate venue. but you aren't doing that, you are making an entirely
new and different language using c as some sort of seed, so neither
comp.lang.c or comp.std.c are appropriate. comp.lang.misc is fine, in fact
it's quite appropriate, but alas you haven't confined your discussions to
that group.

--
a signature
Nov 14 '05 #9
Michael Nahas wrote:
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) [snip] Torben


Why do we need a language to replace C?

C is a fine language, so are C++, Lisp, Java, Fortran,
Basic, Snobol, Pascal, Modula2, Ada, Smalltalk, Logo,
PL/1 (and PL/M), Basic, Ruby, Python, ....

None of these languages is replacing the other. Languages
come about because somebody believes that a new language
is better suited for a set of problems (situations), since
no language is perfect for all applications.

Since your name is not Microsoft, what rights do you have
in inventing a new language to replace another? :-)
{As you can see C# has not replaced C, C++, or Java.}

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.l earn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Nov 14 '05 #10

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

Similar topics

49
2874
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
5205
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
1883
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
8046
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
1353
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
1175
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
9106
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
10325
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
10148
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...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8972
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
7499
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
6740
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
5381
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...
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.