/dpt/ - Daily Programming Thread

What are you hacking on, /dpt/?

Previous thread:

Other urls found in this thread:

15445.courses.cs.cmu.edu/fall2017/schedule.html
youtube.com/playlist?list=PLSE8ODhjZXjYutVzTeAds8xUt1rcmyT7x
15721.courses.cs.cmu.edu/spring2017/schedule.html
ipfs.io/ipfs/QmeRy1Wji4MjrUTYJ
twitter.com/NSFWRedditImage

Repostan :

Expanding upon my point: I mainly code in C++ right now because that's what my Uni uses.

c++ is the best language of all time

CLion seems nice but isn't free.

Go to bed Bjarne

This is extremely OOC.
5/10 good edit at least.

I made the perfect integer square root function function in python
def isqrt(N):
half = N.bit_length() >> 1
a, b = N, (1 > half) >> 1
while a > b:
a, b = b, b + N//b >> 1
return a

Let's design a CS curriculum, /dpt/!

>Scheme
>ML
>Prolog
>Haskell
>Agda

I looked at the github you put on your resume and your profile picture is a cartoon girl.

Care to explain?

Hey if it's a feminine penis it's not gay- I'm not gay, haha...
I mean
what was the question again?

figured out the last 8 digits of 1777 ^ 1855

#include
#include
#include
#include

uint64_t powMod(uint64_t a, uint64_t b, uint64_t mod) {
printf("powMod (%llu, %llu)\n", a, b);
uint64_t result = a;
while (b > 1) {
result = (result * a) % mod;
b = b - 1;
}
return result;
}

uint64_t dubsMod(uint64_t a, uint64_t b, uint64_t mod) {
printf("dubsmod (%llu, %llu)\n", a, b);
if (b == 1) {
return a % mod;
}
else {
return powMod(a, dubsMod(a, b - 1, mod) % mod, mod);
}
}

int main() {
printf("%llu\n", dubsMod(1777, 1855, 100000000));
return 0;
}

I masturbate to chinese cartoons and post about it on an smoke signals forum too.

It's none of your fucking business matey boy. I put it there so you can look at my projects in awe, nothing else. Remember that you need me to take this job, whereas I've got other offers already lined up and gagging for me to say yes.

>Lisp
>Lisp
>Lisp
>Lisp
>Lisp

don't use inheritance
you can use classes just as a way to group data and functionality together and to split things up neatly into header and implementation files
and there you go, that's pretty much all you need to do

I've never done anything with databases and now my project ideas all need databases but SQL is so fucking boring.

Even reading the SQLAlchemy docs which wraps a bunch of shit is mind numbing.

so don't do it, then?
store all of your data in a simple text file like a csv or something
then parse it to read data and print it when you need to save data

Just don't use OOP. It's a dying paradigm.

it's really not that big a change
the vast majority of code that the average OOPer writes is just regular procedural code

>mfw there are people trying to major in cs in the current year

Do yourself a favor and major in something that's not a sinking ship like math, accounting, or electrical engineering. The number of cs enrollments on every campus in America is quadrupling. This means that there will be higher unemployment, lower wages, more competition, and less job security for people who work in software. Programming should be a hobby only. Not a career.

Do you really think all those people will turn out to be great programmers?

"conservative" languages: Java, C++, PHP
"liberal" languages: Javascript, Ruby, Python
"right-wing" languages: C, Forth, ASM
"left-wing" languages: Lisp, Haskell, Rust

Agree?

>enterprise languages
>web/scripting languages
>languages i like
>languages i don't like

I'm going into Computer Engineering.
I feel like there's a LOT less of us compared to Software Engineers and Computer Scientists.

Trying to build some zirconium crystals to match experimental data. Shit's rough.

Only companies like Google, Amazon, Facebook, etc. care about great programmers

The rest only care if you can use X javascript framework

>Google
>great programmers
>no exceptions allowed in c++
>created go for its employees to use

well yeah, comp eng is more like EE than it is like CS

Feels like something I should learn
Especially if I ever want a job

>Especially if I ever want a job
yeah it would be good to know
I'd say just start a project that needs a DB and learn it as you go
it's really dead simple
do a Select to get data out, Update to change data, Insert to add new data

I'd suggest setting up a mysql database on a local server on vmware or something and then install phpmyadmin
this way you can poke around, create your DB and tables with the GUI and visualize the thing
also helpful for debugging

Take a real course in dbms, here's a CMU course
15445.courses.cs.cmu.edu/fall2017/schedule.html

The lectures are open: youtube.com/playlist?list=PLSE8ODhjZXjYutVzTeAds8xUt1rcmyT7x

uses sqlite and you do some advanced SQL, which is interesting. There's a running meme in the course the professor is a shady criminal, you'll understand what that means when you watch the lectures.

Also the advanced version you build your own dbms 15721.courses.cs.cmu.edu/spring2017/schedule.html

Anybody have that massive list of coding challenges that were color-coded with difficulty?

If not, any big list will do. Hoping to fiddle with some challenges.

ORM is a step up from using the simple sqlite drivers. So stick with the sqlite drivers for w/e language you use. then learn the sqlite lexicon for its use. Sqlitebrowser is a great tool.

found it

>30 hours of lectures
truly a monumental waste of time, as well intentioned as this post was
just dive into it and google when you're stuck
you'll learn 10 times more in one tenth the time

Is there a less stupid way to swap the first and last letter of a string?
Console.Write("Enter a word: ");
string word = Console.ReadLine();
string front = word.Substring(0, 1);
string back = word.Substring(word.Length-1);
string words = word.Substring(1,word.Length-2);
Console.WriteLine("{0}{1}{2}", back, words, front);
Console.ReadLine();

Well Sup Forums? What does it print?

#include

int main()
{
int i = 0;
int arr[2];

arr[i++] = i++;
std::cout

0, uninitialized garbage is my official guess

Are .app, .presentation, .interface and .account legit executable filetypes in java? How would I execute them, assuming that the console class is in the .app file?

>tfw graduating in 3 weeks
>no job offers or even one real interview after applying to 18ish places
I-I'll get a job eventually right?

Time to start your Fiverr career

thanks for advice

Nope.

Yeah, after compiling it it looks like I got it backwards.

3 biggest factors in getting interviews imo are:

1)Type of school you went to(Stanford or some no name flyover state college?)

2)Quality of internships you have had(no internships is a death sentence)

3)Resume quality(companies receive over 500 resumes for single opening so you better have one that sticks out)

I know you're joking but I'm getting kind of scared I made the wrong life choice.

Are you guys doing the advent of code thing?

Yep. I honestly didn't know what it would do which is why I thought of it in the first place.

Well fuck. I can maybe build a better resume since I will have no job and lots of time to code.

I was going to, but the first problem is too hard.

this is sarcasm right?

>mfw people hear about composition over inheritance and think that it means they should compose all the functionality of their derived classes into a single class instead of composing the functionality of the base class into the derived classes

I applied around 40 times over the course of a couple months and landed just 3 interviews. 2 were with smaller companies, one was with a large corporation. Still work at the corporate job but the trick is apply nonstop. You'll get in touch with recruiters who can help you later on if nothing else.

>class inheritance

I have no idea how to read in a single character from a file as an integer in C++.
Probably gonna have to read documentation for fstream's read function.

bitte antworten

i just copied and pasted it as a string, getting a character at an index is extremly trivial in sepples

If you're reading it from a file you'll probably want to feed it into a string anyways to make the secound part less obnoxious

The next bubble will be in Biotech, basically degrees in computational aspects of high-throughput laboratory methodologies for large-scale, systematic studies of protein structure and function, analysis of biological image data and especially computational genomics.

Already schools like MIT and Ivy Leagues have been filling their bio engineering/biotech departments in prep for the coming bubble. You won't do fizzbuzz in interviews, they'll ask you to do shotgun sequencing in parallel.

Inheritance sucks but many people use composition in a way that's just as bad or even worse.

What's the second part? Do I have to login to see it?

you have to beat the first part to get it, you do something similar to the first part

Oh okay.
So how do you have to convert the individual characters to integers to add them?

In ASCII standard the value of letters and numbers are in order
that is if 0 has a value of n then 1 has a value of n+1

oh so you just subtract the offset before adding to your total, thanks for the tips man

np m8

It's time for C.

>He doesn't compile with -flto

that would be the weapon form of JS or any dynamic shitlang though.

C
C++17
Intro to systems programming
Computer architecture
Operating systems development
Compiler development

>CS curriculum
>no subjects, only meme languages

>instead of composing the functionality of the base class into the derived classes
This is completely retarded.
Why would you repeat yourself like that?
The whole fucking point of inheritance is that you don't repeat yourself.

Although templates customized with concepts/traits at compile time is better than inheritance.

arr[i++] = i++;
those are post-incrementing which means that they only increment after execution.

therefore arr[0] = 1
however, i = 2

arr[1] = uninitialized garbage.

If it wasn't clear by the part about replacing composition with inheritance, there wouldn't be inheritance at all. Base and derived classes refer to how they would be with inheritance.

Oh and by C I mean C11. ANSI/C89/C99 tards can fuck off.

Is it guaranteed that the left hand side of an assignment is evaluated before the right hand side?

all I know is C so it might be wrong for other languages but...

++i = increment i before execution of i
i++ = increment i after executio of i

I mean if you have a[i++] = i++ is it guaranteed that it's a[i] = i + 1?

But C11 didn't introduce of value apart from finally making anonymous structs/unions. There's _Generic but it's so limited that it's barely generic.

Then maybe threads.h in libc but it's optional and implemented in only a few libc. The only real way to go about it is that header that wraps pthread.

>C11
your programs will contain 98% C89/C99

In C yes.
just tested it with the debugger and can in-fact confirm.

Doesn't matter. It's the newest standard and therefore you should be using it by default.
There is NO reason to stay on old standards unless it actually breaks something and it's too much trouble to fix it. C11 doesn't do this so there's literally no reason at all.

Also, anonymous structs are useful, so may as well make them available.

>Hur one implementation does it therefore all do
>UB? What's that?

"Works on my machine" does not mean guaranteed.

C11 did make VLAs optional though, something required by C99.

Not that they were very helpful, but that is broken compatibility right there.

Also you want the newest and greatest, that's latest GNU C. As much as it sucks to say, a lot of what comes from ISO was taken from gcc. Also some of POSIX comes from glibc.

>not every system has latest GCC
Not every system has a C11 compiler either.

I got the right answer for the first part!
The last two characters in the string returned by ifstream::read are flags, which was throwing me off.

>Also you want the newest and greatest, that's latest GNU C
Not standard.

nice, you should be able to avoid adding those by checking for eof() i think

I've made a simple IPFS imageboard. No server-side code.
ipfs.io/ipfs/QmeRy1Wji4MjrUTYJ
fXUW7BMaGsfqLa8UM77Gxaow6pdnV/

Wow, great imageboard.

>78 - Dijkstra's
Joke's on you, I already did my homework.

...

Obviously. Unless you only care about being standard C, I think gnu99 is more distributed and available than standard C11 at this point.

Doesn't really matter though, I don't agree with making your project -std=gnu11 but it gives the most features and you were just arguing for features.

C is slower to pick up than C++, there isn't a new standard every 3 years. Many projects can't even get off C89 at this point.

Unless your program is widely distributed, which it probably isn't if you're using C11, just stick to a "C" and leave it at that. The standard doesn't matter. For example linux is still gcc, it has no reason to change either.

I did it on purpose. Else it's blocked by Sup Forums as "spam".

What does the console tell you? An extension is most likely causing this.

I know there's a space, how do you think I got to the site in the first place?

Pic related.

>and you were just arguing for features.
No, I was arguing simply for the latest standard, regardless of features.

did we ever solve the "self-awareness" problem?

Finished the second part!
I'm gonna make it this year.

But nothing in C is "latest and greatest", regardless of standards.

If you look at any code base that is older than 10 years, all you see splattered everywhere is:

#ifdef
#ifdef
#endif
#endif
#ifdef
#endif
#ifdef
#endif

There's no way in hell of changing that to C11 without a full rewrite, they're almost trying to support the ENIAC at that point.

Arguing that a new C project should be C11 instead of GNU11, I would agree with that. Except I wouldn't agree too hard considering clang also supports all the GNU shit and if you want to use it, go ahead.

>clang also supports all the GNU shit
it doesn't