[ / / / / / / / / / / / / / ] [ dir / ask / femdom / hikki / just / newbrit / sonyeon / startrek / sudpol ][Options][ watchlist ]

/tech/ - Technology

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Name
Email
Subject
Comment *
File
Select/drop/paste files here
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

File (hide): 37fc519cadc6b7b⋯.jpeg (106.06 KB, 718x435, 718:435, long cat.jpeg) (h) (u)

[–]

 No.799567>>799569 >>799595 >>799900 >>800477 >>800545 >>800569 [Watch Thread][Show All Posts]

>check catalog

>shit language concept with shit syntax and shit features.

Ok. Time to present a true, non-shitty language. I've called it Z, because it's literally the last language you will ever need.

Syntax

Because novel syntaxes lead to meme write-only languages such as Rust or Haskell, Z is 99% C-like syntax, meaning you can understand and even modify programs written in it without having learned it.

Readability is a must, so special characters are kept to a minimum.

The aim of the language is to truly replace C while at the same time extending its scope and adapting it to $CURRENT_YEAR computing.


function main(int argc, string[] argv) => (int)
{
/* This is a comment! */
int age;
string name;
io.write(stdout, "Hello, world!\n");
io.write(stdout, "What is your name?\n");
name = io.read_line(stdin);
io.write(stdout, "How old are you?\n");
age = io.read_integer(stdin);
io.write(stdout, format("Okay, %s, ", name));
if (age < 18) {
io.write(stdout, "you are underage b&\n");
} else {
io.write(stdout, "you are a mature adult!\n");
}
return 0;
}

Easy to understand, right?

string name;

io.write(stdout, "Hello, world!\n");

io.write(stdout, "What is your name?\n");

name = io.read_line(stdin);

io.write(stdout, "How old are you?\n");

age = io.read_integer(stdin);

io.write(stdout, format("Okay, %s, ", name));

if (age < 18) {

io.write(stdout, "you are underage b&\n");

} else {

io.write(stdout, "you are a mature adult!\n");

}

return 0;

}

[/code]

Easy to understand, right?

 No.799568

File (hide): ac9a9a622ad82d5⋯.jpeg (65.04 KB, 500x500, 1:1, coffin skate.jpeg) (h) (u)

Type system

Strongly typed, all conversions have to be explicit, otherwise it's a compiler error. Basic portable types are:

* byte -- Defined as an integer which is equal to the byte size of the target machine and at least 8 bits.

* char -- Defined as an 8-bits integer. It is the only type to which you can assign characters, and the only one to accept them.

* int -- 32 bits minimum signed integer

* long -- 64 bits minimum signed integer

* float -- IEEE 754 single precision floating point number

* double -- IEEE 754 double precision floating point number

* errno_t -- Holds a POSIX error value

For situations where a bit width has to be defined, basic fixed types are available, based largely on C99 types:

* int8, int16, int32, in64, int128, uint8, uint16, uint32, uint64, uint128

* float32, float64

* hword, word, dword -- integers which depend on the word length of the targeted architecture

* size_t, off_t, ssize_t, clock_t -- equivalent to their C counterparts

Because we can't reinvent the wheel every time, the following compound types (built-in structs) are available:

* string -- consists of a char array and a size_t length. No more

* time_t -- equivalent to its C and Python counterparts, used to work with calendars and such

* socket_t -- time to have proper network support

* file -- does it need an explanation?

* error_t -- we will see more on this later

To work with the size of each variable, the C operator sizeof() is made available.

Up until here, everything is pretty standard, it's pretty much just C. The fun comes next.


 No.799569>>799575

>>799567 (OP)

is it memory safe?

does it have generics?

is the compiler free software?

is it a meme lang? (rhetorical question)


 No.799570>>799576

Functions

Function-level polymorphism is available, and name mangling is defined by the standard (unlike with C++). This means no shit _Generic

as introduced by C11.

The following functions are different:


function foo(int a) => (void);
function foo(float a) => (void);
function foo(string a, int b) => (void);

Nothing spectacular, is there? HOL' UP. Return type is also taken into account for polymorphism. The following is perfectly legal:


function parse(string s) => (float);
function parse(string s) => (int);
function parse(string s) => (time_t);

How do we know when to call one or the other function? This can be inferred at compile-time, of course, and it comes at no

cost since the language is strongly typed.

Pretty cool, isn't it? But HOL' UP. HOL'. UP. There's more! Functions can also return several values.


function convert_coords(int x, int y) => (float, float)
{
return (float)x * 5., (float)y / 5.;
}

Okay, so this gives us a pretty flexible function system. But, does this mean we will end up with a code full of shit like this?


x, error = foo();
if (error) {
return 0, ERROR;
}
y, error = bar();
if (error) {
return -1, ERROR;
}

No! In Z, there is a difference between a function that returns a valid result, and one that fails. How so?


 No.799571>>799572 >>799665

No! In Z, there is a difference between a function that returns a valid result, and one that fails. How so?

Introducing... the keyword "fail", and the global variable "err".


function my_sqrt(float x) => (float)
{
if (x < 0) {
fail;
} else {
return sqrt(x);
}
}
function connect_to_server(void) => (socket_t)
{
socket_t buttnut = io.socket("google.com", 443);
if (err) {
log(ERROR, "Could not open connection to server.");
fail;
} else {
return buttnut;
}
}

The fail; statement is equivalent to a standard return, except it has some more features: it sets the global 'err' value to a valid error value,

and all return values are set to 0/NULL.

At the beginning of every function, 'err' is set to a value meaning "No error has happened."

Okay, okay, okay. Stop right here. A global variable? And what is its type? Won't it also cause a large overhead?

Worry not! It is a global variable, but a per-thread one. This means no concurrency problems! As for the type, it is an error_t variable.

It contains the following fields: errno_t errno, and string errmsg. The errno field hold a value as defined by errno (3),

while the errmsg is a user defined string. By default, with a standard fail instruction, errno is set to EGENERIC, an extension to the

POSIX errors which Z defines as meaning any error. The following syntaxes for the fail; statement are also available:


 No.799572>>799575

>>799571

>global

LOL


 No.799573>>801371


fail EIO, "Error writing to file.";
fail "Received a negative value";
fail format("Person '%s' is not in database", person_name);

While, on failure, errno is always guaranteed to have a non-0 value, errmsg is optional and its value by default is an empty string.

If you do not want the overhead of setting the global 'err' value and need maximum speed, it is possible to define your functions as

"nofail". Inside these functions, it is not possible to access err, and as such the fail; statement is forbidden:


nofail function swap(int a, int b) => (int, int);

Pointers

Pointers are a mix between C pointers and C++ references. They can be NULL, but you do not use the ampersand operator to get their value.

The conversion between a type and its pointer is one of the only implicit ones found in Z:


int a = 5;
int* b = a;

Here, b is equal to the address of a. Implicit conversion between an integer and a pointer is forbidden anyway, so there is no ambiguity there.

Of course, as with C pointers, their usecase lies mostly with passing structures to functions.

In the example above, the value of b is accessed, as in C, with the unary operator *, and with structures, as with C, the operator -> is

used to access subfields.

Explicit conversion between pointers and integers can be achieved with the use of operators addr_of() and as_addr(). The compiler

will issue a warning if the integer type is too small to contain a pointer for the targeted architecture.

Because the implicit conversion between integers and pointers is forbidden, it is not possible to set a pointer to "0". Instead,

it must be set to the keyword value null. It is not possible either to give it a constant value. This must be done via as_addr().


 No.799574

Memory allocation

The new() and delete() operators are made available. Logic-wise, they act as functions. new() can accept one or two arguments. The

first one is a data type, and the second one is the amount of elements to be allocated. Memory is unitialized.

delete() accepts a single argument, a pointer to any data structure. The pointer given is also set to 'null'.

Note that trying to delete() stack-allocated data will result in a program crash, as it is basically an equivalent to C's free().

More features which I will post later:

* inline asm using built-in asm() function

* GUI and 2D graphics as part of the standard library (as C++20 might get)

* structures and packed structures

* modules

* functions as data types, function pointers

* regex, socket modules as part of the standard library

* complete and sane string handling module (split(), search(), concat(), etc.)

* generic containers as part of the standard library

- Maps, queues, stacks, etc.

* Database registries and persistence as built-in features (probably with compiler switches)

* Built-in thread management and parallelism (akin to openmp)

* Cryptographic and hash functions as part of the standard library

* Because of all the previous features to be included in the standard library, a division of it into two parts: a "core" part, to

be used in systems programming, and an "extended" part, to use in more general programs.


 No.799575>>801495

>>799569

>is it memory safe?

No.

>does it have generics?

Yes.

>is the compiler free software?

Yes, under GPLv4, which will be written specifically for Z

>is it a meme lang?

Where do you think you are?

>>799572

Keep reading, kid.


 No.799576>>799578

>>799570

funtion overloading was a mistake

consider this example:

you have funtion foo which returns an int.

you write foo(); somewhere, you dont care about the return value. later you declare another foo function that returns a void. now you have to change every instance where you call foo and specify that you want the function that returns an int and not void.


 No.799578>>799580

>>799576

>you write foo(); somewhere, you dont care about the return value

But that is forbidden, anon!

Either the function returns a status code, in which case you just use the 'err' global variable, or the function returns a result which you have to care about or else you wouldn't call it in the first place.


 No.799580>>799581

>>799578

so even if you dont care about the return value you _have_ to write int kys = foo();

LOL


 No.799581>>799582 >>799598

>>799580

What is that function with a result you should not care about, again?


 No.799582>>799583

>>799581

a map that returns the old value on insertion if a value for the specified key already exists


 No.799583>>799585

>>799582

Assuming you're referring to C++'s map::insert(), f you use such a function instead of the [] operator, then you do care about the return value.


 No.799584

Where is the compiler?


 No.799585>>799586

>>799583

im not referring to anything. i was just giving you an example. anyway your meme language is shit that no one wants nor needs. what you are proposing is basically a slightly less shit c.

there already exists a better c and it is called d


 No.799586>>799587

>>799585

>D is a better C

LARP alert


 No.799587

>>799586

>no compiler

LARP alert


 No.799594>>799596

>systems programming language

>error_t contains heap allocated string

are you retarded???????????


 No.799595>>799600 >>799602

>>799567 (OP)

I know this isn't an education thread for plebs like me, but I wonder: how do you create a compiler for a language you invent?

I went as far as reading that you need to modify LLVM/Clang but didn't dare go deeper.


 No.799596

>>799594

Can be disabled with compiler switch --bare-metal


 No.799598>>799600 >>799602

>>799581

Not him, and im only learning C so maybe theres something wrong, but Ive had functions with returns I sometimes care about and sometimes might not in the K&R exercises.

say, a function to read a line(I know getline, its an exercise) that returns the length of the line read(even if larger than the buffer) and assigns only as much of it as it can into the buffer

what if I really dont give half a shit about how long the line is though?

What if I Just want to get one line and then print it, and then not do anything with its length?


 No.799600>>799602 >>799604

>>799595

have you tried using a search engine?

http://llvm.org/docs/tutorial/

https://www.gitbook.com/book/landersbenjamin/llvm-implementing-a-language/details

btw you forgot to sage

>>799598

dont start with c. it is an awfully designed language. also avoid any languages inspired by c. learn a functional language first.

btw you forgot to sage


 No.799602>>799608

>>799595

First step is to define a grammar, then you create a parser for your language, which will create an AST (abstract syntax tree), from which you can then generate machine code (or, more easily, code in another language, which you will then feed to an existing compiler).

Flex and Bison are the two GNU tools usually used for this task.

>>799598

The thing is, these functions are interesting in C, because C strings do not contain their own size, so you end up with functions that return two values: a string (passed as an argument), and an integer value. The key here, is that such a function returns the most important value via an argument rather than via the return keyword.

In the particular case of getline() or sprintf(), in Z, the string contains its own size, so it is a single return value, and not via an input argument.

string user_input = io.read_line(my_file);

Ignoring the return value in such a case would make no sense at all.

If, for some reason, you would like to ignore the next available file, it is more reasonable to do the following:


pass_line(my_file);

If you do not get a line, then calling a function called get_line makes little sense, and adds a small but noticeable difficulty to fluently read the code.

Of course, Z would also allow you to declare the following function anyway:

function get_line(file_t f) => (void);

TL;DR, the problem of functions with unused return values arises mostly because of status codes, single return values and null-terminated strings, all of which are non-problems in Z.

>>799600

Sage isn't a downvote, reddit.


 No.799604>>799608

>>799600

you forgot to suck my dick


 No.799608>>799614

>>799602

>unused return values aren't a problem because i say so

what are side effects???

>Sage isn't a downvote, reddit.

saged XDDD

>>799604

you forgot to sage


 No.799614>>799616

>>799608

>hurr I can't program

Is all I can read in your post. Side effects have little to do with return values in this particular context, so I guess it's just that you can't program for shit, hence your recommendation to learn a functional language.


 No.799616>>799621 >>801345

>>799614

>hurr i can only larp

where is the compiler???????????

prove me wrong faggot. protip: kys *


 No.799621>>799623

>>799616

Looks like I've struck a nerve here, kid.


 No.799623

>>799621

epic

still no compiler though. LARP alert


 No.799641

Very great language for systems computing. Even though computers are meant for maths, as

>>799636

is meant for.


 No.799665>>799673

>>799571

>fail

#define fail \
errno = 1; \
return NULL;

#define fail_void \
errno = 1; \
return;

memelang defeated


 No.799670>>799673

Is there a way to pack structures for systems programming? They really help for defining descriptor tables.


 No.799673>>800058

>>799670

Yes, I'll write about packed structures later. I had thought about them for easy implementation of binary communication protocols as well, or anything related to information exchange between two potentially different architectures for that matter.

>>799665

>not wrapping macro in a "do {...} while(0)" statement


 No.799900>>799942 >>799985

>>799567 (OP)

>image

>National GDP, % change on previous year

Why is this relevant? Is the image trying to convey some message about the impact of tall buildings on the economy?


 No.799942>>799985

>>799900

>wasting dubs and trips on a shitposter namefaggot


 No.799985

File (hide): bb39dc1326f1bc0⋯.png (944.75 KB, 997x811, 997:811, fake taxi.png) (h) (u)

>>799900

Probably to show that tall buildings are usually built in periods of economic growth, rather.

>>799942

>butthurt


 No.800058

>>799673

I wait with bated breath.


 No.800177>>800189 >>800206

This language is pointless. It's basically C with a few very minor differences.

I bet your compiler just changes everything to the C equivalent (easy to do) and then uses gcc.


 No.800189

>>800177

>compiler

there is none


 No.800206>>800227

>>800177

>I haven't read anything

Besides, virtually every imperative language is "C with minor differences" if you go by that


 No.800227>>800230

>>800206

except all the imperative languages that arent trying to be c.

btw where is the compiler?????


 No.800230

>>800227

It's WIP!


 No.800477>>800538

>>799567 (OP)

If you introduce strong typedefs and explicitly reject CoC in a premptive manner Im in.


 No.800538>>800664

>>800477

Compiler will require you to take a picture of yourself to prove your hair isn't dyed. This should keep the community healthy.


 No.800540

You seem smarter than the people who made C and it is a better language, but it's still too much like C for me to want to use it.


 No.800545>>800548

>>799567 (OP)

Are there classes, or do I have to use function pointers in structs?


 No.800548>>800550 >>800668

>>800545

Why do you want OOP?


 No.800550

>>800548

I just prefer thing.do() over thing->do()


 No.800569>>800593

>>799567 (OP)

>Haskell

>write-only

It's not Simon Peyton Jones' fault that you're too retarded to read Haskell.

>Z is 99% C-like syntax, meaning you can understand and even modify programs written in it without having learned it.

So you're appealing to people who use C, C++ and Java by keeping the ugly syntax


 No.800593

>>800569

FPIDF get out, Haskell is objectively unreadable


 No.800598>>800600

Also thinking on supporting anonymous functions and structures, because these are really missing in C.


 No.800600>>800604

>>800598

can you also add support for memory safety????????

also a compiler would be nice, i gues....


 No.800601

>namefagging narcissist

thread hidden


 No.800604>>800608

>>800600

>can you also add support for memory safety????????

No.

>also a compiler would be nice, i gues....

I'm actually fighting with LLVM's lack of documentation for its C++ API (which has been broken in several versions), and it seems I will have to use the Ocaml API.

Of course, I don't know Ocaml, but heh.


 No.800608>>800609

>>800604

>cuck license

lol. nice meme m8


 No.800609>>800611

>>800608

>no mention of the license

Ok kid


 No.800611>>800621

>>800609

i mean llvm. use gcc or kys niggerfaggot


 No.800621>>800624

>>800611

>using the tool with a total lack of documentation

No.


 No.800624>>800638

>>800621

>I'm actually fighting with LLVM's lack of documentation


 No.800638>>800640

>>800624

simple lack > total lack


 No.800640>>800644

>>800638

dude all you have to do is convert your shitty c wannabe memelang to c and then invoke gcc.


 No.800644>>800646

>>800640

That involves writing a lexer and a parser at a minimum, kiddo


 No.800646>>800647

>>800644

yes???????


 No.800647>>800663

>>800646

ok well it isnt a trivial task kiddo im trying to get flex and bison to work nicely


 No.800663

>>800647

>he cant write a parser for his memelang

LOOOOOOOOL


 No.800664>>800671

>>800538

sadly you didn't reply to the other issue. I'm being quite serious, I'll EVEN HELP or INVEST if this thing has those two things, because so far this sounds like something I have wanted for a long time.

1) Will you have strict Typedefs?

2) Would you be willing to compromise to simply publicly disavow CoC's at the first time someone requests you to add a CoC?


 No.800668

>>800548

also, please, don't add oop. Let people build their own oop schemes.


 No.800671

>>800664

Yes, I would publicly refuse to adopt any CoC. As for your question on strict typedef, I'm not quite sure what you mean.


 No.800675>>800678

Typedefs are not checked at compile time, they-re actually treated as aliases.

If you write:

Typedef int pepe;

Typedef int oscar;

pepe a=1;

oscar b=a;

Will not even do a warning. The crime here is that the compiler has this features for its own types, but doesn't allow the user to have it.

The dark council of C++ assumes this is fixed just because Classes, which are unfairly favored already have this behaviour.


 No.800678>>800680

>>800675

So, you mean treating typedefs as new types of their own, instead of merely aliases?

Yes, I agree.


 No.800680>>800682

>>800678

Good, I'll be following this thread in case you start a repository or open some irc channel or something.


 No.800682>>800695

>>800680

You can catch me in #/tech/ on Rizon (there's a reason I tripfag in the first place) at roughly 11am-11pm GMT+1 every day, as for setting up a repo, I'll first get a parser running with Bison+Flex.


 No.800695>>800702 >>801214

>>800682

I thought it was because you were an attention whore. Still, I like this idea, sadly, I see no channel like that on rizon.


 No.800702

>>800695

lel, derp, riot irc client can't enter channels with slashes on its name, or something like that, Will try tomorrow on other client.


 No.801214

>>800695

>I thought it was because you were an attention whore.

It can be and is both.


 No.801345>>801348 >>801353

>>799616

hello were is de compiler :D :DD


 No.801348>>801353

>>801345

i dont know XDDD where is it?????? :^)


 No.801353

>>801345

>>801348

fagmo is still working on the lexer.


 No.801371>>801629

>>799573

You are already making the big mistake of having retarded defaults like C++. This is how I know you are larping "If you don't care about this super duper cool feature I'll add a keyword for you to remove it", it should be opt-in, you write more text to do more things not the opposite.

Also making it not possible to access err means any leaf err function would virally force everything else to be fail.

>Have a big nofail function tree

>Suddenly you want to use one error function on a leaf

>Have to remove nofail from the entire fucking path to the root

I hope you realize how stupid this is. I don't see what's stopping me from using err functions in nofail functions, as long as I can handle the error.

Also all that pointer shit is a non issue in C++, it's just that C allows implicit casts so shit like "unsigned a = &4;" compiles, just force people to make casts like in C++ and there would be no problem, at least not a single problem that does not exist in your convoluted system. You're making it different for the sake of making it different, you solved absolutely nothing.


 No.801495

File (hide): 7c01ca04597567a⋯.jpg (63.59 KB, 744x786, 124:131, BeNiggerElsewhere.jpg) (h) (u)

File (hide): d0eac2a9688ac4d⋯.png (50.2 KB, 699x770, 699:770, RemoveRust.png) (h) (u)

>>799575

>Yes, under GPLv4, which will be written specifically for Z

>not BSD

Dropped. Another shit-turd like Rust.


 No.801629>>801632 >>801635

>>801371

>just force people to make casts like in C++ and there would be no problem

That's how I know you've never developed anything besides single file fizzbuzzs.

You should see C++ code that's in production sometimes to understand how fucked up pointers can be.

>>Have a big nofail function tree

>>Suddenly you want to use one error function on a leaf

>>Have to remove nofail from the entire fucking path to the root

This isn't a situation because you only "nofail" performance-critical functions where you need to get rid of the call overhead, which only makes sense when that function doesn't call more than a couple functions itself, which in turn don't call any other functions, otherwise nofailing it makes no sense.

>hurr i can't follow the rules of optimizations

>wtf now i have 2 modify everything now????????


 No.801632>>801634

>>801629

>larping

where is the compiler???????????


 No.801634>>801636

>>801632

Working on the parser ATM


 No.801635>>801639

>>801629

>You should see C++ code that's in production sometimes to understand how fucked up pointers can be.

Show me


 No.801636

>>801634

why did you make a thread about your memelang without a working compiler????????????????


 No.801639>>801642 >>801653 >>801909

>>801635

Are you retarded? I can't post production code online, that goes against company policies and intellectual property laws. Not that you'd know that since you've likely never had a job anyway.


 No.801642

>>801639

>larping

LOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOL

seriously though, where is the compiler???????


 No.801653>>801794

>>801639

>We are hitting amounts of larping that shouldn't even be possible

Show me an example retard, show me a common mistake that your shitty system prevents.

Pointers still can be null, so they are not references. You can still take the address, you can still assign a pointer. The implicit conversion is already forbidden in C++ ("Because the implicit conversion between integers and pointers is forbidden", LARP INCORPORATED). What the fuck does your language do better in that regard?.


 No.801794

>>801653

not adding oop retardation to the mix seems quite enough to me to be honest.

Most people that care about performance go for c++ with a c appearance, ignoring all the unpredictable, bloated and nonsensical features. For any of those people having a c++ that looks crippled for a modern c++ cultist would be a gem.


 No.801909>>801917 >>801964

>>801639

Nifty spec.

I'm betting 1 litecoin that this project will be abandoned within 6 months. My definition of abandoned is no commits within a 3 day timespan.


 No.801917

>>801909

>no commits within a 3 day timespan

there is no source code


 No.801964>>801966

>>801909

>if you go on vacation a week all your projects are abandoned

Found the LARPer


 No.801966>>801968

>>801964

if you start a thread about your memelang and dont have a working compiler you are a LARPer


 No.801968>>801971

>>801966

>what are concepts

Nice sage-as-a-downvote btw


 No.801971>>801974

>>801968

where is the concept compiler??????????????

sage


 No.801974

>>801971

counter upboat




[Return][Go to top][Catalog][Screencap][Nerve Center][Update] ( Scroll to new posts) ( Auto) 5
97 replies | 3 images | Page ?
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / ask / femdom / hikki / just / newbrit / sonyeon / startrek / sudpol ][ watchlist ]