[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 332
Thread images: 47

File: EO.png (30KB, 512x774px) Image search: [Google]
EO.png
30KB, 512x774px
What are you working on, /g/?

Old thread: >>58787146
>>
File: Nim.png (228KB, 750x750px) Image search: [Google]
Nim.png
228KB, 750x750px
>>58793774
So is Nim worth learning, /g/?
>>
File: amer-goth-lines2.jpg (649KB, 632x768px) Image search: [Google]
amer-goth-lines2.jpg
649KB, 632x768px
Generating art from lines. The results are pretty good.
>>
>>58793783
First for C#, which is way better than Java.
>>
>not classic /dpt/ picture
Dropped.
>>
>>58793783
What's left of OOP after you take away all of that?
>>
>>58793815

Poor excuse to post animu, now go jerk yourself off to your oriental cartoons, you kissless virgin.
>>
File: mqdefault.jpg (7KB, 320x180px) Image search: [Google]
mqdefault.jpg
7KB, 320x180px
>>58793840
What did he mean by this?
>>
File: tmp_20305-hqdefault-739687889.jpg (17KB, 480x360px) Image search: [Google]
tmp_20305-hqdefault-739687889.jpg
17KB, 480x360px
>>58793840
Nah, Rajesh, learn anime, last anime-less days are coming. /dpt/ will be anime for ever.
>>
>>58793783
fucking lol i found the Elegant Objects manifesto thing the other day. funniest thing i've read in ages desu. it's like they took every bad idea from Java and removed all the good ones
>>
>>58793812
How does your algorithm work
>>
>>58793833
well OCaml's object system is pretty much that. it feels a lot nicer, although it's very rarely used anyways. Smalltalk is supposed to be pretty similar to that too I think but I really haven't ever tried using it.
if you want a real good laugh check out the language this man is designing for the book https://github.com/yegor256/eo
>>
>>58793808
No? It has nothing interesting going on.
>>
>>58793906
>>58793939

http://www.youtube.com/watch?v=YgHNtzxO0y8
>>
>>58793931

for number of lines
for number of candidates
generate candidate[i];
parallel-fitness-test all candidates;
apply best candidate;


That's it, in a nutshell. Obviously the implementation is a bit more complicated, but the idea is dead simple.
>>
>>58793808
Literally no job if you do.
>>
>>58793892
Autism goes this far.
>>
File: le_orange_negro.png (129KB, 300x300px) Image search: [Google]
le_orange_negro.png
129KB, 300x300px
>>58793939
>sjwhub
>>
1st for traps are programming culture
>>
>>58793906

Well, he IS a shitskin Java programmer. What did you expect?
>>
C++ ball-bouncing simulator with customizable physics using SFML
>>
File: 1485578121463.gif (3MB, 700x285px) Image search: [Google]
1485578121463.gif
3MB, 700x285px
>>58793939
>build: failing
>EO (stands for Elegant Objects or ISO 639-1 code of Esperanto)
>It's the future of OOP.
>we don't need generics (not sure)
>it's a "pure object oriented language" yet lots of things aren't objects
>maximum of 15 characters per identifier
>>
>>58793961

lol that's just throwing shit on the wall and hoping it sticks. Why not make an algorithm that isn't just playing the odds.

2/10, try harder next time
>>
>>58794023
>lol that's just throwing shit on the wall and hoping it sticks.

I haven't had a single run where there's a regression in error values.
>>
>>58793814
>First
You're right, but you're still a faggot.
>>
File: Feb04-200308.png (131KB, 833x993px) Image search: [Google]
Feb04-200308.png
131KB, 833x993px
>>58793783
My own shitty fourchan browser (C++/Qt)
Now even with thumbnail caching. Working on parsing post markup (got links working so far)
>tfw your browser can't display greentext
>>
>>58794070
nice post code
>>
>>58793956
haha oldie but goodie
>>58793997
isn't he a slav?
>>58794000
it gets worse
>things we don't tolerate
>mutability
>constants
>scalar types
>annotations
>operators
>DSL and syntactic sugar

>thigns we want to build in
>continuous integration
>logging
>TDD
>licensing

plus they want object metadata but no reflections?? how does that even make sense
>>
>>58794095
Well at least they got "pure OOP" right in one sense.
>>
>>58793974
No need to reveal your diagnosis, we already know that.
>>
>>58794121
Don't make fun of autism again.
>>
>>58794115
more like pure POO
>says minimum identifier length is 3 chars
>entire readme littered with 1-2 char identifiers
>>
File: this-planet.jpg (83KB, 1280x720px) Image search: [Google]
this-planet.jpg
83KB, 1280x720px
>>58794000
>>we don't need generics (not sure)
People still fail to understand why OOP need generics.
>>
What kind of people master C++?
>>
>>58794168
White ones.
> C++ masterrace
>>
File: 1485749465753.png (98KB, 600x500px) Image search: [Google]
1485749465753.png
98KB, 600x500px
dae c++ even relevant today??
>>
File: CANTWAKEUP.png (117KB, 290x290px) Image search: [Google]
CANTWAKEUP.png
117KB, 290x290px
>>58794095
>slavs
>white
>>
>>58794198
Whiter than Pajeets.
>>
>>58794186
whites get shit done

they use java or sometimes python
>>
>>58794237
That's not really a feat, anon.
>>
File: 1486232562635.jpg (38KB, 212x175px) Image search: [Google]
1486232562635.jpg
38KB, 212x175px
Any compiled languages better than C out there?
>>
>>58794285
java
>>
>>58794285
OCaml
>>
>>58794243

>java

wonder how the java garbo collector stops from collecting itself
>>
File: logo.gif (6KB, 133x63px) Image search: [Google]
logo.gif
6KB, 133x63px
>>58794285
Object Pascal
>>
>>58794291
> Java
> Compiled
GNU Java compiler does not count
>>
I want to learn AI where do I start?
>>
File: 1446354735829.jpg (14KB, 320x320px) Image search: [Google]
1446354735829.jpg
14KB, 320x320px
>>58794297
LOL fking hilarious dude!
>>
>>58794285
>>
>>58794297

It's not self-aware, so it doesn't know itself exists.
>>
>>58794307
java
>>
>>58794307
>>58794336
>>
>>58794314
java
>>
>>58794311
java
>>
File: com.png (71KB, 585x755px) Image search: [Google]
com.png
71KB, 585x755px
I don't like the COM.
>>
>>58794380
This code looks fucking disgusting
>>
>>58794380
what language
>>
>>58794380
What esoteric programming language is that, anon?
>>
File: 640.png (135KB, 288x415px) Image search: [Google]
640.png
135KB, 288x415px
>>58794380
why does rust look so fucking ugly
>>
File: not com.png (29KB, 810x351px) Image search: [Google]
not com.png
29KB, 810x351px
>>58794388
>>58794396
>>
>>58793783

who /bored/
>>
File: dogshit.png (26KB, 344x256px) Image search: [Google]
dogshit.png
26KB, 344x256px
>>58794396
Because le (dys)functional meme.
>>
File: 1470422975741.png (949KB, 722x686px) Image search: [Google]
1470422975741.png
949KB, 722x686px
>>58794285
Go
>>
>>58794396

GOTTA BE SAFE FRIENDO
>>
>>58794404
>>58794380
What's with the cancerous font?
>>
>>58794404
that code looks fucking beautiful
>>
>>58794420
But as far as I know, it isn't better (both aesthetically and in performance)
>>
>>58794446
are you, perhaps, blind?
>>
>>58794285
best yuri
>>
>>58794460
It depends on your definition of "better". If you only care about aesthetics and perfs then sure it can't replace C, but if you're talking multithreaded server software then it's light years ahead.
>>
>>58794418

This, any language that attempts to start implementing even the slightest functional features eventually turns esoteric. Just look at JavaScript.

Functional paradigm is cancer.

>>58794285

Yes, Gambas.

http://gambas.sf.net/
>>
>>58794480
>Gambas
>>
>>58794480
>Functional paradigm is cancer.
It's cancer in imperative languages like Java. Functional languages are comfy af.
>>
>>58794494
Well, he did say better than C. The bar wasn't set too high.
>>
>>58794095
>OPERATORS
>>
>>58794554
https://www.youtube.com/watch?v=9Ei89MsnCd0
>>
>>58794392
java
>>
What's actually wrong with javascript?
>>
>>58794655
java
>>
File: trash.jpg (72KB, 992x558px) Image search: [Google]
trash.jpg
72KB, 992x558px
>>58794655

It was created by a bigot.
>>
>>58794655
it's not java
>>
>>58794655
['10', '10', '10'].map(parseInt)
>>
>>58794285
Chapel
>>
>>58794752
>[10, NaN, 2]
rofl. Wtf does that happen?
>>
>>58794839
don't ask, some faggot will defend it
>>
>>58794839
>https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
parseInt('10', 0) -> 10
parseInt('10', 1) -> NaN
parseInt('10', 2) -> 2
Apparently JavaScript cannot into default parameters.
>>
>>58794839
['10','10','10'].map(function(x) {return parseInt(x)})
>>
>>58794839
It's an unholy combination of default parameters with abusing the name "map".
>>
>>58794655
If you write for a bad compiled language, you have to know if features work in the compiler you use.
When you write software meant to be run in a browser, you rely on features the user may have in a browser.
Usually this means everything is written for IE, chrome and Firefox.
The worst part: they have the same functions, but Firefox call them mozFunc, chrome call them Func and IE calls them something more retarded.
It is a shitfest.
You have to constantly evolve your code to keep up with the 80 different libraries you "have" to use, the changes in the browsers and all that stuff.
Compiled languages are a bitch on the developer system and that is it.
>>
File: Feb04-210919.png (509KB, 1416x784px) Image search: [Google]
Feb04-210919.png
509KB, 1416x784px
>>58793783
Working on imageboard (like danbooru)
Thinking of rewriting it from scratch using RoR instead of Django
>>
last month it was the average of two integers, not it's complaining about javascript's .map AGAIN
/dpt/ is so boring
>>
>>58794944
i still want to know where akari bbs anon is
>>
>>58794480
>brainlet mad he can't understand FP code
>uses javascript strawman
>>
>>58794966
Post some trivial C code so I can post a better rewritten version
>>
>>58794198
1. Russians are not slavs. They are half-mongolian and more than 10% are muslim
2. Slavs create USA. Read about Puławski and Kościuszko. You can't create country only with nigger fucker politics.
>>
>>58794966

shut up!
>>
File: NIcpEGw.png (75KB, 956x1138px) Image search: [Google]
NIcpEGw.png
75KB, 956x1138px
>>58795178
>Russians are not slavs.
>Slavs created USA.
Found a butthurt Pole.
>>
>>58794752
LMAO functional programming - not even once!
>>
>>58794999
>>58795248
samefag
>>
What is some fun language to learn don't care about jobs
>>
>>58795297
Haskell sure is your choice.
>>
>>58795297
Haskell
>>
>>58794939

this, plus it has inconsistencies that make 0 fucking sense.

the OOP/type system is cancerous garbage

plus all ints are floats
>>
>>58795297
C
>>
>>58795248
shitty bait, but
haskell:
lst :: [Int]
lst = read <$> ["10", "10", "10"]

common lisp:
(mapcar #'parse-integer (list "10" "10" "10"))

racket lisp:
(map string->number (list "10" "10" "10"))

ocaml:
List.map int_of_string ["10"; "10"; "10"]
>>
>>58795166
Here's some trivial code I wrote:

static char whitespace[]=" \r\n\t";

static bool iswhitespace(char chr) {
char *w=whitespace;
while(*w) {
if(*w==chr) return true;
w++;
}
return false;
}

static int iswhitespace_line(char chr) {
if(chr=='\n') return 2; //Ignore \r
return iswhitespace(chr)?1:0;
}

static bool isalphanumeric(char chr) {
return (chr>='0' && chr<='9')||(chr>='A'&&chr<='z');
}

static int chartonum(char c) {
int i=c-'0';
if(i<0||i>9) return -1;
return i;
}


static bool strstrt(char *str, char *strt) {
for(;;) {
if(*strt==0) return true;
if(*str!=*strt) return false;

str++;
strt++;
}
}

static bool isvalididentifier(char chr) {
if(chr==')' || chr=='(') return false;
return !iswhitespace(chr);
}
>>
>>58795166
void ttp_mem_lin_new(ttp_allocator *x, uint s)
{
void *b = malloc(s);
TTP_NNULL(b);
x->alloc = &ttp_mem_lin_alloc;
x->free = &ttp_mem_lin_free;
x->clear = &ttp_mem_lin_clear;
x->destroy = &ttp_mem_lin_destroy;
x->back = 0;
x->lin.buf = b;
x->lin.size = s;
x->lin.offset = 0;
}

void *ttp_mem_lin_alloc(ttp_allocator *a, uint s, uint al)
{
uint ns = s + al;
if(a->lin.offset + ns > a->lin.size)
return 0;
void *p = ttp_align_top((char*)(a->lin.buf) + a->lin.offset, al);
a->lin.offset += ns;
return p;
}

void ttp_mem_lin_free(ttp_allocator *a, void*p)
{
TTP_LOG_ERROR("can't free single item from linear allocator");
}
void ttp_mem_lin_clear(ttp_allocator *a)
{
a->lin.offset = 0;
}
void ttp_mem_lin_destroy(ttp_allocator *a)
{
if(a->back) {
sfree(a->back, a->lin.buf);
}
else {
free(a->lin.buf);
}
}

>>
>>58795341
small ints are represented in V8 as actual integers.
>>
>>58795297
Nim
>>
There is no such thing as a bad programming language they are all different tools to make a program
>>
>>58795359
writing lisp interpreter?
>>
>>58795359
>badly re-implementing C standard library
Why would you do that? Don't you have something useful to code?
>>
File: 1466448884276.jpg (368KB, 3000x3000px) Image search: [Google]
1466448884276.jpg
368KB, 3000x3000px
>>58795447
>>
>>58795359
>>58795362
I said trivial, not completely useless and out of context
>>
>>58795453
Bingo
>>
>>58795480

Just use the libraries from qmail.

The C stdlib is cancer.
>>
>>58794380
Why use Rust if you're making everything unsafe?
>>
>>58795503
>FFI
>everythingg
>>
>>58795498
Nice, but the code you provided is subpar, I worry for how the actually meaty part of the interpreter is going to be built
>>
>>58794999
>>58795281

That doesn't really help your case, as FP languages go JavaScript is one of the few bearable ones. If it isn't any good, what does that tell you about completely incomprehensible esoteric languages like Haskell and Lisp?

I'm sorry, but FP is just a forced meme pushed by academia. Nobody uses it in the real world.
>>
File: 1465740370726.png (39KB, 620x456px) Image search: [Google]
1465740370726.png
39KB, 620x456px
>>58795533
>as FP languages go JavaScript is one of the few bearable ones
>>
>>58795540
It is the only one with a non-negligible marketshare, anon.
>>
>>58795526
Can you explain what's wrong with the code? It was just thrown together, but if there are glaring deficiencies I'd like to correct them.
(Other than the fact that I should just use c library functions.)
>>
>>58795540
JS is the best functional language, closely followed by Rust
>>
>>58795569

But JS is not functional, anon.
>>
>>58795533
JavaScript is not an FP language
>>
>>58795558
First of all, never write parsers in C by hand, use (f)lex + yacc/bison.
>>
>>58795359
static bool isvalididentifier(char chr) {
if(chr==')' || chr=='(') return false;
return !iswhitespace(chr);
}

Why do you return
!iswhitespace(chr)
instead of just returning true? Wouldn't this create unnecessary overhead?
>>
Agreed Javascript and Java are the two best programming languages
>>
>>58795579
>>58795578

This. JS is OOP. That's why it sucks.
>>
>>58793783
Learned Java and currently writing a Bukkit server mod. I'm also currently working on a website using React for a company that builds international art schools. Last thing I worked on was a green house controller in Python that regulates things like humidity and temperature.
>>
How does collision detection work with objects in programming?
>>
>>58795693
>objects
Don't use objects. Use functions. Objects are for pajeets.
>>
>>58795728
I can't use functions Java forces me to use objects there is no way around it
>>
>>58795359
static bool iswhitespace(char chr) {
for (char *w = " \r\n\t" ; *w ; w++)
if (*w == chr)
return true;
return false;
}
>>
>>58795591
It's an educational exercise. I don't really want to use some gigantic existing library I don't understand.
>>58795599
It's for the lexer, and needs to return false when the end of an identifier is reached.
>>
>>58794303
They called their IDE Lazarus because the shitty programming languge was dead on the spot
>>
>>58794480
Functional programming is more of a way to write code than anything? Javascript is a wreck, but not because of FP. If anything, implementing classes into the language made it more shit. Functional programming is a simple concept. After using Java for sometime, forced OOP seems like trash.
>>
any android devs here?

i want to do an effect but i have no idea how it's called
basically what it does, is that it's an element in a listview (most realistically in a recyclerview) and when a certain type of view comes on to the screen thanks to scrolling, it snaps to the top, replacing ("shoving") the old one away either out of the screen (scrolling down) or into its place (scrolling up)

i have no fucking idea what to google because i have no idea how it's called. Anyone?
>>
OOP is actually better for larger projects because it makes it easier to maintain and fix your code compared to functional programming. Java is pretty good desu
>>
>>58795377

Yes, I forgot that people always use Javascript with a life support module stapled on (another reason it is shit)
>>
Hey /g/uys what do you think about github? Give it to me straight, how do I make the most out of it

Is it a place where I can post super basic codes I'm working while learning a language? I would mostly post coding challenges I'm doing from the book if I make an account. I can't really contribute to big projects on there since my knowledge is small but would doing what I said look good to potential employers?
>>
>>58795836
switching to one view to another by scrolling in android
>>
>>58795887
Anything is better than nothing.
>>
File: Pascal.png (81KB, 800x1444px) Image search: [Google]
Pascal.png
81KB, 800x1444px
>>58795788

If Pascal is dead, then every language below it in the TIOBE index is also dead.

Just sayin'.
>>
will Java ever die out?
>>
>>58795887

Use BitBucket instead.
>>
>>58795968
i think it's more about where it previously was
>>
>>58796010
I'll check it. Looks like FB for coders. Whats the difference betweeen that and github?

>>58795943
What do most people on there do
>>
I found this on CL last night and applied.

http://seattle.craigslist.org/tac/cpg/5988854034.html

Early this morning I got a response and apparently I was the first one to submit my application correctly.

I've been lurking, and thinking about learning programming recently and this seems like a good opportunity to get some ""free"" education.

Something about the ad kind of bothers me though, and I'm not sure what. Does anyone with experience taking gigs off of CL see any red flags? I googled it and there's a duplicate ad for Austin, TX's page, but it's remote work so I don't know if that's a sign.
>>
>>58796067
How on earth did you get FB for coders out of Bitbucket?

>Whats the difference betweeen that and github?
nothing
>>
File: 161093861073.jpg (24KB, 227x173px) Image search: [Google]
161093861073.jpg
24KB, 227x173px
>>58795968
looks pretty dead to me
>>
>>58795968
TIOBE is a shitty index though. People have shown it's very easy to game their system just by mentioning the language name more times in your blog post for example. It's also neither based on industry use nor use in personal projects.
Here's another point, languages with more beginners will always rank higher because it is impacted by StackOverflow posts and github projects. more github projects = smaller ones in general, which beginners make. more SO questions means less experience both in the language and in general. first-time Lisp programmers are generally more experienced than first-time Java programmers, so Lisp will receive fewer stackoverflow questions.
>>
>>58796079
Negative factors:
1. It's weird
2. "Possibly get paid" and receiving the lump sum only if he decides you did "awesome"
>>
>>58793808
If you like semantically leaking to-C/C++ compilers.
>>
>>58795968
The TIOBE index is shit

>>58796067
>What do most people on there do
They post personal projects or contribute to open source projects.
>>
>>58796079
Sounds like some covert gay sex ad
>>
>>58796079
>Do not ask questions about the task
>if you do great, I will send a lump sum upon completion
You're going to be doing some awful grunt work and then not get paid.
>>
>>58796016
But according to the index Pascal is rising, anon.
>>
>>58796166
then it's not dead
>>
>>58794095
So... why not just usse structs?
>>
>>58796204
STRUCYTS DONT COME WITH BUILTING LOGGING AND COTNIUNEUSOUS INTEGRATI@NS!!!
>>
>>58796204
Because polymorphism, liskov substitution, interfaces, decorators, etc.
>>
>>58793783
Learning assembly
Anyone have some good resources?
>>
>>58796204
>inb4 le "objects are just structs with methods" meme
>>
>>58796123
1. True
2. I could use money, but I didn't really associate this ad w anything other than education.

>>58796153
pls no

>>58796161
I'm gonna try calling him when he's free in 20~ min and asking more about the job. I'll report back.
>>
>>58796226
that's true though
>>
>>58796217
>liskov substitution
talk about a meme, just say subtyping
>>
>>58795968
yes, every language below pascal there IS dead
>>
>>58796262
I might agree, but
>dead
>Ruby, Lua and Swift
>>
>>58795836
>>58795900
i was talking more about the pushing away part
i found a video of this effect, but its on an iPhone
https://youtu.be/jN6rYhnA184?t=1m35s
im talking about the first letter tab. it gets pushed out once it is no longer relevant and is replaced by a new one
>>
What's the fastest scripting language?
>>
>>58796434
How do you define scripting language?
>>
>>58796434
How do you define fastest?
>>
>>58796460
Scripting languages are interpreted.
>>
>>58796434
Perl is pretty fast.
>>
>>58796434
Html
>>
>>58796489
Few languages are actually interpreted these days.
>>
>>58796513
It's markup language.
>>
>>58796434
LuaJIT?
>>
>>58796434
LuaJit, neck in neck with Java(beats it in memory every time though), sometimes contests C++

Mike Pall is like THE programming god though.
>>
File: uwe_schuenemann_passwd.jpg (2MB, 1601x1760px) Image search: [Google]
uwe_schuenemann_passwd.jpg
2MB, 1601x1760px
Still waiting for Jai to be released.
>>
>>58796530
same thing
>>
>>58796489
no idea how do an effect but you're making everything is a shitskin java or into default parameters with a forced oop after using it. if you define scripting language?
>>
>>58796575
no
>>
>slavs created by scrolling in android anything other day.

funniest thing i've been lurking, and github projects. sounds like they use java file: not an algorithm work with abusing the fact that code you expect? c++ even relevant and github? nothing file:
>>
>>58796615
Try English next time.
>>
>>58796615
/g/ post neural network? Or just /dpt/?
>>
File: 1475520088774.png (41KB, 1790x1640px) Image search: [Google]
1475520088774.png
41KB, 1790x1640px
>>58796615
>even the computer knows c++ isn't relevant anymore
>>
>>58796678
>>58796688
definitely generated by a markov chain
>>
>>58796688

words = text.split()
lwords = []
ddict = {}
new_article_words = []
string = ""

for i in words:
i = i.lower()
lwords.append(i)

for k,v in zip(lwords, lwords[1:]):
ddict.setdefault(k, [])
ddict[k].append(v)


start_word = random.choice(lwords)

running = True
while running == True:

new_article_words.append(start_word)

if start_word in ddict:
possible_words = ddict.get(start_word)
next_word = random.choice(possible_words)
if len(new_article_words) > 2 and new_article_words[-1] == next_word or len(new_article_words) > 100:
break
else:
start_word = next_word

for i in new_article_words:
string+= i
string+= " "
print(string)

>>
>>58796615
>>58796720
next time, parse only the text from posts
>>
>>58796568
e-celeb bullshit
>>
>>58796720
what is this shitlang?
>>
>>58796732
Don't really care as long it's as fast as C while being comfier than C++.
>>
>>58796720
>== True
>>
>>58796422
found it
it's called a sticky header if anyone reading this cares
>>
>>58796079
>Lump sum

If anything's going to be lumpy, it'll be his semen in your mouth :^)
>>
>>58796720
the functional programmer in me is really not liking this
>>
File: d_fizzbuzz.png (57KB, 800x334px) Image search: [Google]
d_fizzbuzz.png
57KB, 800x334px
> monte MONTE
>>
>>58796877

I tried to look up functional programming in python and when I posted my code, the python guiz made fun of me and said explicit is better than implicit and readability counts
>>
>>58796939
well python is basically a non language so maybe learn something useful
>>
>>58796756
Doubt it.
>>
>>58796966
It already is though.
>>
File: 1458323464034.png (11KB, 672x462px) Image search: [Google]
1458323464034.png
11KB, 672x462px
>>58793783
>What are you working on, /g/?
Pong

Trying to figure out how I can get the ball to do what I want
>>
>>58796732
It actually looks decent. And JBlow isn't just an e-celeb, he is a serious programmer.
>>
>>58797000
yeah i'd use it. it has dependent types and everything!
>>
>>58797038
Also type introspection and reflection (at compile time, which is some kind of runtime).
Can't wait to write a program that make a post on 4chan whenever I compile it.
>>
>>58797073
reflection at compile time is just advanced preprocessing 8^)
>>
>>58796460
http://wiki.c2.com/?ScriptingLanguage
>>
File: face_fatcat.jpg (79KB, 560x444px) Image search: [Google]
face_fatcat.jpg
79KB, 560x444px
>>58797086
Can your advanced preprocessing post on 4chan?
I DIDN'T THINK SO
>>
>>58797107
sure, although im too lazy to go implement the 4chan API in ocaml.
>>
>>58796742
python
>>
>>58797086
anything at compile time is just advanced preprocessing :-*)
compilers are just advanced preprocessors :--&)
>>
>>58793808
yes. nim deprecated rust, go, pytho, cpp and java.
>>
>>58797000
It's a vanity project.
>integrated build process
just lol
>>
>>58795533
>lisp is completely incomprehensible/esoteric
its just expressions u tard
>>
>>58797198
not necessarily. a preprocessor is some form of mapping of uncompiled code to uncompiled code. if your preprocessor doesn't process the code at all it's not a preprocessor, is it? and a compiler is not a preprocessor because it crosses language barriers
>>
File: reaction_tableflip.gif (9KB, 391x644px) Image search: [Google]
reaction_tableflip.gif
9KB, 391x644px
https://youtu.be/UTqZNujQOlA?t=49m47s
>tfw you'll never play a Space Invaders clone and have your score embedded into some software
>>
>>58797239
compile time reflection requires introspecting the AST for type information which at the very least makes it an interpreter
a compiler is commonly defined as an interpreter that produces coded; is it a requirement to cross language barriers?
>>
>>58796993
algebra 2, vector operations
>>
>>58797275
Neato.
People harp on C++ for being undecidable etc., which yes it's a problem because of stupid grammar rules of C++, but running arbitrary code (with undecidable termination, THEREFORE making it seperate from dependent types) at compile time is very useful; macro programming is possibly the most powerful form of abstraction and at the very least can be used for performance by precomputing values.
>>
Why is programming difficult?
>>
>>58797278
an interpreter is just a compiler though
type introspection only requires the interpretation of a meta-language (i.e. the type-level language/where type checking is performed)
however, due to the multi-stage compilation model of Jai the line is not so clear
>>
>>58797347
Depends on what you program you big baka
>>
>>58795178
>terrible English
Obvious Slav.
>>
>>58797347
because abstraction and application of concepts are hard. and require fundamental understanding of whatever you're abstracting.
>>
>>58797382
like what?
>>
whats the difference between fmap and map
>>

package com.tutorialspoint;

public class HelloWorld {
private String message;

public void setMessage(String message){
this.message = message;
}

public void getMessage(){
System.out.println("Your Message : " + message);
}
}

package com.tutorialspoint;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainApp {
public static void main(String[] args) {
ApplicationContext context =
new ClassPathXmlApplicationContext("Beans.xml");

HelloWorld obj = (HelloWorld) context.getBean("helloWorld");

obj.getMessage();
}
}

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<bean id="helloWorld" class="com.tutorialspoint.HelloWorld">
<property name="message" value="Hello World!"/>
</bean>

</beans>

>>
>>58797356
>an interpreter is just a compiler though
False, most interpreters are compilers (for numerous reasons), but interpreters do not have to be compilers.
The following function is definitely an interpreter but is not a compiler.
(struct lam (arg body))
(struct app (fun arg))

(define (eval e env)
(match e
[(? symbol? x) (cdr (assoc x env))]
[(lam arg body)
(lambda (v) (eval body (cons (cons arg v) ctx)))]
[(app fun arg)
(apply (eval fun env)
(list (eval arg env)))]))


>>58797414
fmap can apply to any kind of data that is a functor (for instance Maybe's and functions), while map can only apply to lists
note
instance Functor [] where
fmap = map
>>
why doesn't /dpt/ have a code jam or daily programming challenges
>>
>>58797499
but we have.

you can only see it if you're a programmer god, though.

but we have
>>
>>58797514
don't listen to this guy he's lying we don't have anything here sorry
>>
>>58797347
You can make it easier by first learning how to structure and design any kind of program. These 3 courses teach you that: https://www.edx.org/course/how-code-systematic-program-design-part-ubcx-spd1x

Second you want to learn problem solving, because that's what programming generally is: solving problems with computation. There are actual strategies and skills you can learn to properly define and solve problems:

"How To Solve It" George Polya. Heurists and problem solving skills, by a great mathematician.

The Art and Craft of Problem Solving, 3rd Edition by Paul Zeitz (US math olympiad winner)
http://ca.wiley.com/WileyCDA/WileyTitle/productCd-EHEP003691.html

This is all you need. A solid foundation in logic and problem solving. Now you can go pick up any full language spec book and start programming using the strategies of the above courses and logic books.
>>
>>58797570
alright thanks i'll start with Java
>>
>>58797570
This looks like HtDP which is available for free online at http://www.ccs.neu.edu/home/matthias/HtDP2e/

Also paper on why it's better than SICP
http://cs.brown.edu/~sk/Publications/Papers/Published/fffk-htdp-vs-sicp-journal/paper.pdf
>>
>>58797622
It is HtDP taught by a UBC professor with interactive assignments so you learn by doing, it's a really good course and basically everybody should take it if they're new to programming since it shows you design of ridiculously difficult functions and multi module programs.
>>
>>58797539
pajeet tier programmer detected
>>
>>58797622
It's not 'better' than SICP, they teach different things.

You still would want to read SICP after doing HtDP in fact you'll gain a much better understanding of SICP if you've read it after programming for a bit.
>>
>>58795968
>9. assembly language

what in the name of FUCK?
>>
>>58797648
I'm attending NEU where the author of HtDP teaches and I think it's a great improvement on the shitty way that 90% of other tutorials attempt to teach. Basically if you're struggling with learning to program, it's probably because you aren't reading HtDP.
>>
Why does
#include <stdio.h>
#include <stdlib.h>

int main() {

FILE *f = fopen("eee", "r");

char *t = (char*)malloc(1);
fscanf(f, "%s", t);
printf("%s", t);

free(t);
fclose(f);

return 0;
}

work and print out my whole file, but
#include <stdio.h>
#include <stdlib.h>

int main() {

FILE *f = fopen("eee", "r");

char *t;
fscanf(f, "%s", t);
printf("%s", t);

free(t);
fclose(f);

return 0;
}


prints nothing?

shouldn't the first code only print 1 char?
>>
File: 1445722183259.jpg (68KB, 700x700px) Image search: [Google]
1445722183259.jpg
68KB, 700x700px
>>58797608
NO YOU FUCKING BRAINLET YOU DIDN'T UNDERSTAND ANYTHING OF MY POST
>>
>>58797758
null character terminated strings

also
>malloc(1)
why.jpg
>>
>>58797758
go back and learn what malloc does and what fscanf does

e.g.
does scanf know how many characters of input to read from the user?
>>
>>58797695
assembly is still used for stuff like microoptimisations (important for cryptography)
>>
>>58797758
just gonna mention
>uninitialised memory
>free()ing an uninitialised pointer that doesn't point to memory allocated by malloc() or calloc()
>>
>>58796720
reflection at least they want to me straight, how do that? don't ask, some faggot will be anime for a way better than 10% are represented
>>
>>58797758
Always use calloc unless doing performance critical embedded work, read this:
https://matt.sh/howto-c

If you have a string literal that you do not want to modify: char *literal = "foo";

You also essentially performed a 'double free' by freeing memory that wasn't allocated in second example.
>>
>>58797885
There is absolutely no reason to use calloc if you're just going to initialise the memory yourself immediately.
I don't see how the string literal thing is relevant.
That is not a double free bug in his second code. It's the use of an uninitialised pointer.
>>
>>58796720
looks decent. and kościuszko. you take away all trademarks and hoping it isn't any red flags? i can't use the implementation is better than c standard library why do you kissless virgin.
>>
>>58794647
3/10
>>
>>58796720
anyone have shown it's an unholy combination of the difference betweeen that people have shown it's complaining about puławski and github?
>>
>>58797783
>>58797807
>>58797846
>>58797885
I'm lost here
#include <stdio.h>
#include <stdlib.h>

int main() {

FILE *f = fopen("eee", "r");

char t[2];
fscanf(f, "%s", t); //text in file:zzzzzhello
printf("%s %i\n", t, sizeof(t));
printf("%c%c%c%c%c%c\n", t[0], t[1], t[2], t[3], t[4], t[5]);
printf("%i", sizeof(t));

fclose(f);

return 0;
}

how does my 3 slot char array store 10 characters
>>
>>58797443
Stop replying to tripfags.
>>
>>58793808
>is Nim worth learning
Has it got a USP worth a damn?
>>
>>58798015
you're using uninitialised memory again
>>
>>58796124

All compilers leak semantically to C--. At least all good compilers anyway.
>>
>>58798015
Go on libgen.io and get the gopl.io book:
http://www.gopl.io/

It has clear examples how to open and manipulate files and you can pick up go in a couple of weeks as a beginner and be fluent in it. If you want to learn C and especially I/O in C read this: http://csapp.cs.cmu.edu/
>>
>>58798015
>fscanf(f, "%s", t);
The %s in *scanf is unbounded. It doesn't know anything about the size of the buffer, and will happily read past the end of it.
It's basically gets() in disguise.
Either add a bound to the string length, or use a different, more safe function which take the buffer's length into account.
fscanf(f, "%.1s", t);

fgets(t, sizeof t, f);
>>
I think VLAs were a good idea.
>>
>>58795788

You're mixing things up. The language isn't dead. RAD is what's dead. It's too problematic and leads to poor design.
>>
File: ok.jpg (51KB, 600x694px) Image search: [Google]
ok.jpg
51KB, 600x694px
>>58795968

>ruby dead
>go dead
>swift dead
>vb dead
>obj-c dead
>pl/sql dead
>sas dead
>d dead
>cobol dead
>f# dead
>fortran dead
>scala dead
>transact-sql dead
>lisp dead
>haskell dead
>rust dead
>erlang dead
>clojure dead

I'm ok with this.
>>
>>58797414
Nothing. Map only works on lists.
>>
>>58797414
Cruft.
>>
>>58798224
>>58798241
the timing of these posts arouses my suspicion
>>
>>58798253
I (>>58798241) saw >>58798224 and decided to reply as well.
>>
>>58798253
Bumps breed replies.
>>
>>58798270
I saw your posts and now ill reply for no reason
>>
>>58798094
Ah, that makes sense, thanks
>>
>>58798253
I'm the first one. I was reading something else, hence delay in response.
>>
>>58793783
I'm installing MSYS2 so I can get my program to work on Windows. Microsoft made such a terribly designed operating system, I'm surprised a toy OS like Windows ever got popular.
>>
>>58794285
Racket.
>>
>>58798189
>C still used after an infinite amount of time
really makes you think
>>
>>58795968
>TIOBE index
Why is java so high?
>>
>>58798454

Java is the modern-day COBOL.

http://www.youtube.com/watch?v=LR8fQiskYII
>>
>>58798390
C is here to stay, they're even working on a C21 version: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2021.htm
>>
>>58798592
nothing beats C in speed, it's the best choice for libs and kernels
>>
>>58798592
What if instead of fucking C even more they would just make new language that would have same stable ABI as C but to make as modern as possible without forcing gc or some other bullshit.
>>
>>58798645
>nothing beats
Assembler.
>>
>>58798592
>(a) Trust the programmer.
>(b) Don't prevent the programmer from doing what needs to be done.
>(c) Keep the language small and simple.
>(d) Provide only one way to do an operation.
>(e) Make it fast, even if it is not guaranteed to be portable.
>(f) Make support for safety and security demonstrable
why is perfection so tasty
>>
migrating my company's legacy infrastructure into kubernetes
>>
File: 1471996948763.png (728KB, 1165x1075px) Image search: [Google]
1471996948763.png
728KB, 1165x1075px
guys I'm really proud of my solution. What do you think?

>Write a program detab that replaces tabs in the input with the proper number of
blanks to space to the next tab stop. Assume a fixed set of tab stops, say every n columns.

#include <stdio.h>


main () {
int i;
int c;
int counter = 0;

while ( (c=getchar())!= EOF ) {

if(c!='\t') {
putchar(c);
counter++;
}
else {
for (i=0;i<(8-counter) ;i++ )
putchar('_');
counter = 0;
}
}
}
>>
>>58798592
>>58798703
>(d) Provide only one way to do an operation.
x = x + 1;
x += 1;
x++;
++x;


>>58798703
>At the WG 14 meeting in London, England, in June, 2007, the original principles and the principles that were used for C99 were reviewed, and the following observations were added, not in any particular order:
>12. Trust the programmer, as a goal, is outdated in respect to the security and safety programming communities. While it should not be totally disregarded as a facet of the spirit of C, the C11 version of the C Standard should take into account that programmers need the ability to check their work.
>>
>>58798651
rust desu
>>
>>58798906
>Without forcing bullshit
>>
>>58798914
>bullshit
such as?
>>
>>58798860
>
x++;
++x;

Not the same
>>
>>58798922
safety? :^)
>>
>>58798860
None of those are equivalent, idiot.
>x = x + 1;
Normal assignment.
>x += 1;
Any side-effects of x are only evaluated once.
e.g.
*ptr++ += 10; // Not equivalent to *ptr++ = *ptr++ + 10

>x++;
Value is x, with the side effect of x being incremented.
>++x
Value is x + 1, with the side effect of x being incremented.
>>
>>58795347
>racket lisp
Also works in Scheme.
>>
This should go in the stupid questions thread. Though 30 different Google searches and I can't find any relevant material - which startles me, quite honestly.

There's a way to get a batch script, say, after running a regular old $(program -var1 -var2 -var3), then on the line you're running...
$ sh memescript.sh more_data_appended_to_end_of_shell_input


And have "more_data_appended_to_end_of_shell_input" be put after the initial command run within $()?

Basically, I need to grab from the line the script has ran from
There's a special control code for this kind of thing, right?
>>
>>58798842
It doesn't work when the tabs are more than one level deep.
e.g.
$ printf "%10s\ttest\n" " " | ./a.out
test

Where the result should be
          ______test
>>
>>58799028
Correction,
$ sh memescript.sh(...)

If that wasn't an obvious typo
>>
File: 1479371573450.png (179KB, 462x450px) Image search: [Google]
1479371573450.png
179KB, 462x450px
>>58793998
>not C and SDL
>>
File: file.png (488KB, 640x580px) Image search: [Google]
file.png
488KB, 640x580px
>>58799086
>not haskell and x86 asm
>>
File: assembly.png (50KB, 998x716px) Image search: [Google]
assembly.png
50KB, 998x716px
why is assembly gainign popularity
>>
be honest, if you had to write a function to perform the modern fisher yates (knuth) shuffle on an array right now, could you do it?

>inb4 what is that
>>
>>58799115
People realized abstractions were a meme
>>
File: answer my fucking question.png (884KB, 800x1192px) Image search: [Google]
answer my fucking question.png
884KB, 800x1192px
>>58793783
how does the toggle
bool = !bool
work?

How doesn't it just set bool to false?
>>
>>58799131
Look up what a not operator does
>>
>>58799131
1=1
2=2
3=3
0=0
A49B4E3=A49B4E3
0001010111011=0001010111011

: ^ )
>>
File: 1483654790065.jpg (110KB, 1280x720px) Image search: [Google]
1483654790065.jpg
110KB, 1280x720px
>>58799103
>not machine code
>>
>>58799125
Nope, but it seems simple enough
>>
File: file.png (258KB, 408x408px) Image search: [Google]
file.png
258KB, 408x408px
>>58799165
>not hooking batteries into wires to communicate with a microprocessor by swapping very small voltages rapidly
>>
>>58799131
!false is true
!true is false
>>
>>58799115
developers realized they can't just throw more hardware at stuff now that CPUs can't be made faster, so people have to go back to understanding how computers work.
>>
Is this possible to export a simple SDL game to web assembly yet?
>>
File: 1467332057493.jpg (52KB, 484x410px) Image search: [Google]
1467332057493.jpg
52KB, 484x410px
>>58799178
>being a doggoposter
>>
New thread:

>>58799206
>>58799206
>>58799206
>>
>>58799217
Stop creating threads early, you fag.
>>
>>58799223
>311th post
>>
>>58799272
>39 posts to go
>>
>>58795347
type classes make so much sense honestly
>>
>>58797885
>https://matt.sh/howto-c
for (uint32_t i = 0; i < 10; i++)


I get his argument for using fixed-width types, I really do, but why on earth would you go to the trouble of typing "uint32_t" over ""int" for a fucking 0-to-10 counter?

This dogmatic shit is about as cancerous as GNU code styles.
>>
>>58799289
>hownew.ru
>>
>>58799272
The 310th post was the new thread link, so that must mean that the thread was created before the 310th post.
The bump limit needs to be followed strictly. Not even a single post early.
Fortunately, the image wars have died down, but this sort of early-posting leads to other fags posting even earlier, and it just becomes a stupid competition.
>>
>>58799289
bump limit is 310
>>
>>58795693
>>58795739
look up AABB collision for 2d

you are talking about gamedev right
>>
>>58793783
I decided to learn Python.
>>
>>58799303
Generals don't need to be bumped.
>>
>>58799294
I agree.
However, using the fixed width types has their own problems over the standard types as well.
- They aren't completely portable, as the standard doesn't guarantee that they actually exist, so your code won't work on CHAR_BIT != 8 and non-twos compliment computers. It might not be something you care about, but it's something.
- It conveys to the reader that the value needs to be 32-bits for a specific reason, which can be very misleading and just burdens the reader. A plain 'int' has no baggage associated with it.
>>
>>58799357
it's not a "bump" limit but a limit at which threads are no longer bumped.
>>
>>58799357
It would be nice if there were one big rolling pinned /dpt/ programming thread though.
>>
>>58799366
Good job, you figured this much alone? I'm proud of you.
>>
>>58799357
>>58799403
(You)
>>
>>58799418 (You)
>23 more
>>
>>58799352
I'm sorry
>>
>>58799358
Well that's what I was hinting at, I would only use them when I actually care about the type size.
Given that ints have to be at least 16-bit and and always the fastest to use, I rarely have to give a shit.
>>
>>58793961
link repo
>>
Hey /g/, C++ question about vectors. In Programming Principles and Practices, in the section about Traversing a Vector, it says "The range for a vector v is [0:v.size()]. That's the mathematical notation for a half-open sequence of elements."

That part I understand, this next part I don't-

"The first element of v is v[0] and the last v[v.size()-1]"

I get that v[0] is the first element, but I'm not understanding v[v.size()-1]. Why -1? Feel free to explain it like I'm an idiot.

Thanks again, you all always explain this stuff really well.
Thread posts: 332
Thread images: 47


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.