/tech/ - Technology

Technology & Computing


New Reply
Name
X
Sage
Subject
Message
Files Max 5 files32MB total
Password
[New Reply]


college-grade_programming.png (u)
[Hide] (133.3KB, 3000x3000)
It's like /agdg/ except without videogames. Well there wasn't any videogames to begin with, but now there may be other software.

See also /agdg/ at >>>/v/ for videogames.

What are you working on?
Replies: >>1412 >>2510
There isn't really a screenshot for it, but I just finished improving my mouse input system.

The program now only handles mouse events in 2 cases: either the mouse is doing something on top of the window, or you click-and-dragged outside of the window. It was more annoying to do than it sounds because Windows only fires input events when the mouse is over the window, so you can't drag out from it (which makes sliders and such annoying if they're near the window edge). But if you get global mouse position manually, it doesn't have any information about whether some other window is obscuring yours. Global mouse position is also based on the monitor, not based on the window unlike the mouse move events, so you have to fix that. You also need to detect when you lift a button while the mouse is away from the window (which again Windows doesn't fire an event for), otherwise you get the age old issue where the button gets stuck on until you click on the window again.

I need this because next I'm going to work on a program that has custom controls for moving/scaling the window, and it needs to mostly sit idle so I don't want any unnecessary mouse events causing it to run logic and use CPU.
Replies: >>1418
>>1410 (OP) 
>fixing up emulators & controller tools to not be shit
mostly minor changes but these minor changes were really starting to annoy me
winder.webm (u)
[Hide] (946.9KB, 620x434, 00:19)
>>1411
Got the window UI figured out, now I just need to actually put something in it. This is a remake of an older program, an image viewer of sorts.
Replies: >>1419 >>1456 >>1494
>>1418
what's this? an imgui clone? I haven't seen the previous thread
Replies: >>1424
PSA on toilets:
https://invidious.tube/watch?v=8SUkrR7ZfTA
>>1419
>an imgui clone?
I'm not sure what you mean by that, imgui is an idea about how to manage a GUI. If you mean Dear Imgui then no, I wouldn't call what I'm doing a UI system at all, I needed a bunch of buttons so I just made an array of buttons. The UI is just means to an end rather than a project in itself.
>>1418
Very cool Anon.
Working through the graphics chapters in Stroustrup's PPP2, and working on creating a wrapper library for FLTK that eliminates the need to write C code to use it. The author of the library claims it's 'C++' but plainly it's 'C with classes' at best. Hardly surprising given it's heritage goes all the way back to SGI & the NeXT.

Anyway, when I'm done we should have a very simple to use, very portable, very high performance GUI/windowing system that will run smoothly on even tiny microcontrollers if needed. 

This is an interesting area to learn and touches on a lot of different disciplines, as Bjarne correctly points out. It will be a good learning exercise for me, and will teach me a lot about doing efficient library design using C++.
Replies: >>1461
>>1457
why a wrapper though? wouldn't it be easier to just fork FLTK 1.x and replace raw pointers with RAII pointers, const char* with string_view, char* with string, and function pointers with std::function<...>?
Replies: >>1462
>>1461
>wouldn't it be easier
No, heh it definitely wouldn't be easier. FLTK is a big-ass library (unsurprising given it's basically a full-featured Windowing/GUI system over 30 years in development). So, I guess my reasons are mainly these two.
A) I'd like to have this done before Summer's end, not five years from now.
B) I'd like anons to simply install the FLTK dependency from their own repos, then my code will simply rely on that. 
Taken together, I think the wrapper idea is cleaner & less error prone. Besides, I've already succeeded at this approach for the cURL library, and it works fine that way.

But you're right about using modern C++ programming idioms Anon, they really are a good idea in general.
Replies: >>1463
>>1462
What is the difference between using modern C++ features and free()ing memory on my own?
I understand it seems like automatic but what's wrong with explicit memory management and C idioms?
Replies: >>1464
>>1463
>What is the difference between using modern C++ features and free()ing memory on my own?
Well, the first and most obvious one is, well, you Anon.
>and free()ing memory on my own
>my

Relying on humans to correctly and consistently manage resources properly has obviously been an utter failure. The computer does some things much better than we can, and RAII is one extremely good example of that.
Replies: >>1465 >>1466 >>1493
>>1464
And btw, RAII isn't 'modern' in that sense. It's been a part of C++ from the very, very beginning. Certainly by ARM in '85.
Replies: >>1466
>>1464
>>1465
Right, RAII isn't modern. And I know it's similar to auto-closing fridge doors. Then again, shouldn't people close their fridge doors on habit? It's just lazy or stupid not to anyways.
Replies: >>1468 >>1470
>>1466
Well it's not quite that simple Anon. Computing systems are prone to exceptional conditions. And men (there are no women in programming, really) aren't all that clever at the foresight required to anticipate all those possibilities.

Even if you free resources dutifully in the recommend fashion, exceptional states can often render those steps useless. RAII basically always does the right thing, and it relies on very little else to do so. Certainly not the men involved, for instance.
Replies: >>1472
>>1466
not him, but:
first, have in mind that C++ RAII unique_ptr implementation doesn't have memory overhead unless you use a custom destructor (which you almost never do), and won't affect execution time as long as you use -O1/2/3 (which remove the additional function call on creation).

there are many inconveniences with manual memory de-allocation; just to name a few that come to my mind:
0. let X be an array of structs Y with arrays Z inside. do I really want to write de-allocation functions for all those types? it's going to be exactly the same for all of them.
1. suppose I have a function and I want to insert "early returns" (a common pattern when using error codes); without RAII, I would have to free all my resources before every return statement.
2. I can't make "ownership" explicit with raw pointers syntax, so I'm going to have to document which pointers I'm supposed to free (FLTK does this).
3. many algorithms require ref-count'd pointers. C++ ref-count implementation has been the same for decades

so here are the two main reasons why I use RAII:
>have to write less code for exactly the same functionality
>0 (zero) overhead

just give it a try anon, it stops feeling wrong after the first three or four times. besides, if you are on GNU, you can use gcc -S -O2 <your file> and check the generated x86 by yourself.
Replies: >>1472
>>1468
I see. By using those features, the foresight can be shared and inherited. It makes sense to use them if and only if the programmer knows what they are doing. Blindly following practices just like a pajeet is bad, especially when the execution is not explicit.
>>1470
I will. Still prefer C with class for now, will try adding in RAII to the mix.
1616402034220.png (u)
[Hide] (200.6KB, 421x519)
I should just nuke this thread from orbit before another anon contracts this pajeet aids.
Replies: >>1475
>>1474
What aids?
>>1464
i don't care if the pajeets can do it or if it melts their brain all the more reason to call them retards.
memory management is so easy it doesn't even factor to the difficulty of writing a program usually.

and you are not supposed to use malloc and free regularly inside functions for like whatever.
its methods you should rarely use, insted of using raii learn to use your brain.

all these problems and more can be solved if you just learned assembly
Replies: >>1497 >>1508
image.webm (u)
[Hide] (3.1MB, 648x464, 00:29)
>>1418
>it's fine if I procrastinate and play videogames a bit
>suddenly it's 4 days later
Where does time go

Continuing this, you can now actually view images on it. I don't have a smooth image scaling function yet though, so the image looks a bit messy when zoomed out.
Replies: >>1495
scaling.webm (u)
[Hide] (2.1MB, 598x452, 00:25)
>>1494
Continuing with some UX. The image gets centered to the window when you open it, and also scaled down if it's too big to fit the window. The bottom left button now also works, it toggles between fitting the image into the window, and filling the window with the image.
Replies: >>1510
long_bs.png (u)
[Hide] (330KB, 834x344)
>>1493
>factor to the difficulty of writing a program usually
>use malloc and free regularly inside functions for like whatever
nobody said that. why can't you refute a simple point and have to embarrass yourself?

not him but, assembly isn't hard, it's probably the most simple and easy to learn programming language. most comp-sci students learn x86_64 and mips64 in their first year.

the only good reason to mention asm (x86 in particular) would be to point out the overhead of an additional PLT symbol lookup (1 jmp, ~2 movs, 1 ret) the first time an object is deleted, but only IF the call destination address was not resolved at link time (unlikely).
>>1493
>all these problems and more can be solved if you just learned assembly
But I did learn assembly Anon. I even did it before C and then C++. C++ brings so many benefits to the table, with so little overhead related (usually no overhead) that to me it's an absolute no-brainer to use the language for any resource-constrained projects as long as a build system is supported on the platform. Since today that includes practically every platform it's an easy choice IMO. Some things are better to do in Bash or even Python. But for practically everything else C++ produces the singular best results -- both for size, runtime perf, extensibility & maintainability.

Perhaps in the future some like Golang (if you can stomach the poz of the community itself) may displace C++ for systems programming, perhaps not. Regardless, neither Assembler nor C ever stand a chance of doing so.
Replies: >>1511 >>1553 >>1572
pasta.webm (u)
[Hide] (4.2MB, 1292x788, 00:41)
>>1495
Added more ways to open images. You can now drag images in from a web browser, copy&paste bitmaps from a browser or image editor, and also copy transparent images from Krita and Gimp. Anything that puts a regular bitmap into the clipboard should work, and I think programs like Krita always do that as fallback. I don't know if there's a commonly accepted clipboard format for images with transparency, Gimp and Krita both put a png file into the clipboard, but they use a different ID and name ("image/png" from Krita and "PNG" from Gimp). Not sure what other programs like Photoshop do.

Strangely you can't copypaste stuff from Krita into Gimp. You can copy from MS Paint into Gimp so Gimp does recognize the default bitmap. Both I and MS Paint can successfully read the bitmap data from all 3 programs, so I wonder why Gimp can't read it when it comes from Krita.
Replies: >>1514 >>1547
>>1508
>neither Assembler nor C ever stand a chance of doing so.
>C
C is already the de-facto systems programming language.
Replies: >>1553
scale.webm (u)
[Hide] (2MB, 450x324, 00:21)
>>1510
Smooth scaling now works. It scales in a separate thread when the zoom level changes, in the meantime a quick preview is shown.

This is the first time I'm using threading for any actual purpose, and I already hate it. I can only imagine what a mess it would be to add threading to a videogame and managing a million mutexes for everything. I wish you could use a bracket scope syntax for them, so instead of this:
lock_mutex(cia_killer_mutex);
	// process CIA niggers
unlock_mutex(cia_killer_mutex);You could just do something like this:
cia_killer_mutex {
	// process CIA niggers
}
Replies: >>1515 >>1531
>>1514
I found this book on multi-threaded shared-memory programming to be quite interesting. You can check it out: https://cdn.kernel.org/pub/linux/kernel/people/paulmck/perfbook/perfbook.html
Replies: >>1516
>>1515
>881 pages
I have better things to do with my time but thanks, I'll save it just in case.
Replies: >>1517
>>1516
>I have better things to do with my time
really, like what
Replies: >>1518
>>1517
Programming. Reading that much for what will probably amount to a handful of neat tricks isn't worth stopping programming for. How much would I learn that I wouldn't learn by doing multithreaded programming for the same amount of time anyway? Rhetorical question.
Replies: >>1520 >>1523
>>1518
Skim and skip. You can probably learn quite a bit of tricks that are not easily searchable.
Replies: >>1524
>>1518
>I can't learn to program properly I have to shit on the street
Pajeet, you should be as far away from computers as possible.
Replies: >>1524
>>1520
Sounds like needle in a haystack. I mean I'm sure there's useful stuff there, but nothing I'm going to do for a long time warrants a >500 page book.

>>1523
How about you post your program instead of whining about what other people do.
scaling.webm (u)
[Hide] (3.9MB, 982x682, 00:41)
>>1514
Holding Shift now preserves window aspect ratio, and holding Ctrl will scale the image along with the window. Clicking and dragging with right/middle mouse will scale the image linearly.
The point under mouse will now stay in place when zooming.
The bottom right button now works, it scales the window to the image size.
Nigger rigged my old bitmap text system to show zoom level, and instructions at startup. The instructions text isn't perfectly centered because it includes spaces in the row width, but I'll probably write a whole new bitmap font system sometime.
UI is now visible when dragging stuff even if mouse leaves the window.
Sprites are embedded into the file so the executable is completely standalone. There is a file though, which you can edit to customize the icons, but if the file isn't found then the embedded data is used as fallback.

I think this program is now complete as long as I'm not forgetting anything. Well, I still need to figure out how prevent stb_image_resize from fucking up the alpha channel when it does a smooth rescale.
Replies: >>1535
flip.webm (u)
[Hide] (2.4MB, 514x376, 00:24)
>>1531
There was something I was supposed to add after all: buttons to flip the image.

>prevent stb_image_resize from fucking up the alpha channel
Never mind I'm retarded, I wasn't enabling the alpha channel on the scaled down image, so my own drawing function was ignoring alpha. I didn't realize because it's usually enabled automatically when I load an image file.

Anyway it's done, here it is in case anyone is curious:
https://tsun.itch.io/reference-image-window
It is meant to be a tool that artists can use to view a reference image while they draw.
Replies: >>1548 >>1549 >>1553
>>1510
Nice work lad.
>>1535
I looked around but I couldn't find the source code Anon?
paint.webm (u)
[Hide] (106.8KB, 600x400, 00:07)
Photoshop watch out.

The reason I worked on >>1535 is because I thought it would be a good warmup to what I really want to work on: a graphics editor. I've been working on the UI and design of this program for ages for fun, I'm very happy with how it all looks so now I just have to worry about actually making it.
Replies: >>1553
>>1508
> Some things are better to do in Bash
No, shell sucks ass, unless it is absolutely 100% trivial.

> with so little overhead related (usually no overhead) 
OOP adds a memory overhead. And C++'s convenient features (good example is vectors which are actually truly convenient) do things behind your back (by design) which is an issue when programming systems software or embedded systems.

> Golang (if you can stomach the poz of the community itself) may displace C++ for systems programming,
Golang will never displace or replace C nor C++. Golang is not good for systems programming. Golang is good for creating tools and, in general, Go is a less harmful python replacement.

> C++ produces the singular best results for maintainability
Not unless you and your team follows a strict style guide that tells which features you can use. C++ has a ton of features and C++ is way more complex language than C.

>>1511
> C is already the de-facto systems programming language.
Either C or "C-style" C++ (without OOP or anything that uses OOP or anything that has a big overhead in general) C-style C++ can be better than C because the C++ compiler does more checks and you get some extra features. 

>>1535
>>1549
Good Job Anon!
Replies: >>1554 >>1555 >>1564
>>1553
>shell sucks ass
Do you mean POSIX shell sucks or the concept of shell sucks? Why?
Replies: >>1556 >>1557
>>1553
C++ can help create much more maintainable code than C ever can. And as with much of the rest of your postions in this post, you have the point about strict guidelines exactly backwards: the only way you can ever hope to have maintainable large C projects is by them. Well-written C++ naturally tends to enforce the designer's intentions well, by design. It's much much easier to creating a steaming pile with a good C developer's code than with a good C++ developer's.

>C-style C++ can be better than C because the C++ compiler does more checks and you get some extra features. 
It's true that C++ compilers are better than C ones, but 'C-style C++' is neither, and sort of an abomination. C developers may like that shit, but certainly no professional C++ developers do.
Replies: >>1557 >>1568 >>1572
>>1554
I'm not him, but both suck and I'm angry. Angry about shell.

POSIX shell is completely useless for any serious programming, see http://www.etalabs.net/sh_tricks.html for a good rundown on some of the myriad ways it sucks. The other extension shells aren't much better, sh is just the most outrageous of them all. Writing a shell program that handles all inputs correctly is straight up impossible because there is so much hidden and retarded "helpful" action that you can't possibly keep all of it in your head.

Almost everything has to be prefixed by some gargantuan BE_RETARDED=NO --dont-do-the-retarded-thing --no-really-stop-being-retarded song and dance, with no way to get rid of it once and for all. I doubt you knew all of the pitfalls in that link, and before you misunderstand this as a challenge to try and learn them so you can be 1337 Unix Greybeard, let me say that memorizing that shit is a colossal waste of your time and runs counter to the point of a computer, which is to automate work, not create it. The reason you see all these shitty to mediocre "scripting languages" pop up again and again is that the shell sucks.


The concept of a shell as found in Unix sucks because what you get is a really retarded programming environment where everything has to be built from global variables (called files), byte streams and fuckhuge variadic functions (called programs) that take opaque byte arrays (called arguments) and return a small integer (called return code). Anything beyond that must be reimplemented by every single program and thus ends up wildly inconsistent.

What you're doing in the shell is really programming - the environment and language are just so thoroughly crippled and useless that you don't even recognize it as programming half of the time. The classic example of a system that does this right is Genera, but really any proper programming environment would be an improvement, even if it's just the javashit REPL of your browser. When you hear windowsfags rave about Powershell, that's because it fixes some of these issues. I don't know how many of them though, wild horses couldn't drag me to Microsoft land anymore.
Replies: >>1557
>>1554
> Do you mean POSIX shell sucks
Yes and so do all POSIX shell look-a-likes.

>>1555
> you have the point about strict guidelines exactly backwards
Let me reiterate: because C++ has so many features and so much more complexity in the language, you simply cannot use all of the features. If you are working with a team, you should pick the allowed features to prevent your codebase from becoming a mess.

>no professional C++ developers do.
Like I said, C++ is not suitable for embedded systems or resource (especially memory) constrained environments/software (Unless, you use "C-style" C++)

>by design. It's much much easier to creating a steaming pile with a good C developer's code than with a good C++ developer's.
Define what you mean by "steaming pile" exactly. are you complaining about Cstrings again? (I never claimed that C has good support for strings) or are you complaining about the C type system (which I never praised). Don't tell me you are actually comparing a legacy codebase (that can date back decades) to a modern one. Finally, if you are complaining about muh header files, then you must realize that modules were introduced to C++ just recently.

>>1556
> I don't know how many of them though, wild horses couldn't drag me to Microsoft land anymore.
FYI, PowersHell also works on GNU/Linux: https://github.com/PowerShell/PowerShell (but I have never used it on Linux)
Replies: >>2140
>>1553
>OOP adds a memory overhead
OOP != C++. you can do OOP with C. actually, most big C projects do, in an inconsistent and inefficient way (see the linux kernel or any other C project with more than 20K LOC).

>vectors which are actually truly convenient
[citation needed]

>do things behind your back (by design)
[citation needed]

>which is an issue when programming systems software or embedded systems
if you don't know the difference between stack and heap you shouldn't be near embedded systems anyway. literally not a language problem.

>Not unless you and your team follows a strict style guide that tells which features you can use.
guidelines are just common sense, they only exists because companies keep hiring uneducated retards to drive wages down.

>C-style C++
>what is const
>what is constexpr
definitely not C

have you ever programmed an embedded device? people don't use C because they want, most of the time they do because there are no C++ (or any other language) compilers for those ISAs, and companies are too greedy to spend money developing a C++ compiler just for constexpr and consteval.

internet 1337 h4x0rs praising handwritten vtables are mentally ill
Replies: >>1572 >>1594
>>1555
>It's true that C++ compilers are better than C ones, but 'C-style C++' is neither, and sort of an abomination. C developers may like that shit, but certainly no professional C++ developers do.
Mike Acton, former Engine Director from Insomniac Games, and current Principal Engineer at Unity, in charge of the complete overhaul they're doing of their backend to try and make their performance not dogshit. Well known advocate of Data Oriented Programming, one paraphrased quote from him is "we only hire C++ programmers because they're easy to find, then teach them to write C in C++ instead"
Replies: >>1569 >>1593
.jpg (u)
[Hide] (24.2KB, 600x400)
>>1568
Kill this anon, he is refusing to accept C++ into his heart and soul. This is unacceptable. Not using [latest C++ features] and believing in the C++ committee is the highest form of sin. C++ is perfection, C++ is god. Programming anything without using at least 7 C++ features in it is bad coding practice.
>>1508
>>1555
honestly, we can agree to disagree if you don't want to discuss this any further since this kind of discussion is not very productive.

>>1564
> OOP != C++.
true, but OOP is one of the biggest features of C++.

>vectors which are actually truly convenient
>[citation needed]
>do things behind your back (by design)
>[citation needed]
the reason why vectors are convenient is that they do the allocation/growing behind your back. vectors use more memory than C arrays because vectors allocate more memory than what is actually needed.

> literally not a language problem.
yes it is. if you use those language features or stdlib functions/types you have less precise control over how the memory is being used. memory is usually the most precious resource in embedded systems and adding more memory is going to increase the cost (per unit) of the final product.
Replies: >>1584
forcefield.gif (u)
[Hide] (985.9KB, 320x240)
I want to make a jigsaw puzzle engine for browsers, what's the best graphical interface to use for this? Was looking into WebGL but would like a second/third/nth opinion.
Replies: >>1576
>>1574
You literally have no options besides just drawing shit on a canvas directly, which is just going to be slower.
Replies: >>1583
>>1576
this, unless you want to port sdl2 to javascript, on top of webgl obviously
>>1572
>the reason why vectors are convenient is that they do the allocation/growing behind your back
doing something that you explicitly asked != doing something behind your back. all the documentation is pretty straight forward about memory allocation (which is mostly common sense, you shouldn't need documentation to know how std::vector works)

>vectors use more memory than C arrays
because they're different data structs that serve completely different purposes. if you don't need dynamic allocation, you should use std::array which is equivalent to C arrays but with more compile-time information and without the pitfalls (degradation, etc).

>if you use those language features
not a language feature. constexpr is a language feature

>stdlib functions/types you have less precise control over how the memory is being used
then don't use them? do you really need someone to explain that to you? that you have to choose the right tools and not be a complete retard?

namespace and std, not malloc and free ok. praise bjarne
Replies: >>1592
>>1584
>praise bjarne
Keke. There's a recent video interview done with him. This lockdown kikery is obviously really wearing on him over the past year. I'm a bit concerned over his health now tbh.
https://www.youtube.com/watch?v=8aIqIBmNJyM

BTW, you really seem to know what you're doing around the computer. Have you ever taught programming Anon? I have a thread intended to help complete newcomers get up to speed with C++ on our board, but so far no one's participated in it. I'm wondering if you have any tips on how to go about it properly?
>>1568
I'm quite aware of Mike's positions, and saw his presentation as the closing keynote for CppCon14. Mike's kind of a pandering ass, and laughably his only real agenda that day was to spew out verbal clickbait over his disgust with the audience he was being paid to serve. Maybe warranted, maybe not. But disingenuous of him at best.

But he is exactly right about keeping the cache line occupied as a performance key. The C++ Committee -- indeed all the systems programming world -- was quite aware of how the prefetcher works long before Acton took the stage that day.
do_not_want_wait_i_want.webm (u)
[Hide] (1.3MB, 744x408, 00:10)
>>1564
>actually, most big C projects do, in an inconsistent and inefficient way (see the linux kernel or any other C project with more than 20K LOC).
This. Double-nigger this. If it weren't for the fact we have to actually wade through these steaming piles of ad-hoc chicanery on a regular basis, these DO  NOT WANT, DO NOT WANT, DO NOT WANT. oh wait...i want 
>
manchildren rants would be pretty laughable.

NIHS is basically a form of mental illness. One the rabid C crowd suffers from deplorably.
babbys_engine.jpg (u)
[Hide] (75.4KB, 500x500)
>learn assembly
>it's just more verbose and specific C without a standard library
I thought it was supposed to be super hard and impossible to make programs with. Now I want to make a programming language that's just macros for assembly code and some syntax features.
Replies: >>1602 >>1608 >>1621
>>1596
Check out HLA or LLVM.
Replies: >>1604 >>1605 >>1608
>>1602
>HLA
/throd.
HLA.png (u)
[Hide] (119.1KB, 1012x1024)
>>1602
Very interesting but I don't know what it has to do with programming.
Replies: >>1608
>>1596
>>1602
>>1605
HLA as in High Level Assembly (check out The Art of Assembly Language, 2nd edition by Randall Hyde) If you don't like HLA, check out the 1st edition of The Art of Assembly Language instead.
I dont know shit about computers let alone languages that make things happen, but can anyone help me understand the whole ordeal behind people exploiting terry davis image/work on cuckchan and holy c itself?

What made holy c different from the other c stuff and languages/engines you guys use?


I honestly just want to understand how fucked in the head you have to be to exploit a dead person to sell ugly clothing merchandise and the retards buying them
Replies: >>1611 >>1612
>>1610
The fuck are you talking about? How are people "exploiting" terry? What's going on?
Replies: >>1612
7bcd98a9d4d203f6f70961357368d4ffc5225506a590ab7e100b342986937ecc.png (u)
[Hide] (676.4KB, 640x651)
DO_IT_LIKE_A_WHITE_MAN.mp4 (u)
[Hide] (409.3KB, 640x368, 00:09)
tad.webm (u)
[Hide] (2.4MB, 429x592, 00:25)
182ecbcca3888478904e4b0a5194aec16aa1cfba16d3fd089c94974c3e3ee777.webm (u)
[Hide] (4.9MB, 200x150, 02:00)
>>1610
> https://archive.org/download/TerryADavis_TempleOS_Archive/videos/
> https://archive.org/download/TempleOS_ISO_Archive
> https://web.archive.org/web/20170221041504/http://www.templeos.org/
> https://web.archive.org/web/20170304224627/http://www.templeos.org/Wb/Doc/HelpIndex.html
> https://web.archive.org/web/20170204193807/http://www.templeos.org/Wb/Doc/Welcome.html (important)
> https://web.archive.org/web/20161129044519/http://www.templeos.org:80/Wb/Doc/FAQ.html
> https://web.archive.org/web/20170204193809/http://www.templeos.org/Wb/Doc/Charter.html (important)

TempleOS's Features
possible language: html, relevance: 8
* Oracle in with <F7> for words or <SHIFT-F7> for passages.  See tongues.
* x86_64, ring-0-only, single-address-map (identity), multitasking kernel with multicore support.
* Master/Slave MultiCore 
* Free, public domain, 100% open source.
* 64-bit compiler/assembler for HolyC.  Truly compiles, doesn't interpret.  Just-in-Time and Ahead-of-Time compilation.  With JIT, no need for object or exe files.
* No 32-bit krufty code.
* 640x480 16 color VGA graphics.
* Keyboard & Mouse support.
* ATA PIO Hard drives, support for FAT32 and RedSea file systems with file compression.
* ATAPI PIO CD/DVD support with ISO9660 file system.  Can make bootable ISO9660  ISO files so you can roll-your-own distro's.
* Partitioning tool, installer, boot loaders for CD/DVD and hard disk.
* Editor/Browser for a new Document Format.  Source files and the command line window can have graphics, links, icons, trees, colors, super/sub scripts, margins. Everything is seamless through-out the tool chain.  No need for separate resource files.
* 8-bit ASCII, not just 7-bit.  Supported in entire tool chain.  <CTRL-ALT-a>
* Graphics in source code, no resource files, graphic sprite editor. <CTRL-r>
* 64-bit pointers.  All memory, even more than 4Gig, can be directly accessed by all tasks on all cores at all times.
* Ring-0-only.  Highest CPU privileged mode at all times.  No off-limits insts.  No time lost changing modes or address maps.  Switches tasks in half a microsecond.
* 2D/3D graphics library
* Real-time fancy differential-equation solver for physics engines, to use in games.  (Adaptive step-size Runge-Kutta, interpolated for real-time.)
* Auto-completion, jump-to-source tool called AutoComplete with Dictionary.
* Window Manager.  Pan scrn with <CTRL-LeftDrag>.  Zoom scrn on mouse cursor with <CTRL-ALT-z>/<CTRL-ALT-SHIFT-Z>.
* File Manager, <CTRL-d>.
* Code profiler, merge, diff utils.
* PC Speaker support with many hymns.
* Music composing tool.
* Many games, demos and documentation.
* All source code included.  Only compiles with the included TempleOS compiler and assembler.
> I dont know shit about computers
Read K&R, Learn HolyC. Install TempleOS. Entertain Mr. God.

> What made holy c different from the other c stuff 
Terry A. Davis improved the C language (Basically, Terry added some features and changed it so it's easier to use as shell language for TempleOS)

>>1611
They are probably still selling TOS t-shirts and mugs. Terry said it's ok.
a_serb_in_his_habitat_and_with_his_winter_fur_on.jpg (u)
[Hide] (141.7KB, 1024x693)
If you pick your programming language based on how small the statically linked hello world is you can't go wrong.

>>1596
All the mystification of assembly as some impossible god-level shit pajeets made really gets to one's head, makes me wonder what else they managed to sneak into my thoughts.
t. programs 8086 assembly with JWASM on DOS.

I'm not sure if Ken Thompson was held at gunpoint while he worked on Go or if age got to him, but when he made C he understood what programming meant. He wrote a language that simultaneously provides only abstractions that cleanly and efficiently map into assembly, and provides all the useful abstractions a programmer might want.
This is the definition of a good programming language that modern languages just don't understand. Modern languages are about enabling ignorance and hiding the machine away like it's evil.
C on the other hand shows you that after the machine has what it wants, you can have what you want too, but only if a skilled language designer makes that his goal.
Replies: >>1637 >>1644 >>1645
>unironically posting the trannyme book
shiggy.
Terry would call your shit out for being a FUCKING NIGGER
Replies: >>1631
david_wheeler.jpg (u)
(4KB, 148x185)
>pajeets made assembler
Why does the BO allow this diversity-hire tier glownigger shit here? Why hasn't he run them over yet?
Replies: >>1629
>>1628
>I can't read
>>1627
calm down, wigger. it's just a joke.
hapas are a joke. degenerate faggots are not, except as udderly cow fodder.
>>1621
>If you pick your programming language based on how small the statically linked hello world is you can't go wrong.
If everything you write is on that level, sure. I don't particularly care how my compiler optimizes trivial programs because that's not what I spend most of my time on.

>He wrote a language that simultaneously provides only abstractions that cleanly and efficiently map into assembly, and provides all the useful abstractions a programmer might want.
Except for overflow flags, proper strings and arrays, advanced control flow, useful macros, precise control over data layout... If you're looking for nonsense that silently sneaked into your thoughts, look no further than the deification that C went through. C was a product of substantial poverty (take a look at the machine Unix was made for) and perfectly appropriate at the time, but it's a joke of a language outside of that context. It wasn't even particularly efficient originally, all that came through later work and often clashed with the original design - that's especially visible if you compare K&R with the shameless pilpul over undefined behavior of today.
>>1621
>If you pick your programming language based on how small the statically linked hello world is you can't go wrong.
<small automatically == better
That depends. If you are on a tiny, tiny microcontroller or sensor where size is of utmost concern then sure, that's correct. However, most of us (and the rest of the world) care more about wallclock perf. In that case, increasing the memory footprint of the image in exchange for much, much higher performance is the proper course. Either C or C++ can allow you to make these kinds of tradeoffs, but few other languages can. Assembler doesn't count b/c I don't want to spend six months of my life managing to pull off something I can do instead in two seconds with -O3

As with all engineering, there are always tradeoffs to consider, with different ramifications. The only absolute guarantee we have going in is The 2nd Law of Thermodynamics. Beyond that, it's a progression of exploration & creativity. 

>tl;dr
Don't presume Anon, test.
GNU_face_when.png (u)
[Hide] (841KB, 994x658)
>>1621
also
>but when [Thompson] made C
wew
>>1663
Soydev > nodev.
Replies: >>1665
>>1664
I'm inclined to disagree. There's a strong correlation between knowledge of computers and being a complete fucking faggot.
Replies: >>1667
>>1665
>taking pride in having 0 computer knowledge
As the kids would say: the absolute state of /tech/
Replies: >>1668 >>1669
>>1667
> write minecraft scripts
> ilook guys im a foking programer tech god
Replies: >>1671
>>1667
You should some pride in your reading comprehension if that's what you took away from my post.
>>1668
>14 year olds writing minecraft scripts are more computer-literate than you
Replies: >>1672 >>1889
>>1671
sippycup 4 drinkypoo pls
nenewithbook.jpg (u)
[Hide] (84.3KB, 1191x670)
>>1671
>cute anime girls completely outclass you
I've read a lot of quality source code, gone through a book about proper practices, read plenty of good blogposts and talks by people over the matter, and learned at least this much.
Now I write really good code but can't come up with the most basic of programs.

rate
Replies: >>1905 >>1924
>>1903
>can't come up with the most basic of programs
What do you mean? Do you lack ideas or knowledge on algorithms/libraries?
Replies: >>1910
>>1905
Lack of knowledge on algorithms and libraries.
Also I'm extremely uncreative so I'll have trouble making anything I don't already know the recipe for.
Replies: >>1913
>>1910
then you never wrote shit or even tried to you idiot 
I spent years writing while( string[len] != '\0' ){ len++;} instead of strlen() and doing string manipulation by hand, until I discovered  strings.h, which was part of the fucking standard library the whole time, I never knew so  I broke my fucking balls putting str[end]='\0' everywhere while getting ptsd from memory corruptions and segmentation faults yet I still got shit done without any libraries
youre either lazy or fucking stupid, and theres no creativity involved, you write down the instructions and then translate them into code 
[what I want to do ] 
// print nigger x10 times
[ trying to figure out what code will do this ] 
printf() will print nigger, so put printf() into a loop for x10 
[ code ] 
for( i=0; i<11; i++) {prinf("nigger");}

wow, master coder
stop being a lazy nigger
Replies: >>1914 >>1926
>>1913
>I spent years writing while( string[len] != '\0' ){ len++;} instead of strlen() and doing string manipulation by hand, until I discovered  strings.h
What is wrong with you? Are you one of those subhumans who learn through Youtube tutorials?
>theres no creativity involved, you write down the instructions and then translate them into code 
Only for exceedingly trivial toy programs, you can't implement printf with that for instance.
>for( i=0; i<11; i++) {prinf("nigger");}
That will print nigger 11 times.
Replies: >>1916
>>1914
no a fat book that must be 50 years old or something that I never bothered to finish once I read the beginning , once I knew basic syntax I didnt bother to learn more, I could do anything I wanted which is the point, lack of knowledge is bullshit if you know the syntax because its just translating instructions at that point, I had to make my own libraries because I didnt know they existed, I even made my own version of sed and grep because I used them so much in bash and didnt know about the c regex engine I never cared because I immediately made them myself when I needed it, massive waste of time sure but I literally didnt know any better and just proves theres no excuse if all you is the basics
and it doesnt matter how complicated the software is, its always just a series instructions, a --> b --> c --> etc., doesnt matter how long or complex you make it, something has to happen when something else happens, if you know that then you dont need creativity or abstract libraries, you just need to know what has to happen and translate the instructions into code, in fact if creativity was involved then the fucking compiler wouldnt even work, by definition everything has to be a set of standardized instructions thats how computer works, anyone thats written assembly is probably more familiar with this mentality since there you really see what its like giving direct instructions 
its more logic and structuring , the only time you would be creative is in optimization  and EVEN there the compilers O2 flag will optimize the binary to near perfection so effectively there is zero use for creativity
>>1916
There is creativity in finding non-wageslave ideas, structuring projects and coming with with new algorithms. Once you get the idea pinned down, there isn't much creativity involved.
>>1916
>learning C through trial and error
>thinks optimization is code tuning
Imagine the UB
Replies: >>1920
>>1919
unironically yes
UB is my forte, its why I got into coding to begin with, I got into c only because I wanted to make hacks for CS1.6 years ago, started with hooking processes and manipulating memory addresses and then eventually more sophisticated ones using dll injection as I got better at coding, maybe thats why I dont give a shit about soydevs and soy programming, Im conditioned to think about actual runtime and not pseudo code 
made some cool malware too, a reverse tcp shell that used a priv-esc exploit that gave you full access(for winfail obviously) this was when msfpayload became popular with scriptkiddies and not even x86shikataganai would get you past gay antivrus because they spammed the msf fingerprint so much, so you had to make your own, and mine was sick could even turn the host into an ftp server to steal files or send goatse to set as the background, this was also when godamn adobe motherfucking flash, the virus of all viruses, was still considered safe 
those where the golden days, the days before soydevs
Replies: >>1921
I_can't_believe_this_story_you're_telling_me.webm (u)
[Hide] (557.3KB, 490x360, 00:03)
>>1920
>l33t haxx0r
>can't even print nigger 10 times without getting it wrong
>>1903
I wouldn't trust an architect that's "gone through a lot of books" to build me a house, unless he has actually completed projects. If you're on Linux, there's so much unoptimized, barely working dogshit code in mundane utilities that you will be forced to think "why don't I just write this shit myself" every day. This will show you if your code is actually good, or just golfed into a working state on hello worlds or whatever the fuck you were writing that can't be considered basic programs. Or you can just get a job and do something else as a hobby, like 90% of normalfag programmers.
Replies: >>1929
>>1916
This might just be the dumbest thing I've read on this board.
Replies: >>1927
>>1913
>>1916
I've heard of mount stupid but this is truly out of the fucking stratosphere.
Replies: >>1927
>>1925
>>1926
N00b passing by, why is he stupid?
Replies: >>1928 >>1933
>>1927
he made a typo on the internet can you believe it
Replies: >>1936
sammies.jpg (u)
[Hide] (121.6KB, 960x720)
>>1924
> If you're on Linux, there's so much unoptimized, barely working dogshit code in mundane utilities that you will be forced to think "why don't I just write this shit myself" every day.
Yes, I've seen plenty of it.

Retard-tier string manipulation. 
Dirty code bases with trailing whitespace everywhere, style violations everywhere. People who have never heard of enums and keep using the preprocessor for constants that fit an int. 
People who write all the functions with no top-level comment defining their interfaces so you have to read the function infer the details of the parameters and return values. Hueg source files full of obtuse code and with only 2 comments, those 2 comments spell out the obvious.
Using all the booleans at the same time. true/false from stdbool, their own #define TRUE and #define FALSE, and 1/0 integer literals.
Premature optimizations that make no sense. I've seen people use if-elses to get rid of modulo operations, I guess they heard modulo is slow..
Programs that are practically rewritten for every platform they run on. Huge #ifdefs and #elifs enclosing most of the source.
Garbage-tier file separation where there may be a file for graphics and another for sound but functions for those are everywhere.
People implementing a basic bitch binary search instead of using the stdlib, modulo as a hash function.

I haven't even gone through all that many projects.
I keep asking myself where those people learned C. I fix up quite a bit of code to gain experience and pad out contributions for a possible job, but the kind of people who make those mistakes are often the kind that will never recognize them or even care if they recognize them.


What do you recommend for learning to design bigger programs btw? I keep inching towards it but I'm not making particularly big progress. Reinventing the wheel daily is not really the way for doing those kinds of things, learning correct techniques from others is.
Replies: >>1931
>>1929
Lurk kernel mailing list for people shitting on other's code?
>>1927
Because he builds things by himself instead of listening and believing every single thing that soy drinking C++ enthusiasts from India who read books more than they actually program think. This is literally illegal and wrong and we should DOX and assassinate him to restore balance.
Replies: >>1936
>>1928
>>1933
Samefag harder.
You know, lately I've been swearing  a lot 
over some fucking piece of shit software
that has been over hype for more than half a decade. Look, if you gonna make a full featured software that is big and useful, at least make it less cumbersome and have no margin of shitty errors. For whatever reason, a lot of dev out there doesn't put enough effort on providing error exception logs or warning sign for end user to debug. When shit goes wrong, nothing useful error is being reported other than segfault. Because of that, users have to waste their time finding solution on the internet rather than able to fix themselves. Another thing is the UI design. Dear fuckhead, not everyone here run a 1080p resolution screen so why the fuck do you have to design a UI that is unscalable and big. A lot of these wasteful spaces could have been safe for the use of useful option button but no, they like to put the useless spaces there that has no use whatsoever. Fucking retard!
Replies: >>2012
>>2010
making something retard proof means you end up with thousands of lines of garbage checks throughout your code that make your shit unreadable and impossible to manage, its easier to just have a global "go fuck yourself [errorcode]" function for when the user is too stupid to read the instructions
Is it okay to talk about someone else's project, as means of motivation?
Replies: >>2017
>>2015
No. You're not allowed to talk about projects, including your own. You're only allowed to tell people that they're doing everything wrong and demoralize and blackpill everyone and everything in sight.
Replies: >>2031
roman.png (u)
[Hide] (536.9KB, 1920x1050)
Let me tell you about what I consider to be one of the very well written programs I've had the pleasure of using; Persistence of Vision Raytracer, also known as POV-Ray.
This program was initially made in the late 1980s by one person, who was later joined by a handful of contributors, and released as "DKBTrace". That was back in a time when 3D software only existed as highly specialized packages that were business-oriented and too expensive for home users, the idea of a 3D program for the common man was completely alien. Enter David K. Buck, who made a 3D program that was not only free, but also open source and cross platform. Granted that it was a purely CLI program, it still compiled and ran flawlessly on MS-DOS, Unices, Macintosh, and Amiga, without any libraries or toolkits too. Needless to say the program was a total success.

So what was the secret? Good programming practices, nothing more nothing less. DKB wrote highly portable, strictly standard compliant code. He used proper indentation and documented all his files by writing comments inside them, while also providing clear and straightforward compilation instructions for every system. He also referred to theoretical books and academic references when implementing functionalities, and took inspiration from an existing raytracer. He used C, naturally, but that is beyond the point... All these practices carried on from DKBTrace to POV-Ray, the "rebranded" version of the program released in the early 1990s, which is still being developed today.

What's astonishing is that all these ancient pieces of software still compile on today's machines. I grabbed the POV-Ray 2.2 source from 1993 and compiled it with GCC, and to my surprise it compiled gracefully without spitting a single error. I was also able to compile the old DKBTrace from 1990/1991, after only a small tweak to the config file inspired by the one from 2.2... The reason I'm writing this is to bring attention to this beautiful piece of software as living proof that timeless code is very possible, and also to express dismay at newer pieces of software that are the complete opposite. Ever since I began my linux journey and started compiling other people's programs, I would often encounter extremely messy projects. Errors everywhere, heavy reliance on OS-specific code, lackluster or even outright nonexistent compilation instructions, dependence on obscure poorly written libraries or worse, dependence on custom versions of libraries that are no longer available...etc. It's particularly awful with recent projects, barely a couple years old and already aged like milk. We are living in a time where building robust code is easier than ever; cross platform libraries and frameworks, build systems, automated tests and what have you are all freely available, yet software is worse than it's ever been.

You have no excuse to make shit software. Learn from history and use every tool at your disposal. Write your code to be timeless... Otherwise you are part of the problem.
Pic related, rendered using DKBTrace.
Replies: >>2026 >>2027 >>2028
>>2025
>Good programming practices
Where can I learn it? Schools are useless, books are boring, just-code-it doesn't bring good programming practices. Am I supposed to read programs like POV-Ray to learn this?
Replies: >>2140
>>2025
That generally means you have to do more work yourself (as opposed to gluing together random libraries with minimal effort), and have discipline and high self respect, and most importantly taste for what's good. The way I see it, most programmers today are the programmer equivalent of mobile game players or fast food junkies. They don't have any taste for what's good and only see the very surface layer of things, aren't willing to put in extra thought or effort to get something of higher quality, will make excuses to justify their behavior and even put it on a pedestal like the better things aren't actually better or worth it.

I always try to make my programs as self-contained and self-reliant as possible, and not use any external tools besides the compiler. I only use libraries when there's some insurmountably complicated task which I could never competently do myself like parsing font/image files or videos.

There's a subtle art to writing simple code, I'm still learning all the time. I used to have weird naming schemes and I always wrote up all kinds of "systems" so I can re-use them later and mix and combine, but I've come to think that it almost always just overcomplicates the problem and often doesn't allow me to do what I need to anyway. The one thing I'm still struggling a lot with and currently working on is text rendering, I have various UI and text input systems but I want to get rid of most of them and just make something simple for text. It's hard to come up with something that's fast and simple and flexible though, like how do you organize text characters into a sprite sheet for the GPU, and how do you manage those spritesheets when you suddenly need some nippon runes?

Honestly I think the biggest problem is education. Even if I want to learn how to do X well, how am I supposed to find that information? Almost every program and game has text in it, yet I have no idea how to search for good ways to do text character rendering. I think in the past before the internet, you might think it was harder to do things, but I think it was actually easier because although it was harder to find information, when you found information you could generally trust that it's valuable. Now you have so much information that it's nearly impossible to extract the good information from the sea of shit and opportunists and agenda pushers and search engines giving pop culture results instead of something useful.
Replies: >>2028 >>2140
>>2025
The wonder of actual standards. I had a similar experience with a piece of Common Lisp code from the 90s and hear Ada is similar. People cannot shut their traps about how supposed "bitrot" means that everything must be maintained (read: go through regular churn) or magically stop working, but if you step back and think about it for a moment, it becomes immediately obvious that it isn't the program itself that is rotting but its environment. The problem is framed in a way that completely obscures its source so that the question "why is the environment changing to begin with" never occurs.

I saw the nature of this "bitrot" first hand when I had to run with an old version (4.9.4) for a while. Apparently at some point they decided that the default C standard should be changed from gnu89 to gnu99 or gnu11 (I forget which) because IT'S THE CURRENT YEAR. This is a completely pointless change that maybe saves someone somewhere eleven characters in a makefile, but instantly lead a bunch of retards to remove standard declarations "because we no longer need to declare C99", resulting in minor but completely pointless breakage to no benefit whatsoever. You may call it silly to get mad about this, but it's almost nothing but inane shit like this. No actual work is being done.

Programming has stopped being about automating work and has become a job creation scam. You still work the same hours, but instead of flipping physical levers you flip digital ones. Go through the changelogs of some software you use. How many changes actually eliminate work and how many are just stupid bells and whistles? Keeping up with pointless churn? Replacing old with new solely because the new one is shiny? Things that shouldn't have been in there to begin with but absorb hour after hour of programmer lifetime? It's depressing.

>>2027
>Honestly I think the biggest problem is education.
I agree. Classically this is the job of schools and universities - to cut out the noise and collect the signal - but anyone who's seen one from the inside knows they don't do that job anymore, especially when it comes to programming. I still remember the diatribe by MIT about how SICP is outdated "because programming is about trial and error science with libraries now". The CS sections of university libraries are lined with worthless schlock - what the fuck is jQuery For Dummies doing next to Knuth? It's civilizational rot, plain and simple.

As a result the top of the field is mostly made up of autodidacts, who are by their nature combative and constantly reinventing wheels. You see this attitude here on imageboards a lot, where people refuse to pick up a book out of principle. In a way you can't blame them, but at the same time it just perpetuates the problem. I have no idea how to combat it but dear god I'm turning into Uncle Ted with every passing year.
Replies: >>2029
>>2028
>refuse to pick up a book out of principle
What book do you suggest then?
Replies: >>2032 >>2035
>>2017
>blackpill everyone and everything in sight
Blackpill doesn't mean what you think it means.
Blackpill is a problem with no solution. It does not imply depression, suicide, violence or any other normie made-up crap. Anon, don't spread the normie crap.
>>2029
For what topic?
Replies: >>2036
>>2029
>actual standards
How to write timeless software and to structure programs.
t. college CSfag
Replies: >>2036
>>2035
meant for >>2032
What are some programming languages whose creators and lead developers are not fag worshippers?
Replies: >>2503
Working on a bulletin board to run as a shell with ssh access. Going to make a text converted image captcha for signup using aalib.

>>1557
>C++ is not suitable for embedded systems or resource (especially memory) constrained environments/software
>(Unless, you use "C-style" C++)
I know I'm replying to a 2 month old post, but this shit gets me mad as an embedded dev who uses C++. The real reason C++ "isn't suited" for embedded is because through the 90s and 00s no microcontroller producers were willing to maintain a C++ toolchain because it's so much more complex to implement than C. NOT necessarily heavier on the device! These day's you're hard pressed to find a MCU without a good C++ toolchain. C++ evangelists somehow get it into their head that C++ programs have to use half of the massive STL (not to mention boost) or else they're not using "real" C++. Sorry for the rant, it just seems like C++ fanatics try to actively discourage embedded devs from using it.

>>2026
Read well written programs. Write the best programs you can and then figure out how you can make them better.

>>2027
>Even if I want to learn how to do X well, how am I supposed to find that information?
Jesus Christ you sound like a whiny faggot. Boohoo there's TOO MUCH KNOWLEDGE on the Internet! Just start somewhere and you'll find your way to what you're looking for: read an ancient book, pick up a cutting edge paper, it doesn't matter; just GO! Stop being so goddamn helpless.
F.gif (u)
[Hide] (18.4KB, 152x170)
G.gif (u)
[Hide] (22.2KB, 193x151)
U.gif (u)
[Hide] (20.1KB, 177x160)
>there's an esoteric mystery bug in a json parser I made months ago
>consistent but doesn't replicate itself in 2 different strings that both have the same structure
i-it's not like I wanted to dev anyway...
Replies: >>2483 >>2484 >>2487
>windows uploads files in the wrong order unless they're on the desktop
i-it's not like I was trying to spell anything with those letters anyway...
Replies: >>2483
fgu.png (u)
[Hide] (85.9KB, 384x314)
>>2481
>>2482
FGU DXXXXXDXXXXXX D::D
>>2481
Memory corruption? Try changing up the test order.
r8bq16f0.jpg (u)
[Hide] (136.9KB, 698x701)
>>2481
After a long and arduous journey, I found the problem and fixed it. I managed to narrow down the problem to where if I have 2 arrays, if the first one was long enough then the next one broke.

Turns out it was a good old array reallocation problem. I stored a pointer to the array node when I detected an array, and kept incrementing it's child count as I parsed more values. However if the node array needed more space for the child nodes and reallocated, the pointer to the parent array node became invalid.

I'm not sure how to stop making this mistake. I could use a different array type that creates new chunks when it needs more space (similar to C++ vector), but it's much more annoying to loop through because you need to use a bunch of verbose macros.
Replies: >>2488 >>2490 >>2504
>>2487
You can write your own vector in a header and only access it with functions. Some of them can be inlined to behave like macros.
Replies: >>2489
>>2488
I'm using C.
Replies: >>2492
>>2487
I don't think there is a way to avoid this other than just reminding yourself of this problem every time you reallocate something or trying to reduce the number of references to shit that tends to get reallocated. Actually there is, it's called garbage collection :^)
Replies: >>2491
>>2490
I just realized I could simply use a normal for loop with the second array type, and then use a get() function to get the correct item.
for (int i=0; i<array.count; i++) {
	Something* item = get_array_item(&array, i);
}My autism will probably prevent me from doing that though, because the get_array_item function would require some math vomit, so looping through with macros is more efficient. It would be better if performance is irrelevant though.
Replies: >>2493 >>2495
>>2489
Yeah, your own C version of vector or chunked arrays. You can check while inserting if the index is the last one, if so, expand it or create a chunk.
>>2491
Macro is tricky to get right, https://gcc.gnu.org/onlinedocs/gcc-11.1.0/gcc/Inline.html#Inline is just as fast.
Replies: >>2494
>>2493
You can't use functions to loop through an array though, at least not without doing some convoluted callback shit. The code for looping through a chunked array without macros is something like this:
possible language: php, relevance: 8
int local_index = 0;
Array_chunk* chunk = array.data;
Something* item = chunk->data;
for (int i=0; i<array.item_count; ) {
	// code goes here
	
	i ++;
	local_index ++;
	item ++;
	if (local_index >= array.chunk_size) {
		chunk ++;
		local_index = 0;
		item = chunk->data;
	}
}
Replies: >>2496 >>2498 >>2504
Or alternatively this if you do >>2491
language: c
for (int i=0; i<array.item_count; i++) {
	Array_chunk* chunk = array.data + (pos/array.chunk_size);
	Something* item = chunk->data + ((pos % array.chunk_size)*array.item_size);
	
	// do something with *item
}
I just realized >>2494 doesn't necessarily work because if a new chunk is added during the loop then the chunk pointer breaks, you'd have to re-obtain the chunk pointer when you move to the next chunk. I haven't used that array much so I haven't run into that problem. I need to benchmark the different loops to see what the speed difference is, maybe the benefit is so miniscule that even my autism won't give a fuck and there's no reason to ever use the first one.
>>2494
>You can't use functions to loop through an array
You can.
language: c
Chunked_array* carray;
inline void** get_ca_chunk(array, n) {
	/* 
	 * Assuming you are storing chunks in an array
	 * 
	 * Also didn't do bounds checking, you can add it
	 */
	return (array->chunks)[n];
}
inline void* get_ca_item (Chunked_array array, i) {
	div_t q = div(i, array->chunk_size);
	/* 
	 * Assuming you are storing pointer,
	 * otherwise cast to char and do pointer arithmetic
	 *
	 * Also didn't do bounds checking, you can add it
	 */
	void **chunk = get_ca_chunk(array, q.quot);
	return chunk[q.rem];
}
for (int i = 0; i < carray->size; i++) {
        void item* = get_ca_item(carray, i);
        //Do something with item
}
Replies: >>2504
Array with 100k 4D matrices, chunk size of 32, 20k loop throughs (setting first value to 123)

For loop with get() speed; min 2375, max 3579
Macro loop speed; min 1042, max 4426

Array with 100k 4D matrices, chunk size of 16384, 20k loop throughs (setting first value to 123)

For loop with get() speed; min 2371, max 3993
Macro loop speed; min 971, max 4082

I don't know how to interpret these results. I did the tests 10k loops at a time, swapping their order for the other one, though it didn't seem to have a noticeable effect.
Checked the average speeds, get() method is about 2600 and macro method is about 1600. So it seems like the macro speed is indeed noticeably faster, not sure why it's so much more inconsistent though. How much the difference matters when there's actual code doing shit is another story.
>>2139
It's hard to argue invariably on this but C++ is mostly CIS White Males with extra privilege. I say this as a professional in the software industry, and relating to most of the men I work with. Zero obvious cock-suckers.

However, obviously a flaming faggot is the convener of the committee, at least one other is a well-known former author with a faggot lisp a mile wide, and as of last year, the biggest conference decided to literally trot young trannies out on stage to introduce the headliners. They even prop up a few token women now.

So the C++ community overall is very definitely under attack by the globalist kikes, but it's obvious that Bjarne doesn't think very highly of the faggots in the community, and again, in my experience in the industry we are practically all normal White men, a few Asian men, with just a couple of (much more advanced than usual) Poos in the mix.

But since it's a White Man's language (as is C), there's not a lot of reasonable propping up of incompetents. It's by and large still very much a meritocracy, given it's common type of use case/project development expense.
loops.png (u)
[Hide] (4.4KB, 466x66)
Got curious so I did a slightly more complete test, 100k loop throughs this time. All arrays are separate from one another, and also pre-filled so there's no inserts or allocations or anything.
Flat array is the fastest possible dynamic array to loop through (as in there's literally no way to make it faster), it's the one I typically use since it's also the simplest, and also the one that I used in >>2487
Macro loop is >>2494
get() method is basically >>2498

I'm a little surprised that the chunk size has almost 0 effect on speed with the get() method, and that the bigger chunk size has bigger maximum times.
Replies: >>2505 >>2512
>>2504
Curious, did you inline get? If not, can you try that?
Replies: >>2506
>>2505
Yes it's set to inline. It's slightly different from your code though because my array includes item size.
Replies: >>2507
>>2506
My guess is division. Wrote a test with function pointers.
I probably did something wrong, the results aren't sane.

Output:
1000K Flat array: 0 s 8048413 ns
Test count: 1024000
1000K cs20 get() for loop: 0 s 12434219 ns
Test count: 1024000
1000K cs20 iterator: 0 s 4155361 ns
Test count: 1024000
Code:
language: c
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

typedef struct Chunk_array {
	int length;
	int chunk_size;
	void ***chunks;
} Chunk_array;

static inline void ** get_ca_chunk(Chunk_array *array, int n) {
	return (array->chunks)[n];
}

static inline void* get_ca_item(Chunk_array *array, int i) {
	div_t q = div(i, array->chunk_size);
	void **chunk = get_ca_chunk(array, q.quot);
	return chunk[q.rem];
}

void ca_iterator(Chunk_array *array, void (*fun)(void*)) {
	void ***chunk = array->chunks;
	for (int i = 0, j = 0; i < array->length; i++) {
		fun((*chunk)[j]);
		j++;
		if (j >= array->chunk_size) {
			chunk++;
			j = 0;
		}
	}
}

void * test_item = NULL;
long test_count = 0;

void nothing (void *item) {
	test_item = item;
	test_count++;
	return;
}

void time_diff (struct timespec *start, 
		struct timespec *end, 
		struct timespec *diff) {
	if ((end->tv_nsec - start->tv_nsec) < 0) {
		diff->tv_sec = end->tv_sec - start->tv_sec - 1;
		diff->tv_nsec = end->tv_nsec - start->tv_nsec + 1000000000;
	}
	else {
		diff->tv_sec = end->tv_sec - start->tv_sec;
		diff->tv_nsec = end->tv_nsec - start->tv_nsec;
	}
}

int main() {
	void **flat = malloc(1024*1000*sizeof(void*));
	Chunk_array *ca = malloc(sizeof(*ca));
	ca->length = 1024 * 1000;
	ca->chunk_size = 20;
	ca->chunks = malloc(1024*1000*sizeof(void*)/20);
	for (int i = 0; i < 1024*1000/20 ; i++) {
		(ca->chunks)[i] = malloc(20*sizeof(void*));
	}

	struct timespec start;
	struct timespec end;
	struct timespec diff;
	test_count = 0;
	clock_gettime(CLOCK_MONOTONIC, &start);
	for (int i = 0; i < ca->length; i++) {
		test_item = flat[i];
		test_count++;
	}
	clock_gettime(CLOCK_MONOTONIC, &end);
	time_diff(&start, &end, &diff);
	printf("1000K Flat array: %ld s %ld ns\n", diff.tv_sec, diff.tv_nsec);
	printf("Test count: %ld\n", test_count);

	test_count = 0;
	clock_gettime(CLOCK_MONOTONIC, &start);
	for (int i = 0; i < ca->length; i++) {
		test_item = get_ca_item(ca, i);
		test_count++;
	}
	clock_gettime(CLOCK_MONOTONIC, &end);
	time_diff(&start, &end, &diff);
	printf("1000K cs20 get() for loop: %ld s %ld ns\n", diff.tv_sec, diff.tv_nsec);
	printf("Test count: %ld\n", test_count);

	test_count = 0;
	clock_gettime(CLOCK_MONOTONIC, &start);
	ca_iterator(ca, nothing);
	clock_gettime(CLOCK_MONOTONIC, &end);
	time_diff(&start, &end, &diff);
	printf("1000K cs20 iterator: %ld s %ld ns\n", diff.tv_sec, diff.tv_nsec);
	printf("Test count: %ld\n", test_count);
}
Replies: >>2512
>>1410 (OP) 
Making my own software waifu/chatbot has been a long time dream of mine but I am afraid I have no idea where to start. Now that I have been stuck in the webdev rabbit hole, I am not sure if I will ever get to there at all.
Replies: >>2513
loops.png (u)
[Hide] (11.6KB, 506x198)
>>2504
It occurred to me after going to bed that there was a couple flaws with those tests. Firstly a performance test isn't very relevant unless I compile in release mode, so this test is compiled with -O3.

Secondly I ran the tests on a bunch of 4D matrices, which are 4x4 arrays, in other words 16 floats or 64 bytes. With 20 of them each chunk is already 1280 bytes so it's not that surprising that chunk sizes didn't have much effect. So this time I included tests with 2D vectors which are just 2 floats. That puts each chunk at 120 bytes on the smaller case, but that's honestly already pushing how small chunks you'd use in reality, the default chunk size if you don't specify it is 64 items, so 20 is smaller than default. The gap between the macro loop and the get() method widened noticeably in the 2D vector arrays, with the macro loop being about 2-4 times faster.

Lastly I added a different version of the get() function, get2() uses the div() function instead of / and %. I thought get2() might be faster or similar, but it's a little shocking how much slower it is.

>>2507
It's pretty weird how you got a slower time on the flat array than the iterator. I can't see anything wrong, but I have 2 theories.

First theory is that since it was your first test, the CPU wasn't prepared to loop through a bunch of things, but some optimization kicked in after looping for a while. That's why I did each test 100k times.

Second theory is, I've heard that when you allocate a lot of memory, Linux doesn't actually allocate all of it, it only starts to allocate when you use the data. I don't remember exactly how that works so maybe it's not relevant. You could try looping through the array once before doing the test to make sure this isn't happening.
Replies: >>2517
>>2510
Just stop doing webdev and start learning about neural networks. I don't know anything about it so I can't point you anywhere though.
Replies: >>2515
Found the Linux memory allocation thing:
https://yewtu.be/watch?v=R5tBY9Zyw6o
10:00
>>2513
/robowaifu/ is probably the best start, as far as the webring goes.
>>2512
>lazy allocation
Looks much better now, can you do a test with function pointers?
1000K Flat array: 0 s 8392991 ns
Test count: 1024000
1000K cs20 get() for loop: 0 s 13340369 ns
Test count: 1024000
1000K cs20 iterator: 0 s 4698121 ns
Test count: 1024000
1000K Flat array pass 2: 0 s 2441695 ns
Test count: 1024000
1000K cs20 get() for loop pass 2: 0 s 9516012 ns
Test count: 1024000
1000K cs20 iterator pass 2: 0 s 4012364 ns
Test count: 1024000
Replies: >>2518
>>2517
Function pointer would just add the overhead of the function pointer, and I don't see a reason to do that, it isn't related to array types and just limits how you're able to loop through the array. The reason I call one of them a "macro loop" is because I'm using macros to do it, the actual code I have to write looks like this:
for_carray (&array, Vec2f, item) {
	item->x = 123;
	
	for_carray_next(&array, item);
}And the code for the macros are this:
possible language: python, relevance: 22
#define for_carray(a, type, name) \
	Carray_chunk* name##_chunk = (a)->data; \
	type* name = name##_chunk->data; \
	int name##_local_index = 0; \
	for (int name##_index = 0; name##_index < (a)->item_count;)

#define for_carray_next(a, name) \
		name##_index ++; \
		name##_local_index ++; \
		name ++; \
		if (name##_local_index >= (a)->chunk_size) { \
			name##_chunk = (a)->data + (name##_index/(a)->chunk_size); \
			name = name##_chunk->data; \
			name##_local_index = 0; \
		}
Replies: >>2524 >>2530 >>2580
Can't say I approve of this shitty "guess what programming language was in the code tags" feature.
Replies: >>2521
>>2520
you are intended to indicate which language the code s on the first line of every code block anon.

language: c
muh_C
language: python
muh_Python
http://crghlabr45r5pqkgnbgehywk5nxutdks5iss7tabyux5psikqqjirryd.onion/faq.html#2519
Replies: >>2522
>>2521
I know but it shouldn't guess the language because it always guesses wrong, it should just default to plain text.
>>2518
Right. I don't know enough macro to do it. The only reason to use a function pointer in this case would just be avoiding macros, unless you want to rewrite for loop into two inline functions, with the custom code in between. Probably would just be as bad as badly written macros at that point.
For anyone who's interested in C macros, here's a short description of them.

Macros are essentially just a text replacement, they don't do anything. You can put complete gibberish in the macro and it will always compile because it's just a text replacement instruction, not actual code. When you use the macro somewhere, that's when it'll break because it'll paste the gibberish into your code.
language: c
#define   fugger(a, b)   a = b

void main () {
    int x = 6;
    int y = 100;
    fugger(x, y);    // x = y;
    fugger(y, 6*10); // y = 6*10;
}The part where it gets complicated is when you use ##, which lets you attach text into the inputs.
language: c
#define   fugger(a, b)   a##foo = b

void main () {
    int x = 6;
    int y = 100;
    fugger(x, y);     // xfoo = y;      Error: 'xfoo' not defined
    fugger(y, 6*10);  // yfoo = 6*10;   Error: 'yfoo' not defined
}The reason I used it in >>2518 is because it allows you to stack loops. The loop needs several variables, and you won't be able to stack loops if the variables have the same names, so I used the item name to modify them. Instead of calling the chunk pointer 'chunk', I called it "name##_chunk", so when you send "item" into it as a name, it becomes 'item_chunk'. If you add a second loop inside it and send "second" as a name, then the chunk pointer for that loop would become 'second_chunk'.

I'm also sending a type into it, so the 'item' variable can have the correct type without requiring it to be cast separately.
language: c
#define   variable_one(name, type)   type name = 1;

void main () {
    variable_one(nigger, int);  // int nigger = 1;
    nigger += 100;
}
A macro ends with a new line, but you can make multi-line macros by escaping the new line. Just put a backslash as the last character on the line. It might be easier to read if you align the backslashes, but it's more annoying to edit.
language: c
#define   multiple_variables(name, type)       \
          type name##_x = 1;                   \
          type name##_y = 2;                   \
          type name##_z = name##_x + name##_y;

void main () {
    multiple_variables(foo, int);  // int foo_x = 1;
                                   // int foo_y = 2;
                                   // int foo_z = foo_x + foo_y;
}
Replies: >>2531
>>2530
retard
Replies: >>2532
>>2531
You got a better way to use macros?
Replies: >>2579
>>2532
Yes, not using them.
Build your binaries with LTO and for something that is not a library everything that can and should be inlined will be inlined. But don't forget to declare functions static just because of this.
Replies: >>2580
>>2579
How can I do the macro for loop in >>2518 with inlining?
Replies: >>2581
>>2580
I have no idea, your macro spaghetti is only better than an #ifdef forest.
Replies: >>2583
>>2581
>all macros are spaghetti
What's wrong about it except being a macro? How about you come up with a way to do it just as fast? Or everyone should just put on faggot socks and rust their dicks off because of muh safety?
I have an urge to code, but I never know what to code. I need to practice my C , but I don't know what I would want to code in C.
Replies: >>2594
1410758547451.jpg (u)
[Hide] (278.1KB, 1261x1000)
challenges.png (u)
[Hide] (1.2MB, 3840x2160)
>>2593
Replies: >>2595
>>2594
Thanks, I'll give it a try.
webring.png (u)
[Hide] (208.6KB, 960x721)
Finally made some progress on something I've wanted to do for a long time: a program that shows webring boards.

It stores and organizes all the sites and boards into a local file so it doesn't lose any information if something fails to load, and obviously you can choose which sites to load in the first place. You can also color-code sites and hide boards, and it shows which boards were updated since the last time you checked (shown with bright outline). Favorited boards will show up above other boards when I make a better UI. There's also links to the catalog, but that too needs a better UI.
newposts.png (u)
[Hide] (30.8KB, 961x112)
>>2601
I just realized that it's possible to show the amount of new posts since last update.
Replies: >>2603
>>2601
>>2602
What library are you using for the ui?
Replies: >>2604
>>2603
The "draw rectangles on the screen" library. You don't need one for something like this. I may use something when I make the UI better though.
Replies: >>2607
>>2604
Thought you are on Linux, there are much choices on Windows.
You can do framebuffer, xlib, xcb or even wayland on Linux.
Replies: >>2608 >>2613
>>2607
aren't*
>>2607
I don't care what the options are when I don't need any of them, it would just be a lot more work to interface with some bloated UI library.
Replies: >>2615
>>2613
A GUI library that isn't an exercise on how horrible software can get quite literally has never been written outside obscure hobbyist OSes.
Replies: >>2616
>>2615
>Good GUI library
Hard to do when all display stacks sucks and are unpenetrable massive blobs.
Replies: >>2618
>>2616
I looked at X source and saw unions of structs, I closed the file and never dared to look into that codebase again.
wrk.webm (u)
[Hide] (4.1MB, 1208x900, 00:35)
>>2601
Made a better UI. If you click the board description it takes you to catalog, not sure if there's a better place to put that link. The favorite star doesn't do anything, it just makes it easier to spot the boards you care about the most (it's also meant to become bright white when there's new posts, but looks like I missed adding that).

There's still a few minor things missing, such as showing a notification when someone added a new site to their webring follow/known list (so you can learn about new members and add them to your list if you want), showing the full description/title when you hover over it (currently it just clips out if it doesn't fit), and ability to use a different sorting method (pph/users/etc). It also opens a CMD window for a split second when you click a link because I just call system("start url") to open the links, I'm not sure what a better way to open links would be. Maybe calling the browser executable directly instead of 'start', but I have no idea how to dynamically find out where the executable is (or what browser is the default in the first place).

I encountered a crash at one point. Curl seems to create new threads that get stuck on, and every time you refresh the board list it creates even more threads and/or crashes, I don't understand why. I'm not doing anything wrong as far as I can tell, and I'm error checking the curl functions. Curl #includes windows.h and fucks up my main function as well by the way. This kind of shit is exactly why I don't want to use anyone else's gay libraries. I'd make my own HTTP requests if I didn't have to deal with the cancer that is TLS.
Replies: >>2620 >>2622
index.gif (u)
[Hide] (10.9MB, 1100x580)
>>2619
>>2601
wow nice
>>2619
wow, its shit

170 replies | 40 files
Connecting...
Show Post Actions

Actions:

Captcha:

Instructions
- news - rules - faq -
jschan 0.1.4