/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 2.0.

Please be aware of the Site Fallback Plan!
In case outages in Eastern Europe affect site availability, we will work to restore service as quickly as possible.

WE ARE PLANNING THE 2.8 SITE UPGRADE FOR THIS WEEKEND, MONDAY EVENING 6-27. DOWNTIME WILL BE BRIEF, AND THEN WE HUNT FOR BUGS.
(Estamos planeando la actualización del sitio 2.8 para este fin de semana, del lunes 6 al 27 por la tarde o por la noche en CST. El tiempo de inactividad será breve y luego buscaremos errores.)


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

Board Nuking Issue should be resolved. Apologies for any missing posts.

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.
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.
>>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?
(15.75 KB 630x630 mfw I try to code.jpg)

>>1854 My bad; should have clarified. It's really vague, I agree, but it's designed for use with C, and there aren't any explicit instructions with regards to libraries. If I understand his phrasing correctly, it's supposed to >take input, and store it in an array >take the individual ASCII values of each character in the string and add them all together >Spit out the sum total thereof. What worries me is that it came from a page designed to give beginners ideas for projects. Not only that, but I'm also designing my own project (a character sheet data generator) which obviously utilizes multiple function calls, and I can't even get that to work right. In particular, the Y/N options that are supposed to either send the user to the next function, or back to the previous one, just aren't working at all. The code is already littered with errors, even with stuff as simple as function arguments, despite the fact that I appear to be using the proper formats for all of them. I think. Luckily, I'm also interested in computer hardware repair and networking, so maybe those are better options for me. Probably better for having a more-stable schedule, too. I really love learning about privacy tech and how it works, but when it comes time to code, I just can't get myself into that sort of "toolbox" mentality for some reason.
>>1875 If there are no libraries listed then it probably means you can only use the standard library. Anyway, the task is pretty simple, so here are some tips: - Everything in C is actually just a number, the only difference is how many bytes of memory it takes. In particular, this means that a character is just a number as well. The character 'a' is the same as the number 0x61. You should have an ASCII manpage on your system (man 7 ascii) which lists the numbers - Strings in C are just a social construct: A string is an array of characters. You cannot tell the length of the array, but you know that the NUL character (ASCII 0x00) is the last character of the string With this it should be pretty straight-forward to solve the problem. There is the issue of integer overflow: if the sum is too large to fit inside an integer, something will happen. What exactly? If the integer is unsigned the value will roll over back to zero. If the integer is signed the behaviour is undefined. But you would need a lot of character to hit that limit. > Not only that, but I'm also designing my own project (a character sheet data generator) which obviously utilizes multiple function calls, and I can't even get that to work right. In particular, the Y/N options that are supposed to either send the user to the next function, or back to the previous one, just aren't working at all. The code is already littered with errors, even with stuff as simple as function arguments, despite the fact that I appear to be using the proper formats for all of them. I think. Well, I don't know your project, so I cannot help you with it. But one piece of advice: don't learn just programming, learn computer science as well. For example, and incomprehensive mess of function calls and if-else blocks might be much easier expressed as a finite state machine. But in order to see that you need to understand computing theory, not just how to glue libraries together like a Pajeet. I made that same mistake, thinking just because I knew a programming language I knew how to program. And if you just want to glue some scripts together that's perfectly fine, but if you want to actually program you will need the theory. Fortunately I was taking computer science classes at university, so I got my arrogant attitude beaten out of me early enough.
>>1881 Thanks for the help, anon; I appreciate it. >a character is just a number as well. Yeah, but the issue I was having was in how to get each individual character to add together, rather than just having something like this: printf( "The sum total of your string is %d\n", input ); which appears to return wildly inconsistent values, even just for single-character input. >Strings in C are just a social construct: A string is an array of characters. You cannot tell the length of the array, but you know that the NUL character (ASCII 0x00) is the last character of the string So, no matter what, there's no need to trim the length of the array after input is assigned to it, since null characters will not add to the sum total? I had that right then, at least. >With this it should be pretty straight-forward to solve the problem. I think I'm just not approaching the issue properly. I'm not sure how to get individual values from the array and store them separately, such that they can later be added together (if, in fact, that's even what I should be doing). >But one piece of advice: don't learn just programming, learn computer science as well. I would, but I'm specifically trying to find an employable field that won't take much longer than two years or so for basic certifications. I already made the retarded mistake of taking a rather impractical field as my only Major, so now I need to make up the difference without screwing myself over even more in the long run. <tfw late 20s and still absolutely no stable, liveable job prospects >But in order to see that you need to understand computing theory, not just how to glue libraries together like a Pajeet. >if you want to actually program you will need the theory. That's completely reasonable. I guess I might have to find something else to get my foot in the door and support myself in the meantime, then work on my code / CS during night classes or something. Not to mention my only prior experience with CS classes exposed me to some of the worst, most unhelpful teachers on the face of the Earth lol.
Fuck anyone who complains about bias towards younger people in the programming job market. Maybe if you live in Silicon Valley where you can't swing a tree branch without hitting a tech startup this is true, but I'm in no position to be paying 10k a month for rent in a shitty apartment. All the programming jobs around me are clearly biased in favor of boomers, requiring 10 years experience and a master's degree. I can't get my foot in the door for entry level shit because a bachelor's degree is a hard requirement for most entry level jobs even if you do have a portfolio of small self projects. And even the entry level jobs typically want you to have gone through some internship, which is something you can only get through college in most cases. All programmers in my surrounding cities are a bunch of 50 year old men either maintaining legacy Visual Basic shit or working on stuff that's upper level and would never occur to a lowly self-taught programmer like myself. There's no room for inexperienced programmers who have never before been incentivized to work on something that's not for entertainment or simple utility purposes. People have been saying that the programming job market is going to be so big that there won't be enough people to meet the demand, but I'm just not seeing it. If anything, there are too many programmers in this world and the likelihood that a company would pick me out of all others is slim. Programming is pretty much the only skill I have that would keep me from working some heat-stroke job shoveling dirt or whatever other people do for a living. Sorry for the blogpost I'm just pissed off and have nowhere else to vent.
(67.78 KB 410x410 ideas worth spreading.jpg)

>>1894 >People have been saying that the programming job market is going to be so big that there won't be enough people to meet the demand, but I'm just not seeing it. People talk shit out of their asses all the time. The programming job market is big indeed, but the number of graduates each year grows because this field is pushed everywhere, "it's the future", "it's where the money's at". Many foreign graduates in the US, Australia, Europe. The number of graduates is probably bigger than the number of job openings each year in civilized countries. Then there's the Indian problem. For a fraction of what a competent man would earn, one can hire a team of pajeets. All (((big tech companies))) do this to save shekels (and for other purposes too.) Smaller ones do the same thing but only because of shekels. Then there's incompetence in graduates. The meme that many college graduates can't even write FizzBuzz is based on truth. Then there's the HR department, mostly women. Usually incompetent dumb fucks with zero knowledge about technical subjects, sometimes trained in (((psychology))), who can only read and compare texts: if the resume does not contain <name of faggot JavaScript framework>, whole words, case insensitive, then it's rejected. Similar technologies, concepts, products, etc, mean nothing to them. Then there's interviews, sometimes made by the same kind of people. Then there's diversity necessities. Many companies advertising job openings online add this to the titles: "f/m/d" -- the F comes first, stands for "female" and the "D" stands for mentally ill. They prioritize female, mentally ill and colored people or foreigners. Then there's constant changes in these fields. It's hard for competent people to remain useful for years. Older men have to become faggots and join the younger ones in their faggotry. Then there's the corporate bullshit that many technology jobs increasingly require. Often you are required to know about shit that has little to do with technology. Then there's this: >requiring 10 years experience and a master's degree. >because a bachelor's degree is a hard requirement for most entry level jobs even if you do have a portfolio of small self projects >If anything, there are too many programmers in this world and the likelihood that a company would pick me out of all others is slim. There are many, many competent people in technology in this world who are unemployed. The job market in general is shit. There are intelligent people with degrees competing for menial work. There aren't enough jobs for everyone. Technology is shit nowadays and bound to become worse as time passes. All heading towards the botnet. Soon the whole world will be a herd of nigger cattle.
(409.31 KB 640x360 do it like a white man.mp4)

>>1895 >Then there's the HR department, mostly women. Usually incompetent dumb fucks with zero knowledge about technical subjects, sometimes trained in (((psychology))), who can only read and compare texts: if the resume does not contain <name of faggot JavaScript framework>, whole words, case insensitive, then it's rejected. Similar technologies, concepts, products, etc, mean nothing to them. Then there's interviews, sometimes made by the same kind of people. Anon are you me? I swear every time I get an email saying that the employer passed on my application, I always get into a rant about tech illiterate middle aged women who are just marking off a checkbox based on what the senior programmer told them. Every damn time, I get the mental image of some plump 46 year old woman with red skin complexion sitting at her desk, reading my resume and asking the programmer >Heyyy, uhhh do we use this See Hashtag code at our company??? <Huh? Uh, no, we use Java. (continues typing away busily) >Oh, well I guess we don't have much use for this one then. Honestly everything just seems fucked. I learned programming for fun at a super young age and as I got older I always imagined myself doing it for a living, but now I'm in my early 20s and the closest I've ever gotten to it is a handful of interviews with an email a week later telling me >While we are impressed with your skills and resourcefulness, you lack the education and work experience compared to other candidates so you were not selected for this role. At this rate even if I do land a programming job (or anywhere in tech) the pay rate is going to take a massive nose dive by the time I've built up enough momentum in my career, because by the time that happens basic programming will be a nearly disposable skill akin to mobile phone repair. Really makes me wonder what the job market in the future will look like for the middle class with disposable income.
>>1893 Have you even read K&R C? From the looks of your printf statement it doesn't look that way. It's a pretty short book as far as programming language books go (under 200 pages when you don't count the appendices). You can read it over a weekend if you skip the exercises. Not that I recommend skipping the exercises of course. It will take a bit of your time, but in the end it will still be more time efficient than banging your head against the wall repeatedly hoping that you happen to get it right. Take for example your print statement: the first argumetn is a template string (called a format string), it contains the text you want to display, followed by values you want to splice in. The template contains little placeholders like %d which will be replaced by a value. Now here is the thing: %d stands for "decimal", it will be replace by whatever "input" is when it gets interpreted as an integer. But input is not an integer, it's a string, which is an array of characters, and arrays decay to pointers when passed as arguments to a function. So what you see is actually the memory address of your string, which will be different every time you run the program. Here is what you need to do: your input is an array of characters, that means it's a sequence. You need a variable to collect your intermediate results. Initially the value will be 0 because you have not counted anything. Now you need to step through the string, one character at a time, take the numeric value of that character and add it to the intermediate result. Once you hit the NUL character you need to stop. Here is a piece of pseudocode given: input (an array of integers) let: result = 0 (accumulate values here) index = 0 (keep track of position) keep doing: current = input[index] Is current == NUL? If yes, then terminate result = result + input[index] index = index + 1 You should be able to translate this into C. The key point is that you can index a string the same way you index any other array: by useing the input[i] notation. >Not to mention my only prior experience with CS classes exposed me to some of the worst, most unhelpful teachers on the face of the Earth lol. Computer scientists can't teach. The best computer science books have been written by mathematicians, electrical engineers and physicists. In fact, the entire field of CS is a giant mistake, it's the most soy-dripping and pozzed of all STEM disciplines. For fuck's sake, SICP was written by electrical engineers and it really shows.
>>1894 >>1895 >>1896 Can confirm all of it. At my current job (full stack webdev shit) we need new programmers, but our tech lead keeps rejecting people straight out of college, just because they are straight out of college. The trick is to get your foot into the door doing work that's even below a Pajeet and hope that something opens up. Things like manual testing in QA is one way, but even that is going out of fashion thanks to TTD and CI and dev-ops. And even then all you will be doing is glueing shit together, taking open source libraries and applications, adding a massive amount of bloat and selling that shit. It's a constant balancing act between acting eager and interested in learning the newest stuff, but at the same time you have to navigate a minefield of overblown egos and the slightest comment could upset one of your hipster shit colleagues. Basically, be a worker drone, but don't appear like a worker drone. God, I fucking hate my job and the entire industry. All I wanted to do was make nice things, but instead I'm shoveling shit all day. At least thanks to Corona Chan I don't have stare at their ugly faces all day and sit in an open office space hearing the chatter of twenty other people. >>1896 >At this rate even if I do land a programming job (or anywhere in tech) the pay rate is going to take a massive nose dive by the time I've built up enough momentum in my career, because by the time that happens basic programming will be a nearly disposable skill akin to mobile phone repair. I would actually like that. If the general population could program to a limited extent, it would drop the botton underneath all the Pajeets and hipsters. After all, why would I buy your buggy shitty bloatware if I could just get the very same open-source apps you ship as well, except I install and wire them up the way I want? Think about it that way: every person knows how to use basic tools, the average man can fix a lot of things around the home without havign to be a proper mechanic. There is still a lot of jobs for real mechanics and engineers, but there is no place for some faggot who can barely use a screwdriver and wants to LARP as a mechanic. When it comes to computers however the general population really is that illiterate. Throwing together a shitty Python script is on the same level as being able to nail together a few pieces of plywood, but it is beyond the capacity of most people.
(365.92 KB 1280x710 Thumbsup.jpg)

>>1901 >>1901 Sorry for the late reply; thanks for the help. >Have you even read K&R C? Sort of; I'm the same anon who posted >>1244 lol. It started out decently, and it did teach the basics really well, but there were some issues. Maybe it was more a problem with the specific PDF I was using, though. >So what you see is actually the memory address of your string, which will be different every time you run the program. Ahh, that explains the bizarre output, then. Thanks, anon! >Here is what you need to do... Thanks for the clarification; I was thinking I'd need to move through the array somehow, but I was having trouble conceptualizing it. This helps a lot. >The key point is that you can index a string the same way you index any other array: by useing the input[i] notation. Alright, maybe this was part of my problem, then; I haven't even learned about indexing at the point I'm at in the textbook I'm using. Which, incidentally, isn't on OP's list, maybe due to superior options being available. Looking into how it works, it seems incrementing the index is exactly what I would need to do. This is fantastic, anon; thanks a bunch.
>>1948 A Brazilian different languages, and you choose Portuguese.
Hey Anons. Does Nim make for a decent first programming language? As it is, I've been sort-of learning both Nim and Python at the same time through Exercism because I can't choose between them. They're very similar syntactically so it actually hasn't been that much of a headache, but I recognize that this is a suboptimal way to learn. Nim is a language that greatly fascinates me. Enough to give me motivation to learn it, and despite the language seeming to be intended for more lower-level programming, the community has actually been surprisingly accepting of me being new to programming when I asked beginner level questions on the official forum. On the other hand, the differences in the quantity of resources between Nim and Python might make learning Nim more difficult to a new programmer. Anyway sorry if this is rambly, but I just wanna know if it would be better to learn the language I'm more motivated to learn, or the one with more resources. Maybe learning both at the same time isn't as bad as I think it is? I don't know.
>>2241 It doesn't really matter which language you choose as your first, as long as it's not retarded (Javascript) or something esoteric (Brainfuck). Python and Nim have very similar syntax, but they have very different purposes. Python is a scripting language, it's basically executable pseudocode. There is a ton of libraries available through pip, so whatever you want to do, you can probably just glue together some code in a few minutes and be done with it. It is much older and popular than Nim, so there is a lot of resources for it. On the other hand Python is slow. If anyone tells you that Python can be fast, they are lying and using libraries written in C with Python bindings. Nim is as systems programming language, it is meant for writing proper applications and it is fast. There are fewer resource (there is only one book written for it to date) and it has become stable only recently. It is better when it comes to writing proper applications in, but you have fewer libraries to choose from. Since Nim piggy-backs on C it allows you easily to use C libraries, but you need to be familiar with C in order to use them properly. While the Nim ecosystem is smaller, the community is also cozier. Python is cucked, but so is pretty much anything these days. Not Nim though. Nim takes ideas from a number of languages like C and Python (obviously), but also Lisp, C++ and Ada. Nim is also statically typed (you cannot change the type of a variable). To me Nim feels a lot like "what if we could do C++ all over again, but not even try to be backwards compatible with C syntax?". Personally I find Nim much more interesting than Python as a language. My personal recommendation: for your first language pick something that is easy to learn. I think that due to the large amount of resources Python is a better choice in that regard. You don't have to master every facet, just enough to be comfortable with the ideas behind programming. For your second language you can then pick whatever you need or find interesting. With every new language you learn you will find it easier to learn the next one.
>>2248 >pick something that is easy to learn. Most languages aren't particularily easy to learn though. Even if it's just about learning how to use four different types of brackets (the '(', '[', '{' and '<' symbols, as used in many languages), there are a lot of concepts behind them that everything blows up pretty fast. The syntactic sugar that many languages have also makes things worse. The best "learning" language would be something with next to no special syntax and a semantic that is as straightforward as possible with little special cases. I'm sure you've met countless times those situations where a certain construct (say 'A()') means something in a place but something else in a different one. That doesn't make it good for a "first ever" language. There are actually a bunch of languages with a small syntax and semantics that do not require books to explain all the caveats, but unfortunately they are either "unique" (for a lack of a better word), meaning that when you use a different language the only thing you can reuse are the basic concept of programming rather than code or something else, or "small" to the point that you can't really make something worthwile with it. Some people might argue that by simplifying the language too much one doesn't learn anything, but consider this: when someone is looking for a "first programming language", usually that means that the person doesn't know much about programming at all; wouldn't it be better to teach him the core concepts of writing good programs, instead of wasting time over less important things like the syntax of a specific language? In my personal opinion the "midway point", where you get actual power while not being overwhelmed by useless crap as you learn how to program, is C. That language has a small syntax, at least compared to Python, and most of the time the semantics are intuitive enough that you don't need to read any tutorial or documentation once you understand what a symbol (or combination of symbols) does. As a comparison to show how C is small, consider that Python has different ways of defining a function, while in C you can define a function only in two ways. Python has anonymous lambdas and named functions, methods of classes (which are slightly different than plain functions), functions with optional arguments and/or with keyword arguments; in C you can only have named functions or named functions with variadic arguments. I'd say it's easier to learn this way. I know that manual management of memory is its own can of worms, but if all you need is to learn the basics of how computer works and how programming languages instruct the computer, you don't need to master memory management nor do you need to release your code to the public, so even if you allocate a bunch of memory and forget to release it, nobody will care. Once you get the gist of programming you can just ditch C and move to something else with automatic memory management.
>>9 If you didn't grow up with good access to computers and the Internet then you will never likely ever learn to code. I tried off and on from age 23ish to 31 and it never pans out to the point that I avoid using Linux as it forces you to use the command line console, terminal, whatever, often. In college at 20 I was planning on it but back then had no computer access at home. Before 20 I was in HS and had only a win98 computer with no home Internet. So yeah. I guess you're a teen getting other teens into it. When i was a teen I only wished I was playing around with computers. I had to-do lists that ended up stopping with installation and management of now retro emulators on windows computers. That and a hacked a phat psp, for retro emulation and to use it for browsing, basic computer stuff. I had that coupled with the win9x desktop at the trailer home I lived in that was far from any bus system or store as an adult. Before that i had as pre-18 zero computers. 18-20 thus is all I learned pretty much. Some things I guess I learned but I pretty much crammed all I needed in the 18-20ish range. Not to say that I never had any computer access, school teaches you how to use excel and ms-word and how to be a touch typist, at least they did back in the early thousands and late early thousands, but that does not teach you computer programming nor anything really useful. It might have panned out once I was neet at 22 and at 23, but it was too loud and at that point i had only a wonky android tablet to use for programming, and back then I had no computer access at home and would wait for weeks on end for wifi access to be near by, something that now never ever happens. I'm only online now because after so many years my area that I live in now, at 31, has rented wifi mobile hotspots. These being mobile are range banned from modern 4chan, so I use various dead sites like this to socialize as a forever-neet. So I was obligated to give up in short. I am now on a win7 32bit computer, but it's locked out of it's bios so inb4 install linux on thumbdrive. Inb4 everything really, there's no point in trying to learn how to use a computer better than I do now in my faggoty family environment. It takes me 3 days to calm down anytime something negative happens and every single day the parents do something to piss me off, and then there's bound to be a rat flying by me in this shithole that I live in NOW, even though no longer the previous ones, or rap music playing, or I'll need to take a shit, get worried about my hypertension from sitting coding all day, there's no point at 31 to attempt it. To this day I often go weeks, even a month without Internet access of which only forced me into alcoholism starting at age 23. The 'free' wifi that is rented only started in this house after 25, probably 26, by then you're done with adolescence as it lasts at the approx latest for males to 25, so there's no point in picking up a new complex skill nor attempting it. Internet access at the house is too little too late at that point. I coped without it by bringing books and roms and emulators and such back home to where I needed no tube sites nor infinite knowledge for le hax0r life. Tube sites are all the Internet gets you in my position, that and le talkerino shitposts. I mean really, when I was in the early 20s and trying and there was nothing but the glitching android in my way of using the free code camp (keyboard would short out then reload the page) I should have in a real modern world that was nice have been sent to a real camp with a real school setting rather than sitting with my legs crossed on a couch near a window on someone else's wifi with a 6 usd keyboard and no mouse on some faggoty (((android))) that made me feel watched too much to learn while there was the noises from the parents and interruptions, and interrupted access. A real camp is what someone would need in certain life scenarios. We don't get that, we get a library where you sit in a noisy and full of discord home. That's worse than the way scholars learned in the past. Resources? Useless. There's no camp. No school. The Internet is shitposting and propaganda games and porn. It's not a school. It's not a quiet library, most things you want to even download are illegally hosted. It's not even designed to be a library and is not quiet. Actually real libraries where I live are not quiet and the librarians even harass you if you look homeless or are sitting next to someone with loud headphones, they'll assume it's your earbuds you were using to block it out that had no noise coming out of them. People are assholes and they made an asshole world and OP's immature "do et" shit just pisses me off. With less resources and more peace people would do it. They did so in the past but times were better back then in certain areas. Not everyone is privileged nor young ergo not everyone can code, fuck your biased and naive positivity. It is not possible to learn. I can prove it to you if you let me move in with you, therein I will every time I see you GO HEY HEY THE (((NEWS))) SAID SOMETHING *giggle* HEY like a roomie would to me, then if not mad I'll beat the shit out of you until you realize that the news is supposed to make you mad for 3 days straight because it tells nothing but negative and irrelevant bullshit meant to piss people off and that among other things will be used to piss you off. If i see a bit of dirt in the bathroom I will demand that you stop what you are doing, come into the bathroom, and then look at what I found before I clean up what you left after bothering you without even letting you do it. Then Ill will vacuum at 3am, then 1am, then 7am, batshit random hours, and walk into your room even if you lock it. Until you realize that it's not possible. And I'll not let you do any drug but booze, then get pissed at you if you do it enough that you actually get drunk and happy and start abusing you for it due to jealousy and christian bigotry, causing you discord with the goal to make your stomach too sour to keep drinking. >>697 >maths This is why no one should hardly even be told to get into programming. In college they don't even teach coding so much as gratuitous advanced mathematics, and most humans are simply not capable of learning such math. It's like people with aphantasia being told to be artists.
(717.19 KB 640x358 absoluteanger.webm)

Holy fucking shit making GSL run with Codeblocks was a fucking nightmare, but I got it running in the end
>>2425 from your essay it sounds like you regret not being an english major.
>>2441 What essay do you mean? The posts above >>2425 aren't mine.
(64.55 KB 444x637 1567574439678.jpg)

Hello, friends, I am not sure if this is the most apt place to ask this question but here goes: I'd like to find all unique elements in a specific row of a multi-dimensional array, but I would like to avoid the double-for loop I've see so many people use. I was wondering if there's a more elegant or faster way to do so. I thought for sure this would have been an easier thing, but the problem has left me stumped.
Don't ask here. This place is dead as fuck. The only reason I saw your post is because I was browsing through the overboard. Anyway. I'm gonna try solving your riddle. >multi-dimensional array You mean an array filled with arrays? It's better to use math. myArray[i+j*rowLength] >I'd like to find all unique elements in a specific row of a multi-dimensional array This problem is actually no different from finding all unique elements in a single dimensional array then. >but I would like to avoid the double-for loop I've see so many people use. I was wondering if there's a more elegant or faster way to do so. I don't see how if your data isn't sorted. If you count every element of the same value, you'll have to loop over the counts to modify them. If your data is sorted, you could check whether an element is not the same as the last or the following and add it to your list of uniques. If you have very simple data like bytes you could make an array and use the values as keys and store the counts. Afterwards you can loop through that array and get your uniques. You still have two loops but at least they're not nested. #include <iostream> using namespace std; unsigned char a[] = {4,4,5,8,1,8,6,8,4,4,1}; int counts[256]={}; int main() { for(int i : a) { counts[i]++; } for(int i=0;i<256;i++) { if(counts[i]==1) {cout << i << endl;} } return 0; }
>>3155 >I don't see how if your data isn't sorted. Whoa man, you just gave me a great idea. Thank you, I really needed a couple of fresh eyes to solve this.
>>3157 Glad I could help.
I'm gonna ask a stupid question but I'd really like to know the answer even if it's long and complicated. Is there a programming language that isn't as anal as C but either compiled in it/just as fast but again, isn't as anal? I'd like to start dabbling in something but Python doesn't feel right and C feels a bit retarded in the workarounds I have to do to achieve similar functionality as other languages. I might be asking something impossible here though. Is Haskell fast enough? I heard it helps with codefag practice
>>3170 If you want "fast" you're probably looking at compiled in some manner. C, C++, Rust, Go, etc all compile to assembly but are varying degrees of "anal". C is arguably less anal but has a lot of pitfalls. Some give errors and others just silently fail. Rust has the whole "borrow-checker" meme to control memory. Personally, despite having more options and also giving you enough rope to hang yourself, C++ is a good balance in my opinion. Lots of built-in tools for managing memory safely and handling common data structures and algorithms, but without a lot of runtime bloat and without having to write everything from scratch using only structs and creative typedefs. If you hate "anal" then you really don't want Haskell. It's a solid language and popular among functional programming purists for a reason, but you will get all kinds of errors about type mismatches that are indecipherable until you learn the type system inside and out. If you like lots of built-ins like Python has but prefer the syntax of C, you could look at Java or C#. I'm not a fan of them, but they have a ton of libraries. C# is more consistent all around while Java has a lot of legacy cruft, but there's usually a library or a package for anything you need, and the runtime performance is fine.
>>3170 It's called C++. It has all the abstractions you need in the standard library. You need a list? <vector> has you covered. You want your array to know its size, so you can pass it around more easily? <array> does just that.
>>3176 And these days they update the standard every 3 years, don't even need Boost anymore remember when C++11 was this new exciting shit fuck I feel old
>>3152 >but I would like to avoid the double-for loop I've see so many people use like >>3155 said you can actually address 3D arrays using 2D array (https://en.wikipedia.org/wiki/Row-_and_column-major_order). But really you shouldn't be obsessing over details like this, compiler can optimise much more difficult things than this
>>3202 >there's a fucking wikipedia article on this >I just do it because it's logical and didn't read it anywhere Are there so many retards on this gay earth? >>3201 Yeah. Next they'll replace #include and header guards with the compiler side modules and the keywords import and export. It will also work for the entire standard library and legacy headers. (Legacy headers will however import #defines until they're converted to modules) Can't wait for that to happen. It will kill the preprocessor which was one of the major critizisms of C.
>>3205 >Are there so many retards on this gay earth? I don't even know what you're trying to say so I guess there are lol
>>3202 >But really you shouldn't be obsessing over details like this, compiler can optimise much more difficult things than this Depends on what language he writes in. If he does it in any scripting language his "array" will be a vector and the array of arrays will be a vector of pointers to vectors and major overhead is guaranteed.
In C# and Java, they also seem to do a bunch of pointer shit under the hood. https://en.wikipedia.org/wiki/Jagged_array Have fun waiting for the garbage collector to clean that mess up.
>>3202 >But really you shouldn't be obsessing over details like this So I've looked it up now. And you're fucking wrong. It turns out that even C++ only supports multidimensional arrays on the stack, not on the heap. Using new you can only create a single array of pointers to other arrays or use math like I recommended. Since the stack is small, in most cases you're going to make heap allocations where can choose between a pointer array and a simple array. So you have to be obsessed over this.
>>3208 >Depends on what language he writes in If performance matters then it'll be a fast language. If performance doesn't matter then who cares how arrays are handled. >>3214 >It turns out that even C++ only supports multidimensional arrays on the stack, not on the heap What are you on about? Multidimensional arrays are treated exactly like 1D arrays, you can literally address a 2D array using a single address if you want, and in fact that's what the compiler will do. The only thing you need to know is row major vs column major so you loop through on the columns on the inner loop. But most of the time compiler should optimise even if you do it wrong, it's called loop optimisation and one of the most fundamental aspects of compilers
>>3243 >What are you on about? Multidimensional arrays are treated exactly like 1D arrays Okay, go ahead and show me how you declare a multidimensional array in C++ or C using new or malloc().
>>3245 int array[10][10]{};
>>3245 You can actually just do auto arr = new int[row][col]; to get the exact same memory object as the stack one in heap BUT if you are limited to ISO c++ (no compiler extensions) col MUST be known at compile time. If you have GNU extensions available both values can be whatever,I assume llvm has a similar thing somewhere.
>>3274 >col MUST be known at compile time huh I never knew that. Apparently even 1D VLAs are not supported, even though they are supported in C.
>>3275 >even though they are supported in C Not anymore, they were made optional to implement by C11 because (((some))) vendors hadn't implemented them in their compilers since C99.
>>3170 >Is there a programming language that isn't as anal as C but either compiled in it/just as fast but again, isn't as anal? A couple of languages off the top of my head: > C++ Basically what happens when you are forced to write C but are envious of all the cool languages out there, so you start bolting on every feature under the sun. It has a lot of features, even some that make it less anal than C, but the result is an abomination that begs for a mercy killing > Nim Take C++ but make it like Python and add some Ada and Lisp into the mix. I have only experimented with it a bit, but I already like it. It has a lot of features, some taken from non-retarded languages, and the syntax is a lot like Python. It compiles to C first, then to machine code, but you don't really notice that intermediate step. It has good interoperability with C, C++ and Objective-C, and it can also compile to Javascript for running in the browser. > Common Lisp It depends on the implementation, but some like SBCL compile to native machine code and can indeed be as fast as C if you add appropriate declarations to your code. Standalone SBCL binaries are quite large though because they include the compiler as well, so if you are looking for something small to send out it's not a good choice. I have heard that ECL and the proprietary implementations are quite good, but I have not tried them. On the other hand, when you want for example to deploy a server application, then size doesn't really matter and you can just install SBCL on the server anyway. > Haskell, ML, Ocaml No idea about their performance, but they are compiled languages. They are functional languages and quite anal about the functional part. > Vala, Genie Similar to Nim, these compile to C first. Vala is a lot like Java or C#, so if you know either of those you already know 90% of Vala. Its OOP model is just syntactic sugar for the GObject library, so if you have to use GObject you might as well write your Code in Vala. Aside form OOP it also supports imperative programming and some functional techniques. Genie is basically Vala but with a more Python-like syntax. > Objective-C The older brother of C++ no one knows about. Apple used to be pretty much the only company that still used it, but they have all but abandoned in in favor of Swift. Objective-C is a superset of C which adds object-oriented programming in a way that is not as retarded as C++ and is in my opinion a much nicer language, but it still has quite a lot of C-isms. GCC and clang can compile Objective-C, so you are not at the mercy of Apple, and you can use GNUStep as a Cocoa replacement. > Go, Rust If you are gay > Swift If you are gay and rich enough to afford a Mac (Swift is actually available for other platforms as well, but you are still at the mercy of Apple) > Forth When you think that C is too safe for your tastes. C is like riding a motorcycle without helmet, Forth is like riding a on a rocket in your underwear. A bit of a meme language, but quite mind bending.
>>3274 >auto arr = new int[4][4]; Okay, I'm surprised that actually works. I take back what I said, though I wouldn't use this. >auto is int(*arr)[4] >declare arr as pointer to array 4 of int How does this make any sense at all? >col MUST be known at compile time. That does seem to make it quite limited in its ability or is this only when you use auto? >>3275 >VLAs Don't pretend they weren't controversial.
>>3278 >If you have GNU extensions available both values can be whatever That answers my last question already.
(24.91 KB 620x406 shrug2.jpg)

>>3278 >How does this make any sense at all? (*array) is recognised by the standard as a type of variable length/size.Don't ask me why.
>>3311 Okay. I guess I have to live with that.
I want to learn programming, specifically C. I have very little knowledge of programming at all. Would it be in my best interests to start with SICP or The C Programming Language?
>>3377 Either is fine, but they're totally different paradigms. What operating system are you on? I will post some resources. The best thing to do might be try each and stick with whichever one holds your interest more.
>>3378 I'm on a windows PC, but I plan on dual booting my PC with a linux distro. Maybe Manjaro. I'm relatively inexperienced with linux, but I plan to learn about it along with C. So, I'd really appreciate both sources if you can. Thanks once again.
>>3377 Always happy to see people wanting to learn C. Good luck and feel free to ask questions if you get stuck with something. I guess people will advise to set up a traditional development environment but at the risk of bullying I've always found it easier to just use an IDE. I also wouldn't completely write off the crappy tutorials series you find online as they provide piecemeal lessons that demonstrate one topic at a time, so they're kinda okay to quickly get familiar with how something works.
>>3382 Thanks for the support. I'll make sure to ask questions in this thread if I'm having any issues.
>>3379 I've attached two books. The first is an introduction to C. I have not worked through this book myself, but I selected it from my collection because it's aimed at absolute beginners and it includes a section at the front dedicated to installing CygWin. Personally, I think getting a proper development environment on Windows is too much of a pain, but I figured you should have some kind of guidance if you choose to pursue it that way. You'll get a compiler and BASH-like environment out of this on Windows. It's not as comfy as developing on Linux, but it keeps things sandboxed. I'd recommend using a text editor and compiling with gcc, and it seems like this book prefers that to native Windows compilers. That said, if you want a book that'll focus on native Windows code, I'm sure I can find something that'll focus on Visual Studio integration. But I'd avoid Microsoft's compiler. GCC is the gold standard. For LISP, I've attached the seminal work SICP. Yes, it's a /tech/ meme. But it's popular for a reason. Functional programming teaches you how to think about moving data around and giving it form. I would recommend installing the DrRacket IDE https://racket-lang.org/ and using the SICP language option https://planet.racket-lang.org/package-source/neil/sicp.plt/1/18/planet-docs/sicp/index.html which will force compatibility with the version of Scheme included in the SICP book. There is also the SICP website run by the MIT Press https://mitpress.mit.edu/sites/default/files/sicp/index.html which has errata, code, and even the instructor's manual if you think that would help get you unstuck. But I think you should view SICP as both a language introduction and a puzzle book. The "a-ha!" moments are joyous. Bits of this curriculum survive in MIT and Berkeley introductory courses today. >>3382 >I've always found it easier to use an IDE I understand the impulse. IDEs, out of the box, can seem very simple. Some of them handle compiler installation and configuration. One-click compile and run is handy, especially for a beginner. Meanwhile, popular text editors have a learning curve. Vim and Emacs both require some time to learn keybindings before you can even write code. However, it's worth remembering text editors like Sublime Text, Notepad++, and Atom exist. While I have various issues with each of these and do not use them myself I also think they're better than a full IDE for beginners. Why? Because a beginner needs to learn how compilers work, especially if working with C. It's important to learn how to link your files together correctly, and how to write a Makefile once you start dividing your code into multiple files. Additionally, full-blown IDEs tend to have clutter. What do all the buttons do? Probably nothing relevant to a newbie. You basically spend your time digging through menus and looking for the right button. I think that feels more productive than trying to get Vim's keybindings right, but in reality it wastes just as much time, if not more. If it's that much of a pain, there are not online editors with one-click compilation available online.
>>3385 I'll be sure to read those books. Thanks for the tips and the books. How do you feel about C Programming A Modern Approach by K.N King? I see a lot of people reccommending it online for absolute beginners to C.
>>3387 >C Programming: A Modern Approach If I have a copy of that, it's not in the right folder. It's hard to make comparisons when I didn't learn C from these books, and not as a first language. I started with Scheme and C++, and then worked back around to C for kernels and embedded. If others are recommending it and you get a copy then feel free to give it a try. Any introduction to both languages and programming as a whole needs to cover all the basics, so be sure it's not skipping over anything. You can compare the tables of contents. If one book doesn't work for you, try the other. Here's a copy of some specialty books, as well as the ANSI C book, whose style is outdated but it it written as a reference by the authors of the language. It's not a very modern way to use C, but a lot of people learned from this book. Not recommending it as a first go, but it might make a good companion or a good second book.
>>3377 Hi anon, I hope you end up reading this. Both SICP and K&R C are great books and worth reading, but they have very different target audiences. < K&R C This is a language reference book, it assumes you already know how to program but don't know C yet. It is quite short for a language book, has exercises is easy to read. If you already have some basic programming knowledge then there is no reason not to read it. C has advanced quite a bit since they, but the book is still relevant and you can easily catch up with the new stuff afterwards. < SICP This is not a book about programming (although there will be programming in it of course) but about computer science. It assumes zero programming or CS experience and by the end you will have a very strong grasp of the concepts. However, it uses Scheme, a Lisp dialect, which is a good language, but a rather obscure one. And the book is very large because of the amount of concepts it covers. If you want to learn enough programming so that you can get "stuff done" or read other people's code, then Scheme is not the best choice. C is still quite a popular language in some domains. I recommend reading both SICP and K&R C eventually, but depending on what you want and how much time you have those might not be the best choices for a first book.
>>3417 I'm that anon from before. I was planning on looking through SICP first and then going through C Programming a Modern Approach afterwards. Would it be better to grasps concepts first or to learn a bit of programming and then go back to the concepts?
>>3418 Hard to say. I don't think there is a universally good approach, different people learn differently. Grasping concepts first definitely has the advantage that you learn things properly from the start instead of having to unlearn bad habits. On the other hand, some people need to get rapid feedback, they want to throw something together first and clean up the mess later.
>>3418 The most important thing is that you know how to allocate shit on the heap. First you need to include a header because C made some stupid decisions: #include <stdlib.h> int* array = malloc(20*sizeof(int)); And you're done but if you try to access any of these elements you're in for undefined behaviour. Most often you'll have to set them to 0. So instead use calloc which creates the array and initializes it to 0. int* array = calloc(20,sizeof(int)); //note that it has two arguments, easy to fuck up when you're a beginner And don't forget to free your shit when you don't need it anymore. free(array); Do not double free things but you don't have to check for NULL before freeing. It doesn't do anything when the pointer is NULL. Now you can use malloc and free and become like Terry A. Davis. You can program everything now.
(732.46 KB 75x75 1576184651444.gif)

Let's say, hypothetically, I really want a feature on a program. And this program is LISP based. I'm willing to pay 4 digits in American currency for someone to add this feature. How do I find someone who could do it? How would I pay the nerd? Am I doomed to hiring a team of 10 pajeets that'll fuck it up?
>>3437 How complex is the feature?
>>3437 1000 $ or 10.00 $ ? >And this program is LISP based. Emacs?
(44.85 KB 504x519 lily1.png)

(33.36 KB 699x299 lily2.png)

(79.63 KB 822x942 lily3.png)

(1.63 MB 452x474 rattling_bones.gif)

>>3440 >>3439 The program is Lilypond,which is a music engraver. A music engraver grabs text and transforms it into a nice looking page of music. I want to have a couple of alternate notations available (i.e. non regular staffs/notes/symbols/etc.) Here is an example of an alternate notation system. >>3439 So I'd say, somewhat complex. Look at that line number on the alternate plugin code. >>3440 I meant the four figures, no fooling. I gave lisp a try but the parent indentation is cancer. I'm sure there's an IDE that would make it not so horrible, maybe with alternating colors and auto whitespace for my autistic ass.
(157.75 KB 320x320 sweeping_reimu.gif)

>>3432 Ok then. For now, I think I'll just go through the SICP and then if I feel like I need to switch learning styles for a bit, I'll do so. I appreciate the info. >>3433 I have no idea what your talking about, but I'll take a screen shot so I know what you're talking about later.
>>3442 >I want to have a couple of alternate notations available (i.e. non regular staffs/notes/symbols/etc.) Damn. I can't into notes beyond the basics. Fuck. I would have liked those thousand dollars. >LISP is cancer Yes but it's simple.
(106.35 KB 1200x675 C4iv_loUoAAcN-5.jpg)

>>3444 I posted the books and I'll echo the previous response. SICP is a book that teaches you computer science and uses LISP as a vessel to do so (there is also a Python version Berkeley used as the basis for their intro courses). The other books, including the beginner's guide to C I posted, are aiming to teach you C. There's an additional complication, which is that C is a procedural language and LISP is functional. That makes them diametrically opposed in philosophy and composition. As stated above, it helps keep newfags motivated when they can immediately see the result of their code. This is why "coding bootcamps" do some kind of JavaScript to build webpages, often with a ton of libraries preinstalled. It helps keep their students engaged when tweaking one line changes a visual element on a webpage. A lot of computer science is not that. It's the opposite. It's reasoning about how to compose a problem via a series of described steps to get an accurate result. Bugs are the result of issuing improper commands with unintended side effects. This is why neither C nor LISP rank highly on lists of "good beginner languages": neither one does enough of the work for you to give that immediate rush. You will have to do a lot by yourself for any payoff. But that's exactly the point. >>3442 It doesn't look too bad, pending the particulars of how it actually draws shapes. Why not save the cash and write it yourself? Surely LISP is not that big of a barrier.
>>3442 Your best bet would be to contact the authors or maintainers of Lilypond, they know the code the best and it´s going to be the easiest for them. What does Lilipond even do? From the looks of it you just write LaTeX and it generates a PDF of the music sheet. If I knew anything about music I would give it a try, but I would have an easier time deciphering hieroglyphs than a music sheet.
When is it better to use procedural programming versus object oriented programming?
>>3480 >When is it better to use procedural programming versus object oriented programming? OOP is inherently more complex than procedural. As with every kind of complexity, the answer is "when you lose less due to complexity than you gain from OOP". For short applications that do one thing and do it well there is generally little benefit from OOP. If you want to write large bloatware applications then OOP can help you structure and organize your code better. Especially if you want to unit-test it heavity (with small applications there is usually no need for unity-testing, you can just jump ahead to integration testing). The idea of OOP is not classes and inheritance, it is about interfaces and objects exchanging messages. You structure your application as a graph of objects and they communicate among each other by sending messages (calling methods). The kind of message an object can receive depends on its interface (i.e. usually its class and the protocols it implements). I don´t mean interface in the way Java uses it (which should be called protocol) but the public methods it exposes. Now here is the important part: you can swap out one object in the graph for another with the same interface and the rest of your application will not notice it. This allows you to change the way your code works at runtime and you can contain behavior inside data. So for example instead of massive if-statement like if (some_condition) { // lots of code here } else if (another_condition) { // another wall of code here } else { // you get the idea } you can have one handler object variable and simply change the value of the variable when some global condition happens: var handler = new WorkingHandler(); handler.handle(clientRequest); // Something happens and we need a handler that always rejects a reques handler = new RejectingHandler(); handler.handle(clientRequest); So the ultimate question is, which is easier to write in your case. If you have a long running application that needs to adapt to changes and have a lot of features, then OOP might be a good fit. I also want to mention functional programming which can also produce flexible applications without all the mental overhead of classes.
>>3480 I like procedural programming because it gives me a lot of freedom and it doesn't force me to conform to doing things the way the language wants me to, but ultimately you end up reinventing the wheel because things usually fall in line with how OOP organizes things in classes anyway. That is, you end up with a structure (object) and several functions (methods) that receive the structure as a parameter (this pointer) and operate on it, possibly declaring the structure as an opaque type to force the user to only access it through the interface.
>>3480 Have to agree with some key points made in >>3482. Inheritance is far less important than textbooks and people at job interviews give it credit for. Controlling access to data and grouping the data via a common interface is the real meat of it. If you don't need to organize data and control access to it, there's really not a massive need for objects in your code. There is a case for inheritance, of course, especially as you move to large programs. Especially those with GUIs. And factories can help with abstraction. It's nice to be able to generate an object as needed and be able to interact with it using the same interface for all the children without regard for the underpinnings. But it's also a lot of preparation. The worst thing is developers who worship Object Oriented as though it were a god. Absolute brainlets who think a 50 line script is improved by 300 lines of handlers to abstract something you set once. It could have been a variable. No harm is done. No additional validation is needed. If you're that concerned, add a check or an assert. Adding objects where they're not needed just adds complexity for no reason. If you look at a big block of spaghetti, or worse, multiple blocks of repeated copypasted spaghetti, and you say "it would be easier just to track each of these and manage them with basic rules", it's time to use an object. Segregate the data, mark how to handle it, and then have that function handle it properly for that subtype. You just condensed spaghetti into one line and it probably cost you 50 in boilerplate, but you never have to worry again. >>3487 Procedural is fine and great for scripts, but there does come a point when sifting through data or trying to ensure certain variables comply with rules is just easier to do with objects. Procedural has some severe limitations when it comes to tracking state over the long term. Like you said, you end up reinventing the wheel more often than not. Sometimes you really just want a linked list, and writing one in C is a lot of extra work with a lot less guarantees. This is one reason I use C++ even for programs that would be fine in C: it's nice to just include existing data structures and run with them. >
I haven't tried using Rust, but from what I read and (try to) understand, the "safety" of Rust comes from not allowing raw memory access with pointers outside of unsafe blocks?
>>3599 The compiler has an element called a "borrow checker". This is basically the same as smart pointers in C++, where references to an object are counted and tracked. The difference is, they still make you clean it up and have syntax to specify you're passing ownership of the memory from wherever, and then the borrow checker looks it all over and verified everything created was freed by its owner. Unsafe blocks basically just disable the checker for that region. Rustfags are just mad other languages gives you tools to handle memory instead of having the language scream in your face constantly.
(40.48 KB 474x592 op.jpg)

Any opinions on this book? Should I pick Modern Operating Systems or another one as my first OS book instead? https://libgen.is/book/index.php?md5=7312960D0FB110104EA01347F30CC98A >>16 >If you have something specific in mind, post a request and I'll dig up some resources. Coding malware, especially bots, rootkits and spyware. Maybe something to do with AI in the future. (lol I know, I'll have to study a lot for that). I`ll take a look on OP resources anyways to help me survive in the modern market. I hope having read half of a C book and knowing some basic python will help me understand. (I had some knowledge on complex variables calculus, which I guess would help, like any math does, but that was like 10 years ago, already forgot almost everything lol)
>>3442 >A music engraver grabs text and transforms it into a nice looking page of music. >I want to have alternative notations Why not use LaTeX MusiXteX for this? Output the lilypad and then edit the tex file to get what symbols you want. Am I missing something? https://texdoc.org/serve/musixtex/0 http://tug.ctan.org/info/latex4musicians/latex4musicians.pdf There seem to be multple packages which do something like you're saying but I don't know specifically what your goals are.
Why the fuck am I forced to take discrete math for my computer science degree?
>>7828 Because computers are discrete machines, and a decent discrete math course will teach you about how mathematical problem solving. That said, most discrete classes fucking suck because they are basically remedial or just formalize things already taught in college math. If you spend all semester learning about sets, functions, series/sequences, and propositions like it's the first time you have ever been taught it, yeah you're in a shit class. The cool things in discrete worth learning are where number theory and cryptography intersect, where probability and combinatorics can be used to accurately understand algorithmic complexity, graph/tree modeling, and finite-state machines -> theory of computation sort of stuff.
>>7836 That makes sense, shame my current prof is known as one of the worst in the building >>7836 >>7836
discrete math a fuckin nightmare from what people have told me
>>7836 ive seen that fucking garbage when I was writing a regex engine and holy shit, its fucking oop but x999999 more retarded, what fucking imbecile comes up with this shit its complete bullshit and the worst way to understand code execution, like yeah wow look a fucking conditional jump look how complicated it is, fucking grow up, its literally just a fucking jump in the code this is what happens when no one understands assembly anymore, computers are super fucking simple, stop creating bullshit complexities that DO NOT EXIST
(31.08 KB 1300x642 state_machine_diagram.png)

>>7854 Are you complaining about the state machines for checking whether a string matches a regex? Like these or pic related? https://en.wikipedia.org/wiki/Nondeterministic_finite_automaton https://en.wikipedia.org/wiki/Deterministic_finite_automaton I thought the whole point of this is that this can be done by something simpler than a computer (Literally a finite state machine). And then other problems like matching parentheses requires a stack
>>7861 yes this is absolute fucking autism lingo for regex directed and text directed matching ie. while ( regex[i++] != '\0' ) { match( regex[i], text ... } while ( text[i++] != '\0' ) { match( text[i], regex[j] ... }
(153.87 KB 446x457 1343800725619893.png)

>>7854 Discrete Math/Theoretical CS is less about computers and computation so much as it is about teaching sophomores how logic works, because otherwise they will spend all of their lives cuntpasting from stackoverflow instead of ever thinking about the machine state. Most kids don't have an understanding of algorithmic problem solving which is agnostic of a specific coding language, and maybe 30% of those I've seen actually shouldn't be there because they will never develop an internally consistent model of how a anything works despite lecturing. "Johnny can't code" stands especially today because many zoomers have spent most of their lives in (web)app-world instead of anywhere close to the machine. >no one understands assembly anymore The same people who went out of their way to learn asm in the 80s and 90s still eventually learn asm now: a small vanguard of auto-diadacts who do so because they wish to program at a low level. You're not wrong, but you are not the intended audience.
>>7863 But isn't that what the regex / text directed matching is doing underneath? It compiles the regex to some representation of the graph, and then tries to match the text to it. The abstraction isn't supposed to help you understand the "code execution." The code execution is derived from the abstraction.
>>7884 no youre a fucking idiot the graph doesnt fucking exist, all engines are fundamentally only doing one fucking thing and thats comparing the current match count with the total required to get a full match its just setting flags for each individual condition in the regex and when all flags are 1 it returns the position and size of the match, heres a simple fucking regex directed sequence for matching literals matchN=strlen(regex); while ( text[t] != '\0' ) { match=0; r=0; while ( regex[r] != '\0' ) { if ( text[t+r] == regex[r++] ) { match++; } else { break; } } printf(";%d;%d\n", t, t+r ); if ( match == matchN ) { return t; } t++; } every other feature is just a different evaluation of the match condition, like lazy quantifiers it would change if ( text[t+r] regex[r++] ) to while( text[t+r] regex[r++] ), or a fucking dot which would change it to if ( text[t+r] != '\0' ) its the same with text-directed but with no backtracking on failure, isntead it just slowly builds a map of the entire text piece by piece getting all permutations of regex[i] at once instead of sequentially and then when you actually compile it and disassembly it you wont even see any loops or fucking state bullshit, just a shit load of xor, not and 'and' because most of theses comparisons can be be done completely branchless using bit operations like xoring the bits of every character to an accumulator and shifting left which would literally tell you every single position of the character in the string without making a single comparison or loop ie. [000010000111000] which are indexes (3,4,5,9) none of youre abstract bullshit is real not on a code level or the physical level inside the actual cpu it has NOTHING in common with reality
<it can be compiled to jumpless bit-fuckery <for my super special regex engine (special like me) <so state machines are not real
(57.13 KB 633x729 011734520943.png)

>>7887 >magic box
>>7887 believe me bro I wrote a lisp compiler in haskell that uses a data flow model to compile with fully automatic paralellization to verilog and runs on FPGA and does everything in O(1). I haven't released it because the CIA might kill me. Quantum is a jew hoax.
>>7901 how hard it is to write a compiler? :0
>>8185 Depends. Is it your own language? How fully-featured do you want it to be? If you just want to write a simple compiler for an easily parsed language then it's not so bad. You could also start with an interpreter first. Here's an example you can follow if you'd like: https://www.youtube.com/watch?v=eF9qWbuQLuw
based
the SICP book is not 10$ :/ ....
Is PajeetScript really that much on demand? I don't wanna use it, but it feels like everyone is telling you to do so.
>>8511 If by PajeetScript you mean Javascript then yes, yes it is if you work in webdev (which is most of programming jobs).
Honestly, I recommend starting with Python or something. >https://automatetheboringstuff.com/#toc
Has anyone ever made a webscrapper for collecting images under a tag/hashtag on twatter/oixiv/some booru? How would you go about doing such?
Bump this awesome thread. I'm learning prog from scratch, whish me luck.
>ctrl + f >"the art of programming" not found contempt.png


Forms
Delete
Report
Quick Reply