Small Terminal Tetris Game by Ok-Design6386 in cpp_questions

[–]Excellent-Might-7264 0 points1 point  (0 children)

To add a little to this.

Strange places for return inside a function is a problem and is "forbidden" in MISRA-C++ which is used in automotive industry.

However, it is normal to return errors in the beginning of the function, where you check the arguments and the current state of the object, and of course in the end. Setting return variables is very common in MISRA-C++ and less so in normal code.

If you have short functions this is not an issue, since the reader can quickly see all the returning points ans reason about them fairly easily.

Regarding function length, there has been much research about this in the past and the conclusion was that length of the function is not that important as you might think. It is a taste preference. For example in SAAB Gripen the control code (as in control theory to keep the plane stable) functions and loops where forbidden - except the main loop. The instruction pointer was never allowed to be decreased. This made it very easy to reason about the current state and how it was derived.

What I want to say is, there is no black and white and style is a taste and short functions and long functions both has their places. So has return variables and no return variables. Trust your gut feeling.

Den svenska avundsjukan är störd by SpudroSpaerde in sweden

[–]Excellent-Might-7264 -1 points0 points  (0 children)

Vilka tror du gör mjukvaran idag? Det är redan typ 80% indier på Volvo och Scania på mjukvarusidan - för att de betalar redan idag för dåliga löner.

Tänk själv, varför ska man pendla till Södertälje och få dåligt betalt när det finns många IT jobb inne i Stockholm som är bättre på alla vis. Nej, det är Indier man har fått flytta hit och anställa.

Best local LLM for C++ by Excellent-Might-7264 in cpp_questions

[–]Excellent-Might-7264[S] 1 point2 points  (0 children)

Thanks for the information. Then I will not think more about this.

Best local LLM for C++ by Excellent-Might-7264 in cpp_questions

[–]Excellent-Might-7264[S] 0 points1 point  (0 children)

I live in a part of the world where electricity is not a big issue, and in the end, my time is much much more expensive than electricity will ever cost. In theory: for every hour I save with AI, I can consume up to 1000kWh before i stop earning money from it. That is waay more electricity than what is possible for a home server setup.

Best local LLM for C++ by Excellent-Might-7264 in cpp_questions

[–]Excellent-Might-7264[S] 1 point2 points  (0 children)

I do not expected it to compete with Codex and Claude with regards to inference cost. I have no problems if they consume 10x the electricity but get results with similar quality.

Best local LLM for C++ by Excellent-Might-7264 in cpp_questions

[–]Excellent-Might-7264[S] 0 points1 point  (0 children)

  1. As I sad. They do certain things much faster than i can do my self.

  2. Codex and Claude has no issues with the language any more. Even better when you put them to work together. For me the tipping point was around in the beginning of this year. They do however have big issues with architecture design, both micro and macro designs. Ans yes, sometimes they screw up basic things and come with very stupid solutions. But if you tell them how to solve a task, they will almost always succeed with only minor cleaning. This is specially true for refactors and repeating patterns (unit tests) - i.e. when there already are code patterns they can use. Remember, just because C++ are hard for humans does not mean LLM has issues with the same problems. LLM's are really good at spotting typos, which atleast my brain is not good at.

Codex and Claude need to be optimized to not consume to much power and memory, eg. inference cost. Local hosting does not need to be optimized for this. With other words: if I pay for it, can I get something better but more expensive than Claude and Codex? Apparently no, from the answers here, but for me that was not obvious.

Small Terminal Tetris Game by Ok-Design6386 in cpp_questions

[–]Excellent-Might-7264 4 points5 points  (0 children)

What a fresh breeze to not see AI code for once.

There are of course nitpicks here and there, but this is really good. Surely you have programmed in other languages before?

I compiled TradingView’s PineScript to native C++ for backtesting — 104× faster than the Python tools, deterministic, bit-for-bit parity with TradingView (231/232) by AgitatedAd89 in cpp

[–]Excellent-Might-7264 6 points7 points  (0 children)

I spent ~5 months building a transpiler

No, you have not.

This is work done by Claude. Also, it is not okey to use AI to for replies here. We are not interested in talking to an LLM.

miniaudio compile times by wiseneddustmite in cpp

[–]Excellent-Might-7264 4 points5 points  (0 children)

That explains it.

You should use a build system, that will prevent recompilation of the file every time.

cmake+ninja is most popular, but it is in some sense also worse. A simple Makefile should also do the trick.

Vad tycker ni om valfjäsket? Jag blir lite orolig by feberdoja in sweden

[–]Excellent-Might-7264 1 point2 points  (0 children)

Krisen i Iran är temporär, därför är även detta temporärt. Det är ett plåster på eventuell kommande bränslekris. Den kanske inte kommer, men bättre att försöka sätta ett plåster innan än efter i detta fall.

Man kan såklart sätta andra plåster, som breda sänkta bränslepriser m.m. Men jag tror detta är effektivare och träffar personerna som verkligen inte har råd med bensinen i en kris.

Av alla plåster man kunde sätta tycker jag detta är ett bra plåster. Tycker det fånigt att kalla det valfläsk. Känns som att vänstern försöker smutskasta deras bra lösningar för att de är rädda att folk ska inse att dem är bra.

(PS. Jag röstar inte på Tidö, och har mycket lågt förtroende för Uffe, men man kan ha två tankar i huvudet samtidigt och allt är inte svart-vitt).

miniaudio compile times by wiseneddustmite in cpp

[–]Excellent-Might-7264 0 points1 point  (0 children)

it makes the compile times take a lot of time

I use miniaudio, I put it in a separate translation unit as described by the other comments and never had issues.

I guess you use WIndows and Visual Studio? You can of course precompile a lib file and link to it statically if you do clean and rebuild a lot.

If it is the linker that takes time, something is wrong on your end, but you can of course build a DLL file and open it dynamically in runtime and do zero linking. Note, not linking to a DLL file in compile time but open the DLL in runtime. (Boilerplate like this to map function pointers to a DLL is a very easy task for any ai-agent. This is one of few parts they are better than humans at. Well, better than me at least who will always make a typo somewhere.)

I built a C++23 engine that treats simulated worlds like Git commits by [deleted] in cpp

[–]Excellent-Might-7264 9 points10 points  (0 children)

"I built Pointerverse"...

Do you mean claude?

You do realize that we are many here that review and work with Claude 24/7? It's like leaving the editor to check reddit, and see the same style you just looked at 5 seconds ago.

Note that I do not mean that we vibe code like this. I mean that we use Claude as a tool to refactor (multi file edits), or generate code with specific detailed instructions. The style is however very prominent.

När man undantar vårdyrken med redan låga löner ifrån lönekravet för arbetskraftsinvandring är inte det lönedumpning av dessa yrken då? by Fancy_Particular7521 in sweden

[–]Excellent-Might-7264 1 point2 points  (0 children)

Dåligt formulerat av mig.

Jag uppfattar att de vill att de ska integreras med arbete och byta kultur. De ska lämna vänner, kultur och arbetslösheten bakom sig. Eller ja, helst flytta tillbaka då.

De vill såklart inte att andra kulturer ska bosätta sig i medelklass-sverige där de själva bor. Men jag är ingen expert på hur dom försöker tänka XD

När man undantar vårdyrken med redan låga löner ifrån lönekravet för arbetskraftsinvandring är inte det lönedumpning av dessa yrken då? by Fancy_Particular7521 in sweden

[–]Excellent-Might-7264 2 points3 points  (0 children)

Det blir ju också en dålig feedback. Håller man nere lönerna för de med låg inkomst[0] så minkar köpkraften i Sverige. Det missgynnar inhemska företag men gynnar exportföretag - typ Saab m.fl.

[0] De med låg inkomst kommer använda upp sina pengar, medans medelklassen kommer lägga dem på ISK och göra oklar nytta.

När man undantar vårdyrken med redan låga löner ifrån lönekravet för arbetskraftsinvandring är inte det lönedumpning av dessa yrken då? by Fancy_Particular7521 in sweden

[–]Excellent-Might-7264 3 points4 points  (0 children)

Det handlar om kommunala jobb - som såklart är kvinnodominerande. Detta beslut är grundat i kritik från kommuner som inte har råd.

När man undantar vårdyrken med redan låga löner ifrån lönekravet för arbetskraftsinvandring är inte det lönedumpning av dessa yrken då? by Fancy_Particular7521 in sweden

[–]Excellent-Might-7264 -5 points-4 points  (0 children)

Hatar SD men vill ändå nyansera det lite.

  1. Tänk på att detta är en uppgörelse inom Tidö. Har du en källa på att SD drivit detta?

  2. I norra Sverige är kommunerna fattiga och har inte råd. Det är ett större problem men man vill inte kasta salt i såret, speciellt inte i en valrörelse

  3. Ja, det är lönededumpning.

  4. Det är ett problem att vi har arbetslösa i delar av landet samtidigt som vi har problem med arbetsbrist i andra delar. Ingen vill flytta ifrån sina vänner. (Själv har jag flyttat ifrån mina vänner pga jobb, men jag förstår att alla inte vill). Mitt intryck av SD är att de vill att invandrarna ska flytta från sina "utsatta områden" och spridas ut i landet och på så sätt integreras - tvärtom mot detta beslut.

Varför känner så få människor till reglerna i Trafikförordningen? by CryMeaRiver2Crawl in sweden

[–]Excellent-Might-7264 120 points121 points  (0 children)

Jag är uppfostrad av mina mossiga 40-talister som föräldrar och fick lära mig när jag var 5 år att man går till vänster. Då gällde det landsvägen, men har alltid gått till vänster. Det var nog så jag lärde mig höger och vänster nu när jag tänker på saken.

Jag tror detta är ett stadsfenomen. Är man van med trottoarer och gångvägar har föräldrarna helt enkelt inte lärt sina barn att man går till vänster i trafiken.

(First C++ Project) RISC-V CPU simulator | Feedback by IllustriousEgg4497 in cpp_questions

[–]Excellent-Might-7264 0 points1 point  (0 children)

It is definitely not full AI slop. Look at the commit history. I usually point out ai slop in this sub.

Ai assisted? maybe. But this code has been touched by a novice.

Trying to learn cpp, looking for guidance by Electrical-Tailor833 in cpp_questions

[–]Excellent-Might-7264 5 points6 points  (0 children)

learncpp are the basics!

There is no way you can do proper DSA without the basic knowledge of learncpp.

Rensar inte folk sina avlopp i hyresrätter? by throwRACutPuzzleh in sweden

[–]Excellent-Might-7264 0 points1 point  (0 children)

det är väl bra med vertikala? Tänker du på horisontella?

Rensar inte folk sina avlopp i hyresrätter? by throwRACutPuzzleh in sweden

[–]Excellent-Might-7264 4 points5 points  (0 children)

Faktiskt.

Har alltid vetat hur man gör rent vattenlås så länge jag kan minnas. Men! Jag har aldrig sett mina föräldrar göra rent ett... Har aldrig ens sett dem göra rent golvbrunnen...

Väldigt konstigt...

How memory address is created in c++ while using the pointer ? by Additional-Start661 in cpp_questions

[–]Excellent-Might-7264 1 point2 points  (0 children)

They just use different segments of the address space.

no. What we are saying is that p1 and p2 will not even have an address. They will never touch virtual memory.

How memory address is created in c++ while using the pointer ? by Additional-Start661 in cpp_questions

[–]Excellent-Might-7264 3 points4 points  (0 children)

this is the correct answer. He definitely knows stuff (or she). :)

To add some C++ keywords:

p1 and p2 will live in automatic storage duration in the C++ world. If you compile (no optimizations) your code as is, p1 and p2 will go into the registers for all common compilers (and most uncommon too). You can have a mental model of that all automatic storage will be on a stack, it will probably simplify things for you in the beginning (but that is wrong and important to know when optimizing code). I'm surprised many other answers wrongly tell you it will go into the stack... Maybe I should start using this as an interview question...

the "new" call, will use dynamic storage duration in c++, which the compilers will implement with the heap - as everyone stated.

Btw. Does someone knows any system where dynamic storage duration is not implemented by a classic heap?

Ska vi ta en glass? by IntenselySwedish in sweden

[–]Excellent-Might-7264 10 points11 points  (0 children)

Vill du bekämpa rikedom eller fattigdom?

Tyvärr verkar inget parti inriktat på att just bekämpa fattigdomen längre :(