[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: 1694873372443821.jpg (130 KB, 1600x2000)
130 KB
130 KB JPG
Old thread: >>96035134

What are you working on, /g/?
>>
rewriting c++ game engine in c
>>
>>96070919
rewriting c game engine in c++
>>
Webgame with jquery because I hate myself
>>
>>96070954
could be worse
>>
>>96070919
Incredibly based.

>>96070945
Incredibly not based.
>>
>>96070851
Making an HTTP server in C++ and I plan to use it with HTMX
>>
File: 1624011142124.jpg (93 KB, 669x680)
93 KB
93 KB JPG
>>96070851
Getting excited and learning about one interesting thing after another, and then never doing anything with any of it.
>>
>>96071376
Incredibly based.
>>
>>96016501
I'm doing Modern C by Jens Gustedt next
>>
>>96071112
What's painful is I tried to use Flask logic as much as possible but as complexity escalates (menus, levels, etc) the javascript goes spaghetti
t. maniac autism
>>
>>96071541
>Jens Gustedt
He's on the C standards committee. I read his blog every few months when it occurs to me.
I don't agree with everything said in Modern C, but for the most part it's good.
>>
>>96071666
>t. maniac autism
>t. 666
>>
>>96071666
why would you do that
>>
>>96071728
kek
>>96071829
because i'm self taught and nobody taught me better
>>
I'm trying to convert SVGs into a normal graph because I know the standard deviation and the mean
>>
File: 1562947670242.jpg (330 KB, 836x1200)
330 KB
330 KB JPG
pondering whether to learn ReactNative or Dart & Flutter!
>>
>>96071666
Just use react
>>96071896
ReactNative
>>
zig or go?
>>
>>96072069
For writing hello world? Only artisan crafted machine code will suffice
>>
>>96071919
Do you have an example? Don't know react but willing to learn
>>
I have a specific issue in C# and I don't know if anyone can help. I'm making a snakes and ladders game. My entire program works fine, the only thing I can't get to work is the special mode, which basically allows you to instantly warp your sprite around to test different functions of the board.

I can't get my sprite to teleport around. It always follows the grid. No matter what I try. The sprite is named "sprJoueur" and the special mode check box is called mnuSp├ęcialModeTest. I'm positive the solution involves a NOT operator but I'm too fucking stupid.

Here is an attempts:

mnuSp├ęcialModeTest.Checked = !sprJoueur.FollowGrid;

Another:

if (mnuSp├ęcialModeTest.Checked)
{
sprJoueur.FollowGrid = false;
}
>>
>>96071896
Dart & Flutter are pretty fun but ReactNative will probably make you more employable. Depends on the goal
>>
>>96071376
Ok I made it working with boost asio and beast was simpler than I thought
>>
File: file.png (34 KB, 638x193)
34 KB
34 KB PNG
ass
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2961r0.pdf
>>
>>96073065
lmao
Do cniles lawyers really?
>>
>>96073094
*sepples
>>
File: file.png (84 KB, 751x958)
84 KB
84 KB PNG
>>96073065
holy mental illness
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2955r1.html
>>
File: 1680314513564.jpg (24 KB, 828x631)
24 KB
24 KB JPG
>made a program with cool features not found in existing similar programs (that are popular but code clusterfucks)
>want to share the source code because I want people to use it
>expect the new features to just be stripped from it and added to the existing applications
>>
>>96073393
Damn, that'ld suck if software and people's lives improved as a direct result of your work.
>>
>>96073393
So release it under the GPLv3?
>>
>>96072675
check its move function. Also, those random code snippets you provided with absolutely no context are absolutely useless.

Frankly, I don't know why you are setting the special mode from the grid status anywhere, unless the grid following behavior can be changed by other means. The check should change the behavior, not the other way around.

Anyway, your move function is what you need to investigate.

>>96073065
>>96073094
This is what happens when you shoehorn needed functionality into existing syntax.

>>96073393
If your program does everything else well and serves as a drop in replacement, distribute to the end user. If not, pick an existing project that you actually like and fork it.
>>
File: screenshot.png (110 KB, 1053x870)
110 KB
110 KB PNG
>>96070851
Learning zig so I'm implementing some basic data structures in it.

Loving the language so far.
>>
>>96074311
that doesn't look like zig to me
>>
>>96074311
>const Self = @This();
horrific
>>
File: 130221984383.jpg (49 KB, 600x578)
49 KB
49 KB JPG
>library kicking out 20k error messages per second
>find where it's coming from
if (id == -1)   /* can't happen */
>>
>>96074394
Why? It's only a type alias to make it more convenient to use the type of the struct within the struct itself.
>>
>>96070945
Based. C++ is the superior language. C is for brainlets.
>>
>>96072675
use debugger, breakpoint where you want the change to happen, then look at the state of the objects to see if they change how you want.
>>
is freecodecamp a good starting point for self learning? I dont want to get a software job, just a new hobby and afterwards I'll dig around at getting a linux distro
>>
File: Purple_dragon_book_b.jpg (21 KB, 257x389)
21 KB
21 KB JPG
>>96074838
> is freecodecamp a good starting point for self learning?
No, just buy this book.
>>
I'm hoping this isn't too dumb for this thread, but I'm just learning Python and don't know what Python's issue is with the following code:

from math import sqrt

def primefactor(num):
lim = math.sqrt(num)
factors = list()
if num == 1:
return factors
else:
for i in primes(lim):
if num%i == 0:
factors.append(i)
factors.append(num/i)
num //= i
return factors

def primes(x):
primes = list()
sieve = [True]*x
for i in range(2,x):
if sieve[i]:
primes.append[i]
for j in range(i * i, x, i):
sieve[j] = False
return primes

primefactor(num)

I'm completely new to programming and am just trying out some simple ideas I know from maths. What I want from this code is:
primes(x)
should do a simple Eratosthenes sieve to get me a list of all primes up to and including x and then i'll use that list to go through and check the prime factors of a number
primefactor(num)
.
However, Python tells me has a TypeError on lines
primes = list()
and
for i in primes(lim)
, because it "can't multiply sequence by non-int of type float" - can someone explain why?
I don't actually see where this was even done in the code.
>>
File: 1693182311316365.webm (777 KB, 720x720)
777 KB
777 KB WEBM
is there a thing in which I can execute C code line by line and view the memory as it changes? sort of like 8086 emulators
>>
>>96074623
I do agree for modern C++. They look at the potential for added complexity and just decide they don't want to deal with it at all.

Most C applications should probably be using trimmed down C++ compilers. Then they could build containers which are the number 1 primary most useful abstraction ever.
>>
>>96075224
https://www.sourceware.org/gdb/
>>
Alright last thread I had some trouble figuring out how to deploy softwares to linux users without containers, making them build the whole thing or finding maintainers for each distros but I think I've got it.
>vendor all libraries
>static link what I can
>-rpath what I couldn't
>build on an older LTS distro to make sure my minimum supported glibc version isn't too high
If I've got it right this should ensure my shits can run about anywhere that's still being supported.
>>
File: game_of_life.webm (2.44 MB, 480x480)
2.44 MB
2.44 MB WEBM
An anon mentioned doing Game of Life with Raylib. It sounded like fun so I did the same thing today with SDL2.

It was very uneventful but it was fun.
>>
>>96075065
TypeError is probably because you're using primes as both a function name and a variable name.
float error is happening here:
sieve = [True]*x

math.sqrt(num) will give you a float, so x is a float
>>
>>96075326
probably want to check glibc versions for most compatibility
>>
>>96070851
enabling random drivers in the kernel until the USB ports on my ZynqUS+ work
>>
>>96075065
I don't know Python, but some things I see:
You have
lim = math.sqrt(num)
which makes lim a floating point value, then in that else branch, you do
for i in primes(lim)
and it doesn't know what you meant by that.

I recommend casting the result from the square root call and making sure lim is explicitly an int first, then doing whatever else it complains about.

>can't multiply sequence by non-int of type float
I think this refers to
sieve = [True]*x
in your primes function. x is a floating point type caused by the bits from above. I assume that the intent is to set the size of the list sieve? I don't know if that is how you can set the size of containers in python.

Beyond that you are on your own.
>>
>>96075224
like anon said, gdb. there's some frontends that make it a lot less of a pain in the nutsack to use like ddd
>>
>>96075395
I don't know if it's really necessary as long as I stick to the minimum glibc advertised to users. According to
>https://abi-laboratory.pro/?view=timeline&l=glibc
it seem pretty stable.
>>
>>96075362
>>96075416
ah, that makes sense, I completely forgot about that
thanks anons
>>
>>96075515
that's what i meant, min glibc
>>
>>96075224
I think Lefticus has something like that, he uses to teach people assembly programming or something.
>>
I have a weird concurrency bug that only happens like 1 in 100 runs and I'm just sitting here closing and opening my program for 4 hours now to try and see if there is any way to predict it or pattern. honestly feels like im playing pokemon or something wtf
>>
File: 1692227652707197.jpg (78 KB, 1079x1073)
78 KB
78 KB JPG
>>96074311
Looks really clean.
Why do you use null instead of undefined in init()?
>>
>>96075936
Even if you encounter it that way, you will have burned a lot of time using a bad strategy. I recommend doing some digging until you can figure out how to trigger it.

I have a C++ templates question with a minimal example:
template <int N>
struct Demo
{
struct DependentType
{
int value{ 0 };
};

DependentType dt{ N };
};


template <int N>
bool operator==(const typename Demo<N>::DependentType& lhs,
const typename Demo<N>::DependentType& rhs)
{
return lhs.value == rhs.value;
}


bool operator==(const typename Demo<0>::DependentType& lhs,
const typename Demo<0>::DependentType& rhs)
{
return lhs.value == rhs.value;
}


int main()
{
Demo<0> d0_0;
Demo<0> d0_1;

bool acceptable = d0_0.dt == d0_1.dt; // direct match

Demo<1> d1_0;
Demo<1> d1_1;

bool problems = d1_0.dt == d1_1.dt; // template match?

return 0;
}


All of the stack overflow answers just say to make it a friend or define it inside the class. I want to know how to convey my wishes to the compiler that it instantiate an operator== for a Demo<N>::DependentType.
>>
>>96075272
>>96075496
nice thanks, ddd looks cool
is anything similar for windows?
>>
File: raikou.png (658 B, 56x56)
658 B
658 B PNG
>>96075936
Maybe try to produce a core dump when the bug occurs and try to analyze it in gdb?
>>
>>96076511
pretty much, he will just have to pause execution and switch between threads in the debugger and examine some variables to see what is not what it should be.
>>
>>96076469
I would try an explicit instantiation of it with the value you want to use.

I don't really know if that will work, but it's definitely something to try.

template struct Demo<10>; // etc
>>
>>96076777
Oddly enough, calling it like
bool ok = operator==<1>( d1_0.dt, d1_1.dt);

does work. I am just not sure how to make it deduce from context.
>>
>>96076950
I took a minute to play with a template template, that could be a way to do it idk yet, but gotta do work again now.
>>
Is there a cross-platform thread library for C that lets me externally pause and resume threads? I want to be able to run a function in a new thread and be able to interrupt its execution without having to explicitly write the function to yield or use a mutex or anything like that.
>>
>>96072069
it depends
actually, it doesn't. zig if you want to have fun, go if you want to become a code monkey
>>
>>96075355
Now make one that can simulate 1920x1080 cells at 60fps
>>
>>96077159
I think coroutine libraries support something like that?
https://gist.github.com/lpereira/2154951
>>
>>96077159
...like a debugger?
>>
>>96077159
Of course not, since C threads on most platforms are native threads. They do not run in a managed environment, and as such they cannot be interrupted without you adding code for that.
>>
>>96077159
glib tasks
>>
>>96078000
Debuggers use this concept, yes. It's called preemptive multithreading. The easiest way to implement it is SIGALRM, but that doesn't work on Windows.

>>96078006
That's literally how native threads work. One thread issues a hardware interrupt with an associated ID for another thread and it halts that thread's execution.
Anyways, how do you think managed environments implement thread schedulers? You didn't think that they run a conditional branch to check if a thread should pause, did you?
>>
>>96078108
Oh that might do the trick. Thank you anon.
>>
>>96078214
NOOOOOOO you are supposed to use LIBRARIES that do MAGIC
>>
guys i need help with my set up

1. I scrape data from site using python
2. I store scraped data in sql database
3. i want to create an android app that can search the database
4. I need help how to set up push notifications to mobile even if the app itself is disabled on mobile

SQL obviously can't do that, I assume i need some program in the middle (where) that will be able to do that.
>>
>tfw too dumb for tensorflow
>>
redpill me on assertions
assertions being defined as boolean expressions that throw an error on development/debug mode but are skipped or not even compiled on production mode
I dont understand, to me it seems like anything you'd want to assert is something you'd want to do proper error check on production code
>>
>>96079309
yeah it's retarded. they should stay enabled in release
>>
Trying to find a language/framework/whatever to build a GUI that doesn't feel like pulling teeth.
>>
>>96079309
you add assertions for things that should never happen and would only happen if you programmed something stupidly badly.

it's like a mini unit test for major errors, another form of "sanity check" or "smoke test" testing.
>>
>>96079483
The only one that exists is the browser DOM., hence all the Electron apps Let that sink in.
>>
>>96079544
>would only happen if you programmed something stupidly badly.
or unexpected data that shouldn't be the case. such as in decoders of foreign data
>>
>>96079309
In games and other places where performance matters, you take them out to cut down on the branching you do.
>>
added window position saving and loading to my programs

>>96079483
make your own
>>
In the middle of speedrunning CS50 Python - on Day 11. OOP has hands and that part took a lot of the wind out of my sails. Finished uploading all of my assignments this morning and I just can't make myself watch the last lecture and then taking on the final project at the moment.

After this I'll be doing the same thing with CS50x and hopping towards Colt Steele's WebDev Boot Camp or look for more backend stuff. Pivoting careers is a pain in the ass but at least my engineering background eases it a bit.
>>
>>96079483
Tgui.
>>
I still have no idea what good "object oriented programming" is, I just use classes to organize things together.

Also class inheritance seems retarded compared to class composition/components.
>>
>>96080164
>Also class inheritance seems retarded compared to class composition/components.
That's generally what people say nowadays, even OOP advocates.
>>
>>96080164
>I still have no idea what good "object oriented programming" is
doesn't exist
>>
File: Ct8Of3CXYAAQf32.jpg (69 KB, 1024x512)
69 KB
69 KB JPG
>>96080164
>I still have no idea what good "object oriented programming" is

when you build your software upon interface abstraction techniques by composing with interfaces only, no more with data.
>>
>>96070851
I just finished An Introduction to Prolog Programming by Ulle Endriss, what are some more advanced projects in Prolog that i could try to make? I dont feel like I understand it that much yet, that i would be able to write an interpreter, that would be my final goal tho.
>>
>>96080164
https://www.youtube.com/watch?v=32tDTD9UJCE

^ that's how you do good OOP, you end up building a couple/few large inheritance hierarchies and within them you have access to most everything you need. So they use it to avoid fucking with encapsulation rules as much, to some extent.

But a better (more modern) design is separating your architecture into algorithms (Free functions) and containers (classes that exist purely to encapsulate some data). Which means you have a lot more top-level objects and they can interact with each other with far less bullshit--an example of this would be the chrono lib or perhaps the random standard library libs.

Actually, that's the architecture of most of the C++ standard library. So we know it works--damn well.
>>
>>96080407
>gray hair man extolling the virtues of OOP
no thanks
>>
>>96080407
another benefit is that it's easier to swap out one part of the chain for another when you have more top-level objects.

It's sort of like a life hack for programming with a multi-paradigm language.
>>
>>96080533
Yeah well that's the only good way to do OOP, so I guess you're on the free functions and containers train then. Welcome aboard.
>>
>>96080407
>that's how you do good OOP
>c++

c++ has been such a waste of time for so many years now... nothing of it will stay in history. today it is mostly a graveyard for old boomers
>>
>>96080407
That talk is a meandering mess that's impossible to follow or extract anything useful from. It's so convoluted, dogmatic, and rigid (is-a relationships, lmao) that it's creating more problems to solve than actually giving actionable advice to model your problems and data. It's a complete waste of time.
>>
File: project.png (175 KB, 348x355)
175 KB
175 KB PNG
>>96080592
>today it is mostly a graveyard for old boomers

I know you're probably a shillbot, but I still want to laugh at you.
>>
>>96080606
I have a hard time believing you actually work in software, because you have apparently never encountered these concepts before and have no desire to even consider another POV.

Probably some NEET writing garbage C code in mum's basement.
>>
>>96080164
>I just use classes to organize things together.

you should only be making a class when you want to encapsulate some data.
>>
>>96080658
>only NEETs don't like OOP!
it's not the aughts anymore lad, nobody buys it
>>
>>96080658
>because you have apparently never encountered these concepts before and have no desire to even consider another POV.
Doesn't logically follow from anything I said. OOP isn't some helpless, obscure POV.

>Probably some NEET writing garbage C code in mum's basement.
OOPtards lmao
>>
>>96080843
>OOP isn't some helpless, obscure POV.

hmm just too stupid to be a dev I guess
>>
>>96080164
>I still have no idea what good "object oriented programming" is
Few people do.

>class inheritance seems retarded
You might be one of those that do.

If you can make changes and add features without fretting or searching through code, then your code is probably organized ok.

If someone else can make changes and add features without fretting or searching through code, then your code is likely organized well.
>>
>>96080164
Only interfaces and factories. if i see the new operator being used outside of a factory, you are instant demoted from my team.
>>
>>96074838
for yes, but you gotta grind all that html-css-js first, then move to other stuff, even better do your own shit for each tutorial section.
If you are very new to programming first start with C, learn types, structs, functions, data structures and shit.
Try C++ so you get a more modern approach, same shit but you'll use classes/objects this time, then move to JS, otherwise you'll be a bit confused because JS is a fucking stinking pile of flaming shit so knowing the trve languages first and pointers/references will save you the headache trying to wrap your head with that shit.
You don't have to learn C/C++ like a pro, just learn some computer science through those so you get a grasp of the prototype fuckery of js then move on because they made classes, of course along the way you should learn some shit like design patterns, ex factory functions etc so you don't create immense js objects that will make your browser lag.
Good luck.
>>
>>96079805
>>96079580

Jesus Christ, how horrifying.

>>96079710
Putting together my own janky ass solution with C and raylib is seeming more and more attractive.
>>
File: 1691701109670509.jpg (15 KB, 372x268)
15 KB
15 KB JPG
>>96079710
>added window position saving and loading to my programs
That's the job of your window manager, not your program.
>>
>>96084415
>trusting un*x junk and w*ndows
shan't
i will give the users the best experience within my power.
>>
>>96084505
Now you have N different programs with N various incompatible and broken implementations of window manager policy, instead of 1 that's in the place where it should be.

Does your program handle tiling window managers? What if users always want to open new programs (or perhaps just yours specifically) on a specific/new workspace?
Does your program even handle workspaces?
>>
>>96084573
>Does your program handle tiling window managers?
Tinkerers will be elated to know that i do not support their memes, so they have more things to tinker with!
>workspaces?
That's their problem, not mine.
>>
>>96084415
>>96084573
if the window manager wants the program to be on specific position and workspace, it has to do the job itself when the window is mapped
otherwise it's fair to assume that the window manager doesn't care
my program only specifies the positions in XCreateWindow and it just works with tiling window managers, because they just ignore these positions anyway
>>
>>96074311
>global allocator
anyway, did you know that you can use the general purpose allocator to detect leaks?
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer std.debug.assert(!gpa.deinit());


>>96076057
because you are initializing the (empty) list, it is defined you fucking retard
>>
>>96084971
>you fucking retard
rude, he was just asKING a question
>>
>>96075065
the interpreter should give you a traceback with a call stack and if you read it you should be able to figure out where in your code exception was raised
>>
>>96084971
>(.{}){}
Who thought this was a good idea?
>>
>>96085697
people with C brainrot
>>
>>96085863
That's not C, you moron.
>>
so when reading on a serial port with a device on the other end sending a message every 500ms, I don't actually have to poll and read in non blocking mode with a timeout (of say 10ms after getting first character) to make sure I get the whole message. instead I can just set VMIN and VTIME and the OS will do that operation under the hood and only unblock read when data satisfying my timing criteria has arrived? Am I understanding that right?
>>
why is it always the thing i least want to do is always the thing that has to be done
>>
>>96088354
selection effects
>>
so, does zig have resizeable arrays? do I have to resize it manually every time or is there some nice wrapper around it?
>>
Is cockroach db a good database from my saas web app?
>>
>>96089838
>Awful name
>Proprietary licence
Why would you even consider using it?
>>
>>96089838
void shuffle (unsigned short arr[], unsigned short arr_len)
{
unsigned short new_place = 0;
while (--arr_len) {
new_place = random() % arr_len;
arr[arr_len] ^= arr[new_place]
^= arr[arr_len] ^= arr[new_place];
}
}

Is there a more efficient way? I've read about lexicographic ordering and wish to cut down to one random() call but switching neighbors is far from efficient. Recursion might help but i'm bad with it. Any ideas?
>>
>>96089990
Appears to be the best option for something that can be globally distributed while having low latency read-write times globally.

The awful name is a good thing. You can be 100% sure an engineer picked the name.
>>
>>96090018
>while (--arr_len) {
lol
>>
>>96080407
>separating your architecture into algorithms (Free functions) and containers (classes that exist purely to encapsulate some data)
So... classic structural programming?
>>
>"Any Vk*Flags member or parameter returned from a query command or otherwise output from Vulkan to the application may contain bit flags undefined in its corresponding Vk*FlagBits type. An application cannot rely on the state of these unspecified bits."
is there any reason vulkan does this? i just don't get how you're supposed to work around that if trying to check flags
t. reading the spec fundamentals section, haven't written any code
>>
>>96090325
Old application built against new Vulkan.
>>
>>96090149
why not
>>
>>96090460
what happens if arr_len is 0
>>
>>96090460
>>96090018
That doesn't handle 0 properly
.
As much as a meme as the "goes-to operator" was, it's actually the proper way to write a decrementing loop with unsigned integers.
//The meme
while (arr_len --> 0)

// properly formatted
while (arr_len-- > 0)
>>
>>96090406
seeing you say something i didn't get made me understand that i misunderstood the text, thx for making me think twice lmao
i figured it out
>>
>>96090537
Just to be more explicit then, if you have something written against Vulkan 1.0, and they depend on some unused bits being 0 for whatever reason, they'll break in e.g. Vulkan 1.3 where those previously unused bits gets used.
Hence them saying, "please don't rely on these bits being 0".
>>
>>96090571
ah, that makes perfect sense, thanks for the clarification
i probably should've gotten that from them saying to be careful about switch statements with enums since things can change with new extensions
>>
>>96090481
Fair enough. I'd rather add "if (arr_len < 2) return;" because shuffling short arrays makes no sense
>>96090489
Kek, somebody actually used that?
>>
>>96090489
Of course, you don't need the >0 here at all. Just the postfix decrement.
>>
File: 311.jpg (28 KB, 600x485)
28 KB
28 KB JPG
>>96090489
>goes-to operator
>>
GOES-TO MY ANUS
>>
goes-to deez nuts
>>
>>96090870
That was the meme. It was to trick new programmers to thinking it was an operator, not just postfix decrement and greater than.
>>
>>96090870
how nu ru
>>
Lads I need help. I have to make a choice. A big oil company made me a huge offer, literally double my current salary, but it's working on legacy code. It's shitty software written in Java and the guy on the team said the job is basically writing tests and slowly migrating it. I also have another offer for a company that's actually doing something fulfilling but same salary as much current job (which I am leaving because of relocation).

What would you do? I am already sick of programming so I'm not sure I can take any more tedium but the money is irresistible.
>>
>>96091116
>sick of programming
Second company unless you're in huge debt or something
>>
>>96070851
good resources to learn bash and awk? Preferably something interactive.
>>
damn, gcc takes ages to build from source
>>
>>96091116
if you're in a good spot financially (happy) just take the second job. if you can jump class lines consider the first one, but honestly you'll be better off not wanting to kill yourself 1, 2, 5, 10, or however many years down the line
>>
>>96074888
https://meta.stackexchange.com/questions/25840/can-we-stop-recommending-the-dragon-book-please
https://twitter.com/Jonathan_Blow/status/1657156380032225280
>>
>>96070851
I wanted to have some fun with functional programming.

What are some fun things you can do with Haskell? What it is good for?
>>
>>96091928
>modern compiler implementation in Java
>>
>>96074838
just make little games with pygame like everyone else on earth
or read sicp if you're a masochist
or csapp if you're retarded (low-level programmer)
or javascript if you want an easy-in to working with graphics (p5.js)

really, you should be tailoring your learning towards what you want to do. why learn things you aren't interested in? wanna make games? python, c#, c++, other scripting languages used in game engines. wanna automate processes? probably python. machine learning? python, normally. robotics? c, c++ if you're dumb, python, ROS
just look up tutorials for what you want to do, then if there's something you don't understand, look up tutorials for those things. eventually you'll hit the basics and can move your way back up the chain
>>
>>96091383
Read this and then regret that you didn't read it years ago.
>>
>>96092047
that's a good book, the other version by the author is in ML
>>
>>96091383
https://killercoda.com/kodxxl/course/Linux
>>
>>96074838

>>96092063
is a good advice.

Use some course to learn enough to start doing things by yourself, best done in some easy language like Python. Python docs are great, not sure how good for learning basics of programming tho. I started out with this course and I liked it very much, probably still can recommend it for everyone. On his page you can find pdf version with some exercises after every chapter - do these AND everything you think is cool, test how things work as you learn new material, start writing bigger and more complex programs.

Best way to learn programming is working on projects you're excited about and are a little bit above your capabilities.

https://www.youtube.com/watch?v=8DvywoWv6fI
>>
>>96091928
>https://twitter.com/Jonathan_Blow/status/1657156380032225280
>People are stupid and I don't care what they think but I still tweet.

Which compiler book then?
>>
File: file.png (23 KB, 587x187)
23 KB
23 KB PNG
>>96092294
brilliant recommendation from this guy right here
>>
File: Download (3).gif (484 KB, 500x281)
484 KB
484 KB GIF
I'm just starting CS in college and have to learn java.

Any tips?
>>
>>96092417
if you can think analytically it's easy
if your school isn't known for cs and the intro class is in java it really shouldn't be hard. the syntax can be kind of obnoxious but if you use an IDE with code completion and error highlighting you should be fine. if a problem seems large, break it down into smaller sub-problems that make it easier to solve
>>
>>96092151
>>96092072
tenks frens
>>
>>96089471
define "resizeable arrays". do you mean something like std::vector<> in c++?
>>
>>96092471
Thanks
>>
>>96092417
https://papermc.io/
setup minecraft server for yourself and friends, then start writing plugins for it. It was always pain in the ass to setup development environment properly in Java, maybe it's easier with some video tutorials, but if you struggle with something you should know its not your fault.
Learn some other, less 'Object Oriented' language, do that as soon as possible.
>>
I am a noobie trying to parse a file some person created using regex.

It consists of an numerical ID, a person name and some numerical fields. Each person entry is between "/", while their individual fields are separated by ",". The file is badly formated and has newlines and spaces in random positions.

Can you guys help me? why does pic related does not match correctly? It is a very large file so manually removing things is a bad idea..
>>
>>96093043
and the file ends in a "." too.....
>>
>>96093043
stop using regex. write out code to parse it manually, it will be much easier and more maintainable. regex isn't a parser
>>
>>96093068
My idea was to find each entry using regex then process them.
>>
>>96073998
No, it wouldn't. But it would suck if the work I had done was simply thrown into a separate bloated and dysfunctional codebase (with no attribution) while that other dev makes money off it because it's established and "good enough".

>>96074050
Yeah, thanks. That's one of the things I'm considering.

>>96074302
>distribute to the end user
Including the source as well? I just might
>>
>>96093043
>Each person entry is between "/"
>The file is badly formated and has newlines and spaces in random positions.
delete old newlines and place a new one after each "/"?
what's your goal with the file anyway?
>>
>>96093043
This is almost exactly what awk exists for.
Assuming / doesn't exist in any names, try running it through something like
BEGIN {RS="/"; FS=","}
{ gsub(/[ \t\n]+/," ")
print "New Record: "
for (i = 1; i<=NF; i++)
printf " Field: %d %s", i, $i
print ""
}

and see if it chops it up properly.
>>
How does one create interoperability between languages? Say, for instance, you want to make a scripting language that calls C/C++ code. How does that work? Can you just make a function in C/C++ with a specific name and then call it from a scripting language?
>>
>>96093894
C++ is a clusterfuck here. The C ABI for platforms is actually well-defined, so everything cross-language basically always goes through C, even if C itself isn't being used.
>Can you just make a function in C/C++ with a specific name and then call it from a scripting language?
"Yes", but you still need to deal with assembly and object files etc/
>>
>>96093894
c ffi
>>
>>96093068
filtered
>>
>>96093043
do your own homework

>>96093068
shit advice. you clearly don't know what "maintainable" means
>>
>>96093959
>>96093974
I'm trying to read this article https://sampruden.github.io/posts/godot-is-not-the-new-unity/ and understand how it's possible to call the internal engine code (written in C++) from C# without using function pointers which is what he seems to be suggesting.
>>
>>96093894
#include <dlfcn.h>
void *ptr=dlopen("/usr/lib/libc.so.6", RTLD_NOW);
void *sym=dlsym(ptr, "puts");
int (*func)(const char *s);
func=sym;
func("hello");
dlclose(ptr);

void *ptr=dlopen("/usr/lib/libc.so.6", RTLD_NOW);
void *sym=dlsym(ptr, "printf");
int (*func)(const char *s, ...);
func=sym;
func("num = %d\n", 5);'
dlclose(ptr);
>>
>>96093894
Scripting langs usually have some setup where you take your new C code and link it against the scripting language and initialize it and register your new commands. So basically you're make a new, extended, interpreter.
Or they let you compile your C code as a shared library, and you load it dynamically from the scripting side.
>>
>>96094045
I should have removed const, it's silly
>>
>>96094026
Its not homework, its just that some government exams release preliminary results in absurd format (the one presented), in a giant pdf. I was trying to parse the results before the official release (which will follow the same retarded format).

>>96093841
thanks bro, awk seems cool. I am still trying to grasp regex... I will test this when I get home.

>>96093818
Ideally I would like to avoid opening the 1 mb txt file in a editor.
>>
>>96093068
Just because you can't grasp 2nd year computer science concepts, it doesn't mean that other people can't.
>>
>>96094126
The const on the function pointers? Those are supposed to be there.
In fact, your printf signature isn't specific enough:
int (*func)(const char *restrict s, ...);
>>
>>96093894
depends on the type of interoperability. anything compiled will require an ABI, in linux that means the C ABI, in windows you use DLLs (not sure if these use the C ABI)

>a scripting language that calls C/C++ code
you don't necessarily need an ABI in this case. there are two common strategies for embedded scripting languages; 1. use a virtual stack to pass values and call functions or 2. pass the actual callback
lua for example uses (1): https://www.lua.org/pil/26.1.html
python uses (2): https://docs.python.org/3/extending/embedding.html
you could implement a scripting language in C++ and then use one of these strategies. squirrel comes to my mind: https://github.com/albertodemichelis/squirrel
>>
I rewrote a python script for changing folder names in torrents via their hashes. It prints the right names for the folders, but it doesn't change them.
I guess the request.post second to last line in fault, but i don't know what to put there for actually renaming the folders.
Any tip?
     for name in rename:
if name.lower() in file_data['name'].rsplit('/', 1)[1].lower():
file_data['name'] = file_data['name'].replace("xyz.siterip", "asd")
print(file_data['name'])

r = requests.post(url + 'api/v2/torrents/filePrio',
data = {'hash' : torrent_hash, 'id' : str(file_id), 'priority' : '0'})

# without pauses qBittorent can choke on requests
time.sleep(0.05)

[\code]
>>
Weird question:
My template class has a base class template, I have two template functions, one takes a template template type parameter and one just takes a type parameter, normally the template type is selected for overload first except if there is a base class conversion like I have, so the linker refuses to do the base-class conversion if the type parameter function is declared, it prefers the type parameter function. Is there any way to get a sub class to call the template function that requires a base class conversion without relying on the user to explicitly do an upcast with a reference variable? I'm looking at using some kind of delegation with if constexpr maybe but that's also a pain because I am doing explicit templates so I need to 2x instantiate templates just to have one function forward to another and I also don't like that.
>>
>>96094045
>>96094100
>>96094459
Interesting, thanks.
>>
by the way, if I were you, I would use something like zig as the host language. in fact, here is a zig function I wrote some time ago to generate lua functions from zig functions on compile time (think of it as C macros but with more features and consistent with the rest of the language)
pub const Func = fn (lua: ?*c.lua_State) callconv(.C) c_int;
pub fn wrap(comptime func: anytype) Func {
return struct {
const Type = @TypeOf(func);
const info = @typeInfo(Type).Fn;
const Tuple = std.meta.ArgsTuple(Type);
const fields = std.meta.fields(Tuple);
const len = fields.len;
const return_type = info.return_type;
pub fn f(opt: ?*c.lua_State) callconv(.C) c_int {
const lua = opt.?;
var args: Tuple = undefined;
inline for (fields) |field, i| {
c.lua_pushvalue(lua, -@intCast(c_int, len - i));
@field(args, field.name) = load(field.type, lua);
c.lua_pop(lua, 1);
}
if (return_type != null and return_type.? != void) {
const ret = @call(.auto, func, args);
push(lua, ret);
return 1;
} else {
@call(.auto, func, args);
return 0;
}
}
}.f;
}

it takes an arbitrary zig function ("func") and returns a C function with the lua_CFunction signature that you can call from lua
>>
>>96094447
Honnestly I don't know what the "type annotations" const and restrict do exactly, only that they are kind of a joke, type system wise, even from in comparaison to C's type system, and the essential is that the signature have the right "normal" C types for the calling convention of the specific called function
>>
>>96094815
>the right "normal" C types
machine types is a better term
>>
>>96094029
>how it's possible to call the internal engine code (written in C++) from C# without using function pointers which is what he seems to be suggesting.
https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.dllimportattribute?view=net-7.0
https://stackoverflow.com/questions/14471571/how-does-dllimport-really-work
>>
How do I fix this?
string.match("/opt/test/video.mkv", "[\/\\]test[\/\\]?")

>lua5.3: Main.lua:1: invalid escape sequence near '"[\/'
I want to match either / or \ to make the string match compatible with both unix and windows paths but I'm not able to escape the characters within the regex character sets around "test"
>>
>>96095582
stop using regex
>>
>>96095582
looks like a escape character conflict between lua and regex
try replacing \ with \\
>>
File: file.png (28 KB, 971x275)
28 KB
28 KB PNG
>>96095788
Ah apparently only \ required escaping
>>
>>96094815
You don't have to escape a /, or basically, \/ is not a valid escape sequence.
> string.match("/opt\\test/video.mkv", "[\/\\]test[\/\\]?")
stdin:1: invalid escape sequence near '"[\/'
> string.match("/opt\\test/video.mkv", "[/\\]test[/\\]?")
\test/
>>
>do vulkan tutorial
>validation layers don't work, can't get error to display
>reinstall vulkan like 4 times and try every debugging thing that popped up
>vkconfig mentioned it couldn't read a random json file with a completely unrelated layer, surely it can't be that...
>uninstall rivatuner, fucking rivatuner, and it works
yep, i'm gonna kill myself
>>
cmake question
If I have a global defined in A.cpp and I compile A.cpp with add_libary(A OBJECT A.cpp)
Then have
add_library(B SHARED B.cpp $<TARGET_OBJECTS:A>)
and an analogous C lib
then both B and C contain the definitions for the global in A, right? And if I link them together it will fail
>>
>>96095931
>\/ is not a valid escape sequence.
mmm
>>96095582
it's an double quoted string interpolation issue, not a regex issue
lua is not doing what other languages do. usually when you escape a random character that doesn't make a special backslash sequenc like \n \t \xFF, etc.. in an other language, the escaped character is put as is, but lua freaks out.
stupid lua
$ lua -e 'print "a\/bc"'
lua: (command line):1: invalid escape sequence near '"a\/'
>>
  VkPhysicalDevice vk_physicaldevice;
uint32_t queuefamily_graphic, queuefamily_present;
for (VkPhysicalDevice device : vk_physicaldevice_v) {
uint32_t avai_extension_count;
vkEnumerateDeviceExtensionProperties(device, nullptr, &avai_extension_count, nullptr);
vector<VkExtensionProperties> extension_props_v(avai_extension_count);
vkEnumerateDeviceExtensionProperties(device, nullptr, &avai_extension_count, extension_props_v.data());
std::set<const char*> notfound_extension_s{c_device_extension.begin(), c_device_extension.end()};
for (auto& e : extension_props_v) {
notfound_extension_s.erase(e.extensionName);
}
if (!notfound_extension_s.empty()) {
if (device != vk_physicaldevice_v.back()) continue;
else throw std::runtime_error("no siutable physical device");
}
uint32_t queuefamily_count = 0; // runtime exception
vkGetPhysicalDeviceQueueFamilyProperties(device, &queuefamily_count, nullptr);
vector<VkQueueFamilyProperties> queuefamily_v(queuefamily_count);
vkGetPhysicalDeviceQueueFamilyProperties(device, &queuefamily_count, queuefamily_v.data());
}

what the heck? why wrting to local var throws an exception? I don't think I wrote something wrong to the stack. Is it related to using unamed scope to manage variable life time?
>>
File: 1666458771036697.jpg (136 KB, 1920x1080)
136 KB
136 KB JPG
please ignore this post >>96096457
I was stupid
>>
>>96093841
Can you explain how does that work? I used to believe that awk only worked with {pattern} {action} style. I can understand what it does, but not why awk works like that lel.
>>
>>96096554
based retard
>>
>>96096731
Uh, in no particular order.
print, printf, and for should be obvious.
gsub is like sed s/regex/replace/g
BEGIN is a special pattern that runs before the first line of input. Or if there's no input it's the only thing that runs.
If you don't put a pattern then it defaults to true and the action runs on every record.
Awk breaks input up into records and then breaks up records into fields. It defaults to newlines for records and spaces/tabs for fields, but you can set RS and FS to whatever.
NF is the number of fields awk found in the current record.
$1 to $NF hold the individual fields, and you can just do $i or whatever to use a variable to access them.

just read the book >>96092072
>>
>>96097101
amazing. I was under the impression that the lack of pattern resulted in false, hence my misunderstanding. thanks browsky!
>>
What do you guys use for quick chatgpt help?
I don't like asking retarded questions ITT and google is useless if the problem isn't super common.
>>
>>96070919
Reinventing the wheel. Feels nice to have time to waste
>>
>>96098667
>derp, we should have stopped making new engines after the first one
>>
>>96098646
I dont use chatgpt, I spend 4 hours automating a task that would take 20 minutes, like god intended.
>>
>>96096457
>literal alphabet soup
my poor fucking eyes
>>
>>96096457
The single comment being "runtime exception" adds a lot.
>>
File: 1691560492758373.png (190 KB, 484x483)
190 KB
190 KB PNG
>>96098852
>>
>>96098667
Unartistic and anti-human sentiment
>>
>write C
>make structs and function that operate on them
>API is nice and easy to use

>Write C++
>make classes and templates
>APIs are fucked and nobody knows what's going on
>>
>>96092778
Thanks
>>
>>96092047
Check out GraalVM, writing a compiler is Java is surprisingly a decent option.
>>
>>96098879
>used reflection once like 5 years ago in a different language
>"in [language] using reflection, how would I access [field] which is found in [instanced field I can access]->[field of type [private class]]->[private field]?"
>get a perfectly working answer on the first attempt
>have another similar problem on the same project
>decide to solve it myself instead of relying on chatgpt
>takes like 2 hours to get it right
I'm going to be replaced within 10 years...
On the upside, it does often give trash answers.
>>
Tell me your favorite coding practices so I know what not to do when writing code.
>>
>>96099562
use C++ and OOP
>>
>>96099347
>communism
>automation is used to make our life easier
>capitalism
>automation is used to make people more miserable and the capitalists richer
really makes you think huh
>>
>>96099657
>communism
>automation is used to make the party richer
>capitalism
>automation is used to make the business owners richer
>national socialism
>automation is used to make our lives better
>>
>>96099102
Same in perl but with hash tables, hash tables are enough.
Following this analogy, this would make python C++.
>>
>>96099562
use C and procedural programming
>>
>>96099569
>>96099897
I shall use Haskell and functional programming.
>>
>>96099562
use BASIC and spaghetti programming
>>
File: 1694965738573199.png (1.61 MB, 1024x1024)
1.61 MB
1.61 MB PNG
>>96094463
anyone can help me with this please?
>>
>>96099562
Use Haskell and functional programming.
>>
>>96099969
>>96100072
I shall use Prolog and logic programming.
>>
File: ook.png (13 KB, 698x413)
13 KB
13 KB PNG
>>96099562
use Ook! and esoteric programming
>>
>>96100030
I don't know Python but if you can get the full string but can't change it then you're either using the wrong method to change the name or something inside the folder is currently being used (likely by your torrent).
>>
>>96099657
Shame the commie "our" is the empty set.
>>
>>96100135
i dont't know python either and i just rewritten this script like in some years ago for something else
I want to rename the root folder of the torrent, the folder has 2 files in it and another folder with a file in it.
Somehow it iterates through all the files and it changes the first occourance of the root folder with the first file, then reprint the last 2 files with the original folder name, then it goes for the 2. file and renames the root folder in its path the 3. file still stays the same with the original rootfolder name path, then going for the 3. file and all the paths prints the renamed root folder, , but actually nothing happens in the torrent client
>>
>>96100305
Well since neither of us know python I think the right thing to do is ask someone who does.
Chatgpt.

The `requests.post()` method is used to make an HTTP POST request to the specified URL. It sends data to the server in the form of form-encoded key-value pairs.
Based on your code snippet, it seems like you're using the `requests.post()` method to change the folder names in the torrents. However, it looks like you're only calling the API endpoint for changing the file priority (`'api/v2/torrents/filePrio'`) instead of renaming the folders.
To rename the folders, you need to find the appropriate API endpoint provided by the torrent client or tracker that allows you to change the folder names. Once you find the correct API endpoint, you need to identify the correct parameters and data structure required to rename the folders.
Assuming you have found the correct API endpoint for renaming folders, you need to modify the code accordingly. Replace the existing `requests.post()` line with the correct endpoint and provide the necessary data in the form of key-value pairs to rename the folders.
Here's an example of how the code might look if you have the correct API endpoint for renaming folders:

for name in rename:
if name.lower() in file_data['name'].rsplit('/', 1)[1].lower():
file_data['name'] = file_data['name'].replace("xyz.siterip", "asd")
print(file_data['name'])

# Replace the URL with the correct API endpoint for renaming folders
rename_endpoint = url + 'api/v2/folders/rename'

# Replace the keys and values with the appropriate data for renaming the folders
data = {'hash': torrent_hash, 'folder_id': str(folder_id), 'new_name': 'new_folder_name'}

r = requests.post(rename_endpoint, data=data)

# without pauses qBittorent can choke on requests
time.sleep(0.05)


Please note that this is just an example, and you need to find the correct API endpoint and data structure specific to your torrent client.
>>
File: pp,550x550.jpg (34 KB, 550x327)
34 KB
34 KB JPG
ok boys, better stand back...
I am about to start coding.
>>
File: numba1.jpg (84 KB, 1024x572)
84 KB
84 KB JPG
>>96100443
oh fuck thank you kind anon!
>>
>>96100443
IT WORKS ANON, THANK YOU
NOW I KNOW HOW THE API WORKS TOO
I WAS LOOKING HOW CAN I WORK WITH IT, NOW I KNOW
LET THY BE BASED AND BLESSED ANON
>>
>>96100836
I didn't do anything anon, I just put your post into chatgpt(3.5?).
I've been using https://gptonline.ai/ for quick prompts, sometimes it's buggy but closing/reopening/clearing session seems to work most of the time.
>>
The hard part is over, now the hard part begins
>>
>>96101118
women after I enter them
>>
File: thats-what-she-said.jpg (53 KB, 1280x720)
53 KB
53 KB JPG
>>96101118
>>
>>96070851
I'm learning how to write advanced algorithms because i haven't continuously programmed anything in a decade.
>>
File: 1608519721810.jpg (117 KB, 812x800)
117 KB
117 KB JPG
>>96070851
>>96101840
Also, here's some bullshit i wrote in nim that probably doesn't work

#[--------------------------------------------------]#
#my attempt at robot arm movement problem

type
Plane = object
x: seq[float]
y: seq[float]

Robot = object
posx: float
posy: float

proc move(xpoint: Plane, ypoint: Plane): float =
var r: Robot

xpoint.x = @[0.00, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.7]
ypoint.y = @[0.00, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.7]

for i in xpoint.x:
i = i + 1
for j in ypoint.y:
j = j + 1
while i > 0 & i < xpoint.x[i] & j > 0 & j < ypoint.y[j - 1]:
r.posx = inc i
r.posy = inc j

while i < 0 & i > xpoint.x[i] & j < 0 & j > ypoint.y[j + 1]:
r.posx = dec i
r.posy = dec j
return i
return j

proc pSort(p: Plane): Plane =
px: Plane = p.x[0]
py: Plane = p.y[0]
i = 0
while px & py < px[7] & py[7]:
i = i + 1
px[i] & py[i] < p[i - 1]
move(px[i] & py[i])
return px & py

proc conn(x: float, y: float): float =
x = x + 1
y = y - 1

return x * y

proc dist(x: float, y: float): float =
x = x + 1
y = y - 1

return x / y

proc cSort(p: Plane): Plane =
let n = p[7]
for i in n - 1:
do
d = Inf
for s & t in n.x & x.y:
if dist(s,t) < d:
s[n.x] = s & t[n.y] = t & d = dist(s, t)
conn(s[n], t[n])
connt(s, t)

proc oSort(p: Plane): Plane =
d = Inf
for n in p[n]:
if cost(p[n]) <= d:
d = cost(p[n]) & p[0] = p[n]
return p[0]

>>
File: file.jpg (116 KB, 768x1024)
116 KB
116 KB JPG
At this point I'm starting to believe I have negative IQ
>>
>>96102283
keep going maybe it'll underflow
>>
>>96102283
>At this point I'm starting to believe I have negative IQ
You're telling me. My code example above yours is probably infinitely more retarded than whatever the fuck you're doing.
>>
>>96102283
Everyone feels like that at first, and syntax errors don't indicate an inability to think critically.
>>
>>96102419
>syntax errors don't indicate an inability to think critically.
what about this?

import std/[algorithm, tables, sets, strutils,
base64, oids, terminal, rstdin]

type
Record = object
edb: Table[string]
id: Oid

proc post*(var e: string[Record]): Record =
#[take user input, hash user input, store user input in table, output tree node to console]#
readLineFromStdin(e)
var
t = initTable[uint32, string]()
id = e.Oid

for j in id < 0:
hash(e)
result = toTable(t[id, e]())
echo "Current List Content:", result
>>
>>96070851
how the fuck do i make any sort of 3d engine in C
actually

what the fuck do I use
what the fuck do I do?
what the fuck am I?
what the fuck is the reason for every piece of documentation relating to this subject matter being a fragmented mess that doesn't explain what's going on - but rather shows you a cookie-cut way of doing something specific?
>>
>>96102684
>what the fuck do I use
SDL, openGL or vulkan

>what the fuck do I do?
Start by making something simple, then as time goes on, move on to more of the advanced stuff

>what the fuck am I?
A dumbass just like me

>what the fuck is the reason for every piece of documentation relating to this subject matter being a fragmented mess that doesn't explain what's going on - but rather shows you a cookie-cut way of doing something specific?
Welcome to my world. Most os devs don't have the time to make everything look pretty and have everything on hand in one site directory so you'll have to garbage dive through multiple websites and directories for more info.
>>
>>96080407
>algorithms (Free functions)
this is exactly where most people fuck up

OOP should model behaviors, i.e. algorithms. if you put them out of classes, you inevitably force your codebase to grow shittier and shittier
>>
Learning ATS so that I'm able to understand dependent types, linear types, proofs and things like that. I'm at chapter 4 and doing a tons of tests on the side, it's starting to get interesting. I'm so hyped about this.
http://ats-lang.github.io/DOCUMENT/INT2PROGINATS/PDF/main.pdf
>>
>>96102792
That does not appear to be the case in any of the standard library, the boost libraries, nor my own project that uses it.

Objects exist to encapsulate data, not the functions (algorithms).
>>
File: 1608457294390.png (628 KB, 488x571)
628 KB
628 KB PNG
>>96102734
Alright, funnily enough a tutorial using the old Graphics library for C has lead me to realize what I'm looking for is SDL.

I'm trying to make some basic ass raycasting ass engine ass bullshit for the sake of le DOOM-wannabe tomfuckery. And I realized all I need for that, on a fundamental level, are lines that I can color. Everything else can be solved through applying algorithms. Sprites? Apply algorithm to take pixel and put in world. Wall and floor textures? Apply algorithm to take pixel from .jpg and put on surface.

SDL will do exactly that. And it's like a string, as long as the string has a starting point of tension - where I begin, and an ending point of tension - what I want to learn which is SDL in this case, then the string can be used to make music.
>>
>>96102830
Exactly. John carmack's retarded atheist ass built doom and a fuckload of other shit after dropping out of college to start grinding math and programming books, so you can too.
>>
>>96093043

(?P<id>\d+),\s*(?P<name>[\w\s]+),\s*(?P<fields>[\d\.,\s]+)


https://regex101.com/r/121Lvs/1
>>
>>96102817
>That does not appear to be the case in any of the standard library, the boost libraries, nor my own project that uses it.
does not contradict my post

>Objects exist to encapsulate data, not the functions (algorithms).
wrong. objects are meant to model behaviors, giving them a contextual boundary
encapsulation is meant to hide internal state of an algorithm so only the public interface is used

consider sorting
a sorting operation can logically only be applied to data that's a collection of things; at the same time you can have many implementations of a collection that could be sortable (an array, a set, etc.)
if you keep sort as a free function, you will either have to create a new sort() for each collection implementation, or modify sort() to support any new collection type. it might be sufficient for small and simple programs but in the long run you'll have shittier code than if it were OOP
>>
>>96070851
An anonymous p2p network that would support authorization
>>
I'm creating a web debugging proxy using Tauri (Svelte + TypeScript) for the front end, and obviously Rust for the backend.
>>
>>96103450
is it something like the activitypub protocol?
>>
>>96102951
he has quite a few games before doom you'd be surprised to see, he started in the trenches with "crappy" little top down 2D games written in 16 bit assembly
>>
>>96103327
modeling behavior is exactly the problem, that is exactly where people fuck up with OOP. They are abstractions over something complicated involving data, not every random item in your codebase.

>if you keep sort as a free function, you will either have to create a new sort() for each collection implementation, or modify sort() to support any new collection type. it might be sufficient for small and simple programs but in the long run you'll have shittier code than if it were OOP

That is profoundly silly, a simple generic sort will work with an iterator abstraction or most other implementations.
>>
>>96103327
I'm going to write more free functions just to prove you wrong-er
>>
>>96103784
He did non gamedev stuff before like rocketry and whatnot.
>>
I am finally going to build that tool that will sort/organize/tags all my images properly, I need a break from work
>>
>>96094029
>>96095004
DLLimport works with C functions, so you create static instances of the C++ code and call it via free functions wrapped by "extern "C" { }"

-OR-

you write a wrapper around the C++ code in C++/CLI aka "managed C++" which creates a mixed-mode (.NET and native code) assembly. You then import the C++/CLI class and you can use it from C# like any other class.
>>
File: clumsy.gif (2.17 MB, 498x498)
2.17 MB
2.17 MB GIF
>>96104572
Sorry this answer was so late, I was working and getting grilled for using free functions instead of 2000s OOP design. I relented and made them static member functions of the class.

Someday, someday they will update everything. All in one fell swoop, the whole codebase. We'll even have unit tests and concepts too! Y-you'll s-see!
>>
>>96103800
>a simple generic sort will work with an iterator abstraction or most other implementations
iterator is an OOP design pattern, modeling a behavior
>>
>>96104750
I don't think this is proving your point the way you want it to.

And, since literally everyone in the world is using some form of OOP, most of them are realizing it isn't the greatest thing since sliced bread, which means my point is more and more valid every day.

The OOP fad peaked around the 2000s and has since been declining. That is, OOP describing the most common implementation wherein the functions are also intentionally encapsulated along with the data, whether they need to be or not.
>>
>>96103327
>you will either have to create a new sort() for each collection implementation, or modify sort() to support any new collection type
Don't you always have to create a new sort function?
Given a list of T you can't sort it unless you implement the comparator T -> T -> Integer.
>>
>>96103327
how would OOP solve your sort() problem anyway?

Because every object having it's own sort() function is just another problem to deal with--namely you can't f-ing re-use them.

At least with a free function you would just call the external implementation you wanted when implementing the member function sort() for the object that is compatible with it.
>>
>if you make a shared_ptr with "new" it creates a similar but less efficient object than if you had created it with make_shared()

ffs
>>
>>96104839
>And, since literally everyone in the world is using some form of OOP, most of them are realizing it isn't the greatest thing since sliced bread
speculation
>The OOP fad peaked around the 2000s and has since been declining. That is, OOP describing the most common implementation wherein the functions are also intentionally encapsulated along with the data, whether they need to be or not.
irrelevant/strawman

again: if you're doing OOP, you're supposed to use classes/interfaces to model behavior. if you instead use classes to model your data structures, your codebase will inherently have all the problems people usually bitch about when calling OOP bad.

things like iterators are a proper application of OOP - it's a behavior modeled as a class/interface.
a "sort" free function is a procedural approach rather than OOP; if you want to adhere to OOP, you would have a Sort class/interface with a sort method.

the point is not that being strict to applying OOP to everything is objectively better
there are trade-offs (both positive and negative) using either procedural or object-oriented, and more trade-offs whenever you mix paradigms
the point is that, if you're going to use OOP, use it correctly before you blame the whole paradigm for being bad
>>
>>96105091
it's still deterministic and it's not slower, so what's the problem you doing embedded or something?
>>
>>96105336
so you would add all the extra crap to implement a "sortable" interface and wind up either still using free functions to do the actual work, or just re-implementing it each time?

Then if you need some behavior your concrete interface implementation doesn't provide you either add it to the base class (most common approach) despite being unused in this case, or you create a whole new one to implement, right?

Or do you inherit one interface from another to extend it?

>b-but it's extensible!

With more cruft required than another free function and concrete interface implementations, not generic ones. The FF approach still seems quite a bit better. It also enables you to easily do things like the strategy pattern or external polymorphism.
>>
>>96105529
in case you are wondering, external polymorphism is one solution to having too many virtual functions in your class.

I imagine most OOP design systems wish they had small well-managed non-polymorphic classes to work with.
>>
>>96105336
>use it correctly before you blame the whole paradigm for being bad
The problem is that there's so much garbage OO code that newbies end up failing to discern what sensible OO looks like. It's especially a problem in older Java codebases.
Unironically I think Ruby is one of the few proper OO languages to do it well. Shame it's dead outside of Rails and Gitlab.
>>
>-Os is faster than -O3
It's the software equivalent of when they discovered RISC was faster than CISC. Simpler is always faster.
>>
>>96104942
>how would OOP solve your sort() problem anyway?
by being able to model more cohesively what's sortable, or at least apply a high level of cohesion easier and more cleanly than with a procedural "free" function approach
it's more cohesive if all sortable objects have a sort() method while objects that don't support sorting don't have sort()

>Because every object having it's own sort() function is just another problem to deal with--namely you can't f-ing re-use them.
reuse is a case of extracting behavior to a separate structure, either a class/method or a free function

>At least with a free function you would just call the external implementation you wanted when implementing the member function sort() for the object that is compatible with it.
in OOP this compatibility is inherent by objects "having" the sort() method themselves: if a type has sort(), you can sort it
>>
>>96105336
>not real oop
don't care. you want to sabotage criticism by pointing to some ideal oop that only exists in textbooks and isolated examples. if that's your definition of oop, I have to say that it is pretty useless
so no, you are wrong, oop is the shitcode that exists in real life in real codebases
>>
File: 1648646707405.jpg (73 KB, 540x673)
73 KB
73 KB JPG
>>96105949
So all of these problems remain: >>96105529
but you defer to putting the implementation in a free function after you already know you want to re-use it, which nobody ever does.

>in OOP this compatibility is inherent by objects "having" the sort() method themselves: if a type has sort(), you can sort it

But all you are actually doing is adding structure that doesn't need to exist at all. You are adding more code that does nothing, it doesn't even provide a means of determining if something is sortable or not because we have concepts now.
>>
>>96105949
by the way, if you have visual studio or another modern IDE, create a vector or some type in a multi-paradigm language that supports free functions like C++, then press the up-arrow instead of the down arrow, all of the free functions you can call on it are there at the bottom.
>>
>>96106144
>>96106170
I guess you might not know what a "concept" is though, it's just an interface but better.

It is used to specify that a type must support some operation and/or return something convertible to something the function/class/etc. requires. An interface is much more concrete implementation with specific types, and if you want to change those then you will have to update everything using it.
>>
>>96106144
you don't understand, if you do all this busy work and follow this particular doctrine of the cargo cult, your project will benefit

>inb4 when? how?
not immediately of course, but in an undetermined future lets say, because your code will be more maintainable. I promise
>>
>>96105529
>so you would add all the extra crap to implement a "sortable" interface
yes
>and wind up either still using free functions to do the actual work, or just re-implementing it each time
no, Sort would be its own class, or interface for which there could be different implementations of a sort(Sortable) method

then I will be free to add new implementations of Sortable and new implementations of Sort, and have all my new and previous implementations work with each other
>>
>>96105972
>write shit code
>blame paradigm
>refuse to accept criticism of writing shit code, continue blaming paradigm
>>
>>96106280
...you literally just described using a concept, but "sort" is now a class instead of a free function, and your concept is worse because it specifies a more explicit interface...

I'm sorry anon, but OOP is just not the latest and greatest. It's fine, it's still good and most software in the world uses it--but multi-paradigm is the wave of the future.

Also, we do functional programming better.
>>
>>96106331
>OOP is just not the latest and greatest
strawman again: that was never my point
>>
>>96106434
That's just me trying to break the hard news to you politely, I am explicitly saying multi-paradigm with the architecture divided into algorithms and containers is better than 2000s style OOP.
>>
File: 1683465206502797.jpg (2.09 MB, 1836x2448)
2.09 MB
2.09 MB JPG
Currently working through the vulkan book and tutorial.
Does anyone know good resources/papers for learning more advanced rendering techniques like global illumination or raytracing? I have a bit of experience writing a small raytracer, and basic renderers (stuff like shadow maps, lights, etc.).
>>
Are there any jobs in programming for junior devs? Or any devs at this point? So many programmers lost their jobs, and the market is flooded with poos and fresh graduates. Is there still a job market out there?
>>
What do you guys think is the best way to implement a system with smooth scrolling that makes API calls to a remote server to receive paged data, but the order of the data can change in real time (like for example a ranking by scores that are changing in real time), so e.g. when you go to get the next page worth of data some entries from page 1 may have already slid back to page 2 and you get duplicates? Current plan is to get a list of like 100 entry ids up front and then as the user scrolls fetch the needed entries by ID instead of asking for successive pages of the ranking (which may now be out of order compared to the data that's already on the user's screen). But when the user scrolls past 100 we'd have trouble.
>>
>>96103327
>if you keep sort as a free function, you will either have to create a new sort() for each collection implementation, or modify sort() to support any new collection type. it might be sufficient for small and simple programs but in the long run you'll have shittier code than if it were OOP
iterators and comparator functions my friend
>>
>>96108004
When the user reaches the end you rebuild the whole table.
If the amount of entries is low you can get away with anything.
>>
>>96108040
Well the real thing we need to impress upon OOP afficionados is that they are creating a massive structure that isn't necessary. We have better tools these days, though we do still use things like inheritance in moderation.
>>
>>96108004
>ask for new data
>for all collisions, remove the old rows
>add the new rows
it would be good if you also updated the data when the user scrolls up
but in both cases the result is kind of shit. disgusting even. do you really need smooth scrolling AND paging?
>>
File: 23-48_Sep19_23.jpg (73 KB, 703x825)
73 KB
73 KB JPG
>ask chatgpt if there is a better version of my program
>it gives correct answer
>I accidentally skipped a couple lines copying it and it didnt work, tell chatgpt to rewrite it because it didnt do x
>chatgpt apologizes, tells me im right and proceeds to give me the exact same code as the last time as the "revised" version
>proceeds to gaslight me in pic related
wew thats it for today i think
>>
How the fuck do I get and stay motivated? I was programming a lot, then slowed down and now I just can't seem to get started.
>>
>>96076469
explicit instantiation isn't really going to fix this the way you've got it set up
you actually want to block the template from being instantiated for operator===(Demo<1>::DependentType&, Demo<1>::DependentType&) since you're using an overload instead which is already a concrete function
either way, you need to invalidate the generic template somehow, either SFINAE or constraints
//iirc most constrained template is selected by default so if they were both templates since this is technically the most generic case this doesn't need a constraint
template<int N> requires (N != 1)
bool operator==(const typename Demo<N>::DependentType& lhs,
const typename Demo<N>::DependentType& rhs) {
return lhv.value == rhs.value;
}

//or
template<int N, std::enable_if_t<N != 1, int> = 0>
bool operator==(const typename Demo<N>::DependentType& lhs,
const typename Demo<N>::DependentType& rhs) {
return lhv.value == rhs.value;
}

though frankly i'd do it neither way and just branch inside of the template
template<int N>
bool operator==(const typename Demo<N>::DependentType& lhs,
const typename Demo<N>::DependentType& rhs) {
if constexpr(N != 1) {
}
else {
}
}

i mean for fuck's sake at this point you can pass basically anything to a template, anywhere, and do anything with it, why write specializations you don't have to
>>
>>96103614
Yes, there is
It's kind of a social media backend for decentralized clients
>>
What's the best book for learning Python right now? I want something physical.
>>
i feel like i have learned more in the past 2-3 months of my job (first job) than i did my entire 4 years of college
anyone else relate? i guess this is why they encourage people to do internships and shit
>>
>>96075936
>what are unit tests
gtest is especially good for running the same shit over and over until it finally breaks
>>
>>96109053
I probably shouldn't have included the Demo<0> example in there, it doesn't matter. What does matter is that my compiler isn't deducing the dependent type. I think it might be corrected under something more recent though, as I am under C++17.

>at this point you can pass basically anything to a template, anywhere, and do anything with it, why write specializations you don't have to
As it turns out, I have encountered unexpected matches. I try to make all of my types as restrictive as possible.
>>
>>96093894
>Can you just make a function in C/C++ with a specific name and then call it from a scripting language?
with C code, in some languages, yes (C#, luajit using the FFI library), though with other languages you have to write a wrapper on top of the function that uses a specific interface (Java, regular lua, python)
for C++ you need to flatten out your API to a C one since the ABI isn't guaranteed to be stable, generally you use a code generator and generate C FFI using some sort of IR or using a clang based tool with reflection support
or you use a library with enough template metaprogramming to ease the pain somewhat
if you're from the future you use metaclasses and reflection to automate this

C++ based languages that cross execution environments and have access to a c++ compilation internals like CUDA or HIP just force everything to use itanium (the ABI not the failed ISA) which is probably the road everything's eventually going to head down anyways

>>96093959
>>C++ is a clusterfuck here
it's not, itanium is stable, versioned, and even integrated that GNU language extension that lets users explicitly version their ABIs __attribute__((abi_tag))
it's just the MSVC ABI, and that situation becomes more clear once you understand Microsoft just decided to make COM their defacto stable C++ ABI since it offers additional runtime and safety features like automatically binding to C#

fun fact: bare metal itanium (i.e. not through mingw/msys) on windows has a limited level of support through llvm's C++ ABI library and STL which can be compiled with the x86_64-pc-windows-itanium triplet
>>
is there a specific term for the horrid practice of writing bits of documentation in terms of other bits of documentation? I want to comment on this to the dev of an API

it really pisses me off when I look up documentation for feature X and all it basically says is "it works like feature Y except Z"

just fucking repeat yourself if you have to, don't assume that I know everything about your system except feature X / send me to read something else with a mental list of changes to apply on the fly
>>
vulkan gets better 30 hrs in
>>
>>96109387
at the end of the day the ambiguity should still go away if only one of those templates resolves, it doesn't matter you posted an example with an overload
>I think it might be corrected under something more recent though
probably, i don't know the language versions associated with deduction rules off the top of my head and it might also be affected by other things, like all the additional ways == can be rewritten added by C++20
it's a longshot since i think c++ supports this kind of CTAD implicitly but you tried just writing an explicit deduction guide?
>As it turns out, I have encountered unexpected matches. I try to make all of my types as restrictive as possible.
yea, i know, that's not what not what i meant
you should make the restrictions using if constexpr blocks inside templates wherever possible as opposed to relying on template specialization or overload resolution since you can shove anything in template params and use it in the body of the template directly and you don't need to do a lot of the goofy shit you used to like wrapping values in types or most shit people use SFINAE for
no unexpected matches if there's only one thing to match and you can also localize errors better this way

also you should definitely be using C++20 at the least, i can't imaging going back to pre-concepts templates, i exclusively switched to C++20 and later as soon as the first barely usable implementation was committed to clang
>>
File: FEQpKtHXwAEU4Do.jpg (83 KB, 678x680)
83 KB
83 KB JPG
>>96109607
"it works like feature Y from [completely unrelated program] except Z"
>>
>>96109607
writing it against or in reference to something? maybe?
it pisses me off too
unlike what i think is every other khronos standard GLSL is only available as a PDF and every single GLSL extension is only documented like this, separately from the standard, in a text document, and extensions can reference the standard on a sentence by sentence level
tired of having to read 10+ documents to read one, the vulkan standard is available as an XML with extensions integrated that you can parse and that's where the PDF versions and also things like the C++ API are generated from
>>
>>96110035
>>96109607
An issue here is maintaining integrity. If you repeat yourself, then if you change something in one place it should be changed in all others.

You really need automated documentation for this sort of thing.
>>
>>96108040
iterator and comparator are both interfaces that model behavior
>>
New thread:
>>96110475
>>96110475
>>96110475
>>
>>96090018
Writing it like that doesn't make it any more efficient. You could use a faster random number generator and generate 4/8 indices in one call to your RNG.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.