/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

geeksforgeeks.org/generalized-suffix-tree-1/
agui.boards.net/
en.wikipedia.org/wiki/Euclidean_algorithm
numere-prime.ro/cel_mai_mare_divizor_comun_al_numerelor.php?lang=en&numar1=1248&numar2=3913&cmmdc=13&cmmdc_factorizat=13
blog.racket-lang.org/2018/01/racket-on-chez-status.html
twitter.com/NSFWRedditGif

first for python

>Like reading about academic topics related to programming more than I like programming itself

>tfw no C programmer bf

g++ is stupid

use gcc

no ur a compile

gcc has the same problems

>wanting a bf
>wanting a programmer bf

it's not the compilers fault when you're a fucking retard idiot

It's the compiler's fault when it generates shit code

You should try implementing some of the stuff from academic papers or just data structures in general. Pretty fun m80

Here's something to get started geeksforgeeks.org/generalized-suffix-tree-1/

Whats a good framework to program a HD 4K pc game?

Quick, give me some project ideas!

>geeksforgeeks.org/generalized-suffix-tree-1/
>typedef struct

>struct struct_name

It's illustrative of the algorithm, I wouldn't even recommend implementing it in C unless you're a masochist

Reading through this. I tried reading Haskell From First Principles but I'm too much of a brainlet. I'm actually understanding Haskell now though.

Here's a function that calculates the sum of every numner that is a multiple of 3 or 5 from 1 to x

sumMultiples :: Integer -> Integer
sumMultiples x = sum [n | n

>go ""type" system"

Here:
agui.boards.net/

static int SumMultiples(int to) => Enumerable.Range(1, to).Where(n => n % 3 == 0 || n % 5 == 0).Sum();

Creating a bot to buy and sell bitcoins, keeping the trades quite low risk, just to ride waves up and bail when dips occur. It just sits there on a Azure cloud machine making gains ... the dream.

can someone post projects list blz

thats really cool, how long have you it running? much success?

Post your text editor, NOW


Here fella

>tfw too much of a brainlet to implement Euclid's algorithm in a C program

so i know python and c (and scheme but thats useless in practical terms)
you can extend python with c and all but it's a bit of a hassle
i need a language to write fast programs, i could stick with c, but maybe you guys have a better option

c++ is HUGE
rust is too new and will die soon
c# and java are kinda too ugly
go is google java

i mean, using python and c i've done most of in one form or another

anyone have any comments or suggestions

Writing fast programs is hard, and if you want to do it you will have to learn a hard language

Jai could be up your alley. It's like C++ but without garbage and with nifty features. Also compiles faster than literally anything else on the planet.
It will most likely ship this year, keep an eye out.

>fast programs
Lisp it is!

Whats the market like for python devs going into the future?

nvm, just was thinking about it wrong. Afterwards I looked at stackoverflow and found a retard who took two functions to do it and imported three libraries, so I'm happy with myself.

what's the difference between a segfault and a general protection fault?
My program is terminated and prints "segmentation fault" but dmesg shows "general protection". Can they be the same? I've seen both "segfault" and "general protection".
the program segfaults about 1 in 10 times i run it, randomly. when running inside gdb, it never does. how can I figure out where the problem is?

Here's the retarded code I was writing
#include

int main()
{
int n, m, r, numer, denom;

printf("Enter a fraction: ");
scanf("%d/%d", &numer, &denom);
m = numer;
n = denom;

for(;;)
{
r = m % n;
if(r == 0)
break;
m = n;
n = r;
}
numer /= n;
denom /= n;
printf("The lower form of the fraction is %d/%d\n", numer, denom);
}

Windows 95.

Dude, that's gay.

>trading bot
>python
>success
hehe

Type systems are overrated.

you don't need to know either to make money

what a goddamn waste of bytes you are

t. python user

Hey dpt, what do you use for infinite loops?

for (;;)

anyone else starting school tomorrow?

pls lord help me contain my power level

call me old fashioned, but while True: never let me down

t. C user

The hardware has no type conception, so whatever type system you decide to use will by definition be a limitation.

if you're talking about this:
en.wikipedia.org/wiki/Euclidean_algorithm

Then I have a recursive solution which seems to work. Hope this helps.
// euclid.c
// Computes the GCD of two positive integers, using the Euclidean Algorithm
#include

// precondition: a > b
int gcd(int a, int b) {
int q, r;
q = a/b;
r = a%b;

if (b%r == 0)
return r;
else
return gcd(b,r);
}

int main() {
printf("%i\n", gcd(3913,1248));
}

t. cowboy coder
Type systems make code readable

(loop)

It prints "13", which matches the answer at this website: numere-prime.ro/cel_mai_mare_divizor_comun_al_numerelor.php?lang=en&numar1=1248&numar2=3913&cmmdc=13&cmmdc_factorizat=13

Programming languages are just tools. You use the tool that is appropriate for the job at hand.

Whining about how you dislike one language or another because of reason x, y, or z and sperging out about which language tickles your autism just the right way is a sure sign that you've never accomplished anything actually worthwhile with any language whatsoever, let alone the one you fap to while complimenting yourself for for being a big brain pickle rick nibba for understanding pointers or simple recursive algorithms.

The best way to learn a programming language is to have a reason, a desire, to create something. Find something that will keep you going until the project is finished. Choose the language you wish to use based on which one best fits the problem set, including availability of frameworks useful to achieving your goals.

Do you want to be an autist who collects shiny hammers and uses them to practice banging nails into 2 x 4s to hone your hammer using skills while fapping to the quality of the grain in the wood handle of the hammer, or do you want to find a hammer that is decent enough to actually build something like a fucking house and get to work and accomplish something with your life?

>tfw "programmer" who has never made a useful application in his life

for {
// do something
}

Disgusting

(defun sum-multiples (x)
(loop :as n :from 1 :to x
:if (zerop (mod n 15)) :sum n ))

I prefer it to while (true)

In every programming language I've tried thus far with a "sophisticated" type system, I end up spending more code at manipulating types than code that actually does the stuff the program is supposed to do. Type manipulations crowding out actual functional code does not improve readability.

Also whoops, I don't need q

the only correct answer

Ive been working on my website. Can't wait to show it off to Sup Forums when its done, even though its not particularly special and I've kind of cheated using open source web apps for most of the functionality, Im still really happy with it because its the first website I've ever built.

Python is a piece of shit, if your language doesn't have a good type system, you end up spending more time trying to figure out what something is then actually writing code

LOOP_: {

goto LOOP_;
}

>>Sup Forumswdg
Disgusting

It was you who asserted that I use Python, not me.
>if your language doesn't have a good type system, you end up spending more time trying to figure out what something is then actually writing code
But no, that false. I've never had this problem in C.

program a lightweight and portable end to end encryption chat program that works over TCP and can be used from the command line.

That's because C has a good type system

lol

Because having bools quietly evaluate as integers at 3 A.M with a 9 A.M. deadline looming is really fucking useful.

Don't forget the sheer elegance of implicit float to int conversions lurking in 400k lines of pajeet code you need to refactor and optimize.

Kill yourself.

If you think C has a good type system, what is it that you have against Go? When people complain about type systems, they're usually C++- or Haskell-fags. Sorry if that's not you.

...

Strangely enough, I can't recall ever having a problem with any of this, even at 5 AM. Could it perhaps be that you're a lesser programmer who can't read your own code properly?

>What is it you have against go
I have nothing against go, however I do have something against languages with shit type systems

Could it be that you've never worked with other people before, or inherited projects from developers who are long gone?

Could it be that you're an autistic shut in who has never worked in the real world before and who thinks he's reached the pinnacle of programming proficiency using a 40 year old language?

C++-fags can kindly be directed to their designated shitting streets.

And, to get the reduced fraction, just divide by the gcd of course.

// euclid.c
// Computes the GCD of two positive integers, using the Euclidean Algorithm
#include

// precondition: a > b
int gcd(int a, int b) {
int q, r;
// q = a/b;
r = a%b;

if (b%r == 0)
return r;
else
return gcd(b,r);
}

void print_reduced(int a, int b) {
int ab_gcd = gcd(a,b);
printf("The Fraction %i/%i reduced is: %i/%i\n", a, b, a/ab_gcd, b/ab_gcd);
}

int main() {
printf("%i\n", gcd(3913,1248)); // 13
print_reduced(3913,1248);
}

I don't know what shitters you work with, but I have no problem reading and patching open source C programs. Specific projects I've been dealing with lately include Pidgin, BSDDB and Linux.

I'm also currently making my living with a 150+ kLOC C program.

A tool to analyze C++ TU dependencies to help with cleaning up a garbage legacy codebase. I guess iwyu solves this problem but it doesn't really see much active development and has a number of open issues. Plus I don't learn anything if I just use an off the shelf tool.

Uni is making us learn ANSI C.

Do people still use this anymore? Damn.

I use whatever language I need to get the job done.

After years of experience in the real world, the benefits of both static and strongly typed programming languages are blatantly obvious.

Give a single good argument for why weak typing is superior to strong typing, brainlet.

In lisp, this is just
> (gcd 3913 1248)
13

Trying to find a way to sync calcurse (a curses based calendar client) to google calendar. I haven't had any luck with the python wrapper provided by the calcurse devs so I'm working on replacing it with my own. Just wish the calendar API docs were a little less autistic

>Do people still use this anymore
kek

>I've patched some open source plugins and "have dealt with Linux lately"
>I'm a programming guru who has never made a mistake involving implicit type conversions
Want to know how I can tell you've never cupped a woman's breast before?

there's two kinds of Cfags.
There are the Cfags who do not in fact write C, but write the dialect of C supported by GCC. They use C99 and C11 features along with all the gcc extensions.
Then there are the purists. They will only write strictly standard compliant C89.
Pick your poison.

Wow, that's just like importing urllib in Python to write my own wget. Completely useless from a pedagogical point of view, unless you know how to implement your lisp GCD.

blog.racket-lang.org/2018/01/racket-on-chez-status.html

it's part of the language, not a library, dumbass
so no, it's not like importing urllib

Yes, C is still used, especially for low level programming such as programming micro controllers or device drivers.

Even if you never go on to use C, learning C and the lessons it will teach you about how your computer actually computes will be invaluable and will stick with you your entire life.

>I'm also currently making my living with a 150+ kLOC C program.
funny, I'm making my living with a 200k loc C++ program :D

(define/match (gcd a b)
[(a 0) a]
[(a b) (gcd b (modulo a b))])

>I use whatever language I need to get the job done.
I too, and that is often C. I do use other languages when the task calls for them, however.
>Give a single good argument for why weak typing is superior to strong typing, brainlet.
You will notice that C is neither dynamically nor weakly typed per the normal use of those terms, and that I still haven't argued for weak typing. That being said, among the languages I use elsewhere, Python and Common Lisp are included, and I have had little problem with typing there, either. I do, however, often use type declarations in CL, and I wouldn't argue for Python because of its weak typing.

this is great, but CL's gcd accepts an arbitrary number of parameters
you may as well go all the way

Nice. Was about to post mine in Scheme
(define (my-gcd a b)
(define r (modulo a b))
(if (= (modulo b r) 0)
r
(my-gcd b r)))

>and other things i've never said
I just took those examples because I haven't worked professionally with a project that used C.

>it will teach you about how your computer actually computes
s/computer/PDP-11/

i want to learn a functional language, any recommendation?

>C has a good type system
that's why you need to re-implement every arithmetic function separately for int, short, long, long long, float and double right?

auto gcd(int A, int B)() if (A > B && (B % (A % B) == 0))
{
return A % B;
}

auto gcd(int A, int B)() if (A > B && B % (A % B) != 0)
{
return gcd!(B, (A % B))();
}

auto gcd(int A, int B)() if (A

clojure

python is dynamic but strongly typed

public class Item
{
private string _text;
private string _name;

public Item(string text)
{
_text = text;
_name = SetName();
}

private string SetName()
{
// name = something(_text)
}
}

What's a more graceful way of doing this for multiple variables?

Scheme
Segregation is good