/dpt/ - Daily Programming Language

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

doc.rust-lang.org/std/primitive.slice.html#method.get_unchecked
doc.rust-lang.org/book/
rustbyexample.com/
doc.rust-lang.org/nomicon/
sifive.com/products/hifive1/
suckless.org/sucks/
pages.github.com/
twitter.com/AnonBabble

Java is better in it's domain than C++ or C#.

>60067026
That's literally wrong: doc.rust-lang.org/std/primitive.slice.html#method.get_unchecked

Employed System F programmer reporting in

it doesn't count if you're the only employee, desu.

This is the worst general on Sup Forums
not the topic, just the general atmosphere and the people

good day

I'm actually not.

Should I learn x86 assembly?

is a bachelor degree in cs worthless?

What else do you come to Sup Forums for other than autistic shit posting?

I don't fit in anywhere else :]

The reason Rust is being pushed so hard is because social justice warriors have found great difficulty penetrating the communities of open source system coders who use C and/or C++.

The "safety" features give advantages to lobotomised Feminist studies "coders" who are trying to "disrupt" these communities while breaking the knee caps of everyone else who knows what they are doing.

Literally nothing in Rust actually solves problems that haven't already been solved by RAII in C++ and even some GC/stack/heap techniques in the arguably superior but slower D compiler.

The advocates are all social justice warriors and this is their "long march through the development communities". They are employing critical theory against their main targets C and C++, by criticising everything it is and does and demonising its users. They've held back their "cis het white male" jargonism for now, but once they have established a foot hold "killer app", expect them to go wild with it. Just read through the big throbbing CoC they've erected on their main website.

Rust is kill. Don't touch it, spit on all its advocates.

Learn ARM or Risc-V or MIPS or 68k or some other RISC assembly instead, unless you're actually planning on using x86 assembly.

Once you grok one assembly, the others are all pretty much the same, except RISC is way easier because there just isn't as much to know.

Modern x86 was never really meant for humans to write, but rather for compiler implementation. armv7 was getting that way, but they cut a lot of fat out with armv8.

That said, it's probably better to learn an older assembly, meant to be written by humans, on an emulator, than a modern one.

I'm just now picking up Risc-V, we'll see how that goes. I've read it's pretty similar to MIPS, so maybe human-grok-able.

>one autist made a pasta to counter other autist's pasta
That's why I like this site.

It's autistic to post here.

thanks for the quality reply.

I used to program microcontrollers (8bit AVRs and 8051) in assembly, maybe time to dust those old platforms.

knowing x86 assembly can at least help in reverse engineering, the only really useful thing assembly gives you

I feel like every program one may need on their computer or smartphone are already made. So I can't begin to a project, am not productive at all. Give me some advice

I agree, to add to this RISC assembly is more pragmatic to learn being that it has more direct applicability in the real world at this point over x86. What I mean by this is that there are many more reasons to program assembly on an embedded platform these days than on an x86 unless it's some minute optimization. If you're going to write in a language that is so completely tied to hardware, you might as well be doing so because you wish to interact with the hardware directly.

get a raspberry pi and arduino and go to town :-D

Friendly reminder that there is literally no way in C to recover when malloc returns a NULL pointer.

>Learn ARM or Risc-V or MIPS or 68k or some other RISC assembly instead
Which one of these is the "better designed" one? Should I just learn ARM if I have a raspberry pi?

>implies lack of bounds checking in the code
sounds like a shitty programmer not C's fault

find a popular app on an app store, and clone it, but remove all metrics, tracking, and advertising.

I do this for fun. Also by clone, I obviously mean implement its functions yourself, not steal its code or some shit pajeet.

ARM and Risc are one in the same, ARM stands for Advanced Risc Machine. When you learn RISC you are learning the instruction set for ARM essentially

nth for the greatest language ranking
>1 AS3
>2 C
>3 C++

No way in C to recover what?

Initialize an error handler at the start of the program, and then call from a malloc wrapper than calls the error handler when null is detected.
At that point, you can pause execution and try again or dump everything to disk and hope you can fail gracefully.

>Should I just learn ARM if I have a raspberry pi?

If you want to learn ARM assembly, forget about the pie, cubieboard, banana pi and other ARM boards with desktop-computer capabilities. Especially not the raspi that doesn't work without closed sores crapware. There are plenty of simpler (arudino-like) ARM boards for as low as 10-15 bucks, get one of those. You can start with directly messing with the chip memory, leds, simple outputs etc.

I need help, guys. I'm working on a shell in C++ and there's two things I can't figure out how to do: piping and user variables (e.g. replace $VAR with 5 if they declare that VAR = 5)

I wish this was true, more often than not i have to make my own stuff for a very specific niche need

great idea. thanks

he won't respond to this because it was bait by someone who can't even program.

>not steal its code or some shit pajeet
If needs marching orders to be productive, he's already pajeet-tier. Dollars to doughnuts he'll end up churning out enterprise CRUD garbage, assuming he doesn't get bored and drop programming in favor of accountancy or something.

the time is now
doc.rust-lang.org/book/
rustbyexample.com/

* not for the brainlets *
doc.rust-lang.org/nomicon/

void add(Dictionary dict, char *str)
{
Dictionary temp = dict->next;

while(temp != NULL)
{
if(strcmp(str, temp->word) == 0)
{
temp->count+=1;
return;
}

else if(temp->next != NULL)
{
if(strcmp(str, temp->next->word) > 0)
{
Word* new_temp = (Word*)malloc(sizeof(Word));
new_temp->count = 1;
new_temp->word = strdup(str);

new_temp->next = temp->next;
temp->next = new_temp;

return;
}
}
else if(temp->next == NULL)
{
Word* new_temp = (Word*)malloc(sizeof(Word));

new_temp->count = 1;
new_temp->word = strdup(str);
new_temp->next = NULL;
temp->next = new_temp;

return;
}
temp = temp->next;
}

if(temp == NULL)
{
Word* new_temp = (Word*)malloc(sizeof(Word));

new_temp->count = 1;
new_temp->word = strdup(str);
new_temp->next = dict->next;
dict->next = new_temp;
}
}

Implementing Dictionary in C blows.

C blows.

bare metal assembly on Pi actually turned out to be a bit of a PITA. Doable, but there's so much undocumented magic. I guess if you want to do Assembly in Linux, no reason to not, but worth considering.

Arduino would be better, or just got myself one of these: sifive.com/products/hifive1/

>better designed
Risc-V has the advantage of being from-scratch, leaving out a lot of legacy cruft. Very little real-world practical usage, though.

>I have a raspberry pi
Sure, go ahead, learn ARM then. Doesn't matter too much. Whatever you like. But most of them are also available on qemu or have dedicated emulators, so you "have" most major RISC options available to you. But nothing beats seeing your code run on a real board and interacting with the real world (like controlling music on a couple pins).

>ARM and Risc are the one and the same.
Nah, not quite. ARM is but one RISC ISA. Other RISCs might differ in more significant or less significant ways. Arm code just won't run on MIPS code automatically (and probably can't be auto-converted, either).

I second this, as I already stated elsewhere. Only reasonable if you're staying on Linux or don't mind wasting hours finding an undocumented feature on some thread somewhere not indexed by google.

you're not wrong. I write on Pi's as well as Uno's, Yuns, and ESP8266's. Out of all of them the ESP8266's are probably the nicest to write for. (honestly just because they're pretty stripped down.) The Pi's have all these annoying things to account for like Physical pin numbering vs BCM pin numbering, etc--it's a bit to chew on for sure. I think the other nice thing about the Arduino's is you can leverage the serial libraries to step-by-step your assembly

How is a malloc call that returns NULL other than a fopen that returns NULL or a time() call that returns -1?

The only difference is that memory allocation is usually required, whereas file opening/time info are often not.

But if your program needed to open a file to work, and fopen always returns NULL, you're equally as screwed as with malloc.

do you guys know of any good resources out there on best practices for writing hardware interrupts in assembly/C for arduino-type uC's?

>suppressing a warning causes another warning about supressing the first warning

What C compiler should I use?
suckless.org/sucks/ says that both GCC and Clang suck, and I'm not going to switch to windows just to use Visual C++. So what options do I have?

suckless is literally satire
don't take them seriously you retard

>Thought SICP was a meme
>Finally came around to reading it
>Discovered LISP Macros
>Mind is fucking BLOWN
Is there a way to make LISP not GC? I'm in love.

Just about everything I know about assembly and things this low level is from actually reading docs or seeing it actually done. AFAIK there aren't really any good books, tutorials, or other online resources for this kind of thing, as it's pretty fucking niche, and done by people who're also learning from the same way (and more often than not, for their job).

Maybe you'll have some luck browsing some OCW?

gcc + gdb are great.
clang I know nothing about.
Visual C++ is a meme

>GCC is the virus which has spread into nearly every Linux distribution and has added its language extensions to be not easily replacable.

lol true tho

>That's why I like this site.
I'm loving the Rust butthurt as well. The one Rust autist got rekt in his own thread.

>Rust

The reason why GCC non-standard stuff has made it's way into every GNU project is because it's so damn convenient.
Nearly all of C99's additions were GNU C extensions that were given the standards committee's official blessing.

No it's not

yeah, GCC extensions were just a bunch of quality of life things for programmers.

>harmful: GNU head
>use sed 10q instead

>April
>Not using ESP32

I forgot to mention, I also need to treat ';' like a newline character.
For example, if the user entered "pwd ; ls" it would execute pwd, then once pwd is finished it would execute ls.

never take sucksmore.org seriously at any level. If they are serious that's why, if they are just pretending to be retarded then that's why.

what is a lexer, read a book.

I am already tokenizing the strings, hence why I wasn't asking for help with that fundamental task. If I couldn't do that, I would need to solve that problem long before I tried to handle piping or something.

what font

please post the correct image

they compile their stuff with GCC they just really are headstrong about 'software bloat' it's a necessary evil

the philosophy may be satire but their stuff is super nice. I use `tabbed -c surf -e` to browse--works amazing. DWM is my WM--it's awesome and super hackable. st is my terminal--again it's great works well with zsh. I even use ii in vim for IRC (vim is my irc client thats dope I think)

back in the day I read ed 1 & 2 of 'Assembly Language Step By Step' and that book was excellent, just didn't know if there was anything for Risc. I figured it'd just be me looking at a ton of libs and datasheets

just tokenize lines based on ';'? If you have a lexer written this should be a trivial addition.

oh shit dude good looking out, I didn't know about these. I don't really check out new boards much lately

gcc

Thoughts on using github as a databse? For my blog which i expect to get hits, im just parsing the data to my blog anything wrong with this?

that is a very bad idea. Just look at what happened to cocoapods. If you're going to do something like this at least use pages.github.com/ but not straight up github. jekyll i

what kind of blue hair dye and septum piercing do I need to buy to become a fit rust developer?

You need to look up the fork() system call and the pipe() system call. Suppose you want to pipe p1 | p2. Then, your program should create two child processes by forking and run p1 and p2. Also, you have to create a pipe using the pipe() syscall and redirect the STDOUT of p1 to one end of the pipe and STDIN of p2 to the other end of the pipe.

Redirection can be done using the dup() or dup2() syscalls.

>Tfw took over project
>mfw its C
>MFW int ****x;
Why do people do this*

Maybe my implementation is more primitive than it should be. Currently it iterates through the input string letter by letter, creating an array of strings out of a single string, replacing any space character wtih '/0'.
Tokenizing it based on ';' as well would just give me one long command which would fail to execute when it reached execvp because it would simply pass the second command on as input parameters for the first command.

I'm aware that I'm probably just a fucking idiot.

whichever one matches your python buttplug

one or two pointers are fine, anything past that is over kill

>Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
????????

the runtime complexity makes me think binary search, but it's two lists, not one. you can't just find the median of both lists and then average them

wouldn't a python be closer to a dildo? just form-factor wise i mean

I remember being able in QBASIC draw with subroutines like line(), point() and such.
What libraries and languages people use to draw in real life? How can I make possible saving in SVG or, let's say, PNG?

Why can't I edit javascript in a [VM] tab in chrome?

you'd know

That's just:
(first_array[last_element] + second_array[last_element]) / (first_array_size + second_array_size)

Kek

but arent python buttplugs appropiating black cocks? I don't want to cause a mass triggering in the rust dev team making em unable to work for hours.

yea yea, w.e faggot

Woops, you wanted median, in which case just get the midpoint by dividing the size.

(Anyway remember that the input arrays are sroted.)

is christian anime a thing?

I just had a final exam. One question was this:

#include

int main()
{
int a = 1;
int b = 2;
int *c = &b;
*(c + 1000) = 128;

return 0;
}


>what is wrong with this code snippet?

I was thinking an lvalue cannot contain operands but it compiles fine, why? Is the answer related to dangling pointers?

did you just assume his gender?

3 is okay for c-strings

>be me filling out tax form
>get to gender
> see "male", "female", "faggot"
>check faggot box.

you are asigning 128 to *(adress of b + 1000)
thats very wrong.

lol

that's not what medians are

>you can't choose multiple genders
welp, i guess i'll have to curl up in a ball and cry and leave my websocket privilege checker in Rust for later.

I was talking in terms of integer pointers, but I do agree char pointers should have up to three.

I doubt many humans will write assembly that performs on the same level as C these days in any reasonably complex application. Compilers are capable of some crazy shit that assembler optimizations can't really match. You should really only go down to that level to bypass bugs in your compiler, which you're unlikely to ever encounter in the first place, unless you're using some obscure compiler or something.

He wants the median of both the arrays. What he means most probably is that if you merge both the arrays, what will the median be?

Naive implementation will take O(n+m) steps to merge and then O(1) to find the median, but he wants to do it in O(log(m+n)).

>websocket privilege checker in Rust

i know that... i said it in the original post. you can get the median for one list by dividing by the size, but there's 2 lists

what should i study up on if i want to get a job at palantir? data science, networking security, or algorithms?

Merge two lists and get a median

:3