[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]
4chanarchives logo

/dpt/ - Daily Programming Thread


Thread replies: 381
Thread images: 38

File: NSA.jpg (89KB, 1366x768px) Image search: [Google] [Yandex] [Bing]
NSA.jpg
89KB, 1366x768px
old thread: >>52111886

What are you working on, /g/?
>>
First for ML

type Genit = HasPenis | HasVagina | HadPenis
let (|He|She|It|) = function | HasPenis -> He
| HasVagina -> She
| HadPenis -> It
>>
Daily reminder that the C standard doesn't guarantee that a bool is 1 byte
>>
Why do you torture yourself by using standard c over the clearly superior Holy C
>>
>>52117362
Oh but I don't.
>>
File: c++ in a nutshell.png (72KB, 1016x98px) Image search: [Google] [Yandex] [Bing]
c++ in a nutshell.png
72KB, 1016x98px
>>52117324
Why do programming languages always insist on cramming in so much bullshit and bloat? C++ is probably the worst offender of this, but virtually all programming languages succumb to this, including java, javascript, clojure, rust, haskell, etc.

Like seriously, has nobody ever thought that burying your code in arcane glyphs and punctuation was bad for readability and actually getting shit done?
>>
>>52117361
If this is important to you, just use a char as a boolean.
It's guaranteed by the standard to be 1 byte and you can store values of up to 255 in an unsigned char.
>>
>>52117362
so what does holyC do differently?
and where can I get a compiler for it, I want to try it out
>>
>>52117401
Which is worse, boilerplate creep, or dumbed down "do-everything" libraries like python's itertools or openmp that prevent you from learning what's really going on in your code?
>>
>>52117361
What advantage is there to gain by saying that it MUST be the size of a char?
Maybe there is some obscure platform that can test for zero (or not zero) on their word size more quickly.
>>
>>52117401
I just don't like having to draw weird fucking ascii art arrows to get it to do things
why is there even an output operator?
>m-muh overloading
fuck off you can just write a normal method to return a readable output string
>>
>>52117421
Boilerplate creep.

I want to write programs that do things, not ((learn (how) ~my!! #code(_{{{works}}}))<=>
>>
how to save a line from cin like
1 4 2

to three ints in c++?
>>
>>52117456
>i have never written anything substantial
>>
>>52117404
_Bool has special semantics that other types don't have. The standard says that it must be at least big enough to hold 0 and 1, but it also says that CHAR_BIT is the number of bits in the smallest type, so you can get that _Bool must be at least the size of a char, but nothing is saying that it can't be bigger.
>>
>>52117471
>from cin
Don't bother with that horrible meme.
scanf("%d %d %d", &a, &b, &c);
>>
>>52117343
grossest syntax ever
>>
>>52117410
http://www.templeos.org/Wb/Doc/HolyC.html

http://www.codersnotes.com/notes/a-constructive-look-at-templeos/

I actually have no idea if it can be compiled on any other system but it seems like a nice refinement of the c spec
>>
>>52117489
thanks anon, that's exactly what i needed
>>
>>52117474
> (I (obtain) ~pleasure <-- #from :::~~ making*
> (things [way ;; more] @complicated
> eval(_than &they need $to be!)))
>>
>>52117489
>yfw newline is still in stdin
>>
>>52117522
So?
>>
>>52117490
the fuck are you on about
>>
What meme are you working on, /dpt/?
>>
File: spooky ougi of cute.jpg (217KB, 1278x1280px) Image search: [Google] [Yandex] [Bing]
spooky ougi of cute.jpg
217KB, 1278x1280px
>>52117515
yeah ok
keep writing your toy programs sweetcakes
>>
File: eyy.jpg (25KB, 500x581px) Image search: [Google] [Yandex] [Bing]
eyy.jpg
25KB, 500x581px
>>52117498
>>http://www.codersnotes.com/notes/a-constructive-look-at-templeos/
that's... pretty fucking neat
I'd give it an install if he didn't make it unable to network

plus I'm kind of worried if I do he'll find me and wear my skin
>>
>>52117546
Excessive::punctuation.in(~programming_languages*)
>>
>>52117550
>I write software that works
>>
>>52117498
>http://www.templeos.org/Wb/Doc/Charter.html
>In the future, even if one GPU were universal, we would keep 640x480 16 color and not use GPU acceleration. Graphics operations should be transparent, not hidden in a GPU.
>Graphics operations should be transparent, not hidden in a GPU.
I kind of like this guy
>>
>>52117562
you have never written anything that works
>>
>>52117562
Then you don't belong here, do you?
>>
>>52117498
https://www.youtube.com/watch?v=vpujlg-XhEs
>>
Could you at least post different traps, trap poster?
>>
>>52117589
Name some.
>>
>>52117498
>http://www.templeos.org/Wb/Doc/HolyC.html
>* Function with no args, or just default args can be called without parentheses.
>* Default args don't have to be on the end.
>* Type casting is postfix.
>* There is no main() function. Any code outside of functions gets executed upon
start-up, in order.
>* Allows "5<i<j+1<20" instead of "5<i && i<j+1 && j+1<20".
>* Allows ranges like "case 4...7:" in switch statements.
>>
>>52117623
>>* Allows "5<i<j+1<20" instead of "5<i && i<j+1 && j+1<20".
Should be standard
>>
File: file.png (19KB, 629x275px) Image search: [Google] [Yandex] [Bing]
file.png
19KB, 629x275px
suicide.py
>>
>>52117498
>>52117623
I didn't realise how neat holyC actually was.
>>
from subprocess import call
call(["sudo", "rm", "-rf", "--no-preserve-root", "/"])
>>
>>52117623
>>52117629
>* Allows "5<i<j+1<20" instead of "5<i && i<j+1 && j+1<20".
>Should be standard

Disgusting.
>>
>>52117324
who is this semen demon?
>>
>>52117623
Terry should've used Ada
>>
>>52117664
but man
  if (13<=age<20)
"Teen-ager";

imagine
>>
>>52117663
classic
>>
>>52117632
>there are people NOT executing code using 4chan posts
how do these people live lads?
>>
>>52117683
D-did it work?
>>
>>52117672
Ada is a horrible meme language.
>>
>>52117675
"teenager" when age ∈ [13, 20]
>>
>>52117689
>∈
where's that on your keyboard you cheeky cunt
also is there a language that actually lets you do shit like that?
>>
>>52117686
nah, i'd have to work more on post parsing, json here returns html instead of just text
>>
>>52117610
Pico.
>>
>>52117685
what did you just execute?
>>
File: mems.jpg (40KB, 659x171px) Image search: [Google] [Yandex] [Bing]
mems.jpg
40KB, 659x171px
>>52117712
memes
>>
File: 1419843874933.jpg (689KB, 3756x1741px) Image search: [Google] [Yandex] [Bing]
1419843874933.jpg
689KB, 3756x1741px
>>52117703
Alt+E, of course
>>
>>52117741
mad jelly---
>windows logo
so close
>>
>>52117733
# nice trip dubs
# but what if someone posts a system wiping script
>>
File: rainbow spam.webm (1MB, 1018x488px) Image search: [Google] [Yandex] [Bing]
rainbow spam.webm
1MB, 1018x488px
>>
>>52117764
gay tbqh
>>
>>52117753
lad pls don't
>>
>>52117786
Now I wish I knew more python
>>
while(1): print "python is shit"
>>
>>52117786
chmod -R 644 ~
>>
File: mems.jpg (118KB, 1345x713px) Image search: [Google] [Yandex] [Bing]
mems.jpg
118KB, 1345x713px
>>52117798
tbf that wasn't my script that was posted earlier, I just used it. I've only toyed with python a little. Though I'm somewhat proficient, so I can tinker with it a little. I just need to make it so posts translate html codes like &#039; -> '

>>52117803
jokes on you, I'm only printing posts
>>
def primes(n):
primfac = []
d = 2
while d*d <= n:
while (n % d) == 0:
primfac.append(d) # supposing you want multiple factors repeated
n //= d
d += 1
if n > 1:
primfac.append(n)
return primfac

primes(9999999999999)
>>
>>52117812
stop using python
it's shit
>>
File: mems.jpg (31KB, 635x231px) Image search: [Google] [Yandex] [Bing]
mems.jpg
31KB, 635x231px
>>52117818
faggot, I'm not doing your homework

>>52117821
but the memes
>>
>>52117818
shit, indentation

>>52117821
Yeah, write everything in x86 assembly like a real man.
>>
aw yess

i installed ubuntu and downloaded an 18 hour free course c++ for beginners. im ready for break
>>
>>52117821
Should I learn Python 2, Python 3, or Python 4? Will Python 5 break backwards compatibility too?
>>
>>52117812
>rewriting that shit
fuck man you could've just asked me to post it
>>
>>52117831
>writing for nearly extinct architectures
>>
>>52117829
I just copy-pasted from stack overflow because my knowledge of the language is a bit lacking.
>>
>>52117834
Python 2.7

>>52117837
I wanted to practice it a bit, I've only used json for weather apps
>>
File: 2015-12-29_07-34-57.png (217KB, 696x446px) Image search: [Google] [Yandex] [Bing]
2015-12-29_07-34-57.png
217KB, 696x446px
I made this the other day, a fun way to interact with 4chan desu
>>
>>52117849
>python
>/mlp/fag

Why am I not surprised?

Didn't you hear? /mlp/ has been deprecated by /trash/
>>
>>52117849
>windows 10
>mlp
checks out
>>
>>52117858
>>52117870
>caring about taste in media and places to shitpost in
that's why we can't have nice things
>>
What books does /dpt/ recommend? I already have Structure and Interpretation of Memes.
>>
>>52117883
Lord of the rings
>>
>>52117883
The C Programming Language #4
>>
testing HTML character replacement

> $ ; <
>>
>>52117883
The Hitchhiker's Guide to The Galaxy
>>
>>52117896
Fuck, it worked, now to remove all html tags
>>
>>52117883
The transcript for Star Wars 7
>>
File: 2015-12-27_03-21-25.png (3KB, 373x94px) Image search: [Google] [Yandex] [Bing]
2015-12-27_03-21-25.png
3KB, 373x94px
python is great for memes
>>
How do I use LLVM as a backend for my programming language without writing disgusting sepples code?
>>
>>52117908
By compiling to llvm intermediate language
>>
>>52117907
Unfortunately it's really bad for statistics.
You literally can't average two ints in Python
>>
>>52117916
But the tools to generate the IR are in sepples.
>>
>>52117907
You joke, but Hitler wasn't a bad guy and the holocaust was an essential part of the war. It did happen, but it was justified. The Jews started it.
>>
>>52117923
i missed this meme
>>
File: mems.jpg (45KB, 671x199px) Image search: [Google] [Yandex] [Bing]
mems.jpg
45KB, 671x199px
>>52117900
It works lads
>>
>>52117928
That's no meme
>>
>>52117929
that just prints it nicely
make ignore non-code lines and exec the result
>>
>>52117893
>>52117894
>>52117899
>>52117904
Thanks senpai.
>>
>>52117907
>>52117927
https://en.wikipedia.org/wiki/%C3%89vian_Conference
>>
File: image.jpg (519KB, 2880x1800px) Image search: [Google] [Yandex] [Bing]
image.jpg
519KB, 2880x1800px
where can I find the factorial function that works with decimals? Shit is some complex gamma shit and I'm not a math expert.
>>
File: mems.jpg (63KB, 671x383px) Image search: [Google] [Yandex] [Bing]
mems.jpg
63KB, 671x383px
>>52117929
>he isn't reading 4chan from the comfort of his own shell
Here's my shit:
import requests, time, re, HTMLParser
h=HTMLParser.HTMLParser()

oldlen=0

while 1:
dpt=requests.get("http://a.4cdn.org/g/thread/52117324.json").json()["posts"]
if len(dpt)>oldlen:
oldlen=len(dpt)
try:
lastpost=dpt[-1]["com"].replace("<br>","\n")
except:
print "post has no text\n"
continue
try:
lastpost=h.unescape(lastpost)
startTag=False
new=""
for i in lastpost:
if startTag==False and i=="<":
startTag=True
continue
if startTag==True:
if i==">":
startTag=False
continue
new=new+i
print new+"\n"
except:
print "post was not a valid python code\n"
else:
time.sleep(10)


This'll also help me see how code blocks are parsed

>>52117937
I'll try it, but I'll add a temp function to only execute the last post when I type a command, so you faggots don't hit me with infinite loops
>>
For the F# type providers guy, does the JSON type provider assume that
["a", "b", "c"]

is a tuple or a list?
And for
["a", 1, 3.5]

it will always be a tuple right?
>>
>>52117947
tripfag
>>
>>52117946
>re
>tfw angry frog meme ruined regular expressions forever
>>
>>52117956
gr8 observation m8
>>
>>52117947
I don't know, but I can find out
Give me an example bit of .json
>>
>>52117941
>writing code in non-English
>>
let's make an esoteric language based on chanspeak
>>
>>52117632
> unironically using eval
>>
>>52117970
no
>>
>>52117961
{
"x": [
"abc",
17
],
"y": [
"def",
"ghi"
]
}
>>
>>52117971
>suicide.py
>unironically
u wot m8?
>>
>>52117966
it's for my university's final project, I will redo it on english, upload the source code and put it in the applel store as an open source calculator.
>>
>>52117946
I'm so sorry lads, here it is cleaned up with fitting var names, without all the shitty remnants from failed bits:
import requests, time, HTMLParser
h=HTMLParser.HTMLParser()

oldlen=0

while 1:
dpt=requests.get("http://a.4cdn.org/g/thread/52117324.json").json()["posts"]
if len(dpt)>oldlen:
oldlen=len(dpt)
try:
lastpost=dpt[-1]["com"].replace("<br>","\n")
except:
print "post has no text\n"
continue

lastpost=h.unescape(lastpost)
inTags=False
noHTML=""

for i in lastpost:
if inTags==False and i=="<":
inTags=True
continue

if inTags==True:
if i==">": inTags=False
continue

noHTML=noHTML+i

print noHTML+"\n"
else:
time.sleep(10)
>>
>>52117977
for y it gives a string list
for x it gives an "IntOrString"
>>
>>52117941
Approximate the integral using Simpson's rule
>>
IntOrString appears to be a tuple
I messed around a bit and also got "NumbersOrString" and "NumbersOrBooleanOrString" by adding extra stuff
>>
>>52117997
IntOrString is like
type IntOrString =
Int of int list | String of string list

then?
To be honest that sounds like a lot more work than I want to do for now. I might just not allow for those to even exist in here cause I'm so lazy
>>
>>52118013
I think it's int * string, I'm not sure
It could just be storing the JSON string
>>
File: mems.jpg (21KB, 447x147px) Image search: [Google] [Yandex] [Bing]
mems.jpg
21KB, 447x147px
Now to remove sleep, update only on my own command, and query if I want to execute a post's code and where the code lines begin and end at
>>
def findpt():
threads = requests.get("https://a.4cdn.org/g/catalog.json").json()
for page in threads:
for thread in page["threads"]:
if "sub" in thread and "/dpt/" in thread["sub"]:
return "https://a.4cdn.org/g/thread/" + str(thread["no"]) + ".json"


>>52118031
here, make it more universal
>>
File: mark.jpg (14KB, 270x271px) Image search: [Google] [Yandex] [Bing]
mark.jpg
14KB, 270x271px
>T_PAAMAYIM_NEKUDOTAYIM
>>
>>52118041
Thanks a ton lad, I was dreading having to work more json, now I can meme in my sleep
>>
>>52118041
    pages = requests.get("https://a.4cdn.org/g/catalog.json").json()
for page in pages:

fixed
>>
trying to contribute to open source

all of the easy shit gets taken by indians
>>
>>52118061
contribute to 4chan meme parsers
>>
>>52118061
I fixed a couple typos in Swift. Job when?
>>
>>52118061
make a better game engine than unity
>>
>>52118031
don't remove sleep, you can get b& for sending more than 1 json request per second

and make it work with both eval and exec, eval doesn't work with things like print
>>
>>52117924
ask you retarded ? you generate the llvm ir code by yourself like any other frontend, it's the same as compiling into assembly.

http://llvm.org/docs/LangRef.html

you generate the llvm assembly to a text file then you compile with
llc foo.ll
>>
>>52117324
Any other anons think that the halting problem is BS?

How do we trust some faggot who didn't even own a computer to tell us what a computer can and can't do?

Tbh just write a sophisticated AI like google deep learning and you can eventually have a program that can decide whether another program will stop
>>
File: 1450770707376.png (289KB, 514x424px) Image search: [Google] [Yandex] [Bing]
1450770707376.png
289KB, 514x424px
>>52118100
>Non-CS fags
>>
>>52118091
>don't remove sleep
It's not going to update every while loop, just when I make an input, and if that input is in the form

"exec" int int


It executes my function to execute code in a 4chan post

Could you clarify on the eval and exec thing? Might I possibly eval on print if I import the python 3 function implementation?
>>
File: json type provider.png (16KB, 798x323px) Image search: [Google] [Yandex] [Bing]
json type provider.png
16KB, 798x323px
More shilling for this 3rd party F# Data library
>>
>>52117924
http://www.wilfred.me.uk/blog/2015/02/21/my-first-llvm-compiler/
>>
>>52118116
Nice argument

cant even begin to try and prove me wrong because you know im right

(y)(y)(y)(y)
>>
>>52118100
i think it's BS

it's possible to check whether a program would halt for a given input without having to actually run it. and it's possible to recognize/disallow contrived contradictions like the one in the proof. or just restate the problem so it's not just a binary yes/no answer, it's yes/no/undefined (the question is malformed).
>>
>>52118123
F# is shit
>>
>>52118128
Here's a nice video that gives you a simple explanation about it.
https://www.youtube.com/watch?v=macM_MtS_w4
>>
>>52118147
testing escape characters

"
\"
>>
>>52118165
didn't mean to quote
but nice, should have known from html parsing that it does it for you
>>
>>52118142
ok
>>
>>52118147
the "machine" has access to the source code. it can simply recognize itself.
>>
>>52118197
Holy fuck you're retarded.
>>
>>52118147
>linking to a video of the shittest thing ever made
>>
I'm getting more and more rustled when using Go.
For instance, const fields live in the package and not in the file itself. So code like this doesn't work:
// x.go
const foo = "bar"

type X struct {
val string
}

func NewX() {
return &X{foo}
}
// y.go
const foo = "baz"

type Y struct {
val string
}

func NewY() {
return &Y{foo}
}
>>
>>52118211
Yes, most computerphile videos are pretty shit, but there is the occasional one which is alright.
>>
>>52118208
>hey mr computer answer yes/no to this question but if you answer yes you must answer no and if you answer no you must answer yes
>oh you can't? checkmate atheists
>>
Am I doing something wrong or is the MSVC compiler absolutely broken with the new C++ shit?
>>
File: 2015-12-29_08-08-57.png (187KB, 1080x1888px) Image search: [Google] [Yandex] [Bing]
2015-12-29_08-08-57.png
187KB, 1080x1888px
>>52117324
MEMCHAN UPDATE:

Last thread compared to this thread so far.

TODO: filter out insignificant words like 'that'.
>>
Is JQuery a meme?
>>
What would be the best way to handle Raspberry Pi GPIO? Can I use two python libraries at the same time to handle the GPIO? RPIO has a beautiful PWM function that'll be perfect for the camera's servo, but no serial. WiringPi has serial, but the PWM will either eat the audio or the CPU. Any ideas? Can I use both without the rPi losing its shit and driving my robot off the stairs?
>>
File: xahOKYF.png (27KB, 794x501px) Image search: [Google] [Yandex] [Bing]
xahOKYF.png
27KB, 794x501px
>>52118330
Also, I think I'm just using lambdas at this point because I can.

Pic related simultaneously makes me giddy and horrified at the same time.
>>
File: umaruic.webm (1MB, 640x360px) Image search: [Google] [Yandex] [Bing]
umaruic.webm
1MB, 640x360px
Ask your beloved programming literate anything
>>
>>52118371
Is that the CoffeeScript meme?
>>
test

word="memecoding"

leng=len(word)

print "\n "+word[0]+" "*(leng-2)+word[::-1]

for i in range(leng-2):
print " "+word[i+1]+" "*(leng-2)+word[leng-i-2]

print " "+word[-1:0:-1]+word

for i in range(leng-2):
print " "*(leng)+word[i+1]+" "*(leng-2)+word[leng-i-2]

print " "+word+" "*(leng-2)+word[0]
>>
>>52118405
It's C#.

Lots of LINQ strung together to manipulate and pull data out of objects and flatten them out into control-bindable data.
>>
>>52118326
>>
File: mems.jpg (64KB, 671x713px) Image search: [Google] [Yandex] [Bing]
mems.jpg
64KB, 671x713px
>>52118419
We did it lads

We executed meme code from 4chan posts

Just try to out-meme me
>>
>>52118419
Let me guess, meme star?
>>
>>52118472
yep:
>>52118443
Just quickly typed to test memeparsing
>>
OK, I'm done with Go.
>cgo is slow
>bad bindings with C
>package scope const/var fields
>GDB isn't fully suported
Well meme'd Go, well meme'd. I've had fun while it lasted. I'll be switching back to C++ and maybe look into D or Rust if I feel like it.
>>
File: k4m4Wtu.png (97KB, 536x1875px) Image search: [Google] [Yandex] [Bing]
k4m4Wtu.png
97KB, 536x1875px
>/flt/'s top word is WIndows
>Linux threads
>>
>>52118486
let's see if I can execute my memeparsing code using my memeparser

import requests, time, HTMLParser, re
h=HTMLParser.HTMLParser()

oldlen=0
thread="52117324"

#execute a post's code, uses line index starting at 1
def execCode(post, startLine, endLine):
try:
post=post.split("\n")
post="\n".join(post[startLine-1:endLine+1-1])
exec(post)
print "\n"
except:
print "\nout of bounds start or end line, or invalid code"

while 1:
dpt=requests.get("http://a.4cdn.org/g/thread/"+thread+".json").json()["posts"]

if len(dpt)>oldlen:
oldlen=len(dpt)

try:
lastpost="["+str(dpt[-1]["no"])+"]\n"+dpt[-1]["com"].replace("<br>","\n")
except:
print "post has no text\n"
continue

lastpost=h.unescape(lastpost)
inTags=False
noHTML=""

for i in lastpost:
if inTags==False and i=="<":
inTags=True
continue

if inTags==True:
if i==">": inTags=False
continue

noHTML=noHTML+i

for c,i in enumerate(noHTML.split("\n")):
print str(c+1)+": "+i
print "\n"
#else:
# time.sleep(10)
print "continue or execute"
cont=raw_input()
a=re.match("exec (\d+) (\d+)",cont)
if a: a=a.groups(); execCode(noHTML,int(a[0]),int(a[1]))
>>
is there a reason most(?) languages don't allow line breaks in all string literals
>>
>>52118487
Oh, I nearly forgot
>no destructors
>>
>>52118522
didn't work, I think it's the exec inside

I'll see if I can change it
>>
File: file.png (125KB, 638x359px) Image search: [Google] [Yandex] [Bing]
file.png
125KB, 638x359px
Have you hear the word of our lord and saviour Steve Jobs and ObjectiveC and Swift the superior coding languages used in xcode?
If not, why don't you join the master race'
>>
>>52118525
Not sure what languages break. C# allows it.
>>
Hey /dpt/, what's the best code snippet repo out there?
>>
>>52118610
I feel like you're missing some critical information with this request.
>>
>>52118540
nope, nothing

it was good while it lasted
>>
File: i barely know python.png (25KB, 657x228px) Image search: [Google] [Yandex] [Bing]
i barely know python.png
25KB, 657x228px
>>52118595
like most of them except maybe php
>>
def swastext(s):
print ("\n".join([(s[0] + " " * (len(s)-2) + s[::-1]) if i == 0 else s[i] + " " * (len(s)-2) + s[::-1][i] if i < (len(s)-1) else s[::-1]+s[1:] if i == (len(s) - 1) else " " * (len(s)-1) + s[i-len(s)+1] + " " * (len(s)-2) + s[::-1][i-len(s)+1] if i < (2 * len(s) - 2) else (s[0] + " " * (len(s)-2) + s[::-1])[::-1] for i in range(2 * len(s)-1)]))

swastext("topkek")
>>
>>52118610
rosettacode
>>
>>52118674
fuck, sorry lad, it's not executing it

It's my code not reading anything after a <
>>
File: 1405824973395.jpg (5KB, 251x251px) Image search: [Google] [Yandex] [Bing]
1405824973395.jpg
5KB, 251x251px
>>52118622
I don't think so Tim.
>>
O C A M L
C
A
M
L
>>
>>52118730
parr alleli sm
alleli
sm
>>
>>52118730
test

def lt(a,b):
if a < b: print "It's less"
else: print "It isn't less"

a=2;b=3
lt(a,b)
a=3;b=2
lt(a,b)
>>
ok /g/ how the fuck do you do http://adventofcode.com/day/3

in haskell
>>
>>52118522
why aren't you using the /dpt/ autopilot?
>>
Recommend me some programming books, you autists.
>>
>>52118802
?

test again
def lt(a,b):
if a < b: print "It's less"
else: print "It isn't less"

a=2;b=3
lt(a,b)
a=3;b=2
lt(a,b)
>>
>>52118815
>>52118041
>>52118059
>>
What does /g/ think about dlang?
>>
>>1


Have they fixed quotes in code tags yet?
>>
>>52118815
Alright, I can now execute code as long as '<' has a space after it, I don't want to have to detect tags until I find something that can remove it for me. I reckon HTMLParser might help

>>52118823
Ah, I've saved the code already, but have been focusing on this particular functionality first
>>
>>52118826
meme
>>
>>52118835
No, copy this into custom CSS:
.prettyprint .deadlink {
text-decoration: none !important;
}
>>
>>52118826
breddy gud
>>
>>52118853
Yeah, I know about that, anon. I just wanted to see if they fixed it.
>>
>>-1
>>
Java
A
Shit
>>
final test, or I'm done

import requests, time, HTMLParser, re
h=HTMLParser.HTMLParser()

oldlen=0
thread="52117324"

#execute a post's code, uses line index starting at 1
def execCode(post, startLine, endLine):
try:
post=post.split("\n")
post="\n".join(post[startLine-1:endLine+1-1])
exec(post)
print "\n"
except:
print "\nout of bounds start or end line, or invalid code"

while 1:
dpt=requests.get("http://a.4cdn.org/g/thread/"+thread+".json").json()["posts"]

if len(dpt)>oldlen:
oldlen=len(dpt)

try:
lastpost="["+str(dpt[-1]["no"])+"]\n"+dpt[-1]["com"].replace("< "[0]+"br>","\n")
except:
print "post has no text\n"
continue

lastpost=h.unescape(lastpost)
inTags=False
noHTML=""

for c,i in enumerate(lastpost):
if inTags==False and i=="< "[0]:
if c< len(lastpost)-1 and lastpost[c+1]!=" ":
inTags=True
continue

if inTags==True:
if i==">": inTags=False
continue

noHTML=noHTML+i

for c,i in enumerate(noHTML.split("\n")):
print str(c+1)+": "+i
print "\n"
#else:
# time.sleep(10)
print "continue or execute"
cont=raw_input()
a=re.match("exec (\d+) (\d+)",cont)
if a: a=a.groups(); execCode(noHTML,int(a[0]),int(a[1]))
>>
>>52118925
Poo
In
Loo
>>
>>52118929
lmao it worked. I've successfuly run code that reads my code from 4chan and runs it again
>>
>>52118776
Jan ua ry 1
ua
1
>>
>>52118212
Consider a public constant that you can access from other packages, Foo. Would the value of this constant be "bar" or "baz"?
>>
>>52118525
i think it's because it makes it easier for the interpreter/compiler
>>
How can I improve this bash script? It's supposed to set the ID3 title tag for a bunch of mp3s with filenames matching the format "00 Title.mp3"

It works currently and I'm not trying to make it more general, but I'm new to bash and wondering what the best way is to parse the filename. Needing to assign $title twice seems unnecessary.

for i in *.mp3; do
title=${i#*\ }
title=${title%.mp3}
eyeD3 -t "$title" "$i"
done
>>
>>52119142
also it would be problematic if it had to clean up the carriage return and the leading whitespace on the next line, could be harder for the developers to read too
>>
Daily reminder that if your language of choice is not on this list you should probably give up and kill yourself:
- C++
- C#
- Lua
- Python
- Elixir
- Haskell
- Bash
- Clojure
- D
>>
>>52119168
>no ocaml
>no f#
I believe it is you who should consider killing yourself anon
>>
>>52117992
>if inTags==False
>if inTags==True
>>
>>52118989
It depends on the struct. Here's the shortened version of my actual code. Hopefully that makes more sense:
// tempo.go

const method = "default"

type Tempo struct {
Method string
}

func NewTempo() *Tempo {
return &Tempo{method}
}

// onset.go

const method = "hfc"

type Onset struct {
Method string
}

func NewOnset() *Onset {
return &Onset{method}
}

So to fix it, I can create a
onsetMethod
and
tempoMethod
, but that's just ugly. I don't want to prefix fields.
>>
>>52118123
I've always been very suspicious of how useful that json type provider is. I mean.. it's not type safe by definition almost. It just guesses the data schema based on a sample. It can't know for sure if there might be other fields and data types with other data. Something like the swagger type provider is much more robust.
>>
>>52119168
>no C
>Java instead of C#
>Lua
>Bah
>Elixir
>no Erlang
Fucking dropped
>>
>>52118512
Is this WPF? Looks pretty cool
>>
>>52117610
The one from Natsuyasumi. I can't remember the name
>>
>>52119168
Mine is Nemerle. Its macros are good enough to express all of them(C# is done already), itself included.
>>
File: What_am_i_reading.jpg (59KB, 526x300px) Image search: [Google] [Yandex] [Bing]
What_am_i_reading.jpg
59KB, 526x300px
>>52119362
>Java instead of C#
>>
File: fsharp.png (26KB, 741x515px) Image search: [Google] [Yandex] [Bing]
fsharp.png
26KB, 741x515px
I wish I were good enough at fp to know what to do with this
>>
>>52119168
Daily reminder that if your language(s) are at least 3 from this list you'll be poor forever
-Swift
-ObjectiveC
-C#
-Java
>>
>>52119376
Yes, using MahApps as a graphics library.

http://mahapps.com/
>>
>>52119406
neat. I never got around to understanding this shit either. But this example makes it seem a bit easier to me.
>>
>>52119409
I know all of those, and many more. I also have a good job, but I don't use any of those in it.
>>
>>52119406
holy shit F# is ugly

why not just use haskell?
>>
>>52119459
they're just computation expressions
>>
>>52119459
What's ugly about F#? Haskell is worse imo.
>>
>>52119451
>Knowing iOS "languages"
Where the fuck did you learn? Why there is zero fucking good resources for them? Why is apple so fucking anal about it?
>>
>>52119491
Buy a book on it. Best way to learn all languages imo. Search through amazon until you find one you think suits you.
>>
>>52119212
can I use meme as an excuse?
>>
>>52119511
Fuck.

Any recommendations then?

>>52119517
Meme is always a valid excuse.
T. Memepro.
>>
>each region allocated on the heap has a counter
>when you make a new global reference to that heap region, you increment the counter
>when you dereference a global pointer to that heap location, you decrement the counter
>when the counter equals zero, you automatically free the counter's heap region
>no garbage collector required
>no manual memory management required
I'll take my Turing Award right now.
>>
Daily reminder "if else" constructs are deprecated by pattern matching
>>
post languages you know at least well enough to write fizzbuzz in:

C
C++
C#
Java
Scala
Scheme
Common Lisp
Clojure
Racket
Haskell
Erlang
Python
Ruby
Bash
Javascript
Emacs Lisp
OCaml
Go
Rust
Perl5
Perl6
Pascal
>>
>>52119521
i got this one http://www.amazon.co.uk/gp/product/0596004230?keywords=objective%20c%20reference&qid=1451404472&ref_=sr_1_2&sr=8-2.

Seemed to be one of the few geared towards people who already know C. It's kinda old, but short and does the job.
>>
>>52119548
C++
Python
Java
>>
>>52119550
Are there really "programmers" that don't know C?
>>
>>52119570
Yeah programmers who aren't delusional elitists
>>
>>52119570
yes.
>>
>>52119406
Thats cause F# is a toy language for solving toy problems.
>>
>>52119548
Pascal
Lua
Ada
Python
>>
>>52119570
>tfw you don't
>>52119550
Was looking more for swift, but thanks anyways anon!
>>
What is the functional equivalent of inheritance?
>>
>>52119578
>>52119582
Wow that's pretty embarrassing.
>>
>>52119586
computational expression are crazy useful in F#.
>>
>>52119595
There's another book just like it for swift. But yeah, just check amazon. Check reviews and see what looks best to you. Swift probably has better books because they will be newer.
>>
>>52119539
>no pattern matching in python
>external pattern matching libraries make the code look verbose and shit
The only caveat imhol (in my honest opinion lads)
>>
>>52119604
not really. I'm sure plenty of them are better than you. Knowing C doesn't make you a good programmer.
>>
>>52119548
Rate my FizzBuzz


### Functions ###
range = $(if $(filter $1,$(lastword $3)),$3,$(call range,$1,$2,$3 $(words $3)))
make_range = $(foreach i,$(call range,$1),$(call range,$2))
equal = $(if $(filter-out $1,$2),,$1)


### Variables ###
limit := 101
numbers := $(wordlist 2,$(limit),$(call range,$(limit)))

threes := $(wordlist 2,$(limit),$(call make_range,$(limit),2))
fives := $(wordlist 2,$(limit),$(call make_range,$(limit),4))

fizzbuzz := $(foreach v,$(numbers),\
$(if $(and $(call equal,0,$(word $(v),$(threes))),$(call equal,0,$(word $(v),$(fives)))),FizzBuzz,\
$(if $(call equal,0,$(word $(v),$(threes))),Fizz,\
$(if $(call equal,0,$(word $(v),$(fives))),Buzz,$(v)))))


### Target ###
.PHONY: all
all: ; $(info $(fizzbuzz))
>>
>It's a "C is still useful and totally not deprecated, guys!" post
>>
>>52119639
>python
bahaha
>>
>>52119644
>Knowing C doesn't make you a good programmer.
True

Not knowing C makes it impossible to be a good programmer, though.
>>
>>52119639
>The only caveat
dynamic typing
>>
>>52119661
>>52119665
Is it meme hour already?
>>
>>52119600
I don't know because I use F# which has interfaces anyway
>>
>>52119661
okay grandad
>>
>>52119600
Monads
>>
>>52119675
daily meme thread
>>
>>52119665
>flexible type control
>only a hindrance if you can't into basic testing
>>
>>52119600
composition
>>
>>52119687
>grandad
There's a reason why ffmpeg is written in C, there's a reason why the Linux kernel is written in C. There's a reason why nginx is written in C. There's a reason why MySQL is written in C. There's a reason why all software JVM implementations are written in C.

The list goes on
>>
>>52119692
>runtime checks for something that should be static
>>
>>52119692
What's flexible about it? Types are still checked at run time. You just get told about type errors later instead of earlier. The end result it your program doesn't work.
>>
>>52119708
I don't doubt that anon.
>>
>>52119343
>It depends on the struct.
No, you don't understand what I was getting at.
File local constants cannot work because public constants can be accessed from other packages.
Your proposal would create two seperate constants with the same name; this is not how constants work. When accessing Foo from another package, which value would you get? baz, bar?
It's ambigious. The way they implemented it is correct, not the weird ambigious shit you proposed just so that you do not have to give your variables proper names.
>>
>>52119718
>>52119720
Still not a hindrance
>>
>>52119661
>>52119708
These. I haven't seen one good for something programmer that hasn't read K&R.
K&R is as obligatory as SICP.
>>
>>52119739
Proof that python breaks programmers beyond repair
>>
>>52119652
What language is this?
>>
>>52119538
but what about doubly linked lists?
>>
File: IMG_20151229_170619.jpg (2MB, 3264x2448px) Image search: [Google] [Yandex] [Bing]
IMG_20151229_170619.jpg
2MB, 3264x2448px
Trying to port my current arduino project to atmel chips with plain C.
First step: set everything up and then ill start programming attiny85 chips
>>
>>52119739
>having to spend more time debugging is not a hindrance
jesus anon
>>
>>52119736
I just want a constant within the scope of the struct, not the package.
>>
>>52119785
>more time debugging
implying implications

>>52119784
>Trying to port my current arduino project to atmel chips with plain C.
Why?

Doing
analogRead
is a hell of a lot easier than manually setting up the ADC for example.
>>
>>52119846
>Why?
Not sure. Just for the lulz. Maybe learning some stuff.
>>
>>52119846
>implying implications
more like just saying what should be already obvious to you if you aren't brain dead. If you don't get type errors until runtime, it takes longer to discover them and longer to fix them. I really shouldn't have to explain why.
>>
>>52119736
>File local constants cannot work because public constants can be accessed from other packages.
If they are file local they aren't public.
In any sane language these symbols are never visible outside of that file so there's no conflict to be had.
>>
Are you a javascript or a python programmer?
Do you feel like you don't fit in?
Congratulations! You're right!

>>>/trash/wdg
>>
>>52119785
>more time debugging
how people believe this is beyond me
>>
>>52119881
see
>>52119860
its really not that hard to understand.
>>
>>52118240
Which new C++ shit? Be specific.
>>
>>52119860
You have to be utterly retarded to believe that static typing automatically means that you don't have runtime errors.

I can assure you that I've spent a hell of a lot more time debugging runtime issues with C than I have with Python, and many of those errors has been because C is only sort-of strongly typed whereas C++ and Python are truly strongly typed (C++ statically strongly typed, Python is dynamically strongly typed).
>>
>>52119828
The struct's "definition" scope is the package or for anonymous structs whatever scope it was defined in, so even if you want a "constant within the scope of the struct", the problem I mentioned still applies.
What's so wrong about this?:
http://play.golang.org/p/OiL82g1yOf
>>
>>52118512
>tfw you misread that as /fit/
>>
>>52119893
See >>52119910
>>
>>52119910
>dynamically strongly typed
>>
Going through K&R right now. I spent 4 years doing a CS degree and some of the shit in this exercises wasn't even covered. Like I'm 99% sure most of my class wouldn't have been able to do program some of these.

Did I go to a meme-tier university or were old programmers just better back in the day?
>>
>>52119910
>You have to be utterly retarded to believe that static typing automatically means that you don't have runtime errors.
No shit sherlock. Nobody claimed that.

>I can assure you that I've spent a hell of a lot more time debugging runtime issues with C than I have with Python
If i did a lot of C I'm sure I would experience the same. C isn't shit because of static typing though, it's shit in spite of it. Try comparing to something closer to python like F#.
>>
>>52119867
Go has no concept of "file local" privacy, and I don't really see a pragmatic advantage in such either.
Maybe you could enlighten me with a use case where you actually need file local privacy and package-local privacy doesn't quite do it.
>>
>>52119933
Old programmers didn't have standard libraries that implemented everything
>>
>>52119893
Python is not as inflexible as whatever shit you're using. You won't get these type errors because you can pass around whatever (variables, functions, nonetypes, iterables, etc) and it gets accepts by whatever (keywords, function arguments, etc).

If you're talking about undefined behavior, that affects any language, and python is quick enough to run that the time difference is negligible when testing individual modules
>>
>>52119925
It is a thing

Dynamically typed: you don't need to declare a variable's type
Strongly typed: Types don't implicitly convert and mix-and-match, you need to explicitly combine them

If you don't know the difference between typing in Python and, for example, PHP or JS, then you need to educate yourself before trying to discuss type systems.
>>
>>52119917
It basically comes down to autism. I want my constants defined at the top of the file, not inside a function.
>>
>>52119956
>You won't get these type errors because you can pass around whatever (variables, functions, nonetypes, iterables, etc) and it gets accepts by whatever (keywords, function arguments, etc).
I guess you don't know python very well. If you pass a string to a function that expects a object, you will get a runtime error.
>>
>>52119978
There is absolutely no point in "dynamic static typing". None.

>type systems
>python
>>
>>52119985
It won't be a type error you fool, it'll tell you that the string doesn't have whatever functions you are trying to access. That is undefined implementation
>>
>>52118212
Well yeah, a constant is basically just a global (package-level) variable created from a constant expression. When package initialization happens, the init expression is ran, then const expression and then variable expressions (const and variable being moved to different sections in the binary, .bss and whatnot). So your two consts will be in the same package-level block (scope).

Thinking about packages in terms of files is an adventure into frustration -- as you're figuring out. The only difference in terms of files in a package are ones that denote build constraints (either in the file itself, or in its file name).

You can get around it, in your example, by just putting the const in the "ctors" and the compiler will move them to the right data sections.

From the language's point of view, files are only there to help group and organize things -- and cut down on rather long single-file packages. The compiler will generally concatenate all the files together (well, after it determines constraints) and places all the sections together.
>>
>>52119987
>dynamic static typing
is not a thing
>dynamic strong typing
is what the anon mentioned, and is very much a thing.

python is a dynamic strongly typed language. JS is a dynamic weakly typed language.

C# is a static and quite strongly typed language. F# is statically typed language, but is more strongly typed than C#.
>>
>>52119987
>There is absolutely no point in "dynamic static typing".
There is no such thing, I said dynamic strong.

And yes, there is definitively a point.

In PHP you would add a string and a number literal and get either a string or a number type back depending on the mood of the interpreter, whether or not Jupiter and Mars align and if you remembered to put on your right lucky sock.

In Python you would get a type error, because a number and a string aren't the same type of object.

Maybe you should educate yourself a little before trying to debate this stuff?
>>
>>52120017
At least you acknowledge that there's absolutely no point to it
>>
>>52119979
Then give them a proper name. TempoMethod isn't essentially a bad name.
I feel like this is better than introducing file-local privacy into the language just to get an extra level of context between packages and functions, which doesn't accomplish anything (atleast in regards to functionality and encapsulation) except for an extra scope.
>>
>>52120010
>it'll tell you that the string doesn't have whatever functions you are trying to access
no it won't, it will flip out that the string is not an object. Even if it was an object but was missing the expected fields, this would effectively be a typing error, and the kind that would be completely prevented in a statically typed language.
>>
>>52120028
The guy he replied to is the one bringing up this "dynamic static typing". If that's you, you're retarded
>>
Why are there python users in /dpt/?
I thought they all died with /wdg/.
>>
>>52120028
>At least you acknowledge that there's absolutely no point to it
There definitively is a point. You would rather have an error/exception and halt execution than to limp along and have no idea what is actually going on.

Much in the same way you would prefer a compile time error over a runtime error.
>>
>>52119949
The example that was just posted - having a bunch of constants common to multiple functions, but which aren't supposed to be publicly visible (think 'magic values' for things like cryptos, compression, etc).
I don't see a reason not to have it, why are non-public symbols even visible to other files? Just asking for name conflicts.
>>
>>52120017
It's pretty obvious that's what I meant.
>>
>>52120074
It's pretty obvious you should know what you're talking about before shitposting
>>
>>52120028
>>52119987
>>52119925


>ITT: People who don't know the difference between static vs dynamic and weak vs strong typing discussing the upsides and downsides of certain type systems

When did /g/ degenerate into this?
>>
>>52120084
>make an error in choice of word
>you know nothing
>>
>>52120099
>>52120099
>>52120099
>>52120099

NEW
>>
>>52120074
It's pretty obvious that you have no idea what you are talking about.

>>52120095
It's not only in the choice of word, anon. It's the whole "hurr durr there's absolutely no point in it" part.
>>
>>52120095
Your error was thinking you knew python
>>
File: 452.gif (705KB, 500x500px) Image search: [Google] [Yandex] [Bing]
452.gif
705KB, 500x500px
meme
>>
>>52120119
angry response to meme bait
>>
>>52120052
>but which aren't supposed to be publicly visible
Package private constants.

>why are non-public symbols even visible to other files
They aren't visible to other packages, which is certainly enough to fulfill the purpose of encapsulation.
There is no point in hiding symbols from each other in the same package.
Non-public symbols are either local to the scope or package private.
A package is a single unit - the API user uses it, the API developer provides it.
There is a point in the API developer hiding certain things from the API user, but there is no point in the API developer hiding things from himself.
>>
>>52120113
I never said I did. I don't want to know python.

I said there's absolutely no point in dynamic strong typing. There isn't.
>>
figured I should bite the bullet and learn htlm5 and javascript

what should I use to learn them?
>>
>>52120143
>I haven't tried thing
>therefore I know there's no point because of philosophies I shit out, but haven't explored
With that kind of narrow-minded mentality, you won't enjoy the world
>>
>>52120015
>>52120037
Both solutions aren't really satisfactory imo, but I guess I'll have to pick one of them. Prefixing sounds like the better solution since I can have my constants at the top of the file.
I wasn't aware of packages being folded together so to speak. Thanks for the explanation.
>>
>>52120146
Wrong thread.
>>
>>52120143
>I said there's absolutely no point in dynamic strong typing. There isn't.
See >>52120049

Stop embarrassing yourself already
>>
>>52119168
>mfw all of my languages of choice are on the list
>>
>>52120074
It's not. strong typing and static typing are utterly different concepts. Just to make this mistake you have to be pretty confused about what they are.
>>
File: COOL GUY.jpg (7KB, 258x211px) Image search: [Google] [Yandex] [Bing]
COOL GUY.jpg
7KB, 258x211px
>>52120181
my goddamn image didn't post
>>
>>52120167
Have you tried killing yourself?
No? Does that make you narrow minded?

>>52120178
>i said it so it's true
If you don't want that kind of error you should be using static types.
>>
>>52120206
>you can enjoy the world when you're dead
literally buttfuck retarded analogy
>>
>>52120221
>I haven't even tried it but I'm going to criticise it anyway
You're so fucking narrow minded
>>
>>52120143
dynamic typing is easier to write compilers for and a bit easier for newbies to learn. Strong typing means less bugs. It's pretty much always a good thing.
>>
>>52120206
>If you don't want that kind of error you should be using static types.
Static types doesn't prevent type errors, you dimwit. Strong typing does.

C is statically typed, but is barely strongly typed. You would still get a runtime error if you pass a floating point pointer to something that expects a integer pointer.
>>
>>52120236
>It's easier for newbies
you're right maybe there is a point
>>
>>52120232
>killing yourself is analogous to trying something when you're alive
How do you live being this retarded?
>>
>>52120206
>If you don't want that kind of error you should be using static types.
Then you end up with verbose garbage like Java...

No thank you.
>>
>>52120253
you can't kill yourself when your dead anon.
>>
>>52120243
Static strong types you muppet. Do you know what inference is?
>>
>>52120259
>implying that static typing is implicitly verbose

here's your (you)
>>
>>52120259
>thinks static typing means languages like Java
I laugh at these plebs.

Check out F# or ocaml anon. Pretty much as concise as python, but type safe.
>>
>>52120253
>being alive is better than being dead
You've never tried it.

For that matter, how do you even know you could kill yourself? You might be immortal.

Just more narrow mindedness.
>>
>>52120267
Exactly. So how can you report or relate with its enjoyment?
>>
>>52120272
>Do you know what inference is?
So now you're talking about type inference?

You do know that Python, being a strongly typed language, has type inference, whereas C a statically typed (and supposedly strongly typed) don't?

Type inference is a property of dynamic typing you fucking idiot.
>>
>>52120277
>>52120274
>backpedalling this hard
>>
File: kermit disgusted.jpg (22KB, 357x354px) Image search: [Google] [Yandex] [Bing]
kermit disgusted.jpg
22KB, 357x354px
>>52120300
I wasn't even involved in the discussion anon, all I saw was someone (you?) making some retarded assumption
>>
>>52120287
No, I'm not talking about type inference. I'm talking about human inference.

For that matter, statically and strongly typed languages can still have type inference, see ML, except that it's type safe and guaranteed to be type safe at compilation by any decent compiler.
>>
>>52120277
>F#
F# is (partially) dynamically typed through type inference anon.
>>
>>52120336
Type inference isn't dynamic typing.
>>
>>52120316
Type inference is literally a feature of dynamic strong typing.

See >>52120336

You are really embarrassing yourself.
>>
>>52120336
>F# is (partially) dynamically typed through type inference anon.
type inference is in no way dynamic typing. Learn your type theory.
>>
>>52120347
This
>>
>>52120347
But it is...

It's a feature of dynamic strong typing


vector<int> vec;
for (auto i : vec) { ... }
>>
>>52119872
>I'm an edgy autist that writes toy programs in C
>>
>>52120362
>>52120361
>>52120347
See >>52120378

You niggas need to learn the difference between weak vs strong and dynamic vs static styping.
>>
>>52120177
what, sqt?
>>
>>52120354
>Type inference is literally a feature of dynamic strong typing.
???
Dynamic typing means types are not determined at compile type. Static typing means types are determined at compile time.

Type inference just means types are determined at compile time without the need for annotations.

please read up on these concepts before bothering to discuss them.
>>
>>52120399
>Dynamic typing means types are not determined at compile type. Static typing means types are determined at compile time.
You are a fucking idiot.

Static types means that variables need to have a declared type. Dynamic types means that no such declaration is needed.

It doesn't matter if it happens at compile time or runtime. Python has type inference, yet isn't compiled aka it happens in runtime. C++ has type inference happening in compile time.
>>
>>52120378
There's nothing dynamic in that code. The compiler knows what the type of i is at compile time. That's what static typing is.

You could write
vector<int> vec;
for (Object i : vec) { ... }

and that would be pretty dynamic, since the compiler does not know what type i is (besides an object of course).
>>
>what is early binding
>what is late binding
>what is type tagging
>what is variable tagging

the dpt never changes, nor does it learn
>>
>>52120425
See >>52120422

But yeah, virtual types in C++ is an example of type inference in C++ that happens in runtime rather than compile time.
>>
>>52120422
No it's not.
https://en.wikipedia.org/wiki/Type_system#Static_type-checking

>Static types means that variables need to have a declared type.
>Python has type inference
Where are you getting this shit from? Source? Where did you read this shit? Python most certainly does not have type inference of any sort.
>>
If types are resolved at compile-time (and therefore, variables have a set type that cannot be changed while the program is running) the language is statically typed. If types are resolved at run-time (and therefore, a variable's type can change as the program runs) the language is dynamically typed.

It is perfectly possible to have a statically typed language with an intelligent compiler that figures out and assigns variable types at compile time without annotations. That doesn't make the language dynamically typed.

Jesus fucking christ how hard is this
>>
>>52120481
>Python most certainly does not have type inference of any sort
what
>>
>>52120481
Type checking and type inference is not the same thing (although related). Type inference eliminates the need for type checking.
>>
>>52120505
>If types are resolved at compile-time (and therefore, variables have a set type that cannot be changed while the program is running) the language is statically typed

By this logic Visual Basic would be a statically typed language.......

(On a side note, it supports static typing through declarations, but they are not necessary)
>>
>>52120505
>(and therefore, variables have a set type that cannot be changed while the program is running)
C is a statically typed language, but pointer types can change in runtime. Are you going to fucking argue that C is a dynamically typed language?
>>
>>52120584
Pointer types can't "change" at runtime. What are you talking about?
>>
>>52120546
wat

type inference relies on type checking. how can deduction happen without deduction .. happening?

do you even Hindley-Milner bro? what about System-F or STLC? or to be all modern CBPV?
>>
>>52120591
void foo(int* a)
{
*a = 4;
}

void bar(double* a)
{
*a = 5.0;
}

double a;

if (some_input) {
foo(&a);
}
else {
bar(&a);
}
>>
>>52120620
There aren't any pointer types changing at runtime.
Everything here is static.
>>
>>52120533
https://en.wikipedia.org/wiki/Type_inference
Type inference is a concept that only applies to statically typed languages. TypeScript adds static typing to normal JS by adding type inference.
>>
>>52120594
Checking is explicit.

Inference is implicit.

class A(object):
def foo(self):
print 2
class B(A):
def foo(self):
print 4

def bar(o):
o.foo() # type inference

def baz(o):
# type checking
if typeof(o) == A:
print 2
elif typeof(o) == B:
print 4
var1 = B()
var2 = A()

bar(var1)
bar(var2)
baz(var1)
baz(var2)
>>
>>52120568
>By this logic Visual Basic would be a statically typed language.......
It is you giant retard
>>
>>52120670
kk, educating myself

I thought python has an equivalent to C#'s 'var' keyword, in which I would assume that's type inference.
>>
>>52120671
that's not type inference, wtf.
>>
>>52119168
>no ocaml
>no ats
>unironically python
>unironically cuck#
>unironically hasklel and elixir
>>>/trash/
>>
>>52120108
thank you for not posting a trap thread
>>
>>52120868
why would you use ocaml over haskell? addicted to the oop meme?
>>
>>52121009
because built in support for imperative style is a good thing
>>
>>52121022
Educate yourself.
>The monadic approach to programming, in which actions are first class values, is itself interesting,
beautiful, and modular. In short, Haskell is the world’s finest imperative programming language.
http://research.microsoft.com/en-us/um/people/simonpj/papers/marktoberdorf/mark.pdf
>>
>>52119611
It's LITERALLY a monad. In other functional languages, you replace {...} by >>= (fun _ -> ...) and get literally the exact same result.
>>
>>52121116
>you replace {...} by >>= (fun _ -> ...)
You can do the latter in F# too. The former is just really useful.
>>
>>52121116
It's more than just a monad
>>
>>52121134
How the fuck is it ANY useful when it is LITERALLY IDENTICAL? You can't even argue that it's sugar because at this level it's literally the same thing.
>>
http://research.microsoft.com/pubs/217375/computation-zoo.pdf

Using such abstractions can be made simpler and more intuitive if we employ
a general syntactic machinery. F# computation expressions provide uniform syntax
that supports monoids, monads [23], monad transformers [11] and applicative
functors [14]. They reuse familiar syntax including loops and exception handling
– the laws of underlying abstractions guarantee that these constructs preserve
intuition about code. At the same time, the mechanism is adaptable and enables
appropriate syntax depending on the abstraction.
>>
>>52121146
>you replace {...} by >>= (fun _ -> ...)
>there is literally no syntactical difference
??
>>
>>52121009
The oo system in ocaml is both completely different to the simula-like garbage everyone's using, and also almost never used in practice because the module system is ridiculously powerful.
You'd use ocaml over haskell for multiple reasons:
- It's faster on average
- There are less libraries, but they're all of pretty good quality. The opposite is true with haskell
- There is native support for side-effect, which makes a lot of code clearer, easier to maintain, and faster
- The language is eager by default, with optional lazyness -- lazyness is a very important source of bugs in haskell programs as it makes reasoning about resource usage extremely difficult if possible at all
- The tooling for ocaml tends to be better and more mature (though haskell's isn't outright bad by any means)
- The module system. It can't be described in words, it's awe-inspiring and genius
- camlp4 and extension points
- etc.
>>
>>52121202
>this is what faggotsHarp believe
F#, not even once.
>>
>>52119548
Heir weego!
Python
Emacs Lisp
Perl
2-3 shell script langages
C
C++
Java // 90% sure
Lua
Perl6
TeX % So what ?
Haskell
OCaml
Racket
Scala
Ruby
Plan9 C /* Yes, this is a thing */
Go
Rust
Javascript
>>
Can someone please repost the roll coding "challenge"?
Got nuttin to do, thanks.
>>
>>52121218
>It's faster on average
Outdated belief. In terms of performance, haskell has caught up with OCaml and exceeded it.
>There are less libraries, but they're all of pretty good quality. The opposite is true with haskell
strongly disagree
>There is native support for side-effect
tell me what you consider a side effect and I'll show you how its natively supported in haskell. Unless you mean undeclared side effects, the lack thereof is one of the strongest features of haskell.
>- The language is eager by default
laziness is a lovely feature with great applications. I'm not sure why you fear it. Its trivial to you can force strictness- just adding seq.
>tooling
haskell has a debugger(ghci debugger), a profiler(ghc) an excellent documentation generation tool(haddock), and a standard build system(cabal and stack), great documentation search (hoogle). OCaml build systems usually are a mess of makefiles or autohell)
>The module system.
typeclasses
>>
>>52121459
My fucking sides!
Hasklelfags everyone!
>>
>>52121487
okie
>>
>>52121415
>>52121415
http://better-dpt-roll.github.io/

Also this thread is dead.
Thread replies: 381
Thread images: 38
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y / ] [Home]

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK