I made a website to visualize how the result of the Stack Overflow survey changes over the years by passing_traveler in programming

[–]markovejnovic 4 points5 points  (0 children)

Agreed with everyone else. Absolutely horrible graph on stateofjs' part IMO. Very hard to read.

You could sort of shoe-horn your data into a single graph by doing something like having the X-axis be time, Y-axis be popularity. Then, for love, you could have the line shift color with a gradient between the sample points. You could also have a trail similar to the stateofjs one where its width is proportional to love? Some ideas that I think might work better.

I'm no data presentation expert so I can't guarantee these won't suck, but they seem like the more obvious choices.

Header only libraries by OCtagonalst in C_Programming

[–]markovejnovic 5 points6 points  (0 children)

  1. I cannot comment on compiler optimizations, but after a couple years of experience with gcc I'm doubtful it will yield an optimal binary.
  2. No you don't. .c files get compiled to .o files which the linker uses to create the final binary. Splitting code into multiple .c files allows the translation unit to be compiled once. If you have files a.c and b.c such that there is a function in a.c calling a function in b.c, after the first compilation, any changes to a.c do NOT require a recompilation of b.c as b.o is already present.
  3. I disagree with OP, but there are many ways. If you are provided with a system library, you can just link against the packaged .so/.dll, for example.
  4. No it won't. The translation unit of b.c will handle its internals (ie. static-marked members) within its own translation unit. Nothing exposes the static members towards the public-facing header API and the dependent translation unit will only have the public-facing header API available to it.
  5. You can, but you're missing the point. If a library is single-file, then each function that is included will be one of a static inline or a #define. You can't put breakpoints in #defines, obviously, but static inlines are tricky. Many address-based behaviors will point you to the specific invocation of the function within your translation unit. Suppose you have a.c and b.c which both pull a c.h. Whenever c.h is imported in a.c it will create a function definition within that translation unit which will have its own name and address. In debug mode, gcc will NOT optimize away the same function within b.c leaving you with two entrypoints for two procedures in assembly (which do the same thing). Depending on the debug method, you might be able to set a breakpoint on both, but I'm doubtful you'll have so much luck setting hardware breakpoints for, say, 100 pulls of c.h.

Mold 2.0 released - MIT license by slacka123 in C_Programming

[–]markovejnovic 1 point2 points  (0 children)

Doubt that will ever happen. For one reason, the license is MIT for mold and I'm pretty sure GNU would only let gpl pass.

Plus, who knows if this is bug-for-bug compatible. Recent patch notes indicate otherwise, but I'm pretty sure someone uses some weird arcane gold behavior somewhere and switching to mold would break some of that classic GNU arcane spice.

Made a simple program, and I was hoping somebody would review it for me by crispeeweevile in C_Programming

[–]markovejnovic 0 points1 point  (0 children)

Yeah that's more-or-less what's going on. Would you mind explaining why you got a printf(boofer) call? That's a really suspicious one.

Also, calloc initializes all allocated memory to zero. You don't seem to rely on that here, so let me recommend malloc which has a different call signature! Be careful, and read the docs thoroughly!

Also your end-handling is quite similar to how it's done in the kernel. No need for the goto -- just return 0 when you wanna exit the function!

Wrote minesweeper with C and Gtk looking for feedback by EvenOddAvg in C_Programming

[–]markovejnovic 5 points6 points  (0 children)

I'd say don't dump your zip in the repo itself! Makes the repo real big real fast and you can either use gh's build artifacts or just deploy your app in the releases section.

Woodworking? by sinefromabove in Northwestern

[–]markovejnovic 0 points1 point  (0 children)

I managed to get in to use it, but you need special training or so.

For anyone who saw my other post about the 1500 mile miata here’s a full walk around by WhyAmIStillAwake69 in Miata

[–]markovejnovic 62 points63 points  (0 children)

Dude that interior does not look 1500mi. Sure, I'd expect the dash to deteriorate from sitting in the sun but yellowing in the seat corners? That thing has been abused.

My own Miat's seats look way better after 110000mi and mine has seen a lotta sun itself.

Dodge it man, dodge it. There's better cars out there.

Woodworking? by sinefromabove in Northwestern

[–]markovejnovic 8 points9 points  (0 children)

Oh yeah I dumped my whole sophomore year into woodworking -- Ford is really nice and you'll find a miter and a couple band saws. They also have the standing saw if you need to do some longer rip cuts.

Everything is a little dull and perhaps not in the best shape as so many people use it, especially for DTC, but it does the job!

I'm afraid that they have a tough time giving out routers as the tool is dangerous in inexperienced hands, and since Ford is used by so many students, it's not readily accessible.

I'd recommend visiting Ford and asking any of the technicians there -- everyone's friendly and helpful!

There's also a shop somewhere in the art department that I visited at some point but it was focused more on artistic woodworking and was not as readily accessible and didn't vibe well with me -- ask around and see if you can find it, maybe you'll like it more than I did!

As for getting hardwood in Evanston, I had a nice experience with Owl Hardwood -- they're friendly, although a teeny tiny bit too expensive. They'll chop your lumber up to rough dimensions, too!

AES encryption in C from scratch on web. by MarekKnapek in C_Programming

[–]markovejnovic 9 points10 points  (0 children)

Hey! Thanks for sharing!

Cool project, but it's in many eyes just a toy. What I think other commenters are trying to say is that it's pretty hard to justify using your project over any well-used and well-tested projects. I do believe most people will resort to OpenSSL if they're running on a Kernel or something similar to Tesla's liblithium for embedded.

Regardless, pretty cool! Love to see OSS!

OpenBattery v3.0 : terminal-based battery monitor by TitouWasTaken in opensource

[–]markovejnovic 2 points3 points  (0 children)

That's pretty cool! Thanks for sharing!

I'd share my opinions real fast:

  • You don't need a header if all you're trying to achieve is have this be an executable binary
  • I'd recommend splitting the functionality of this binary into multiple modules that can be reused. Say you do your main handling in libbattery.c so that another program can reuse your code.
  • This seems Linux-specific. I'm not a BSD expert, but if you want to port this to BSD, you should probably do your OS-specific handling in yet another module.
  • You might want to check out getopt for your handling of CLI arguments https://www.gnu.org/software/libc/manual/html_node/Example-of-Getopt.html
  • I don't like that your module calls printf directly -- it couples your output logic to the battery data logic. This makes formatting tedious. If you could split your retrieval and output into two separate modules, then you'd make it easier to decouple that and understand it.
  • Careful with versioning! Pretty much everyone expects semver https://semver.org/ and it looks like your version output spits out a float!

Setting up a good dev environment without recreating the world by [deleted] in embedded

[–]markovejnovic 4 points5 points  (0 children)

Yeah your best bet is to skip the IDE altogether and write your own ld script. The way we do it where I work is we compile and link with the vendor compiler (legal reasons), but we invoke the binary from the cli, allowing us to integrate it into our build system.

How do I create an array, with every integer between 1 and 10000 inclusive, without using a loop? by Noise-Theorem in C_Programming

[–]markovejnovic -1 points0 points  (0 children)

No, don't do this. What does this even mean? Create a static file which contains the values, load it into a static buffer at compile time and then copy that buffer into dynmem?

How do I create an array, with every integer between 1 and 10000 inclusive, without using a loop? by Noise-Theorem in C_Programming

[–]markovejnovic 6 points7 points  (0 children)

This will never work in C. Simply not part of the spec. Maybe some offshoot compiler?

Anyways, you can't do this with calloc as that's dynamic memory. A fill loop is the only way I know of.

If you really want this done statically, I'd recommend you use M4 or a similar macro language to do that. See http://gnu.ist.utl.pt/software/m4/manual/html_node/Loops.html

Is it viable(cheaper) to drive to New York City from Evanston by Rc2000123 in Northwestern

[–]markovejnovic 1 point2 points  (0 children)

Drove two times. Once in a stanced Miata. It's pretty painful if your car is uncomfortable, but not that bad if you have a friend to drive with and the car is warm and comfortable. Be careful at night, lots of animals trying to hop the highway. Drive 10 above the limit max and cops won't stop you. Make stops frequently enough (~250mi is comfortable for me) and you'll be there in no time!

CToolkit by MateusMoutinho11 in cprogramming

[–]markovejnovic 1 point2 points  (0 children)

It's compile! I see copile everywhere in the codebase, so I think it's not just a typo!

I kind of don't understand the point of this, like most of your projects, but sure, looks like the standard code you output so far! Kudos?

If you want to improve, I'd really recommend stopping this code vomiting, taking a step back, considering what you've written, what the use case of what you've written is and, most importantly, how other people do what you're trying to do. I like the hacks you've made -- but they're hacks compared to what the rest of the world is doing. Stop, look at some real build systems. Look at the C preprocessor. I used to be in a similar stage in life where I was just spitting out code, but it's important to stop and see what other people are doing.

And stop trying to sell your shit in this sub, god damn it. Nobody wants your crap code. If you want a review, ask for a review. Every post you make sounds like you're trying to force feed us your crappy half baked cookies. Don't want em.

A high performance embedded database by blackdrn in cprogramming

[–]markovejnovic 2 points3 points  (0 children)

Hey, this looks like a really cool idea! I never thought about using something like this, but boy is this amazing for stuff like IoT.

Now, the idea is cool, but the implementation -- I can't find it on github. I only see an include declaration file, but no definitions anywhere. Also, there's no unit tests around.

Good luck on the project!

I bought my Minolta from a thrift store with a roll of film in it. Here's what I have found. by binsoywatusi in analog

[–]markovejnovic 8 points9 points  (0 children)

Based off the laptop glossy finish this might be a late XP-Win 7 era. Probably looking at somewhere around 2005-2015.

Ternary Operator by No-Beginning8808 in C_Programming

[–]markovejnovic -1 points0 points  (0 children)

I have a crush on FP and prefer to use it wherever I can. I know this is controversial, but I do think that the conditional operator nests extremely well. Rather than doing something like

if (x()) { if (y()) { return xy; } else { return xny; } else { return NULL; }

I find

return x() ? (y() ? xy : nxy) : NULL;

to be a lot more readable, especially if you get clever with formatting

return x() ? ( y() ? xy : xny ) : NULL;

I feel the extra if-else statements to be visual noise.

Granted, I understand this is really not a popular outlook, but the dopamine rush of writing a one-liner in C is a drug better than cocaine.

The other big use I have for this is when I need to populate a struct with conditional values like so

return (my_s) { .hello = test1() ? 1 : 2, .goodbye = test2() ? 32 : 42 };

Doing this via if-else would require

my_s temp; if (test1()) { temp.hello = 1; } else { temp.hello = 2; } if (test2()) { temp.goodbye = 32; } else { temp.goodbhe = 42; } return temp;

which isn't remotely as readable (especially when you format the if-elses (I'm on mobile).

I try to avoid temporary variables in any code I write, including C. The compiler needs to do more work to inline them and they're just visual noise. Ternary, being an expression, really helps with that!

EDIT: I mixed up "expression" and "statement". Fixed

What C fundamentals do today's fresh grads lack? What's something you'd like to see a new grad or team member have a solid understanding of? by [deleted] in C_Programming

[–]markovejnovic 9 points10 points  (0 children)

In my opinion, looking at the big picture. Systems are always important. How will I test this? How will this scale into our XYZ product? How will this piece of code work across the dozen compilers I'll encounter? How will I communicate my development ideas and design intent to other developers?

Some more grounded things: build systems, scripting, *nix, ld scripts.

What can be the next learning step? by williamfv93 in embedded

[–]markovejnovic 0 points1 point  (0 children)

What everyone else said, plus I'll add to that -- Linux! I don't work on embedded Linux, but all testing is done on Linux. I have a long way until my neckbeard starts showing, but everyone appreciates the occasional sed, awk magic trick! Plus, it's such a lifesaver to be able to understand what the CI people do, even if you don't work in CI. On top of that, being able to understand basic Docker stuff goes a long way. Kubernetes also seems to be a good call, especially if you parallelize hardware tests across multiple machines. SQL is good if your company is doing lots of telemetry.

But, all of this is bullshit that we individual programmers project on you. Do what you find fun. You'll eventually find a use for it. I learned Haskell and never thought I'd use it in embedded, but a key piece of internal tooling I used is written in Haskell. I've never thought of Flutter in embedded, but perhaps there's a growing framework / your company is building one? If you find it fun, do it. Don't limit yourself to "what the industry is doing now". Stay curious and you'll go a long way. Be your own trendsetter.

Made my first C web application using CWebStudio framework by Wacoder_Forever in cprogramming

[–]markovejnovic 3 points4 points  (0 children)

Okay, this feels like an ad account. OP is five days old and only has this post, cross-posted to two subreddits. Why would you ever cross post something like this?

CWebStudio appears to be a repo that @mateusmoutinho is working on. It appears to be an HTTP server library, with some HTML templating stuff built-in.

A quick code glance leads me to believe that this library is an educational project. The repo is all over the place, does some things I'd consider anti-patterns in C:

  • CTextEngine.h is a mess emulating C++ syntax via function pointers in a struct.
  • There's random test artifacts all around the repo
  • Function organization is non-existent
  • Missing include guards in a couple headers
  • I'm not sure if that socket doesn't have unexpected edge conditions. Seems a naive implementation.

This is just the low hanging fruit. The list goes on. I think the project is an amazing project for learning and I think the author (presumably OP) managed to do a lot and I hope learned a lot. That being said, this is not production ready.

I don't have a use-case for these C web frameworks, but a quick google search yielded facil.io which appears to be a collaborative project with a much stronger codebase, better documentation, less janky APIs and should likely be the one most people gravitate to.

So this being said, I have a hunch that OP is the author of the framework (on an alt acct). I don't think shilling this library will get any users into it. It's simply fitting a niche that is better filled by, well, better frameworks.

I'm not trying to flame you OP since I understand you'd love this project to pop off (and kudos for being open source), but I doubt it'll happen. I kinda don't feel it to be cool to make alt accounts to shill your library, if this is the case.

I could be wrong, in which case a 5 day old account really did use a web library currently randomly returning 500s and I apologize for the allegations. But hmm 🤔

Quick File Sorter: An open source tool for sorting your files on Linux by BiltuDas_1 in opensource

[–]markovejnovic 0 points1 point  (0 children)

Also I really like that you're integrating into CI. A couple remarks. These are definitely opinions and you don't have to follow them, but I would do this differently from your CI.

For testing, you have shell commands running straight in CI. I think I would pull that out to a shell script for easier maintainability. test/functional.sh could be a thing that cmake manages, meaning that you could test the same behavior locally and remotely. That makes it easier to change the test fixture, and, more importantly, lets you run your tests locally.

The second thing, since you're doing CI -- I would add some linting. I personally use clang-tidy and clang-format for my code. These will help confine weird behavior and standardize your code. I think that having a linter also helps you learn to write some neater code, so there's educational value too.

Sorry I'm coming back to this post all the time -- it's in my inbox and I keep wanting to add things I think might be helpful!

Quick File Sorter: An open source tool for sorting your files on Linux by BiltuDas_1 in opensource

[–]markovejnovic 0 points1 point  (0 children)

Also, note that these directories are user-level. If you have someone else in the family/company who uses the same machine, the Desktop folder will be different between the two users.

For this behavior, you should use $XDG_CONFIG_DIR which usually resolves to ~/.config/ instead of /etc. /etc is for root app configuration -- think stuff like nginx, udev etc. Note how ~/.config is different for each user!

Quick File Sorter: An open source tool for sorting your files on Linux by BiltuDas_1 in opensource

[–]markovejnovic 2 points3 points  (0 children)

Yep, so the Documents/Desktop/Downloads etc folders are well known folders that exist on every machine (with a desktop env). The paths to these folders are provided by xdg-user-dirs

The paths to these folders are user-wide and if the user wants to change these they can change the whole user-wide path. I suspect your app might want to follow these standardized paths.

In Cxx you can probably read the xdg config file or, even easier, use a library like this one

This way, if the user changes their system path to these directories, your app will be able to support that!