The C Killer

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
Pesto
Posts: 737
Joined: Wed Sep 05, 2007 5:33 pm UTC
Location: Berkeley, CA

The C Killer

Postby Pesto » Wed Aug 25, 2010 1:13 am UTC

Okay, it's time. Time for the old guard to retire and for us all to step into the 21st century. It's time to replace C.

If we were to design a new language from the ground up to fill the same niche as C, how would you like it to look?
What would you want it to be able to do?
What kinds of features could it not have, as those features would remove it from the C-ish niche?
What languages would you borrow from?

bieber
Posts: 223
Joined: Thu Mar 13, 2008 12:13 am UTC

Re: The C Killer

Postby bieber » Wed Aug 25, 2010 1:33 am UTC

I dunno, my ideal C-esque language pretty much is C. I'd definitely want to add some of the nicer features from C++, like exceptions, new/delete, and a couple more, but you can already use C++ and just write C code with a couple of extra features. I can't really think of any pressing reason that I'd want to change the syntax...is there something big I'm missing? C just seems like a language that's gonna be with us for a long time..

kmatzen
Posts: 214
Joined: Thu Nov 15, 2007 2:55 pm UTC
Location: Ithaca, NY

Re: The C Killer

Postby kmatzen » Wed Aug 25, 2010 3:37 am UTC

bieber wrote:I dunno, my ideal C-esque language pretty much is C. I'd definitely want to add some of the nicer features from C++, like exceptions, new/delete, and a couple more, but you can already use C++ and just write C code with a couple of extra features. I can't really think of any pressing reason that I'd want to change the syntax...is there something big I'm missing? C just seems like a language that's gonna be with us for a long time..


C is what it is and it does it's job nicely. It's just an abstraction layer above assembly. If you want anything more, then you don't want just an abstraction layer above assembly and that's a different thing.

Unless you wanted to approach the C thing from a fresh angle and eliminate the backwards compatibility stuff or things that modern compilers can detect and currently only issue warnings for. Things like omitting a return value, omitting a return type, omitting a parameter list in the declaration, etc. All things that probably are sane to require in modern code, but aren't required since the compiler has to support legacy code.

stephentyrone
Posts: 778
Joined: Mon Aug 11, 2008 10:58 pm UTC
Location: Palo Alto, CA

Re: The C Killer

Postby stephentyrone » Wed Aug 25, 2010 4:21 am UTC

Pesto wrote:Okay, it's time. Time for the old guard to retire and for us all to step into the 21st century. It's time to replace C.


There is a replacement for C -- the C1x draft standard. C is a beautiful language, and it isn't going away any time soon; I expect C to outlive any hip "modern" language out there. Keep your fads, I'll use what works.
GENERATION -16 + 31i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

User avatar
MHD
Posts: 630
Joined: Fri Mar 20, 2009 8:21 pm UTC
Location: Denmark

Re: The C Killer

Postby MHD » Wed Aug 25, 2010 5:42 am UTC

I'd like something that is a little more elegant and python-esque in the syntax. Actually I think I'll just go write a translator.
EvanED wrote:be aware that when most people say "regular expression" they really mean "something that is almost, but not quite, entirely unlike a regular expression"

User avatar
Zamfir
I built a novelty castle, the irony was lost on some.
Posts: 7602
Joined: Wed Aug 27, 2008 2:43 pm UTC
Location: Nederland

Re: The C Killer

Postby Zamfir » Wed Aug 25, 2010 7:40 am UTC

MHD wrote:I'd like something that is a little more elegant and python-esque in the syntax. Actually I think I'll just go write a translator.


Are you sure that with strong typing python would still look elegant?

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: The C Killer

Postby TheChewanater » Wed Aug 25, 2010 8:10 am UTC

C++ is the C killer. Except, it just kind of missed and wounded C. C couldn't defend itself because it kept shooting itself in the foot.
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

User avatar
Sc4Freak
Posts: 673
Joined: Thu Jul 12, 2007 4:50 am UTC
Location: Redmond, Washington

Re: The C Killer

Postby Sc4Freak » Wed Aug 25, 2010 8:31 am UTC

TBH I think there are few reasons why you'd ever use C over C++. I can only think of a few:

1) You're writing an OS kernel where most of C++'s features would be unavailable anyway (or other similar situations, like microcode)
2) You only have C programmers on hand and can't hire/train C++ programmers
3) You have an existing codebase written in C which would be prohibitively expensive to convert

In basically any other situation you'd be better off using C++. There's nothing that says you have to use all the advanced features of C++. After all, you can just use C++ to write better C.

User avatar
thoughtfully
Posts: 2253
Joined: Thu Nov 01, 2007 12:25 am UTC
Location: Minneapolis, MN
Contact:

Re: The C Killer

Postby thoughtfully » Wed Aug 25, 2010 12:36 pm UTC

Zamfir wrote:
MHD wrote:I'd like something that is a little more elegant and python-esque in the syntax. Actually I think I'll just go write a translator.


Are you sure that with strong typing python would still look elegant?

There's Pyrex for a statically typed Python, and C# for a C that's got some Pythonic elements. Or D.
Image
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

User avatar
Zamfir
I built a novelty castle, the irony was lost on some.
Posts: 7602
Joined: Wed Aug 27, 2008 2:43 pm UTC
Location: Nederland

Re: The C Killer

Postby Zamfir » Wed Aug 25, 2010 1:18 pm UTC

thoughtfully wrote:
Zamfir wrote:
MHD wrote:I'd like something that is a little more elegant and python-esque in the syntax. Actually I think I'll just go write a translator.


Are you sure that with strong typing python would still look elegant?

There's Pyrex for a statically typed Python, and C# for a C that's got some Pythonic elements. Or D.

I haven't used Pyrex myself, so I can't really judge if it really would work as alternative to C.

Or more precisely, if someone would really turn Pyrex into C-with-Pythonesque syntax, I am not sure it would look pretty anymore. Having type definitions already clutters a bit more than "pythonesque elegant". Add more pointer stuff and manual memory management, and I doubt it would look much cleaner than actual C code.

C# feels to me more like Java-with-C-syntax than Python-with-C-syntax. Is it really more Pythonesque than Java itself?

User avatar
Cleverbeans
Posts: 1378
Joined: Wed Mar 26, 2008 1:16 pm UTC

Re: The C Killer

Postby Cleverbeans » Wed Aug 25, 2010 2:04 pm UTC

Zamfir wrote:C# feels to me more like Java-with-C-syntax than Python-with-C-syntax. Is it really more Pythonesque than Java itself?


C# doesn't feel anything like python, it's a Java knockoff with some whistles and annoyances. The main thing I like about Python is the central role played by tuples, lists, dictionaries, and sets, as well as the ability to write non-object oriented code.

As for a C killer, the only issues I have with the C variants right now is the syntax. If I have to replace it, I'd prefer something more Pythonic or LISPish. Something graphical like Manufactoria would be sweet too since state machines make such pretty graphs. ;)
"Labor is prior to, and independent of, capital. Capital is only the fruit of labor, and could never have existed if labor had not first existed. Labor is the superior of capital, and deserves much the higher consideration." - Abraham Lincoln

User avatar
Zamfir
I built a novelty castle, the irony was lost on some.
Posts: 7602
Joined: Wed Aug 27, 2008 2:43 pm UTC
Location: Nederland

Re: The C Killer

Postby Zamfir » Wed Aug 25, 2010 2:24 pm UTC

Cleverbeans wrote:
Zamfir wrote:C# feels to me more like Java-with-C-syntax than Python-with-C-syntax. Is it really more Pythonesque than Java itself?


C# doesn't feel anything like python, it's a Java knockoff with some whistles and annoyances. The main thing I like about Python is the central role played by tuples, lists, dictionaries, and sets, as well as the ability to write non-object oriented code.


Actually, C# does lists and dictionaries pretty well, and I think it they do sets and tuples too nowadays (but I have no idea whether they are nice to work with). I guess that would be an area where they really did make it more pythonesque than Java, in a good way too.

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5101
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: The C Killer

Postby Xeio » Wed Aug 25, 2010 4:05 pm UTC

Zamfir wrote:Actually, C# does lists and dictionaries pretty well, and I think it they do sets and tuples too nowadays (but I have no idea whether they are nice to work with). I guess that would be an area where they really did make it more pythonesque than Java, in a good way too.
As far as I'm aware, C# doesn't do tuples, though lambdas can sort of take input like that...?

Everything else it does well (I suppose you can't technically break OO, though that's mostly because everything must be contained in a class, static or not, but you can still basically write procedural code).

User avatar
hotaru
Posts: 1045
Joined: Fri Apr 13, 2007 6:54 pm UTC

Re: The C Killer

Postby hotaru » Wed Aug 25, 2010 5:28 pm UTC

Cleverbeans wrote:C# doesn't feel anything like python, it's a Java knockoff with some whistles and annoyances. The main thing I like about Python is the central role played by tuples, lists, dictionaries, and sets, as well as the ability to write non-object oriented code.

yeah... lists, dictionaries, lambda expressions, list comprehensions (LINQ), and generators are more like java than python.

Code: Select all

factorial product enumFromTo 1
isPrime n 
factorial (1) `mod== 1

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: The C Killer

Postby TheChewanater » Wed Aug 25, 2010 6:25 pm UTC

I think Vala has a good shot of killing C.

It:
    Has bindings for a ton of C libraries, and more can be made easily.
    Uses familiar C and C++ conventions.
    Has a Java/C#-like syntax.
    Has a Python-like syntax.
    Compiles to C code, which can build on a variety of platforms that have Glib.
    Has some of the best features of other modern languages, like lambdas, reference counting, object orientation, etc...
    Comes with libraries for GUIs and graphics and more
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

stephentyrone
Posts: 778
Joined: Mon Aug 11, 2008 10:58 pm UTC
Location: Palo Alto, CA

Re: The C Killer

Postby stephentyrone » Wed Aug 25, 2010 6:57 pm UTC

TheChewanater wrote:Compiles to C code, which can build on a variety of platforms that have Glib.


A language that is intended to compile to C is extremely unlikely to kill C. It depends on C for it's implementation, and will lag behind as C adds new features (even C++ lags severely behind C with regard to certain features).

Vala looks like yet another thin object layer on C with some nice features, which is an idea that's about as old as C is. (Objective-C hasn't killed C yet, despite having been around for ~25 years)
GENERATION -16 + 31i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: The C Killer

Postby TheChewanater » Wed Aug 25, 2010 7:41 pm UTC

stephentyrone wrote:
TheChewanater wrote:Compiles to C code, which can build on a variety of platforms that have Glib.


A language that is intended to compile to C is extremely unlikely to kill C. It depends on C for it's implementation, and will lag behind as C adds new features (even C++ lags severely behind C with regard to certain features).

Vala looks like yet another thin object layer on C with some nice features, which is an idea that's about as old as C is. (Objective-C hasn't killed C yet, despite having been around for ~25 years)

Well, you don't need to know C or even touch it to use Vala. It automatically compiles the C code unless you tell it not to, just like a C compiler assembles the assembly code. C++ was originally intended to compile to C, and it's doing pretty well.

I think Objective-C is unable to fill the same niche as C because it adds so much new syntax, while Vala borrows a lot of its syntax for C++ and C# and Java (and Python).
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

stephentyrone
Posts: 778
Joined: Mon Aug 11, 2008 10:58 pm UTC
Location: Palo Alto, CA

Re: The C Killer

Postby stephentyrone » Wed Aug 25, 2010 7:51 pm UTC

TheChewanater wrote:I think Objective-C is unable to fill the same niche as C because it adds so much new syntax, while Vala borrows a lot of its syntax for C++ and C# and Java (and Python).


Objective-C adds almost no new syntax to C. One keyword, and a syntax for method declaration and calling. Any C program (that doesn't use the one extra keyword) is a valid Objective-C program. Vala, by contrast, looks totally foreign to me as an experienced C programmer.

C++ was originally intended to compile to C, and it's doing pretty well.


It's doing pretty well in the domain of application programming, but most applications never really should have been written in C to start with. Systems programmers, by and large, continue to use C (and assembly), which is the domain to which it is naturally suited.

Personally, I would argue that a large portion of the application programming done in C++ would be better done in higher-level languages, and that C++ is stuck in a sort of no-man's-land of being too abstract for low-level systems use and not abstract enough for general purpose programming. However, I know that some people really like C++, and in competent hands it's actually a beautiful language, so I won't complain too much.
Last edited by stephentyrone on Wed Aug 25, 2010 7:56 pm UTC, edited 1 time in total.
GENERATION -16 + 31i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

User avatar
Pesto
Posts: 737
Joined: Wed Sep 05, 2007 5:33 pm UTC
Location: Berkeley, CA

Re: The C Killer

Postby Pesto » Wed Aug 25, 2010 7:56 pm UTC

kmatzen wrote:C is what it is and it does it's job nicely. It's just an abstraction layer above assembly. If you want anything more, then you don't want just an abstraction layer above assembly and that's a different thing.
stephentyrone wrote:There is a replacement for C -- the C1x draft standard. C is a beautiful language, and it isn't going away any time soon; I expect C to outlive any hip "modern" language out there. Keep your fads, I'll use what works.

I love C, but I love it like an the dog you've had for twenty years who now has kidney problems. Sometimes the best thing to do is to have it put down and get a puppy.

Unless you wanted to approach the C thing from a fresh angle and eliminate the backwards compatibility stuff or things that modern compilers can detect and currently only issue warnings for. Things like omitting a return value, omitting a return type, omitting a parameter list in the declaration, etc. All things that probably are sane to require in modern code, but aren't required since the compiler has to support legacy code.

Yes, these are excellent examples.

Here's my wish list off the top of my head.

Variable sizes should be consistent across platforms. There should be a one-byte integer, a two-byte integer, a four-byte integer, etc. I realize some oddball systems have strange sized bit arrays, but 2n-byte size data types are so ubiquitous that they should be built in. Pehaps there can be some special syntax to deal with bit arrays, or you just drop into assembly.

Adopt Haskell's typing system. The 1-, 2-, 4-, and 8-byte integers only differ in size. Every action that is legal for one will be legal for the other. We should be able to define functions that take generic types. Take this function in C, for example.

Code: Select all

int foo(int a, int b)

If you want to implement foo for different sizes of integers, you need to do something like this.

Code: Select all

char foo8(char a, char b)
short int foo16(short int a, short int b)
long int foo32(long int a, long int b)
long long int foo64(long long int a, long long int b)

We should instead be able to define a function that takes two ints of a given size, and returns an int of the same size. Breaking this out into functions for each specific type used can be done automatically at compile time.

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: The C Killer

Postby TheChewanater » Wed Aug 25, 2010 8:00 pm UTC

stephentyrone wrote:
TheChewanater wrote:I think Objective-C is unable to fill the same niche as C because it adds so much new syntax, while Vala borrows a lot of its syntax for C++ and C# and Java (and Python).


Objective-C adds almost no new syntax to C. One keyword, and a syntax for method declaration and calling. Any C program (that doesn't use the one extra keyword) is a valid Objective-C program. Vala, by contrast, looks totally foreign to me as an experienced C programmer.

To an Obj-C programmer (and compiler), C looks alright. But to a C programmer, Obj-C looks foreign. What the hell is this?
Spoiler:

Code: Select all

@implementation classname
+classMethod {
    // implementation
}
-instanceMethod {
    // implementation
}
@end

Vala looks natural to anyone who knows C++, C#, Java, or Python, and not that different for a C programmer.
It's doing pretty well in the domain of application programming, but most applications never really should have been written in C to start with. Systems programmers, by and large, continue to use C (and assembly), which is the domain to which it is naturally suited.

True, I guess. But we're discussing what could kill C, not why C should already be dead in mainstream programming.
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

User avatar
Pesto
Posts: 737
Joined: Wed Sep 05, 2007 5:33 pm UTC
Location: Berkeley, CA

Re: The C Killer

Postby Pesto » Wed Aug 25, 2010 8:06 pm UTC

TheChewanater wrote:But we're discussing what could kill C

Just to be clear, I made the thread title provocative to generate discussion. Nothing will actually kill C. Just like all that COBOL that's grinding away somewhere, C is going to be around for ever. I'm just trying to brainstorm about the next evolution of systems programming.

stephentyrone
Posts: 778
Joined: Mon Aug 11, 2008 10:58 pm UTC
Location: Palo Alto, CA

Re: The C Killer

Postby stephentyrone » Wed Aug 25, 2010 8:09 pm UTC

Pesto wrote:Variable sizes should be consistent across platforms. There should be a one-byte integer, a two-byte integer, a four-byte integer, etc. I realize some oddball systems have strange sized bit arrays, but 2n-byte size data types are so ubiquitous that they should be built in. Pehaps there can be some special syntax to deal with bit arrays, or you just drop into assembly.


Code: Select all

#include <stdint.h>


Adopt Haskell's typing system. The 1-, 2-, 4-, and 8-byte integers only differ in size. Every action that is legal for one will be legal for the other. We should be able to define functions that take generic types.


There are compiler-specific ways to do what you describe (there need to be, to satisfy the requirements of the standard with regard to the <tgmath.h> header). I agree that standardizing a means to do this without requiring extensive macro-fu or use of compiler-specific features would be a very nice improvement, but it's a change that can easily be accomplished within the bounds of the C language revision process. A whole new language certainly isn't needed.

TheChewanater wrote:To an Obj-C programmer (and compiler), C looks alright. But to a C programmer, Obj-C looks foreign. What the hell is this?
Spoiler:

Code: Select all

@implementation classname
+classMethod {
    // implementation
}
-instanceMethod {
    // implementation
}
@end

Vala looks ... not that different for a C programmer.


You picked one of the two extensions to the C syntax. Vala looks equally foreign (or worse) to a C programmer. What the hell is this?
Spoiler:

Code: Select all

public class className : someSuperClass {
    public static int classMethod( ) {
        // implementation
    }
    public int instanceMethod( ) {
        // implementation
    }
}

Not only have you gone and added bunch of keywords, you've added an operator and overloaded the keyword static. You think that this is somehow looks less foreign than Objective-C? Only because you already know C++/Java/C#. To a C programmer, they're equally foreign. Objective-C is easier, if anything, because it doesn't change the meaning of anything; it just adds a couple bits of syntax.

(Note: neither one is actually hard to understand as long as the reader isn't a moron. There's no accounting for morons, and they're going to screw up in whatever programming language you hand them.)
GENERATION -16 + 31i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

User avatar
Pesto
Posts: 737
Joined: Wed Sep 05, 2007 5:33 pm UTC
Location: Berkeley, CA

Re: The C Killer

Postby Pesto » Wed Aug 25, 2010 8:27 pm UTC

stephentyrone wrote:A whole new language certainly isn't needed.

Maybe, maybe not. After doing some reading, I'm not a huge fan of having the string format be part of the language. I don't know how you'd change that without a new language. There are other low-level alternatives to C strings. If you're writing code at the same level as C, and you have to deal with strings, I'd like to see more flexibility in the underlying data structure, not to mention encoding. As it is, C gives you a 0x00 terminated array of bytes, then says, "And you'll like it!"

Unfortunately, I don't have any concrete ideas on how to fix this, yet.

Edit: Another thing that really bugs me. Includes!

Code: Select all

#include "foo.h"
#include <bar.h>

Why do we only get two options on where to include files from? Two! That's it!* What's wrong with being able to define these things with more granularity?

*Yeah, yeah, each searches a list of directories. Not good enough, I say.
Last edited by Pesto on Wed Aug 25, 2010 8:31 pm UTC, edited 1 time in total.

stephentyrone
Posts: 778
Joined: Mon Aug 11, 2008 10:58 pm UTC
Location: Palo Alto, CA

Re: The C Killer

Postby stephentyrone » Wed Aug 25, 2010 8:29 pm UTC

Pesto wrote:
stephentyrone wrote:A whole new language certainly isn't needed.

Maybe, maybe not. After doing some reading, I'm not a huge fan of having the string format be part of the language. I don't know how you'd change that without a new language. There are other low-level alternatives to C strings. If you're writing code at the same level as C, and you have to deal with strings, I'd like to see more flexibility in the underlying data structure, not to mention encoding. As it is, C gives you a 0x00 terminated array of bytes, then says, "And you'll like it!"

Unfortunately, I don't have any concrete ideas on how to fix this, yet.


You can write a string library that uses any format you want. Now use it in your programs. As far as you can tell, the string format is no longer part of the language. Ta-dah!

Why do we only get two options on where to include files from? Two! That's it!* What's wrong with being able to define these things with more granularity?


Your include directives needn't be bare file names. You can have paths (on most platforms; this is actually implementation-defined. It would be a nice change to standardize this, but it's very very hard to do so in a portable fully generic fashion).
GENERATION -16 + 31i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: The C Killer

Postby TheChewanater » Wed Aug 25, 2010 8:38 pm UTC

stephentyrone wrote:Not only have you gone and added bunch of keywords, you've added an operator and overloaded the keyword static. You think that this is somehow looks less foreign than Objective-C? Only because you already know C++/Java/C#.

Okay, fine. It's a C++/Java/C#/Python killer.
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

User avatar
Pesto
Posts: 737
Joined: Wed Sep 05, 2007 5:33 pm UTC
Location: Berkeley, CA

Re: The C Killer

Postby Pesto » Wed Aug 25, 2010 9:03 pm UTC

stephentyrone wrote:You can write a string library that uses any format you want. Now use it in your programs. As far as you can tell, the string format is no longer part of the language. Ta-dah!

That is just retrofitting a broken system. I'm looking for language constructs to make low level string handling easier and more flexible.

qbg
Posts: 586
Joined: Tue Dec 18, 2007 3:37 pm UTC

Re: The C Killer

Postby qbg » Thu Aug 26, 2010 12:20 am UTC

It is built on top of a powerful lisp. Stage 1 of compilation is compiling the lisp source. There are some IR forms that when compiled generates IR and is collected for stage 2. There is a large library of macros and functions that provide useful abstraction over the IR forms, like defining functions, loops, pattern matching data, etc. Type inferencing is performed in many of these macros. The type system is designed to protect the semantic understanding of values and for code generation, but there are many operations that can reinterpret data for various purposes. During stage 2, the compile takes the collected IR and applies optimizations to it and eventually produces lean object code that can then be linked to produce the executable.

In short, a language that the programmer powerful tools to neatly express their intention, going beyond what standard C allows. (The language is for language implementers)

User avatar
Pesto
Posts: 737
Joined: Wed Sep 05, 2007 5:33 pm UTC
Location: Berkeley, CA

Re: The C Killer

Postby Pesto » Thu Aug 26, 2010 4:20 am UTC

I see C as more of an OS language, not a language implementation language.

Edit: It would be nice to have a multi-level break and continue. That would work well as an extension to C.

User avatar
Thesh
Made to Fuck Dinosaurs
Posts: 6598
Joined: Tue Jan 12, 2010 1:55 am UTC
Location: Colorado

Re: The C Killer

Postby Thesh » Fri Aug 27, 2010 4:52 am UTC

There are some things I would change with C:

1) Make all primitive types system independent
2) Add a new type of pointers which have ownership, and automatically free memory when they go out of scope
3) Add function overloading
4) Add simple classes by extending structures to allow methods, constructors, and destructors (RAII)
5) Exception Handling
6) I hate the dereference operator, it's just so damned ugly. Find an alternative. Also, why not just make the dot operator dereference pointers instead of having a separate arrow operator?
7) A standard library which covers just enough that most third party libraries and their dependencies can be written on top of it without getting into non-portable code
9) in switches, make it so that omitting a break causes a compiler error, and if you want to fall through you specifically have to write continue.

Of course, the more I write, the closer I will get to C++. As has already been said, for the most part there is no reason not to just use C++. What most programmers that don't like C++ seem to want is a good alternative to C++ and not a replacement for C.
Summum ius, summa iniuria.

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: The C Killer

Postby TheChewanater » Fri Aug 27, 2010 5:24 am UTC

Thesh wrote:9) in switches, make it so that omitting a break causes a compiler error, and if you want to fall through you specifically have to write continue.

That sounds redundant. Why not just omit the break and only have a continue if you want to continue?
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

User avatar
'; DROP DATABASE;--
Posts: 3284
Joined: Thu Nov 22, 2007 9:38 am UTC
Location: Midwest Alberta, where it's STILL snowy
Contact:

Re: The C Killer

Postby '; DROP DATABASE;-- » Fri Aug 27, 2010 6:38 am UTC

I would love to see some sort of assembly language that isn't platform-dependent. I don't know HOW, other than all processors using the same bytecode, but it'd be nice.

A hacked-up Lua, with strong typing, integer operations, etc might make a good replacement for low-level C stuff.
poxic wrote:You suck. And simultaneously rock. I think you've invented a new state of being.

User avatar
hotaru
Posts: 1045
Joined: Fri Apr 13, 2007 6:54 pm UTC

Re: The C Killer

Postby hotaru » Fri Aug 27, 2010 7:30 am UTC

'; DROP DATABASE;-- wrote:I would love to see some sort of assembly language that isn't platform-dependent. I don't know HOW, other than all processors using the same bytecode, but it'd be nice.

there are things like ilasm (mono, microsoft), inferno's asm, smali, and jasmin...

Code: Select all

factorial product enumFromTo 1
isPrime n 
factorial (1) `mod== 1

Carnildo
Posts: 2023
Joined: Fri Jul 18, 2008 8:43 am UTC

Re: The C Killer

Postby Carnildo » Fri Aug 27, 2010 8:07 am UTC

'; DROP DATABASE;-- wrote:I would love to see some sort of assembly language that isn't platform-dependent.

That was the original point of C.

User avatar
Thesh
Made to Fuck Dinosaurs
Posts: 6598
Joined: Tue Jan 12, 2010 1:55 am UTC
Location: Colorado

Re: The C Killer

Postby Thesh » Fri Aug 27, 2010 6:06 pm UTC

TheChewanater wrote:
Thesh wrote:9) in switches, make it so that omitting a break causes a compiler error, and if you want to fall through you specifically have to write continue.

That sounds redundant. Why not just omit the break and only have a continue if you want to continue?


Sorry, poorly worded. I meant you have to have one or the other, and not having one causes a compiler error.
Summum ius, summa iniuria.

cogman
Posts: 112
Joined: Sun May 18, 2008 2:17 pm UTC

Re: The C Killer

Postby cogman » Fri Aug 27, 2010 6:47 pm UTC

Honestly, I would only change a few things with C rather then replace it all together.

For one, I would make threading easier/a built in feature. When the standard C library was written, multithreading wasn't a big deal. Now, it is the way forward. How would I do this? I don't know, something like being able to say

SomeFunction(Value).asThread();

Would be really nice as the threading libraries have so many parameters to memorize and just feel clunky.

On a similar note, something like

variable.lock()
variable.unlock()

would also be nice.

User avatar
thoughtfully
Posts: 2253
Joined: Thu Nov 01, 2007 12:25 am UTC
Location: Minneapolis, MN
Contact:

Re: The C Killer

Postby thoughtfully » Fri Aug 27, 2010 7:32 pm UTC

cogman wrote:For one, I would make threading easier/a built in feature. When the standard C library was written, multithreading wasn't a big deal.


This is one of the features of Google's C killer, which, curiously, nobody's mentioned.
Image
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

User avatar
Xeio
Friends, Faidites, Countrymen
Posts: 5101
Joined: Wed Jul 25, 2007 11:12 am UTC
Location: C:\Users\Xeio\
Contact:

Re: The C Killer

Postby Xeio » Fri Aug 27, 2010 7:42 pm UTC

thoughtfully wrote:
cogman wrote:For one, I would make threading easier/a built in feature. When the standard C library was written, multithreading wasn't a big deal.


This is one of the features of Google's C killer, which, curiously, nobody's mentioned.

Code: Select all

func main() {
20        flag.Parse()   // Scans the arg list and sets up flags
21        var s string = ""
22        for i := 0; i < flag.NArg(); i++ {
23            if i > 0 {
24                s += Space
25            }
26            s += flag.Arg(i)
27        }
28        if !*omitNewline {
29            s += Newline
30        }
31        os.Stdout.WriteString(s)
32    }
Things I hate about that:
Var, why is it there? What does it do other than needlessly add a keyword? I can only assume something about making writing the compiler easier?
The for loop... eh... I like parens, same for the if statement, parens seem to give it a nice little box. :?
I assume "i"'s type is inferred, which is good, you'd think they could do that in other places though...

Oh well, at least it isn't whitespace significant. I really wish it had C#'s get/set syntax too...

bieber
Posts: 223
Joined: Thu Mar 13, 2008 12:13 am UTC

Re: The C Killer

Postby bieber » Fri Aug 27, 2010 7:45 pm UTC

Xeio wrote:
thoughtfully wrote:
cogman wrote:Oh well, at least it isn't whitespace significant. I really wish it had C#'s get/set syntax too...


Actually, it seems that it is to an extent, because of the way the compiler auto-inserts semicolons (there may be a way to turn that off, I'm just getting this from skimming the Go page). If you put the opening brace of a control structure on the next line then the compiler automatically inserts a semi-colon before the brace, which of course screws everything up :/

stephentyrone
Posts: 778
Joined: Mon Aug 11, 2008 10:58 pm UTC
Location: Palo Alto, CA

Re: The C Killer

Postby stephentyrone » Fri Aug 27, 2010 8:53 pm UTC

cogman wrote:For one, I would make threading easier/a built in feature. When the standard C library was written, multithreading wasn't a big deal. Now, it is the way forward. How would I do this? I don't know, something like being able to say

SomeFunction(Value).asThread();


With blocks (a small C extension) and libdispatch:

Code: Select all

dispatch_async(WorkQueue, ^{ SomeFunction(Value); });

I think this is actually much cleaner because it lets you think about synchronous vs. asynchronous execution and dependencies instead of specific threads and locks (most of the time).
GENERATION -16 + 31i: The first time you see this, copy it into your sig on any forum. Square it, and then add i to the generation.

User avatar
Pesto
Posts: 737
Joined: Wed Sep 05, 2007 5:33 pm UTC
Location: Berkeley, CA

Re: The C Killer

Postby Pesto » Fri Aug 27, 2010 10:01 pm UTC

Xeio wrote:Var, why is it there? What does it do other than needlessly add a keyword? I can only assume something about making writing the compiler easier?

It stops people from naming variables "var" :D


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 6 guests