/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

harmful.cat-v.org/software/c /I_did_it_for_you_all
hastebin.com/upofuqayug.cs
youtube.com/watch?v=NvWTnIoQZj4
common-lisp.net/project/ecl/)
youtube.com/watch?v=ZhuHCtR3xq8
youtube.com/watch?v=75Ju0eM5T2c
rubykoans.com/
twitter.com/SFWRedditGifs

almost first

Lisp is the most powerful programming language.

reimplementing rust in c

which lisp you fucking poser

I love C++.
I unironically believe it is the best language available.

>harmful.cat-v.org/software/c /I_did_it_for_you_all
Stroustrup: Well, it’s been long enough, now, and I believe most people have figured out for themselves that C++ is a waste of time but, I must say, it’s taken them a lot longer than I thought it would..

Is memmove basically:
void *memmove(void *dest, const void *src, size_t n)
{
void *tmp = malloc(n);
memcpy(tmp, src, n);
memcpy(dest, tmp, n);
free(tmp);
return dest;
}


or is the description just off on it?

does anyone actually think thats real

There is only one good Lisp.

>this link
Hey look, it's that fake news stuff Trump kept telling me about

>
even if its fake, the lang is still fucking abomination

Its actually kind of funny how uncomfortable bjarne and other c++ heads get when asked about other languages.
c++ con is like the village

hastebin.com/upofuqayug.cs

The while loop asking to play again won't work, I use openJDK on windows from RHEL.

Pretty much, but it would be implemented more efficiently than that.

>funny how uncomfortable bjarne and other c++ heads get when asked about other languages
youtube.com/watch?v=NvWTnIoQZj4
wow, so uncomfortable

that sure is a short cppcon talk

Is SBCL fast enough to make games in?

Wow that rambling at the end really brings his insecurities to the surface. I saw the same with Carmack.

It essentially translates to "I know it's better, but I can't admit that I've put so much effort into something inferior and even if I could, I'm too old and comfortable to change"

C++ can be wrangled into a decent language even for a team. Like a style guide for project code methodology/idioms. It's a lot of work but nothing really scales to the same levels that C++ can easily, excepting of course Rust which nobody wants to use, is difficult, and is too immature for anything important.

i think it's the fastest implementation of common lisp ever

of course it'll never be C grade performance

Rate my sudoku solver!
int sudoku_deduce(struct sudoku *pz)
{
/* compute missing numbers with vectors
* return 0 if stuck
*/
restart: ;
short box[3][3] = { { 0 } };
unsigned i, j, k, l;
for (k = 0; k < pz->size; k += pz->sq) /* box */
for (l = 0; l < pz->size; l += pz->sq)
for (i = 0; i < pz->sq; i++)
for (j = 0; j < pz->sq; j++)
box[k/3][l/3] |= (1 arr[k+i][l+j] - 1));
for (i = 0; i < pz->size; i++) /* find next missing no. */
{
for (j = 0; j < pz->size; j++)
{
if (!pz->arr[i][j])
{
short row = 0, col = 0;
for (k = 0; k < pz->size; k++) /* row */
row |= (1 arr[i][k] - 1));
for (k = 0; k < pz->size; k++) /* col */
col |= (1 arr[k][j] - 1));
short vec = row | col | box[i/3][j/3];
if (vec == 0x1FF) /* maxed out all 9 bits */
return 0; /* cannot continue */
while (!pz->arr[i][j])
{
unsigned num = rand() % 9;
if (!(vec & (1 arr[i][j] = num + 1;
}
goto restart; /* state has changed */
}
}
}
return 1;
}

>of course C++
>related videos
>him calling C obsolete

hmm... seems like he's trying to compensating for something obvious

seems like you're the one who's insecure

C is obsolete though

At that point, you could try ECL.

compensate*

If you are a young, inexperienced programmer, do yourself the favor of learning FP first (and delve into type systems second). It's the future. The C approach was short-sighted, a mistake governed by a miscalculation of just how incredibly far hardware would go in such a short span of time. Now that things such as parallelism and GPU programming are clearly the future, FP (and safety through types) is the obvious future.

I think you're being unduly harsh.

The languages that will succeed C++ are standing on the shoulders of giants, just as C++ stands of the shoulders of giants.

C++ is 34 years old. Programming language research has come a long way since then. Any modern language doesn't have nearly as large a ball-and-chain of backwards compatibility to lug around with it as C++ does.

C++ is a huge improvement over the languages it supplanted.

XD he memed again!
LOLOL hahahaa!!1

assembly is better

I started learning C++ recently. after Js, Python and C it looks so ugly I started thinking about learning Rust instead..

Unless you're making an AAA game (I'm not), you probably don't need C/C++ grade performance. You can afford to use a language that runs 1/2 or 1/3 as fast.

What's ECL? Link please?

On the contrary, you can't even hack me

I'm sure C++ will forgive me for not sparing its feelings. It's not being harsh, it's being pragmatic, and it's an observation about these people. I admire their contributions and skills/artistry, but you can clearly see it when they speak: They understand that C++/java/etc is a dinosaur and FP is the future, but it's a future they aren't equipped to be a part of.

anyone who wants to be a professional or do any really fun hobby programming should already know assembly

Embeddable Common Lisp (common-lisp.net/project/ecl/)

yeah i guess you're right, you probably won't need it for a 2D shmup

as for ECL i don't know if that's a good idea, your program technically goes through 2 compilers, doesn't it?

Thanks

why would you rope carmack into this group?
he's totally into fp

So im retaking a computer hardware class (needed a B and got a B-) and I already took my programming class to take with it (object oriented programming) so I will be taking the next class this summer but Im scared I wont remember anything about c++. Thoughts?

yeah but if you already know assembly why would you ever learn anything else

it's just better

do the C++ problems on hackerrank

Oh, I completely agree that FP is the future. I wish there weren't so many schools teaching Java/C# and nothing else, because going from OOP to FP is possibly harder than just learning FP from nothing due to all the unlearning that must be done.

He's into it from a distance. Better than Bjarne's beta-bitch snub, but he still recognizes that FP is a future he won't be part of. Carmack's a hero of mine btw so hope it's not coming off like I'm shitting on the guy. But my understanding is he talked about FP being important at that keynote, tried and gave up on a haskell wolfenstein, and probably continues to just use C++.

Which assembly? I know MIPS and a little ARM.

>Which assembly?
yes

>FP is the future
what a retarded opinion to hold unironically
nobody has ever been able to predict where paradigms will be in the future
nobody knows until the future happens

obviously x86 you retard

You can easily do 3D stuff in SBCL, the difference is you're not gonna be doing AAA with millions and millions of triangles in a single frame as a decent frame rate probably unless you optimize the rendering pipeline to the point where you're missing out on the ease of CL.

I never bothered with ECL but it's not as maintained and probably not as good simply because of that.

"Function composition is the key to controlling complexity" (might have mangled it a bit, but that's the gist of the quote)

youtube.com/watch?v=ZhuHCtR3xq8

what do you guys think of Go? is it a meme language?

>carmack
>wolfenstein
hmm, rly makes u think

Carmack was a C guy, I think he was against the use of C++ altogether. Still, best tool for that particular job.

Its the only logical conclusion though.
Mutable state causes more problems than it solves.

The future is multicore. Shared mutable state and locks are the assembly language of multicore programming. Pure FP is a much more tractable and manageable way of doing it.

Yep.

Thanks for all the help last thread, just one last thing though. Anyone know why my averages come out wrong?

{
int high, low, sum, i, count;
double avg;
printf("Enter a number (-1 to quit): ");
scanf_s("%i", &i);
high = i;
low = i;
sum = i;
for (count = 0; i != -1; count++)
{
if (i > high) {
high = i;
}
if (i < low) {
low = i;
}
printf("Enter a number (-1 to quit): ");
scanf_s("%i", &i);
sum += i;
}
avg = (double) sum / count;
printf("\nThe lowest number was %i\n", low);
printf("The highest number was %i\n", high);
printf("The number of values entered was %i\n", count);
printf("The average of the numbers was %.2lf\n", avg);
}

cant
{

}

functions so i dont want any

he basically says in C vid that scientists, engineers and physicists are too stupid to understand computers. they can't program in C and need high-level lang ie C++

Go is a perplexing language. It feels like it belongs in the 1970s.

proly cuz u add -1 to da sum yo

He also said he wished C was a subset of C++ so programmers could pick and choice from C++'s tool set while writing C which is laughable since he led a lot of the early committees for C++ and could have made it include all of C's standard if he wanted to.

oh fuark how can I avoid that here?

Right now I'm using this:
constexpr auto& get(vector2i p, auto* ptr) const noexcept
{
p.x %= dim.x;
p.y %= dim.y;
if (p.x < 0) p.x = dim.x + p.x;
if (p.y < 0) p.y = dim.y + p.y;
vector2i offset = pos + p;
return *(ptr + offset.x + size.x * offset.y);
}
to do bounds checking and wraparound on a matrix (screen buffer).
Any ways to optimize it?

Go was never designed to be used by humans outside Google's army of Indian programmers that can't be trusted with C.

thanks guys. yeah my job is trying to get me to learn it but after doing the tutorial it seems pretty meh. then again i don't gaf about concurrency and shit like that

downloaded this book like 3 years ago

finally started reading. The first part of the book is implementing a very simple language in ruby. I've been doing nothing but javascript for 2 years or so but once considered ruby my favorite language. It's making me nostalgic. I kinda want to start a project with rails but I'm so rusty.

I've been lurking dpt for years but this might be my only post cause I'm high as fuck right now. lol.

Surely if your boss wants you to learn it then you must learn it or quit?

youtube.com/watch?v=75Ju0eM5T2c

Donald Knuth - 'Avoid the hurd when seeing what language to use'

i don't think it will come down to that but if it does i'd rather quit

maybe if he had more dinners with K&R, he would've designed a better looking frankenstein.. oh well, he will still have a chance when they meet in hell

u do da
if(i == -1)
break;

rite b4 u do da
sum += i;


also u needa go bak n change da input to not use i in dis manner
u breaking da established practices n shit yo

Hey man, I love that book and I love ruby. I'd say stay the hell away from rails though, it almost killed my love of ruby. But that's a great book to read high my friend. Ruby was my first introduction to programming almost 10 years ago? It also gets me feeling nostalgic.

rubykoans.com/ This is what you should do instead of rails.

...
scanf_s("%i", &i);
if(i == -1)
break;
...

can't use breaks cause can't use shit we didn't learn yet brahs, that's cheating and that's no good. but I used my head and actually looked at it and I moved the sum like so and now shit works

sum += i;
printf("Enter a number (-1 to quit): ");
scanf_s("%i", &i);

>stuttering constantly
>looking down constantly

To think the mind behind TAOCP is an autistic old man is amazing.

What did you expect. We can't all be Feynman!

he has a point though. most of his peers already have brains fried with altzheimers, math helps you avoid that

that's how almost all brilliant people are in person
it's extremely rare that someone is a genius and also highly socially capable, like an einstein

Sing 99.

proc StrOfInt of Buf, St, I where
J, K.
Digit : 8.
perform
if I then
loop I do
J :- I.
loop J do
K :- J.
J % 10.
done.

Digit :- I : 8. NB. Widthcast syntax may change.
Digit + ?0.
Buf/8 :- Digit.
St/WORD + 1.
I % 10.
done.
else
Buf/8 :- ?0.
St/WORD + 1.
fi.
corp.

proc Sing of Bottles where
Buf :- reserve 8 x 1024.
St :- 0.
perform
loop Bottles do
St :- 0.
StrOfInt Buf, \St, Bottles.
StrAppend Buf, \St, `` bottles of beer on the wall''.
emit Buf.

St :- 0.
StrOfInt Buf, \St, Bottles.
StrAppend Buf, \St, `` bottles of beer''.
emit Buf.

emit ``Take one down, pass it around''.

Bottles - 1.

St :- 0.
if Bottles then
StrOfInt Buf, \St, Bottles.
StrAppend Buf, \St, `` bottles of beer on the wall''.
else
StrAppend Buf, \St, ``No more bottles of beer on the wall''.
fi.
emit Buf.
emit ``''.
done.

renounce Buf.
corp.

What language is this?

If this works how I think it works, it cannot solve all puzzles. Some of the "hard" puzzles cannot be deduced and require trial guesses.

The language you've always secretly wanted in your heart.

Looks like dog food.

two characters for assignment ops is shit

>Doesn't like the emoji language
>: - I

Why haven't you converted to the one true paradigm yet user?

I already use Lisp.

What are trial guesses in the context of sudoku puzzles?
Is that bruteforcing?
Because that's basically what I'm doing, limiting guesses to numbers not found in the same box, row or column and restarting when I run out of digits for any given missing number.

Could you post an example of a hard one so I can test it?

But I have.
Haskell is the only language with vulkan bindings though so its gonna have to wait.

I actually am not seeing how your algorithm can solve sudoku puzzles. Could you explain it?

From what I see, you compute available numbers for each position but then there is this bit.
while (!pz->arr[i][j])
{
unsigned num = rand() % 9;
if (!(vec & (1 arr[i][j] = num + 1;
}
goto restart; /* state has changed */


Basically this guesses a number until it finds one that can go in that position, then stores that random number plus 1? Why? Also, what happens if that random guess is incorrect?

globale
form est un formulaire, titre vaut "La boite à texte", largeur vaut 400, hauteur vaut 260
boite est une boite,x vaut 30, y vaut 30, largeur vaut 200, hauteur vaut 100
b1 est un bouton, texte vaut "Afficher le texte dans le tableau", x vaut 30, y vaut 150
l1 est une étiquette, texte vaut "", x vaut 30, y vaut 200

principale :
début
ajoute boite & b1 & l1 dans form
Fais réagir b1 à "clic souris" pour afficher valeur
tant que 1 != 2, lis
temporise
ferme

afficher valeur :
*b est un bouton
début
affiche texte de boite
reviens

Switch to the superior language faggots

That language is english.

R reporting in
`[`(11:20, 3)


Also daily reminder that the magrittr pipe is a monad

get random number 0-8
bitwise shift is zero indexed
it checks if that number doesn't already exist and stores it plus one because the puzzle numbers are 1 indexed.

If the random guess is incorrect, there will come a point in future guesses where the bitfield vec for the current position is maxed out, all numbers exist already and no more guesses can be made, so you quit and start over.

I need a language recommendation for the two following things:
ncurses interface
trawling web pages

I would greatly, GREATLY prefer to keep the application in one language for maximum portability, and I would also greatly prefer not to go anywhere near Python because that language is a pile of aids.
I was thinking C initially for the ncurses but I can't imagine there's a robust web-trawling framework for it.

What does /dpt/ think, could this have been done better?
lst = list(
"08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08"
[...]
"01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48")
for i in range(lst.count(" ")): # Remove empty strings
lst.remove(" ")
lst = map(str, lst)
lst2 = []
for a in lst:
b = next(lst)
if a == '0': # Remove leading zeros
lst2.append(b)
else:
lst2.append(a+b)
lst = [i for i in map(int, lst2)] # Convert sorted list to ints
MAX = 0
for i in range(1, 20):
j = 20*i
a = max(lst[j-20:j])
index = lst[j-20:j].index(a)
for ii in range(-1, 2):
try:
b = lst[j:j+20][index + ii]
c = lst[j+20:j+40][index + ii*2]
d = lst[j+40:j+60][index + ii*3]
except IndexError:
b=c=d=0
PROD = a*b*c*d
MAX = PROD if PROD > MAX else MAX
if ii != 0:
try:
b = lst[j-20:j][index + ii]
c = lst[j-20:j][index + ii*2]
d = lst[j-20:j][index + ii*3]
except IndexError:
b=c=d=0
PROD = a*b*c*d
MAX = PROD if PROD > MAX else MAX
print(MAX)

Yeah, sorry for asking, it makes sense, I figured it out after I posted.

The thing about random guesses is that you can't ensure it won't make the same incorrect guess. Random guessing is unconstrained, and what you have is a constrained search.