/dpt/ - Daily Programming Thread

Old thread: What are you working on, Sup Forums?

Other urls found in this thread:

github.com/redox-os/kernel
youtube.com/watch?v=JtKqGa66CTM
hwaci.com/sw/mkhdr/
twitter.com/SFWRedditGifs

nice pic

>not Rustkell++

dropped

No, you daft little blubber; It's one of the greatest pieces of literature of the immediately preceeding generation

Thanks, I stole it from /r/rustjerk.

>tfw no language combining the freedom of js with the features of php and a bigger standard library
Imagine compile-time variable name autocorrection. Imagine = and == being aliases, only varying based on context. Imagine what could have been.

JS was the first language I learnt ~10 years ago. The "freedom" of JS is really retarded. It's like C but much worse and far better simultaneously.

>Why are the basics of computer science no longer relevant?
SICP is just an introductory textbook, nothing special about it, and textbooks tend to become obsolete. I mean, all the universities in the world teach CS without SICP, even MIT itself ditched it like 10 years ago, so I guess it's not relevant anymore. Yet SICP cultists got fixated on it for some reason, I guess because it's the only relatively useful book about Lisp.
But even if it were, why would a professional programmer waste her time on an introductory textbook for college freshmen, even on a very good one?

>SICP is just an introductory textbook, nothing special about it
It's a good introductory textbook. Not saying it's uniquely so, but it's worth reading.

>and textbooks tend to become obsolete
Still waiting for you to explain how the basic principles of computer science have become obsolete.

>all the universities in the world teach CS without SICP
>even MIT itself ditched it like 10 years ago
Some universities teach CS with SICP. Some don't. Argument from popularity fallacies are kiddie-tier.

>guess because it's the only relatively useful book about Lisp.
The book is not about Lisp.

>why would a professional programmer waste her time on an introductory textbook for college freshmen, even on a very good one?
>a professional programmer
>her time
>her
And now that I know where you're coming from, I know I can safely dismiss everything else you're about to say. Either way, most "professional programmers" (by which you mean third party library plumbers) can't code their way out of a shoe box, and would benefit greatly from reading as many introductory textbooks as possible.

these girls are literally LITERALLY seriously discussing SICP

Part of me hates C++. Simply because

It requires you to use a heavy IDE even for a CLI application: The thing with current C++ is, you have to maintain a separate header file and its source files. Should you need to update the function signature (because you realized you made a wrong decision while declaring it in the header) you need to jump back to the header file, fix it and make sure the signatures are identical.

No centralized package repo: I can't really blame C++ for it because the language came out way before github/bitucket/gitlab etc were a thing. I don't think C++ can ever fix this even if it tried. If they try to standardize project management, the older libraries and projects would not care. At all. Libraries like Qt will probably never get rid of their Qbs. Projects that are hardly maintained but necessary are not going to change from CMake or GNU Make. There are so many build system and interfacing over them is impossible.

On the same note, CMake, no matter how modern it is, will never have a dependency management system. Indeed, it's not a package manager. There are many software that are written in C/C++. When a specific library/package is not available in your distro's repo, you have to experience the taste of using CMake and manual package management. Honestly it hardly works because of dependency-hell.

Modern languages like, for example, Rust has cargo, a standard project manager that handles dependency management, project building, testing and benchmarking. D has dub, python has pip, ruby has gem. C++ has nothing, except for git-submodules which requires time and experience to master.

Before you think of mentioning Conan or Hunter, while their efforts are admirable, I would suggest you to look at their number of packages beforehand.

[ctd]

No open language server: The idea of language server is pretty new, but seeing how other languages already have multiple implementation of language servers you would think C++, being such a prominent language has one. Alas, the only one we got is clangd and it's still a WIP, not usable as of now.

There are millions of libraries written in C++ that can enhance your productivity. But you don't have a standard tool to handle all of them. Have fun using boost (or std::stringstream, or (god be merciful) strtok) to split a string.

Resources suck: While learning C++ in 2017 I only found 3 books that even mentions smart pointers. C++11 has been released since quite a while now. However some books introduce you to legacy pointers, new and delete but never introduces you to classes like std::unique_ptr. The learners have to look up online and learn about it. Even then, there is a fair chances that the resources you find online will not introduce you to the smart pointers as a full replacement of legacy pointers. Even though people will swear by it. For example, I didn't know std::unique_ptr does not provide a subscript operator. You have to use object.get()[]. Have fun discovering these as you go.

...

It's already settled (see: previous discussion) that all real work in Rust is done in C-mode, where no safety checks are performed, so system programming in Rust is still unsafe. That's not up for discussion anymore, and your delusions on the issue will continue to be ignored.

>I already mentioned a real life scenario where multiple mutable references are harmful
That's cute. Now I'm waiting for you to prove that they are universally unsafe. The fact that you shouldn't munge the same piece of data from several threads simultaneously doesn't prove that having multiple mutable references is universally unsafe. You can have multiple mutable references without munging the same piece of data from several threads simultaneously. To prove that multiple mutable references are universally unsafe, you have to prove that it's never possible to statically verify that they are not being used in a way that causes data races. Of course, you won't be able to do that, because humans are perfectly capable of deducing that no two threads will ever try to modify the same data at the same time, so it's a question of implementing the correct deduction rules and giving the programmer an ability to specify the necessary constraints.

>1% of code being C-tier unsafe means 100% of code is C-tier unsafe
It's like you can't into basic logic.

>1% of code
You mean 1% of your fizzbuzz code. When it comes to actual system programming, that's the 80% of the code where 95% of the bugs come from.

>work on C++ project because teacher only wants C or C++
>must serialize a struct
>heap corruption
Why are teachers against progress?

>that's the 80% of the code where 95% of the bugs come from.
Like double free, use after free, null pointer reference? Yeah, Rust covers most, if not all of those.

Why are people in the tech industry such dishonest niggers? I keep getting rejections despite doing highly on interviews and there are people I would consider brainless making 200k or more. Something seems wrong here.

You need to have people in place, references and lobbies and shit

>Rust covers most, if not all of those.
Only for your fizzbuzz code, though. Most system programming tasks don't involve immutable trees, and can't afford redundant dynamic borrow checking and reference counting overhead that comes from types like Rc.

So it really isn't about talent. Time for the fire and brimstone

>Won't count references because mah performance
>Won't do unsafe because mah "systems programming"
Looks like you are in a permanent denial, nothing is good for you.

Did you know Linux is reference counted and X11 is garbage collected? The more you know

>I keep getting rejections despite doing highly on interviews
>people I would consider brainless making 200k or more
You realize brainlets always think they are competent and "doing highly", while usually failing to recognize real competence in others, right? They then blame others for their failures because they can't see the real root of the problem. Not saying that's necessarily you, user. Just saying you should consider that possibility. In the meanwhile, show us evidence of your competence.

>When it comes to actual system programming, that's the 80% of the code where 95% of the bugs come from.
Is an actual kernel "system" enough for you? Because github.com/redox-os/kernel only has 7.5% of unsafe code, that's 92.5% less unsafe code than an equivalent C project would have. Obviously, user-mode stuff has even less.

BTFO

Reminder that if you don't use a GC you are a brainlet.

>using reference counting where necessary
>using reference counting even when cleanup responsibilities are trivial because rust is a shitlang
>this is somehow the same thing
>conveniently ignoring the other points
So this is the power of the Rustlet.

Not that guy but I can see why he'd feel that way. I recently interviewed for a company that blamed me for prematurely optimizing in an exercise that explicitly stated performance would be taken into account. Sometimes people just don't know what they're asking.

>using reference counting even when cleanup responsibilities are trivial
So better than manual cleanup. Good one, fucking brainlet. You just played yourself once more. Get the fuck out.

>Is an actual kernel "system" enough for you
Just because someone can afford types like Rc for every trivial structure in an OS class toy kernel doesn't mean you can do that for a real kernel. You can't even implement a doubly linked list without overhead in "safe" Rust. It's getting tiresome to point out the same basic fact over and over and watch the Rust subhuman sperg out in response.

>j-just because people can do this, it doesn't count

>there are people ITT who believe vectors should always be used instead of lists
programlets amirite lmao

>I recently interviewed for a company that blamed me for prematurely optimizing in an exercise that explicitly stated performance would be taken into account
What was the exercise, and what was the "premature optimization"? I can see how that would happen if you start autistically obsessing about minor details while the overall algorithmic efficiency of your solution is subpar.

No one thinks that. Arrays, vectors, RB trees and linked lists cover 95% of your tasks

>getting performance penalties in kernel code is better than manual cleanup when the cleanup responsibility is straightforward
You're precisely the kind of retarded monkey Rust was designed for.

It's over, m8, your bogus claims and false dichotomies were debunked with actual facts.

>kernel code needs to be high performance

Making a webstore based on reaction commerce as a part of a school course at my uni. Wew lad what a shitshow. Thinking of making a twitch bot for the hell of it and maybe refactoring a game project I've had for a while. Can't rly find the time or motivation tho

Oh boy, you must be the latest kernel hacker of Sup Forums. Must take balls when even LInus ref counted his kernel but you won't do it because it has safety overhead.

Sorting. Do you call properly ordering operations that would be evaluated anyways "autistically obsessing"?

moronic python noob back here. so, this program is supposed to calculate average rainfall over a certain number of years from the user with input validation error messages if the user enters something stupid.

i keep getting syntax errors and other weird error messages on the last three lines. what did i do wrong this time?

#Validates the user's input for number of years
def validate1(years):

try:
int(years)
except ValueError:
print ("I'm sorry, you've entered an invalid number. Try again.")
return

if int(years)

>even LInus ref cou...
No need to repeat "arguments" that have already been destroyed, monkey.

>even LInus
Linus doesn't do anything else than rage at the lkml

>Sorting. Do you call properly ordering operations that would be evaluated anyways "autistically obsessing"?
As I said:
>I can see how that would happen if you start autistically obsessing about minor details while the overall algorithmic efficiency of your solution is subpar.
For all I know so far, that might've been the case.

>manual cleanup
Ref counting is not only faster but also safer you autistic mongrel. You are going in full circles now.

>won't do ref counting because need performance
>won't do unsafe because need safety

>won't do ref counting because overhead
>Linus does ref counting
>"it doesn't count"
Too weak

Made an Ulam's spiral thingy in Erlang, it's pretty good, uses multiple threads and shit.

I once worked at a SV startup. Head Android developer and their CEO/CTO struggle for weeks on a problem with Andoid coming up with a solution that doubles the data usage. I looked the problem myself wondering what was going on, and came up with an ideal solution on the spot. I still get treated like an idiot - they insisted on the lead developer implementing the solution herself and basically taking the credit, she screws up using reflection to invoke public methods and refuses to fix it when I point it out to her. Needless to say I was underpaid with respect to my peers.
It wasn't just myself either, they once chose a pajeet candidate over an Asian who was a post doc at Stanford for a machine learning role.
This only scratches the surface of the horror story, some of it is too horrible to imagine.

>that might've been the case
Dude, it can't be prematurely optimized if it's going to happen anyways.

>doing completely unnecessary operations is faster than not doing them
>i'm too dumb to do trivial cleanup correctly so i need redundant reference counting in performance-sensitive code to do it for me

>Linux is reference counted
The fuck? All these years Sup Forums told me reference counting is slow? WHY THE FUCK IS THE KERNEL REFERENCE COUNTED THEN?

I mean if the way the solution was implemented is inefficient then it's inefficient, not prematurely optimized.

>it can't be prematurely optimized if it's going to happen anyways.
I can see why you would get rejected. You fail even at basic reading comprehension.

>i'm too dumb to do trivial cleanup correctly
So you are one of those that think turning on the "make no mistakes" switch will solve world hunger.

Never reply to me again, basement dweller.

>makes dumb assumptions
>doesn't know context
>thinks he knows better
>actually is the one who can't read
This is... the power... of /dpt/

Your parenthesis are fucked up m8

post the error messages too

It isn't. It's both faster and safer than manual memory management. Why do you think C++ moved to smart pointers?

Parentheses even. Anyway, your missing some closings. Usually the problem lies in typos

std::unique_ptr has almost no overhead but I always see more of std::shared_ptr in production, which is ref-counted.

It's just easier to work with shared_ptr 2bh

>faster
No. Especially not in a multi-threaded context.
>safer
Agreed but it can leak memory.

>I keep getting rejections
git gud
>despite doing highly on interviews
doubt

Alright, I fixed the parentheses. Now the error message I'm getting is:

Traceback (most recent call last):
File "python", line 48, in
TypeError: unsupported operand type(s) for +: 'int' and 'str'

wtf does this even mean

>obsessing about minor details while the overall algorithmic efficiency of your solution is subpar
Misguided attempt at optimization != premature optimization

line 48 being this:

print("The total inches of rain was: " + str(sum(rainFall)))

>I mean if the way the solution was implemented is inefficient then it's inefficient, not prematurely optimized.
It's one thing if your solution is just inefficient. It could be that your inefficient solution is efficient enough for whatever use case, and makes up for it in simplicity. If they're unhappy with that, they will typically ask if you can make it more efficient. If, however, your code is fundamentally inefficient while also being complicated by your autistic twiddling with things that have little impact, that shows that you have no idea what you are doing, and that in a real-world scenario, you will not only write inefficient code initially, but also waste time micro-optimizing it before timing it to see if the approach is viable at all. That is premature optimization.

>reference counting is slow?
well duh, counting is slower than doing nothing, is this news to you?>It isn't.
found the retard
>Why do you think C++ moved to smart pointers?
because you were too dumb on your own?
>I always see more of std::shared_ptr in production
of course, most people are incompetent

Sure, user. Everyone out in the real world and doing real work is just too competent to understand your genius. I should have simply assumed that instead of proposing a more realistic possibility and asking you to provide useful details (which you have repeatedly failed to do, showing your inability to follow instructions).

Would /dpt/ pass pajeet interview?
youtube.com/watch?v=JtKqGa66CTM

You need to go back. This is a numale-free zone.

Somehow it doesn't like it if you sum it inside the str operation, just get it before sticking it in there. I guess it's better to do the counting before stuffing it in the print anyway, as you end up getting the sum for the same thing twice. Nitpicky but oh well.

You're in the real world while "autistically" posting instead of doing your real work.
And you don't even know what premature optimization means.

So of all this drama around Rich Hickey's statements about static typing, I want to know what we've productively gained from it:

Can we have statically typed arbitrary, nested data structures, and can we do it with usable, readable, understandable semantics? I feel like this might be a good research paper for a languages PhD.

Good thing we got variants in C++17, can't wait for C++28 with the pattern matching.

>her time
I always cringe when people try to be inclusive by sometimes writing he and sometimes writing she, just use they when the gender of the person is unknown.

>you don't even know what premature optimization means
"Premature optimization" means trying to optimize code before finding the real bottleneck, fucktard. If your attempt at an efficient sorting algorithm came out as O(n^2) or outright broken, but you waste your time fiddling with barely-relevant details blissfully unaware of that, you are doing premature optimization.

>just use they when the gender of the person is unknown
In this case, just use "his", because women can't code, hence the gender of the (presumably competent, from the context) professional programmer is known.

Come on, there are some smart women in STEM, don't shit on everyone just because of the current SJW bullshit in tech.

>there are some smart women in STEM
I was talking specifically about programmers. Where do I find competent female programmers?

Now who could be behind this post?

...

Come on now, you should be able to recognize that writing style.

I'm a male, not a female, if that's what you're implying.

>trying to optimize code before finding the real bottleneck
By designing the code in a way that prevents maintainability/optimization, not refactoring working code.

>get a degree ("free")
>move to somewhere in southeast asia
>start freelancing
>list location as home country
>80% savings rate easily with low cost of living and taxes, still get a first world salary
Any pitfalls? How do I set it up legally with the companies and all that? Will I have to pay income tax in my home country if I use a company registered there?

>numale
ftfy

...

Is there a way to generate C++ header files from .cpp source files?

I'm a good programmer and I don't have a Y chromosome
makeheaders

yes, just rename the .cpp files to .h files

why didn't I think about that earlier

>tfw failing programming class
i wanna shoot myself in the head

Here. It's from the guy who makes the Lemon parser generator and SQLit.
hwaci.com/sw/mkhdr/

I believe in you user, you can do it!

good the industry is becoming saturated anyway

Sure you are, how's it going with the ASP.NET project?

Post yfw asp.net actually redirects to the asp.net website

Nope. I write code for robots

void menuPrinter();
void pizzaChecker(string pizza[]);
double priceChecker(double price[]);
double pizzaSize(char &idLike);
void toppingArray(string toppings[]);
int toppingCounter();
void toppingAdder(double price[], string pizza[]);
void toppingMenu(string toppings[], int length);

const int FULL_PIZZA = 7;

int main ()
{
double price[FULL_PIZZA];
string pizza[FULL_PIZZA];
double sizeCost;
double finalPrice;
char size;
int choice;
int length = 18; //toppingCounter();
string toppings[18];

menuPrinter();

cin >> choice;

toppingArray(toppings);
switch(choice)
{

case 1:
do
{
cout > size;
sizeCost = pizzaSize(size);
if (sizeCost != -1)
{
cout

where are the #includes mate