Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Fixing C

Name: Anonymous 2014-04-09 15:55

How to fix C?
What don't you like in C?

I do not like the many useless types while we could just define our own n-bit integer
also a a better typesystem for compile time checking would be nice
I also would like pure functions that I would be able to use outside of functions just like I do in macros

no sageposting allowed

Name: Anonymous 2014-04-09 16:27

You can't force n-bit types because of portability. They are ugly, but they are also the reason C is so common in the first place.

About fixing C, make it a restricted Lisp.

sage

Name: Anonymous 2014-04-09 16:34

>>2
It's true, I couldn't force n-bit types but I could force least n-bit types. This is what I meant

[sub]sage[/sub]
fuck you!

Name: Anonymous 2014-04-09 16:50

Name: Anonymous 2014-04-09 16:55

>>3
It kinda does that already: The default types have ranges they must cover in order to be compliant.

Name: Anonymous 2014-04-09 17:05

I'm gar for Dennis Ritchie.

Name: Anonymous 2014-04-09 17:09

>>5
yes but I can not define an atleast 128 bit variable for example
What if I want a 24bit variable? I can't do it in standard C. The defalt typed are just weird, they do not show their size, is there any portable type that shows that I want to use only 32 bit (except uleast_32_t)? there are many systems where long is 64 bit and since the standard says that int is atleast 16 bit I can not use it. It feels like a waste of memory

>>4
Bloat, horrible and jewzilla

Name: >>7 2014-04-09 17:10

Damn

uleast_32_t
I mean uint_least32_t

typed
I mean types

Name: Anonymous 2014-04-09 17:11

>>7
·zero-cost abstractions
·guaranteed memory safety
·optional garbage collection
·concurrency without data races
·minimal runtime
·efficient FFI

Name: Anonymous 2014-04-09 17:49

>>9
You forgot ``·[b]ENTERPRISE QUALITY[/B]''

Name: >>10 2014-04-09 17:52

Sure, this [b]BBS[/B] Software is shit but is it abelson shit?

Name: Anonymous 2014-04-09 18:04

The variables are going to be aligned to the next multiple of the word size anyway; you won't lose anything by just using a unpacking\packing macro if you absolutely must access by bit. It is more complicated to do arithmetic with, say, two 512 bit numbers, but it gets evaluated in software anyway, so just make it manually.

Name: Anonymous 2014-04-09 18:06

- Add GC
- Make it interpreted
- Remove curly braces
- Force indentation
- Change printf to be a statement instead of a function

Name: Anonymous 2014-04-09 18:10

>>13
Make it interpreted
C can already be interpreted

Add GC
you should change many things to the language to be able to add a non-shitty, non-rc GC

Name: Anonymous 2014-04-09 18:57

I'd fix it like a dog, cut its testicles off.

Name: Anonymous 2014-04-09 20:38

>>15

+1

Name: Anonymous 2014-04-09 20:41

>>16
Upboat
am I shitposting yet?

Name: Anonymous 2014-04-10 5:15

- A real module system instead of the preprocessor.
- Better support for whole program optimization / LTO (requires its own intermediate representation).
- Standard primitives for vector operations.
- getcontext / setcontext instead of setjmp / longjmp.

>>7
What if I want a 24bit variable? I can't do it in standard C.

What machine are you using that provides operations that work on 24 bit integers? If you don't have such a machine, then

#include <stdint.h>

typedef int_least32_t int_least24_t;
typedef uint_least32_t uint_least24_t;
typedef int_fast32_t int_fast24_t;
typedef uint_fast32_t uint_fast24_t;

#define TO_INT24(n) ((n) % (((int_fast24_t) 1) << 24))
#define TO_UINT24(n) ((n) & ~(~((uint_fast24_t) 0) << 24)


If you do have some bizarre machine that works on 24 bit integers, the C compiler for that machine will certainly provide an exact width type that you can use for int24_t and uint24_t.

>>9
Most of those requirements are at odds with each other.

>>13
Python exists.

Name: Anonymous 2014-04-10 5:45

Just make it exactly like Rust is now, except keep the ability to do cross-language libraries easily.

Name: Anonymous 2014-04-10 5:59

>>19
except keep the ability to do cross-language libraries easily

Except this will never happen for any language that tries to standardize much more than structure layout and calling convention. The architecture specific appendices for the SysV ABI alone are tens of pages in length. Language designers love writing their own runtimes and hate compromising their elegant re-inventions to accomodate others. Even if you can pay people to play nice (like Microsoft did with CLR) the resulting standard will need to be modified for every new feature that's above the level of syntactic sugar.

The bottom line is you will always need to write a translation layer to interface code in two languages if said languages weren't designed to interoperate in the first place.

Name: Anonymous 2014-04-10 9:15

scheme jit written in scheme that generates x86 asm.
https://progrider.org/lounge/read/1392406890/5

I now realize this isn't related to this thread. But I'm going to post it anyways. Because I want C to do this too. Although I don't quite understand what I want it to do.

Name: Anonymous 2014-04-10 9:21

>>21
This is actually awesome

Name: Anonymous 2014-04-10 11:12

>>21
So, you want a C compiler written in C that generates x86 asm? Because we've got those.

Name: Anonymous 2014-04-10 13:46

Why do people keep complaining about C's types? It wouldn't make much sense to allow generic n-bit integer types. It would be substantially slower.

Name: Anonymous 2014-04-10 14:02

>>5,24
I don't understand this fixation on integer types either. It clearly can't be founded in a desire to interface with hardware that uses certain size integer types, since (in practice) the provided primitive types map directly to machine operand sizes.

Do lots of people need to be able to parse binary data that uses arbitrary size bitfields? Doing that in C is painful because doing it in machine language is also painful. The solution is to use a library or domain specific language that's intended for that.

Name: Anonymous 2014-04-10 14:05

int, uint, long, unsigned long, long long, unsigned long long, uint8_t, uint16_t, uint32_t, uint64_t

what else do you need?

Name: Anonymous 2014-04-10 14:08

>>26
uint8_t, uint16_t, uint32_t, uint64_t
unportable

int, uint, long, unsigned long, long long, unsigned long long
useless

>>24-25
Nobody understands me ;_;

Name: Anonymous 2014-04-10 21:42

>>27
They're not useless. They make sense for what C is. You can come up with portable solutions if you use the macros INT_MAX, LONG_MAX, etc.

Name: Anonymous 2014-04-10 23:07

>>27
Neither unportable nor useless. Although >>26 has been a bit strict: we may also have [u]intX_least_t and [u]intX_fast_t.

Name: Anonymous 2014-04-10 23:41


#define CONST 0x0
register int1_ffast_t i = CONST

OMG OPTIMIZED

Name: Anonymous 2014-04-10 23:54

>>30
Depends, is it compiled with -funroll-loops?

Name: Anonymous 2014-04-11 2:40

>>27
You've yet to name a situation where you'd want arbitrary exact width integer types.

Name: Anonymous 2014-04-11 3:47

- Add classes
- Add polymorphism
- Add exception handling
- Add semi-managed references
- Add type checking memory allocation constructs
- Add half-assed closures

Name: Anonymous 2014-04-11 6:37

>>33
So basically reinvent C++?

Name: Anonymous 2014-04-11 11:11

Just make it exactly like Java is now, except keep the ability to allocate memory with malloc.

Name: Anonymous 2014-04-11 11:17

>>35
Malloc, eh? Kid, I have a story about malloc.

I once freed a memory I didn't need. Oh, then I just realize I need some data of that memory. Now, instead of removing the freeing part of my code, I'd do something much more exciting.

I knew the malloc implementation we were using managed the memory in LIFO-manner, so basically I could get the same memory back. I just allocate more memory, with exactly the same size the freed buffer was. I'd get that data back. Ingenious!

Heh heh, that code is still in production use. In a software called OpenSSL.

Name: Anonymous 2014-04-11 12:54

>>36
lol'd hard

Name: Anonymous 2014-04-11 15:27

>>32
exact width integer types
I do not care about exact width integer types

Name: Anonymous 2014-04-11 15:33

something like

typedef __int(32) int_least32_t;
typedef __int(24) int_least24_t; /* it's the same as int_least32_t in most systems */

Name: Anonymous 2014-04-11 17:48

/prog/, I'm an expert coder. Please rate my C/C++ codes...


string modify( const string & str )
{
if( str.size() == 0 ) return "00";
if( str.size() == 1 ) return "0" + str;
return string( str.end() - 2, str.end() );
}

string modify4( const string & str )
{
if( str.size() == 0 ) return "0000";
if( str.size() == 1 ) return "000" + str;
if( str.size() == 2 ) return "00" + str;
if( str.size() == 3 ) return "0" + str;
return string( str.end() - 4, str.end() );
}

string TimeISOFormat( time_t cur )
{
char buf[32];
struct tm * timeinfo;
timeinfo = localtime ( &cur );
strftime(buf, 32, "%y", timeinfo);
string year(buf);
strftime(buf, 32, "%m", timeinfo);
string month(buf);
strftime(buf, 32, "%d", timeinfo);
string day(buf);
strftime(buf, 32, "%H", timeinfo);
string hour(buf);
strftime(buf, 32, "%M", timeinfo);
string minute(buf);
strftime(buf, 32, "%S", timeinfo);
string second(buf);
return modify4( year ) + "-" + modify( month ) + "-" + modify( day ) + "T" + modify( hour )+ ":" + modify( minute )+ ":" + modify( second );
}

string CurrentTimeISOFormat()
{
time_t cur = CurrentTime();
char buf[32];
struct tm * timeinfo;
timeinfo = localtime ( &cur );
strftime(buf, 32, "%y", timeinfo);
string year(buf);
strftime(buf, 32, "%m", timeinfo);
string month(buf);
strftime(buf, 32, "%d", timeinfo);
string day(buf);
strftime(buf, 32, "%H", timeinfo);
string hour(buf);
strftime(buf, 32, "%M", timeinfo);
string minute(buf);
strftime(buf, 32, "%S", timeinfo);
string second(buf);
return modify4( year ) + "-" + modify( month ) + "-" + modify( day ) + "T" + modify( hour )+ ":" + modify( minute )+ ":" + modify( second );
}

time_t CurrentTime()
{
time_t rawtime = 0;
time(&rawtime);
return rawtime;
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List