/tech/ - Technology

Technology & Computing

New Reply
Files Max 5 files32MB total
[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)
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
what's this? an imgui clone? I haven't seen the previous thread
Replies: >>1424
PSA on toilets:
>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.
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
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
>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
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
>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

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
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
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
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
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
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.
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
What aids?
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)
>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)
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)
>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).
>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)
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
>neither Assembler nor C ever stand a chance of doing so.
C is already the de-facto systems programming language.
Replies: >>1553
scale.webm (u)
[Hide] (2MB, 450x324, 00:21)
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:
	// process CIA niggers
unlock_mutex(cia_killer_mutex);You could just do something like this:
cia_killer_mutex {
	// process CIA niggers
Replies: >>1515 >>1531
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
>881 pages
I have better things to do with my time but thanks, I'll save it just in case.
Replies: >>1517
>I have better things to do with my time
really, like what
Replies: >>1518
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
Skim and skip. You can probably learn quite a bit of tricks that are not easily searchable.
Replies: >>1524
>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
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.

How about you post your program instead of whining about what other people do.
scaling.webm (u)
[Hide] (3.9MB, 982x682, 00:41)
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)
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:
It is meant to be a tool that artists can use to view a reference image while they draw.
Nice work lad.
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 >>2862
> 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.

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

Good Job Anon!
Replies: >>1554 >>1555 >>1564
>shell sucks ass
Do you mean POSIX shell sucks or the concept of shell sucks? Why?
Replies: >>1556 >>1557
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
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
> Do you mean POSIX shell sucks
Yes and so do all POSIX shell look-a-likes.

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

> 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
>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
>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)
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.
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.

> 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
You literally have no options besides just drawing shit on a canvas directly, which is just going to be slower.
Replies: >>1583
this, unless you want to port sdl2 to javascript, on top of webgl obviously
>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
>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.

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?
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)
>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
Check out HLA or LLVM.
Replies: >>1604 >>1605 >>1608
HLA.png (u)
[Hide] (119.1KB, 1012x1024)
Very interesting but I don't know what it has to do with programming.
Replies: >>1608
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
The fuck are you talking about? How are people "exploiting" terry? What's going on?
Replies: >>1612
7bcd98a9d4d203f6f70961357368d4ffc5225506a590ab7e100b342986937ecc.png (u)
[Hide] (676.4KB, 640x651)
[Hide] (409.3KB, 640x368, 00:09)
tad.webm (u)
[Hide] (2.4MB, 429x592, 00:25)
182ecbcca3888478904e4b0a5194aec16aa1cfba16d3fd089c94974c3e3ee777.webm (u)
[Hide] (4.9MB, 200x150, 02:00)
> 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)

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.

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
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
>I can't read
calm down, wigger. it's just a joke.
hapas are a joke. degenerate faggots are not, except as udderly cow fodder.
>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.
>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. 

Don't presume Anon, test.
GNU_face_when.png (u)
[Hide] (841KB, 994x658)
>but when [Thompson] made C
Soydev > nodev.
Replies: >>1665
I'm inclined to disagree. There's a strong correlation between knowledge of computers and being a complete fucking faggot.
Replies: >>1667
>taking pride in having 0 computer knowledge
As the kids would say: the absolute state of /tech/
Replies: >>1668 >>1669
> write minecraft scripts
> ilook guys im a foking programer tech god
Replies: >>1671
You should some pride in your reading comprehension if that's what you took away from my post.
>14 year olds writing minecraft scripts are more computer-literate than you
Replies: >>1672 >>1889
sippycup 4 drinkypoo pls
nenewithbook.jpg (u)
[Hide] (84.3KB, 1191x670)
>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.

Replies: >>1905 >>1924
>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
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
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
>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
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
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.
>learning C through trial and error
>thinks optimization is code tuning
Imagine the UB
Replies: >>1920
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)
>l33t haxx0r
>can't even print nigger 10 times without getting it wrong
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
This might just be the dumbest thing I've read on this board.
Replies: >>1927
I've heard of mount stupid but this is truly out of the fucking stratosphere.
Replies: >>1927
N00b passing by, why is he stupid?
Replies: >>1928 >>1933
he made a typo on the internet can you believe it
Replies: >>1936
sammies.jpg (u)
[Hide] (121.6KB, 960x720)
> 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
Lurk kernel mailing list for people shitting on other's code?
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
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
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
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
>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
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
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.

>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
>refuse to pick up a book out of principle
What book do you suggest then?
Replies: >>2032 >>2035
>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.
For what topic?
Replies: >>2036
>actual standards
How to write timeless software and to structure programs.
t. college CSfag
Replies: >>2036
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.

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

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

>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)
Memory corruption? Try changing up the test order.
r8bq16f0.jpg (u)
[Hide] (136.9KB, 698x701)
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
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
I'm using C.
Replies: >>2492
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
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
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.
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
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.
>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.
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
Curious, did you inline get? If not, can you try that?
Replies: >>2506
Yes it's set to inline. It's slightly different from your code though because my array includes item size.
Replies: >>2507
My guess is division. Wrote a test with function pointers.
I probably did something wrong, the results aren't sane.

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
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++) {
		if (j >= array->chunk_size) {
			j = 0;

void * test_item = NULL;
long test_count = 0;

void nothing (void *item) {
	test_item = item;

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];
	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);
	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)
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.

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
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:
/robowaifu/ is probably the best start, as far as the webring goes.
>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
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
you are intended to indicate which language the code s on the first line of every code block anon.

language: c
language: python
Replies: >>2522
I know but it shouldn't guess the language because it always guesses wrong, it should just default to plain text.
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
Replies: >>2532
You got a better way to use macros?
Replies: >>2579
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
How can I do the macro for loop in >>2518 with inlining?
Replies: >>2581
I have no idea, your macro spaghetti is only better than an #ifdef forest.
Replies: >>2583
>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)
Replies: >>2595
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)
I just realized that it's possible to show the amount of new posts since last update.
Replies: >>2603
What library are you using for the ui?
Replies: >>2604
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
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
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
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
>Good GUI library
Hard to do when all display stacks sucks and are unpenetrable massive blobs.
Replies: >>2618
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)
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.
index.gif (u)
[Hide] (10.9MB, 1100x580)
wow nice
wow, its shit
Have you seen https://zzzchan.xyz/boards.html
Replies: >>2625
I found the crash, turns out it is indeed Curl. It happens when I call curl_global_cleanup for the second time. I really don't have any idea what I'm supposed to do about that except keep it initialized, but that sounds gay. I could create a separate program and launch that, but A) that's also a pain because now I need 2 separate programs, and B) I don't have enough experience with interacting between processes like that so I don't know how to do it properly. Like I have no idea how to send an integer from one process to another, or if it's even possible in the first place, I need to be able to know which ones succeeded and which ones didn't.
Replies: >>2632
>know which ones succeeded
On Linux, this is done by forking and wait(2). Windows should have their version of this.
Forked process on Linux can share memory space until there are changes. The parent can set a variable right before forking and the child can see it. Other ways to interprocess communication are pipes, sockets, shm/mmap, sysv ipc, posix msg queue and signal.
GIhF.gif (u)
[Hide] (1.8MB, 282x278)
I learned to do proper color blending with alpha. It's a lot more confusing than it seems because if you draw with 50% opacity on top of 50% opacity, the result is not 100% opacity, it's 75%. And if one of the colors is pure red and the other is pure green, the result is not 50% green and 50% red, it's 66.6% of the upper color and 33.3% of the one below.

I'm probably calculating the result in a retarded way and there's a much smarter way of doing it, but it works. Pic related is 2 test images being drawn on top of each other, and then the result being drawn on top of a background.
Replies: >>2783 >>2790
why are you multiplying percentages
use a float and just add them
Replies: >>2784
I don't understand what you're saying. A "float" multiplied by 100 is a percentage.
Replies: >>2785
i = 0.5 + 0.5; i % 2; i *100
how are you getting 75%
Replies: >>2786
>how are you getting 75%
It doesn't matter, that's the correct value. If you have a sheet of glass with 50% transparency, and you look at it through another sheet of glass with 50% transparency, you can still see behind both of them.
Replies: >>2788
Working on a textboard script. I might upload a sample sometime soon. All I have left to do is add bumping, saging and security and it would be functional but no one would use it until I polish it
Transparency: 50% * 50% = 25%
Opacity: 1 - 25% = 75%
He is talking about opacity, not transparency.
Replies: >>2789
Opacity and transparency are the inverse of each other, it's the same thing.
GIF.gif (u)
[Hide] (1.9MB, 294x293)
Trying to SIMDify it and ran into an interesting visual glitch.

I'm struggling to figure out how to cast 32bit ints into 8bit ints in SIMD. It kind of doesn't seem possible. I can make this work by manually extracting the 32 bit ints one by one and casting them down, but that seems silly.
Replies: >>2884
sections.webm (u)
[Hide] (1.7MB, 1200x800, 00:23)
>5 months ago
I got slightly distracted I guess.

Continuing this, I've been working on a UI sectioning system for the past several days so I can organize panels onto the screen. I had a lot of difficulty figuring out how to do it, but turns out it became very easy when I defined in literal and very specific terms what I want to happen in any given situation.

I want each panel to have an absolute minimum size that it can't get below (so the panel contents won't become hidden). I also want the ability to scale the panels to a desired size (so you can resize a layer list for example). Some panels also need to stretch to fill the unused space (for example canvas, maybe layer list). If the desired sizes aren't enough to fill the screen, then the panels that have stretch booleans set will expand to fill the remaining space. If the desired sizes do not fit into the screen, then all the panels that haven't reached minimum size are shrunk. If even the minimum sizes do not fit, then all panels are forcibly scaled down, this isn't "supposed to" happen but it's a failsafe so the UI is less likely to go off-screen. I may add a hard-coded forced minimum size of 50 pixels or so to prevent the panels from shrinking to an unusable size.

Width and height work slightly differently however. The width is always shrunk to fit the screen (as described above), but the height has 2 modes (configurable based on user preference). In the first mode, if the panel desired heights do not fit the screen, then that column will get a scrollbar and you can scroll it down like a list of panels. In the second mode, the panels are scaled down towards their minimum size if they don't fit, and only get a scrollbar if the minimum heights do not fit. The first mode has more user control over panel sizes, and the second mode tries to avoid creating scrollbars.

This is great progress because now I can start adding actual controls to the program.
Replies: >>2934
is probably the instruction you are looking for.
for future reference the website is nice and contains every x86 instruction.
Replies: >>2902
You need a CPU from the last few years to have support for that, and Intel is apparently dropping support for it for new CPUs. It sounds like what I want but I don't want to use AVX512.

>for future reference the website is nice and contains every x86 instruction
The Intel intrinsics guide is also good:
Replies: >>2951
auto-height.webm (u)
[Hide] (791.7KB, 1204x760, 00:15)
As I started working on the tools panel, I immediately realized that the panel's final width may change it's minimum height and it's not completely straightforward to make that work. I had to change some things to account for it which wasn't a huge deal, but it was enough to demotivate me for most of the week.
Replies: >>2935
stretching_problem.png (u)
[Hide] (58.4KB, 1030x960)
Just discovered another problem, and this time I'm not sure how to solve it. If a column is taller than the window, it's supposed to have a scrollbar. However, if any one column is taller than the window, it's going to stretch everything else to be taller than the window as well, so the whole screen would end up getting a scrollbar.

It gets more complicated if for example the top tool bar was stretched across the whole screen, then you couldn't treat the right column as it's own thing. It would be hard to determine which column should get the scrollbar.

My first theory is that when stretching things vertically to fill available space, I should use the window size as a limiter, so they can't stretch any further than that.
Replies: >>2936
stretch_fix.webm (u)
[Hide] (668.8KB, 1006x744, 00:14)
>My first theory is that when stretching things vertically to fill available space, I should use the window size as a limiter
Well that worked easier than expected.

The left toolbar still goes offscreen because of unrelated reason; it's attached to a column instead of a row. That's something I planned to change anyway (such that panels can only be in rows) so it'll fix itself at some point.
Replies: >>2940
swatches.webm (u)
[Hide] (2.5MB, 1060x774, 00:30)
Added some color swatches. Video compression messes with the colors so they look a bit wrong on the canvas in webm.
according to autists in forums taking die shots Intel reached a point in useless meme instructions to fake benchmarks with where the meme instructions take most of the die area and they could win the CPU wars for a while if they just tried to beat AMD honestly instead of adding more deadweight.
img1.jpg (u)
[Hide] (19KB, 380x187)
i made a db thing for all the games i want to play because i'll play them all for sure.
sorry for the blurry pic but i can't reveal all the details to the feds. they have to work and not play my games.
timer.png (u)
[Hide] (4.7KB, 270x294)
I keep forgetting to drink water for an entire day and shit, so I made a program that plays a sound every hour.
Replies: >>2973 >>3281
flash.png (u)
[Hide] (28.5KB, 187x283)
On that note, what should I call the function that flashes the taskbar icon to get your attention?

request_attention_in_taskbar() ?
window_ask_for_attention() ?

I can't come up with anything that sounds clear. I want to avoid using the word "flash" just in case some other operating system does something else, like show a notification icon.
Replies: >>2957 >>2959
Replies: >>2961

t. unix guy
Replies: >>2961
'Notify' sounds a bit like it's going to open a popup or something.

That's no good for multiple reasons.
Replies: >>2963
How about taskbar_beckon(), then?
Replies: >>2964
That sounds interesting. Might use something along that line.
Here's a download.
I ended up using it to do hourly push ups.

I tried to port it to Linux but I don't know how to install SDL since I can't get internet on my Linux computer.
1616298500309.gif (u)
[Hide] (2.3MB, 498x498)
Holy shit I've been on a tangent for a while now because it annoys the fuck out of me how big my program executables are. I just can't get the filesize to go down no matter what I do even when the program barely fucking contains anything.

I just looked at an executable with a hex editor again and found some fucking function names in there that are never even close to being used in the program. I've tried every possible combination of -s,  -Wl,--gc-sections,  -fdata-sections,  -ffunction-sections,  -fno-data-sections,  and -fno-function-sections, but nothing fucking works. Then I figured the compiler is broken so I downloaded one from a different souce and the filesizes are completely different. An empty project goes from 300 kb to 50 kb which was exciting at first, but then I tried to compile an actual project and it went from 500 kb to 1 mb, and some of my projects don't even compile because of some fucking multiple definition conflict that ever existed before.

I'm so close to throwing all of this shit into the trash and writing my own programming language from scratch that outputs assembly. Or I would but I have never before in my life managed to get an assembler working because it literally just never works even when I do the literal exact thing down to the atoms that a guide tells me to do. So rather than outputting assembly, my compiler would output x86 machine instructions.
Sincere advice: Get over your ricer phase. There are things that are actually worth optimizing down and executable size isn't one of them, especially when you're in the 1MB ballpark.
What language/compiler/stdlib are you even using?
Replies: >>2976
That "ricer phase" will never end, it's part of my personality to be in control of my things and not accept bullshit.

>What language/compiler/stdlib
C, GCC (MingW). I've spent plenty of time trying to figure out how to remove C standard libraries and still be able to actually do things, but it's like looking for a needle in a haystack. Removing libc makes the executable go to 5 kb and compile so fast that it looks like it doesn't even happen, which was a dream come true until I realized nothing actually works.
Replies: >>2978 >>2979
Have you tried tcc?
Replies: >>2981
>That "ricer phase" will never end, it's part of my personality to be in control of my things and not accept bullshit.
You don't seem very much in control when you struggle with an Assembler, have your project's headers barf on a different compiler, and don't understand why a C program doesn't work without libc - but what do I care.
>C, GCC (MingW)
Tough luck, as far as I know there aren't obvious switches you could try like glibc -> musl on Linux. If you want to bypass libc you'd have to start looking into your platform's ABI; Windows' should be pretty stable and documented due to backwards compatibility and reversing, but mostly you'll just waste your time doing shit by hand that C already does for you.
Replies: >>2981
I don't care about filesize so much that I'd destroy my program's performance.

>struggle with an Assembler
What the fuck do you expect me to do? I'm following the instructions to a T and it just doesn't fucking work. There's exactly 0 results when I try to search for help because nobody uses assemblers these days except people even more autistic than me.

>project's headers barf on a different compiler
It was because of some operating system functions that the compiler links differently.

>why a C program doesn't work without libc
I know why it doesn't work. I want to know how to make it work. I wouldn't think it's such obscure thing to do that I have to start learning some assembly interface from scratch, I might as well just start writing my own compiler if I need to go that deep.
Replies: >>3002
sigsegv.png (u)
[Hide] (6.7KB, 640x129)
Testing some new debugging utilities. I can now track the current call stack, and detect when there's a memory overflow. This also allows me to add profiling later so I can check what functions take the longest in my program. My favorite part is that none of this requires any external tools.

It's a little surprising how many function calls there are when you can see it happen. I guess it's also the fault of Windows terminal being slow, but my program goes to like 0.5 FPS when I enable function call printing.
>I don't care about filesize so much that I'd destroy my program's performance.
Then stop this obsession because chances are you will not wind up with ANY program if you continue down this path. You are not as clever as you seem to think you are, and your struggle to find resources in the most knowledge saturated environment ever should clue you in to that fact. It's fun to let loose in low level occasionally, yet you need the programming chops to back it up. I wrote a brainfuck compiler straight to machine code once; it produces tiny executables, but I know it sure as fuck isn't optimized. To prove my point I'm going to drop a minimal Linux Hello World that compiles down to about 1k with GCC on my machine and show you some sources so you can choose to masochistically cargo cult your way through low level hell. I'm giving you rope, go hang yourself faggot.

First the makefile, we'll want no standard library and a custom entry point because the default involves the c runtime setting up flags. Found the options on stackoverflow:
> https://stackoverflow.com/questions/67516597/gcc-passing-nostartfiles-to-ld-via-gcc-for-minimal-binary-size
> https://stackoverflow.com/questions/7494244/how-to-change-entry-point-of-c-program-with-gcc
	gcc -nostdlib -eentry -s -static -n main.c
Now the program. Just a quick wrapper around a couple syscalls. The arguments are the same and implicitly in place because of the ABI.
> https://hackeradam.com/x86-64-linux-syscalls/
> https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI
possible language: c++, relevance: 19
void mywrite(int fd, const char *str, int len) {
                "mov $1, %rax\n"

void myexit(int err) {
                "mov $60, %rax\n"

void entry(void) {
        mywrite(1, "Hello World\n", 12);
Replies: >>3004
>executable size
oh, check out plw/geimu/ thread, I've suffered with it since forever. Or read this.
If you program for linux, I recommend programming for wine. Fuck linux. There is a link to the linux version of that thread somewhere in comments.
Replies: >>3004
>you will not wind up with ANY program if you continue down this path
Yeah, except I'm practically the only one in this thread posting my programs. When I make a program like >>1535 and I know I could probably cut the executable size in half or less and improving compile time by a similar amount just by removing useless shit that I don't need, I'm obviously going to want to do that. Someone already complained that it was suspicious when one of my program's executable size inexplicably jumped up like 50%: https://anon.cafe/make/res/161.html#q179
I still don't really know why it happened, maybe I updated my compiler somewhere along the way and that caused it. My only theory besides that is, I figured out recently that there's some bug(?) with IF blocks in batch files and that may have dropped a part of my compile string. Either way I want to be in control of this stuff and I don't want random shit to be inserted into my program.

>quick wrapper around a couple syscalls
I can kind of read assembly, but since I never got an assembler to work, I haven't been able to learn it much so I don't really understand how/why that works. I'm also primarily on Windows so I can't try that right now. The main issue I have is that when I link with Windows API functions, none of them work. Even if I know how to write to stdout or something, I still wouldn't know how to get the rest of the operating system to work.

I'll write that down though for when I use a Linux machine, so thanks either way.

I saw that, but it seems bound to MSVC, I couldn't get it to work on GCC.
gcc is shit, it adds a little string that says something like "compiled with gcc version this", use microsoft compilers. Or at least digital mars c++ is somewhat tolerable, but ancient. There is pelles C or something like that, but eh. There is clang, the worst thing I can say about it is internals of it are weird (it adds yet another intermediate language besides assembly), and nothing but microsoft compilers can do SEH well. There is ZIG language, but you cannot be both crossplatform and perfect, easier to do two different versions that share some cpp files.

I'm planning to upload a tiny gdi program in a few weeks, could be useful as a reference.
Replies: >>3006
I don't plan on downloading Visual Bloat Spyware Studio so I could compile my program. I'm going to use the compiler that lets me download it and then use it, and a third party GCC build is the only one that let me do that.
Heh. I wasted years on GCShit, when I should've used proper IDE and proper debugger, they are really unvaluable.

Download visual studio 2005 at least, it is still relatively usable. Also don't download free version of new visual studio, it will force you to register later, steal an enterprise version instead.

Also you keep using the word "GCC", you sure you don't mean Mingw?
Replies: >>3008 >>3009
Do you even know what Mingw is? It's built for windows linux binaries, it comes with gcc.
Replies: >>3009
I strongly object to installing programs like Visual Studio on my personal computer, and I don't like adding more tools into my workflow. Also as >>3008 said, MinGW is like a package that contains GCC.
It doesn't come with gcc, it's a port of gcc for windows. It's about as shit as gcc, but still much better than cygwin. Cygwin dependencies are impossible to remove while using that compiler, mingw dependencies are possible.to remove.

gcc debugger is a barely functional thing, while in visual studio it just works. It may be a good idea to use visual studio for development, but make your code compatible with smaller compilers.

People keep talking about visual studio code, sounds like a very cut down version, I never tried that.
Replies: >>3011 >>3013
f9fb2714814ca4b9e2d82fc400678d2859a9848696326931aa6ac00344742f2c.jpg (u)
[Hide] (35.2KB, 720x540)
>thread still on top
Why are you so dumb? Anyone using sage is an edgy moralist anyway.
Replies: >>3012 >>3013
shutup newfag
>edgy moralist
You problem is more likely due to working in a toy os designed by street shitters for retards who never programs. Of course nothing works on that piece of crap. My gdb just works. You need mingw, cygwin, wsl all those shitty wine-for-fags just to use bash or gcc or install this 5gb bloat burger nigger to use a glorified notepad, compiler and file manager that loads in 5 minutes. But wait there is dark theme :3! And you can play your jew games on the same OS!!!!111 Not to mention you never need to learn about what compiler flags are and how any of that shit works. What a steal.
Have fun reading about all the 500 useless compiler switches gcc provides and 50 defacto dead architectures it for some reason still supports. Waste your time, I don't mind. Everything gcc does, visual studio does less painfully.

I have no idea why new visual studio is so heavy. I'll just say "this is a tool for professionals that can afford good hardware and keep it open all the day anyway", though it's a bad excuse. I think first launch takes about 2 minutes, every following launch is faster. I pretty much open it once and never close it.

Again, visual studio 2005 express is pretty neat for older computers.
About how to make tiny exe on windows with mingw. I just googled "mingw freestanding".


You can't use stdlib and exceptions anymore, but you still can use winapi and SEH. Not sure about SEH though.

On linux, yeah you can fuck with syscalls all you want, but even loading a library in this way is a really complicated task that just requires adding libc or one of the smaller alternatives of libc. Linux just wasn't made with binary compatibility in mind, you have to recompile everything every time some faggot decides it's time to deprecate some shit.
Replies: >>3017
Ah, if only microsoft faggots weren't trying to kill pc gaming and visual studio to the boot. I heard rumors of microsoft paying developers to not release their games on windows, and going all in on xbox. Visual Studio 2019 free version gathered telemetry and one day just suddenly forced me to register with microsoft account, which I just couldn't do for some reason. And I heard there is no free version of Visual Studio 2020. Yeah, just pirate that shit.
Replies: >>3017
>||Freestanding|| refers to programs that don’t link, either statically or dynamically, against a standard library (i.e. libc)
Thanks, hadn't heard of that term before.

>Visual Studio 2019 free version gathered telemetry and one day just suddenly forced me to register with microsoft account, which I just couldn't do for some reason
This kind of shit is exactly why I avoid using anything more than the bare minimum and why I avoid most mainstream programs.
Has the stupid text formatting ever worked correctly on this fucking imageboard engine?

'aaa'   aaa  'aaa'  ||aaa||   aaa   aaa   aaa   `aaa`
sec18-quach.pdf (u)
What you want to do is not possible with an ordinary compiler as far as I know, so it's useless to golf your flags. You might be interested in this concept though: https://www.usenix.org/conference/usenixsecurity18/presentation/quach
Replies: >>3040
Untitled.png (u)
[Hide] (260.9KB, 1040x481)
Holy shit I want to stop using itch.io. Is there any other place you can upload your programs to? I don't care what it is as long as you can make a page that describes the project and has screenshots, and isn't a git page.
Replies: >>3034 >>3035
Are you using mingw? There are some broken mingws around.
Indiestand runs on Google services, but it's new enough to be free of pozz. They don't have any kind of payment system, so your game has to be free. https://sites.google.com/view/indiestand
IndieDB is run by fags, but it's not itch.io. Yet. https://www.indiedb.com/
You can use something else (eg jew-drive, mega, torrent) to store your program/source and neocities for site.
It's possible, but not on linux. Because linux is shit.
Replies: >>3041 >>3053
You mean embedded firmware can't be compiled on linux?
The fucking board ate my PDF. Do you mean in general? Because the presentation I linked states
>Our solution can successfully compile and load most li- braries on Ubuntu Desktop 16.04
Or is it due to the prevalence of dynamic linking?
Replies: >>3054 >>3063
He means he is a winfag who can't properly config/build a toolchain so he must rely on vendor supplied shit to just werk.
>On linux, yeah you can fuck with syscalls all you want, but even loading a library in this way is a really complicated task that just requires adding libc or one of the smaller alternatives of libc. Linux just wasn't made with binary compatibility in mind, you have to recompile everything every time some faggot decides it's time to deprecate some shit.

Also I didn't watch that presentation, it's too long. Somebody should make a better executable format, a loader, and apis that aren't garbage for linux. SDL2 is somewhat acceptable, but opengl is garbage.
Replies: >>3078 >>3083
>opengl is garbage.
What about Vulkan? I've heard it's a big improvement over OpenGL.
Replies: >>3079 >>3122
If we're talking about how good an API is, then Vulkan significantly more garbage than OpenGL. It's clearly designed by the same kind of retards who jump into bandwagons every month and think OOP is the gold standard of programming and write 70 times more code than required for any given problem.
Replies: >>3080 >>3088
>cluesess cnile decides that shitting up /g/ wasn't enough
Replies: >>3117
>Also I didn't watch that presentation, it's too long
Then skim the PDF, it's 13 pages of two column text. It outlines several limitations and problems when doing this that I hoped someone would shed more light on if they're experienced with C and looking at the resulting binary it produces. The most annoying problem is probably the bits of assembly.
>Somebody should make a better executable format, a loader, and apis
Am I talking to a GPT? What the fuck are you talking about? SDL is not a graphics API, it is a platform independent wrapper around them. Which means it has zero use as a graphics renderer if there is no OpenGL, DirectX or Metal on your system. Secondly, I still don't understand how a new executable format and all that other shit would solve the problem of compilers including unused bits of code from the main program and libraries associated with it.
Replies: >>3118 >>3122
double_facepalm.jpg (u)
[Hide] (36.3KB, 640x480)
I agree with you anon. When I first read that there was this new Vulkan thing I was thinking they were going to fix all the Opengl clusterfuck api. Then I saw the documentation, and they clusterfucked it even more than I thought was possible.
f7719264ed78aea7ef9aaf968f087b989b9e8474d35bfc6dc26208d2b03c7073.png (u)
[Hide] (177.6KB, 1050x828)
Seeing "senile" spelt that way is viscerally disgusting. It's like I'm looking at someone infected by a disease, someone who wants everyone around him to feel as sickly as he is.
Replies: >>3119 >>3121
>the problem of compilers including unused bits of code from the main program and libraries associated with it
is this even real
I thought the compiler tosses out dead variables and functions when statically linking
Replies: >>3123
>nooo don't mock me for fanboying C without understanding it
Maybe you should stop and wonder why you're praising OpenGL, a garbage fire that is now officially deprecated, against Vulkan, a complicated but effective tool that is actually used in the industry.
Replies: >>3120 >>3121 >>3133
I wonder if you're purely baiting or if you legitimately can't see the irony in what you're saying. Vulkan being a horrid pile of shit has nothing to do with OpenGL being good or praiseworthy.
Replies: >>3148
Stop. One mention of the language that begins with L and ends with p and you're going to summon HIM.
Replies: >>3124 >>3127 >>3148
>Then skim the PDF
Skimmed through it. Looks like it tries to improve already existing linux programs, simply by recompiling it in a more smart way. So, it tries to soften the impact of bad code, while I want to rip it the fuck out. It doesn't mention elf format being shit, and in fact adds even more sections to it. Well, linux gonna linux, it doesn't concern me.

>What the fuck are you talking about? SDL is not a graphics API, it is a platform independent wrapper around them.
SDL1 is everything api, including graphics, file io, sound, keyboard/mouse. But it can't do 3d hardware accelerated graphics, so SDL2 uses opengl for that. I don't mind SDL1 as my main api, it's pretty neat and small. I still would rather use winapi, simply because it already works, and I don't want to break something that works just fine. And because linux doesn't seem to have anything like VirtualAlloc, I wonder if there are any patents involved or something. And because exe ends up smaller if you use lower level apis directly without any dll or libraries in between.

>What about Vulkan? I've heard it's a big improvement over OpenGL.
No idea. I noticed that using OpenGL on windows machine resulted in first launch of that program taking about 10 seconds, while Direct3D9 program loaded instantly. That probably had something to do with Firefox using Direct3D9 on my computer, so it is already loaded when I try to use Direct3D9 in my own program. I think OpenGL also shitted up main heap with some trash. I assume Vulkan does something like that too, plus it only works on windows 7 and older.

I'm going full monkey and abandoning even the thought of ever writing a high performance 3d game, so I don't really need additional performance Vulkan provides. I'm trying to aim for compatibility with older hardware instead. So, I'm limiting myself to Direct3D9, it is good enough for 2d platformers and maybe simple 3d games. Vulkan is in the realm of big studios and serious engines, it's not an area I can compete in.

I actually kind of started to like Direct3D approach compared to OpenGL once I understood how it works. Every OpenGL function you use, adds a string with its name to the exe file. While with Direct3D, the only string that gets added is Direct3DCreate9. That's some clever shit, this function returns to you an array of functions you can use, some of which return yet another array of functions. Unlike C++ which doesn't have a stable binary api, DirectX uses COM (Component Object Model), which explicitly states how each such thing is going to behave. You can even use it from C if you want to. It's more painful though, so you better not, you have to call something like IDirect3D9_CreateTexture(d3d9, width, height) instead of d3d9->CreateTexture(width, height).
Replies: >>3123
static_dynamic.png (u)
[Hide] (94.3KB, 1500x844)
>I thought the compiler tosses out dead variables and functions when statically linking
It's an approach meant to compromise with the already existing environment of everything being dynamically linked. Basically adds a loader that strips out extra code based on a dependency graph. Gains compared to statically linked code are negligible, pic related.

Not necessarily recompiling, more like peeking inside what happens during the compilation process itself and gathering data for the loader, which is why it's based on LLVM and clang.
>It doesn't mention elf format being shit, and in fact adds even more sections to it
I'm assuming you mean that it's shit compared to EXE/COM. In what way?

>SDL1 is everything api, including graphics, file io, sound, keyboard/mouse
I should've been more clear. SDL is, as the name states, a layer. It's convenient and, relatively speaking, easier because you have a saner abstraction level above raw OpenGL and DirectX calls. Can't really replace anything with it, because it is just that.
>using OpenGL on windows machine resulted in first launch of that program taking about 10 seconds
Windows refusing to play with NIH technology is not surprising, especially if it's 7 or lower.
>So, I'm limiting myself to Direct3D9
>it can't do 3d hardware accelerated graphics, so SDL2 uses opengl for that
I thought SDL 1 and 2 both have DirectX backends?
Replies: >>3126 >>3128
But what if I want to summon him? I loved his posts and the pure anal pain they caused.
>>It doesn't mention elf format being shit, and in fact adds even more sections to it
>I'm assuming you mean that it's shit compared to EXE/COM. In what way?
No import section. Elf format forces you to do syscall magic to get your libraries. With PE, you just list libraries you need to load, functions from said libraries you need, and os does this aaaal for you. Elf way is more annoying, it takes more space, and it is less maintainable.
Also you can't run 32bit executables on 64bit processors on linux for some reason. Maybe you can, but it's not as easy as doubleclicking it.

>I thought SDL 1 and 2 both have DirectX backends?
DirectDraw backend maybe. It's still 2d only.

>I should've been more clear. SDL is, as the name states, a layer. It's convenient and, relatively speaking, easier because you have a saner abstraction level above raw OpenGL and DirectX calls. Can't really replace anything with it, because it is just that.
All SDL2 does is opens a window for you.
Anyway, API is Application Programming Interface. I call SDL an API because it is Interface I use when Programming an Application.

Replies: >>3141
tbh you can't deny that the APIs (in  this case OpenGL and Vulkan) are messy and complex because of the typical Cnile mindset aka "worse is better" (instead of doing the right thing)
Replies: >>3133
>It's an approach meant to compromise with the already existing environment of everything being dynamically linked
this makes no sense
so its literally just static linking because the loaded libraries are impossible to share between programs since the address space for functions would be totally different for each program compiled with a modified library
this feels like a solution( not really ) to an artificially made up problem that only exists in hypothetical scenarios that do not even exist, like an os that runs only a single tiny program thats dynamically linked to a large library
Replies: >>3130 >>3141
The "problem" is that dynamic linking is fucking stupid, and rather than get rid of this idiotic idea that was originally introduced to deal with the bloatshit that was X11. Just look at the arguments the authors list against static linking:

>Requires recompilation of binaries with every library or software update.
This is a lie, it only requires relinking which is easy to automate. Package managers have existed for decades now.
>Does not allow memory sharing across processes.
This is a lie, instances of the same process will still share memory. It's only different programs using the same library that don't share code, but the code removal also (substantially, as the very same study shows!) decreases the size again. That said, none of this even matters with current resources, we're talking about code size for fuck's sake. This was relevant for the bloated interwoven spaghetti shit that was X, which was also the original reason dynamic linking was even invented.
>May result in accidental violation of (L)GPL.
Nobody cares.
>Increases binary size compared with dynamic linking.
Yeah because the metric conveniently excludes the size of the dynamically linked code. Turns out women have less debt than men if you don't count debt by women. Who'd have thought?
>Risks transferring bugs in a shared library to the binary.
Just like dynamic linking can silently introduce regressions to previously known-good programs, but somehow this part never counts for anything.

Another fun one you hear often is "but static linking can't do ASLR". Then you ask why it can't do ASLR and it turns out that the only reason is that when they added ASLR, it was convenient to use the dynamic linking mechanism for it and they said "well, static linking is bad anyway and nobody uses it" and made no effort to add compatibility with static linking.

I don't even blame the authors personally for this, dynamic linking is basically a religion at this point. But god fuck am I sick and tired of the mountain of ever more complex "solutions" that narrowly avoid solving the actual problem, which is rather simple.
<and rather than get rid of this idiotic idea that was originally introduced to deal with the bloatshit that was X11, they keep adding stupid "fixes" that don't solve the issue.
made me wonder why isnt there a kernel level solution that does on the fly dynamic-dynamic linking for userspace processes 
like it would buffer loading the program into memory and replace functions that are identical and already loaded in memory with an existing pointer instead of loading duplicates
this way you wouldnt need to load the entire library into memory and instead gradually "build" the library into memory as more and more shared functions get called while also purging library functions that are no longer being used
downs.png (u)
[Hide] (75.1KB, 229x318)
>if you don't like my godawful forced meme you like C and OpenGL
iirc Multics had a pretty sane approach to dynamic linking (it's been a while since I looked into this, so I can't give too many specifics), but said approach required memory segmentation and the vast majority of CPUs nowadays are designed around memory paging and, if I recall correctly, so are most operating systems including Unix-based ones.
>Also you can't run 32bit executables on 64bit processors on linux for some reason
I don't think the underlying architecture that allows doing this on Windows is simple.

I guess it's a stopgap solution for when you are stuck with dynamic linking but also need to reduce code footprint. One thing to also note is that this makes startup times really slow.

Actually, Linus agrees with you at least when it comes to userspace: https://lore.kernel.org/lkml/CAHk-=whs8QZf3YnifdL[email protected]/

>Another fun one you hear often is "but static linking can't do ASLR"
But it can https://drewdevault.com/dynlib
>We've had ASLR for statically linked binaries for some time now. It's called static PIE.

A source-based distro with more of a focus on static linking could be an alternative to Gentoo, less load on the package manager that way too.
Replies: >>3149
>implying worse isn't better
>do the right thing no matter the cost
If you machine always do the right thing, it would be bloater than your mum. Getting to the point where only the essentials are implemented makes  the implementation simple. It is easier to implement, debug and understood.
>Vulkan being a horrid pile of shit
According to who?
Some contrarian nocoder on a dead board?

I don't even like that language with the L, I don't even hate C that much, I just hate clueless retards that worship C as some kind of RETVRN TO TRADITION.
Replies: >>3152
>>We've had ASLR for statically linked binaries for some time now. It's called static PIE.
Sweet, I didn't know about this because I stuck with GCC4 for so long.
C/C++ is eh, but everything else somehow managed to be even worse.
>I don't even like that language with the L
I think it's one of the best languages out there, because of the (lack of) syntax. Particularly the one with the S because it was designed to be more sane and minimal.

Well, it is at this point, at least for high-level languages. And of course, almost all good software is still written in C (and a lot of terrible software too, of course) while it's safe to say that other languages mostly produce a bunch of crap, and trying to replace C would be a disaster because you know that it would be done as poorly as humanly possible and it would be replaced with bloated garbage written in a bloated and retarded language, designed to give corporations as much control as possible. As imperfect as old tools and standards may be, people today are too retarded and evil to replace them, so we're better off not doing it. There are a lot of changes that I would really like to see, but for now, fix humanity first, then the tools, or the tools will be corrupted and ruined.

For now just accept that C isn't successful because it's perfectly designed to give you whatever unnecessary features you want (that most people would only use to make a bigger mess), it's successful because it's small and simple and only gives you what you need and nothing more, and it has been resistant to change, so it's reliable and stood the test of time. It's not successful because of what it does, it's successful because of what it doesn't do and hasn't done. It requires a little more competence, but that has the benefit of repelling idiots, to some extent. The morons are all working on bloated trash written in Python or whatever it is that they do. Do you really want them working on your kernel? I don't.

Other languages, on the other hand, almost always become so complex that they can't possibly replace a language like C well. Nowadays, the average developer wants to maximize complexity, so when they attempt to replace C, the result is the abomination known as Rust.
Replies: >>3154 >>3156
>designed to give corporations as much control as possible.
How would you design a language to give a corporation control, and over what?  That doesn't even make any sense.
> it's successful because it's small and simple and only gives you what you need and nothing more
The first part, sure.  The last part, no.  If the system I'm building would benefit from using object oriented programming, why wouldn't I use a language that supports it instead of hacking something similar to it in C?
Simple tools aren't useful for building shit that's inherently complex.  It's not that you can't do such a thing, but you're going to open yourself up to memory leaks, dereferencing null pointers, and other unexpected behaviors if you're not careful.  And just saying "be a better program" is idiotic since nobody's perfect.
>but that has the benefit of repelling idiots, to some extent
Or maybe they realize that they can write better software in a different language that supports the abstractions they need, with the benefit of not needing to worry about lower level shit when they don't have the resources to do so.
>The morons are all working on bloated trash written in Python or whatever it is that they do. Do you really want them working on your kernel? I don't.
no, but python and C are two completely different use cases.  Most people aren't going to write their websites in C.
> the result is the abomination known as Rust.
Can you give some examples of what's wrong with rust, pushing aside everything about the rust community?  Just as a language.
I personally don't see rust replacing C because there'll always be low level cases where the whole "memory safety" shit can't apply, but if it's not some kernel level shit I think there's a use case.
Replies: >>3155
Not him, but
>Simple tools aren't useful for building shit that's inherently complex
A problem I have with things outside of the C/C++ field is FFI and general language interop since I don't know much about it. Even with C++ libraries you'll run into issues with exposing their functions to other languages because of, for example, templating. Is this better in Rust? C is pretty much the gold standard for integrating it into other systems at the moment.

Say I write a complete piece of software in Lisp or Rust. Now somebody decides that a piece of my program's functionality would be good to use in another language. Can they do it without any major issues?

>Can you give some examples of what's wrong with rust, pushing aside everything about the rust community
I think it's fine, aside from it not being as portable as the C family. There are also problems with following the bootstrap chain up until the latest Rust compiler because of LLVM, so you basically have to trust the binary official sources are distributing. The guy maintaining Sabotage Linux was complaining about that one. Not something wrong with the language itself, more of a Trusting Trust problem.
>Particularly the one with the S because it was designed to be more sane and minimal.
In practice, this "sanity" and "minimality" ends up in you reimplementing half of Common Lisp in a more ad hoc way. See Guile for a particularly egregious example of this in action.
>And of course, almost all good software is still written in C (and a lot of terrible software too, of course) while it's safe to say that other languages mostly produce a bunch of crap
You pulled this straight out of your arse, but even if it was true it wouldn't matter. It's just the "but so many good sites use PHP" pseudoargument.
>trying to replace C would be a disaster because you know that it would be done as poorly as humanly possible
What kind of fatlogic is this? Never change anything bro, improvements aren't possible. A major reason why you have so many specialized languages is that C sucks and their authors wanted to get the fuck away from it. The issue is that they usually only fixed the few parts that bothered them the most or didn't have an actual design in mind beyond "I just want to program".
>[C is] successful because it's small and simple and only gives you what you need
What if I need overflow checks? Or vectorization? Or bounds checks by default that I can selectively disable in hot paths because disabling those by default when 1% of the code is responsible for 99% of the runtime is retarded? Or actual arrays? Or control flow in the vein of CL's restart system? It's not even simple. Try writing down the semantics of pointers some time, they are mindblowingly awful. The "simple" C you think of is your obvious implementation of C (because the language definition is optimized to make that conforming), but that's not the implementation you're actually using and hasn't been for a decade or two. Undefined behavior based optimizations send their regards.

C is successful because it's established (so unless you want to break with the ever increasing ball of legacy shit you'll need C support at some point) and extremely primitive (easy porting => first one to market). It also provides absolutely nothing for sane interop, so replacing it is obnoxious. No, C interop is not good, vendors just had to standardize on an ABI for the most urgent necessities because otherwise nothing would work at all, and C doesn't provide many features beyond those necessities. Those it does provide don't reliably work. Passing structs by value? Fuck you. Bitfields? Fuck you. Constants that are defined as macros and depend on preprocessor shit? Fuck you, have fun basically reimplementing half of C if you want to support that. Supporting the absolute basics is not an achievement.

>Other languages, on the other hand, almost always become so complex that they can't possibly replace a language like C well.
Of course they're not going to be a replacement for what C programmers want, but that's because what C programmers want is fucking stupid and if you make something like that you'll basically just end up with a different C that sucks just as badly. Once you start actually handling errors, the simplicity and elegance of C vanish in a puff of smoke.
>the result is the abomination known as Rust
I'd really like to know what parts of Rust you hate (there are certainly enough to last a lifetime), because most Cfags who hate Rust seem to hate it for the most idiotic of reasons. Usually that the language actually forces them to think about errors and lifetimes, and won't let them pajeet pointers all over the place, or that they don't feel like a 1337 h4xx0r when using it because there are safety mechanisms. There was a similar hatred for Ada back in the day, and it had no tranny cabal or language instability.
Replies: >>3157 >>3167 >>3174
Actually Ada did have an equivalent of "muh trannies" back in the day, now that I think about it. "Muh military".
it really shows that you don't grok C, therefore you don't like it, therefore it's broken.
you should read more about where C comes from, why it was made that way, how it evolved and why it's kept the way it is.
it's not perfect, but it's definitely not broken.
Replies: >>3173
I probably know more about all of that than you do. That your response to all arguments is the equivalent of a commie going "read a book" is telling.
Replies: >>3201
limitations are universally bad youre taking control away from the programmer, how are you this stupid
good programmers dont want training wheels and you cant become a good programmer if you rely on training wheels
Replies: >>3175
And yet you piggyback off your compiler's calling convention. What's the matter, do you suck too much to write the function prologue by hand every time? Come back when you've taken off the training wheels, india boy, this board is for actual programmers.
Replies: >>3176
thats trivial
memory control and void pointers are not
Replies: >>3177
Confirmed for never looking at any assembly output by a compiler, but that was obvious given the blind C fanboying and that you think void pointers are somehow special. If memory control is non-trivial, why aren't you letting the computer assist you with it? Is it because you
>don't feel like a 1337 h4xx0r when using it because there are safety mechanisms
Replies: >>3178
calling conventions are trivial
if dont understand why void pointers are special, then youve never done memory mapping, good luck trying to make any kind of efficient data structure in rusticle retard
What about C#
Replies: >>3203
so in your opinion, i'm telling you to get informed on something i don't know anything about? doesn't even make sense.
also, i was in the cracking scene more than 20 years ago, so no, i don't have to learn anything from you.
Replies: >>3202
Yeah, just like the commie doing it makes no sense. We can compare e-dicks all day, or you could address the actual arguments. Hopefully in a better way than the other retard who thinks void pointers are magic and optimizing calling conventions is trivial rather than intractable.
Replies: >>3220
>What about C#
Microsoft's clone of Java.
Java has a larger FOSS community (with tooling and libraries) which is why I would pick Java instead of C#.
I did address the arguments, you started the "commie" ad-hominem.
my argument was (and still is) that you are using C wrong. car analogy: you can't use a car like a boat, so you say the car is broken.
the fact that you say you know the history and purpose of C better than me (or whoever else) is clearly false or you wouldn't point out problems that are not there.
if you want me to argue in detail, again, read the history and purpose of C, my arguments  are there.
and now for me is case closed.
Replies: >>3224
This may surprise you, but "no u just don't understand its genius, making retarded tradeoffs is actually good because i say so" is not actually an argument.
Replies: >>3378
ct-amtrak-train-derails-vermont-20151005.jpg (u)
[Hide] (791.8KB, 2048x1360)
I warned you. I told you not to summon him.
Replies: >>3227
I haven't even reached 10% of his autism output. Check your bounds properly and nobody gets hurt.
activity.png (u)
[Hide] (8.3KB, 295x295)
Making a program that tracks how long you've been paying attention to programs, so I can (hopefully) learn to waste less time on the internet. It just grabs the active window, finds what the process executable is, and increments a counter for it.
Replies: >>3317
Untitled.png (u)
[Hide] (11.1KB, 367x298)
Now shows 2 different global timers, one for all the programs, and another for how long the timer has been running. Some programs aren't counted such as the "UNKNOWN" and the timer program itself, so you could use the program itself as a pause of sorts.

I think I'll combine this with >>2955. I've wanted to make a proper timer program for a long time, but I never thought about the ability to tie timers to program usage.

I wonder if there's a way to detect mouse/keyboard input without the window being active and without running some loop at 20000 fps. Supposedly Windows has some kind of hooks system but I don't know how it works. It would be cool if I could detect actual activity, so I could make separate timers for window focus time and actual activity time.
Replies: >>3304 >>3363
N00b C question:
Why should I ever use "normal" data types if int_fastN_t or int_leastN_t do the same thing?
That's actually a good question.
A pedantic answer would be because those types are optional whereas int, char, and so on are not.
Replies: >>3294 >>3303
I never found them to make any difference, they're probably only relevant if you're compiling to some unusual platform.
Replies: >>3294
Readability, mostly. Outside of some really specific scenarios (largely involving intN_t and intptr_t), these types are basically useless.
Replies: >>3290 >>3294
Isn't int_fastN_t more readable than long long/long/short? The byte is on the type.
Replies: >>3294
> Why should I ever use "normal" data types if int_fastN_t or int_leastN_t do the same thing?
> Isn't int_fastN_t more readable than long long/long/short?
Types such as  int_fastN_t are, or can be, a bit different than int/long int. It may have different size (optimization). I recall C Primer Plus, 6th ed. by Stephen Prata had a section that discussed the differences of various type specifiers. For example, int8_t is always 8 bits. See https://en.cppreference.com/w/c/types/integer for reference.
Replies: >>3295
I understand the difference, but normal data types are "at least N bytes long", which is the same as fast and least except I can choose to be small or fast as well.
it's most likely pre-optimization.  If you're program is too slow without these types, you're probably doing something wrong on a much more fundamental level.
I think int_Nt was optional but not the least or fast variants.
Though I think this was only introduced in C99 if that's what you meant.
Untitled.png (u)
[Hide] (3KB, 270x80)
>keep it up for a while
>think I've been pretty productive so far
>not even 40% of my time spent paying attention to useful things
I hate this program.
Replies: >>3305 >>3383
install vim
Replies: >>3310 >>3338
I cannot think of a much less interesting and less useful thing to waste braincells on.
Replies: >>3335 >>3336
This sounds fun, I might try that myself.
>tfw too inteleglent to learn anything
Leave it to a Windows user to make such retarded posts.
What do you use vim for? I've come back to it several times, and each time decided it was a mess. I recently looked into macros to see if they'd be useful, but I came to the conclusion that I never need anything that general purpose in editor. Replace/sed and the shell commands cover those rare cases fine, and no editor I know of actually supports semantic replacement rules (as in, aware of scopes and types), which is what I actually want. Unfortunately vim seems to be promoted heavily by the same kind of autists who think that studying functional languages makes them a wizard. Not to say that it isn't good at anything, but I don't see a lot of people who just write code talking about how much better it is. Ultimately I just use it as a less ergonomic editor when I need to use a text mode editor.
Replies: >>3342 >>3350
I use vim for everything (except fucking java).
>never need anything that general purpose
It's bloat. But the bloat doesn't affect the startup time and run time much. Most users, including me, probably don't use and even know half of the function. It is fast and easy to use enough after learning about 10 keystrokes.
Vim is good for just editing text. Startup time is instant, text objects are great, modal editing is voodoo but for large amounts of successive commands it's great and things like vimdiff and autocmd hooks are just plain useful even when you only use them occasionally.
If you want an IDE that does fancy IDE things, you could make it in vim if you were autistic enough. I know neovim now supports lua by default and every other language by plugin, so you don't even have to work with vimscript.
Ultimately, if you have a text editor that just works for you, there's no reason to switch, but if you do vim will almost never be a bad choice.
timetracker.webm (u)
[Hide] (1.5MB, 1280x800, 00:16)
Made a better UI for it. It's now possible to create groups and timers. Timers can be attached to groups or programs, or they can be global. The lock allows you to make a timer or tracker stay active, so you could for example create an empty group and use it to manually track non-program related things.

Didn't actually add sounds yet, ran out of time for today. Also need to make an interface for modifying the timers and groups, currently they're hard-coded. A more involved thing I kinda want to add is sessions, such that all the times will be saved from the last time the program was up, you can click a button to start a new session, and can view old session times. Not sure if I'll bother to add it for now though.

I managed to optimize the program so that ProcessHacker shows 0 CPU usage even though the timers keep updating.
Somewhat related to that, it turns out Windows has a very easy way to track mouse events when you click on the window and drag off-screen. I used to use very ugly and complicated ways to handle that myself, so cleaning that up feels pretty good. All you need to do is call SetCapture() when mouse is pressed, and ReleaseCapture() when mouse is lifted.
Replies: >>3367
flashy.webm (u)
[Hide] (1.2MB, 734x700, 00:17)
Sounds can now be tied to timers, though webm is muted because I can't find the setting to enable audio recording in ShareX. The timer will also flash until you click the screen, or until 1.5 seconds after focusing the window.

I'm getting to the unfortunate part where this already does what I want, so I don't have a lot of motivation to finish it by making groups/timers user-configurable. Maybe I'll just keep the program for myself.
Replies: >>3368 >>3387
>Maybe I'll just keep the program for myself.
You can just say that is configurable by editing the source (like Suckless stuff)
tablet_photo_rescale.jpg (u)
[Hide] (761.5KB, 1125x1500)
>What are you working on?

>last project
>have 10+ year old pen tablet
>plug-in but no drivers
>find foss Linux kernel drivers for it
>still doesn't work
>can't tell what the problem is
>crash while trying to figure out the problem
>write libusb driver to see if the device isn't broken
>it works
>add hotplugging
>put up a fundraiser that didn't ask for much
>get more than I expected

I might buy some used pen tablets of the same series just to support them. This is a fairly unknown brand however (compared to wacom/cintiq).

For now, I'm doing random programming challenges in Ada.
Replies: >>3386
i'm not surprised by your strawmanning what i never said.
also, thank you for providing a list of problem C has, along with the sources of those technical decisions made by the iso workgroup, compiler vendors and whatnot, and your arguments against them.
see? if you do your research you'll find most criticising is just an exercise in ignorance.
keep the quality posting going.
time.png (u)
[Hide] (7.1KB, 354x114)
It's weird, as soon as I start this program, I get motivated to do stuff because I don't want to let the shameful counters build up. Still not as good times as I'm hoping for though.
You might be also interested in the Linkers And Loaders book.

Like the article I take for inspiration, I set out to create the smallest ELF file that runs on modern Linux

A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux
Replies: >>3385 >>3413
neither of the articles are written by me
4073324eaa58bc8a56cea638104c565e955395b3.gif (u)
[Hide] (481.6KB, 640x480)
Great work, anon!
Added a settings file so timers and groups and such can be configured. There's still a few things I'd like to add like the ability to sort the list by time, but I'm anxious to get to working on other stuff.

Here it is:
Can't you just use -Os or -Oz and compress the executable?
Replies: >>3415
Ignore, he's a Windows pajeet doing static linking.
[New Reply]
311 replies | 68 files
Show Post Actions



- news - rules - faq -
jschan 0.1.7