/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

dpaste.com/3F1GNG0
twitter.com/AnonBabble

We didn't have to choose C
Things could have been different
It didn't have to be this way

Radio station software unnies

...

Well the alternative would have been lisp machines and I bet you faggot wouldn't like that either.

C was a mistake
ML was robbed
My mouth is full of dicks

C#

Reimplementing the unix kernel in Visual Basic 2

explain?

bait

doing my own std::chrono

Gee, ya think?

>What are you working on, Sup Forums?
Refactoring my old hack to use a more streamlined memory allocation model.

Pic related, had to comment out a bunch of stuff to make it compile and then write stuff back in again function by function.

What's a nice book to learn fortran?
Don't meme me please

You memed yourself son

sometimes I pass too many functions into functions, it sounds neater in my head, but have no clue what im looking at when I write it out

def convert(unit_type,unit_value): #eg convert('oz',1) >>> 29 ml >>>
ml_in_oz = 29.57353
if unit_type == 'oz':
return unit_value * ml_in_oz #returns ML

def standard_drink(percent): #returns ounces
return 60 / float(percent)


def prompt():
return input("Enter Percentage of Alcohol, or 'the anykey' for chart of popular percentages \n >")

def chart():
popular_percentages = [3,4,5,7,8,10,12,13,15,17,20,25,28,30,35,38,40,45,]
print("Percent" "\t\t" "OZ" "\t\t" "ML")
for x in range(len(popular_percentages)):
print(popular_percentages[x],"\t\t" "{}" "\t\t" "{}" .format(round(standard_drink(popular_percentages[x]),2),round(convert("oz",standard_drink(popular_percentages[x])),2)))


def main():
try:
in_oz = round(standard_drink(prompt()),2)
in_ml = round(convert("oz",in_oz),2)
print("Use {} Oz, or {} ML".format(in_oz,in_ml))
except:
chart()

if __name__ == '__main__':
main()

use your local library or university library. They may have a physical book or they may have an ebook. either way, it's gonna be from the 70s at the latest.

Source: This is how I learned COBOL

>sometimes I pass too many functions into functions, it sounds neater in my head, but have no clue what im looking at when I write it out
That's because you don't write in functional language.

>Gonna be from the 70s
It'll most likely be from the 90s

Congratulations, you've just confirmed for yourself how natural it is to think in terms of functions and function composition.

Because it was arguably the best non-GCed compiled language available in the 70s. Pascal was shit.

>doing my own std::chrono
>uses std::chrono

Why is suddenly the enitre DTP memeing about C?

Thankfully after the ~50 year derailment, we're beginning to acknowledge the mistake and move back to Lisp/ML family concepts.

How2fix this? I want it to print 'The first of the months is January', 'The second of the months is February', so on.

dpaste.com/3F1GNG0

yeah I mean just the clocks

>C
>70s
C isn't that old.

Fortran was dominant up until well in the 1990s.

Preferably Haskell/Idris these days desu

Some butthurt Rust-nigger learned about buffer overflows and code injection and all the Haskellfags jumped on the train too.

...

To compilers this term. Ended up with the second highest score on my compiler for an object oriented and type inferred language. Score above me was earned by two grad students working together.

>imagining all the salty C devs who have put 10+ years into that broken mistake finding that industry has moved on without them
Diamonds

months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'November', 'December']
numbers =['The First','The Second','The third','The fourth','The fifth','The sixth','The seventh','The eighth','The ninth','the tenth','the eleventh','the twelth']
for i in range (12):
for j in numbers:
for m in months:
print(j + ' of the months of the year is '+ m)

This program is going to output 12^3 strings.
You have nested loops.

stop wasting time on your bullshit and help make gcc7 happen already

>nesting for loops
Yuck

Wish I could understand better why vectorized operations are a problem, but I don't understand compilers/architecture well enough

C was created at AT&T in 1969 bruh...

No, work on a better compiler and release it on MIT license instead of GPL communism

Fortran wasn't structured when C was invented. It was structured around goto-like jump-to-label statements. Decent Algol clones with non trash performance were still rare.

>the twelth of the months of the year is March

kek i forgot october.

and I spelled twelfth wrong. i would blame drugs or something but i'm completely sober.
>tfw brainlet

The problem more is that CS students (and even moreso, people actually in industry) fail at even basic linear algebra for the most part, so using nested for loops like a chimp is all they can deal with

Also Fortran is still dominant in scientific computing. It just happens to have adapted really well by adopting new features constantly without becoming bloated.

Only an undergrad right now, but may apply the PhD program if I can prove I'm not a brainlet

Jeg vet at jeg intet vet.

>BCPL is C
They're not even syntactically related.

C as we know it today came with ANSI C in 1989. No one on Sup Forums even recognises C when the original parameter declaration list is used.

>Also Fortran is still dominant in scientific computing
Not really. It's used by ageing physics professors, but any real scientific computing done on compute clusters etc use C/C++ with high-speed message passing APIs.

I best languages evolve with relatively small communities

BCPL was created in 1966. B was created in 1969. C Was created shortly after in 1972 (I admit I was off 3 years). C is still from the 1970s

Hvis du ikke kan et fremmed språk, vil du aldri programmere godt.

aighty ty a few seconds of using my brain and i figured it out

months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September','October', 'November', 'December']
numbers =['The first','The second','The third','The fourth','The fifth','The sixth','The seventh','The eighth','The ninth','the tenth','the eleventh','the twelfth']
x=0
for i in months:
z=numbers[x]
print(z + ' month is ' + i)
x+=1


Is there a better i could have accomplished this?

This is ridiculously bugged, and prints every number month combination, including wrong ones.

Correct version ( caveat: I haven't bothered to run it).
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'November', 'December']
numbers =['The First','The Second','The third','The fourth','The fifth','The sixth','The seventh','The eighth','The ninth','the tenth','the eleventh','the twelth']

for month, num in zip(months, numbers):
print(num + ' of the months of the year is' + month)

I know basically nothing about the differences between C compilers.
Do they often us LALR1 for the compatible parts of C?

...
for i in range(len(months)):
print(numbers[i] + ' month is ' + months[i])

ahhhhh. Ty user.
Thanks m8

...

...

Det heter fremmedspråk, din ubrukelige neger. Lær deg særskriving.

Python is shit

So is Google.

Let me guess: 5 voters?

Protip: one of the main reasons why Python is one of the best imperative languages is because of iterators. Make sure you learn to use the various iterators in the standard library. Iterators free you from indices and off-by-one errors.

Pre-K&R C looks nothing like modern C.

Hell, even pre-ANSI C looks very little like modern C.

Bet you have an Android phone though

>even ironically writing in ML

months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September','october', 'November', 'December']
numbers =['The First','The Second','The third','The fourth','The fifth','The sixth','The seventh','The eighth','The ninth','the tenth','the eleventh','the twelth']


for x in range(len(months)):
print(months[x], "of the months of the year is", numbers[x])


### or


zipped = zip(months,numbers)

for x in zipped:
print(x[0], "is", x[1])

C++ has iterators. Java has iterators.

Wrong kind of iterator you ditz.

It makes Google better somehow?
New versions become more and more closed.

Please, show examples.

What kind of iterators?

The ones that are lazy lists in disguise, and let you do operations like zip, enumerate, comprehensions, map, collect into arraylist, and all kinds of declarative stuff.

Where can I read C standard library headers?

You mean like Haskell lists?

// note that I don't include stdio here

main(argc, argv) // main is int, so implicit type
char** argv; // argc is int, so implicit declaration
{
printf("hello, world\n"); // implicit function declaration
} // implicit return 0


This is valid K&R style C for example

Isn't that an iteraABLE.

in your TE

my python is std free too!

>implicit
>implicit>implicit>implicit>implicit>implicit
>implicit>implicit>implicit>implicit

wew

The only thing makes me wonder is the abscence of stdio.

Is there anything besides serialize/deserialize that will let me store data in a file or database (can be sql but i hate writing sql statements) that basically equates to one or two lines like ndatabase?

I recognize K&R style C, and I haven't even read K&R. You just have to actually look into some older C codebases, I think even the current Nethack code uses K&R style parameters.

Can you give an example of pre-K&R C and how it differs from pre-ANSI C?

Putting all my shit into Docker containers.

So what does PRE-K&R C look like?

>cucking all your shit
Why?

Two array should work just fine, access them in one loop with same index.
Here is C example:
#include
void main(void){
char months[12][10]={"January",///}
char numbers [12][16]={"..",//
for (int i=0;i

#define NK_STRING_JOIN_IMMEDIATE(arg1, arg2) arg1 ## arg2

What does this make?

>Can you give an example of pre-K&R C
It's hard to come by any actual examples, because before K&R-style C, it was mostly an internal programming language used at AT&T/Bell Labs.

>how it differs from pre-ANSI C?
Implicit types and implicit function declarations, for example, are considered invalid C.

Other examples involve parameter passing. With K&R style argument declaration, you also need to pass parameters reverse.

foo(a, b)
{
return a;
}

bar()
{
printf("%d\n", foo(3, 5)); // this actually prints 5
}

Warnings in gcc, clang, cc.

it joins 2 arguments

check it for yourself

Yes, because this isn't valid C89/90.

But it is valid K&R C. First edition K&R is filled with these.

Thinking containers are here to stay. Don't know about Docker specifically, but seems to have mind share.

People who don't deploy might not understand.

How do I get tesseract to not suck ass?

Also one line comments (aka // comments) aren't technically legal, it should be /* comment */

That just concatenates two things at compile time. Not sure why they used such a verbose name for it.

So how do you tell K&R and pre-K&R C apart? Both use the weird so-called "K&R" way of declaring function parameters, right?

>first edition K&R
Invalid syntax, it was very long time ago, examples from second edition works just fine.

Sort of. They aren't quite as powerful as Haskell's lists, but you can map/filter/zip/fold them, or do more advanced itertools operations on them.

They are the reason why python's for loops and generator expressions are so nice. If all your python for loops look like for i in range(...) you are missing out.