lainchan / λ
The Beginner's General
λx.x · 2022-05-14 08:53
This is the Beginner's General for beginners' questions.
If with a simple question, and a suitable thread doesn't already exist, just post it here and someone will probably try to answer it.
Remember to do some research before asking a question. No one wants to answer a question that a simple search can already resolve.
JARGON · 2022-05-15 05:45
I love hot that fat man can go to all sorts of interesting places and every time he's just looking at his laptop screen. Are programmers like that? Is there a way I can avoid becoming this alienated from my surroundings? Or is it better to stop programming altogether?
Lunch · 2022-05-15 06:35
>>31173
It's really no different than people being glued to their phones (though maybe more productive). It's nothing to do with programming and all to do with escapism from boredom or anxiety. Just don't do that, my guy.
The Phantom Phreak · 2022-05-18 11:06
>>31173
Hot fat man pictured is Richard M. Stallman, but he is known by many names. The First Liberator of Printers, Keeper of the GPL, Free Software Daddy. He is a magical creature existing at the borderlands of reality, as he would be even if computers didn't exist, for such is his nature. Blessed be his radiant gaze and melodic autistic screeching.
But like yeah, programming is just knowing how to code. It doesn't magically make you weird. There's correlation, but the causation goes in the other direction.
swap · 2022-05-19 16:28
Is SICP a decent read for a beginner? I've only been learning Python and dabbling a tiny bit in C for the past 30 days, for 3-5 hours a day. I downloaded SICP (the old version with Scheme, not the new JavaScript edition) and started reading through it. I just finished the first batch of exercises and found them a little tricky but 100% doable, but maybe there are some big difficulty spikes coming up.
Tyrell Wellick · 2022-05-19 17:31
I'm not used to asynchronous programming, and making a simple bot using an API. I want advice on how to control flow with dumb websocket events, without just polling.
If it weren't asynchronous it would be simple:
>for each account:
>>authenticate
>>get attribute
>>set updated attribute
>>close
But WebSockets only seem to have:
>send()
>on open()
>on close()
>on error()
>on message()
Meaning that most actions are triggered by me sending then onmessage() being called later.
I'm assuming this invalidates using tools like await and promises, as I'm only calling ws.send() which isn't receiving the return message. Is there a way onmessage() can fulfill a promise in some other function like send_login_form() that didn't trigger onmessage() to run?
My current coping method is having a global variable keep track of the current operation (e.g. "authenticate", " process-authentication", "get-text"), and onmessage() calling a single function that uses a switch/case on that operation variable to run the next step of the process.
It works, but it feels fragile and hacky. Is there a better way to do this without it becoming an over-engineered bloated mess?
Delilah · 2022-05-19 22:07
>>31223
Depends on how strong your math fundamentals are, it's an MIT book. I don't really see it as a beginner book, although it's been used in that way, but it is very good and will make you think through concepts deeply. Feel free to revisit it later if you end up getting stuck, that's what I did.
Elliot Alderson · 2022-05-20 03:46
>>31223
>Is SICP a decent read for a beginner?
IMO, you should read Little Schemer/Seasoned Schemer instead. SICP is great a book, but you shouldn't read it if you don't have some programming experience.
>https://mitpress.mit.edu/sites/default/files/sicp/index.html (SICP site with the full text)
>https://www.youtube.com/watch?v=-J_xL4IGhJA&list=PLE18841CABEA24090&index=1 (SICP lectures)
>https://www.gnu.org/software/mit-scheme/ (MIT/GNU Scheme. You could use Guile, Chicken or Racket+sicp package instead)
藤原純一 · 2022-05-21 13:19
I am trying to make a simple calendar program but I don't know what data structure to use. The user inputs a date and an event description. I want to save the events defined into a file and then later find and read the dates requested without having to scan the whole file.
Jane Doe · 2022-05-22 12:08
>>31241
>I want to save the events defined into a file and then later find and read the dates requested without having to scan the whole file.
Are you doing this as an exercise in optimisation for its own sake, or for actual performance reasons?
If the latter, remember to always measure first to find your actual bottlenecks. I doubt that reading more or less of the file can make a significant difference, for the file size I imagine your program will usually work with. Anyway, the fastest thing I can think of is to ditch the single-file approach and instead keep each event in its own file, named after the month and day, inside a directory for the year.
If it's optimisation porn you're after, here's what I can come up with:
Simply keep the file sorted by date, so that you can always tell if the requested date is missing without reading all of it. Access time varies with the date and grows O(n) with file size, so this is quite bad.
A binary tree is less bad, as growth is only log(n). However, I don't know of a way to store a binary tree into a file so that you can search it directly, rather than having to read it all into memory first.
An ideal solution would involve being able to compute, from the date alone, the offset at which the event is inside the data file. One way to do this is to define your program to only work within a range of dates, and use a fixed size for each entry: to retrieve the event data, simply read the data file at offset (date - starting_date) * entry_size. The whole file must be generated and filled with blank values when the program first runs. Although improvements can be made, this approach is terrible - but, hey, O(1) access time!
Crazy Jake · 2022-05-22 12:47
I'm decently into SICP now, but I'm still having trouble with determining the time complexity and growth of a procedure. Are there other resources that will help me to understand how to figure that out?
H.R. Giger · 2022-05-22 13:23
>>31253
Can you post the specific section/page? Try tracing the function and looking at its shape: https://cs.wellesley.edu/~cs251/s00/trace.html (At some point, you want to also learn analysis of algorithms/asymptotic notation etc.) Also, watch the relevant SICP video lecture: https://www.youtube.com/watch?v=-J_xL4IGhJA&list=PLE18841CABEA24090&index=1
overriding · 2022-05-22 21:20
>>31254
Exercise 2.63 to narrow it down, though in the past I've had trouble or been unable to solve other exercises with this. I should really try expanding them, but I feel like there's a more important calculation that I'm missing.
Frank Garza · 2022-05-23 00:01
>>31251
>Are you doing this as an exercise in optimisation for its own sake, or for actual performance reasons?
It's an exercise to understand how databases operate, since I don't think databases scan the whole table file to perform read/insertion queries.
For the time being I think resizing fields, adding or removing fields and creating multiple tables is way out of my reach so I'm only interested in read/insertion under those restrictions.
>A binary tree is less bad, as growth is only log(n). However, I don't know of a way to store a binary tree into a file so that you can search it directly, rather than having to read it all into memory first.
I thought about making a binary tree but yeah that's the problem, I simply don't know how to translate pointers into data that can be used to re-generate the binary tree in memory.
>The whole file must be generated and filled with blank values when the program first runs.
Thought about that, but if each event has a title of 120 characters and a date it would be around 128 bytes per event.
If I want my program to work until 2052 I would need a 112 MB file to store the dates which is not something I'd like to do.
Koichiro · 2022-05-27 04:57
Is there a disassembler tool that help lainons analyse the offsets of C(++) struct/class members?
John Doe · 2022-05-27 18:48
>>31308
it's laindomos
look up reclass
Ender · 2022-05-28 08:35
>>31319
Thx! RE is fuarrrking hard fuarrrking requires experience and masochism.
Stallman · 2022-05-28 19:52
More of a /tech/ question than a programming one, but I've built a new computer that has 32gb of memory. Should I even bother with swap space?
() · 2022-05-28 20:25
>>31337
Don't.
If you notice running out, then sure, add it later if it makes sense. But if you're just doing whatever you were doing before on less then its probably needless.
The Oracle · 2022-05-29 04:57
>>31337
Nowadays, you don't need swap, unless you want to suspend on disk (DragonFly BSD even deprecated swap, IIRC). However, there are some counterarguments from systemdick folk:
>https://chrisdown.name/2018/01/02/in-defence-of-swap.html
If you are worried about OOM situations, install Earlyoom (you can also use systemd-oomd, if you use systemd)
Dr. X · 2022-05-29 15:50
I started to learn programming, I am learning c sharp with this book.
Got any tips :o?
push · 2022-05-30 10:27
>>31351
I recommend you use VSCodium (sic.) instead of full Visual Studio, unless you really need it. If you are using .Net Core, turn off the telemetry: https://wiki.archlinux.org/title/.NET#Telemetry Also, if you are looking for another book, I can recommend Microsoft Visual C# step by step by John Sharp. You also want to learn unit testing: https://www.manning.com/books/the-art-of-unit-testing-second-edition (I liked this book). Finally, don't try to use OOP design patterned forcibly. My advice is to avoid a pattern, unless you are sure that you should use it. I recommend you also download these 3 pdfs: https://books.goalkicker.com/CSharpBook/ & https://books.goalkicker.com/AlgorithmsBook/ & https://books.goalkicker.com/DotNETFrameworkBook/
And start using git version control: https://git-scm.com/docs/gittutorial & https://www.atlassian.com/git (git is much better than copy-pasting backup files)
Iverson · 2022-05-31 10:52
>>31241
>>31262
Calendar/database lain: I've figured binary trees a bit better, and I think I have some insight that we had both missed.
You can indeed search a binary tree directly from a file. All that is needed is to serialise it width first; then the offset within the file where each node starts can be figured out with a simple calculation. Finding an entry will require log(n) file seeks on average then, without restricting your date range or any such hackery.
The second problem is file size, but a simple solution exists too: keep your tree as close to complete as possible, and you will minimize the amount of blank nodes in your file (all nodes still need to be the same size, however, so space is still wasted there).
See here for definitions and details: https://cs.lmu.edu/~ray/notes/orderedtrees/
William Holtzer · 2022-06-01 18:51
I am an Electrical Engineering graduate who never got to work with what I studied due to COVID messing things up. I am ready to get into STEM and over these years I have lost my passion of EE developed a love for computers and I want to learn how operating systems work (with hardware) and maybe even help maintain one, who knows. What I want to know is where the best place to start. I have used C++ in passing but that's about it. I know about logic gates, binary math and other things EE's typically know about computers. Any recommended reading or things to research? From what I have gathered C is what I should start with in terms of languages, but correct me if i am wrong. Should I try to learn data structures and algorithms? There's a million things to learn and I want the most efficient route.
Morpheus · 2022-06-01 21:20
>>31398
You could try nand2tetris, which builds from the ground up. C is a good place to start, but I would also check out a dynamic language like Javascript or a Lisp and a functional language like Haskell (or Lisp), and then something object oriented to get a feel for the variety of programming.
swap · 2022-06-02 03:19
>>31398
>I have used C++ in passing but that's about it.
>From what I have gathered C is what I should start with in terms of languages, but correct me if i am wrong.
I recommend you learn some C before learning C++ (learn what malloc() does and what pointers are). PPP2 is a great C++ book if you haven't programmed much before (another option is C++ Primer by Lippman et al.). I think C/C++ is a great second/third language, but I think starting with a high-level language is better (you usually get immediate feedback). I recommend learning Scheme (use Guile or Chicken) or Lua first because they are simple languages.
>Read Little Schemer and Seasoned Schemer
>https://www.lua.org/pil/contents.html
>Should I try to learn data structures and algorithms?
Not at first. The first thing you should do is to learn a high-level programming language (Scheme/Lua) and a "low-level" programming language (C and a bit of asm). But you definitely need to learn data structures and algorithms before you can start writing "serious" programs.
>>31399
>nand2tetris
this and/or Programming From The Ground Up. Nand2Tetris and Programming From The Ground Up teach how a computer work. Some say that C teaches you how a computer works but that's not true (C teaches you how UNIX works). To really learn how a computer works, you need to learn asm.
Backus · 2022-06-05 17:33
How do I even get started? It's not like drawing where all you need is a pencil and paper. Every step I take reveals two more ahead of me.
>start CS book
>need to know math
>start studying math in addition to CS
>need an environment
>get GCC
>need to know command line
>start studying command line
>everything uses Linux packages
>install Linux
>kernel not compiling
>spend multiple days reading various manuals
It has been so frustrating just even getting to a point where I feel like I can even start and my new environment isn't even set up yet.
Project 2501 · 2022-06-05 18:29
>>31436
Sounds like you've dived right into the deep end. Try installing a simpler distro where you don't need to compile anything and just using Linux for a while. You'll learn better this way.
Same with the maths, put it to one side for now and when you encounter some trig or whatever you don't understand go back and read specifically about that topic.
Leto Atreides I · 2022-06-06 00:54
>>31436
stop listening to /g/. you don't need to read a math book to start programming. whatever OS you're currently using is fine to learn programming. download gcc + an editor like visual studio code and you're good to go.
also i'm assuming you have good reasons for starting with C. if you chose it just because /g/ told you then it's better to just drop it and learn something higher-level like Go, Python or Javascript. this way you can focus more on stuff like algorithms and writing software (which is probably the reason you want to learn programming, right?)
you can always go back to C at a later time
Kay · 2022-06-06 01:29
How do I develop the skills to contribute to projects?
You know when you read through the issues-page and you don't even know where to start?
How do you go from knowing nothing at all to being competent enough to solve the issues?
Neuromancer · 2022-06-06 08:06
>>31436
>How do I even get started?
First, you should learn high school math and install GNU/Linux (like Xubuntu, Debian/Devuan, Arch/Artix or Gentoo). If you don't know which distro you should pick, I recommend Xubuntu. Use the Windows Disk Management utilities to shrink the Windoze partition and dual-boot Windoze and GNU/Linux. For shell/command line skills, read https://linuxcommand.org/tlcl.php
I recommend that you do not start with C/C++ or Java/C#. >>31401 Recommended Little Schemer and Seasoned Schemer (for Scheme) or https://www.lua.org/pil/contents.html (for Lua). Scheme and Lua are really simple programming languages (and there aren't a lot of details to learn). For Scheme install Guile or Chicken (but you can also use Racket). Python and Ruby are also okay starting points. C/C++, Go, Java/C# are good second or third languages, but starting with them is not a good idea.
Pulse · 2022-06-06 12:49
I have to catch up with Operative Systems and Computer Architecture, so I'll stop programming for a while, how should I practice programming to avoid forgetting what I learned using just an hour a day?
Batou · 2022-06-06 15:33
>>31446
GP what?
Saaaaaaaaaa (now it's long enough)
Spike Spiegel · 2022-06-06 20:54
>>31440
0. lrn2prgrmngUn44b
1. learn the domain of the project
2. learn what project does
3. learn to use it
4. learn how the codebase is structured so you can more or less navigate it
5. learn how to debug by debugging
6. you should be more or less capable how to develop new shiet for teh project
Masami Eiri · 2022-06-07 03:07
>>31439
ehh, disagree about installing Linux. Most programming is still unix-centric and you're really just retarding yourself by insisting on windows.
You don't have to get super deep into it, but at least knowing your way around a shell is extremely useful.
BloodCat · 2022-06-13 19:34
Not sure if this is the place to post since I'm not a beginner to programming in general (I mostly use Common Lisp and have worked as a Python dev): what is the least awful way to do mobile development? All I want is a way to quickly make an Android app that looks nice and works without wanting to kill myself, don't care how to get there.
Iverson · 2022-06-14 17:46
>>31495
Kotlin compiles directly to android, it is provided as the new "official" language for android dev, it's a functional language so it's much better than java. The UI is designed via XML, so you could write a lisp program to create yourandroid UI, and add the logic with Kotlin. Of course it depends on what you want to do, but it should be simple enough for most applications.
cond · 2022-06-14 22:58
>>31498
That sounds doable maybe. I was considering using ClojureScript, but SPA webshit scares me. I also was considering Flutter but Dart at a first pass at least seems like an inscrutably bad language, but maybe that's because all this syntax hurts my lisp programmer brain.
John Doe · 2022-06-19 13:27
no one uses lisps.
what do
Void · 2022-06-20 05:05
>>31535
Do you want to have real job? Check out >>30745 and learn Python and Java/C# and a bit of SQL. You might find a Clojure job if you are lucky. If programming is just a hobby for you, then you can do want you want. Lisp dialects are great and fun programming languages. I recommend you start with Guile and read Little Schemer.
Nobody important · 2022-06-20 05:25
>>31449
I agree with what you're saying about unix but I believe when learning something it's best to remove as many distractions as possible so you can focus on the important stuff.
Having to install & learn a whole new OS is a pretty big distraction and i don't think the pros are enough to justify it for a beginner.
Armitage · 2022-06-20 05:30
>>31552
Microsoft considers C a deprecated language. C (and C++) programming is easier and more fun in GNU/Linux and *BSD (You even get man pages).
Vasya Pupkin · 2022-06-22 04:53
I love C and am in the process of learning C++ (with a textbook). Rust keeps popping up on every end but the usual channels shout mostly slurs when you ask for an opinion on the language.
Worth learning or should I focus my efforts to excel in my trifecta of favorite languages instead (C, C++ and Python)?
Donna Hawthorne · 2022-06-22 10:27
>>31589
Those are your three favorite languages, out of how many, and from how many different families, that you have learned?
It is always worth learning a language that will teach you something new. If you have never learned a statically-typed, functional language, or a lowish-level language with a focus on memory safety, then you would benefit a lot from learning Rust (or Haskell, or OCaml, or Ada).
Maybe you'll love it and never want to use anything else. Maybe you'll find it too cumbersome for daily use but a good choice for certain projects. Or maybe you'll never use it again, but even then, chances are you'll pick up some techniques that you can apply to your usual languages and gain a broader understanding of programming in general.
Davis · 2022-06-23 14:36
>>31589
Rust is cool. It's kind of like what C++ would be if it were functional instead of object-oriented and didn't need to maintain compatibility with C. Most of the dislike for it comes from hype backslash.
cond · 2022-06-24 03:41
Can someone list all the viable programming careers (i.e have a decent number of jobs)? I'm third year in SWE and still have no idea what I want to do once I graduate.
I looked on the local job finding site and I found a lot of web development jobs. I tried writing a web server in Go but I wasn't really interested enough to polish it. Is there any other career path?
Moore · 2022-06-26 15:56
>>31603
Webdev is the most common code monkey. Later would be not necesserly webdev stuff for banks and insurence companies, airlines, railroads. Yes, that;s the most codemonkey stuff I can think about. The rest is pretty much a niche mostly.
Koichiro · 2022-06-26 22:54
This sounds really stupid, but i am a bit afraid of using Python for anything due of its infamy of being prone to break up even within the same mayor version, am i shortsighted by my lack of experience? I considered starting to port some dumb adhoc bash scripts that basically are "given this path finde the files based on a regex expansiom, identify their filetypes and pass them to a respective external program/move them somewhere else to process them, then add a timestamp to the outputted filename" because they're honestly very bad, however the idea of having to tweak crap every few months with an update that will eventually break them isn't appealing, neither the idea of using virtual environments soykaf. Am i being too dramatic? What other language would you recommend for this simple task?
Neo · 2022-06-27 06:23
>>31643
pylint should tell you whether a souce file is using any deprecated method, module argument, class, alias, etc. for example the threading library not long ago deprecated a bunch of aliases to methods.
pip install pylint """ test.py """
import threading
print(threading.currentThread()) pylint test.py
of course, i should warn you the "proper" thing to do is to unit test every single piece of code, so if you have the budget/time you should do that as well. if you're interviewing for a company and they ask you how you would account for breaking changes in future python versions, you answer by writing thorough unit tests for everything, otherwise you get disqualifed. they have the money to throw at employees to write unit tests instead of making do with just pylint.
Judge Fang · 2022-06-27 06:45
Haskell Programming from First Principles and SICP are great for functional programming, i was wondering, is there anything equivalent for OOP? Most OOP books i could find don't really go in depth to the tradeoffs of OOP or reasons why i would choose it.
Drifter · 2022-06-27 11:25
>>31651
>Haskell Programming from First Principles and SICP are great for functional programming
>i was wondering, is there anything equivalent for OOP?
I guess, the Blue Book?
>https://wiki.squeak.org/squeak/64 || http://stephane.ducasse.free.fr/FreeBooks/BlueBook/Bluebook.pdf
Use either Squeak or Pharo.
Wirth · 2022-06-27 11:40
>>31650
Didn't knew about pylint, thanks. Maybe i am being way too pesimist after all, i'll explore further. Still think i'll stick to a slower moving target for something i can't be arsed to tweak/containerize. Maybe perl? What else is a good and stable scripting language? Babashka?
XERXES · 2022-06-27 11:51
>>31662
>Still think i'll stick to a slower moving target for something i can't be arsed to tweak/containerize.
There is Ruby (as easy as Python), Lua and Tcl (check out the wiki!). There was a good copypasta about Tcl floating around. For Lua there is https://www.lua.org/pil/ and for Ruby there is Programming Ruby: The Pragmatic Programmers' Guide aka the Pickaxe Book. I guess Racket is an option, too? If so, read Little Schemer and then the Racket Guide.
>Maybe perl?
Perl is ok and it has Perl Monks community, POD and CPAN. Also, try: perldoc perltoc Just don't do OOP in Perl. I think Python is not good for OOP either to be honest...
Apoc · 2022-06-27 12:28
>>31651
>>31660
I can recommend Practical Object-Oriented Design - An Agile Primer Using Ruby. It makes an effort to teach you many of the things that can go horribly wrong in an OOP project, and is quite easy to follow.
XERXES · 2022-06-27 12:33
So I been working in this program for a while and it's going terribly
/*
--------------------------------------------------------------------------------
FILE: exr.c PROJECT: C Primer Plus exercise 12 - 7a
AUTHOR: Ayef
PURPOSE: "Write a program that opens two files. You can obtain the filenames
either by using command-line arguments or by soliciting the user to
enter them.
b. Modify the program so that lines with the same line number are
printed onthe same line."
LICENCE: --
DATE: 2022-06-22 14:29:47 VERSION: 220627
--------------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LENGTH 80 //common text mode resolution
#define HALF 40
/*
!!!:
God knows why but the function declaration has to be AFTER the block of #include
or else the compiler won't even know what a FILE even is
2022-06-24 14:20:37 -- Ayef
*/
int PrintLines(FILE *FrstString, FILE *ScndString);
int main (void)
{
FILE *FrstFile;
FILE *ScndFile;
char BlankSign[LENGTH] = "\0";//this is here just to be used with strcmp
char FrstInput[LENGTH] = "\0";//I still don't understand the difference
char ScndInput[LENGTH] = "\0";//beatween " and '
/*request input*/
/*
FAQ:
strcmp returns 0 if the two strings are equal so as longFrstInput is empty
this loop will run
2022-06-22 14:20:46 --Ayef
*/
while((strcmp(FrstInput, BlankSign)) == 0)
{
printf("Give me the names of two files: ");
scanf(" %s %s", FrstInput, ScndInput);
if((strcmp(ScndInput, BlankSign)) == 0)
{
printf("\nInvalid name for the second file\n");
FrstInput[0] = '\0';//is this a hack?
}
}
/*error messages*/
if((FrstFile = fopen(FrstInput, "r")) == NULL)//probably not writen right
{
printf("\nCan't find the first file");
exit(1);
}
if((ScndFile = fopen(ScndInput, "r")) == NULL)//probably not writen right
{
printf("\nCan't find second file");
exit(1);
}
/*call the print function*/
PrintLines(FrstFile, ScndFile);
/*closing statements*/
fclose(FrstFile);
fclose(ScndFile);
return 0;
}
/*
prints two documents in the same line
*/
int PrintLines(FILE *FrstString, FILE *ScndString)
{
char CarryChar = '\0';
int Cols = 0;
/*
FAQ:
putting the ! before the function seems to set to the loop to work while the
return isn't positive
2022-06-22 14:26:02 --Ayef
*/
//prints the lines
while(!feof(FrstString))
{
fscanf(FrstString, "%c", &CarryChar);
if(CarryChar == '\n')
{
while(Cols <= HALF)
{
printf(" ");
Cols++;//sorry I wrote this fuarrrking lasagna of a program
}
}
/*prints the second half*/
if(Cols >= HALF)
{
fscanf(ScndString, "%c", &CarryChar);
if(CarryChar == '\n')
{
Cols = 0;
continue;
}
if(Cols >= LENGTH)
{
Cols = 0;
continue;
}
if (feof(ScndString))
break;
else
{
fprintf(ScndString, "%c");
Cols++;
}
}//the if loop ends here
else
{
fprintf(FrstString, "%c");
Cols++;
}
}//the while loop ends here
/*
BUG:
the program is printing one messy line and nothing else
2022-06-26 19:54:47 -- Ayef
*/
return 0;
} Last night I was copying one character of the file to another variable and printing it but it was coming out as jumbled lines of nonsense from both files
Today I tried directly printing the file but the compiler gives me this nonsense
exr.c:134:39: warning: format ‘%c’ expects a matching ‘int’ argument [-Wformat=]
134 | fprintf(ScndString, "%c");
| ~^
| |
| int And then the program prints a block of nothing.
This all has been really frustrating, I want to rewrite the whole function but I have no idea what to do for that.
Hacker · 2022-06-28 05:14
Question from a non-programmer, or rather, a complete nobody, to programmers here: why do you do the things you do? How did you come to like programming?
I am bad at math and I am normally too afraid to experiment with computers, or see no point in doing so. I've been like this for as long as I can remember. That said, I've become curious about the way programmers (and by extension, engineers and mathematicians) think as of late, because it feels like the mindset is pretty alien to me. Is it about the challenge? Is it about optimizing things? Is it about creativity?
When I tried reading about programming I couldn't shake off the feeling of how pointless it is to me personally. It seems there is nothing to optimize and automate in my life, and all the software I could ever need has been created already. If I do get an idea, it's usually (borderline) impossible, like optimizing or customizing closed-source software, or it requires skill and knowledge I don't have the time and patience to attain.
So, why? Is the thinking really that different? Is it even possible to learn programming and computer science if you're a dimwit like me?
Cereal Killer · 2022-06-28 06:28
>>31681
Did you like Lego or Meccano as a kid? Same thing. Same reason one uses Gentoo, really.
Lain Iwakura · 2022-06-28 06:53
>>31663
>Fount the Tcl copypasta:
Tcl is the best scripting language for the real but still productive hacker
(some of the fattest Schemes are not far).
* Extremely small - whole syntax/grammar is described in 12 rules in a single
man page (Tcl(n)) of 150 lines and there's no reserved keyword.
* Official man pages! No pydoc or cppreference garbage, here you almost have C
degree of exhaustivity.
* Kind of "unfashionable" language meaning basically no poz.
* At least two implementations with jimtcl being a very thorough embedded one.
* One of the simplest if not the simplest interaction with C, letting you write
C plugins very easily (with critcl, ffidl and swig to help).
* Comparable in speed to cpython, a bit slower than Perl5 and Lua. Has a
and a WIP/dead LLVM compiler (tclquadcode) for a big speedup in the far and
uncertain future.
https://wiki.tcl-lang.org/page/Tcl+Performance for more.
* Cool type system that is superficially "everything is a string" (like sh)
but in reality "everything is a tagged union with on-the-fly conversion when
needed and a unique string representation". Allows for some very cool things
like editing dictionaries as lists or lists as strings and transparent
serialization (`puts $mydict $chan` <=> `set mydict [read $chan]`).
* Talking about types, multiprecision arithmetic is transparently handled,
allowing you to do `expr {42 ** 1000}` if you just want to.
* Very powerful introspection through `info` (mainly). Allows for stuff like
getting the name/body/arglist of a procedure, get all the registered
procedures, know if a variable exist, get information on the stack frames and
their content, etc...
Together with `trace`, you can write an internal debugger in few lines. See
https://wiki.tcl-lang.org/page/Full+program+trace+onwards for an example.
* Procedure arguments are passed by pointer with a copy-on-write system: don't
modify the argument and you don't get any memory copy. To you, it just looks
like regular passing by value.
* On the subject of performance and simplicity, no need for an actual garbage
collector, reference counting is enough because you cannot make circular
references.
* Modifying the procedure arguments is done via `upvar`: in Tcl, a variable
reference is just a name (string) with a stack frame number, quite elegant
considering the language's concepts.
* If you use at least the builtin extensions (thread, http, tdbc, tcltest,
msgcat) and the very basic tcllib/tclX/tclUdp/tklib packages, you're almost
set for life. Personally, I also use the very convenient tclreadline, tdom,
pipethread and tclcurl.
Some more here: https://core.tcl-lang.org/jenglish/gutter/
* Channels is the cleanest I/O implementation I've ever used with some cool
features:
* Transformations allowing filters like deflate/zlib/gzip or TLS to be put on
a channel (see `transchan` for the API).
* Reflected aka virtual channels, to make a channel without an actual backing
FD. Basically like glibc's unportable fopencookie.
* Centralize all ioctl/fcntl soykaf and even more (like defining the EOF char).
* Integration with the event loop via `chan event` allows for a nice callback
oriented approach to sockets and pipes.
* Other third-party channel types include pty (expect), random, memory or
fifo (memchan).
* Builtin event loop (see `after`, `vwait`, `socket -server` and `chan event`)
for powerful and seamless concurrency/command scheduling.
* An elegant thread extension consisting of an interpreter per thread and no
raw access to other thread's memory. Comes with both simple (`thread`) and
performant (`tsv`) synchronization/communication facilities.
* Finally a sane, light and portable (even more with Tile) GUI toolkit: Tk.
* One of the fastest unicode aware regex implementations, written by Henry
Spencer himself. Has its own greater-than-POSIX-ERE syntax called ARE, not as
complete as PCRE (lacking lookbehind constraints, most importantly), but
still great for an hybrid NFA/DFA engine.
cf https://github.com/mariomka/regex-benchmark/pull/44.
* `uplevel` (execute a script in a different stack frame) and `tailcall`
(replace the current procedure with another command) let you augment the
language by implementing control structures and keywords yourself.
Inferior to CL's synergy between unhygienic macros, "naked AST" style
homoiconicity, symbols as first-class objects, gensym and quasi-quoting, but
still quite powerful.
* Safe interpreters let you do very fun things like config files in Tcl with
limited access to the machine and master interpreter.
* Obvious Lisp inspiration:
* Homoiconic through strings.
* Usual FP goodies like map/filter/apply.
* Already mentioned macros.
* Proper prefix arithmetic allowing for `* 4 [+ 1 2 3]` instead of
`expr {(1 + 2 + 3) * 4}` with sane behaviour for more than two (reduce) or
zero (neutral element) arguments.
* Multiple more-or-less powerful object systems ([incr Tcl] for C++ style OO,
XoTcl for CLOS inspired OO or Snit for something Tk oriented).
* All of that with the same advantage of CL: it does not enforce nor preach a
particular way of programming, unlike the ML family that comes with the
"everything is immutable" ball and chain that often gets in the way instead
of helping (because, big surprise, modifying data is often an essential
part of efficient and intuitive algorithms while recursing only makes sense
when manipulating recursively defined data types).
See https://wiki.tcl-lang.org/page/Functional+Programming for more.
* Biggest inconvenient is the near-death state of the language and community
(practical consequences: no LSP/SLIME equivalent, bugs accumulating, lack of
maintainted libraries) as well as some warts that can't be solved easily. As
someone who knows a bit of CL, the language itself is less powerful
(especially on the macro side) but the standard library is miles ahead during
the day to day.
Basically, a mix of CL and sh that somehow managed to end up very good and
getting even better with time.
I could continue all day, but you should just try it. Some more talk about it:
* https://wiki.tcl-lang.org/page/What+is+Tcl
* https://wiki.tcl-lang.org/page/Tcl+Articles
* https://colin-macleod.blogspot.com/2020/10/why-im-tcl-ish.html
* https://yosefk.com/blog/i-cant-believe-im-praising-tcl.html
* http://antirez.com/articoli/tclmisunderstood.html
Where to begin:
* man n Tcl (or `man 3tcl Tcl` on retarded distros like Debian)
* https://wiki.tcl-lang.org/page/TCL+for+beginners
* https://wiki.tcl-lang.org/page/Tcl+Tutorial+Lesson+0
* https://wiki.tcl-lang.org/ for everything, this is where the Tcl community lives
* Rosetta Code for examples/exercises
Anon's page: https://wiki.tcl-lang.org/page/q3cpma
>>31668
>God knows why but the function declaration has to be AFTER the block of #include or else the compiler won't even know what a FILE even is
FILE is specified in stdio.h so the #include <stdio.h> must be before it (and it's good style to put function prototypes after #include s).
>//I still don't understand the difference beatween " and '
" is for strings and ' is for single char.
Instead of using strcmp to check whether a string is filled with \0 chars (the first while loop in main()), you should treat the string as array and use == check if it's a null terminator char. Also, when you use scanf() with %s, you need to specify input length/limit or you need to use fgets() instead (I think fgets() might be better here?). The while loop on line 99 is suspicious (the man page says that non-zero means that EOF has been reached).
>>31681
>why do you do the things you do?
Either for fun/learning purposes or if I need to automate something (https://automatetheboringstuff.com/).
>How did you come to like programming?
I always liked computers and gaming. Then I wanted to learn the Windows command line (Batch). After that I learned Python and a bit of Bash.
>I am bad at math
Me too. But you can get a lot done with just basic high school math/precalculus (actually, just basic algebra and arithmetic). I recommend you get Precalculus Mathematics in a Nutshell (by George F. Simmons) and check out 3Blue1Brown and The Organic Chemistry Tutor on YT:
>https://yewtu.be/channel/UCYO_jab_esuFRV4b17AJtAw
>https://yewtu.be/channel/UCEWpbFLzoYGPfuWUMFPSaoA
>and I am normally too afraid to experiment with computers
Try using a virtual machine like VirtualBox (https://www.virtualbox.org/) or Qemu.
Tyrell Wellick · 2022-06-28 06:58
>>31643
Hijacking this to ask, how do ensure that my Python scripts have at least some degree of longevity? Do I really need to use containers and conda if all I want to do is transverse the file system, scan some ports and call other executables but with better constructs than shell's? I understand that there're domains where constant updates are beneficial, like cryptography, but why almost all of them are breaking prone with this language? Can I at least get some guarantees if I stick to the standard library? Or should I bite the bullet and just keep using shell?.
Special Agent Bob · 2022-06-28 11:07
>>31643
>>31687
I don't get where your fear comes from, the only time things were actively breaking is the stretched final shift (which at that point was extremely overdue, mind you) from Python 2 to Python 3, luddites clutched onto Python 2 created problems for themselves.
Dependency hell is real, but 99% of the time not caused by Python itself. It is pretty much unavoidable when you deal with things like this, be it Python, npm, Blender add-ons, game mods and whatever else.
Doesn't help that pip is trash, but anyway.
If you just use the standard library you shouldn't have problems.
If you use "first-class" packages like numpy you should be fine too.
If you use packages that depend on other packages, if you need a 50-package deep learning stack for your image sorting script, or you feel too lazy to not use that abandoned package that needs dependencies from 2 years ago that does just the thing you need - use venv.
Erik Johansson · 2022-06-28 13:38
>>31681
i personally started programming because i wanted to make videogames. i didn't even realize i was programming at the time, i just typed "how to make videogames" in google, downloaded the first thing i found (Game Maker) and started following tutorials.
nowadays i don't care too much for videogames but i kinda like understanding how things work so that's how i spend my time. i am still a student though, i'll have to learn something actually useful for a job some day soon.
> I am bad at math
i wouldn't worry too much about this. the math you need is the math related to the field in which you want to apply your programming knowledge. if you want to do rocket science programming then you'll need rocket science math, if you want to apply programming to a field with no math then you'll need barely any math.
> and I am normally too afraid to experiment with computers
why, you can fuarrrk up as much as you want and you'll never break anything. also pretty much everything is free, to me it seems a great playground
> It seems there is nothing to optimize and automate in my life, and all the software I could ever need has been created already
it's absolutely possible you have no use for programming, but it also could be that you don't see the opportunities because you don't know what tools you have.
that being said, it's rare to get the opportunity where it's quicker to write a program than to do some mind-numbing 30 minutes of work.
here's my opinion on why you might want to consider programming: because it's an augmenter for literally every other hobby.
* you like playing music? you could learn how to make virtual instruments. maybe you could learn how to use a microcontroller and build your own synthesizer
* you like literature? how about doing some data analysis on your favorite books, maybe find out which authors write most similarly?
* you like drawing? how about drawing with code, or maybe create some filters to apply for your photos.
even simply recreating something that already exists is fun, you don't have to make everything have a purpose
> Is it even possible to learn programming and computer science if you're a dimwit like me?
i don't know, how much of a dimwit are you?
Jens Hansen · 2022-06-28 22:05
>>31686
This pasta looks nice anon, thanks.
>>31688
Is a bit of paranoia and lazyness of my part, i can understand that network facing or some OS stuff need to be rolling targets for security and perfomance improvements, but the lazy side of me thrives for stability on afterthought scripts i use to automate mundane tasks but can't be totally trusted to the shell. Gonna see how far can i go.
Trinity · 2022-06-29 05:18
>>31686
>>31689
>I always liked computers and gaming.
>i personally started programming because i wanted to make videogames.
That's one common thread I see among programmers I talked to, but how come you didn't feel dread at the sheer amount of info you did not know but had to? Just recently I decided to check out how 3D engines and AI programming work, and these seem like an absolute nightmare, requiring entire teams of people with an extremely good grasp of algebra and geometry in order to be made.
Granted, programming an entire engine, pathfinding systems and such is a gargantuan task, and you don't necessarily have to know all this in order to make a game nowadays, but still, my rotten brain goes, "Without an in-depth knowledge of the inner workings of engines and everything you can't be a true programmer," and to achieve this self-imposed requirement I'd need years of intense study, which I can't afford and honestly I'd rather not at this point.
Did you simply not overthink it, or did you actually think this way but still perceived it as a fun challenge?
That's why learning programming feels scary, low-level stuff is simple but essentially useless, anything that's valuable requires a corresponding level of skill and time investment slowly building stuff up. That can be applied to virtually anything remotely creative, but programming seems much more daunting, partly because I have no idea how you get from programming tic-tac-toe to programming cool software or videogames.
>it's absolutely possible you have no use for programming, but it also could be that you don't see the opportunities because you don't know what tools you have.
Most likely. I know little about programming and the available functions, and all the programs I can possible fathom at the moment seem to be simple and "self-contained", like tic-tac-toe. Web-scraping actually surprised me, programming can go beyond tic-tac-toe and actually work with the PC functions or the Internet, cool!
>why, you can fuarrrk up as much as you want and you'll never break anything. also pretty much everything is free, to me it seems a great playground
Not sure. I've been meaning to try out Linux for the longest time but I've never done it due to hardware concerns: VMs and dual-booting apparently wear out the SSD (though basically unnoticeable, it still concerns me), doing away with Windows entirely and installing Linux on the entire drive full-formats it, which is, again, pretty bad for SSD's lifespan. The only true "safe" option I have is to buy an SSD I wouldn't regret running into the ground, which isn't exactly free. Then again, I may be wrong, as the posts that describe a reduction in SSD's lifespan are 7+ years old and maybe the tech isn't as fragile as I make it out to be.
>i don't know, how much of a dimwit are you?
You can gauge it based on my posts.
Naomi Nascimento · 2022-06-29 12:29
>>31686
All of that is beside the point, I just like to comment a lot in my code and comment about dumb observations
My real issue is the second function and its logic, I've polished it a little since my last post but as I go on things make less sense.
On it's current iteration it only prints the the spaces and the second document and I can't see what in the logic is not letting the first one get printed
/*
prints two documents in the same line
*/
int PrintLines(FILE *FrstFile, FILE *ScndFile)
{
char FrstChar = '\0';
char ScndChar = '\0';
int Cols = 0;
/*
FAQ:
putting the ! before the function seems to set to the loop to work while the
return isn't positive
2022-06-22 14:26:02 --Ayef
*/
//prints the lines
while(!feof(FrstFile))
{
fscanf(FrstFile, "%c", &FrstChar);
if(FrstChar == '\n')
{
while(Cols <= HALF)
{
printf(".");//it's a . to see if it's getting print properly
Cols++;//sorry I wrote this fuarrrking lasagna of a program
}
}
/*prints the second half*/
else if(Cols >= HALF)
{
fscanf(ScndFile, "%c", &ScndChar);
if(ScndChar == '\n')
{
Cols = 0;
printf("%c", ScndChar);
continue;
}
if(Cols >= LENGTH)
{
Cols = 0;
continue;
}
if (feof(ScndFile))
break;
else
{
printf("%c", ScndChar);
Cols++;
}
}//the if loop ends here
else
{
printf("%c", FrstChar);
Cols++;
}
}//the while loop ends here
return 0;
} Seriously I need help i been on this for too long
Nell · 2022-06-29 20:20
>>31695
If you want to make a game, go to the gamedev general, look at the resources for game engines, shop around, install one of your liking, seek tutorials for 9t, and start working, and then come ask quetions. If you want to program in general, same: shop around, pick a language, get a book, start learning.
Even if someone bothers to sit down and address each point in your post we'd be wasting our time because that's taking you nowhere. You'renot even asking questions anymore, just complaining, is that working out for you? Are you writing programs yet? Stop complaining about imaginary issues and actually deal with the real deal, lain knows there's plenty of problems with programming languages and ecosystems yet here we are all working our way through that soykaf. We're not going to spoon-feed you
If ultimately you realize you really are not that interested in programming to go through the trouble, then devote yourself to painting, fishing, scuba diving or whatever, but don't come waste your and our time with your excuses.
Idk the rest of the lains, but I can tell you I'm nothing special and I struggle to get even basic stuff done, but if I ultimately can learn and make stuff, then so can anyone.
Lady Jessica · 2022-06-30 13:06
>>31695
> how come you didn't feel dread at the sheer amount of info you did not know but had to?
i wasn't really thinking about that, i just wanted to make videogames. i read tutorials that made you create step-by-step some very basic games (2d platformers, breakout, stuff like that).
> Just recently I decided to check out how 3D engines and AI programming work, and these seem like an absolute nightmare, requiring entire teams of people with an extremely good grasp of algebra and geometry in order to be made.
that's only if you want to make state-of-the-art engines & AI. wanna know what kind of AI i had in my games as a kid? some stupid soykaf like
if (distance_to(player) < 500) {
rotate_towards(player)
shoot()
}
very simple things like this bring you to 90% of the result, it's the remaining 10% that is hard.
> "Without an in-depth knowledge of the inner workings of engines and everything you can't be a true programmer,"
first of all, that's silly: why stop at the engine then? why not learn how to make an operating system and a compiler? why not learn how your CPU and hardware work? why not ... etc
at some point you have to accept there are some things you'll only have a vague idea of how they work. that's not only limited to programming, "we stand on the shoulders of giants".
> I have no idea how you get from programming tic-tac-toe to programming cool software or videogames
that's absolutely normal. my tip is to search for tutorials that make you build something cool step-by-step. that should help you move to slightly-bigger programs. some links from my to-read list:
- build a text editor: https://viewsourcecode.org/snaptoken/kilo/index.html
- build a lisp interpreter: https://buildyourownlisp.com/
- raytracing: https://raytracing.github.io/books/RayTracingInOneWeekend.html
- wolfenstein 3d-like engine: https://lodev.org/cgtutor/raycasting.html
- web browser: https://browser.engineering/index.html
you can for sure find tutorials for making games in whatever language you want, maybe start with 2d games though since they're easier to make
> Not sure. I've been meaning to try out Linux for the longest time but ...
you don't need linux for programming, most programmers actually use windows and are doing fine.
if you're interested in linux for other reasons: i can understand the fear of trying another OS for the first time but come on, that ssd excuse is ridiculous. just use a vm (or the windows subsystem for linux) if you fear messing up your windows install
stack · 2022-07-02 10:54
First few days of learning C.. What am i doing wrong here? #include <stdio.h>
int main(){
int x;
int y;
int z;
printf("1.(*) 2.(/) 3.(-) 4.(+): ");
scanf("%i", &z);
if (z == 1){
printf("First Number: \n");
scanf("%i", &x);
printf("Second Number: \n");
scanf("%i", &y);
double a = x * y;
printf("%i * %i = %i \n", &x, &y, &a);
} else if (z == 2) {
printf("First Number: \n");
scanf("%i", &x);
printf("Second Number: \n");
scanf("%i", &y);
double a = x / y;
printf("%i / %i = %i \n", &x, &y, &a);
} else if (z == 3) {
printf("First Number: \n");
scanf("%i", &x);
printf("Second Number: \n");
scanf("%i", &y);
double a = x - y;
printf("%i - %i = %i \n", &x, &y, &a);
} else if (z == 4) {
printf("First Number: \n");
scanf("%i", &x);
printf("Second Number: \n");
scanf("%i", &y);
double a = x + y;
printf("%i + %i = %i \n", &x, &y, &a);
} else {
}
return 0;
}
1 * 1 comes back as -535358860 * -535358856 = -535358848 also tried breaking it down a bit and swaping a few things but still get a weird response #include <stdio.h>
int main(void){
int x, y, a;
printf("First Number: \n");
scanf("%d", &x);
printf("Second Number: \n");
scanf("%d", &y);
a = x+y;
printf("%d + %d = %d \n", &x, &y, &a);
return 0;
}
1 + 1 = -1413565796 + -1413565792 = -1413565788??? where is it even getting these numbers from
vector · 2022-07-02 11:17
>>31729
learn into -Wall flag of cc
gcc -Wall kurwa.c
kurwa.c: In function ‘main’:
kurwa.c:11:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]
11 | printf("%d + %d = %d \n", &x, &y, &a);
| ~^ ~~
| | |
| int int *
| %ls
kurwa.c:11:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘int *’ [-Wformat=]
11 | printf("%d + %d = %d \n", &x, &y, &a);
| ~^ ~~
| | |
| int int *
| %ls
kurwa.c:11:22: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘int *’ [-Wformat=]
11 | printf("%d + %d = %d \n", &x, &y, &a);
| ~^ ~~
| | |
| int int *
| %ls
Drano · 2022-07-02 11:20
>>31729
Using &variable in printf will return the address of the variable. use only the variable name like:
printf ("the variable is = %d", variable);
↑ · 2022-07-02 11:21
>>31730
Or in other words you are not printing variables. You are printing their addresses. &variable means you are using address of variable
Jane Doe · 2022-07-02 11:22
>>31731
>>31732
>>31730
oh weird, Going through this lesson atm and the teacher says to use that with variables.. Thanks anons i guess i should find another lesson!
Naomi Nascimento · 2022-07-02 11:23
>>31681
> why do you do the things you do?
I like feel the power of programming.
I can say whatever I please to cold soulless machine and it will do whatever I want.
Tequila · 2022-07-02 11:27
>>31733
figured it out! #include <stdio.h>
int main(void){
int x, y, a;
printf("First Number: \n");
scanf("%d", &x);
printf("Second Number: \n");
scanf("%d", &y);
a = x+y;
printf("%d + %d = %d \n", x, y, a);
return 0;
}
thanks again
Netrunner · 2022-07-02 12:34
>>31668
/*
--------------------------------------------------------------------------------
FILE: exr.c PROJECT: C Primer Plus exercise 12 - 7a
AUTHOR: Ayef
PURPOSE: "Write a program that opens two files. You can obtain the filenames
either by using command-line arguments or by soliciting the user to
enter them.
b. Modify the program so that lines with the same line number are
printed onthe same line."
LICENCE: --
DATE: 2022-06-22 14:29:47 VERSION: 220627
--------------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#define LENGTH 80 //common text mode resolution
#define HALF 40
/*
!!!:
God knows why but the function declaration has to be AFTER the block of #include
or else the compiler won't even know what a FILE even is
2022-06-24 14:20:37 -- Ayef
*/
/*
well of course, #include is the exact [citation needed lol] same as just copy pasting the code
from that file into the program before compiling, so if the code for FILE
which is <stdio.h> isn't there first it won't know what FILE is
The compiler reads this file line by line from top down and if it doesn't
know what something is it won't read further because it has no idea what to do
you can look at stdio.h in /usr/include/stdio.h
(assuming your in linux idk about macos or windows)
which basically gets ctrl-c ctrl-v 'd into wherever #include <stdio.h> is
*/
/*idk why you had PrintLines at the bottom of the file but that just makes it more complicated
because again the compile reads from top down so you had to do that wierd thing
where you declare the PrintLines but without the code
*/
/*
prints two documents in the same line
*/
//I renamed these to files instead of strings idk why it was strings
//int PrintLines(FILE *FrstString, FILE *ScndString)//before
int PrintLines(FILE *FrstFile, FILE *ScndFile)//after
{
//char CarryChar = '\0';
//int Cols = 0;
/*
FAQ:
putting the ! before the function seems to set to the loop to work while the
return isn't positive
2022-06-22 14:26:02 --Ayef
*/
//prints the lines
/*so fprintf ****WRITES**** to those FILE* but that won't work because you
opened them in read only mode down where fopen is in main(). If you look
at the man page for fprintf ($ man fprintf) it says it returns the number
of chars written so I bet it would be returning 0 since it can't write anything
Also I don't even think thats what you were trying to do so
Also the "warning: format ‘%c’ expects a matching ‘int’ argument"
makes more sense because it thinks you are trying to write a char
to the file, idk why it says it wants an int, I guess C quirks
*/
//yeah I have no idea what going on here, imma just comment it out
/*
while(!feof(FrstFile)){
fscanf(FrstFile, "%c", &CarryChar);
if(CarryChar == '\n')
{
while(Cols <= HALF)
{
printf(" ");
Cols++;//sorry I wrote this fuarrrking lasagna of a program
}
}
//prints the second half
if(Cols >= HALF)
{
fscanf(ScndFile, "%c", &CarryChar);
if(CarryChar == '\n')
{
Cols = 0;
continue;
}
if(Cols >= LENGTH)
{
Cols = 0;
continue;
}
if (feof(ScndFile))
break;
else
{
fprintf(ScndFile, "%c");
Cols++;
}
}//the if loop ends here
else
{
fprintf(FrstFile, "%c");
Cols++;
}
}//the while loop ends here
*/
/*I really have no idea what you are trying to do up above but here is
how to read in howevermany chars at a time
*/
const int bufSize = 1000;
char buffer[bufSize];
while(true){
bool endoffile = (fgets(buffer, bufSize, FrstFile) == NULL);//hopefully no bufferoverflow attacks
if(endoffile){//returns NULL if nothing left to read
break;
}
printf("%s", buffer);//print file in chunks of 1000 chars
}
return 0;
}
int main(void)
{
FILE *FrstFile;
FILE *ScndFile;
char FrstInput[LENGTH] = "\0";
char ScndInput[LENGTH] = "\0";
//"\0" is the same as [0], but when assigned to a big array is [0, junk, junk, junk, ...] which is what you want since we will overwrite all the junks anyways and nothing should mess up because of the 0 telling it is the end of the string
//'\0' is the same as 0 but only 1 byte and
/*request input*/
while(true){//should probably be its own function to be honest
printf("Give me the names of two files: ");
int stringsRead = scanf("%s %s", FrstInput, ScndInput);//dangerous, buffer overflow attack possible if input is longer than LENGTH
printf("read: \"%s\" for file 1\n", FrstInput);
printf("read: \"%s\" for file 2\n", ScndInput);
if(stringsRead < 2){
printf("failed parsing: only read %d names\n", stringsRead);
printf("enter in format: \nfile1 file2\n");
}else{
break;
}
}
/*error messages*/
//$ man fopen
/*
The fopen(), fdopen(), and freopen() functions may also fail and set errno for any of the errors specified for the routine malloc(3).
The fopen() function may also fail and set errno for any of the errors specified for the routine open(2).
The fdopen() function may also fail and set errno for any of the errors specified for the routine fcntl(2).
The freopen() function may also fail and set errno for any of the errors specified for the routines open(2), fclose(3), and fflush(3).
*/
//basically saying if fopen messes up then it will set this magic variable errno (see #include <errno> added at the top) which tells what error happened. The errno can then be converted into a string specifying the errror by strerror which is already included in <string.h>
//also why did you have the line breaks at the beggining of the string?
if((FrstFile = fopen(FrstInput, "r")) == NULL){
printf("Can't open first file \"%s\": %s\n", FrstInput, strerror(errno));
exit(1);
}
if((ScndFile = fopen(ScndInput, "r")) == NULL){
printf("Can't open second file \"%s\": %s\n", ScndInput, strerror(errno));
exit(1);
}
/*call the print function*/
PrintLines(FrstFile, ScndFile);
/*closing statements*/
/*also check for closing errors but usually
its fine since the program exits right after
but if the program continued the default linux kernel
only allows a file descriptor table of 32 so you can only
have 32 file open at once (unless you recompile kernel
after changing source code)
*/
if(fclose(FrstFile) != 0){
printf("Can't close first file \"%s\": %s\n", FrstInput, strerror(errno));
}
if(fclose(ScndFile) != 0){
printf("Can't open second file \"%s\": %s\n", ScndInput, strerror(errno));
}
return 0;
}
Joey · 2022-07-04 11:49
>>31737
>fprintf actually writes to a file
I'm so mad right now, holy soykaf.
I'm going to start removing my comments before I seek for help, I'm tired of people going on tangents about stuff I wrote for myself,
Also since I made that post I redid the whole function to be less nested but it's still giving me troubles so I just gave up, I'm tired of wrestling with the language.
chadols · 2022-07-05 10:56
What should I read to learn about networking?
Yu-ichi · 2022-07-05 14:19
>>31760
khanacademy.org/computing/computers-and-internet/xcae6f4a7ff015e7d:the-internet
guru99.com/data-communication-computer-network-tutorial.html
javatpoint.com/computer-network-tutorial
The Illustrated Network How TCP IP Works in a Modern Network (2e, 2017)
CompTIA Network+ Certification All-in-One Exam Guide (8e, 2022) (realistically they only hire those with EE/CE degrees)
CCNA Certification Study Guide (realistically they only hire those with EE/CE degrees)
CCNP and CCIE Exam Cram (realistically they only hire those with EE/CE degrees)
Linux Network Administrator's Guide - Bautts (2005)
beej.us/guide/bgnet/pdf/bgnet_usl_c_1.pdf (Beej’s Guide to Network Programming: Using Internet Sockets with C)
Turing · 2022-07-06 04:47
>>31760
Computer Networking: A Top-Down Approach or Computer Networks by Tanenbaum.
>>31766
>beej.us/guide/bgnet/pdf/bgnet_usl_c_1.pdf (Beej’s Guide to Network Programming: Using Internet Sockets with C)
This.
Elliot Alderson · 2022-07-06 06:07
>>31760
>>31768
>beej.us/guide/bgnet/pdf/bgnet_usl_c_1.pdf (Beej’s Guide to Network Programming: Using Internet Sockets with C)
This(x2)
Also Richard Stevens' TCP/IP Illustrated. A bit outdated but solid foundation, and very readable.
Jane Doe · 2022-07-09 14:21
What's a nice programmer?
Agent Jones · 2022-07-09 19:49
>>31785
A miserable little pile of secrets.
The Chanonomous hacker know as 4ham · 2022-07-12 20:57
Is HtDP any good? I've gotten halfway through the 2nd chapter and it feels like I've spent half my time writing boilerplate and tests. Is there a better way to learn the same info in less time or should I just suck it up and grind through the exercises.
>Inb4 SICP
HELIOS · 2022-07-13 02:52
>>31818
HTDP is very introductory. It'll be boring as fuarrrk if you have prior experience even if I think most people could get a lot out of adopting the kind of approach it encourages.
let · 2022-07-13 08:51
>>31819
This.
I would consider reading Simply Scheme and then SICP.
>https://people.eecs.berkeley.edu/~bh/ss-toc2.html
>https://mitpress.mit.edu/sites/default/files/sicp/index.html + https://www.youtube.com/watch?v=-J_xL4IGhJA&list=PLE18841CABEA24090&index=1 + https://www.gnu.org/software/mit-scheme/
I recommend you use MIT/GNU Scheme for these books, but use Guile or Chicken (or Racket/Common Lisp) for real projects. I recommend you install the Scheme implementation of your choice and Gnu Emacs+Rainbow Delimiters+SLY & Geiser (run M-x run-guile to start guile REPL etc).
Joey · 2022-07-14 20:04
>>31837
honestly man i have never met a single computer scientist who's good at math beyond like a high school level
and im talking guys who get paid six figures to touch computers
Anonymous · 2022-07-14 20:06
>>31838
I'm from Brazil, and HS math here in really bad.
Jane Doe · 2022-07-14 20:09
>>31838
I deleted my post because I've found the answer of one of my question just few posts above, only to my utter shame.
Well, I still need few books about Data Structures and Algorithms.
Linda Lee · 2022-07-15 09:33
Novice learning through HTDP here. Two chapters into the first section and I'm already starting to get discouraged not by the difficultly but mostly out of boredom. The book in PDF format is almost 800 pages. It could be that my short attention span or laziness is to blame but I really can't bring myself to trudge through all of this, especially if the material only gets significantly denser from here on out. I understand the importance of fundamentals and how a good education can do me well. I also acknowledge that I wouldn't even be writing this post had I stuck with the first decent-looking resource I came across. Alas, here I am, so many books, videos and curricula later, still without a basic idea of how to program or what to do.
Lady Jessica · 2022-07-15 23:20
>>31847
Uh, what's the question?
Just fishing for suggestions, I'd say download some example programs to view and modify. Recompile / run and see what happens. That's how I learned BASIC back in the day, but then again I was young and there were no online distractions. Book the lang came with was huge, but very boring. I learned more from the built-in help function of QBasic than the fuarrrk!ng manual. TLDR: screw books.
Unspecified · 2022-07-16 06:16
>>31853
Looking back on my post the next day, there wasn't really a question, it was mostly just to let off some steam. If I want to be a programmer I'm going to have to get over the fear of missing some foundational knowledge only found in a large book on computer science and start creating programs to learn from. Worst comes to worst I become a soykafty programmer with bad habits, but I've come to see that even this outcome is more desirable than not being a programmer at all.
Pulse · 2022-07-16 07:33
>>31858
Just don't sweat it. You learn and practice as much as you can. Read as any blkks as you can too. I sy parhize with your previous post. Just don't think you have to read them linearly, one after the other. Do push through the boring parts, read very quickly if you feel there's nothing new in the current section or chapter.
Faye Valentine · 2022-07-16 07:50
>>31847
This is from someone who used to be interested in meme books like these - while they may be useful in truly understanding how programming languages work, and how they're just abstractions of your actual computing CPU, transistors, etc, they aren't really helpful in getting to the part where you "actually do soykaf."
I'll tell you right fuarrrking now how most programming languages work to save you the headaches and 'tutorial hell'. Assuming here you already know how to compile soykaf and use an IDE.
Basically, every programming language has something called a 'function'. You also get variables, which can be whatever the fuarrrk you want.
A function pretty much just eats variables and uses the variables it eats to spit out different variables or "do soykaf". Computers are retarded, so you have to use logic like NOT/IF/AND etc which you can figure the specifics of yourself by googling up "BOOLEANS in 'your favourite language here'"
You can also put functions inside of larger functions to do more complex soykaf and so on. An example of a function is print, printf ,and whatever. Usually the syntax for feeding a var into a function is by putting it into some parentheses to the right of the function's name.
You use loops if you want to do soykaf over and over like run through a list or w/e.
Also - when it comes to anything more complex just search up something like "library for X", by more complex I mean soykaf like playing sounds, creating graphical windows, etc. And if you want to make a script for anything search up "X API", since an API is just the name of what programs/sites/etc use to communicate with outside programs running on your machine and generally prescribe a sort of format for what variables it'll send or receive in order to get things done.
Basically, if you actually want to get to the point and do something, pick literally ANY language, because they all pretty much have the same soykaf like functions/loops/logic, and search up the said terms in your favourite search engine where X is your chosen programming language like so, "boolean operators X", "loops in X", "variables and types in X".
Of course another thing you need to remember is that for you to actually bother fuarrrking remembering all this soykaf you need to make yourself a project or goal to chase.
Emmanuel · 2022-07-16 08:58
>HTDP
I didn't like it very much. It might be useful for teaching middle school/high school kids or something. I feel that other books are better (SICP, Little Schemer, Programming From Ground Up, etc).
Knuth · 2022-07-16 14:20
Should I bother learning Javascript or is WASM going to be the big thing?
The Fin · 2022-07-16 15:45
>>31861
>>31863
Thanks for the answers. "Tutorial hell" perfectly describes what I was going through. I'll be sure to choose a project and start working on it! See you all around.
Zhora · 2022-07-17 06:50
>>31877
>Should I bother learning Javascript or is WASM going to be the big thing?
If you want to do web development, you must know JavaScript. Read https://eloquentjavascript.net/ and use https://developer.mozilla.org/en-US/docs/Web/JavaScript as reference. WASM is only "needed" for resource heavy stuff. In my honest opinion, WASM is harmful. I also don't like NodeJS much (https://harmful.cat-v.org/software/node.js), but it's quite popular for the backend stuff. I think Go, Ruby, Elixir and even Java/C# are better for backend stuff than JavaScript or NodeJS. If you want JabbaShit but "with types", try TypeScript (but you need to learn JS before you learn TypeScript). Be sure to learn a bit of jQuery, Ajax and SQL at some point, too.
Moore · 2022-07-17 12:27
Is there a way to avoid spamming getters and setters or even creating classes for every damn thing in Java? I'm a noob who can't code for soykaf but I'm honestly tired of stumbling upon "just create a bunch of boilerplate code" so often. I like being as quick and to the point as possible.
藤原純一 · 2022-07-17 13:40
>>31899
It's Java, and with the exception of indie Android apps, Java is for corporate software, you don't have much of a choice. If you manage to get a job programming with Java, just play along with the OOP religion (e.g. encapsulation / information hiding) like an obedient employee and be glad you're getting a nice paycheck (until you can find better offers).
Lady Jessica · 2022-07-17 21:28
>>31899
Yes, it's called switching to Kotlin or Clojure.
Hopper · 2022-07-18 00:05
>>31899
if you are writing many getters/setters then you're doing OOP wrong. you should rarely have to write them, except for data classes.
one of the first principles of OOP is "ask, dont tell". every time you are tempted to add a getter/setter to an object you should first ask yourself if the thing you're writing should instead be a method on the object you want to add a getter/setter to.
that said, pretty much every IDE allows you to auto-generate them once you write the properties
queue · 2022-07-18 10:18
>>31909
https://wiki.c2.com/?NobodyAgreesOnWhatOoIs
Jet Black · 2022-07-19 19:39
What would you recommend for learning networks, lain? I have extensive experience in development, but i would not feel comfortable setting up a network or making it secure in any way. I'd like to learn more.
Demeere · 2022-07-20 07:29
>>31952
>What would you recommend for learning networks
Computer Networking: A Top-Down Approach or Computer Networks by Tanenbaum. For practical stuff, read UNIX And Linux System Administration Handbook.
Delilah · 2022-07-27 00:21
I've never been taught math properly, being in countries with soykaf education curricula. Everything I know was self-taught. I've been interested in CS ever since I was young, but it feels incomplete learning programming while not having a solid mathematical background. Should I keep trying to learn programming and devote myself to learning math afterwards; or focus on math now and get to programming later?
Also learning resources for both appreciated.
Cat Mother · 2022-07-27 04:12
>>32042
Contact Microsoft support, we can't help you with that.
Lady Jessica · 2022-07-27 04:23
>>32043
The gentleman on the telephone said my computer is infected with viruses and hackers. He is telling me to go to the nearest Wallmart store to buy some Google Play cards so they can fix my Internet. Thank you for your help.
William Holtzer · 2022-07-28 07:31
Hey Lain. I'm looking to find a way to run a script whenever I connect a device such as my phone to my PC. (Extra points if It can run when it recognizes that it's my phone that'S connected.)
Looking for ressources for doing this task on Windows, (sadly) but bash or algorithmes are appreciated too. I just can't find the right keywords to give me a hint on how to do it.
Agent Richard Gill · 2022-07-28 07:51
>>32064
https://www.google.com/search?q=windows+run+script+when+specific+device+connected
Apoc · 2022-07-29 11:03
Is it necessary to learn how to solve problems recursively? And how often do you solve problem through recursion
Zuse · 2022-07-29 13:23
This is better suited for the beginner questions thread rather than its own thread.
The necessity likely depends on your area of focus. Strictly speaking, anything solved through recursion can also be solved without recursion, but often times that makes for a much messier implementation. Graph theory problems, for example, are often easier with recursion.
Regardless of your area of focus, you should be familiar with it and understand the benefits and drawbacks, some of the related principles (e.g. tail call recursion) and how to implement basic recursive functions, even though you may not see it every day.
Cat Mother · 2022-07-29 13:41
Only use recursion when:
1) Dealing with recursively defined problems or data structures where the substructures can be created in O(1) (e.g. linked list, tree but not arrays).
2) Not doing production software or using a PL with guaranteed tail recursion.
When you're out of these situations, it just makes your soykaf unreadable.
Wirth · 2022-07-30 03:55
I came here to ask why my question was deleted. Sorry
I understand it but struggle to 'think recursively' when ever I'm asked to solve problems through it
Any advice or source of material would be appreciated
synchronized · 2022-07-30 09:38
I think I have a problem. I've probably written around five posts over the span of a year asking about where to start. I've started and dropped dozens of books, courses and videos on computer science/programming. What the fuarrrk do I even do? Is there anybody who relates to this cycle? At this point I have a basic understanding of Python and can create a CLI rock paper scissors program. Where do I go from here?
Davis · 2022-07-30 10:56
>>32087
Yes, because recursion makes some things much easier and cleaner (and easier to understand).
>>32093
>>32094
These.
>>32101
>I understand it but struggle to 'think recursively' when ever I'm asked to solve problems through it
Read the Little Schemer. It's a great book about Scheme and it teaches recursion. Use Guile or Chicken implementation of Scheme.
>>32108
You should think why you want to learn to program. What you want to accomplish? If it's a game, you should learn Pygame or Lua+Love2D (start with https://www.lua.org/pil/contents.html). If you want to automate stuff, read https://automatetheboringstuff.com/ If you are interested in retro computing, you might be interested in https://www.youtube.com/watch?v=MpKoh-AabTM&list=PLzuACU-W7Omo3VEnMKuM0IPupdOHFDzL3&index=1 (Read C Primer Plus along with these videos. If you are new to FreeDOS, read https://dpaste.com/4QXAGEVT7).
>Where do I go from here?
Start creating small useful scripts and automate stuff.
over · 2022-07-30 11:17
>>32108
I had this problem too. Since I've escaped it, I feel absolutely giddy about all the soykaf I can get done. Simple:
Get project idea.
label:
Write code.
jmp label
>but I MUST read the 20 wikipedia artic-
>but I MUST read the 20 research pape-
>but I MUST read every letter of every page of that bo-
>but I MUST read some random soykaf online abou-
>but I MUST read about the history of-
>but I MUST read
>read
It's not always a false statement. However, you need to WRITE CODE. Write. You need to write not just read. You read code but also you write code.
The main objective of your brain on this whenever you get tempted to read bytes too much more often than writing them, should be WRITE CODE. Associate that with actual progress, because you cannot learn to program only by reading a book. Books and papers and articles are good for the very introductory, but for really learning anything they are like reference tables to amplify what you're learning.
Write code.
Write code.
Write code.
Project 2501 · 2022-07-30 11:22
>>32101
Look into some useful recursive algorithms. I think some of the struggle associated with learning recursion is often because the examples given to beginners are unintuitive and not performant, e.g. calculating fibonacci with recursion.
I'd recommend depth first search and breadth first search on graphs.
Splicer · 2022-07-30 11:25
>>32112
This. Additionally, publishing your code is a good step. No matter how much you've read about whatever it is your working on, you've missed something, and publishing your code is the only way to get someone more knowledgeable to look at it and tell you what you missed
Turner · 2022-07-30 12:28
>>32108
I think the first thing you need to do is to answer yourself why you are trying to learn programming in the first place.
Is there something specific you want to be able to do, something you want to create? Do you want to get a job with a good salary?
I can relate, I started reading/learning and dropped (at least for the time being) like 4 books and 3 languages in the last month.
But it's not (at least not as much of) a problem when you know what you want to do.
I got just enough out of one book to be able to do a thing I wanted to do, just enough out of another book to do another thing, got a bit of some general fundamental concepts cleared up - it's like getting a small permanent buff.
Learning languages is easy(-ier) after the first one, if you actually picked up the fundamentals along the way and not just memorized the syntax. Same with frameworks, engines, whatever. Ultimately it's all just tools.
Working with tools sometimes might be not easy, but overall it's not the hard part - design/engineering is. And before everything else you need to know what you want to make, and what for.
All of this aside, if you're stuck in the total beginner phase the thing to do is to pick a book and force yourself to get through it, to get at least the very basics down.
Depends on your background (not just programming, but mathematics, logic...) and willpower/discipline, but it shouldn't be something too long or advanced.
Invent Your Own Games With Python is easy modo.
Set your learning hours (consistent schedule is important) and spend 2-4 hours (with one-two ~15 minute or many very short breaks - whichever works best for you) reading and manually (important) typing in the programs. If you feel like you don't really understand something - go back and reread it, multiple times if necessary.
Didn't read it myself, only skimmed through, but Explorations in Computing: An Introduction to Computer Science and Python Programming seemed like a good CS intro book.
Eloquent JavaScript is, completely unironically, the book I wish I had in my sights when I just started. However, it actually can be too hardcore for a beginner (at least it totally would be for a retard like me), so I consider it a beginner's great second or third book. But if you have no interest in/practical applications for JS then it's better to read something more relevant to you. There are a lot of good books and other resources, too much for one to consume them all.
I can name a bunch of other books like A Gentle Introduction to Symbolic Computation, but you probably should pick between the first two.
The most important thing: practice. Start doing your own things immediately after you finish that book - ideally, start trying to do your own things while you're still reading it, between your study sessions. Just play around.
drop · 2022-07-31 11:14
I want to work with SDL2 on NixOs but I'm failing left and right. Where are the header files?
Cutter · 2022-07-31 13:17
>>32139
Managed to fix it but man what a dumb error. pkconfig is case-sensitive the two packages are called sdl2 and SDL_images. All over the place.
string · 2022-08-02 20:29
Do I need a VCS?
I currently use git because it's widely used and I can sync my project to my server and view it from gitea. I dislike how git keeps track of date and time and I can't hide that. Working alone doesn't give me a good reason to use branches and other features of git, so I wonder if there's something simpler and privacy preserving.
Then how would I archive a project? Should I just leave it aside?
Nanashi No Gombe · 2022-08-02 21:21
>>32162
To add to what this anon says, git also seems to store the timezone of those making commits. Beware.
Linus Torvalds · 2022-08-03 03:53
>>32162
idk about other VCSes, but if you don't need a commit history at all, you could use rsync or just create a tarball whenever you want to save the state of the project and upload that to your server.
>>32163
export GIT_AUTHOR_DATE='Thu Jan 1 00:00:00 1970 +0000'
export GIT_COMMITTER_DATE='Thu Jan 1 00:00:00 1970 +0000' you can change the dates of the previous commit by doing GIT_COMMITTER_DATE=1970-01-01T00:00:00 git commit --amend --date '1970-01-01 00:00:00' do this during an interactive rebase to change multiple commits
Nameless · 2022-08-04 09:35
Thinking about finally taking the dive and actually learning programming. I've hacked together bash scripts and messed with code because I've been using linux for about a decade now, but I never bothered to actually learn.
Any ideas on functional linux related projects for beginners? Ideally something fit for python, as I'll be starting with that. I think the first thing I'll do is rewrite my bash scripts in python, but I'm kinda lost as to what to do after.
Nell · 2022-08-04 10:07
>>32040
They are both worth learning for their own sake and to complement each other. It doesn't really matter what you do, as long as you start doing it and dedicate yourself to it. You can always supplement what you've learned later.
As far as resources go, I really recommend khan academy and pauls online notes. I also never properly learned math in school and these two sites have helped me learn most of Algebra and some Trig. If you do start with programming though, I feel like the concepts you learn will ease you into understanding math better(especially if your math education failed you like mine did).
Mentat · 2022-08-04 12:12
>>32040
>math
Read Precalculus Mathematics in a Nutshell by George F. Simmons.
>>32180
Work through https://automatetheboringstuff.com/
Do exercises at https://projecteuler.net/ and https://exercism.org/
Nell · 2022-08-04 13:04
Need C++ "meta" help.
How do I structure my program properly? I have multiple files and one header, where do I place them, in what folders? Should I declare the classes in the header too? Should my import-statements be in that one too? I wasn't able to compile when I had it in a different folder despite trying to refer to it from the project-root directory.
None of the books I read gave me much info on it.
John Doe · 2022-08-04 14:16
>>32187
You can put the header files from */project/include/ with the -I (capital i) as in -I /path/to/project/include/, make sure to have all this stuff in the makefile.
There are no actual rules as to where to put your definitions and stuff. I usually do have a header file for class definitions and for declaring it's functions, and a cpp file for the actual code of that one class.
#includes are tricky, if you're not careful you can have a circular include loop that'll never end! Usually I think it's better to include files in the code files, where they guide the specific requeriments for some library functions, but there are a few include files that you're going to need virtually everywhere and they could go in their own header files, and classes that you know depend on other of your own classes should probably include them in the header for that class
Jens Hansen · 2022-08-07 05:41
>>32187
>How do I structure my program properly?
You can just put all source files and header files in the same folder if there aren't over 9000 of them. Specify their relations using a makefile or use either CMake or Meson. Use header guards (to make sure that the same .hpp file is included only once). Add things like class declarations, structs, function prototypes and enums to header files. Do not put more #include statements inside a header file than are strictly required to get it to compile.
Nguoi La · 2022-08-11 12:03
> https://www.tutorialspoint.com/data_structures_algorithms/
beginner here, is this good enough to give me an overview of data structures and algorithms?
Cutter · 2022-08-11 13:15
>>32297
For studying algorithms, I would use these instead:
>https://www3.cs.stonybrook.edu/~skiena/373/videos/ + https://www.youtube.com/playlist?list=PLOtl7M3yp-DX6ic0HGT0PUX_wiNmkWkXx
>https://algs4.cs.princeton.edu/home/
Introduction to Algorithms (aka CLRS) is a good book, too.
Sipho Nkosi · 2022-08-11 22:38
>>32298
Thank you so much, lainon!
Liet Kynes · 2022-08-14 13:34
How do I load 32-bit DLL (SysWoW64) in Visual Studio 2022? I'm working on a project that requires legacy Windows libraries and it's my first time working with Dynamically Linked Libraries
HMODULE hModule = LoadLibrary(TEXT("C:\\Windows\\SysWOW64\\MSVBVM50.dll"));
if (!hModule) {
printf("module not found\n");
printf("last error: %d\n", GetLastError());
}
my error comes out to be "module not found, last error: 193" which according to https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499- is "ERROR_BAD_EXE_FORMAT".
based on stack overflow this is because it's a 32 bit library on a 64 bit system, which it indeed is. but how do I deal with this?
Drano · 2022-08-14 13:39
>>32372
nevermind I'm dumb, I just clicked around and found the drop down to switch from x64 to x86.... works just fine now.
first time using visual studio, ignore me!
Masami Eiri · 2022-08-22 09:08
i tend to prefer java or rust, but i screwed around in scheme a bit and wanna learn "real" functional programming.
would haskell or OCaml be a better choice for me to start out with?
Elliot Alderson · 2022-08-22 14:25
Haskell is more purely functional, so if that's what you want go with that.
nil · 2022-08-22 18:10
If you’re comfortable in the JVM, Clojure and Scala are good options.
Haskell and Ocaml both have small communities, so as long as you’re prepared to rely on documentation or books, and not stack overflow, then I’d say pick one and go. The decision is really one of taste, but Haskell is the more abstract of the two.
par22 · 2022-08-23 02:23
>>32471
>i screwed around in scheme a bit and wanna learn "real" functional programming.
Scheme is a good choice due to the abundance of beginner functional programming books that use Scheme as a teaching language. The Little Schemer will teach you functional programming using Scheme.
Frog Poster · 2022-08-24 00:25
Currently working in Testing , I have started studying Data Structures.
I need some tips on how to get in Data Structures
Apoc · 2022-08-24 00:43
Data structures are how you structure the data.
idk i'm not a programmer.
Unidentified · 2022-08-24 01:05
>>32510
There's a 5 hour or so course on them by freecodecamp on youtube along with asymptotic analysis. You don't really need to use a book to understand the vast majority of them. I suggest you implement them all, find out where they're used (i.e. the callstack, so on...). After you've implemented them all maybe grind leetcode a bit since you already have a job and get into a better company.
Try to think of everything you do from now on as an exercise to find the most efficient algorithm. Of course, in some places you might want to just filter instead of mutating in-place because that's weird as fuarrrk, but say you have to use Array.prototype.find repeatedly, maybe sort and use binary search instead.
One of the biggest problems is that in real development you'll almost always use only arrays, sets or hashmaps, so leetcode or interesting portfolio projects are the only way to get good at these.
Frog Poster · 2022-08-24 06:17
>>32513
OP here
Yeah I want to git gud in Data Structures so that I can get a good paying job.
Currently working from Home so even the minimum Wagie Salary feels good but I wanna move out and enjoy life but for that you need money $$$
Turner · 2022-08-25 02:35
>>32516
> git gud in Data Structures so that I can get a good paying job.
Sounds like a meme to me. Data Structures are part of intro2CS curriculum, good to know generally, and what high end employers test as part of ritualistic hiring processes. However, most programmers 'data structures' are import/#include 'ing premade libraries, - its commodity code you can copy paste.
Google will not pay you to write a linked list.
I don't think it would be a mistake to invest time in other skills like unit Testing Technologies, Version Control, Continuous Integration Technologies, or projects.
You will probably get enough practice making linked lists in college.
Frog Poster · 2022-08-25 12:58
>>32528
Actually I am pretty bad in Data Structures plus I am a fresher so there is a scope for me to improve
Issue is I am so distracted ffs.
Ivan Horvat · 2022-08-25 13:52
This should really be in the beginners questions thread and not it's own thread.
>>32529
If you're a freshman studying computer science, your uni will have a course on data structures. if you're just doing this for a job after school, you don't need to get ahead of yourself.
Otherwise if you want to learn it now because it interests you or you're working on some hobby projects, just pick up pretty much any book on data structures. There's not too much variance in it.
>>32513
>One of the biggest problems is that in real development you'll almost always use only arrays, sets or hashmaps, so leetcode or interesting portfolio projects are the only way to get good at these.
To add to this, most of the time you do use a specific data structure, it's through an interface that abstracts away the details of the implementation. The api for interacting with a set is the same whether that set is backed by an array, tree, or hash table. You really only need to know which data structure fits best for your use case, not the implementation details of it.
You should still go implement some of the common data structures on your own because they're good coding exercises and fun.
Arisu Mizuki · 2022-08-25 14:30
>>32510
>I need some tips on how to get in Data Structures
Implement them in C (I guess C++ and Java/C# are okay, too). Watch something like: https://www.youtube.com/watch?v=RBSGKlAvoiM (or some uni lecture videos like MIT OpenCourseWare videos). Read something like CLRS for learning algorithms.
>>32528
But knowing basic data structures (especially when you should them) is crucial programming knowledge (just like algorithms).
Frog Poster · 2022-08-28 05:52
Thinking about switching to linux permanently.
Windows is getting way too distracting for me to focus properly
Hoping Switching to linux might help.
So, Artix (Luke Smith Rec) or Linux Mint?
Molly Millions · 2022-08-28 08:46
>>32559
If you are new to Linux, I recommend you read: https://linuxcommand.org/tlcl.php
>So, Artix or Linux Mint?
It depends on your skills and whether you are willing to read the Archwiki. Arch Linux and Artix Linux are much comfier than Linux Mint or Ubuntu (or any of the alt "flavors"). On the other hand, Linux Mint (and Ubuntu flavors) come with full system but they are more bloated and getting software outside of main repositories is a major pain on Mint/Ubuntu (unless there is a flatpak). Also, on Arch and Artix, you need to install Xorg (GUI), etc. yourself (just run: pacman -S xorg-server lightdm lightdm-gtk-greeter ttf-dejavu xf86-input-libinput xf86-video-vesa xfce4 xfce4-goodies pulseaudio pavucontrol pulseaudio-alsa) .
If you want to use AUR, you need to always read the PKGBUILD files because anyone can submit a PKGBUILD script at the AUR. I recommend you use the rua AUR helper (https://aur.archlinux.org/packages/rua) for installing stuff from AUR because it allows you to easily review PKGBUILD scripts.
The choice between Arch (uses Systemd) and Artix (supports OpenRC and Runit) boils down to whether you want Systemd or not. There are some genuine reasons to dislike and avoid Systemd (https://without-systemd.org/wiki/index_php/Arguments_against_systemd/ & https://nosystemd.org/) but if you are new to GNU/Linux, you might want to install a distro that uses Systemd because when you search the Internet for help, most guides assume you use Systemd. But OpenRC and Runit are just as easy to use and fast as Systemd (but Systemd is much more bloated).
The most noticeable difference (for you as user) between Systemd, OpenRC and Runit is how you use start and enable services.
Here is the comparison between Systemd and OpenRC (but Runit is not any harder to use):
systemctl enable apparmor → rc-update add apparmor [default]
systemctl [re]start apparmor → rc-service apparmor [re]start
systemctl disable apparmor → rc-update del apparmor [default]
If you want to use an installer for Arch, you should use the official archinstall (https://wiki.archlinux.org/title/Archinstall) but the traditional/manual way of installing Arch/Artix is more flexible and you 100% know what's happening during each step (I recommend doing a manual installation; just follow the official installation guide).
On both Arch and Artix you need to follow the news RSS feeds:
>Arch: https://archlinux.org/feeds/news/
>Artix: https://artixlinux.org/feed.php (if you install artix-archlinux-support, you need to follow Arch Linux news as well!)
I recommend you use the Liferea RSS reader, unless you already have a RSS reader.
Sometime ago, I made this copy-pasta of Arch and Artix post-installation steps: https://pst.moe/paste/titspz
If you don't know which distro you should install, I recommend installing Arch Linux (you can later switch to Mint or Xubuntu if you don't like Arch).
Davis · 2022-09-02 23:08
is this a good plan of attack for learning C?
C Programming: A Modern Approach, then Modern C, then Object-Oriented Programming With ANSI-C, then Expert C Programming: Deep C Secrets, then Advanced Programming in the Unix Environment, then The Practice of Programming, then The C Programming Language K&R book?
i just feel kinda lost. I tried getting through the K&R book first but that soykaf is hard, i made it to almost the end but i felt like i was barely scraping by with all the exercises. I just wish there was like a definitive list of books that i ought to read in order to learn C.
i want to eventually get into making game emulators, 2d games, and reverse engineering programs
Judge Fang · 2022-09-03 06:18
>>32625
K&R is outdated and it was written for people who can actually program. K&R also doesn't contain warnings about unsafe stdlib functions. I think the best book on C is C Programming: A Modern Approach, 2nd ed. I used to recommend C Primer Plus by S. Prata but I think C Programming: A Modern Approach, 2nd ed. is better. I recommend only reading the example programs and exercises from K&R and nothing else (even though it's well-written book).
>I recommend: C Programming: A Modern Approach, 2nd ed. → Hacking: The Art of Exploitation → 21st Century C, 2nd ed. → APUE or The Linux Programming Interface
I haven't read Deep C Secrets or The Practice of Programming but they seem like great books (I would read them after Hacking: The Art of Exploitation or 21st Century C, 2nd ed. if you decide to use my recommended book list. Also, remember to enable -Wall and -Wextra compiler options and use Valgrind and a lint (splint/cppcheck or something) a lot.
J.C. Denton · 2022-09-03 15:19
>>32627
alright, thanks so much for the response bro
>I recommend: C Programming: A Modern Approach, 2nd ed. → Hacking: The Art of Exploitation → 21st Century C, 2nd ed. → APUE or The Linux Programming Interface
i think for sure im gonna do this in this order, thanks
Apoc · 2022-09-03 15:52
Am I retarded for wanting to dive into learning Rust to make GUI apps right after "learning" how to use lua to change a few things in a game using its modding API?
Tank · 2022-09-03 18:18
>>32637
>learning Rust to make GUI apps
That's not Rust's strength, at least not yet.
Pulse · 2022-09-03 19:22
>>32637
In terms of bouncing from thing to thing, not necessarily. In terms of what you're looking to do I will echo the other anon's sentiment and say that Rust will get in your way more than it's worth if you want to make a GUI. Rust has pretty good learning materials, but not for your specific goal. If you want to interact with your programs graphically I'd suggest a dedicated learning language or a web language, both consider GUI design a central feature. Racket for example is not limited by being originally designed as an education tool, it can make serious, full programs.
Guthrie · 2022-09-04 05:00
What about this book, is it good?
Knuth · 2022-09-04 12:41
>>32645
I think C Programming: A Modern Approach, 2nd ed is a lot better but the chapter 11 of Effective C is something you should read later (after you have read C Programming: A Modern Approach 2), since testing is not covered in depth in C Programming: A Modern Approach, 2nd ed. The tl;dr version is that you should enable warnings (-Wall -Wextra -Wformat=2), use a lint (like splint or cppcheck. Clang's scan-build is also helpful), and use Valgrind (or your compiler's Address Sanitzer feature but don't use both at the same time) and learn to use GDB (at some point. Also, there are some gdb GUIs available: DDD, Emacs has one and VSCodium has one). Also, when you debug your program use -Og and -g3 compiler flags (in addition to your regular flags but note that you can have only one optimization flag enabled at one time).
The main problem with Effective C is that it's hard to follow (unless you already know some C), whereas in C Programming: A Modern Approach 2 concepts are introduced in a logical order (so it's easier to understand). Also, I recommend that you don't use Visual Studio because it has poor support for C language (but using VSCod{e,ium} is fine, however).
McCarthy · 2022-09-04 13:22
>>32625
> i want to eventually get into making game emulators, 2d games, and reverse engineering programs
i don't see the point in reading so many books one after the other without really putting in practice what you read.
you've read a book on C, you can already start learning how to do these things you listed.
2d games is the easier of the ones you listed, search for some tutorials on SDL (a library for multimedia stuff) and start making little games.
you'll want to learn a little bit of computer architecture for building emulators and reverse engineering, but you can probably learn it on the go
sizeof · 2022-09-05 02:29
>>32652
ok, i'll give it a shot then, i guess i'll start studying the SDL2 docs to try and make little 2D games, thanks
Frog Poster · 2022-09-05 03:20
>>32560
I chose Debian +xfce in the end lmao.
Seems to work fine for me
Frog Poster · 2022-09-05 03:26
Are there any good resources to learn C online?
https://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Pointers
I found this website and it seems good, are there any more like it ?
Yuki Nagato · 2022-09-05 06:34
>>32656
>I chose Debian +xfce in the end lmao.
Debian is a excellent choice (clearly better choice than Ubuntu (or its flavors) or Linux Mint or Manjaro, etc.).
I recommend that you avoid using 3rd-patry repositories, instead use Flatpak when possible (speaking from my past experience with PPAs). Also, if you want a good TUI for apt, install aptitude. You might want to install build-essential (gcc plus other stuff) and firmware-linux + amd64-microcode + intel-microcode packages. Using and enabling ufw and apparmor is also recommended:
sudo apt install aptitude build-essential tmux firmware-linux amd64-microcode intel-microcode bash-completion #apt-listbugs flatpak
sudo apt install ufw apparmor apparmor-utils apparmor-profiles apparmor-profiles-extra nano
sudo ufw enable
sudo ufw default deny
sudo systemctl enable ufw
sudo systemctl enable apparmor
sudo nano /etc/default/grub
# edit the config file to look something like:
# ...
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 apparmor=1 security=apparmor lsm=capability,landlock,yama,apparmor"
# ...
sudo update-initramfs -k all -u
sudo update-grub
Also, if you want more recent packages, you can upgrade to testing (but avoid unstable/sid). First, install apt-listbugs and tmux packages and follow the instructions at https://wiki.debian.org/DebianTesting and then open a terminal/vconsole and run:
tmux
sudo apt update
sudo apt-get upgrade && sudo apt-get dist-upgrade
# if all went well you can exit tmux:
exit
# and then reboot your system.
# BUT if Xorg crashed (very, very rare), the update still keeps going *if* you run it inside tmux (or a vconsole).
# You can switch to a vconsole with Ctrl+Alt F2 (etc.) and
# run "tmux attach" to reattach to the tmux session (where apt runs).
#
# To get help with using tmux see: https://cheat.sh/tmux
# also, try typing this inside tmux: ctrl+b ?
# (ctrl+c exits the tmux help screen)
>>32657
>Are there any good resources to learn C online?
Most online resources just aren't that great.
Use libgen to get a pdf of Programming: A Modern Approach, 2nd ed. Use man-pages (like man 3 printf) and https://en.cppreference.com/w/c as your reference. There is also the webpage for the #c IRC channel (https://www.iso-9899.info/wiki/Main_Page) that contains helpful info. If you are looking for an IRC client, install Irssi or Hexchat (GUI).
In addition, I found these articles to be helpful (but they cover more advanced topics):
> https://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html (you must read this at some point)
> https://insecure.org/stf/smashstack.html
> https://lwn.net/Articles/250967/
> https://gist.github.com/nicowilliams/a8a07b0fc75df05f684c23c18d7db234
> https://beej.us/guide/bgnet/
⍕ · 2022-09-05 06:40
>>32661
> instead use Flatpak when possible ...
* I meant to say "use Flatpak if a package is not available from official Debian repositories". Don't use 3rd party repositories or PPAs. They suck.
Void · 2022-09-05 09:37
In declarative languages, it is possible to extend functionality of some system without ever touching its code. Consider the typical ML-esq Fibonacci implementation:
fib 0 = 0
fib 1 = 1
fib n = (fib n) + (fib n-1) Here, the definition of fib isn't strictly local; all three lines are independent of eachother and could be placed anywhere in the code. This isn't something you can typically do in imperative languages. My question: is there a name for this pattern? I'm shopping around for programming languages and I'm curious to know how this pattern has evolved.
Sabo Engle · 2022-09-05 10:49
>>32661
>https://gist.github.com/nicowilliams/a8a07b0fc75df05f684c23c18d7db234
>"fork () is evil -- vfork() is good"
The issue is not that simple:
>https://lisper.in/vfork-is-still-evil
>https://ewontfix.com/7/
Frog Poster · 2022-09-06 09:27
>>32661
Sir my blessing to you for sharing such cool and nice information.
chadols · 2022-09-08 20:27
>>31169
Where can I find articles/papers on programming topics? I learned a bit about railway oriented programming and I want to learn more about it and other programing concepts. However, when I searched on YouTube for videos on ROP, all I got was conference talks. So, where do I find articles and papers about programming concepts?
Koos van der Merwe · 2022-09-10 09:10
>>32695
Find an author of any paper you found(or conference talk). Look up his webpage on the internet(they usually have a professor's site from some university). Read their papers and use the references to look up other authors from the same topic you are interested. Most, if not all, researchers use Arxiv now(or at least up it on arxiv so people can read it), but you are better off looking for researchers than reading random papers on arxiv.
bit · 2022-09-15 07:15
I started learning c++(I can make loop and selection structure programs) and discrete mathematics (studying propositional calculus from Kenneth Rosen).
Dujour · 2022-09-16 12:09
>>32765
>I started learning c++
I recommend reading PPP2 by Bjarne Stroustrup. Remember to enable the recommended compiler options: -std=c++17 -O2 -Wall -Wextra -Wformat=2
In addition, these can be useful while debugging: -Og -fverbose-asm -ggdb -g3
-Wshadow can be useful as well but it can cause false positives (unneeded warnings).
A program called "cppcheck" can help with finding bugs in your code.
Jens Hansen · 2022-09-16 12:55
>>32788
i suggest also using "-g -fsanitize=address" (they are 2 flags but -g is useful because it gives you nicer error messages).
basically it automatically adds a bunch of checks into your programs to catch memory access errors and warns you immediately when something wrong happened + gives you some useful info to track down the problems.
very useful while debugging
Frog Poster · 2022-09-28 11:28
Hey Lains, I wanna learn about API's
Any good resource to learn and practice using API's?
DEBUG-CONTENTS · 2022-10-02 09:39
>>32873
You want to first learn JSON. Then check the official API docs and then use either Curl or Python (https://automatetheboringstuff.com/2e/chapter16/) to get some data from the API. The best way to learn all this is to first make a JSON file and read/print it using Python and then make a Python script that makes a JSON file. Then use Python to fetch some data from an API (probably using "json" and "requests" modules that are part of Python stdlib). Find APIs using a search engine or a list like: https://github.com/public-apis/public-apis
But if you want to learn to design your own API, then that's another can of worms...
Tequila · 2022-10-03 12:14
What compile-to-C language do you recommend? with benign error propagation to boost my productivity, thx!
John Rain · 2022-10-03 12:23
Hey, so I'm learning to programme on my own, and I was wondering how does anyone really develop an "efficient" way of programming?, is it true that most computer science classes in universities/colleges teach a "it does the job" or "it gets stuff done" kind of mentality?, how can I avoid this type of thinking?, should I actually avoid it?
Drifter · 2022-10-03 12:45
>>32932
If you want high productivity, you should use a high-level language (Python, etc.). But if you want low-resource use and high performance, you should use something like C (read C Programming: A Modern Approach, 2nd Ed.) or C++ (read PPP2). But most of time the most important thing is to pick the correct algorithms and data-structures (also learn program architecture/how to structure your program). If you want to be actually competent programmer (and not some clueless code money), you should start learning algorithms and data-structures. Read either The Algorithm Design Manual or CLRS. Also check out https://www3.cs.stonybrook.edu/~skiena/373/videos/ + https://www.youtube.com/watch?v=A2bFN3MyNDA&list=PLOtl7M3yp-DX32N0fVIyvn7ipWKNGmwpp&index=1
But you need to first learn to program in some language.
>is it true that most computer science classes in universities/colleges teach a "it does the job" or "it gets stuff done" kind of mentality?,
Yes, because the industry needs more code monkeys.
Erik Johansson · 2022-10-03 13:04
>>32932
>is it true that most computer science classes in universities/colleges teach a "it does the job" or "it gets stuff done" kind of mentality?,
Consider that a college has many, many students to teach and need them all to pass to contribute to their field. It needs to do "the job".
>how can I avoid this type of thinking?,
By thinking for yourself.
>should I actually avoid it?
Depends on what you want to learn to do "the job".
over · 2022-10-03 14:11
>>32932
> is it true that most computer science classes in universities/colleges teach a "it does the job" or "it gets stuff done" kind of mentality?
It's more that each class doesn't want to focus on things other than what they want to teach you.
A network class might show you a chat program because they want to teach you how to use sockets. They don't care about teaching you software architecture in that class therefore they put all code in the main function since it's not like that program will ever need to change + it needs to fit in a single slide to show it in class.
You need to think by yourself and not simply memorize every line of code they show you in class.
> how can I avoid this type of thinking?
A good tip is to keep in mind that computers were made to save us from boring work. Basically every time you think "damn, this is going to be a lot of work" you do a google search instead.
----
Anyway since you're starting to program I would suggest you to stop caring about this stuff. Make software and you'll get a deeper understanding of what works and what doesn't, some things you really can't understand from just reading books
Cypher · 2022-10-03 14:56
>>32932
>Hey, so I'm learning to programme on my own, and I was wondering how does anyone really develop an "efficient" way of programming?
Can you clarify what you mean? Do you want code that executes quickly, executes with minimal memory resources, is quick to write, or is quick to read/update/maintain? Note that often times, these are conflicting goals.
Or do you mean it in a more abstract, problem solving sense, e.g you want to quickly be able to realize good solutions for problems?
>is it true that most computer science classes in universities/colleges teach a "it does the job" or "it gets stuff done" kind of mentality?
In my experience, computer science classes are more likely to try to impart upon the students a sense of code quality and "correct" ways of doing things, rather than "if it works, it works." However, other disciplines were very into the "if it works, it works" philosophy and consequently had horrible code. I saw that firsthand in my uni's mathematics and biology departments, but it's likely accurate for most departments other than computer science.
However, computer science curriculums usually start by teaching the fundamentals of a language and for a semester or two while you take general education courses, a class or two about the physical components of the computer, and maybe linear algebra. So as far as programming goes, a lot of first year computer science students aren't exposed to anything more than a basic understanding of one language. This is just enough for them to write terrible, awful, "it gets the job done" code. The next few years will include courses that focus on data structures, design patterns, software architecture, idioms, algorithmic analysis, secure coding, api design, best practices, code quality, etc.
>how can I avoid this type of thinking?
They don't beam thoughts into your head with a mind control device. If they teach you something that you disagree with, you talk to them about it in good faith, see where it goes, and either they'll make compelling points or they won't. In computer science, it's unlikely you'll ever have a hard disagreement with a professor on something like this just because the answer to virtually every subjective question in computer science is "it depends."
>should I actually avoid it?
It depends ;)
"It gets the job done" is fine for some problems, but not for others. Not every program needs to be perfect. Cue the classic example of the guy who audited code for an on-board missile guidance system and found that it had memory leaks and would crash if it ran long enough. He reported it and the architecture said, "we know, but the flights can't last long enough to reach that point, and missiles explode at the end of their flight, so we just let the explosion act as our garbage collection."
A more common scenario where something working inefficiently is good enough is whenever you're working on one part of a codebase that is impacted by a large bottleneck somewhere else. If you're using a public api to query some data set and you're rate limited to 1 request per second, it doesn't matter if your code to deserialize and process the responses takes 1ms or 999ms. So in that case, a simple "it gets the job done" approach that takes 10 minutes to write and finishes in 800ms is a better use of your time than a complex, highly optimized approach that finishes in 8ms but takes all day to write.
H.R. Giger · 2022-10-03 15:06
>>32938
Also it depends on where you are. My uni had a focus on writing code which I believe is common for America and Europe, but during grad school we had several international students from India and various African countries and they said their undergrad was primarily math and theory, not actually programming.
Lukasiewicz · 2022-10-03 15:35
>>32935
>>32933
>>32937
>>32940
Ok that's a lot of information, thanks. I think I'll just study to become a mathematician like I had planned because mathematics are my comfort zone, honestly, anything else makes my peanut brain hurt. I'll keep studying programming on my own to do geek stuff around Linux, albeit I'm a bit sick of computers, they're becoming more like cellphones, and cellphones stopped being useful a long time ago this coming from someone who barely has any knowledge of technology like me apart from basic stuff like how to use Excel and so on.
Trinity · 2022-10-03 16:18
>>32931
>>32933
>If you want high productivity, you should use a high-level language (Python, etc.).
But I want less dependencies and fast startup time. Python programs are quite slow to start and require installing an interpreter.
>C++
Hmm c++ exception is my last resort. Chasing the latest version of c++ and STL or compiling things like the boost library is tiresome.
>algorithms and data-structures
Before improving these two there are some "impure" functions which lead me to the very tedious error handling fuarrrking all over the program. I am working on hobby projects and I say: fuarrrk it let's play games! not gonna make any of them a big crufty code dump :((
Frog Poster · 2022-10-05 09:48
>>32906
Nah I just wanna learn how to use APIs
Spooky · 2022-10-08 02:59
sorry if this isn't the right place to ask, I can't find an old thread, it involved QR codes embedded within a color image with a diamond like patterning using anons own code to make them
I tried looking for the thread or even codes generated like that but no luck at all, there are some halftone ones, or QRs with an icon inside the square, but nothing like what im looking for.
anyone remember this? have the github for it? ecetera? i'd love to use this but im not smart enough to reinvent this wheel.
Frog Poster · 2022-10-08 17:33
Hey Guys , want your help.
I am thinking of creating 2 Projects.
1. A site for a China alternatives manufactured products, I wanna show alternatives from amazon and other e-commerce site.
2. An Online Library + Image Board for creating an online library for my books that I have stored. I wanna create this for storing Books as well as creating boards to talk about discussion of those topics.
⍕ · 2022-10-10 10:52
any easy books to read for beginners?
Armitage · 2022-10-10 18:07
>>32942
>Chasing the latest version of c++ and STL or compiling things like the boost library is tiresome.
There is no need to have the latest version of gcc. People who think they always need the latest STL additions are not programmers solving real problems, they are charlatans.
Yamaoto Toshi · 2022-10-11 01:19
I feel like I'm sniffing glue with my setup. Basically, I have a global struct called global with all important game data for all aspects of game loop, and if I want to get a frequently used namespace I do auto render = &gGlobal->render; .
For reference, this is what GLOBAL is defined as
struct GLOBAL{
struct render {
SDL_Renderer *render ;
TTF_Font *font ;
SDL_Texture* spritesheet ;
SDL_Window* window;
} render;
struct map { ;
MAP_TILE **MAP ;
int MAP_HEIGHT ;
int MAP_WIDTH ;
int TILE_WIDTH ;
int TILE_HEIGHT ;
} map;
struct entities {
Monster *mons ;
} entities;
struct player{
int hp ;
int x;
int y;
// For soem reason I cannot set this to be a union
// right now it doesn't matter
// but FIXME my autism wants this to be a union
struct{
pair dir;
int spell;
ACTION act;
} movement;
} player;
struct{
bool quit;
}other;
};
nil · 2022-10-11 07:31
>>33017
I prefer doing a struct of pointers to individual structs defined separately, it wouldn't be declared globally (only has to be declared before the game loop), and there would be init functions for each of those structs (called before the game loop).
Jens Hansen · 2022-10-11 16:44
>>33011
On what topic?
Try these:
>Little Schemer (use Chicken or Guile or Racket (in R5RS mode)
>https://greenteapress.com/wp/think-python-2e/
>https://linuxcommand.org/tlcl.php (Install Xubuntu or Linux Mint. You can test it using LiveUSB or VM)
Dr. X · 2022-10-11 17:11
>>31169
whats up guys im new here
Milner · 2022-10-15 17:08
>>33019
Kek, you're a lot smarter than me in structure. Thanks, now I feel like reading modern C or something else to improve my skills. My codebase is so soykaf despite being around 500 LOC, it would make Amazon's code look good
Jim Hilger · 2022-10-17 13:55
>>33066
With indie games it's more important your code just works (and ideally respects hardware limitations and algorithmic time & space complexities) than being some code perfectionist. If you're anything like me (ADD, lazy, time-anxious) I wouldn't waste your time reading books. Just continue coding. Figure out what works and what doesn't. Maybe check other people's source code for inspiration. I learned that common approach (struct of pointers to structs) as did others from commonly seeing it used in other people's source codes, not reading books or being "smart" (my IQ is only 106 according to mensa.org's online IQ challenge).
Delilah · 2022-10-17 17:55
>>33086
That's a good point. At work I had to do something similar to that: we had a private git repos and the only way to know how a library works is to look up a repo that uses it. I already kinda did that this morning when I was reading up on some allgero codebases, and thanks to you I might continue on.
Still I do enjoy reading, and I don't see why not. I don't believe in reading alone will make you a programmer (god I hate college for that), but it can at least be a way to get an overview of stuff. Looking forward to reading these books when I get the chance.
chadols · 2022-10-22 10:21
>>31169
What would I need to learn to implement media codecs? What math do I need to learn?
Torvalds · 2022-10-23 06:35
A friend challenged me to build a program that creates Discord accounts and joins them to a server. Problem is I don't know how to work with websites or anything online at all. What skills are needed to create a such a program?
Joe Bloggs · 2022-10-23 13:11
>>33120
There are many ways to interact with services:
* The dumb way: you write a program that literally moves the mouse and clicks on a browser to do whatever needs to be done. It's super prone to errors, it will break at the slightest of changes in the page layout, it's slow and it doesn't really scale but it's easy to do and it might be enough for you
* Via a public API: often services offer a way to some operations through an easy to program interface, usually by doing web requests to certain URLs. An an example, a chat service could have an API where if you want your account to send a message to someone else then you send an HTTP GET request to "somechatservice.com/api/sendMessage?message=<message>&chat=<id-of-the-recipient>&apiToken=<secret-token-they-give-you-after-registering>".
Services usually have some documentation pages with the list of supported operations and how to use them. Discord does have an API but they do not allow you to create an account through that since it would only be used by spammers so that doesn't apply here
* Via a secret API: often services might still have an API because they are an easy way to connect separated services, but they might not say it publically. You can try searching for them by doing some normal user stuff on their services while monitoring the network requests and seeing if something that looks like it comes up. No documentation here, you'll need to reverse engineer by looking at the data that gets sent and received
* By imitating the behavior of the browser: you open up your browser and do what you want to automate while recording all network requests. Then you write a program that repeats those requests, changing what data needs to be sent or received. It's similar to the previous method
Ofc in practice it's never as easy as I wrote: Discord has for sure implemented methods to prevent people from generating accounts automatically which you'll need to bypass.
Kay · 2022-10-23 14:40
Any tips on using keyboard hooks on windows? Wanna make an auto mapper, to make playing DOS RPGs like Wizardry 6 or Might and Magic easier.
Liet Kynes · 2022-10-25 18:59
I'm trying to use elemental/index buffers and for some reason they're not showing up. I suspect it's because I'm using ImGUI or I'm not setting some flag up properly: if anyone can point out the mistake I would appreciate. https://pastebin.com/PkxF1r4Y
limited · 2022-10-26 13:10
Is COBOL a meme? All I ever hear about it is some cliche bullshit. I have asked around internet but haven't really got any reasonable answers; does anyone here happen to really know anything about it? My main concerns, of course, are
a) how difficult it is to grasp compared to some popular languages
b) is there really need for that skill in real world
I do NOT wish to provocate or ask for those same old memes about it but really wonder how that is. This is my last resort on this topic before I will have to contact some university or something.
Donna Hawthorne · 2022-10-26 13:24
>>33157
>b) is there really need for that skill in real world
I keep reading that yes, there is a need for it since many banks and whatnot still use old COBOL code. However, I have not ever seen any job for COBOL programmer here(third world country), so maybe it depends heavily on what country you live.
Special Agent Bob · 2022-10-27 05:44
>>33158
revealed vs expressed preference. they talk about it because talk is free, and experienced engineers are not.
Cereal Killer · 2022-10-27 06:46
>>33167
Who are these "they" you are talking about?
Nanashi No Gombe · 2022-10-27 06:55
>>33168
COBOL job ad-writers, but also the Zionists
Aristóteles Amadópulus · 2022-10-27 09:47
>>33168
Were you unable to pick up the context of what "they" is? I find a lot of people seem to ask "Who are these 'they'?" as if it were some anti-semitic "gotcha!" but when reading what is said, you can easily discern who "they" is representing.
Molly Millions · 2022-10-27 12:56
Which is lisp/scheme more popular than haskell among imageboard users?
Unknown · 2022-10-27 23:23
>>33180
Both groups are so minuscule it's hard to tell
Netrunner · 2022-10-28 06:57
>>33184
I meant to write "why" not "which". I think it's obvious a lot more people that use image boards have a hard on for lisp.
There's 56 matches on "lisp" on the catalog here, but only 4 matches on "haskell".
Boole · 2022-10-28 11:12
>>32668
This would be a piecewise function, but we already know that. Common Lisp has something similar with CLOS and its BEFORE, AFTER, AROUND, and EQL methods.
>>33187
The Lisp General was transplanted here early on, which may have something to do with this.
Nell · 2022-10-28 14:22
I am attracted to programming because I don't want to be left behind, I know some basic concepts, but I don't have any real knowledge of any programming language mainly because I don't really have any project so that discourages me, I'm considering to learn lisp, C or Haskell, mainly because those seem to be the purest forms of programming(?), I want to learn lisp or haskell personally to be honest, although I have heard that they are barely used, C seems to be the best option, but I am undecesive, I was learning python but all the stuff around python out there is about memorizing soykaf instead of teaching you how to develop problem solving skills, meanwhile C and Lisp communities tend to actually praise the idea of developing problem solving skills over just brute memorization, I don't think that I will even get into machine learning or something similar at this point, because the industry seems to value the 4000 Indians that "get stuff done" rather than people that actually have the skills, even if I just go for medicine or engineering instead of computer science, I will have to face programming anyways, but again it will be more about just getting stuff done, which frustrates me, it's a bit disturbing that things have turned out this way, at least from what I've heard from actual programmers.
Tank · 2022-10-28 17:23
>>33190
>I'm considering to learn lisp, C or Haskell, mainly because those seem to be the purest forms of programming(?)
Sans Lisp in that list, no. Now, I can't really comment on Haskell, but there's absolutely nothing nice and pure about the C language. I've grown to believe beginners should perhaps learn a language such as APL, which exposes fundamental aspects of programming, but in a very different way, and with little drudgery.
>I want to learn lisp or haskell personally to be honest, although I have heard that they are barely used, C seems to be the best option, but I am undecesive
Take a look at these C language constructs:
http://www.lysator.liu.se/c/duffs-device.html
http://pigeonsnest.co.uk/stuff/pigeons-device.html
Notice how these are obviously grotesque, and yet the language permits them, due to its lack of forethought in design. Few C language programmers are aware of this nonsense, because they wrongfully believe the language to be simple; it's anything but simple. I'm aware of no other language with such inane constructs, except perhaps the C++ language, but that almost goes without mention. Rest assured that Lisp doesn't allow such queer things, because they don't make sense.
>I was learning python but all the stuff around python out there is about memorizing soykaf instead of teaching you how to develop problem solving skills
The C language is the same way, but with a cult of idiots who believe themselves to be wizards arguing otherwise.
>meanwhile C and Lisp communities tend to actually praise the idea of developing problem solving skills over just brute memorization
Lisp allows for the automation of programming itself, whereas the C language has nothing comparable. Should all things be automated, or is programming somehow special in this respect?
>I don't think that I will even get into machine learning or something similar at this point
Bother not with neural network nonsense, in any case.
Now, I offer links to further reading, but only if asked.
John Rain · 2022-10-28 17:49
>>33193
>Now, I offer links to further reading, but only if asked.
please do so
Moore · 2022-10-28 18:18
>>33194
Here are select articles:
http://verisimilitudes.net/2019-07-15
http://verisimilitudes.net/2020-09-24
http://verisimilitudes.net/2021-05-05
https://www.xach.com/naggum/articles/19940821.4497@naggum.no.html
https://www.xach.com/naggum/articles/3065048088243385@naggum.no.html
https://www.xach.com/naggum/articles/3163193555464012@naggum.no.html
http://www.loper-os.org/?p=55
http://www.loper-os.org/?p=401
http://www.loper-os.org/?p=4012
http://www.niquette.com/paul/issue/softwr02.htm
Project 2501 · 2022-10-28 20:38
>>33193
>Sans Lisp in that list, no. Now, I can't really comment on Haskell
Another example of >>33187
>beginners should perhaps learn a language such as APL
The are only 2 reasons to learn a language besides curiosity: it's very good in a particular area, it's popular. Which one does APL fall into? People use C. C is everywhere. Everything that relies on Vulkan or OpenGL, relies on C. That is why people learn it. A beginner will benefit most from learning something that's relevant to the real world. That is the best way for them to quickly connect their other interests with programming.
Jim Hilger · 2022-10-28 20:58
>>33196
>Which one does APL fall into?
APL is in the former group.
>People use C.
People use most any language. I use APL.
>C is everywhere.
Yes, the C language is on every computer, except for those on which it isn't. What a useless observation.
>That is the best way for them to quickly connect their other interests with programming.
If he wants to learn nothing other than how to glue together gargantuan and constantly-broken libraries, then sure. If he wants to learn knowledge over anti-knowledge, he should follow the advice I've given.
Have another link, and its contents:
https://www.wisdomandwonder.com/link/2110/why-mit-switched-from-scheme-to-python
>Costanza asked Sussman why MIT had switched away from Scheme for their introductory programming course, 6.001. This was a gem. He said that the reason that happened was because engineering in 1980 was not what it was in the mid-90s or in 2000. In 1980, good programmers spent a lot of time thinking, and then produced spare code that they thought should work. Code ran close to the metal, even Scheme — it was understandable all the way down. Like a resistor, where you could read the bands and know the power rating and the tolerance and the resistance and V=IR and that’s all there was to know. 6.001 had been conceived to teach engineers how to take small parts that they understood entirely and use simple techniques to compose them into larger things that do what you want.
>But programming now isn’t so much like that, said Sussman. Nowadays you muck around with incomprehensible or nonexistent man pages for software you don’t know who wrote. You have to do basic science on your libraries to see how they work, trying out different inputs and seeing how the code reacts. This is a fundamentally different job, and it needed a different course.
>So the good thing about the new 6.001 was that it was robot-centered — you had to program a little robot to move around. And robots are not like resistors, behaving according to ideal functions. Wheels slip, the environment changes, etc — you have to build in robustness to the system, in a different way than the one SICP discusses.
>And why Python, then? Well, said Sussman, it probably just had a library already implemented for the robotics interface, that was all.
Morpheus · 2022-10-28 23:43
>>33187
No, it's not obvious. Just because there is a thread about lisp on most chans does not yet mean majority of imageboards do Lisp.
array · 2022-10-28 23:50
>>33197
>People use most any language. I use APL.
You are a minority among minorities, who wants to drag naive people into the same marginal position. You like to tinker with academic languages instead of making anything useful or interesting to people outside of that circle.
>If he wants to learn knowledge
Knowledge is only as useful as its applications. Programming is a means to an end.
>>33198
>does not yet mean majority of imageboards do Lisp
I'm comparing it to Haskell, and I'm basing that comparison on observation.
pop · 2022-10-29 00:37
>>33199
>You are a minority among minorities, who wants to drag naive people into the same marginal position.
Sure, but my position is also the right position.
>You like to tinker with academic languages instead of making anything useful or interesting to people outside of that circle.
Are we describing me or the C language programmers who constantly reimplement unimpressive software but minimally? Eventually, my position wraps around to more practical. I also know Ada, a military language for military systems, and the only reason they allow the C and C++ languages in military systems is either because of legacy or the lowering of standards.
>Programming is a means to an end.
We agree, which is why he shouldn't learn the C language. It's hard to imagine a greater waste of time that people defend. People recognize using Brainfuck is stupid, but defend using the C language, a language which has hundreds of bizarre errors and failure cases, and a language in which absolutely no one can write correct software, including the so-called professionals who waste decades of their lives with it.
Lukasiewicz · 2022-10-29 09:56
>>33200
>the right position
It's not a position that pays. And it's not a position for people who don't want to get "left behind". Boxing yourself into the academic bubble from the very start is exactly that, getting left behind.
>who constantly reimplement unimpressive software but minimally
It does not matter if you deem it "unimpressive". It's useful. Things I use on a daily basis were either made with c/c++, or made with tools, that were made with c/c++.
Earlier you mentioned "obviously grotesque" language constructs that "few C language programmers are aware of ". If they're not aware of them, they're not real problems. It's only a glaring flaw when your top priority is an autistic fixation on "correctness". OpenGL, and Vulkan, and the Linux kernel, and decades worth of libraries, are not going to get thrown out for stupid soykaf like that.
>a language which has hundreds of bizarre errors and failure cases
It accomplishes its task with sufficient efficiency. Just like deep learning, which you also think isn't "worth bothering with". Nothing useful has been made with Brainfuck because it is an incredibly unproductive language. A language can be flawed and productive, the latter being more important when deciding what to use.
Chani · 2022-10-29 10:09
>>33190
>>33196
C or C++ are bad as your first language. I think a high level programming language that provides a REPL and immediate feedback is the best kind of language for a beginner. I recommend Ruby, if you want a compromise but otherwise I think Scheme (R5RS) is a good start (read Little Schemer and Seasoned Schemer). Lua is another good choice because it's so simple (like R5RS). The problem with Lua is that the REPL is like kicking dead whales down the beach (much like the Python REPL). But it's "usable" (or just ok) if you use Emacs to access it. There are some other languages that aren't good first languages but partially for different reasons. I'm talking about JS, PHP, C# and Java. C# and Java teach you OOP which confuses the beginner and they do it in a poor style (when compared to Smalltalk, Ruby, Common Lisp or Racket). I recommend the Pharo MOOC for learning basics of OOP. JS and PHP allow you to make stupid mistakes that are very hard to find (I don't know how to articulate it but do not start with these pls).
Those who say that you should learn C or C++ as your first language often say that it teaches you how a computer works, but in reality C teaches you how UNIX (and thus GNU/Linux and the various *BSD) works. If you want to learn how a computer really works, you need to learn assembly language. And there is a good and free book that teaches you it: https://download.savannah.gnu.org/releases/pgubook/ (it starts from zero). For learning Lua, I recommend Programming In Lua book (the 1st edition is freely available online). For Ruby, there is the famous "Pickaxe Book". For Smalltalk, I recommend downloading a copy of the Blue Book (https://wiki.squeak.org/squeak/64) and working through the Pharo MOOC.
Cereal Killer · 2022-10-29 10:10
>>33199
>Knowledge is only as useful as its applications
False. You probably never heard about pure mathematics.
typedef · 2022-10-29 11:00
>>33202
>It's not a position that pays.
It can, but who cares?
>Boxing yourself into the academic bubble from the very start is exactly that, getting left behind.
I wouldn't even call it an academic bubble.
>It does not matter if you deem it "unimpressive".
That goes both ways.
>If they're not aware of them, they're not real problems.
That's a laughable position.
>It's only a glaring flaw when your top priority is an autistic fixation on "correctness".
Incorrect software is worthless or nearly worthless. Notice most software is worthless.
>OpenGL, and Vulkan, and the Linux kernel, and decades worth of libraries, are not going to get thrown out for stupid soykaf like that.
They will, it will simply take time.
Have the last word.
HELIOS · 2022-10-29 14:06
>>33203
I'd recommend GO because it's a very balanced, simple language, while also having a large ecosystem. Most basic concepts are there, it's similar to other languages that people actually care about and use in the real world, it importantly has typing and it's compiled. Best of all, it's repellent for autists like >>33205
Morpheus · 2022-10-29 16:32
>>33206
>Go
As an outsider, Go does seem pretty good but when you look closer, it seems that there are some cut corners. Example: generics weren't part of the language for a long time. And Go still doesn't have proper iterators (https://github.com/golang/go/discussions/56413) and there isn't function overloading (plus there aren't enums for whatever reason). Also, I feel that the creators of Go had second system syndrome because they changed the way function signatures are written for no reason at all. Anyways, I head that the https://go.dev/tour/welcome/1 and https://gobyexample.com and https://quii.gitbook.io/learn-go-with-tests/ are pretty good places to start. There are like 3 threads about Go in the catalog and I suggest you check out those as well. But I don't think that Go has a REPL (which is a shame).
Moore · 2022-10-29 18:38
>>33207
I started with gobyexample, then immediately jumped into projects.
>I don't think that Go has a REPL (which is a shame)
Yeah, in place of that, I've used the "go playground" https://go.dev/play/
Project 2501 · 2022-10-30 06:33
>>33206
Can a beginner use gcc-go? I don't like Google very much.
Yuki Nagato · 2022-10-30 06:48
>>33211
>Can a beginner use gcc-go?
Sure, using gcc-go is as simple as "go build -compiler gccgo".
If you figure out how to set it up without installing the standard go release, also sure. The compiler shouldn't matter and Go's behavior is intentionally not implementation specific.
Jet Black · 2022-10-30 22:30
I'm learning scheme, but I wonder what are some good books for learning common lisp?, I find it weird how most modern programming languages confuse me, scheme is making a lot of sense, but I wanna be able to do stuff on common lisp since is an industry standard
Leto Atreides I · 2022-10-31 00:52
>>33220
If you have background in calculus, look no further than
>Structure and Interpretation of Computer Programs
tho you might get bored trough most of that book as it is written for people who lived back in the 70s/80s and never before programmed anything in their lives
Nobody special · 2022-10-31 01:00
>>33203
my 1st prog lang was basic, 2nd was Pascal 3rd was C++ (tho very basic) and C was my 4th. I barelly see any reason to program in anything else than in C unless it's some scripting in shell or Perl.
>inb4 but muh memory management and pointers safety
GTFO
Motoko Kusanagi · 2022-10-31 02:20
>>33169
>>33173
I wasn't expecting to be greeted with such brianlets on this board but looks like I was too optimistic once again. Well, one thing has become very clear to me during these couple of weeks; nobody really seems to know or care about COBOL. Well whatever, JS is good enough for my clients and my income is good enough for me, fuarrrk COBOL.
Iverson · 2022-10-31 11:25
>>33222
>I barelly see any reason to program in anything else
I guess Paul Graham was right, pic related.
Lukasiewicz · 2022-10-31 12:42
>>33220
>good books for learning common lisp?,
https://gigamonkeys.com/book/
I recommend you use SBCL and Emacs+SLY+rainbow-delimiters
Some other CL books that are great:
>https://lispcookbook.github.io/cl-cookbook/
>Common Lisp recipes: http://weitz.de/cl-recipes/
>https://github.com/norvig/paip-lisp
>http://www.paulgraham.com/onlisp.html
Visit the Lisp thread for more! >>31415
progn · 2022-11-01 05:02
>>33230
He was, but not in the way you think.
Motoko Kusanagi · 2022-11-01 06:06
In web development we usually have a backend frontend structure, where the backend processes and stores information and the frontend displays it.
How does it work for desktop applications? I'm trying to automatize parts of my life and so far i'm doing it via a CLI application, but at some point i'd like to have a GUI in front of it. How do people usually go about doing that on linux?
Linda Lee · 2022-11-01 06:27
>>33237
Frotend/backend is just set of artificial abstractions many of which get popular just because they were "hot new thing adopted by famous company".
As for CLI and GUI aplications you just separate logic and interfaces. Some applications has them implemented as part of program. Other are CLI apps only and there were written GUI apps that are talking with CLI app translating user input for GUI program to commands and signals and whatever "protocol" CLI apps are using and send/pipe them to CLI programs.
Fred Nurk · 2022-11-01 07:01
>>33238
>Frotend/backend is just set of artificial abstractions many of which get popular just because they were "hot new thing adopted by famous company".
I disagree. If i have a bash script that interacts with a database and listens on a port and public IP, i can treat that as a backend, while a js script on the client is responsible for dealing with the interaction on his side. This is an objective distinction between them. One does not depend on the other, and both are necessary for a successful request.
>As for CLI and GUI aplications you just separate logic and interfaces. Some applications has them implemented as part of program. Other are CLI apps only and there were written GUI apps that are talking with CLI app translating user input for GUI program to commands and signals and whatever "protocol" CLI apps are using and send/pipe them to CLI programs.
Yeah that's what i wanted to read something on. Do you have any books, posts or searchable keywords for the different implementations of this structure? Currently my cli application only answers to direct calls on the executable. What other protocols are there?
Boris Grishenko · 2022-11-02 00:41
>>33240
>I disagree.
That grass is green?
>Do you have any books, posts or searchable keywords for the different implementations of this structure?
Yes. https://sourceforge.net or https://github.com look for GNUchess + xboard and gvim.
> What other protocols are there?
Any you can imagine. And few more above of that. Welcome to the world of hackers, where no one gives a fuarrrk about mindset of corporate code monkeys that are unable to implement stuff unless they read "9001 design patterns" by Gangbang of 69
If you want to dive deeper with more commonly known see ESR's "The Art of Unix Programming" http://www.catb.org/~esr/writings/taoup/html/
Just try to conceptualize hwo would you write a GUI for:
ed
bc
also look into Bourne shell's pipes as they are useful for plumbing together stuff. Also writing vim and emacs plugins.
Hacker · 2022-11-02 03:46
>>33245
>That grass is green?
I'm not sure what you mean. Front end and back end are simple definitions that have no correlation with whatever is popular at the moment or what companies are adopting.
>Any you can imagine. And few more above of that. Welcome to the world of hackers, where no one gives a fuarrrk about mindset of corporate code monkeys that are unable to implement stuff unless they read "9001 design patterns" by Gangbang of 69
I'm unsure whether you think i'm new to this or if i work for microsoft, but i'm not and i don't. I'm just looking for very simple information, thus the beginner's thread.
I'll look into it later today, since it seems i wasn't able to more clearly communicate what i'm trying to find. Thanks for the help though.
vector · 2022-11-02 06:30
Before anything, I need say "thank you" to the administrator, moderators, and lainanons, to help people like me stay alive.
I need be a programmer to stay safe, stay alive and survive, because I live in a really bad place and people started hunt down. I know a little bit of C and Common Lisp, but I need learn enough about computer networks so they don't invade my home and arrest me like it's happening around the country.
I have ten hours a day to study during the next five months,
and I'm already pretty comfortable around with some Linux distributions.
I also need know if I need first learn HTML, CSS and Javascript this months and dig deep into level stuff like C, Assembly or some other low level language.
I don't have time to waste. I need hurry before they come for me.
Thank you.
Aristóteles Amadópulus · 2022-11-02 06:34
>>33249
If your goal is to stay alive against some network threats nothing can beat C and Python. HTML, CSS, and JS will get you a job, but C and Python will make you a very good developer overall. Common Lisp is good too if you don't want to learn Python.
Gyula Kovacs · 2022-11-02 06:34
>>33249
lmao are you bin laden? also, look into harvard's cs50, it's a great and free introduction to computer science. It should give you the basis to dig deeper into networks and whatever else you might need.
As for networks specifically, can't go wrong with "computer networks" from tannenbaum, whatever edition is the most recent.
>I also need know if I need first learn HTML, CSS and Javascript this months and dig deep into level stuff like C, Assembly or some other low level language.
CS50 should teach you all that, but to give more specific advice we'd need to know your exact needs/a better idea of how you want to apply that knowledge. For example, if you want to avoid authorities you don't really need to study academic stuff at all. Just go on /sec/ and read about anonimity.
Academic knowledge is more broad and will not help you to hide from whoever you need hiding from in 6 months.
over · 2022-11-02 07:03
>>33250
I will go for C and Python. Thank you. Should I read Tannenbaum to learn about computer networks? I'm worried about the Calculus ( that is college math where I live), but I have time to learn it.
>>33251
I'm just a political dissident that want freedom for my people, but since I'm not healthy enough to join the fight, I'm doing other things.
Emmanuel · 2022-11-02 07:09
>>33253
You'll want to get more practical experience. I would read K&R, then learn python, then move you can use both C and Python to learn networking.
Tyrell Wellick · 2022-11-02 07:41
>>33254
Thank you. I feel I made the right choice coming to the imageboard. I hope live enough to be safe someday.
null · 2022-11-02 07:59
>>33254
Which book is good do learn Python?
>>33251
I need learn how make my own tools, be a someone that understands how computer and computers work so I can keep myself safe.
See myself as a civilian drafted to fight a war, I civilian that need learn everything he can next 60 days because he will go to the front in January, and need survive until July or August, when he will extracted to a safer position out of the front.
sizeof · 2022-11-02 08:10
>>33257
Python crash course is a very good one.
Kay · 2022-11-02 08:59
>>33257
>I need learn how make my own tools, be a someone that understands how computer and computers work so I can keep myself safe.
Look i'm no fan of larping, but if your question is "can i learn computer science well enough to make security tools from scratch in 6 months?" the answer is no. You'd be better off using this time to understand and make intelligent use of existing tools.
Yu-ichi · 2022-11-02 11:48
>>33259
Sorry. Make my own tools is a long term goal. I want do what you said.
Nameless · 2022-11-02 15:28
>>33254
>I would read K&R
I'd recommend "Effective C An introduction to professional C" instead for all the reasons given here >>29666
Koichiro · 2022-11-06 03:33
Is LLVM/Clang a better compiler than GCC? Its an option on Gentoo, and I would like to know if there are any advantages before I spend 8 hours trying it.
Otto Normalverbraucher · 2022-11-06 06:39
What is the name of the machine learning technique for adding natural-looking cats to photos in the random places?
protected · 2022-11-11 13:23
>>31686
>Official man pages! No pydoc or cppreference garbage, here you almost have C degree of exhaustivity
Given that we have hyperlink, it's weird how people can still praise man pages. The unix fanboys is probably the reason we never get good stuff.
藤原純一 · 2022-11-11 13:55
>>33317
That's one reason to use man or woman in Emacs. It's not surprising that Emacs would clean up after UNIX idiocy in this way.
Judge Fang · 2022-11-11 15:25
>>33318
Which is sad that you need another software for something that should not even be used anymore.
Liet Kynes · 2022-11-12 11:16
>>33291
depends which one of them you have in mind
Y.T · 2022-11-14 06:39
>>33287
>Is LLVM/Clang a better compiler than GCC?
No.
GCC and Clang are pretty much as good. It's a good think that there are 2 good libre C/C++ compilers. Some companies and *BSD folk probably prefer Clang because of its license. I think in the past Clang had better warnings/diagnostic messages but I think this is not the case anymore. Clang also has better (official) support for Windows but you can always use MinGW (but IIRC, Clang is supported by VisualStudio if you use it). Also, I heard that LLVM is more modular than GCC (which should make it easier to add support for a new language).
Jens Hansen · 2022-11-14 07:37
>>31535
To be honest. If you want to be an entrepreneur, the more niche the language the better experience you'll have. Most people that learn niche languages and stick to them are 10-50x better than the average soykaf Java, C#, or Python developer, plus they'll never leave since you'll be the only place to get a job, lol.
Arisu Mizuki · 2022-11-14 09:27
>>31535
No one uses SML, too. Doesn't stop me to have fun using it. If I want to get a job, JS is the only option in my country, anyway.
Motoko Kusanagi · 2022-11-14 09:42
>>33362
I wish ML took off more. It would solve a lot of the major problems in the industry.
Tank · 2022-11-14 09:44
>>33363
Same here. I tried to like Haskell and OCaml but didn't have as much fun as SML, sadly.
Faye Valentine · 2022-11-14 10:12
I want an OS like the Navi. PLease help me becum lain
Lukasiewicz · 2022-11-14 10:39
>>33365
Sorry, mate, last I checked most of the people who are good and can make an OS waste their time making another Unix clone no one will ever use.
It's sad they are not trying some cool experimental soykaf.
Tyrell Wellick · 2022-11-14 16:59
>>33364
I like SML, but I think OCaml is a little more practical since it has more libraries. So I mostly write OCaml now. But if SML had a few good web frameworks I would write it more.
renames · 2022-11-15 09:47
I'd like to learn a bit of C, I'm not looking to become a proficient C programmer, but I'd like to be able to read it and make small programs or just make some changes to existing code.
What are some good resources? I'm not completely new but I'd like the resources to go pretty straight to the basics/syntax and how to use them.
Thanks in advance.
H.R. Giger · 2022-11-15 14:20
>>33381
See >>33261
Read also Deep C Secrets chapters 3 & 4 to understand pointers. Should be able to find these on libgen.lc. Then read http://www.catb.org/esr/structure-packing/ and check out https://www.kernel.org/doc/html/v4.10/process/coding-style.html
cdr · 2022-11-17 15:08
>>33365
The closest you can become to being Lain is by using PonyOS. https://ponyos.org
Warning: leet h4ckers only!
Zhora · 2022-11-19 15:43
>>33399
it still exists? lol lmao rotfl
J.C. Denton · 2022-11-24 02:06
I'm making a simple text editor for terminals. The structure I'm using to store the characters is a doubly linked list.
The issue is that whenever the user types a single character, the program calls malloc to store a new element into the structure. I wonder if this approach is correct, since the program would end up making a ton of calls.
fsociety · 2022-11-24 11:01
>>33461
If you want to keep the linked list structure but minimize malloc calls, you could malloc a buffer large enough for multiple list nodes and fill it until it's empty and then allocate a new buffer.
You could also use a linked list of null terminated character arrays instead of individual characters. I'm assuming you chose a doubly linked list so you can easily insert characters without shifting huge arrays, and this would allow this while also reducing your memory requirements and letting you periodically flatten everything.
For a simple editor you could probably get away with each line being a string and having a doubly linked list of lines instead of characters too.
Can you provide more details about your editor? The features that you want will influence how you can approach it.
Hong, Guil Dong · 2022-11-24 11:39
>>33461
Yeah, it's pretty bad.
I imagine you chose the linked list version because you wanted to edit text in the middle without moving a lot of data around?
I like what >>33464 proposed, the one where you still have a linked list but each element represents a line.
Other than that, this is also a different but fun way of handling insertions in the middle of text efficiently: https://stackoverflow.com/a/4200549/5274227
I'm sure there are better data structures for this problem but that only gets relevant if you want to handle opening huge files.
Anamika · 2022-11-25 04:50
>>33464
I ended up implementing your idea of a buffer since it solved my primary concern, even putting aside the performance benefits it's a lot easier to free the memory.
>Can you provide more details about your editor? The features that you want will influence how you can approach it.
I want to make a bare-bones clone of nano. The essential features I want to add are: moving the cursor around, commands such as cut/copy/paste, display a status bar with information regarding the file being processed (directory, columns, length...).
Not sure if a doubly linked list is the best approach for this, but as >>33465 said, it seems like the simplest way to insert and delete characters.
One thing that I would also like to eventually add is the capability to run scripts from inside the editor. I want to let the user link an action, (such as saving the file or copying a block of text), to a script, and then make the editor automatically run it after the action is performed.
I don't know how useful it could be, but it's a feature I've never seen implemented.
>>33465
>the one where you still have a linked list but each element represents a line
Could you describe at a very high level how it could be implemented? I'm not quite sure how I would go about it.
Spooky · 2022-11-27 01:13
>>33466
>I don't know how useful it could be, but it's a feature I've never seen implemented.
https://www.gnu.org/software/emacs/manual/html_node/emacs/Shell.html
Neo · 2022-11-27 02:59
>>33466
I was thinking of something like this:
struct Line {
size_t allocated, used;
char *data;
struct Line *next, *prev;
}
struct Document {
struct Line *lines;
}
Adding a character to a line might require to move all the characters to the right of the cursor to make space for it, but a line shouldn't have much data so it's cheap.
With this solution you'd probably also want to keep a pointer to the line where the cursor is currently on, so you don't need to traverse the list each time you type a char.
But now that I think of it, if you want each list node to be exactly a line you also need to be careful because when you press ENTER then you split a line into 2 lines. I don't think it's hard to implement but there might be other edge cases I'm not thinking about right now.
Anyway I have this link in my reading list, I can't vouch for it as I only skimmed it but it might interest you: https://viewsourcecode.org/snaptoken/kilo/
Milner · 2022-11-28 15:22
How do you guys deal with the problem between "I need to learn more" and "I should be doing things based on things I've learn"?
A simple example of this is how I feel like I should study more programming-related stuff and end up spending my day studying more than making programs.
over · 2022-11-29 06:14
>>33510
Once you have learned the basics, you should start some small project. If you hit a situation where you don't know how to do $something, you should then switch to studying the relevant topic. Once you have learned enough to do $something, you should continue writing your program. And repeat this cycle until your program is done. I recommend that you document everything. I recommend you put comments to your code and (possibly) write additional markdown/org-mode notes (I think keeping a journal/blog or writing a changelog/news file is also good for keeping yourself motivated). If it's your hobby project or something you wrote because you wanted to learn something, you should write a lot of comments (even if they explain stuff that might be "easy" for professional/experienced programmers!).
Debbie Charteris · 2022-11-30 10:26
I know some programming languages and I know quite well about data structures, yet how come whatever project I think my mind from "it's so hard to I have no idea what to do" even though I know what the end result is supposed to look like. It's like I have a mental barrier and I don't know how to stop it. I learn programming because I knew what I wanted to make, yet I never make anything because I feel like even the most simple thing I want to make is hard[which is why I can't find any like this made by other programmers].
Stallman · 2022-11-30 11:42
>>33525
What do you want to make?
SpectreAlpha · 2022-11-30 12:25
I can so relate to that. Tech is complex and every project requires learning more. The learning never ends. It's always trial by fire. I work in architecture and it requires some programming but usually higher level design. I am a total hack. I just fake it. Lately I am trying to reproduce a similar OS structure to Qubes on my personal PC because Qubes refuses to recognize VT-d on my system even though it is definitely there. So I am using a combination of a barebones SELinux Fedora install as a hypervisor and VMs with containers for apps. Fun stuff.
Bobby Newmark · 2022-12-01 08:48
>>31169
hello, Anon. I have a test task for company. they gave me elf file and said that I need it to execute. I made some research and know that is just small cli program, that output some string. but readelf says that is DYN (Position-Independent Executable file). in ldd everything okay. what to I need to do? how can I execute shared library?
sorry for english, I'm not native
Nobody important · 2022-12-04 02:08
>>31681
Computers literally control the entier planet. Not teaching yourself how these machines function is a grave injustice against yourself and basically turns you into a slave at the whim of whatever algorithms or robotics happen to be part of your life and any given moment in time. Nothing could be further from the truth.
Colmerauer · 2022-12-04 21:18
How much C do you need to modify Liferea? I want to get full articles for feeds that only provide the headline and to automatically download YouTube videos. Only knowledge of the language is enough to complete this years Advent of Code.
Ishikura "Tatsu" Tatsuhiko · 2022-12-10 07:28
>>33617
would be far easier to scrape with python
Ainon · 2022-12-10 14:51
Lainons I need your help, want to get better at programming, I want to finally understand Assembly C++ and Phyton, can I get some help from u ?
Incognito · 2022-12-10 15:12
>>33714
First part of your question is how to get good at some field.
The second part of your question is how to get good at some tools of that field.
Knowing all about C++ doesn't mean you know how to program just like how knowing how to use a hammer doesn't make you a carpenter.
Neo · 2022-12-11 01:09
Practice, apply effort, and find small doable, concrete projects that interest you, figure out how to break them down into sub-tasks, and whittle away at them.
Solve gradually more complex problems on your own without just pulling in some library to do it for you if you can. Study other people's solutions to similar problems and try and understand why they did it the way the did.
If you can at some point get involved with a project, do it, engaging in social programming and collaborative problem solving are essential skills for any programmer.
Be humble, don't get full of yourself, and don't get hung up on failure, just learn lessons from it, maybe journal about your mistakes and how you got around them, and look back a year on to see how you've progressed, because everyone who's smarter than you started out just as dumb or dumber.
There aren't shortcuts. Effort and practice.
It might feel like a waste of time if you don't get something immediately. This is normal, push through and you'll be rewarded in time - recognize your avoidance behaviors when things get hard "I feel tired", "This is dumb", "That's too complicated", "I'm stupid".
You are refining yourself, every ounce of work you put into this will pay off eventually, whether you decide to be a professional programmer or not.
Fred Nurk · 2022-12-11 05:19
>>33714
Assembly, C++ and Python are languages that satisfy different needs and manage different tasks. If you want to get better at programming you need to decide what problems you want to solve and focus on them.
For example, if maths/physics/engineering interest you then focus on Python and some major libraries that it provides like numpy and matplotlib. Make the computer do the tedius and time-consuming calculations for you and create a graph to have a visual interpretation of your results, if it helps you understand things better.
If you are more interested in making videogames, choose a simple premade engine like Godot that manages most boring stuff and let yourself focus on the behaviour of your game objects. Godot has its own scripting language that I've heard resembles Python. Commercial games require heavy optimization that's why they are written in c++ or c#. This doesn't mean necessarily that slower languages are worse. Some simple games will run in a reasonable speed regardless of the language they are written in.
If you want to make a website don't use any of the languages you have described and instead focus on tools like html, css and javascript.
Assembly is way too low level. It provides the most power and control since you are talking directly to the hardware but you cannot think in terms of your problem that you need to solve but on terms that only the current processor can execute. It is useful for some operating system interfaces or compilers but beyond those domains there's not much advantage.
Unsigned · 2022-12-11 07:53
>>33714
>Python, Assembly, C++
That's a pretty big spread. I would recommend picking one and digging deep. Personally I would recommend C++, then use that to build stuff. Eventually you might find you want to integrate a scripting language into one of your C++ projects so you learn Python to fill that niche. Then one day, you may want to do more low level things with your C++ code so you learn Assembly to allow you to do that.
cond · 2022-12-12 05:57
>>33714
>Lainons I need your help, want to get better at programming
>I want to finally understand Assembly C++ and Phyton, can I get some help from u ?
>Phyton
Be sure to start with Python.
It's pretty easy programming language (pretty much as easy as Ruby). Don't worry too much about OOP at first (also: Python does it in a poor way when compared to Ruby or Smalltalk or similar).
I recommend you read Mark Lutz's books but you can begin with https://automatetheboringstuff.com
Be sure to also install pylint and use it to check your code.
You also need a text editor, I recommend using Kate/Notepad++, or NeoVim/GNU Emacs (try them both and go through the tutorials).
>Assembly
Start with Programming from the Ground Up book: https://download.savannah.gnu.org/releases/pgubook/
It teaches x86 asm as your first programming language (but it's not boring if you already know how to program), and it teaches you how a computer really works. The downside of asm is that you need to do almost everything yourself and that writing a program takes a lot of work because asm is so simple. Don't bother writing big projects in asm.
Z80 asm or ARM asm are also good choices BUT you need to make sure you can actually run your code.
>C++
I recommend reading PPP2. It's the best book for learning C++ if you don't have much programming experience (it starts from zero but it teaches you everything you need to know). But be sure to also read about how manual memory allocation ( malloc() + free() ) is done in C (read the relevant parts from C: a modern approach, 2nd edition.). If PPP2 is too easy for you, read C++ Primer. (it's different book than C++ Primer Plus.
I recommend you use GCC or Clang (the choice doesn't matter but other compilers are worse).
And be sure to use cppcheck to check your code for common errors.
Linda Lee · 2022-12-17 06:31
I have just completed a small program that helps me edit pictures in a very, very narrow but handy way. But now i'm asking myself just how much i should refine and optimize the code. There are redundant variables, a lot of false inputs can break the program, it's convoluted, but it works and it's incredibly nieche and only for myself anyway. Is it worth it to iron things out when i could just move on to something else instead?
Lukasiewicz · 2022-12-17 07:35
>>33754
You shouldn't spend a lot of time on code you consider dead, but you should cultivate the impulse to improve the code you've just written.
Naomi Nascimento · 2022-12-24 14:34
Ive been trying to get job ready for a while but ive been stuck.
The only things i know are Some java and a bit of git
When i check the job offers i get overwhelemed by all the requirements of strange tools ive never heard of
Im enrolled in a CS degree but so far ive only taken filler classes.
Im trying to get into java development (gm sir), any advice would be appreciated
How do i even start a open source project? I have ideas but i dont know how to start
dup · 2022-12-24 16:35
>>33782
No class you prepare you for all those tools.
University does not teach you what you need for current job because current job uses a lot of modern tools that will be replaces before university even decides to teach them. It does teach you principles that works(assuming it's not a soykaf uni). The best you can do is just lie to get that job.
swap · 2022-12-25 06:12
>>33782
You should try to get internship at some company. Once you have completed it, you should ask for summer job or a part-time job. But be sure to also complete your degree even if you get a job because getting a 2nd job is a lot more difficult if you don't have a degree.
>Java
Java is a good choice if you want a job. You really should learn to use Ant (just learn the basics) and Maven. Also, check out a tool called "VisualVM". And read Head First Design Patterns (but do not use a design pattern, unless you know you should use it).
>When i check the job offers i get overwhelemed by all the requirements of strange tools ive never heard of
Try to pick a couple of them that are most popular and learn to use them.
>How do i even start a open source project? I have ideas but i dont know how to start
You can start making the program and then later decide whether you want to publish it or not. Start with the easiest idea.
Vasya Pupkin · 2022-12-25 10:21
>>33785
Well yeah i realized a while ago that i had to learn marketable skills on my own, since they dont teach all that stuff in a CS degree.
>>33789
I lost a chance to get an intership because i didnt have enought credits :C
I was close but not enough credits yet, by the end of july ill have enough if I pass all my classes
I checked and the most common tools seem to be: React, Nodejs, MongoDB and other databases, Typescript.... i dont like web development but thats where all the jobs are apparently
And i started working on a project using QT since i had trouble starting an actual project in java (i didnt mention that I know C++)
I really like QT now that ive tried it, though im stuck in a part of a project.
Its a book manager where youre supposed to browse a catalog of books and save them, i just dont know how to integrate the book search function
Turing · 2022-12-25 12:29
>>33790
>I lost a chance to get an intership because i didnt have enought credits :C
You could (and should!) email the same company/companies right now, and ask for a summer job. Look into what they do (+ perhaps try to learn basics of some tech/framework they are using) and say that you are interested. Don't forget to tell them what skills you have. Don't wait. Email them right now because you have still a chance to get a summer job if they are offering one. There is no harm in asking them.
>MongoDB and other databases,
Do yourself a favor and learn SQL first.
>Typescript
>JS frameworks
Learn basics of vanilla JavaScript first.
>webdev
Since you know Java, I recommend you look into Spring framework.
Dr. X · 2022-12-25 19:21
What programming language would you recommend for maths?
My uni teach us python but I would like to know if there is better, faster (julia?)
I am looking for speed.
Ease of use/time spent writing the code are not probelms
Ishikura "Tatsu" Tatsuhiko · 2022-12-26 05:49
>>33796
Haskell, OCaml, or Clojure
Zhora · 2022-12-26 09:02
>>33796
Fortran, R and what >>33800 said
The only good thing about Python is that it's very popular and there are a lot of pre-made libraries written for it.
Nameless · 2022-12-26 11:02
I want to write lightweight issue-tracking software. I'm considering either Phoenix (Elixir) or Zig. I'm kind of a Phoenix beginner but I love Elixir and FP, and this is precisely its domain. But it means pulling BEAM to use it. Zig pulls ahead in comparison, the solution would instead end up being a single light binary.
Thoughts lains? Is Elixir kino?
hash table · 2022-12-29 11:31
I have been thinking in doing some cpu simulation in Standard ML. However, every single example of someone doing something similar to this used ref or any mutable data type(array, for example), which for me sounds stupid because if I'm going down that route, I should just use C or whatever since it will be far easier to do using it.
Does someone have any good idea or links explaining how one would go develop some cpu simulation without using mutable data types?
John Doe · 2022-12-29 12:28
Which programming language would you recommend for a smart 7 years old?