/t/ - Technology

Discussion of Technology

Index Catalog Archive Bottom Refresh
Mode: Reply
Options
Subject
Message

Max message length: 8000

Files

Max file size: 32.00 MB

Max files: 5

Supported file types: GIF, JPG, PNG, WebM, OGG, and more

E-mail
Password

(used to delete files and postings)

Misc

Remember to follow the rules

The backup domain is located at 8chan.se. .cc is a third fallback. TOR access can be found here, or you can access the TOR portal from the clearnet at Redchannit.

WebSockets Enabled! Threads should update live as posts are made. Please report any issues on >>>/site/1518

8chan.moe is a hobby project with no affiliation whatsoever to the administration of any other "8chan" site, past or present.

Programming Thread: Up and Running Edition Anonymous 04/27/2020 (Mon) 19:03:16 No. 9
Hey Anon, Learn to Code! There's a bunch of free resources for learning to program. Come here to ask for advice or to discuss current projects. Download the complete Gentooman's Library: https://g.sicp.me/books/ Visit MIT OpenCourseware on (((YouTube))) https://www.youtube.com/user/MIT Or take one of these free online courses being offered by universities right now: https://www.freecodecamp.org/news/free-courses-top-cs-universities/
Edited last time by codexx on 05/04/2020 (Mon) 00:54:19.
>>9 DON'T TELL ME WHAT TO DO
learning to code is easy learning to code something with a degree of complexity well is a different matter where are the resources for that?
(106.35 KB 1200x675 C4iv_loUoAAcN-5.jpg)
>>15 I've added a few more advanced resources to the OP. >code something with a degree of complexity If you have something specific in mind, post a request and I'll dig up some resources. If you just want to learn how to do software engineering, there really is no substitute for actually joining a project or getting a job/internship, unfortunately. If you just want a chance to get beyond learning a language and repeating then the answer is to understand data structures/algorithms and to actually build a project for yourself.
>>16 yes, more on the engineering side. Naturally you only get good at it by actually working, but are there established do's and dont's?
>>64 There's what they teach you in a software engineering course about good and bad practices, but the actual practices change by company and in my experience insisting one way is "the right way" to do something will just draw ire from others on the team, especially those with seniority. Most software is developed haphazardly based on internal guidelines. The only universal rules would probably be >always use version control >documentation helps >set realistic goals and milestones Even something recommended like code reviews or style guidelines can be abused and turned into a hindrance. Good software engineering practices also vary by language. The way you want to package a Python product is much different from a C++ product, even if they have the same development pipeline. If you want recommendations, you should honestly focus on the stupid DevOps bullshit. Make sure you're comfortable with git. Write test cases. Configure a Continuous Integration pipeline to automatically build your code and run tests. These things, when done properly, make managing large codebases easier. The cruft and technical debt of a small script is very little. Having good regression and unit tests helps identify problems as you make changes. If you want to practice, you're probably better-off writing toy software that mimics actual products. Can you design a word processor? How about an image editor? These things will take more time than most of the project ideas included in the OP, but you will encounter the sort of problems real products face.
I don't want to spoil my brains with that garbage.
(2.92 MB 500x606 934h87tg9384h9384y3984y5.gif)
I actually ordered the SICP book because I'm a music autist and want to learn MIT Scheme for Lilypond music engraving. It's either that or paying some fag 2,000 bucks for what I need and fuck that shit.
>>92 Good luck, anon! We'll be here if you need any help. By the way, you can find the full text of the book along with assignments, code samples, etc on the MIT Press website. https://mitpress.mit.edu/sites/default/files/sicp/index.html
(23.36 KB 100x100 XD.gif)
>>93 Ooo, has the instructor side too. I saw it for sale but chose not to buy it. Neat.
What are some basic programming concepts that you failed to grasp when you were starting out? I completely misunderstood the utility of classes and essentially only used them to separate variables into several .cpp files. I didn't think to store related variables in one class until way later when I realized that it'd be convenient. The closest I came to that was storing related values of the same type in a vector, and eventually I thought "hey, there should be a way to access related variables by their name, shouldn't there?" and figured out that I'm a dumbass. That sort of comes with the territory of how I learned shit, learning a new language plus several libraries all at once from several disconnected jewtube tutorials and trying to get shit to work while googling errors until things worked. No, I'm totally not asking to see if you'll end up naming more things I might have missed. What makes you think that? Haha.
>>478 Mostly struggling with APIs or bindings. Over time I've realized that documentation isn't great or that I was using someone's half-finished project advertised as a complete solution. Sometimes libraries are just stuck in a different decade. A lot of them do their own thing, which might clash with the base language or other libraries. Not entirely my fault, but I've never found interfacing with other software as easy as it should be. Never struggled much with the code itself. Once I learn to read someone's style, it opens up to me. Most of my early learning curve was spent on tooling. Git takes time. Debuggers take time. Editors take time. Time to learn the basics. Time to learn how you can customize them. Time to build a workflow. Time to learn the idiomatic way to write code. Also, I didn't learn it the hard way (thankfully) but writing solid tests is worth it. Especially if you can configure a Continuous Integration pipeline. Not a big deal for small personal projects, but I find even a few unit tests to ensure my scripts haven't broken serves as a good sanity check.
>>478 Probably the importance of using 3rd party libraries. For example, one day I wanted to crawl a website and instead of using libcurl or some other library to do the webpage fetching I built my own engine using raw sockets and an HTTP parser I made. It was a piece of shit too, but it actually did its job. Also related, for some reason I find object oriented design very unintuitive and I often struggle a lot with it. What's even more funny is that when I code in C, every time I do it I end up writing object oriented C and I love the code that results from that. I don't understand why C++ gives me so much trouble.
>>478 >What are some basic programming concepts that you failed to grasp when you were starting out? < What OOP really is about I got taught the typical "a cat is a mammal, which is an animal" kind of OOP they teach everywhere. It's really easy to understand, but unless you program is built around zoological taxonomy, it's completely useless. I wish I could have just been taught what OOP really is about instead of having to work it out myself. < Assuming that if something is not said, then it doesn't apply This is really dumb, but I remember once reading in an API documentatin that a linked list has O(n) access time, while it said nothing about hash tables. So being a moron I used a hash table, even though at four items the overhad of the hash table would have probably been greater than the indirection of a linked list. Of course the realy solution would have been to just use an array. < Writing code more complicated than it needs to be By this I mean using 'foo.bar.baz()' several times instead of assigning it to a variable. I was young and thought "bah, there is no need for creating a variable here, I can read everything just fine". Now that I'm older I can still read it, but after having read so much code I don't have the patience for untangling all these chains. Now I declare my variables at the start of each block and break up big functions into smaller chunks.
>>491 >I got taught the typical "a cat is a mammal, which is an animal" kind of OOP they teach everywhere. It's fine for teaching inheritance. It's just utterly useless as a model for how to write a program. You don't necessarily need inheritance to use objects, and your objects don't need to be like real objects. They're just containers of similar variables with a defined interface. But that still doesn't really cover how they're used in industry, probably for two major reasons. First, because describing how to use them properly is nearly impossible. And secondly, because there's lots of "how not to do it" examples in industry where people have created horrible abuses of object-oriented programming, decided they were a genius, and then slapped a name on it and tried to convince others to do the same. And some people listened. And that's how you end up with all these custom typedefs to hybrid classes that all inherit from each other with the sole goal of operating a factory that produces custom objects at runtime. Instead of just designing the classes you actually needed to rigidly cover a set part of the spec.
what is the best internet browser?
>>493 >>3 Just realized there's no name field?
is college a good idea if your main goal for learning to program is to get a job?
>>498 Depends on what kind of job you want, really. Some will require a Bachelor's and will not look at you without experience. Most will care about experience over a degree, but your resume will need to be solid so expect to put the time you'd have put into school into projects. I think the biggest benefit of attending college is that you'll be forced to do tedious programming puzzles that a lot of employers like to ask people about. That can help. Otherwise you might spend more time doing real work and have zero experience solving problems in vacuum. Plus it will force you to learn a variety of subjects. You'll be exposed to a bit of everything at a good school. Some might complain about taking an Operating Systems class when they just want to do Machine Learning, but I think being well-rounded is beneficial. Same goes for your general courses; you'll be asked to read and write at a college level, and some STEMlords just fail at that and really need it. Going to school takes discipline but they'll give you assignments with deadlines and that has a way of getting people off their ass more than "I promised I would work from SICP today". So if you're bad at self-control when on a home desktop then college has another benefit there. But the downside is the cost. Unless you're going to a local school and your government is covering the bulk of it, the bill can be daunting. Definitely try a community college first to help on savings. If you go that route, sometimes an Associates is enough to get a programming job. It's also a minimum 3-4 years of your life being trained, so you need to ask yourself where you want to be in 5 years and hold yourself to a schedule. Otherwise you can spend forever lurking the halls of a costly institution. The alternative is to just do webdev, which doesn't require a degree basically ever. You'll be a glorified graphic designer doing frontend work in JavaScript frameworks. Absolute cancer if you ask me. But the pay isn't bad (although dealing with clients often is) and a total moron can pick it up with enough time. If you want to write software but can't be bothered to learn "real" programming, you always have that as an option.
(70.34 KB 1191x1684 file-001.png)
(70.23 KB 1191x1684 file-002.png)
>>498 I see four ways of getting a programming job. There are others, if your lucky. >Option A >No college >Either your really good or you know the right people >get job >Option B >be autist >College >git gud >no friends >do FOSS/side projects >send 100s applications >get job >Option C >be normalfag >College >network (parties and bar) >fuck bitches >network (volunteer and part-time) >fuck bitches >get job >Option D >all of the above >genius, never study, GPA 4 >party boy, zigachad >FAGMAN internships, 5 years experience before graduation >Is actually the hidden master of Linus and Theo t. collegefag
>>498 It's a waste of time if you can avoid it. My "computer science" college was a joke and full of downers. Literally being able to read a man page and knowing to put #define nigger_h #ifdef nigger_h at the top of your file already puts you an order of magnitude above eveyone else for the first 3 years. I dropped out near the end because I got a job paying good. I couldn't be fucked to finish it as all it would have taught was some more basic progrmaming shit, and it was pretty obvious at that point the "how are you gonna get a job without le diploma" meme is just that. This was 10 years ago.
(58.00 KB 644x573 oop.png)
>>498 College can definitely help you find work. Most of the material was shit, but I did get two internships through my program and made some pretty good contacts. Research whether your college has a work experience program. HOWEVER, you need to be aware of the job market in the areas where you want to work. (Which may just be the city you live in.) I'm in an awkward position now because all my work experience is in embedded and dsp, but most of the jobs in my city are webdev. I have been unable to get programming work for the past few months, probably due to the the economic downturn and my relatively niche field. My only comfort is that I am not a webdev.
>>513 >#define nigger_h #ifdef nigger_h that's not an include guard <#ifndef nigger_h <#define nigger_h <//coad <#endif nigger
>>493 >what is the best internet browser? Don't need fancy formatting? Use some terminal-based browser like lynx, w3m, elinks, or something. >Want CSS On anything GUI, keep Javascript turned off. Use Tor browser. >Don't care about being anonymous 100% of the time, want reprieve from capchas Brave. Chromium-based so it's highly compliant, de-googled, privacy-focused, and pays you crypto just for being on the internet. Also includes Tor privacy mode so you don't have to change proxy settings whenever you want to use it over Tor (but probably best practice to just use Tor browser when using Tor even though I just use Brave Tor windows lmao)
>>532 >Brave. Chromium-based so it's highly compliant Made up issue. Literally any bloatware browser is compliant enough for the jewniggernet. >1 BAT has been deposited into your account.
>>533 Are you capable of speaking without using a buzzword every second?
(9.00 KB 331x379 max 1.PNG)
(16.46 KB 613x640 max 2.PNG)
So, I picked up C three days ago. I am quite new to programming, with only some very small experience left and right, but good experience in MATLAB. I have two questions. In max 1 (which actually returns the sum, it should be sum() ), what is exactly happening with the pointers? I make a double array, and specify its three elements. I pass is to the function, and this is where my understanding stops: I think that the * at max() turns the a in main() into a pointer, which is then passed to max(), where I can use is as x[] to call values? In the second program my understanding is even worse: In main() (the commented code) I create a char array, which is filled with cmMod(111111) for example, which returns 1 km, 111 m and 11 cm. I can use this array to call its values, but why is the star then present at char *r? Secondly, why is the * present at *cmMod()? This would cause the function to pass a pointer to my array right? Finally, what does if(!r) return NULL; do?
>>569 >I think that the * at max() turns the a in main() into a pointer No, the * in max interprets whatever the function is receiving in that parameter as a pointer. You're probably getting confused because you don't see a * in main. In your example, you're using a vector, and vectors have a very similar behavior and syntax to pointers, in particular what's happening here is that the name of the pointer or vector when used yields the memory address it points to, so max is being passed that memory address and using it as a pointer. To give an example, you could have: int main(void) { double a=1.5;; printf("%f\n", max(&a, 1)); return 0; } And this would also be valid. Despite the fact that a is not a pointer, you're passing its memory address to max (because of using &), and max is interpreting as a pointer. This would not work without the & because then you'd be passing a value to the function and the function expects a pointer, so the compiler would complain. >why is the star then present at char *r? Secondly, why is the * present at *cmMod()? Please use line numbers the next time, it makes things easier. The * at declarations mean to specify that you're declaring pointers. Declaring a pointer means that the variable is meant to contain a memory address and that the variable (pointer) allows the syntax to examine and change that memory address (pointer syntax). If the * is not present at the declaration, the variable would be meant to contain values (integer, floating point values, or other values). So in this case the * are present because you're manipulating memory addresses (first returned by malloc() and assigned to cmMod::r, then returned by cmMod() and assigned to main::r ). This applies both to the variable declaration (char * someVariable) and the function declaration (char * someFunction() for instance). >Finally, what does if(!r) return NULL; NULL is a value that is supposed to be an invalid memory address. When you compare a pointer to NULL, you're checking whether the pointer contains a memory address that's invalid. Here, the code is checking whether malloc() returned a valid memory address or not. If the system is low on memory, or you request a fuckhuge amount of memory (3 terabytes for instance), malloc() can only return NULL and hope you catch in your code that it couldn't allocate the memory you requested. Fuck, I feel like making some code now.
(208.31 KB 500x375 cup of absolutely fantastic.png)
>>570 Holy shit, thank you so much for the detailed explanation! I'll have to look over it a few times, but this already really helps a ton dude. I've been making random exercises from websites for now, and I am already somewhat comfortable using the syntax and structure. Feels really powerful and straight-forward, and seeing there is a large chance I'll be using code for my career this summer project of mine is really helpful.
>>528 >I'm in an awkward position now because all my work experience is in embedded and dsp, but most of the jobs in my city are webdev. I have been unable to get programming work for the past few months, probably due to the the economic downturn and my relatively niche field. My only comfort is that I am not a webdev. I know those feels. >>571 Always happy to help someone get into C. >Feels really powerful and straight-forward It is, it's also pretty consistent. I love it. One thing I noticed about my previous reply: >>570 >Finally, what does if(!r) return NULL; What I wrote before is correct but I didn't notice the comparison was made as "if(!r)", which is a niggerish way to do it. Because in most systems NULL equals 0, and because 0 equals boolean false in C, "!pointer" is most of the times equivalent to "pointer==NULL", but there are systems where 0 is a valid memory address which is why NULL is implementation defined, so hardcoding it to 0 is not a good idea.
(25.31 KB 519x475 costs.PNG)
Yet another (probably) retarded script: a function to calculate energy costs. First 50 units cost 0.5 /u, next 100 units 0.75 /u, next 100 units 1.2 /u and all units beyond will cost 1.5 /u ; an additional surcharge of 20% is added. My question is not so much about the correctness (it shits out all the correct (edge) values, I manually verified) but more about the first 203-205 and 206-209. I want this script to be flexible, so I wanted to add 'delims' numbers of delimiters, which can be filled in independently of cost and unit limit. Finally, a final cost per unit is given and a surcharge. My problem lies in the use of arrays to store these values in. Initially, delims was just int delims = 3; , line 203 was int *unitdelim[DELIMS]; , lines 204-205 were uncommented, but compilation failed (expression { token, variable-sized object not initialized) in the array value assignment without using a loop - which was given as the solution on some websites? So, If I want an elegant solution without bombing my memory or leaving any remains after the function has been called, how would I approach this? >>572 Got it.
>>570 Also, I now understand nearly exactly what was going on! I described to myself out loud what exactly what is happening, and thinking in terms of the pointer as a special flag for handling said pointer did the trick: at last, I truly see how the addresses and values are manipulated and passed.
>>569 What >>570 forgot to mention is that in C arrays decay to pointers when you pass them as arguments to a function. That is, if you have an array of three integers and pass it as an argument to a function, all the function gets is a pointer to the first element of the array. The function does not know how long that sequence is, so you either need to pass the size as an extra argument or have a sentinel element (e.g. have the last element be a negative number when only positive numbers make sense). This array decay is one of the ugly parts of C. >>574 I don't understand what you mean, but I noticed a problem in your code: you need to tell malloc exactly how many bytes you want, not how many elements you want: < unitdelim = (int *) malloc(delim * sizeof(int)); Keep in mind that if you reserve memory that way it will be allocated on the heap, not the stack, so you need to manually release itas well. The array definition above is allocated on the stack and does not need to be released manually. Unless you need your data to persist after a function call you should prefer the stack. I also noticed that you did not declare any type for the allocated data. You need to declare the variable as a pointer to integer. Note that pointers and arrays are not the same, you cannot assign a memory address to an array variable. Arrays can decay to pointers, but they are not pointers and you cannot assign pointers to them. Are you learning C from websites or are you using a book? Websites can be really shit, I recommend the K&R C book, it's quite small for a programming language reference book, and very well written. With websites the quality is usually what you paid for. >>572 > but there are systems where 0 is a valid memory address which is why NULL is implementation defined, so hardcoding it to 0 is not a good idea. I'll need a source for that one. In my copy of K&R C (2en edition), section 5.4 it says > C guarantees that zero is never a valid address for data, so a return value fo zero can be used to signal an abnormal event, in this case, no space. > Pointers and integers are not interchangeable. Zero is the sole exception: the constant zero may be assigned to a pointer, and a pointer may be compared with the constant zero. The symbolic constant NULL is often used in place of zero, as a mnemonic to indicate more clearly that this is a special value for a pointer.
>>576 Let's try that then. Also, yeah, one of the advantages of MATLAB is that it is perfect for very mathematical things: matrix, vector and differential equation stuff are handled more conveniently.
(32.89 KB 1920x1080 autism.png)
>>576 >This array decay is one of the ugly parts of C. It can be pretty ugly, it's bitten me in the ass a bunch of times. In any case anon was handling it correctly. >>574 >I want this script to be flexible This is good practice. I think the easiest way to make this work would be to not declare a size for the array in the initialization and let C do this for you. Then you calculate (at compile time) the size of the arrays and assign it to delims: int unitdelim[]={50, 100, 100}; double unitcosts[]={0.5, 0.75, 1.2}; const int delimQty = sizeof(unitdelim) / sizeof(unitdelim[1]); What I don't like of this solution is that the arrays are disjointed. If you want to change your code later on, you will have to change two independent lines of code in a concerted way or your program will have bugs, and it's good practice to minimize this. Regarding the solutions you proposed: >which was given as the solution on some websites? C99 mandated that variable sized arrays like the ones you tried to use were okay according of the standard. Some compilers (MSVC :^)) didn't think it was necessary to comply with that because why comply with standards. C11 removed this restrictions because it was too difficult for some to implement it in their compilers and certify them as standard compliant, so it was left as optional, and you're left with a situation to resolve. Which you probably tried to do with >#define delims 3 Unfortunately #define will define delims for the whole rest of the file, which is undesirable. Slightly more elegant is to use an enum like a nigger: enum {delims = 3}. There aren't a lot of other elegant ways to solve this in a nice manner. >int *unitdelim[DELIMS] >unitdelim = (int *) malloc(delims) There are several problems with this. Like anon commented you're allocating only delim bytes, but you meant to allocate delim elements (of a certain type). The other problem is that you're declaring unitdelim as an array of pointers. This means each slot of the array will contain a pointer, not a value, which is what you want. Furthermore, despite the error of trying to assign the address of the array like anon explained, there's a conceptual error: malloc returns one memory address for a whole block of memory of the size you requested, so you'd be assigning one of the pointers in the array, not all 3, meaning the other 2 would still be uninitialized and would likely crash your program on access. See pic related for how things would look like in memory after this had executed, assuming pointer sizes and ints of 4 bytes. >unitdelim = {50, 100, 200}; In C, initializer lists may only be used on initialization (in the same line you define your variables), like in #203 on the image. >>575 das good. >>576 >I'll need a source for that one. In my copy of K&R C (2en edition), section 5.4 it says The NULL part is easy. Here's a link to one of the latest revisions of C11 (revisions are available for free): http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1570.pdf >7.19 Common definitions <stddef.h> >The macros are >NULL >which expands to an implementation-defined null pointer constant So the standard doesn't mandate that NULL is 0. The other part (0 being a valid memory address) comes from experience as there are embedded microcontrollers where this happens (they have 0 as a valid memory address), but to be honest I assumed this was enough to conclude it was kosher according to the standard and didn't actually double check it. I actually had to handle a case of this myself, as I was brought on board on a project that was on fire and used a microcontroller where this happened. The original programmer had created several bugs where 0-initialized pointers were being passed to functions and then indirected for write operations. The program was not segfaulting (because the memory was A-OK to write according to the memory model of the device) so the bug had always been in the firmware silently corrupting memory away, which is kind of funny considering the device was making the company several million dollars a day in revenue.
>>576 >Arrays decay to pointers The idea that it "decays" is false. Arrays are always stored as a memory address. There is simply no way to pass them by value since even an array stored locally is actually just a "pointer". You can just as easily perform range operations on any pointer. int ptr[n] is just syntactic sugar for "address at ptr + n * sizeof(int)". Understanding that you'te just accessing straight memory addresses is actually quite convenient. You're not losing anything when you pass it in to a function because naked arrays already fail to offer any convenience functions. In C++ you could always pass in a vector or some other data structure, but you'd be wise to do that by reference as well.
I hope I am not spamming the board to death, at least I'll give it some traffic >>576 I would have declared a datatype in the first line, as described in >>574 . >>576 >>578 > malloc Makes sense. I was also in doubt about using calloc, since this uses a second argument as datatype size. That clears it up, mostly. Two further questions: in that case, why does max2.png in >>569 work? I only reserve three bytes (?), while I place three ints in it? The function does return the correct values. Second, > Keep in mind that if you reserve memory that way it will be allocated on the heap, not the stack, so you need to manually release itas well. The array definition above is allocated on the stack and does not need to be released manually. Unless you need your data to persist after a function call you should prefer the stack. So does malloc/calloc allocate on the stack or the heap? This sentence conflicts a little. Then, how would I or when should I release the memory when using such a function? > Book Nope, the first tutorial I used was https://www.youtube.com/watch?v=KJgsSFOSQv0 , and I am now doing Pajeets big book of exercises at https://codeforwin.org/c-programming-examples-exercises-solutions-beginners . Since I have some programming knowledge from Uni and am somewhat versed with how computers work on a physical level - plus calculus C level of mathematical knowledge did not prompt me to read a book yet. I might download or find a copy of the K&R sometime, if it is exceptionally helpful. >>578 > calculating at compile time This would probably be the most elegant solution for the application I am using, since you would just have to change a single predefined number and would not have to worry about the later definition. > disjointed arrays Do you mean concatenating the strings? Or a struct? The variables have no mathematical relations, as they are predefined by the "Electrical company". > declaring an array of pointers I see what happens now. Yeah, it should just be an array of values I use for the price ranges. I should write out what happens on paper, that'll help. > using enums Which is not really that convenient of a solution no? Finally: for future reference - this means that I can not return a variable length array from a function right? I foresee that it might become a problem when doing variable timestep integration.
(8.08 KB 290x275 memory.PNG)
>>580 > releasing memory I have an example function for this; image related. I just want to retrieve the first and last digit, but after the function has been called, I stored the variables in my main "variable space(???)" and I wouldn't want the original values to be left somewhere taking up memory.
>>580 >I only reserve three bytes (?), This is correct. >while I place three ints in it? The compiler automatically converted them to char. Read up on type conversions. Also increase the warning level in your compiler (/W4 in MSVC, -Wall in GCC/Clang) to have it bitch at you for such conversions. Ideally your data types would match, otherwise it's good to have the compiler warn you when they don't because type conversions are very tricky and if something doesn't match, it's a good idea to review it (and after reviewing it and confirming it will do what you want, you can use type casting to tell the compiler to stop warning you for that occurrence). Looking the function closer it looks like r[2] might overflow for cm>127999 (as 127999/100000 would give 127, which is the maximum positive value a signed char can hold). >So does malloc/calloc allocate on the stack or the heap? On the heap. You allocate on the stack by declaring local variables (uint8_t bigassBuffer[0xFF]) or using alloca(). The latter I'm not sure if it's standard and there's seldom a reason to use it. Also keep in mind the stack is not the heap, the stack is designed to hold enough memory to pass arguments to functions and hold local variables (so a bunch of bytes), don't abuse it. On a PC you probably will have plenty of stack but that will not be the case in every device. On the other hand, stack memory is allocated extremely fast while dynamic memory is a huge headache and not available in more modest devices, so you have to reach a compromise. >how would I or when should I release the memory when using such a function? See free(). >The variables have no mathematical relations They have an important relation in the program. Consider a large function with a couple hundred lines of code and a big preamble of variable definitions, and let's say that you haven't touched this code in a year or two and then you want to make some changes to it. You will have to remember that if you add another value to one of the arrays, you also have to add a value in the other one, and if you don't do it when you go through the arrays in the for you might go out of bounds. This is undesirable, so ideally the code would be structured in a way that wouldn't let you fuck up like this. >Which is not really that convenient of a solution no? Ideally you would just declare the flexible array but it's not portable, so you have to compromise. >this means that I can not return a variable length array from a function right? You can do a couple of things, like creating a structure with the pointer and a size member and passing it as a (pointer) parameter. Something like this for instance: struct param { uint32_t size; char *ptr; } void func(struct param *p, int number) { const static char str[] = "NIGGER"; const uint32_t len = strlen(str); const uint32_t size = len*number+1; //consider terminating null int count; if(p==NULL) return; p->size=size; p->ptr=malloc(size); p->ptr[0]='\0'; for(count=0; count<number; count++) strcat(p->ptr, str); } int main(void) { struct param p; func(&p, 30); printf("%s (%d chars)", p->ptr, p->size-1); free(p->ptr); p->ptr=NULL; p->size=0; } I did this while bored in a meeting so I didn't compile or review it and I did it with half my mind on something else so don't copy and paste like a nigger without making sure you understand if it works. >>581 When you don't want it anymore, free() it, and after that do not use the memory locations that you freed. This only needs to be done for dynamic memory (which you get through malloc()). When you have a fixed number of elements in your array like there, however, you usually pass down the pointer/array instead of returning it from the called function, which is much cleaner.
>>580 Small note: my C reference states that malloc() accepts the amount of ints if I specifiy it to be an array of ints, so malloc(3) will correctly give my an array of 3 values... I think.
>>584 Never mind this one, didn't update to see >>582 yet.
>>584 >malloc() accepts the amount of ints malloc() accepts the number of bytes. An int can be any size and is generally determined by your CPU's architecture. The C spec only dictates that a short is <= int <= long <= long long, so all of them could be 32-bits and it would meet the spec. Do not make assumptions about the size of int. Char is one byte pretty much universally, though. For the sake of readability and ensuring you get the correct size in bytes for an array you should probably use: int *arr = new int[length * sizeof(int)]; This will calculate the size of the data type during compilation and then perform a simple multiplication at runtime to create the correct amount of space on the heap.
So: I written my first piece of code that I am actually proud of. Take a look at this exercise I did, from a Pajeet website: Print the following number pattern for (N=x=y, square) or (x, y rectangle): 4444444 4333334 4322234 4321234 4322234 4333334 4444444 And so on. I knew for a fact and from a little experience that Pajeets and Bugmen have awful coding skills, but today I experienced it first-hand. First: take a guess how the "solution" looked like (Don't look it up, that's cheating) and second: how would you approach this? I actually found a super elegant solution, I'll share it tomorrow. Yes it is a trivial problem and truly a beginner level exercise, but I was still surprised how well it worked.
>>602 I have a solution for squares, but how should a rectangle look?
>>604 and how should even squares (4x4, 6x6, etc.) look?
>>605 ehh fuck it here's my solution in c, its in "functional style". It made sense when it was just odd squares but making it work with even rectangles really made it confusing. There is probably a dumber solution that is better (maybe just some clever string manipulation). #include <stdio.h> #include <stdlib.h> #define MAX(s, t) ((s) > (t) ? (s) : (t)) int main(int argc, char *argv[]) { int r, c, nr, nc, x; if (argc < 3) { fprintf(stderr, "Computers started going to shit when they made them for niggers.\n"); return 1; } nr = atoi(argv[1]); nc = atoi(argv[2]); for (r = 0; r < nr; r++) { for (c = 0; c < nc; c++) { x = MAX(MAX(0, abs(nr - r * 2 - 1) - MAX(0, nr - nc)), MAX(0, abs(nc - c * 2 - 1) - MAX(0, nc - nr))); printf("%x", x / 2 + 1); } printf("\n"); } return 0; }
>>604 >>605 Up to you, or you leave them undefined. My solution is always x/y symmetric, so even squares and rectangle could look like this: m = 6, n = 6 333333 322223 321123 321123 322223 333333 m = 5, n = 6 333333 322223 321123 322223 333333
>>606 You have give or take the same solution as me. Now, watch and gave upon the horrors that a cruel God hath released upon mankind: /** * C program to print number pattern * https://codeforwin.org/2016/06/number-pattern-17-in-c.html * By Pankaj Prakash */ #include <stdio.h> int main() { int N, i, j; printf("Enter N: "); scanf("%d", &N); // First upper half of the pattern for(i=N; i>=1; i--) { // First inner part of upper half for(j=N; j>i; j--) { printf("%d", j); } // Second inner part of upper half for(j=1; j<=(i*2-1); j++) { printf("%d", i); } // Third inner part of upper half for(j=i+1; j<=N; j++) { printf("%d", j); } printf("\n"); } // Second lower half of the pattern for(i=1; i<N; i++) { // First inner part of lower half for(j=N; j>i; j--) { printf("%d", j); } // Second inner part of lower half for(j=1; j<=(i*2-1); j++) { printf("%d", i+1); } // Third inner part of lower half for(j=i+1; j<=N; j++) { printf("%d", j); } printf("\n"); } return 0; }
(47.31 KB 913x965 ClipboardImage.png)
For the record, this is what he does.
Nearly forgot to post my solution: int pat18(int i, int j, int m, int n) { return max2(abs((m/2.0)-i-0.5)+1,abs((n/2.0)-j-0.5)+1); } This accepts the two sizes and coordinates, and passes the value to that coordinate. The loop function is just a run-of-the-mill grid printf. int m = 7; int n = 7; int i, j; for(i = 0; i < m; i++) { for(j = 0; j < m; j++) { printf("%2i ", pat1(i,j,m,n)); } printf("\n"); } Needless to say, it satisfies me greatly to find such an elegant solution.
>>617 I'll let you take the win, its definitely easier to understand that way. I like fixed point math, but with modern CPUs floating point is usually faster.
>>634 I have to say, sometimes you may find the solution to such a problem in an instant, and as soon as I saw this one, I knew exactly what I had to do.
Holy fuck, C is kinda fucky when you want to use multi-dimensional or variable length arrays. I can handle passing the length of a generated array to a function, but things are fucked up when looking at simple subjects like matrix arithmetic. I said it before, but this and variable-timestep things must be a pain in the ass. Since I want to do those things quite a lot, is C truly the language optimal for these things? Is there a good solution for just even passing a mxn matrix to a function which can use it dynamically?
>>657 If you're expecting matrix multiplication out of the box you're not looking for a general purpose programming language. Make your own matrix module to encapsulate the operations or get a library that does it for you. C++ might be prettier for this since operator overloading will make the code cleaner, but if you're struggling already I don't recommend it.
>>658 I really didn't expect matrix multiplication out of the box, I expected better handling of multi-dimensional arrays. The fact that you need to input the rows of the multi-dim array as an argument in the matrix itself is strange - passing it as a separate argument, fine.
>>658 >If you're expecting matrix multiplication out of the box you're not looking for a general purpose programming language. The absolute state of Cniles. Basic math being included in standard libraries isn't a high bar to pass. >>657 Just use C++, there's very few cases in which pure C is a better pick.
For the time being, C was fun, but I am running into constraints here. I can do a lot and have probably the most freedom and interaction, but I am getting frustrated. >>663 To be precise, I would want a method where I input a multi-dim array (and probably the dimensions separately), like void addMatrix(double A, int ma, int na, double B, int mb, int nb, double C, int mc, int nc) or addMatrix(double A, double B, double C) but well shucks man that **A is just not allowed man - and I get why, but there is no neat solution for the passing of these things. Even passing the matrix just as a pointer and perform pointer arithmetic is a huge pain. >>665 I'll take a look, since even the K&R book does not provide a good solution beyond void A[m][n], A[][n] or (*A)[n].
>>667 Oh wow, I forgot that ** is of course a spoiler tag. That should be addMatrix(double **A, int ma, int na, double **B, int mb, int nb, double **C, int mc, int nc) or addMatrix(double **A, double **B, double **C)
>>668 And while this works, it complains about me not specifying the dimensions - which leads me to believe that just doing this is a bad practice: void addM(double *A, double *B, double *C, int m, int n) { int i,j; for(i = 0; i < m; i++) { for(j = 0; j < n; j++) { *((C + i * n) + j) = *((A + i * n) + j) + *((B + i * n) + j); } } }
>>669 I first did this: addM(A,B,C,3,3); printM(C,3,3); Which gave errors, but calling them like this works again without errors? What the fuck is happening here? addM(*A,*B,*C,3,3); printM(*C,3,3); I dereference the pointer of A in main, so I pass the value of A[0][0] to addM. Next, the function accepts this AS a dereferenced pointer, which just takes the true pointer to A[0][0]? This is needlessly complicated. I apologize for quadrupleposting and spamming the board this much, but this is really annoying.
>>670 And it gave me incorrect results irregardless. Fucking hell.
>>671 Hah, I fucked up in my printing program. It works for now. I should read some more of my code instead of complaining, I'll hold off from posting for now.
>>672 Sorry I was too late to offer any help or advice. You should consider creating a Matrix struct which has the dimensions as members. That will make a function to do operations on them much simpler, since you will only need to pass the matrix structs in. Don't forget to do a typedef to avoid having to say "struct" constantly. It will also make it clear that your functions are meant to take matrices and not just any set of ints. Definitely don't be afraid to ask for help. Sometimes it's the best way to learn.
(84.30 KB 749x844 gsl.png)
>>665 I'm not aware of any general purpose programming language containing matrix arithmetic out of the box. >Basic math being included in standard libraries isn't a high bar to pass. >Just use C++ Are you retarded or so ignorant that you've never done matrix algebra before? >>668 Learn how to structure your code, the road doesn't end exactly the moment you start grasping the syntax. Make a matrix abstraction like >>673 said, then you'll have a set of functions like matrix_mult(matrix_t *a, matrix_t *b), matrix_add(matrix_t *a, matrix_t *b), etc., or you can get a library that already does it for you like anyone else would. Look around the net for one, e.g. https://www.gnu.org/software/gsl/ (pic related).
>>674 Thanks, that helps. Any more standard C libraries that might be useful in calculus, plotting and/or data manipulation? Matrix stuff is still a little abstract for me, but things like these are really helpful. I am mainly doing all of this to get acquainted with C, and all the math since I'll be starting my Masters final project after the summer. I serves as a good practice method for myself to recap all of the info of the last 4 years. >>673 Don't worry, sometimes it's best to just keep on puzzling. Structs might be a better solution, but coming from Matlab (and a few other languages), matrix handling is really quite convoluted here.
>>677 >Matrices are convoluted in Matlab Which is funny because they are first-class objects. Every language is going to hack in advanced mathematics in a way that suits its workflow. Precise math in C and C++ has always been clunky because the language is designed around low-cost abstraction, not easy math. There's a reason most physicists used FORTRAN and mathematicians switched to Matlab (which is basically a driver around FORTRAN code, or was at its inception). These days a lot of people have gone over to Python because it has a library for basically everything and numpy has out-of-the-box support for pretty much any operation imaginable. Try structs, though. "Reviewing C" is worthless if you can only use it like you took an intro course, and it will save you a lot of headache. Although I am personally with the guy who said there's rarely a reason not to use C++. It provides better abstraction which is easier to use and it does it with almost no performance penalty. C fags like to brag about the language being lightweight but outside of some embedded environments you don't absolutely need C, and even that's going away in favor of powerful microcontrollers that can easily store a full C++ install.
>>679 I meant convoluted in C, Matlab just lets you pass anything with numbers to any function that handles numbers so that was super convenient. I am still thinking about learning Python as well - but I would also like the knowledge I have gained in the past two weeks to be useful in making games for example. I'll see how things pan out, but the library that >>674 posted has a LOT of shit, even fucking Monte Carlo integration for the three people on the planet that use it, and even Rydberg and Coulomb functions - useless for everyone, but very useful for physicists and chemists.
>>674 >I'm not aware of any general purpose programming language containing matrix arithmetic out of the box. Depends on how strict your "general purpose" definition is, does FORTRAN fit? In any case, the fact that modern CPUs have circuits designed specifically to be fast at matrix multiplications should be a hint about how important that kind of math is.
>>677 >Any more standard C libraries that might be useful in calculus, plotting and/or data manipulation? Although gsl is an established project with lots of functionality, it's not standard. C has very little in terms of standard libraries. Unfortunately I can't really recommend any libraries for your needs since I've never had to deal with tasks like those in C, but C has libraries for almost anything you could possibly need, so do a couple of searches to find alternatives and try the ones that look the best for what you want to do and your compiler kit. A simple search yielded the gsl library from my previous post, another seems to indicate there are good alternatives for plotting libraries which support lots of compilers and formats, and I'm not sure if it's something you need but there are also a good amount of options for arbitrary precision arithmetic libraries (in case you need to do precise computations with integers of several hundred or thousand of decimals). Go nuts! >>683 >but the library that >>674 posted has a LOT of shit GNU has some pretty cool projects for scientific shit. In general given the age of the language there's a ton of stuff made for it. >>684 Unfortunately I don't have a lot of experience with FORTRAN, however I don't think it would qualify as a general purpose language. >In any case, the fact that modern CPUs have circuits designed specifically to be fast at matrix multiplications should be a hint about how important that kind of math is. They do add instructions to perform some operations with multiple data in one go, but that's even more low level and difficult to manage than what you'd get with C and you're limited by the register size. It's hardly the kind of functionality we're discussing here. Also interestingly, I don't think compilers generate functions using those instructions unless you manually code the instructions yourself, but fortunately the kind of code that would need to use those instructions would usually be already encapsulated in some library so you don't need to.
>>687 Compile this with -O3 -msse2{3,4} and you will get branch-free and SSE vectorized code. or read https://gcc.gnu.org/projects/tree-ssa/vectorization.html typedef struct _M { float v[4][4]; } M; M M_sum(M *s, M *t) { M x; int r, c; for (r = 0; r < 4; r++) { for (c = 0; c < 4; c++) { x.v[r][c] = s->v[r][c] + t->v[r][c]; } } return x; } M M_mul(M *s, M *t) { M x; int r, c; for (r = 0; r < 4; r++) { for (c = 0; c < 4; c++) { x.v[r][c] = s->v[r][0] * t->v[0][c] + s->v[r][1] * t->v[1][c] + s->v[r][2] * t->v[2][c] + s->v[r][3] * t->v[3][c]; } } return x; }
>>687 They will generate them, but the conditions have to be perfect. Most commonly, matrix math is used for machine learning and so GPUs are increasingly being optimized. Nvidia has been selling the concept of "tensor cores" lately, which is just high-speed matrix math units. SIMD is nice but it's more about parallel integer multiplication inside of larger registers. For massive parallel floating point you're going to want a tensor core.
(94.38 KB 1024x768 1339426043398.jpg)
>read SICP >get stuck on the "Newton's Method" bit >read Calculus Made Easy >get stuck on infinitesimals >no idea how to even begin to get started on nonstandard analysis
>>697 Do you mean the concept of derivation? Or the computational method behind it?
>>697 What >>698 said; what are you trying to learn to do? Do you already know calculus? If so, why are you reading "calculus made easy" and struggling with a concept like infinitesimals? Or, in summary: we can't answer a question you haven't asked. Try asking a question.
>>699 It's not a question. It's a cautionary tale.
>>700 On the contrary, I think you just need to learn the conceptual basis of calculus.
>>697 only the first (or maybe second) chapter is math heavy. you wont really understand calculus if you don't understand logic and proof methods. You can easily be trained to do derivation of polynomials much like algebra, but still essentially blind to the logic. If you serious enough to read SICP why read "calculus made easy"? "Calculus" by Spivak is similar to SICP in how it demands a precise understanding of the underlying theories before even touching the core subject. Learning calculus the easy way is like learning programming by copying and pasting python snippets from a "recipes" book.
>>499 >>511 >>528 I am a seething turbo-autist with ADHD who can't do college because I am total shit at academia and I can't do homework or pay attention in "lectures", but I've been programming ever since I was in elementary school and I know for fact that I could do a good job if I was hired. What's the best course of action for me?
(59.65 KB 400x468 1446041466326.jpg)
>>703 Your only real option is building a solid portfolio. Either by getting some kind of job, joining an open source project, or starting your own project and actually making something of it. If you can walk in to an interview with an entire github/gitlab full of repos demonstrating solid understanding of material then you can theoretically get hired. The first job is the hardest one because you have no track record or "real" experience. After that, the first company can vouch for you to the second. Normally I'd never recommend books like "Cracking the Coding Interview", since I think companies that hire that way are asking for trouble, but you will be at a disadvantage since they are quizzing prospective hires on common Computer Science homework material. It's an attempt to verify you know the theory. This will be your biggest struggle, so either give up on these jobs entirely or pirate that book and work through it. For what it's worth, SICP also covers a lot of that stuff and it's more coding focused. The only issue is probably that it's functional and not object-oriented like most jobs are looking for. So once again, a post here comes down to "work through SICP". You basically need to be able to say which sort algorithm is best for a scenario, draw a binary search tree, and tell them the runtime complexity of some arbitrary code. There's entire classes on this material being taught, and you'll need to go toe-to-toe with diplomafags. The good news is that most of them suck at these questions and fail because they just crammed the material without understanding it.
Speaking of jobs, what does everyone's resume look like? Do you use one of those newer templates full of colors and retarded shit like star ratings for language and technology knowledge? Or do you still have something more old school with no colors and only one column? I still have the latter and I feel a bit left behind but I do not like the newer style. I'm gonna need to remodel my resume soon so any resume advice welcome. Might not be the right thread but it's moderately on topic. >>688 That's pretty cool. On closer inspection it seems gcc favors XMM instead of the x87 FPU and always uses XMM, which I didn't think it would.
>>705 I think the latex thread became the de facto resume thread, at least for a bit. Obviously everyone is really apprehensive to actually post their resume, which makes it hard to share examples. Maybe we should have a resume thread For mine, I basically eliminated the margins, stuck all the personal/contact info in a centered header at the time. I follow that with an objective (required by some HR departments) and a "skill cloud", which is basically a table (lines hidden) containing my top skills. After that, I have job experience from my top 3-4 jobs. Each of those has bullet points with descriptions of my duties. Numbers are really good, for example "optimized code which led to a 50x speed-up in common task". I was hesitant to do bullet points, but my friend in HR at [well-known corporation] insisted and now I'm used to it. I stick education and some volunteer work in as an afterthought, just to keep it there. My trick is that the template follows the format of a "one column" resume, but because I eliminated the margins I have room to play with. So I use right-justified text on the same line as other text to cram more information into a tighter space. For example, the line with my title will also have the dates I worked there on the right. This avoids wasting lines for trivial information that is immaterial to the work and lets the highlights be my skills and duties, which is what should be put forward to begin with.
>>706 Ah, I'm doing something similar to you. One column, very small margins, skill summary with bullet points, job descriptions in bullet points and specific descriptions that have numbers with a different type of bullet. Unfortunately it still looks dated and it makes it looks like a boring wall of text. I might have to remove some stuff, but I have no idea what. >I was hesitant to do bullet points, but my friend in HR at [well-known corporation] insisted and now I'm used to it. I mixed a little bit, to be fully honest. The bulk of the description for each position is in bullet points but I do have 1 or 2 lines telling what the company and job were about in general terms.
Let's say that I'm working on a library that's going to expose a C++ class, and I want to avoid leaking implementation details (private types, private member variables, private methods, etc.) on the interface header file. How is this supposed to be done? This is easy in C but it's giving me headaches in C++. Here's an example class: #include <someOtherClass1.h> #include <someOtherClass2.h> class library { public: enum class returnValues { ok, not_ok, definitely_not_ok, }; library(){} ~library(){} returnValues pub1() { return returnValues::ok; } private: enum class action { action1, action2, do_barrell_roll }; returnValues priv1(someOtherClass1 &c){} //someOtherClass1 defined in someOtherClass1.h returnValues priv2(someOtherClass2 &c, action a){} //someOtherClass2 defined in someOtherClass2.h } Here the class has an internal type (action), and uses 2 other classes defined in 2 other header files. The latter is specially annoying because it forces me to distribute more header files with my library, header files which are of no use whatsoever to whoever consumes it. Searching around I found that people recommend the PIMPL idiom to fix this issue, and while it looks like yet another workaround to the issues created by OOP, it seems like it would do the job, however this technique goes a bit too far and doesn't allow me to expose the things I do want to expose (public types like returnValues for instance)! What now? None of the examples I've found contemplate this, they always do the piss easy example of a class that has 1 method receiving and returning void. How would you approach this? I have a few ideas but none are very good.
>>721 First, it's a bad idea to use c++ as anything other than a header only library as the ABI changes from version to version and isn't standardized, so you'll need a .lib for each compiler and version you want to support, but ignoring that, PImpl does solve your problem, for you don't need to stick your entire class inside of it. Expose what you want to expose in library and forward declare the Impl class. Library doesn't need to see the definition of Impl to hold a pointer to it, only a declaration, so you can define Impl in some cpp that includes library and make use of its members. class library { public: enum class returnCodes { ok, not_ok, definitely_not_ok, }; library() {}; ~library() {}; returnCodes Foo() { return returnCodes::ok; } private: class Impl; // Defined somewhere else. Impl* _impl; }; Cppreference has a page on PImpl https://en.cppreference.com/w/cpp/language/pimpl. I recommend bookmarking the site if you haven't already as it's a very good resource on c++ and its standard library in general. It's basically one step removed from the standard document, but it at least attempts to include examples and explanations alongside its jargon.
If I want to render environments and objects other than text-based things, am I the best off with learning C++ and use openGL? I cannot find good tutorials for using C and openGL.
>>733 As far as I know it's written in C, but generally game developers (and those doing 3D graphics) tend to use C++ so I imagine most guides will cover that. It's much easier to stick things in objects that just automate tasks rather than relying on passing stuff through functions. I'd recommend learning C++ anyways. Unless you have to work without a standard library or are writing an operating system there's generally little benefit to sticking to C. That said, you should probably consider learning Vulkan instead of classic OpenGL, which is effectively deprecated. If you need any resources on C++ I can recommend a few books. I can't say I know any OpenGL (or Vulkan) resources, but I can dig through my collection of PDFs and try to find something if you need it. But I imagine it will use C++.
>>734 I see - will consider. Sure, it'd be appreciated!
>>728 >it's a bad idea to use c++ as anything other than a header only library Now that doesn't really sound believable, does it? >you'll need a .lib for each compiler and version you want to support I already took that for granted, happens with C too, though I don't know to how much of an issue there is from one version of a compiler to another. >you can define Impl in some cpp that includes library and make use of its members. I thought of doing that, but isn't having that kind of circular dependency terrible form? I mean, library would depend on impl, and impl would depend on library. The headers wouldn't depend mutually because of the forward declare but it still smells stinky. >cppreference Yeah, I use it as a reference sometimes, but man the information written there is written with such complexity. I realize there might not be another way because the language itself has gotten really complex, but that doesn't make things any easier to understand. >jargon This is something that I've wondered for some time. How much of the jargon and complex language functionalities does the average C++ programmer understand and use daily? Am I the only one that thinks the language has gotten absurdly complex? For example, would an average C++ programmer already know what >std::experimental::propagate_const<std::unique_ptr<impl>> pImpl; means? When you read what it does it's reasonable, but I had never come across propagate_const before, and this is just the first thing you see on the linked page, I find that cppreference continually pulls std jargon out the ass and I have no idea how there can always be more!
>>738 I should have specified C is definitely much better as an interface than C++. The lack of name mangling and function overloading allows for a much more stable ABI which can be compatible between different versions of the same compiler or, more specifically, different versions of the standard (a program compiled with C++11 can call c functions in a library compiled with C++20). Once you start using C++ things in the interface you've basically locked yourself in to that compiler version, and it's why you hear stories of companies sticking to C++11 while C++20 is out: they use libraries which they can't recompile. I worked at a place where we didn't switch off of C++14 because no one wanted to recompile boost. > isn't having that kind of circular dependency terrible form? It's terrible form in the sense that it isn't sanctioned OOP design, but strict adherence to a paradigm is for academics. Sometimes the pragmatic solution to a problem won't jibe with the language at hand, and you can either spend hundreds of hours re-architecting a system or just go with what works. In this case, the forward declare could be avoided if you use a void*, but then you'd need to cast it back anytime you want to use it. >>jargon >This is something that I've wondered for some time. How much of the jargon and complex language functionalities does the average C++ programmer understand and use daily? Am I the only one that thinks the language has gotten absurdly complex? For example, would an average C++ programmer already know what >>std::experimental::propagate_const<std::unique_ptr<impl>> pImpl; >means? When you read what it does it's reasonable, but I had never come across propagate_const before, and this is just the first thing you see on the linked page, I find that cppreference continually pulls std jargon out the ass and I have no idea how there can always be more! It really depends on what you mean by average. If you're writing, reading, and reviewing C++ for 8 hours a day, you start to pick up a lot of the esoteric things pertaining to what you're doing. I'd say most of my peers know what templates are and can write simple ones (maybe even a little SFINAE); know about vector, map, set, sort, pair/tuple, string, iostreams, smart pointers, lambdas, iterators, numeric_limits, and maybe filesystem; are capable of looking up most of the language they'd find out in the wild (advanced templates being the thing most would have trouble with); and know some of the surface level jargon of the standard (declare, define, undefined behavior, etc.). Beyond that, you need to have an interest in the language itself to start picking up more stuff. As for if average C++ programmers would already know >std::experimental::propagate_const<std::unique_ptr<impl>> pImpl; I'd say they could look at it and understand what it meant. Most people have probably never used anything in experimental save for filesystem when it was in there, so I'd doubt that anyone could say they've used it out in the wild, but my first intuition is that it would make the pointed to object const if its containing object was const which, from my understanding of cppreference, is the case. The fact that cppreference likes to stick new and strange things into their examples is why I like it so much. You can click on most things that come from the library right from the examples, and their usually simple enough to understand without having to look up everything new. I might be biased, but I like learning about the new and strange stuff, so I don't mind their inclusion. If you really want to get into the jargon, all the papers from the standards committee are posted online at http://www.open-std.org/jtc1/sc22/wg21/docs/papers/ and the working draft itself is posted at https://github.com/cplusplus/draft. I mostly watch the papers for future features and the read the draft if I come across some questionable code.
>>749 >I should have specified C is definitely much better as an interface than C++. I got what you meant anyway. While the lack of name mangling in C does make things a lot easier and might be one less point of failure when linking, ultimately mixing binaries compiled with different compilers is bad idea and might not always be guaranteed to work. You'll link them for sure, but the whole thing might crash at runtime. Hell, if I remember correctly on Windows you can crash your program at runtime even if everything is compiled with the same compiler because they have different underlying runtimes for different compilation configurations. I personally had to work on a (C) project that was being compiled with quite an old GCC toolchain and I needed newer compiler switches not available in that version, but when I tried compiling the code with a newer GCC it would first fail to compile the project and when that got solved, it would randomly crash during execution and not perform predictably. Ultimately I think it's always a good idea to thread carefully around different compilers. >I worked at a place where we didn't switch off of C++14 because no one wanted to recompile boost Did the new compiler really fail at linking with the old libs? Is it really that common for newer compiler versions to make breaking changes to the mangling? And isn't boost kinda easy to compile? >I like learning about the new and strange stuff It's a bit too much for me sometimes. It's interesting stuff, but barely any of it is useful, and I feel a bit peeved that I sometimes have to dig into the language so much when I feel other languages don't require such a big effort and deep knowledge. Anyway, thanks for your answers, they're interesting. I don't get the speak with a lot of other C/C++ devs unfortunately and I lack a ground reference.
(40.31 KB 600x746 how.jpg)
I don't understand memory alignment errors in C . How can one unintentionally end up dealing with misaligned memory? Can you give me a real world example?
>>767 Pointer aliasing for example. In lots of applications, serial numbers are 4 bytes long, or 8 bytes long, or less. Using a 32 bit int or a 64 bit int is very handy to do operations against the serial number (such as comparisons), but using a buffer composed of several 8 bit integers is very useful to store them and transmit them, so what could happen is that the storage is 4 integers of 8 bits each for the aforementioned purposes, and then it's casted to an integer of 32 bits of size to do some other operation, and although this is valid according to the standard it is an unaligned access.
>>767 When you assume sizes/offsets of structs you can run into issues. On 386 Its completely valid to read a DWORD at any byte offset, which can make errors subtle. Its generally not something you run into unless you're trying to be clever. related: http://www.catb.org/esr/structure-packing/ I've had issues while working with structs and binary formatted files. here the file is manually packed, but read with assumed packing, this is a stupid example but I remember doing something similar when I was new. #include <stdio.h> typedef struct { char fugg; int benis; } spurdo; void read_spurdos(spurdo *S, int n, char *fn) { FILE *fp = fopen(fn, "r"); fread(S, sizeof(spurdo), n, fp); fclose(fp); } void write_spurdos(spurdo *S, int n, char *fn) { int i; FILE *fp = fopen(fn, "w"); for (i = 0; i < n; i++) { fwrite(&S[i].fugg, sizeof(char), 1, fp); fwrite(&S[i].benis, sizeof(int), 1, fp); } fclose(fp); } void debug_spurdos(spurdo *S, int n) { int i, j; for (i = 0; i < n; i++) { printf(":%c B", S[i].fugg); for (j = 0; j < S[i].benis && j < 40; j++, putchar('=')); printf("D\n"); } } int main() { spurdo sparde[] = { { 'O', 9 }, { 'D', 6 }, { '(', 1 } }; spurdo gondola[] = { { '?', 0 }, { '?', 0 }, { '?', 0 } }; write_spurdos(sparde, 3, "fugg"); read_spurdos(gondola, 3, "fugg"); debug_spurdos(sparde, 3); debug_spurdos(gondola, 3); return 0; }
>>770 Ebin
>>770 That's a good link and one of my favorite reads. I remember adding attribute(packed) to my first attempts at packed structs, because I didn't trust I was doing it right. Once I realized it was doing nothing and potentially introducing performance penalties, I stopped. Newbies really underestimate the performance penalty of unpacked, misaligned data. They also forget that fitting data into the size of a cache line is immensely beneficial. I've seen benchmarks which stall because you add a single extra unpacked char to a struct.
(12.11 KB 220x280 stupid australian cunt.jpg)
Whats a good resource for learning JCA/JCE and Bouncy Castle? I don't necessarily need to know the mathematics, I am just having trouble understanding the completely autistic class structure. I bought pic related without realizing it's from 2005, so I need something up-to-date. Also, why was the Java Cryptography Architecture designed by a team of severely autistic chimpanzees?
>>784 >Also, why was the Java Cryptography Architecture designed by a team of severely autistic chimpanzees? Because everything about Java was designed by a team of severely autistic chimpanzees. Java is what happens if you take C++, which is an awfully designed language, and remove the C parts, which was the justification for the awful design. You end up with an awfully designed language for no good reason.
>>836 >which is an awfully designed language, and remove the C parts Java is more comparable to C# but it eats more memory do to wanting to be faster just for the sake of claiming to be fastest. >programming languages don't have performance >only implementations do >you can't say that C is faster than Java!!!!!!!11111111111111 >performance doesn't matter, only programming time does because when I sell it, I won't be the one looking at the loading screens all day >rubs hands
(265.06 KB 997x879 eggnog.jpg)
>>838 >performance doesn't matter, only programming time does because when I sell it, I won't be the one looking at the loading screens all day
>>838 >Java is more comparable to C# C# was modelled after Java, but without the burden of backwards compatibility with ancient Java code, which is why it does a few things better. It's still mostly the same OOP Pajeet tier shit, which is intentional by design.
On the topic of C#, is it mostly constrained to Windows platforms on the field or is it also used for Linux to a good degree?
>>850 Mono allows you to compile and run C# and .NET applications (I believe) on Linux.
>>851 I know, but the question was more oriented towards if companies actually do C# development on Linux, as with it being originally a Windows framework I imagine that's the platform most of the development takes place on. I feel I should learn a higher level language but my experiences with Java haven't been great. C# looks a lot like C++ but if people only use it on Windows I don't think it's the language I should go after either. Wish C++ was more popular.
>>852 Ah damn I completely read over the last part. Microsoft is trying to push cross platform with .NET Core, and usage of it is growing in the (loonix) server space. The traditional .Net framework is still focused on Windows development. About C++ development, you shouldn't feel discouraged about learning it if you don't feel there is demand. There certainly is but its likely less than times past since the current programming world has a heavy lean to web development.
>>852 From what I have seen in job postings, C# programmers are also expected to work with various Microsoft Windows technologies. I don't remember the names of those technologies, but I did not even bother applying to those jobs, because I figure they would also make you use Windows as your work OS. I am working as a Java Pajeet, but at least they let me set up my own computer myself.
(134.91 KB 1059x778 wt.png)
Someone on another thread mentioned wt, a C++ library to create webpages. I decided to give it a try and I ended up making a very simple imageboard proof of concept to learn the ropes. It's very interesting though still a bit constrained in some regards, I really hope they continue improving it. One thing I noticed and was surprised by is that somehow this thing does not need javascript to update the DOM. I can make a post and the post is appended to the page correctly even without javascript enabled. Also because of how the library works a thread update timer would not be necessary because the server could just update your browser's page in realtime when a new post is submitted. Overall kind of exciting man. Wish I had a server to play around with for shenanigans. >>868 What's the typical setup for Java development on Linux? What programs are required and what's the typical workflow?
>>881 Java really likes you to have an (((IDE))) regardless of platform. These days, IntelliJ is pretty common, but a lot of shops still run Eclipse. I wouldn't use Eclipse unless you need to contribute to a project which uses it already. But you can absolutely treat Java like C++ and use a makefile to compile a JVM binary. There are linters for every text editor and there are plenty of guides for configuring your makefile, although the process is more arduous than with C++. But it's clear when you look at the ecosystem that Java developers find IDEs appealing and seemingly design their projects around having a package management inheritance tree and debugger available on-screen at all times, and they will rely heavily on hints.
>>881 >What's the typical setup for Java development on Linux? What programs are required and what's the typical workflow? You obviously need a JDK (Java development kit). The current LTS version is Java 11. You also want a build system, so your choice is either (((Maven))) or Gradle. For development most people use IDEs, basically either Eclipse or IntelliJ IDEA, but most people developing in Java are also Pajeets. I don't use that shit, I use Vim with the Java language server, it's basically all the good stuff factored out of Eclipse into a standalone process which the text editor can then communicate with to get the IDE-like features. If Vim is not your cup of tea you can use literally any other editor which supports LSP. It's a really comfy setup, but it's also an uphill battle because there is probably like five or so people in the entire world who don't use one of the two bloated IDEs. People get really offended when someone steps out of bounds.
I'm writing a password manager in C, and I've got a couple questions. I'm wondering what library should I be using for encrypting the file/files. I've been told I could use libraries implementing SSL, like OpenSSL, LibreSSL, bearssl, etc. pass uses GPG, so I thought about using GPGME, or calling GPG directly from the program. After taking a look at the documentation of one of those SSL implementations, however, I didn't grasp much about what I should be doing. I'm nearly an absolute novice at programming, so I could use some guidance here. I'd like to use something lightweight, and GNU isn't known for being that. Another thing I'm wondering is how should I go about password storing. I mostly started writing this out because I didn't like how pass just stored every password in a separate file with the filename being the name of the website. Anyone with read access to the file system can know which websites you use easily, so there goes some metadata. All that is supposed to be stored in a file is a password (though associated metadata can be stored and parsed too, but apparently not by default), and since a GPG encrypted file is always 147 bytes larger than the unencrypted file, password length might leak too. Anyways, I thought about storing passwords and metadata in one file, that way I'd get rid of those two problems. But I recently came across https://github.com/drduh/pwd.sh which actually does store passwords separately, but filenames are randomized and stored in an index file, also encrypted, so that takes care of the paranoia I described earlier, and I think it is superior to the approach I was about to take. I believe that since only one password is unencrypted at a time, and not all of them, there's less risk of having all passwords leak if there's somebody snooping on what's in the RAM. Only the password being extracted would be compromised. I welcome any and all suggestions aimed at reducing the attack surface, in dubious ways like these or in more serious scenarios. Yes, I'm already using functions like strncpy() and other ones with "n", in order to mitigate buffer overflow attacks.
>>1129 > C > password manager > novice in programming Please stop. Security does not belong into the hands of a novice, especially in an unsafe language like C. If you want to play around with encryption, then by all account go ahead and knock yourself out. But if you mean to actually use and rely on it you need more experience under your belt first. > I mostly started writing this out because I didn't like how pass just stored every password in a separate file with the filename being the name of the website. You don't have to do it that way, you can put whatever information you want into a file. It is the usual way, but with a little elbow grease and shell scripting you can use only one file and store your password and metadata in any way you want.
>>1130 >If you want to play around with encryption, then by all account go ahead and knock yourself out. I'm not looking to roll my own crypto or whatever crazy shit. I know full well I shouldn't be doing that. Do I need years of experience just to call a couple of functions from a library to do encryption and decryption for me? >especially in an unsafe language like C I already said I'm paying attention to mitigate attacks exploiting that. I know I need to be careful with that, it's part of the fun. Are you spouting memes just because? You visit Hacker News much?
>>1018 >Java developers find IDEs appealing and seemingly design their projects around debugger available on-screen at all times, and they will rely heavily on hints. Why is this wrong? I will admit to have sinned and never set up a development environment without an IDE, but outside of bloat and maybe coarse configuration options I don't understand why some people hate them so much, and what does setting up everything separately has so much in favor. >>1131 The problem is that security in software that needs to handle cryptography is very difficult to get right, that's why the usual advice is to avoid it entirely and rely on already existing and very audited solutions instead of rolling out your own crypto solution. This doesn't apply only to the actual encryption algorithms but also to whatever you do with those algorithms, that is, not every piece of software designed to use AES is secure for example. It's a bit difficult to take seriously that you're mitigating attacks and exploits when in the previous line you say that you're almost an absolute novice at programming. If you actually are looking to create something to use and not just to learn, I suggest you to keep looking for some other existing solution. >>1129 If you still want to go forward with it, first get a grasp of the algorithms and how they work on a high level (e.g.: AES, Serpent, ECB, CBC, etc.) to learn what you should be doing. OpenSSL is huge and I think it should expose the algorithms you want, and if you're targeting Linux chances are everyone already has it installed. You can probably get single .c implementation of algorithms from lesser known libraries if you want something simpler and that you can compile into your project, ultimately if you're rolling out your own solution you might as well go for the full book of sins.
>>1133 >Why is this wrong? I will admit to have sinned and never set up a development environment without an IDE, but outside of bloat and maybe coarse configuration options I don't understand why some people hate them so much, and what does setting up everything separately has so much in favor. Bloat is one reason, yes, IDEs are slow and convoluted. They also force you into a certain workflow, you either use the entire thing or nothing. You cannot just take your own text editor and hook it up to the IDE, you have to use whatever shitty editor the IDE ships with. And it's not just the editor, but every other component as well. Finally, your entire project now becomes vendo-locked. Since the IDE manages the entire project you and any collaborator need the same IDE and pray that an update doesn't break anything. At best you will be able to at least compile the project from the command line. You don't need any of that shit. Unix itself is already an IDE, you just need to hook up the parts. Yes, it takes a bit more work, but you usually do it once and that's it. You can swap out parts as you wish. You could for example have both Emacs and Vim configured to use the same tooling. And all collaborators can have their own setup instead of being mandated by the project lead. I used to be an IDE user, but the frustrations kept piling up until I just had enough and dived head-first into Vim. It's like jumping into cold water, at first it's awful, but soon enough you get used to it and actually learn to enjoy it. >>1131 It's not just about not rolling your own crypto. You will eventually have to keep unencrypted data in memory in your application, and so you must take extra care that your application does not have any vulnerabilities and does not leak any data.
>>1146 >You will eventually have to keep unencrypted data in memory in your application, I'm fully aware of that. After all, it's part of the reason I was asking whether to just store all passwords in one file that is unencrypted at once or keeping each password in a separate one and unencrypting one when needed. Less unencrypted data in memory, less shit that could go south, I think. >and so you must take extra care that your application does not have any vulnerabilities and does not leak any data. Ok, well, I'll make sure to do that. I want to dogfood this one day, after all. I'm thinking of going for libsodium, since their docs seem to have been made foolproof, but once I build up the confidence I'd like to use BearSSL, since it's not only portable and available on distros, but quite lean.
>>1146 >Unix itself is already an IDE which fails at basic features like code navigation (ctags and cscope are dogshit) yep, IDEs are shit too, i use a dedicated gaymer box to run IDE #520 so i can navigate code for language #20 of project #5723 i'm auditing. >>1131 yes, actually. especially in C. KEK
(13.97 KB 196x256 the satanic bible.gif)
What is the worst possible textbook for learning C, and why is it this monstrosity? >Numerous typos and syntactical errors (esp. missing curly braces) >The example code in Chapter 1.9 DOESN'T EVEN FUCKING RUN >They completely avoid teaching you some of the basic syntax of the language, despite giving you exercises which could be solved way more easily with certain operators Am I retarded, or is this clusterfuck bad for anyone else? Maybe it's just a really bad introduction for people who are new to programming. I feel bad and possibly really fucking stupid for bashing the book made by the creators of C themselves, but surely I can't be the only one who finds it obscure at best, and maddening at worst.
(99.52 KB 640x684 I Don't C the Problem.png)
>>1130 >Security does not belong into the hands of a novice, especially in an unsafe language like C. Not the same anon, (I'm the same one from >>1244) but it sounds like I'm even more of a beginner than he is. Should I be worried if the overview of an Information Systems Security diploma program includes pic related?
>>1245 There's a world of difference between examining things and making design decisions that can impact a cryptographic implementation.
>>1246 That's a no, then? I'm not trying to be pedantic, but I'm still really new to all of this. The privacy/ security side of tech always was fascinating to me, so a career in that neck of the woods would likely be stimulating and rewarding, both for my own benefit, and in the sense that I could help people keep their stuff safe. The thing is, I'm starting from square one, and I only have a few months to become proficient in the way described.
>>1244 > Maybe it's just a really bad introduction for people who are new to programming. Yes, it is. In general a "The <blubb> Programming Language" book is not for beginners, it is for people who already know how to program, but don't yet know <blub>. > They completely avoid teaching you some of the basic syntax of the language, despite giving you exercises which could be solved way more easily with certain operators This is common in textbooks, they want you to solve the problem with what you already have first. Then you learn more powerful operators and you can appreciate what they give you better. If they just dumped everything there is on your head it would just be confusing. > Numerous typos and syntactical errors (esp. missing curly braces) Curly braces can be omitted when there is only one statement in the body. In fact, curly braces can be seen as a way of packing several statements into one. That's not to say that you should do it, but it can make sense in a book where space is limited. > The example code in Chapter 1.9 DOESN'T EVEN FUCKING RUN I'll have to look into that one later.
>>1245 >>1247 You're talking about undergoing training while the previous guy was talking about implementing an actual system that was supposed to be safe. You're not going to be implementing security solutions at a development level in your training, anything you make is going to be experimental and for learning purposes, and most likely it'll just involve understanding how buffer overflows work and maybe making a tool or two.
>>1250 >In general a "The <blubb> Programming Language" book is not for beginners, it is for people who already know how to program, but don't yet know <blub>. Alright, that makes sense. The authors do reference Fortran and Pascal a lot, though I assumed that was just because of the time period during which the book was written. >This is common in textbooks, they want you to solve the problem with what you already have first. Then you learn more powerful operators and you can appreciate what they give you better. If they just dumped everything there is on your head it would just be confusing. That makes sense, though I still think it might be better to use exercises as opportunities to teach syntax. I guess it would be a lot to take in all at once, though. >Curly braces can be omitted when there is only one statement in the body. Huh. I didn't know that, actually; thanks for the tip. >>1251 Alright, gotcha. Thanks for clarifying.
>>1148 > libsodium how about NaCl?
>>1289 I can't find a lot of reasoning behind libsodium being superior to NaCl with a quick online search. According to what I heard, NaCl is alright code wise, made by a guy who knew what he was doing, but it turns out packaging it is a world of pain. That means it isn't as likely to be in other distros as libsodium, since it's a fork that specifically addressed this issue and probably a few others. Why libsodium in particular? I took some features from KeePassXC, and looked into the library they used. More importantly, they advertise it as an easy to use library, and after reading their docs, I just went with it. If I'm feeling braver after dealing with this I might try something smaller, like Monocypher or BearSSL.
>>1290 ok then, best of luck anon.
(13.19 KB 965x485 db1.PNG)
(13.23 KB 968x483 db2.PNG)
(13.19 KB 964x479 db3.PNG)
(11.83 KB 962x480 db4.PNG)
I have not been coding for a while, but have a command line-based game I slapped together in C++ to see what was possible with that. It feels really different with those classes and objects. I still need to figure out how I should link everything together efficiently, but I can see both advantages and drawbacks with this method. Featuring: > a menu with a scrolling intro > startup sound, random welcome message > player input if desired, random player honorific generator > deterministic room generation with a difficulty setting > enemies that move > chests with random items > inventory system that updates dynamically > inter-room movement and collision My first game that I created without something like Gamemaker, so more of a "how the fuck do I do this" and "how should I approach something like this" than an actual proper coding exercise. The coding is some serious spaghetti.
>>1343 That's a really cool project. Great way to learn terminal UIs and how to use objects. Games are a perfect place to represent things with objects. Doesn't matter if it's spaghetti; you've surely learned a lot by doing that and now you can use that to do something more involved. I'd be interested in updates if you do anything else like this or continue to build on it. There's lots of places you could take something like this.
>>1346 Due to the way I have built this, it will probably not happen since I ran into issues with how I organized things - I use objects and temporal willy nilly (all rooms are objects, but the enemies and chests are not for example) but since I also do not have a lot of experience with combining different source files - for utility functions for example - the way I use classes and the main program feels somewhat chaotic. Nonetheless, it was fun experimenting with all the shit available, but since I am /sci/ oriented, I might give the whole GNUplot and GSL a shot, since I also want to do more data related stuff. I would also like to give openGL or even Vulkan a shot, but those are also long ways away. If I have time, I might pour some time into Dungeon Bomber again, I like the concept and it does not feel too devoid of ideas and effort.
(24.26 KB 415x423 1443681020351.jpg)
>>499 I just want a job of any kind tbh, I am tired of being a NEET and don't to work as a fucking Janitor sweating my ass off and hurting my shoulders rushing. It isn't about the money, anyway I lost finances and bank account due to being autisticly mentally incompetent. My family doesn't want me working due losing disabity-bux but it's only way to get my life back and end up free from my family and hopefully regain my ability to control my finances again. I tried asking help from the SS office and state VR but they are no help. The longer stay a NEET, the longer I feel homicidal, I don't to end up dead or in prison for life but thought about it if I go, might as well take someone else with me. I want to get away from this hell hole
>>1365 It could always be worse anon. you could be NEET without even the autism bux like me
>>1365 Please wait 10 years before going through with such a thing. Halt all suicidal thoughts until the 10 years is up is all that I ask!
>>765 Should I read this book over K&R these days, or do I read this book after K&R?
>>1463 K&R really just lays out a spec and offers an introduction. It's valuable for historical reasons but useless for experienced programmers who want to learn C for daily use, and it's probably not the best introduction to programmer for those unfamiliar. While I cannot recommend Modern C (I have not read it), if it fulfills the same role as the Meyers Modern C++ series for C then I would say it's a good way to learn modern C paradigms. The usage of C has evolved over the years, even if the language hasn't, and the biggest issue with K&R is that it prescribes usage the way the designers expected it to be used, not the way it would actually come to be used.
Can anyone upload Effective C? https://nostarch.com/Effective_C What are some useful/practical C projects to contribute to? Most of the C projects I came across e.g., GNU are rather mature and their issues/tasks require deep knowledge of the project itself. I wonder if there are projects in C needing features to be implemented as opposed to simply bug fixing.
>>1512 C is mostly used for low-level libraries, embedded, etc. A lot of Python libraries, for example, implement some functions in C for performance reasons. C is only the primary language in a few cases; most desktop software utilizes C++ because objects are an easier way to manage a GUI. You can always ask even mature projects if they need help, and fixing bugs is a good way to learn the language because you can see for yourself the mistakes of others. Even mature projects like GNU will take newbies if you ask for mentorship. The biggest problem is that you will need to know C pretty well to contribute a new feature. It offers no hand-holding or guardrails so any contributor writing in C needs to know the language, its common tricks, and also common pitfalls very well.
Is Rust the language all the cool kids are learning?
>>1521 Rust is the language all the cuckolds are learning because they think it looks cool.
>>1522 What's even the appeal of Rust besides it being "memory safe"?
>>1522 >>1521 I thought it was Golang. >>1527 It's new, trendy, and probably pays well. You can't ask for more.
>>1527 Memory safety + good performance is big on its own, given how many issues stem for memory mismanagement. The fact that the dependency management and build system are saner than C and C++ is a bonus.
>>1530 Isn't Rust worse in terms of compilation speed and binary size?
>>1531 Compilation speed especially, due to the bootstrap deal, and compilation in general isn't available on as many architectures which is a no-go for embedded systems. I've not seen significant testing on binary size for actual projects, there was one test trying to shrink down a rust hello world down to a C hello world and getting reasonably close but that's not really too useful, still binaries size is a relatively minor concern unless things get really overboard. The community being shit because it attracts the wrong kind of devs is a far more serious issue than both of them, in all likelyhood.
>>1518 > literally the first page that's not the title or copyright notices < Dedicated to my granddaughters, Olivia and Isabella, and to other young women who will grow up to be scientists and engineers And into the trash bin it goes.
>>1535 Do books with these kinds of pages tend to be low quality not worth the time to read all the time?
(6.62 KB 180x239 searx.fmac.xyz)
It's cover looks so unusual, has any of you read it.
>>1365 i got rejected at another job today because i havent worked a coding job for long enough time for them to consider that i dont even know how to code. crazy how that works. stay on autismbux, fuck coding.
Am I retarded for disliking exceptions and trying to stick to return-based error checking?
>>1699 Not entirely. A lot of C programmers still use this and are used to it. The main issue comes with inconsistency. Some languages provide exception handling and expect you to use it which can conflict with bindings that use a different system. It becomes hard to track. The other big downside is you lose a return channel, and your functions likely have to modify data. You can use C in a "functional" way just by making data immutable and using functions to transform it, but you can't do that and also return error codes. It's also a fairly hostile paradigm to multithreaded or asynchronous operations, since they need to run independently and might not return at the same time, or at all. The problem with exception systems is their complexity. Even for a simple task, you need to create some specific object and then pass it somewhere. Handling it can be a nightmare if you don't try to catch it in a specific way, and catching all errors is a bad idea. Plus, it's rarely "free". There's almost always a performance penalty for throwing, catching, or even acknowledging errors. The new C++ exception system looks promising, but in most non-scripting languages the exception system is total junk.
>>1699 It can get burdensome for some programs. For example try writing an interpreter that returns control to the repl after a divide by zero. If you don't use some non local escape via exceptions or setjmp/longjmp every single recursive evaluation will need to check for an error.
>>9 The link to "browse the library" on the Gentooman library is broke. Not sure if anons here can do anything about it, just saying it for future reference.
>>1720 As long as the torrent still works, you're fine. Someone would need to rehost the whole thing. Probably costs a lot and is a target for DMCA. If you want individual books you should just download the entire library. You can just select Do Not Download if books/folders don't interest you.
(16.74 KB 723x111 I Suck.png)
If I'm too retarded to even figure out how to do pic related after multiple days of trying, would it be more realistic for me to give up on ever being able to get a job in InfoSec?
>>1848 What does the question mean? Convert all characters to their ASCII or Unicode code point and return their sum? What language? What libraries are allowed?


Quick Reply
Extra
Delete
Report

no cookies?