Quantcast
[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

/vt/ is now archived.Become a Patron!

/g/ - Technology


View post   

[ Toggle deleted replies ]
File: 703 KB, 2560x1440, -g-animeC.png [View same] [iqdb] [saucenao] [google] [report]
70402190 No.70402190 [Reply] [Original] [archived.moe] [rbt]

What are you working on, /g/

Previous Thread:
>>70397031

>> No.70402206
File: 122 KB, 1358x724, Screen Shot 2019-04-02 at 10.57.22 AM.png [View same] [iqdb] [saucenao] [google] [report]
70402206

>>70402190
I'm trying to get my python workflow set up. I'm using IPython, and really like its quality-of-life improvements over the default python3 shell, but I do have one question.

Is it possible to remove the output of the %load command? Whenever I load a file, I need to press ENTER again, and then I can start typing commands.

>> No.70402231

>>70402206
You don't use a code editor?

>> No.70402277

>>70402190
Third for fuck anime.

>> No.70402284

>>70402273
wasm is kill

>> No.70402325
File: 24 KB, 320x265, woj.jpg [View same] [iqdb] [saucenao] [google] [report]
70402325

What do you guys do if you're presented with something you just don't get? I'm in a class, have gotten assistance with the assignment multiple times, and even got an extension on its due date, but no matter what it just doesn't make sense. How do you guys go about handling shit like this?

>> No.70402341
File: 115 KB, 2054x342, Screen Shot 2019-04-02 at 11.19.15 AM.png [View same] [iqdb] [saucenao] [google] [report]
70402341

>>70402231
Well, for some reason, emacs is really slow when using ipython, and I'm having other issues with the vanilla python interpreter.

>> No.70402347

Still looking for Nim Full Course kind of video guide or something

>> No.70402375

why can't i get past the second question and print out the results in a readable format?

class Die:
def __init__(self):
pass

def DieNumber(self):
int(input("How many dice to roll?\n"))

def DieSides(self):
int(input("Which sided die to roll?\n"))

def __repr__(self):
pass

class Dice:
def __init__(self):
pass

dice = []
for dn in str(Die.DieNumber):
dice.append(Die.DieSides)

def DiceRoll(self):
roll = [Die.DieSides(self) for dn in str(Die.DieNumber)]

def __repr__(self):
pass


first_choice = Die()
first_choice.DieNumber()
first_choice.DieSides()
first_set = Dice()
first_set.DiceRoll()
print("You rolled {} {}-sided dice and got {}.\n".format(Die.DieNumber, Die.DieSides, Dice.DiceRoll))


second_choice = Die()
second_choice.DieNumber()
second_choice.DieSides()
second_set = Dice()
second_set.DiceRoll()
print("You rolled {} {}-sided dice and got {}.\n".format(Die.DieNumber, Die.DieSides, Dice.DiceRoll))

>> No.70402383

>>70402231
Nevermind. The python3 regular interpreter now works fine. I was trying to do something fancy, which ended up screwing the way the interpreter works. At least I have autocomplete with emacs now!

>>70402325
I'm gonna say something super unhelpful: Work Smarter, not Harder.
What is it that you're not getting? Are you asking the right questions when you're getting help, or is it more "I'm stuck... Please help me."
What are you getting stuck on?

>> No.70402389

>>70402277
That's not very nice, dude.

>> No.70402401

Why is \g/ so obsessed with C?<div class="like-perk-cnt">🐸</div>

>> No.70402436

>>70402401
because it is shit. just like how /a/ flips when anything gets popular.

>> No.70402439

>>70402347
libgen the book

>> No.70402446

>>70402436
C is extremely popular

>> No.70402461

>>70402446
/g/'s scale is not popularity, it's shit.

>> No.70402468

>>70402439
only one written in 2017

>> No.70402472
File: 368 KB, 1000x494, js-rocks.png [View same] [iqdb] [saucenao] [google] [report]
70402472

JavaScript rocks!

>> No.70402478

>>70402468
it's the one (NIA) still promoted by Andreas.

>> No.70402482

>>70402401
because all other languages have been delegated to the webdev general so we're stuck with C grandpas and Haskell sojboys

>> No.70402492

>>70402190
This picture is very cute!

>> No.70402501

Taking a "data structures" class that is literally just intro to CS repeated. Fuck me. What is a good book to learn the hard stuff? Preferably Python, Java or C++ based. I don't have time to meet with SICP or Hasklel...

>> No.70402509

>>70402501
The Cormen Algorithms book is pretty good.

>> No.70402535

>>70402383
You're completely right, but I honestly don't even know where to start. I kinda look at everything and just get a headache(I have a really bad case of stupid).

>> No.70402561

>>70402535
>I have a really bad case of stupid
Me too, but that's no excuse to give up.

There's this really interesting story from Khan Academy. They split fifth graders into two groups: Group A watch KA videos starting at a 5th grade level and Group B watched videos from the 1st-grade level. It turns out Group B actually improved a lot more than Group A did.
What I'm trying to get at is go to the most basic thing that doesn't make sense to you, and see what about it confuses you.
Is this for a course you're taking?

>> No.70402564

How may closing >s is acceptable in a declaration of an STL-based templated data structure variable

>> No.70402579

>>70402561
Yeah. It's essentially babby's first programming, but for some reason the introductory language is Ruby(don't ask me why, I have no idea).

>> No.70402598

>>70402579
I like Ruby, so I can vouch for it, but something that helps students is force them to solve the problem without a computer, and then program the solution once they solve the problem with pseudocode.
Are you getting stuck on Ruby's syntax? Or is it a more general "I'm not sure how to approach this problem" situation?

>> No.70402611

>>70402598
Honestly I don't know. I want to say the latter, but I'm not certain.

>> No.70402617

>>70402564
3 then start using aliases

>> No.70402637

>>70402611
Well, I'm not sure how much more help I can be, but try doing some of the problems on this website:
https://www.codestepbystep.com/problem/list/ruby
There are other resources too. Don't be afraid of using another language to help you understand programming and then move on to Ruby.

>> No.70402677
File: 319 KB, 2000x1344, Screen Shot 2019-04-02 at 11.48.34 AM.png [View same] [iqdb] [saucenao] [google] [report]
70402677

>>70402375
Well, one issue is in this line:
for dn in str(Die.DieNumber):
dice.append(Die.DieSides)


Printing out what str(Die.DieNumber) is, I found out it's the string representation of the function. It's essentially calling Die.DieSides once per character in the string.

I then printed out the array of die, and got a *ton* of strings.
Make sure that you're using getter and setter methods in your classes correctly.

>> No.70402682

>>70402611
Well maybe describe what's wrong you massive faggot instead of wallowing in self-pity moaning "I don't understa-a-and!"

Here's an exercise: solve the problem in a pseudocode that will magically have instructions for anything you want. This should be trivial provided you understand what's being asked of you in the first place.
Then go about trying to break each instruction down. If you get stuck there, post some details here. If not, keep going. At some point you'll have detailed pseudocode directly translatable to a program, if you have that, that means you're just stuck on the syntax and that's easy.

>> No.70402692

why worst languages have best tools?

>> No.70402701

>>70402190
that show was trash

>> No.70402713

>>70402190
Crappy vector.

>> No.70402731

>>70402692
because you are deluded

>> No.70402778

>>70402677
i thought in python you didn't need to mess with set/getters. im not really sure what that would be in python. thought, when iw as able to get past the 2nd question, it printed everything out fine except for calling for the 0x0 value instead of a readable format. how would this be affected by what you're printing?

>> No.70402804
File: 416 KB, 1440x900, gsocket_connect.png [View same] [iqdb] [saucenao] [google] [report]
70402804

Working on my IRC client a bit. Added an API to my socket class for connecting to a hostname/port (rather than only supporting IPv4Address/port.) Turned out I had a bug in my DNS client where I would interpret all records as if they were A records. Having fun with programming, basically.

>> No.70402833

>>70402682
to put it basically, I need to take a .txt document that looks something like this:
"a;b;c"
"d;e;f"
and create a new .txt document with the above text
AND a new piece of text at the end of each line. Basically I want:
"a;b;c;3"
"d;e;f;6"
3 and 6 being determined by the 3rd piece of text(c is 3rd letter, f is 6th)
I need to be able to do this for as many lines as necessary, I need to do so using an array to store the text, using a split to divide the values based on ";", create and use a function that can calculate the new value based on the third existing one, loop as many times as needed for each line, and export all the data to the new .txt. I understand the pseudocode(mostly), but I'm at a loss for things like How do I divide the text properly, should I have just one array for the three-four characters on each line or should i have another array for each line as well, how do assign each word to a set place in the array, do I reset the array for each line or continue adding onto it, among other issues. Basically really easy stuff that I somehow can't wrap my head around.

>> No.70402842
File: 18 KB, 431x431, iu[1].jpg [View same] [iqdb] [saucenao] [google] [report]
70402842

How the fuck is one supposed to implement user permissions?

I'm developing a java + postgres employee management app, but cant' figure out what kind of pattern suits this best.

I plan on having 3 tables in the DB: users --<n:1>-- roles --<n:m>-- permissions. But how should I handle it within java? Am I meant to simply manually look for role name string when performing a permission check?

>> No.70402850
File: 19 KB, 192x220, 1401126578487.jpg [View same] [iqdb] [saucenao] [google] [report]
70402850

Had a database entity which could have multiple flags assigned to it and I figured I'd just save the flags as a bit mask in a single column, even had a minor hard-on for how space-efficient the whole thing was
Now I need to read all entities with only certain flags enabled and I just realized that saving them as a bitmask means I need to use bitwise operations inside my SELECTs
I am not a smart person

>> No.70402877

>>70402833
should note:
3 and 6 are determined by c and f being the 3rd and 6th letters of the alphabet, not 3rd and 6th in the document, so if it were "a;b;z" it'd need to output "a;b;z;26"
Also, I'm really confused as to what values should be defined in the initial class and what should be defined in the general program itself

>> No.70402889
File: 573 KB, 1920x1080, 1514866463694.jpg [View same] [iqdb] [saucenao] [google] [report]
70402889

>>70402850
>I am not a smart person
Join the club

>> No.70402901

On an assignment in a course unit I failed 3 times.

>> No.70402926

>>70402375
this may sound harsh but that code makes no sense
why are you getting input just to throw it away?
why are you declaring all these functions that don't do anything?
why are you printing functions?
where's the randomness?
and so on.
I suggest starting with something simpler, look up tutorials on classes etc.

>> No.70402932
File: 20 KB, 410x465, 1552079213863.png [View same] [iqdb] [saucenao] [google] [report]
70402932

I got some basic programming knowledge but I have no idea what to work on and how to improve my skills. Any tips?

>> No.70402935

>>70402842
Calculate the concrete permissions whenever the user logs in and cache them in memory, invalidate and recalculate them when the user changes roles or the role changes permissions, use the cache to check for permissions

>> No.70402939

>By convention, traits are always implemented as structs. Another convention is that the structs used to implement traits are known as trait classes.
Fucking sepplesers

>> No.70402952
File: 36 KB, 655x527, 02f.jpg [View same] [iqdb] [saucenao] [google] [report]
70402952

>>70402901
How did you keep going? I haven't even technically failed this assignment yet and I still feel miserable. Being presented with something like this that I just don't understand regardless of the time or effort put in is incredibly demoralizing and results in compounded negative thoughts for me, resulting in me more or less shutting down within two to three hours.

>> No.70402953

>>70402833
have you tried what I told you last time?
can you write a program that reads a file line by line?

>> No.70402956

>>70402932
do something you'd like to
If you got nothing to strive for, programming is the least of your problems at the time

>> No.70402974

>>70402833
I think part of the issue is just looking up ruby standard practice and what's in the library, but you do have some issues with actually understanding the pseudocode.
To get these out of the way:
>how do I divide the text properly
this entirely depends on the ruby standard library (I have never used ruby so I don't know). Look up on stackoverflow or something.
>should I have just one array or also store every line in another array
That depends on how you take input and provide output. Are you able to stream the files in and out? If so, you might be able to line by line. Your algorithm would then be:
string line = read_line_from_file();
string newline = do_processing_to_generate_the_line_with_the_extra_number_added(line);
append_line_to_file(newline);

Where read_line_from_file() and append_line_to_file(string) would be ruby library functions.
If you can't do this, then the other approach is to load the entire file into an array, then loop over the array calling do_processing_to_generate_the_line_with_the_extra_number_added() for every element, and then save the output. Here you could use a second array to store all the new lines, or you could try to modify the array of lines in place. Either way, again, this depends on what ruby offers you; read the official docs, search stackoverflow, etc.

Now, with code architectured like that, all you need to think about is your do_processing_to_generate_the_line_with_the_extra_number_added() function which takes a string and returns a string. The good thing here is that if you make this a pure function (with no side-effects), you won't have to worry about things like "do I reset the array for each line or not".

Try to go from here and see if you get stuck again.

>> No.70402978

>>70402190
This image has always bothered me, what the fuck language is that on the laptop? It's hard to read but it's not C.

Something Something <- Something()
{
return foo;
}

>> No.70402985

>>70402939
What's wrong with that? Other than traits in general sound retarded but I've never needed to touch them myself so I can't really comment on that

>> No.70403004
File: 177 KB, 245x222, 1540316307549.gif [View same] [iqdb] [saucenao] [google] [report]
70403004

bool operator<(T t1, T t2) { return t2 > t1; }

>> No.70403018

>>70402978

google would have told you it's R

>> No.70403020

>>70402953
>>70402974
I whipped this up just now, it seems to work
my_input_file = File.open("Project_6_Input.txt", "r")
input_line = my_input_file.gets
while(input_line = my_input_file.gets)
puts input_line
input_line = input_line.to_i + 1
end

>> No.70403039

>>70402926
this may sound harsh, but if i knew what i was doing, i wouldn't be asking for help.

I'm merely trying to make a set of dice that the user manipulates and rolls, which resets every time so the user must input each time.

>get input to throw away (again new set of dice)
>declaring functions that don't do anything (i don't get what you mean? i call die to be able to call the methods and then call dice to be able to call the list. this is what i think im doing, at least.)
>printing functions (to see if things are working the way i intend them to. (re: the 0x0 values instead of string format)
>randomness (im using list comprehension to grab a value randomly from a max value set by user)

>> No.70403044
File: 24 KB, 284x283, 1499490884218.jpg [View same] [iqdb] [saucenao] [google] [report]
70403044

>>70402842
Levels of permission should be prime numbers, and a user should have an int that's a product of every permission he has

>> No.70403046

Something something there are two kinds of people, those who intuitively understand programming and algorithms and are happy with it and those who struggle writing a fizzbuzz and seriously can't code.

I remember reading about a detailed study of CS students where freshment with zero programming experienced were asked to answer some questions relating to fundamental programming concepts, like variable assignment, and then were asked the same questions again after a term or two. Those who intuitively picked consistent answers first time around later gave correct answers the second time, those who had no idea what they were doing the first time around and selected at random still had no idea after taking the course on programming.

>> No.70403061

What's a regular expression that matches only the generals for Clover?

>> No.70403066

Should enums be typedefed?

>> No.70403078

>>70403066
The only things that should be typedefed are opaque handles.

>> No.70403083

>>70402978
pretty sure it's squirrel
https://github.com/OpenTTD/OpenTTD/blob/5a5944867dfeaa556ec78c23af4796adb28a6a9f/bin/ai/compat_0.7.nut

>> No.70403084

>>70403066
They're just integers. It's the same as #define.

>> No.70403089

>>70403020
Here I'll assume "gets" reads a line (and keeps track of where it is in the file) and "puts" appends a line (since like I said I don't know a lick of ruby).

First of all, you're skipping the first line: while loops first evaluate their condition, so you do "input_line = my_input_file.gets" twice in a row.

Secondly, is that puts only for debugging? Because if that's an attempt to write the actual output, you should know that you're outputting it before actually doing anything to the line. It should probably come afterwards.

But otherwise you're on the right track. Inside your while loop you now need to split the input_line, take the last element of the array, find the corresponding number, append it to the array, and then join up the array back into a string before outputting that new string. You should be able to google for each of these steps to get ideas on how to proceed.

>> No.70403115

>>70403061
/.*general$/ will match a lot, but many don't have "general" in their name so you'll have to hunt for the rest by hand
/\/\w{2-4}\// or something along those lines (untested, written off the top of my head) might be more thorough, but sometimes people omit the /xxx/ part from the subject

>> No.70403116

>>70403083
That's it, I think you're right. I never even heard of squirrel before.

>> No.70403134

>>70402932
then get that roll picture for projects or https://better-dpt-roll.github.io and do them by order/interest

>> No.70403140
File: 78 KB, 749x865, 1550614143633.png [View same] [iqdb] [saucenao] [google] [report]
70403140

Python and regular expressions are too comfy, lads

>> No.70403145

>>70403039
>get input to throw away (again new set of dice)
def DieNumber(self):
int(input("How many dice to roll?\n"))

this function asks the user for input. the input is then thrown away without ever being looked at
>declaring functions that don't do anything
__init__ and __repr__ don't do anything
this is not such an important point, just unnecessary
>printing functions
I can't see what kind of useful information you'd get by printing functions
>im using list comprehension to grab a value randomly from a max value set by user
that's not what list comprehensions do

>> No.70403168

>>70403020
good. now try to split the line, and print the parts individually
also I'm not sure what input_line = input_line.to_i + 1 is for, doesn't seem to do anything.

>> No.70403179

>>70403061
>he asks, in one of those generals

>> No.70403187

>>70403168
You're right, it doesn't. I thought it might be needed to make sure the program knows to move forward past the first line, but I was mistaken. I will likely need something similar for the program to know to split and transfer past the first line, though.

>> No.70403190

>>70403116
me neither, I just googled some of the code in the picture and then looked up what the hell a .nut extension is

>> No.70403199

>>70403078
// Like this?
typedef struct { ... } stuff;
// Or like this?
typedef struct { ... } *stuff;

>> No.70403202
File: 2.19 MB, 1227x1228, ChiyomaruHeart.png [View same] [iqdb] [saucenao] [google] [report]
70403202

>>70402956
>>70403134
Thanks, I will do my best!

>> No.70403205

>>70402952
I basically take financial risks until I get better at it. Problem is when dealing with lecturers who either force you to do a task a certain way or give harsh penalties if your code does not compile fast enough.

>> No.70403206

>>70403168
Although I am curious, why does it need while(input_line = my_input_file.gets)? It clearly does need it, as it doesn't work without it, but why doesn't simply puts input_line work? am I missing something obvious?

>> No.70403214
File: 116 KB, 1080x1920, Screenshot_Clover_20190402-152734.png [View same] [iqdb] [saucenao] [google] [report]
70403214

>>70403115
FLOOOOOEEEEENS
pic related

>> No.70403225

>>70403187
gets takes care of that, it will always return a new line when you call it, so your input_line get's a new line for every iteration.

>> No.70403234

>>70403145
you're still missing the point about how i don't know what im doing; your post doesn't help me much. ive already pointed out how i don't know how to make the results of the roll readable, so telling me that repr isnt necessary doesn't help me, as ive already gathered that from pointing out how the results are printed in the 0x0 value thing instead of a readable format. (which again, i thought repr did but i still don't know and have tried for way too long to figure this out) ive tried multiple ways of doing this and with the ocean of information out there, finding the right island is actually very hard to do.

how would you write this out then? ive already made shitty iterations of this project but im trying to do things in a more concise and clean manner instead of spaghetts. is there any source of information that cleanly explains what im trying to do without using retarded examples that actually confuse the reader instead of helping?

>> No.70403252

>>70403206
this basically means "while there is still data left to process, read one line from the file and assign it to input_line for processing". in the next iteration, it assigns a new line to input_line, and so on

>> No.70403253

>>70403199
More like
// handle.h
typedef struct handle *Handle;

void handle_foo(Handle);
void handle_bar(Handle);
void handle_baz(Handle);

// handle.c
struct handle
{
// impl
};

>> No.70403254
File: 108 KB, 942x890, 1550509123815.jpg [View same] [iqdb] [saucenao] [google] [report]
70403254

my 20 minute nap turned into a 3 hour one again

>> No.70403285

>..., and recursion is to functional languages as TV is to American pop culture: inseparable)
Based Scott bringing the heat

>> No.70403291

>>70403254
It's called depression, anon

>> No.70403301

>>70403253
>defining structs in *.c
This actually works?
Will any separate file just need to #include the header to see this?

>> No.70403303

>>70403254
It's called being a lazy faggot

>>70403291
Depression is not real
t. Someone who has been "depressed" for 15 years

>> No.70403320

>>70403234
there's a lot of python dice rolling examples out there, pick one and try to understand how it works (ask here if necessary) and see if you can adapt it. start with making the user input a number of sides instead of having it always be 6, then try adding more dice.

>> No.70403326

>>70403301
Yeah, it's called forward declaration. You'll only be able to manipulate the struct through non-dereferenceable pointers unless you're in the .c file though. That's why it's called "opaque".

>> No.70403350

Any opinions on Codesignal?

A friend recommended it to me, and it's pretty fun, but I have never heard of it before

>> No.70403361

>>70403303
>he thinks his ""depression"" was the same thing as people actually suffering from major depression
How to spot a normalfaggot

>> No.70403380

>>70403320
every example has __repr__ which is why i used it in the first place...

>> No.70403383

Am I the only one who thinks objects and classes are bullshit? I'm having to learn Java for a class, and this """"organization""""" into objs and classes in BlueJ seems like such time wasting bullshit. I wish I could just use C instead.

>> No.70403391

>>70403190
Sorry about that, I think I need glasses but I have no optometrist money.

>> No.70403412

>>70403326
Huh, The more you know.
Thanks, anon!

>> No.70403416

>>70403383
C++ is best of both worlds

>> No.70403420

>>70403380
could you post an example?
the ones I'm finding don't use it

>> No.70403429

>>70403291
>>70403303
and I am still tired
I'm never gonna make it, bros

>> No.70403433

>>70403383
Am I the only one who thinks structures and procedures are bullshit? I'm having to learn C for a class, and this """"organization""""" into structs and routines in GCC seems like such time wasting bullshit. I wish I could just use Assembly instead.

>> No.70403446

>>70403433
time to read sicp

>> No.70403447

>>70403383
an object is an instance of a class aka a fucking variable.. at least in java
so what did you mean by
>""""organization""""" into objs and classes

>> No.70403455

>>70403420
forget it. you're not going to help me anyways. i can see why the majority of people will never learn programming.

>> No.70403464

Reminder that you can't call yourself a true programmer if you haven't mastered C++

>> No.70403474

>>70403455
>you're not going to help me anyways
not with that attitude

>> No.70403478
File: 107 KB, 1080x1080, 1545215578072.jpg [View same] [iqdb] [saucenao] [google] [report]
70403478

how does apps like messenger work?
checking network every few seconds would drain battery fast as fuck and android doesn't allow waking phone so frequently anyways

>> No.70403482

>>70403464
'true programmer' is not an alias for 'full blown autist'

>> No.70403493

>>70403464
how do I master c++? there's always something new that suprises me every day

>> No.70403517

>>70403478
ewww

>> No.70403530

>>70403478
Post dick

>> No.70403535

>>70403530
yes, post dick

>> No.70403540

>>70403530
pm'd you

>> No.70403554

>>70402804
Why is assert uppercase?

>> No.70403578

>>70403214
No clue what shitty flavour of regex it uses, I'm assuming Java but I forget Java regex rules. Does the app have any documentation and/or examples?

To be sure I tested it with PCRE and ECMA regex engines and it works as expected so it's not me being retarded

>> No.70403588

Buttplug: in
Knee-high socks: on

It's C++ time!

>> No.70403634

>>70403206
You have kind of a fundamental lack of understanding about how code works.
Not that I'm calling you stupid.

input_line = my_input_file.gets is a statement that takes the value of a file and puts it in a variable.

while is a statement that evaluates a statement and executes a block of code repeatedly as long as it evaluates to true
And "true" basically means "not 0, and not null". So as long as the characters being found in the file are not EOL, the loop will keep running.

It's just fundamental building blocks of a programming language.
I think Python or some very high level language has gotten you used to thinking about code as something that has to be typed exactly one way. Pragmatic programming like C is much more about the atomics.

>> No.70403647

>>70403588
wish that were me

>> No.70403652
File: 189 KB, 1080x1920, Screenshot_Clover_20190402-160706.png [View same] [iqdb] [saucenao] [google] [report]
70403652

>>70403578
>examples
Yes, pic related.

>> No.70403657

>>70403493
you don't.

>> No.70403658

>>70403647
Me too, but I'm only smart enough for Python 3

>> No.70403671

>>70403652
*general*

>> No.70403677

>>70403554
It's a macro, and all my macros are uppercase. I need it to be a macro so I can pick up __FILE__ and __LINE__ from the preprocessor.

>> No.70403683

>>70403493
you learn it all
it isn't hard

>> No.70403684

>>70403671
I am trying to use the 2 backslashes method because of the false positives.

>> No.70403689

>>70403684
* general *

How many false positives can there be?

>> No.70403696

Is ACM membership worth $200?

>> No.70403710

>>70403696
no

>> No.70403753

>>70403689
I got a few false positives yesterday from "generally" and another but I guess if I stick to subjects, it's really rare. Also, I was afraid of people not using the word general but that seems to be rare too. I'll just stick with the simple one. Thanks for the help senpai.

>> No.70403760

Is the latest C++ ISO standard worth 200 CHF?

>> No.70403774

>>70403760
no

>> No.70403776

>>70403677
>and all my macros are uppercase
true patrician

>> No.70403790

is js best lang for prototyping?

>> No.70403793

>>70403760
maybe if you're a compiler writer
I just read the latest drafts if I need to look something up

>> No.70403807

>>70403790
Nim > all

>> No.70403813
File: 86 KB, 526x701, 1513982655694.jpg [View same] [iqdb] [saucenao] [google] [report]
70403813

>The book is very short so can be read in one or two days.
>200 pages
but I can't read that in 2 days

>> No.70403816

>>70403807
>alpha

>> No.70403830

>>70403816
No, more like a 0.9 beta, as .20 which is the 1.0 RC is due to release literally any day now.

>> No.70403847

How can I tell if I'm mentally retarded?

I have a feeling everyone thinks I'm autistic or something, they just don't want to tell me

>> No.70403881

>>70403652
>"Regular expressions."
Based floens providing details documentation. I guess stick with >>70403689 then.

>> No.70403889

why isn't this working? ;_;
let g:ale_completion_enabled = 1
let g:ale_linters = {'cpp': ['clang']}
let g:ale_cpp_clang_executable = '/usr/bin/clang-cpp-7'
let g:ale_linters = {'c': ['gcc']}
let g:ale_c_gcc_executable = '/usr/bin/gcc'

>> No.70403899

>>70402501
You want to do hard stuff, but in your post you claim you're not willing to put in the time to a book as fundamental as SICP. You put data structures in quotation marks like its not a class deserving of respect, and emphasize the language used in the book you ask for. Why even pursue CS if you have no interest in the theory? You're just going to end up a code monkey. Unfortunately you have the same mentality as most on /dpt/. Any book recommendation I'd give you would be pointless.

>> No.70403929

>>70403813
what kind of book?

>> No.70403958

>>70403899
The SICP cult is so amusing. If it's so "fundamental" how come MIT ditched it for Python?

>> No.70403967

>>70403929
http://www.greenteapress.com/thinkcpp/thinkCScpp.pdf
I probably could if I cared enough

>> No.70404052

>>70403967
that looks like a fucking slog to read through
you probably couldn't even if you care, it's just gonna put you to sleep

>> No.70404258
File: 2.42 MB, 320x240, 1554236132574.gif [View same] [iqdb] [saucenao] [google] [report]
70404258

someone link me the full vid of this

>> No.70404308

>>70404258
https://www.youtube.com/watch?v=2Op3QLzMgSY&list=PLE18841CABEA24090

>> No.70404350

>>70403958
they wanted to give a common cursus for both computer science and electronic engineering to reduce costs and difficulty. they also think that programming is no more about writing code from scratch but now about writing glue code on top of already existing libraries.

>> No.70404365
File: 102 KB, 1162x578, image_conbined.png [View same] [iqdb] [saucenao] [google] [report]
70404365

Did I make an abomination? Please help

>> No.70404404

>>70404365
>not catching exceptions for values other than valid ones within the call

>> No.70404423

Anyone here any good with dart? I need some help with creating a timeout for a websocket.

>> No.70404454

>>70404365
the formatting on those braces makes it unreadable. dump the same line crap

>> No.70404535

>>70404404
I figure I'd do that on the calling function as there's some preprocessing to the entries.

>>70404454
Is this less shit? I want it to look like the table image.
{{2,3},{3,3},{3,4},{4,4}},
{{3,3},{3,3},{3,4},{4,4}},
{{3,4},{4,4},{4,4},{5,5}}
},{
{{3,3},{4,4},{4,4},{5,5}},
{{3,4},{4,4},{4,4},{5,5}},
{{4,4},{4,4},{4,5},{5,5}}

Also is this the correct way to handle this sort of table in C++? I'm still very green on it.

>> No.70404587

>>70404535
The table looks like something that can be programmatically generated. Use a constexpr function to initialize it.

>> No.70404626

What do you think about OOP, /dpt/? Is trying to cram everything into objects really the way to go?

>> No.70404647

Alright /g/, fun times. How the hell do I get this shit to actually output into the output document? The program runs without any errors but the output txt remains empty, any ideas?
lass TicketData
def initialize(buyer_name, buyer_age, price)
@name = buyer_name
@age = buyer_age
@price = calculateprice(buyer_age)
end
def calculateprice(age)
if age <= 12
return 5
elsif age >=13 && age <= 64
return 10
else
return 8
end
end
def put_for_output_file
output_string = @name.to_s.chomp + ";" + @age.to_s.chomp + ";" + @price.to_s.chomp
return output_string
end
def display_me
puts @name
puts @age
puts @price
end
end
person_array = Array.new
my_input_file = File.open("Project_6_Input.txt", "r")
my_output_file = File.open("Project_6_Output.txt", "w")
while(my_input_line = my_input_file.gets)
i = 0
price = 0
input_words = my_input_line.split(";")
the_name = input_words[0] + " " + input_words[1]
the_age = input_words[2].to_i
my_person = TicketData.new(the_name, the_age, price)
price = my_person.calculateprice(the_age)
my_person = person_array[i]
i = i + 1
end
for i in (0..person_array.length - 1)
person_array[i].display_me
output_string = person_array[i].put_for_output_file
my_output_file.puts(output_string)
puts output_string
end

>>70404626
No idea, all I know is it's giving me a fucking headache

>> No.70404651

>>70404587
I wish that was the case. Those are "arbitrary" values for ergonomics evaluation, I'm going to do some 20 of those fucking tables, some much bigger.

>> No.70404668

>>70404647
also I missed a "c" at the start of that code because copy-paste is a bitch, just a warning

>> No.70404676

>>70404651

You're making an even better case for generating them procedural ;)

>> No.70404704

>>70404535
>>70404651
That seems like an incentive to sanitize inputs at landing rather than in the calling function, seeing as you'll have different tables doing different things with different values

>> No.70404769

>>70404676
Sure, if I could.

>>70404704
The expected use case is: the entries are generated clicking on radio buttons in a Qt UI. Tbh I haven't figured anything out yet, just making tables trigger happy for now.

>> No.70404771
File: 74 KB, 1520x1080, lainpeeking.jpg [View same] [iqdb] [saucenao] [google] [report]
70404771

https://pastebin.com/XYfZuZ7t

Is this a good way to build a file handler in Java?

Ignore the variable names, Im just trying to find out if this is the best way to deal with opening, writing and reading to files, which is a class with a bunch read and write methods.

>> No.70404906

>>70404771
- You can use the "user.home" system property to get the path to the user's home instead of doing those OS-dependent checks
- Use the Path class to join Path instead of using String concatenation
- You are closing your IO handles outside finally{} blocks, which might lead to leaks
- You should use the try-with-resource syntax to open your resources, it also takes care of closing them if an exception arises
- Your class is not thread safe

>> No.70405025

>>70403889
looks like it should work if you have clang installed, check out what :ALEinfo says when you're editing a .c file.

>> No.70405125

>>70402152
Thanks for the heads up anon, I'll be sure to download everything before the change is put into place.

>> No.70405265

>>70405025
i'm trying to use in cpp but it's not working

>> No.70405279

>>70405265
nothing at all? are you missing
let g:ale_enabled = 1

>> No.70405296

>>70402325
shoot up the school

>> No.70405310

>>70402535
re you the ruby brainlet

>> No.70405339
File: 31 KB, 601x508, 2f7.jpg [View same] [iqdb] [saucenao] [google] [report]
70405339

>>70405310
n-no


yes.

>> No.70405359
File: 507 KB, 1280x720, dontforget.png [View same] [iqdb] [saucenao] [google] [report]
70405359

>> No.70405361

What's something one could write for an hosted embedded platform? MIPS to be specific, 32-bit and no FPU, and I guess I'd use C.

>> No.70405379

>>70404626
use composition brainlet

>> No.70405413

>>70405359
But they save you from this:
if (false)
errno = ERROR;
abort();

>> No.70405422
File: 367 KB, 1280x720, 1550877959282.jpg [View same] [iqdb] [saucenao] [google] [report]
70405422

tomorrow I'll start studying
I promise

>> No.70405445

I'm a newbie at programming and I can't stop using fucking lists. I use them for everything

How do I slowly stop?

>> No.70405453

>>70405445
why stop using something that is useful?

>> No.70405462

>>70405445
Define "for everything"

>> No.70405482
File: 59 KB, 806x640, 1503059406794.jpg [View same] [iqdb] [saucenao] [google] [report]
70405482

>>70402284
horry shit Java's IO APIs are inconsistent dumpsterfire

>> No.70405483

>>70405453
I mean that there are other data structures I could be using

>>70405462
Maybe the correct or more efficient data structure is a set or a stack or whatever, but I keep using lists because it just works

>> No.70405488

How do i wget from one machine to another?
My teacher asked me to do this but i cant find it anywhere on thei nternet.

>> No.70405492

>>70405482
fak it was for >>70404771

>> No.70405503

>>70404647
I made your class nicer. I think you should solve your question yourself, though.

class TicketData
def initialize(buyer_name, buyer_age, price)
@name = buyer_name
@age = buyer_age
@price = calculateprice(buyer_age)
end
def calculateprice(age)
case age
when 0..12 then 5
when 13..64 then 10
else 8
end
end
def put_for_output_file
@name.to_s.chomp + ";" + @age.to_s.chomp + ";" + @price.to_.s.chomp
end
def display_me
puts(@name, @age, @price)
end
end

>> No.70405524

I have an Emacs package with a default refresh rate of 60 seconds, how do I change it without directly changing the internal code?

Here is the code http://elpa.gnu.org/packages/minibuffer-line-0.1.el

The variable "minibuffer-line-refresh-interval" is at fault here.

>> No.70405651

>>70405413
Rust doesn't have this problem

>> No.70405669
File: 78 KB, 600x450, absolutelydisgusting.jpg [View same] [iqdb] [saucenao] [google] [report]
70405669

How do I get this girl at my work to use fucking Git and start organizing herself better? Our boss has us work together on a project and instead of organizing things in a comprehensive way, she just jumps right into work and throws tasks my way via IM, phone calls, and emails. Furthermore, she actually send her code through our internal file sharing service (think mediafire). I just made a git with all of our code in proper folders. I wrote a README, outlined our agenda and pipeline, wrote progress down, et cetera. I even told her to git pull the changes and you know what she did? She said "Oh I can't install it because it needs admin. So I just edited the code that I gave you 2 days ago. Can you look at the differences between the two?"

She's a "Technical Lead" with a Masters in IT and she doesn't understand why organization and version control is important. What do I do? She's giving me unnecessary work this way.

>> No.70405674

how to deal with sadness?
>nothing is working
>i dont even know what i dont know
>everyone calling me a retard for not knowing shit
>dont even know what im ment to know
im seriously considering dropping out of college
thanks for reading my blog entry

>> No.70405687

>>70405279
I didn't have that but nothing changed, thanks for the help anyway

>> No.70405723

>>70405483
>I mean that there are other data structures I could be using
and when you actually need to use them, you will know because a list can't do the job, don't use something else just because.

>> No.70405740

>>70405669
> Can you look at the differences between the two?
No.

Was that hard?

>> No.70405742

>>70405669
Beguile your way into getting her terminated
or just gaslight her, either will do

>> No.70405765

>>70405740
Yes because the boss specifically wants me to work with her and make her life a little easier (she was overloaded with a lot of crap recently).

>>70405742
>gaslight her
I'm not a psychopath unfortunately.

>> No.70405783

i build a small scraper that creats updated socks 4 proxy list.. and overwrite the proxychains.conf file..
I dont know if people search for this kind of stuff so i dont know if i should upload it to github..
regards fags

>> No.70405797

>>70405524
If the count is defined to 60 with
defcustom minibuffer-line-refresh-interval 60
How to change
run-with-timer t minibuffer-line-refresh-interval
inside
(when minibuffer-line-mode
(setq minibuffer-line--timer
(run-with-timer t minibuffer-line-refresh-interval
#'minibuffer-line--update))
(minibuffer-line--update)))


Can elisp accept changing variables on the fly if I add changes on the init.el?

>> No.70405803

>>70405723
>and when you actually need to use them, you will know because a list can't do the job

This is wrong. Look at the difference between a set and a list, especially in a language like python. If you want to see if something is present in one of them, the syntax is literally exactly the same item in data, but doing this for a can be substantially slower depending on how big you are expecting it to be. Just because it works doesn't mean it's correct.

>> No.70405813
File: 21 KB, 302x300, 41c.jpg [View same] [iqdb] [saucenao] [google] [report]
70405813

How can I get better at math? I've struggled with it all my life. Programming is great and I want a future in it, but whenever I have to get involved with math I feel like Forrest Gump. I'm fine with arithmetic. Recently I worked through a lesson where we used tau and sine to create an up-and-down movement in a 3D environment and I just barely understood it.

>> No.70405869

>>70405797
If it's defined with defcustom, just evaluating (setq minibuffer-line-refresh-interval sec) with whatever value of 'sec' you want should work, since it looks for this variable at run-time of minibuffer-line-mode. Just place it somewhere in your init.el or just eval it and reload the mode.

>> No.70405944

>>70405869
Wow, it works. Thanks.

>> No.70405975

>>70403554
to be more assertive

>> No.70405981

>>70403958
Languages change, theory remains.

>> No.70406057

Java is just a dumbed-down C++ with implicit asterisks everywhere and even more bloat

>> No.70406074

>>70406057

This is a new and unique observation.

>> No.70406090

>>70405981
Other book (like Cormen) teach theory well without leaning on meme functional languages.

>> No.70406143

>>70405981
Not that you're wrong, but Java also has a god tier ecosystem too.

>> No.70406208

>>70406057
Actually it would be more accurate to say implicit arrows everywhere.

>> No.70406218

>>70406143
Java's ecosystem is the best of any language bar none. There's a reason why every company uses the lang.

>> No.70406278

>>70405413
What?

>> No.70406285

>>70402190
what should i do with my automated pepe collector? i've got 8000 frogs rn

>> No.70406292

>>70406285
delete them

>> No.70406345

>>70406285
post all of them just to make this guy >>70406292 mad

>> No.70406361

>>70406218

My company uses a million lines of 300 year old motif, raw xwindow, and Pro-C. If your company uses Java, consider yourself lucky.

>> No.70406364

>>70406090
what can one learn from that Algorithms book?

>> No.70406404

>friend starts learning and gets a job in 8 months and makes me feel insecure
I spent 4 years for a degree why

>> No.70406423

I've been using emacs to write haskell and it annoyingly will do two things
1) After a bit, it will lock up entirely for about 30 seconds. This seems to be worse with editing string literals.
2) After a bit, moving the buffer is INCREDIBLY slow, I'm talking a solid 5 seconds to move up a line or down a line and I can watch it painstakingly shift each line in the buffer.

I ran a profiler and it looks like electric-pair syntax checking is fucking breaking or something, eating up 60% of the cpu cycles. Is there some way to leave that on but disable the specific part of it that's doing unnecessary haskell checks? I just want paired brackets, not for it to recheck the entire fucking file every time I type

>> No.70406464

>>70406404
Because now you actually know what you're doing and aren't an underpaid javascript monkey

>> No.70406618

>>70403958
Today's students proved to be too brainlet for it.

>> No.70406619

>>70406404
so you're saying i need 4 more months then i'll be ready
>>70406464
that's prolly what i'll be doing. once you get in the industry, is it worth going back for a BA?

>> No.70406642

>>70404647
This is the worst Ruby code I ever read

>> No.70406650

>write big & overly complicated spaghetti code
>compile it several times under different filenames to compare the functionality
>"okay, it's finally done! now let's remove the junk files"
>accidentally delete the source code for final version. realize that too late, data got overwritten
>check the last exe that got compiled
>everything pretty much works but i didn't add "int argc, char* argv[]" to main which was used to determine the location of the exe
>program work only on G:\ partition
can i salvage this somehow?

>> No.70406661

>>70405339
I'd say your pajeet teachers didn't teach you enough ruby to solve problems properly but I bet telling you to look up string, array and enumerable docs are just going to confuse you even more I'm sorry

>> No.70406669

>>70406619
>4 years for a degree
>not a bachelors
pardon

>> No.70406682

>>70405445
Lists are the most fundamental data structure in existence

>> No.70406686

>>70406669
i already have an unrelated degree, so i don't know if it would be worth it to go back for another bachelors in comp sci once i got my foot in the door

>> No.70406718

>>70406686
Iunno. Probably half my graduating class already had BS in MechEng, but it takes WAY less time to get your second degree so it may be worth it in the long run.

>> No.70406728

>>70406718
Even if it's unrelated? I'll need a job first to get the money, but I'm pretty down once I do get one.

>> No.70406776

>>70405869
Spoke too soon, seems like evaluates once and goes back to counting to 60.

>> No.70406791

>>70406728
A lot of time in uni is spent satisfying core requirements. Depends a lot on how much math you completed but generally it should be faster.
You can meet with an advisor at the school to see what it would take.

>> No.70406808

>>70405503
class TicketData
attr :name, :age
def initialize(buyer_name, buyer_age, price)
@name = buyer_name
@age = buyer_age
end

def price
@price ||= case age
when 0..12 then 5
when 13..64 then 10
else 8
end
end

def to_s
"#{name}, #{age} ($#{price})"
end

def inspect
"#<#{self.class.name} #{to_s}>"
end
end


There, I made it even better

>> No.70406820

>>70405669
Commit her work under your name and claim credit

>> No.70406835

>>70406808
>>70405503
i wonder if crystal is as expressive as this

>> No.70406842

>>70406835
Dunno, don't know crystal. But as far as expressiveness is concerned its hard to beat ruby

>> No.70406912

>>70406650

Use one of those undelete programs like Recuva.

>> No.70406949

>>70406642
you havent read much then

>> No.70406968

>>70406835
Nobody knows because crystal doesnt run on anything.
But probably not. Ruby is so ridiculously expressive because *everything* is an object, even the keyword "class" is an object, so you can write things in lots of different clever ways since the language only really has to deal with one root thing: an object

>> No.70406983

>>70406650
Data recovery tool or just rewrite it.
When you do the rewrite you'll have already figured a lot of goofy problems out and can abstract them and factor them better anyways.

>> No.70406987

common lisp or scheme

>> No.70406989

>>70406968
>even the keyword "class" is an object

Sadly that's not the case. Even something as basic to the language as blocks are not objects: you need to pass a block to the proc method so that it can actually return an object for you to use.

>> No.70407014

>>70406912
>>70406983
like i said, the data is overwritten already
also is there really no alternative to this? i really don't feel like writing the same spaghetti again

>> No.70407015

>>70406989
https://ruby-doc.org/core-2.2.0/Class.html
>When a new class is created, an object of type Class is initialized and assigned to a global constant (Name in this case).
It's an object. You just can't really use it like you would normally. As far as the language construct is concerned though, it's an object.

>> No.70407028

>>70407014
Unless you specifically overwrote that part of the disk with a tool, there's no guarantee those blocks got replaced. Filesystems don't work that way.
Try recovery software. Otherwise, rewrite it.
If it's in Java you can de-assembly the .jar file but it won't have any meaningful variable, class, or function names.

>> No.70407035

>>70406987
Haskell.

>> No.70407069

>>70407015
>>70406989
oop nope you're right, every class is an instance of Class which is a subclass of Object so goofy things like "Class.is_a? Object" return true
Class is just class, its the instances that make it an object

>> No.70407073

>>70407014
>i really don't feel like writing the same spaghetti again

using version control tools, and consider this a lesson.

Source code gets lost every damned day.

>> No.70407116

I have a function written in assembly that takes from 1 to 7 arguments from registers using a standard calling convention.

.global x64_linux_syscall
.type x64_linux_syscall,@function
x64_linux_syscall:
movq %rdi,%rax
movq %rsi,%rdi
movq %rdx,%rsi
movq %rcx,%rdx
movq %r8,%r10
movq %r9,%r8
movq 8(%rsp),%r9
syscall
ret


This code doesn't actually care whether the registers are set or not. Depending on the first arg, some registers won't be used at all. In other words, you can pass as many args as you want as long as its at least 1 and at most 7.

// all valid calls
func(1);
func(1, 2);
func(1, 2, 3);
func(1, 2, 3, 4);
func(1, 2, 3, 4, 5);
func(1, 2, 3, 4, 5, 6);
func(1, 2, 3, 4, 5, 6, 7);
// invalid
func();
func(1, 2, 3, 4, 5, 6, 7, 8);


How do I declare this in C?

// doesn't type check?
// is calling the same function with different arguments multiple times undefined behavior?
// does compiler assume a prototype after the first time you call the function?
// or does it always generate code for the amount of args you passed?
void func();

// varargs are compatible with register calling convention?
// doesn't it put the varargs on the stack or something?
void func(int first, ...);

>> No.70407142

>>70407015
That doesn't invalidate what I said. Classes are objects. The class keyword isn't an object. It does return an object, however.

>>70407069
Object is an instance of itself.

Object.is_a? Object # true

>> No.70407204
File: 14 KB, 504x300, Capture.png [View same] [iqdb] [saucenao] [google] [report]
70407204

Rewriting this C loop into assembly (ARM) and am stumbling poorly.

Are these two loops equivalent? The C code goes character by character and adds the value to the start of a checksum.

>> No.70407215

>>70407028
>Try recovery software
i already did that. that's why i made such statement
>If it's in Java
no, it's C++
>>70407073
well, i guess i have no other option
i'll run the program on G: only for now until i feel motivated enough to start over

>> No.70407228

>>70407215

If "G:" is embedded as a string in the executable, you could probably change it with a hex editor.

>> No.70407243

>>70407204
>ARM programming

How do I into this brother? I can compile my C program for x86 and x86_64 already but I'd love to support ARM stuff as well

>> No.70407256

>>70407204
the loop in arm assembly looks to be
for (const char *s = text; *text; ++text)
checksum += *text;

>> No.70407258

>>70407243
I'm babby-tier with assembly, trying to learn the basics. I'm still unfamiliar with the syntax and verbiage.

>> No.70407268
File: 21 KB, 600x399, 43871237412.jpg [View same] [iqdb] [saucenao] [google] [report]
70407268

>passed 20 hours of continuous work
now this is modafinil

>> No.70407270

>>70406808
Nice trick with ||=

>> No.70407277

>>70407270
fuck you

>> No.70407283

>>70407228
while this will work, it will only allow me to change the directory to some other defined one, forcing me to repeat this step every time i move the exe somewhere
ehhh, should have learned machine code

>> No.70407296

>>70407283

Try using a decompiler.

>> No.70407319

>>70407296
spaghetti is too long and complicated. would end up wasting more time tidying it up than rewriting it. but thanks for ideas

>> No.70407433

>>70406987
Both, but start with scheme.

>> No.70407489

>>70403760
C++20 isn't ready yet

>> No.70407556

>>70407277
I'm not kidding. It's the cutest caching syntax.

>> No.70407559

Hey rubybro, i read through the guides.
I dont think i got much from them that could help with my application, mostly just a bunch of built-in functions and some syntaxes but thats about it

>> No.70407566
File: 44 KB, 640x360, DabbingTree.jpg [View same] [iqdb] [saucenao] [google] [report]
70407566

What is the programming equivalent of the dab?

>> No.70407582

>>70407559
Im saying this because you called me a retarded and that I didnt know shit. Truth is i've programmed before in JS and even though im not good but im not retarded.
I feel like i just dont understand how to implement a solution, why did you say my code was shit -code ?

>> No.70407737
File: 783 KB, 368x92, windemo2.gif [View same] [iqdb] [saucenao] [google] [report]
70407737

created a c64-style demo control for images. I don't know why.

>> No.70407946

>>70407737
Go to sleep, Donald Trump.

>> No.70407953

>>70403889
You're overwriting the linters array with line 4, so you're only linting c.

let g:ale_linters = {'cpp': ['clang'], 'c': ['gcc']}

>> No.70407958

>>70407116
Basically: That ASM has side effects. It works in that order but won't in others, you'll load random values around into your calling function and gets weird things.
Being a valid function call doesn't mean it's a safe or proper one.

Second: Yes, you'd do that using varargs in C. Look at the asm output of a simple varargs hello world to see what gcc does (use -O0)

>> No.70407967

>>70407559
>>70407582
whomst are you in this thread?

>> No.70407988

>>70407566
goto logic

>> No.70408036

so i'm decent at writing code

so what do i do now

>> No.70408080

>>70407277
Be nice, faggot.

>>70407556
It's taking advantage of short circuiting operators and the fact everything is an expression (stuff that returns values).

x ||= y
x || x = y
if x then x else x = y end


All equivalent. Be aware that this is incompatible with variables where either false or nil are valid values.

>>70407582
There's several ruby people in the thread. I thought I was the only one. Comfy.

Anyway, your program isn't idiomatic ruby. There are far better ways to do what you're trying to do. I'm refraining from posting code because otherwise I'd end up doing your assignment for you.

>> No.70408121

>>70408036
git gud
program more

>> No.70408133

arr[i], arr[arr[i]-1] = arr[arr[i]-1], arr[i]
Why doesn't this swap work in Python? I thought it evaluted both sides before assigning? I had to switch to the "keep a tmp variable and swap" method to make it work.

>> No.70408152

>>70408080
>idiomatic ruby
any way to learn to write better ruby ?

>> No.70408173

>>70407958
>That ASM has side effects. It works in that order but won't in others, you'll load random values around into your calling function and gets weird things.

What do you mean? The assembly code can affect the calling function somehow? Pls be patient, I'm not an assembly expert, I just thought it'd be cool to make my own libc

As I understand it the kernel will look at the syscall number and call the implementation with the right arguments, the other ones won't be used at all. I used to set them all to 0 but that served no real purpose.

>Yes, you'd do that using varargs in C.

Yeah. That assembly code is from the musl source code. I just realized it uses varargs

https://git.musl-libc.org/cgit/musl/tree/src/internal/syscall.h#n25

hidden long __syscall_ret(unsigned long), __syscall(syscall_arg_t, ...),

Missed this the first time I read it. Looked up the abi docs and it seems the varargs calling convention uses the same registers as a regular function call. The x86 abi puts varargs on the stack, and indeed the x86 code seems to pull them off the stack:

https://git.musl-libc.org/cgit/musl/tree/src/internal/i386/syscall.s

.global __syscall
.hidden __syscall
.type __syscall,@function
__syscall:
lea 24(%esp),%eax
push %esi
push %edi
push %eax
mov 16(%esp),%eax
mov 20(%esp),%edx
mov 24(%esp),%ecx
mov 28(%esp),%edi
mov 32(%esp),%esi
call __vsyscall6
pop %edi
pop %edi
pop %esi
ret


I have no idea what this vsyscall business is for. Can't the __syscall function simply put all the args in the registers then interrupt into the kernel?

>> No.70408185

The hardest thing about programming in University is understanding what the fuck your professor is trying to say in his fucking project descriptions.

>> No.70408233

>>70408173
>What do you mean? The assembly code can affect the calling function somehow?
Registers are magical special nonsense. If you arbitrarily pop 7 values off, then you get 7 arbitrary values. The function has no idea what they are or if they're the right ones.

Basically if one preceding call sets registers that the next doesn't, but reads from, you get whacky results. Registers are global values in asm, effectively, you don't ever want to read from them unless you know you've set something.

>> No.70408251

>>70408185
Call him out in class with the most pedantic shit possible. I kept getting docked points for not including specs mentioned in lecture and not in the actual specs and I fought him tooth and nail.
Guess what professor writes actual goddamn specs now?

>>70408173
> The x86 abi puts varargs on the stack, and indeed the x86 code seems to pull them off the stack:
Yes but that's likely determined at compile time. I'm not going to deep-dive to answer this for you but the answer is probably:
The format string is parsed, and the number of args is parsed, and that is used to generate the correct number of push/pops onto the stack for variables.
It's definitely not fixed to "max possible amount"

>> No.70408261

>>70408152
The best thing to do is learn the standard library. Whatever you're doing with lists, hashes, strings, numbers, files... There's certainly a shitload of methods there to make it easy to do. Somehow this japanese language yields english like code.

Knowing the standard library is the difference between these lines of code:

[1, 2, 3][rand(3)]
[1, 2, 3].shuffle.first
[1, 2, 3].sample


Learn how to use blocks. Every ruby method is automatically capable of taking a block of code as argument. This is very neatly integrated into the language and is actually a more powerful abstraction compared to JS functions.

array.select &:even?

Don't explicitly return unless you have to (early in the function or something of the sort). In ruby, the returned value is the last expression evaluated.

def f(x)
return x ** 2
end

def g(x)
x ** 2
end


Integrate your classes into the language's conventions. Implement a to_s method to convert to string. Implement a inspect method to return a debugging representation of your object. Then you can just write puts(object) instead of defining a display method to puts(@x, @y, @z). This is just better code.

>> No.70408286

>>70407566
for(;;) instead of while(1)

>> No.70408311

>>70408251
In this case there's no format string. What determines how many registers get used is the syscall number. The compiler can't assume anything about that, right? I assumed it'd generate code to pass in the number of parameters the programmer wrote. If you pass 3 parameters, you get code that pushes 3 args on the stack or something like that.

>>70408233
Is there really a problem if all the asm does is copy the nonsense around and then let the kernel deal with it? If the programmer gives nonsense to the kernel, sure, the kernel will probably return invalid parameter error or do some insane thing. I can't think of a better way to do this tho

I'm making better, type safe functions for general usage but those functions still have to go through this one. At the end of the day they cast everything to long

>> No.70408327

>>70408152
Hey, looks like someone put together a huge list:

https://github.com/franzejr/best-ruby

>> No.70408330

>>70408311
>if all the asm does is copy the nonsense around and then let the kernel deal with it?
That sentence is nonsense. The kernel has absolutely nothing to do with what is executed at the machine level. The kernel manages who does what when and who has access to what memory, but once it hits the asm level it can't do shit.

Basically what I suggest is this: Write a varargs function, and make a Hello World that calls it with n arguments. For each n, save the asm output from gcc, and then compare the difference and see what it does.

>> No.70408471

Ive been slacking on learning but im gonna start again today, after wagie hours..

>> No.70408540

What would be the best language for creating a domain specific language? That is I want to make a language to define statistical models. Like STAN or BUGS or torchscript if anyone has ever heard of those. Which are niche little languages that let you program statistical models. And then operate on them or compile them. Usually they aren't turing complete but sometimes are or come close. Allowing things like for loops.

>> No.70408660

>>70408540
i mean anything can do that, but parsing tools and pattern matching helps. Haskell and ML are probably good, and there's a lisp variant some guy made specifically for DSL creation but I'd have to look for it

>> No.70408685

>>70406423
>emacs
kek

>> No.70408707

I just want to get a job working on compilers, but everything seems to require a degree (usually a master's). :(

>> No.70408728

>>70403482
Actually it is.

>> No.70408750

>>70407489
C++20 isn't the latest C++ standard.

>> No.70408778

>>70408707
Find a company that will pay you to get that master's. Even better go straight into a PHD program, they'll pay you just to start out there.

>> No.70408827

>>70408750
Excuse me?

>> No.70408846

>>70408778
Like an internship? I found one of those, but they seem to be looking for a more junior developer.

>> No.70408872

>>70408846
If you don't have a degree you could pass off as a junior then massively blow their expectations when you start your job. Then they'll really want to keep you on for that master's/phd. Just make sure you're OK with your work being property of the company, remember they're paying for your higher education.

>> No.70408875

>>70408778
This
Pull your bootstraps, walk up to the manager, shake his hand, look him in the eyes and say "Sir, you may not know me, but I'm the best damn coder in the entire Northern side of California"
Five minutes later I was employed

>> No.70408915

>>70408152
Don't bother, most other devs wouldn't. Ruby is a prototyping language, it isn't made to be written well, it's made to be written quickly. That's why no one's bothered to implement it in a way that performs acceptably.

>> No.70408924

>>70408915
truffle ruby is pretty decent if i remember correctly. the main issue is how ruby was designed, which was not with performance in mind.

>> No.70408928

>>70402375
this has only gotten worse since you last posted it

>> No.70408930

>>70408915
https://crystal-lang.org/

>> No.70408944

>>70404350
>they wanted to give a common cursus for both computer science and electronic engineering to reduce costs and difficulty. they also think that programming is no more about writing code from scratch but now about writing glue code on top of already existing libraries.
This is pretty embarrassing. I'm an EE at a smallish school. Our intro to programming class is in C++ without OOP, our discrete mathematics course is in lisp (EEs only have to take one course, CS have to take a few), and our data structures and OOP course is in Python (for EEs, CS majors have it split into two courses and learn it all in C++). And then obviously EEs do a fuckton of C and assembly in various courses and CS majors go deeper into more programming languages and basically ignore C and assembly outside of a reverse engineering course.

>> No.70408948

>>70404626
>Is trying to cram everything into objects really the way to go?
No, it's fucking retarded. They're a useful programming construct sometimes, but should just be one tool in a toolbox.

>> No.70408955

Reverse enginnered a Qt based app. So now I can read the state and interact with the app. Tomorrow I will finish the actual features.

>> No.70408968

>>70405413
So does if (false) {
errno = ERROR;
abort();
}

like the gods intended. Or you could just not be a fucking idiot.

>> No.70408990

>>70408968
But why would you set errno if you're aborting the program?

>> No.70409002

>>70408968
so what's the difference between using {} and newlines?

White spaces being part of syntax enforces a certain amount of formatting so you don't end up with awful spaghetti code and mistakes like the post you replied to pointed out.

>> No.70409007

>>70409002
>goo goo ga ga, baby needs his diaper changed
Most IDEs will have a format button

>> No.70409043

>>70409007
something like clang format wont catch what the first comment posted since it's valid. In that case it might be more obvious to catch later when you see it's not at the same indent level, but the formatter doesn't know the intent of the code so it cant fix it. If it were a subtler example you would most likely end up missing it entirely.

I use both C++ and python at work and it really doesn't make a difference to me, but the people who complain about whitespace being part of the syntax never actually have any reason.

>> No.70409044

>>70408827
The latest standard is C++17, retard.

>> No.70409052

>>70405413
No, they don't save you from severe retardation.

>> No.70409055

>>70409043
You don't even know what a formatter is. You think it's a linter.
The formatter will unindent the third line, retard.

>> No.70409086

>>70409055
That's literally what I said it would do, maybe try learning some reading comprehension before calling others retarded. It's still a very obvious case, in more subtle examples things like that can get passed you if you were either intending both to be in the if block.

You still haven't come up with an actual rebuttal on how using braces is better than newlines.

>> No.70409089

>>70402190
backend or frontend first? I'm trying to decide on how to design my gazillion dollar idea into an app and it's so frustrating choosing the right tools and approach I already feel like giving up

>> No.70409154

>>70409086
>You still haven't come up with an actual rebuttal on how using braces is better than newlines.
It looks better and the delimination is clearer. And since I'm an actual programmer (you aren't) then my subjective opinion on aesthetics has more weight than your subjective opinion on aesthetics.
Lots of indentation without braces is full on cancer.

>> No.70409355

>>70409044
C++20 is upcoming latest standard, shithead

>> No.70409721

>>70409355
I'm not sure what your point is. C++17 is still the latest standard.

>> No.70409827

>>70398039
The 140000 uncensored hentai images are before augmentation.

>> No.70409950

Can somebody tell why it isn't working properly.

https://pastebin.com/AgWkKYq0

In my program I have one pointlight. If I calculate FragColor as accumulated values from lines 66-70 all fragements are pure black, this commented out instruction in 72th line. But when I just use this one PointLight as in 73th everythink works fine. In theory CalcDirLight should return vec3(0, 0, 0) if I didn't pass anything to uniforms.

>> No.70409963

>>70402446
It's never been that popular, but it's widespread in academic and open-source communities as the offspring of Unix, which was pretty much the only publicly documented OS at the time. Thus, this made C the de-facto lingua franca of CS and systems programming. But don't get it wrong, it's not popular in the sense it panders on people's approval, unlike modern _popular_ languages, like Sepples, Python or JS.

>> No.70409975

>>70403760
All the official documents have a fee, for anyone who wanna make an officially compliant implementation of it, but for study purpose and convenience, the last draft before release is free of charge and identical in contents to the official thing.

>> No.70409989

int main(void) {

int a = 4;
int b = 5;
printf("%d %d", b-- > a, b-- > a); // this prints "0 1".
}


how? I'm so confused

>> No.70409995

>>70409989
undefined behavior

>> No.70410001

>>70409989
booleans are just integers.
False is 0, true is any nonzero number, but it's usually safe to assume to be 1

>> No.70410009

>>70410001

yeah but then there is this

int main(void) {

int a = 4;
int b = 5;
printf("%i", b-- > a); // this prints "1".
}

>> No.70410017

>>70409721
no?

>> No.70410022

>>70410009
5 is greater than 4, resulting in true, which is 1
What's the problem?

>> No.70410031

>>70410022

in the code snippet before it was 0

printf("%d %d", b-- > a, b-- > a); // this prints "0 1"

>> No.70410037

make new thread already, I need to shitpost

>> No.70410052

>>70410031
Function parameters are not evaluated in a defined order in C

>> No.70410058

>>70410009
And this is problematic because? b-- decrements b by one after accessing b. So you pull b, see that is 5 and greater than 4, and then store it as 4, pass true (which in this case evaluates to one) as an argument to printf, and in the next operation would have b as one less. Your first example is problematic because C won't evaluate both at the same time, and in what order it does so is undefined. So in this case the compiler spat out code that
int main(void) {

int a = 4;
//sets a to 4
int b = 5;
//sets b to 5
//and evaluates the following line as such:
printf("%d %d", b-- > a, b-- > a); // this prints "0 1".
//the second comparison is evaluated, spits out true (1 in this case), and decrements b by one
//b is now four
//the first comparison is evaluated as 4 > 4, which is false, or 0, and then decrements b by one again
//b is now three
//printf is called with the arguments of ("%d %d",0,1)
}

This is undefined behavior. C is an inherently procedural language, and simultaneous operations don't really exist.

>> No.70410059

>>70410052

I see , thanks.

>> No.70410075

/!\ A L E R T /!\

New thread

>>70410072
>>70410072 >>70410072
>>70410072 >>70410072 >>70410072
>>70410072 >>70410072
>>70410072

/!\ A L E R T /!\

>> No.70410225

>>70410017
You're right, C++20 is the latest standard. I'm going to go enable -std=c++20 on my compiler and start writing C++20 code using all the new C++20 features like modules, concepts, spaceship operator, contracts, etc. Because after all, C++20 is the latest standard.
Oh wait.

>> No.70410333

>>70408915
Kill yourself.

>>
Name (leave empty)
Comment (leave empty)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
Captcha
Action