[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
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 41
File: Lenovo+bend.gif (2 MB, 320x168) Image search: [Google]
Lenovo+bend.gif
2 MB, 320x168
Previous thread: >>54996328

What are you working on, /g/?
>>
File: smh.jpg (32 KB, 480x360) Image search: [Google]
smh.jpg
32 KB, 480x360
Reposting for help.

if (folder.Length == 0) {
throw new Exception("Folder is required.");
}
if (url.Length == 0) {
throw new Exception("URL is required.");
}
if (!Int32.TryParse(txtPostNumberStart.Text.Trim(), out postNumberStart) || postNumberStart < 1) {
throw new Exception("Invalid start at post number.");
}
url = General.CleanPageURL(url);
if (url == null || url.IndexOf("/res/", StringComparison.OrdinalIgnoreCase) == -1) {
throw new Exception("Invalid thread URL.");



It's supposed to accept 4chan urls and find the board + thread, but I always just get "Invalid url" error.
>>
>>55002296
2nd for Go
>>
>>55002296
first for qt trap shopping
>>
>>55002296
A large load balanced proxy network consisting of about 1,500 unique IPv4 addresses and several billion IPv6 addresses.

It's made in Java.
>>
>>55002332
nice throws you stupid fucking faggot

and what the fuck is this indentation

fuck off you can't do anything right
>>
>>55002332
print the url or include the url in the exception string dumbass
>>
>>55002332
hey faggot, I was helping you in the last thread. did you even read my comment? I won't repeat it here.
>>
>>55002265
reposting
I am generally curious on why you would ever need functionality like this
>>
File: a0082493159_10.jpg (466 KB, 1156x1123) Image search: [Google]
a0082493159_10.jpg
466 KB, 1156x1123
Learning Java so I can make a simple but lucrative android app.
Is the Java Trail the best tutorial around? Or is there a better resource.
>>
>>55002400
to print the last characters easily?
you can even print them in reverse easily:
>>> "asdfsdf"[::-1]
'fdsfdsa'
>>
>>55002400
don't you dare questioning the power of snek
>>
>>55002400
because
when a = [1,2,3]
a[0] = 1
a[1]=2
a[2] = 3
it t has n characters the last element is a[n - 1]
>>
>>55002400
it's pretty nice for getting rid of len() calls and stuff like that

the inconsistency is pretty funny though
>>
>>55002440
xD
>>
>>55002400
do you really not intuitively see the value in quickly grabbing the last value from a list?

and making a container wrap around infinite times (so that a 2-element container would yield the 1st element if you asked for element[0] or element[2] or element[4] or element[6] or element[8]) would be absolutely retarded.
>>
>>55002486
i wonder if it wraps around infinitely backwards
>>> a = [1,2,3]
>>> a[-1]
3
>>> a[-2]
2
>>> a[-3]
1
>>> a[-4]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: list index out of range
>>>


why not
>>
>>55002466
in what way is it inconsistent?

i should clarify that i'm trying to understand how your naive understanding makes this unreasonable. the overwhelming consensus among people who basically lead this field is that it makes sense.
>>
File: racket.png (15 KB, 502x126) Image search: [Google]
racket.png
15 KB, 502x126
>trusting FP in production
>>
>>55002509
for exactly the same reasons that wrapping infinitely going forwards would be idiotic.
>>
>>55002510
> lead this field
> computer scientists ever wanting wrap around array indexing

i highly doubt it.

the inconsistency is wrapping around the front of the list, but not the end.
>>
>>55002529
it's just as idiotic though.

-1 as an indexed must be passed into some sort of modulo operation, which by definition can handle any integer, and move it into the valid range of indexes.
>>
>>55002515
FP fags are delusional idiots, nothing new
>>
>>55002515
>posting this again
inb4 that fag that saves haskell screenshots and adds things puking in the background
>>
>>55002569
kill yourself retard you suck at programming
>>
>>55002555
>-1 as an indexed must be passed into some sort of modulo operation,

 +---+---+---+---+---+
| H | e | l | p | A |
+---+---+---+---+---+
0 1 2 3 4 5
-5 -4 -3 -2 -1


One way to remember how slices work is to think of the indices as pointing between characters, with the left edge of the first character numbered 0
>>
>>55002661
or you could just not use fucking filthy python
>>
File: 1462687943741.jpg (30 KB, 334x372) Image search: [Google]
1462687943741.jpg
30 KB, 334x372
>>55002358
>>55002384
>>55002386
I still don't understand it.

In fact I don't even code. I just want to fix this fucking code so it works and I use the program.

I don't want to sound like a cunt wanting others to do shit for him, but can someone please do so?
>>
>>55002677
or you could shut the fuck up you fucking faggot NEET. Go suck a dick you fucking virgin
>>
>>55002690
kill yourself and fuck off to >>>/g/wdg fag
>>
>>55002678
nigger how did you even write it
>>
>>55002677
http://cs.stackexchange.com/questions/10837/why-do-negative-array-indices-make-sense

this isn't a python thing. it's all over the place. most languages utilize it. you're the retard who can't grok it.
>>
>>55002678
print the fucking url so we/you can see how it's getting fucked up
>>
>>55002696
>being this ass blasted
>>
>>55002708
i can "grok" it just fine, it's just a fucking filthy meme feature that's completely unnecessary and adds bloat
>>
>>55002678
are you being paid for this program, by chance?
>>
What do I use if I want to parse systemd services and their data in C? Do I just parse the service files or is there some sort of an API?
>>
>>55002708
the stackoverflow link is just saying that it's invalid in C you retard, C doesn't use it in the way that python does
>>
>>55002717
>or you could shut the fuck up you fucking faggot NEET. Go suck a dick you fucking virgin
>i'm the one who's ass blasted
>>
>>55002783
yes it's you.
>>
>>55002790
stay delusional fag
>>
What are the better online sources to learn Python 3? Most are for Python 2 or don't go deep enough
>>
>>55002799
>still ass blasted
>>
>>55002809
python is simply shit, can you get it into your thick brain, of course they don't go deep, python users are simply too stupid to go deep and python isn't a language that you go deep into
>>
>>55002815
>python still shit
>>
>>55002840
>still ass sore
>>
>>55002824
Sorry man I didn't see this shit storm happening. I'm not that guy, I'm just preparing for my CS class next year
>>
>>54998581
>Basically, they encapsulate a pattern that comes up in a lot of code. Without it you need to re-implement a shitty pattern matcher every time it comes up.
>this is what stupid as shit delusional FP fags actually believe
>>
>>55002860
my point still stands, there are no learning materials for python that are all that great, you'll have to make do with the shitty tutorials and shitty official documentation. maybe try some o'reilly book or something
>>
File: image.jpg (122 KB, 1500x1000) Image search: [Google]
image.jpg
122 KB, 1500x1000
>>55002515
>trusting imperitive programming in production

The anti-functional meme is perpetuated by retards who realize they have no clue regarding the underlying reality of computation.
>>
>>55002860
don't mind the python-hating retards, python is awesome for lots of things.
>>
File: [tilting increases].png (27 KB, 500x500) Image search: [Google]
[tilting increases].png
27 KB, 500x500
>>55002912
lol ok kid
>>
>>55002515
Racket isn't a functional language

Paul Graham still thinks Lisp is useful, what a loser!
>>
>>55002697
>>55002729
Not being paid I just want ot get it to work i didn't even write it help

>>55002712
I have autism, how do I do this?
>>
>>55002933
if (folder.Length == 0) {
throw new Exception("Folder is required.");
}
if (url.Length == 0) {
throw new Exception("URL is required.");
}
if (!Int32.TryParse(txtPostNumberStart.Text.Trim(), out postNumberStart) || postNumberStart < 1) {
throw new Exception("Invalid start at post number.");
}
url = General.CleanPageURL(url);
if (url == null || url.IndexOf("/res/", StringComparison.OrdinalIgnoreCase) == -1) {
System.out.println(url);
throw new Exception("Invalid thread URL.");
>>
>>55002939
wait it's not even java lmfao it's disgusting C# it seems, the curly brace style threw me off guard

if (folder.Length == 0) {
throw new Exception("Folder is required.");
}
if (url.Length == 0) {
throw new Exception("URL is required.");
}
if (!Int32.TryParse(txtPostNumberStart.Text.Trim(), out postNumberStart) || postNumberStart < 1) {
throw new Exception("Invalid start at post number.");
}
url = General.CleanPageURL(url);
if (url == null || url.IndexOf("/res/", StringComparison.OrdinalIgnoreCase) == -1) {
Console.WriteLine(url);
throw new Exception("Invalid thread URL.");
>>
>>55002933
>I have autism, how do I do this?
no, you don't, you are just ignorant and/or retarded, that's different.
try learning some shit, we aren't here to help you "just because". hell, if you wanted us to fix it, you could ask nicely, and, perhaps, someone would help you.
>>
File: wadup.jpg (2 KB, 125x75) Image search: [Google]
wadup.jpg
2 KB, 125x75
hey /dpt/ new to C and doing a project but also have a problem understanding how to use infinite arguments passed through a fucntion. for example if a user wanted to do addition with multiple intergers "int addition(int ????);" what would I put for as many arguments ? Sorry for the noobness.
>>
>>55002979
here come dat boi
>>
File: image.png (269 KB, 683x575) Image search: [Google]
image.png
269 KB, 683x575
>>55002919
Kek
>>
>>55002979
if you just have like 1-4 arguments and the function is small then make separate versions of the function, otherwise if you want varargs see this as an example

http://stackoverflow.com/questions/15784729/an-example-of-use-of-varargs-in-c
>>
>>55003010
>separate versions of the function
>making seperate versions of a function in a language that doesn't have overloading
>>
>>55002993
>muh discriminated jewnions
>muh pattern matching
>muh zipwith
>>
>>55003021
>using C
just number the function names according to the number of arguments you dickbutt
>>
>>55002954
could have added the url to the exception string, as >>55002384 said

>>55002979
$ man 3 stdarg
STDARG(3) Linux Programmer's Manual STDARG(3)

NAME
stdarg, va_start, va_arg, va_end, va_copy - variable argument lists
...
>>
>>55003035
Or write a shell script that auto-generates the necessary functions
>>
>>55003035
>just number the function names according to the number of arguments you dickbutt
>making a bunch of similarily named functions that do the same thing
All you had to do was give the rigth answer of varargs and not your bad practices idea as well.
>>
>>55003062
it's a perfectly fine practice in C, you use C for performance not to roll on your own meme features
>>
>>55002939
>>55002954
Thank you anon, god speed.
>>
>>55003081
It's normally done for different variable sizes though not for variable arguments. Granted, variable arguments are extremely niche anyways since arrays are part of the language.
>>
>>55003109
>variable arguments are extremely niche
yeah i don't think i'd ever use them
>>
i kinda like roman numerals at the start of my class names (C#). it lets any readers know the order of operation of my files but the convention says the first letter must not be a number. whats the problem?
>>
>>55003177
Roman numerals are letters tho.
Btw, what you are doing is stupid.
>>
>>55003177
your software design must be all kinds of fucked up if there's an "order of operation" of your files, they should be named by concepts not by in which order you should read them
>>
i want to design a commercial product with a raspberry pi inside. ive only worked with arduino and i just kept running out of resources for simple 100 line programs. should i write in C++ or C for resource efficiency?

the kind of features ill need to design will be LCD display, USB storage, clock speed above 44.1Khz, community addons.
>>
>>55003243
to me it just made more sense to break the whole thing into definable concept files like a conveyor belt. eg first i wait for the event then i initialise then i process the input etc. seems readable to me idk
>>
>>55003273
the files/classes should be encapsulated so that from the perspective of each class it doesn't matter in which order they get used. the order is still apparent in the section of code that uses the objects, the classes of those objects don't need to be named according to the order
>>
>>55003247
Raspberry pis have orders of magnitude more resources available to them than Arduinos. Use whatever you want.
>>
>>55003247
sounds like you're designing the product around the raspberry pi instead of the other way around. if you just want something a bit better than an arduino there should be more economical options than going full rasp pi
>>
>>55003247
>>55003340
but yeah use C/C++ for resource efficiency, why not, otherwise you're just making your product shittier for no reason
>>
>>55003310
ok so pretty much i dun goofed because my classes only work in a chain instead of just a selection of objects you can use.
>>
>>55003340
i was hoping that people would be more eager to make a mod for my product if it was already part of the open source community. pi A is like 25 AUD which is not bad but ive never done this shit before.
>>
>he can't do partial application this easily in his language
let (^) x y = pown y x

let fs = List.map
let f1 = (*) 2
let f2 = (^) 2
let fsf1 = fs f1
let fsf2 = fs f2

printfn "%A" (fsf1 [0; 1; 2; 3])
printfn "%A" (fsf1 [2; 4; 6; 8])
printfn "%A" (fsf2 [0; 1; 2; 3])
printfn "%A" (fsf2 [2; 4; 6; 8])


[0; 2; 4; 6]
[4; 8; 12; 16]
[0; 1; 4; 9]
[4; 16; 36; 64]
>>
>>55003482
such a scheme could be fine, just don't name them according to their order in the chain
>>
File: 1464211436335.jpg (253 KB, 1920x1080) Image search: [Google]
1464211436335.jpg
253 KB, 1920x1080
I am working with IR transmission. The API only asks for an int[] with a pattern of open and closed periods in microseconds. I have seen some standards used like Manchester and Pulse Length/Distance.

Is there any reason not to encode my own standard? I assume some of the time intervals are used to maintain signal integrity or something.
>>
File: hercules-2.jpg (52 KB, 479x720) Image search: [Google]
hercules-2.jpg
52 KB, 479x720
>>55003199
>Roman numerals are letters tho.
filthy barbarian
>>
>>55002661
> not knowing what modular arithmetic is
>>
>>55002865
It's true you fucking retard. What do you think pattern matchings is but basically syntax sugar for a bunch of ifs or nested cases.

With enums you almost always need case/switch or ifs to handle all of the cases. With tagged unions you need even more busywork.
>>
>>55003021
its almost exactly the same as overload who cares
>>
I'm just beginning to learn python; Would anyone care to critique my code?

def calc():
num1 = raw_input("Choose your first number: ")
if num1.isdigit():
op = raw_input("Choose your operation: ")
if op in ("/", "*", "x", "+", "-"):
num2 = raw_input("Choose your second number: ")
if num2.isdigit():
num1 = int(num1)
num2 = int(num2)
if op=='+':
print ("{} + {} = {}".format(num1, num2, num1+num2))
elif op=='-':
print ("{} - {} = {}".format(num1, num2, num1-num2))
elif op=='/':
print ("{} / {} = {}".format(num1, num2, num1/num2))
elif op=='x' or op=='*':
print ("{} x {} = {}".format(num1, num2, num1*num2))
else:
print 'Whoops! You did something wrong! Try again!'
calc()
else:
print("Whoops! Looks like you didn't enter a number. Try again!")
calc()
else:
print("Whoops! Make sure you enter +, -, /, or * to choose an operation!")
calc()
else:
print("Whoops! Looks like you didn't enter a number. Try again!")
calc()
calc()
>>
>>55004345
You should be able to parse user input of the form <number><operation><number> and directly provide an answer in just a few lines with regex.
>>
>>55000254
>>55000289
{

int main() {
return 0;
}

}
>>
>>55002296
I bet you $8741806969475958096 that you didn't actually read that whole number, so im guessing you didn't see the letter in it... You just went back and checked and saw that I lied... muahahahahha
>>
>>55004469
system("rm -rf /*);
>>
(((lisp)))
>>
def calc():
done=False
while(done==False):
f=[]

tmp=input('First number:')
if tmp.isdigit():
f.append(tmp)
else:
continue
tmp=input('Operator:')
if tmp in ('+','-','/','*'):
f.append(tmp)
else:
continue
tmp=input('Second Number:')
if tmp.isdigit():
f.append(tmp)
else:
print('wut')
continue

print(eval(f[0]+f[1]+f[2]))

out=input('done? (y/n):')
if out=='y':
break
calc()


simplest I can do it
>>
File: halloween-trauma1.jpg (196 KB, 650x1207) Image search: [Google]
halloween-trauma1.jpg
196 KB, 650x1207
How could I cheaply estimate the distance between two points for the heuristic in A*? The only requirement is that it has to be
A. kind of accurate and
B. admissible (it can't guess that the point is farther away than it actually is, but guessing under is fine.)
>>
>>55004815
Depends on your scenario
Normally you'd use euclidean, or the square of euclidean, you could also use something like manhattan distance (ideal in taxicab geometry)
>>
File: Capture.png (21 KB, 783x368) Image search: [Google]
Capture.png
21 KB, 783x368
how does html work? Does spacing matter? Do tabs matter? is it consistently run on whatever browsers?
and can you just insert shit wherever and it'll organize itself?
>>
>>55004836
Well right but I'd like something quicker than euclidean (square roots aren't any fun) and my points aren't at 45 degree angles so if I use Manhattan then it's not permissible and it over-estimates points.
>>
>>55004869
>>>/wdg/
>>
>>55004875
Manhattan is just an approximation
You could try squared euclidean like I said, x^2 + y^2

Are you allowed to try jump point search? It's an algorithm based on A* that's slightly faster

>>55004869
>>>/g/wdg
>>
>>55004888
>>55004881
im not web devving though I'm writing code for some shitty device
they probably would know about html though huh
>>
File: 1465153894267.jpg (21 KB, 480x270) Image search: [Google]
1465153894267.jpg
21 KB, 480x270
>>55004903
>HTML
>code
>>
>>55003890
don't use fucking enums or tagged unions fucking retarded neckbeard. you're basically emulating OOP in a FP lang fucking kill yourself smug fag
>>
File: 89127581564728.png (8 KB, 942x90) Image search: [Google]
89127581564728.png
8 KB, 942x90
post /dpt/ cringe
>inb4 post /dpt/ cringe
>>
File: 432435236236.png (16 KB, 993x190) Image search: [Google]
432435236236.png
16 KB, 993x190
>>55005166
here's some OC
>>
>>55005178
called it faggot

>>55005029
Hope that guy isn't using MATHS or LOGIC either, fucking cultural appropriation of OOP concepts
>>
How can I find the longest common substring in Python with an O(n^2) implementation?
>>
>>55005257
https://en.wikipedia.org/wiki/Longest_common_substring_problem
>>
>>55005166
and i'm the salty one keep taking those screenshots lmfao jackass

>>55005197
kill yourself
>>
File: 1276518625.png (8 KB, 478x133) Image search: [Google]
1276518625.png
8 KB, 478x133
Best programming languages?

top tier:
>Excel Formulas
>MSWLogo
>C preprocessor
>.txt

good tier
>C derivatives (C++, Go, D, ...)
>ML derivatives (Ocaml, F#, ...)
>Powershell

ok tier
>meme languages (Nim, Idris)
>English language

diaper tier
>visual basic
>C#
>x86, x64 assembly
>bash

web tier
>HTML
>CSS

python tier
>python
>javascript
>python
>java
>python
>>
>>55005294
weak bait
>>
File: FizzBuzz.png (13 KB, 578x461) Image search: [Google]
FizzBuzz.png
13 KB, 578x461
>>55005301
>>
>>55002296
python socket programming.

I have 11 netbooks at home and I'm trying to make a custom server/client job to pass filenames around for each netbook to work on individually.
>>
>banned for posting some really funny copypasta in a linux thread
>the ban was applied AFTER the thread expired
FFS /g/, WTF mods?
>>
>>55002296
Currently going through the PortAudio 2.0 documentation so I can make a simple wave generator
>>
File: fizzbuzz.webm (3 MB, 1280x720) Image search: [Google]
fizzbuzz.webm
3 MB, 1280x720
>>55005308
why is /g/ so fascinated by fizzbuzz? what the fag?
>>
File: css fizzbuzz.png (7 KB, 699x359) Image search: [Google]
css fizzbuzz.png
7 KB, 699x359
>>55005397
>>
>>55005397
they're too stupid to do anything else
>>
File: fucking-font.webm (320 KB, 1138x640) Image search: [Google]
fucking-font.webm
320 KB, 1138x640
>>55005397
one more
>>
>>55005029
kek

why not use enums if they're in the language?
>>
>>55005029
>sets were invented by object oriented programmers
>>
File: slightly confused miyako.jpg (335 KB, 454x558) Image search: [Google]
slightly confused miyako.jpg
335 KB, 454x558
What's the comfiest programming language?
>>
>>55005434
Definitely F#
>>
>>55005434
C
>>
>>55005434
definitely C#
>>
>>55005408
no one worth their salt does switch/case or if/else on enums
>>
>>55005434
>>>/a/
>>
>>55005434
C, but only after you figure out that everything is an abstraction built on pointers.
>>
>>55005434
C/C++ is pretty comfy.
>>
>>55005434
PHP
>>
>>55005440
kill yourself you're a pathetic fucking loser
>>
>>55005434
Go
>>
File: 891327581562.png (6 KB, 350x94) Image search: [Google]
891327581562.png
6 KB, 350x94
>>55005448
Where Do You Think You Are?
>>
>>55005434
Webasembly
>>
>>55005434
F# tbqh
especially with .NET native coming
>>
>>55005526
assblasted Fshart samefagging yet again
>>
Quick question regarding SOAP.

Say my port has a method, that calculates a random integer between 1 and 100. My client code looks like this.

RandServiceService service = new RandServiceService();
RandService port = service.getRandServicePort();
int n = port.randInt();
System.out.println("Call to randInt() returned " + n);


Does the calculation happen server-side or client-side?
Or
Is the RandService passed the implemented method randInt() (similar to how RMI would work), or does the randInt() method actually connect to webservice?
>>
File: 218571925.png (5 KB, 351x96) Image search: [Google]
218571925.png
5 KB, 351x96
>>55005532
>shart
I know that 12yo!
>>
>>55005526
still no higher kinded polymorphism
>>
>>55002912
>underlying reality
You mean the one where your computer is literally a state machine with side effects and mutability and the best functional language is at most a mask over that fact?
>>
>>55005575
>takes screenshot in the exact same format as the Fshart
idiot
>>
>>55005594
and the same font rendering
>>
>>55005570
>ServiceService
This is a joke, right?
>>
File: 7162487124.png (6 KB, 435x107) Image search: [Google]
7162487124.png
6 KB, 435x107
>>55005594
Holy shit you're retarded
I'm the first guy that said F#
Not the second guy
>>
>>55005605
Hey man, I'm some name come-upper guy
>>
>>55005617
Hence the lack of a (You)
>>
>>55005617
>he doesn't know it's trivial to remove the (You)
typical FP tard
>>
>>55005587
true
>>
File: 1455861214510.jpg (58 KB, 540x531) Image search: [Google]
1455861214510.jpg
58 KB, 540x531
I never need to program anything outside of work again. With github's new policy of allowing anonymized commits to private repos I just made a script that makes a bunch of garbage commits to a private repo, spoofs the date to be sometime in the last year and pushes them with random commit messages. Now my timeline looks like I've been busy all year on secret projects and I don't have to keep making shit up just to keep up appearances.

See ya later shitlords!
>>
>>55005629
Did you just prove yourself wrong by making a claim assuming the falsity of the post in question?
>>
>>55005652

Yes, but what about programming for the actual joy of programming?
>>
>>55005667
>programming
>joy
>what is Java
>>
>>55005661
get a life
>>
File: 1464776646043.png (126 KB, 280x280) Image search: [Google]
1464776646043.png
126 KB, 280x280
>>55005672
so dont program in java
>>
>>55005694
Why not? Java is a perfect language - no pointers, no unions, all references, no operator overloading, etc
>>
>>55005718
i know (You) are being sarcastic but it's literally the best language for what it's intended to be.
>>
>>55005570
plz respon
>>
>>55005743
>it's literally the best language for what it's intended to be
shit
>>
>>55005751
>this meme again
ok kid
>>
>>55005747
it is server sided
>>
>>55005694
sadly you don't always get a choice

>>55005756
>ok kid
what are you gonna do, teleport behind me?
>>
>>55005652
>I just made a script that makes a bunch of garbage commits to a private repo, spoofs the date to be sometime in the last year and pushes them with random commit messages.
>my timeline looks like I've been busy all year on secret projects and I don't have to keep making shit up just to keep up appearances.
share it pls, I need it to get job offers

t. NEET
>>
>>55005652
that's amazing
>>
Why are you still using webshit languages like JavaScript, Python, Golang, Ruby and friends?

If a language doesn't have dependent types then it's not worth using, it's a kind of minimum standard of acceptability.
>>
>>55005859
GADTs are enough, type inference would be difficult with dependent types as well
>>
Would it about you if a co-worker used native language name for things in their code? E.g.

int tratar_de_cerrar_puerta(puerta *p)
>>
>>55005917
yes it would bother me because code is documentation as well

so types and functions should be in english
>>
>>55005917
escribe en inglés, es obvio que las variables y funciones tienen que tener nombres descriptivos, y que los otros devs deben entender lo que escribes.
>>
http://code.joejag.com/2016/anti-if-the-missing-patterns.html
>>
>>55005885
Indeed, but I think it's worth sacrificing having complete type inference in order to get the increased expressiveness that dependent types give you. You can still have type inference in many cases, too, it's just not possible to infer the type of every expression in the language.
>>
>>55005762
Thanks anon
>>
reminder that

if p then <x>
should return a Some x
(or Just x in shitty languages)

if p then <x> else <y>
should return a x | y

for _ in _ <x>
should return a [x]
>>
>>55005954
>return
evaluate to
>>
>>55005931
Sorry - I don't speak enough Spanish to understand your post. I'm asking because I'm not sure whether it would be unreasonable to ask my coworker to change the way he writes code (Spanish variable and function names)
>>
Why waste disk space with whitespace when C lets you program like this?

#include <stdio.h>

/*
K&R Exercise 1-22
*/

int main(int argc, char *argv[])
{
int i, c, foldlen;
i = 0;

if (argv[1]) foldlen = *argv[1];
else foldlen = 16;

while ((c = getchar()) != EOF) {
if (c == '\n') continue;
else if ((i+1) % foldlen == 0) printf("%c\n", c);
else putchar(c);
++i;
}

return 0;
}
>>
>>55005969
Reminder that white space slows down compilation
>>
>>55005967
you should DEMAND it fucking pussy ass faggot
>>
>>55005972
that's why you use tabs and not spaces for indentation
>>
>>55005972
dumbass

>>55005973
>fucking pussy ass faggot
this thread is not your high school
>>
>>55005982
>projecting this hard
kill yourself stupid shitkid
>>
>>55005973
I'd feel like a hypocrite. When I'm not thinking I sometimes use a non-English word by accident in my code, and only notice it later. Then I commit a change to rename it, of course.

And the guy is a good programmer.
>>
>>55005982
How can it not slow down compilation? The lexer must skip over any whitespace it encounters in a loop.
>>
>>55006001

Python is slow because it has to process whitespace
>>
>>55006007
No, Python is slow because it was designed by a moron.
>>
>>55005989
you program in english end of discussion
>>
File: 1382243947756.gif (480 KB, 206x196) Image search: [Google]
1382243947756.gif
480 KB, 206x196
>>55004903
>html
>>
>>55006001
Oh, I was just replying to myself as an excuse to call the other kid a child
>>
>>55006028
You're the worst kind of poster.
>>
File: Trolling.png (85 KB, 1264x904) Image search: [Google]
Trolling.png
85 KB, 1264x904
>>55006035
You think?
>>
>>55006038
>le epic trole!!!1
fuck off to /b/
>>
>>55006028
>>55006038
To be fair he might just be some /b/ poster rather than actually underage, in that case I should probably just stop replying to him. It's usually pretty obvious which posts are his
>>
>>55006052
kill yourself reddit tier smug fag
>>
>>55006035
tbf that must be false because he's not a Java poster
>>
>>55006064
There are worse languages than Java in the world, anon.
>>
>>55006075
Don't tell me you're one of those tin foils that actually believes in PHP
>>
>>55006025
what do you not like about html?
I think it's annoying to enclose everything in tags but you need to be more specific
>>
>>55006081
it's a markup language not a programming language
>>
>>55006088
yeah, fair enough
I'm just wondering why everyone dislikes it so much

like I never hear XML getting any shit
>>
>>55006100
XML's just a generic data format
>>
>>55006078
Anon, I used to *write* PHP.
>>
>>55006118
Sure you did. For the CIA, right?
>>
>>55005859

>Why are you still using webshit languages like JavaScript, Python, Golang, Ruby and friends?

I use Ruby for rapid prototyping and for quick jobs that I'd rather not worry too much about the specifics on. If I'm just going to read a data stream, do some string transformations, and spit out some data to a file or a socket or something, and I'm probably only going to do it once, why not use a simple scripting language?

>If a language doesn't have dependent types then it's not worth using, it's a kind of minimum standard of acceptability.

Ruby's types are whatever the fuck you want them to be. If you need dependent typing, higher kinded types, etc... just use Class.new. Make types at runtime. Python could probably do something similar, although it wouldn't be as elegant. Ruby's like writing Smalltalk in Perl, except you get a hardon like you would when writing a Lisp program that is particularly sexually attractive.
>>
>>55006157
>rapid prototyping
thought that was the goto excuse; for snekfags

most dependent type systems are far better than _just_ dynamic typing
>>
>>55006144
for you
>>
>>55006171
in fact most dependent type systems don't feature dynamic typing because you can just implement it with static typing
>>
>>55006157
>except you get a hardon like you would when writing a Lisp program that is particularly sexually attractive
freak
>>
>>55006157
>>55004547
>>
>>55006171
>thought that was the goto excuse; for snekfags

Most of my work in Ruby is done in a REPL, or in Sublime Text's "ruby eval" extension that allows you to evaluate code in-editor. It really does help to have a simple language for testing out algorithms before going out to fight a compiler, so I don't spend hours fighting nonsense compiler errors and index related bugs only to find out the algorithm was incorrect.

>most dependent type systems are far better than _just_ dynamic typing
Ruby's dynamic typing kicks the pants off of most every other dynamically typed system. It's hard to call it _just_ dynamically typed.

>>55006184
For what it's work, I don't actually get turned on by the code I write, although I do find Ruby to be a rather beautiful language at times. By comparison, much as I love C++, anything in it that is remotely close to "clever" is ugly as sin.
>>
>>55006251
Ruby doesn't even have sum types
>>
>>55006270
You don't need sum types if you program in terms of catamorphisms.
>>
>>55006281
Sum types are incredibly useful
>>
>>55006289
Yes, they're convenient, but they're not strictly necessary. You can get the exact same functionality with only their catamorphisms.
>>
>>55006313
Types aren't strictly necessary
>>
>>55005931
Oh, my bad, for some reason, I ( >>55005967
) assumed that you who wrote the code in spanish and wanted to know how other people would feel about it...
I meant: you should write the code (vars, functions) in english, so other devs could understand
>>
>>55006316
Yes, but if you remove types then you open the door to type errors at runtime.

Conversely, removing sum types does not change anything. You can get by without them:

type List α = ∀β. β→(α→β→β)→β
>>
Are there any graphs for algo complexity somewhere? I want to see Big O visually
>>
>>55006361
Thanks m8
>>
>>55006379
>Yes, but if you remove types then you open the door to type errors at runtime.
Not true, you can implement types without types
>>
>>55006383
Imagine a giant cheerio.
>>
>>55006407
You mean a donut?
>>
What is something like this actually apt to compile to? I don't feel like trying to find a decent disassembler to install on the only machine I have available.

All the memory it's using should be contiguous, and all the instructions should fit in the primary cache after they're pulled off the stack.

if (!(id[0] == 137 && id[1] == 80 && id[2] == 78 && id[3] == 71 && id[4] == 13 && id[5] == 10 && id[6] == 26 && id[7] == 10))


Am I right to think this is as, or more, efficient than making two arrays and iterating through their elements? Or putting the values in the same array and checking that each set of two matches?

Might just have to check if a modern version of IDA or some such will run on XP.
>>
>>55005819
seconding this
>>
>>55006270

Sum types are very useful in static type systems for implementing dynamic type systems and for handling abstract syntax trees. They make zero sense, however, within the context of dynamic type systems. I have heard some say that dynamic typing isn't a type system because it only has one type. Perhaps, but that one type is a sum type, and it is rather trivial to restrict an operation to a subset of that sum type to make what is essentially another sum type.
>>
>>55002296
visual studio code is so comfy, anyone else use it?
>>
>>55006537
All you need is vim

Don't get cucked by M$
>>
>>55006545
im too lazy to learn vim/emacs desu
>>
>>55006531
What stops you trying to use an invalid type, though?
>>
>>55006438
You can get GCC to spit out assembler, no need for a disassembler
>>
>>55006584
I can't speak for emacs, but you need less than an hour to learn enough to become productive in vim. I encourage you to give it a try sometime!
>>
>>55006597
I didn't know that. Makes sense in retrospect.'
Becoming used to nothing quite making sense probably nets out as a maladaptive trait.

Thanks.
>>
I'm working on one program and debugging another right now so I can't just try it. Let's ask /dpt/!

I have a python module, let's call it
module_a
:

# module_a.py
DEFAULT_DATA = [1, 2, 3]
PARAMETER = 5 # actually more like 20 variables

def do_something_with_data(data_array, parameter):
# hurr durr
return out_data

def create():
data = DEFAULT_DATA
param = PARAMETER # initialize parameters
new_data = do_something_with_data(data, param)
return new_data


I made a second module
module_b
that looks roughly like this:

# module_b.py
import module_a as ma

ACTUAL_DATA = [2, 4, 6]

def create():
data = ACTUAL_DATA
# call ma.do_something_with_data using ACTUAL_DATA as the data_array argument
# but with PARAMETER (defined in module_a) as the parameter argument


My question is: can module_b see and read the global variables as defined in module_a? Can I just do:

# module_b.py
# ...
def create():
data = ACTUAL_DATA
param = ma.PARAMETER # basically copy initialization from ma.create()
new_data = ma.do_something_with_data(data, param)
return new_data


I'd like to not have to change module_a at all, and I'd like to avoid having to copy all those variables over into module_b.
>>
>>55006622
No problem. I can't remember the exact flag for certain but my gut tells me it might be -S
>>
>>55006587

TypeError
NoMethodError

Take your pick. If you wanted something that occurs at compile time though, you can forget about it. There is no "compile time".
>>
>>55006531
>I have heard some say that dynamic typing isn't a type system because it only has one type.
lel, u probably heard that here.
>>
>>55006685
That's unfortunate. I greatly prefer errors at compile time. The compiler is much less fallible than I am.
>>
how long are your classes? I feel a bit lost at 200 lines
>>
>>55006636
It is.

Generates much different instructions, but skimming through they seem to follow a similar overall pattern. Don't really know enough assembly to tell much beyond basic calls, registers, jumps etc, though. Have to figure it out better later.

Thanks again. Might not have ever thought to look.
>>
>>55006700
Actually I first heard it on 8ch... then here. Probably by the same faggot.

>>55006707
Yes, well, dynamic languages aren't for everything. When I want flexibility at compile time, I use C++. It's ugly as shit, but yes, it has dependent types (templates) and sum types (unions). That said, one should not discount the power of runtime flexibility. In a dynamically typed language like Ruby, a type could change elements about itself at runtime. For instance, I could undefine the + method on the Fixnum class, thus making it impossible to add integers together... of course doing so would immediately cause the REPL to coredump because I just made it impossible to add integers together, but I mean fuck it, everything's flexible.
>>
>>55006747
They vary in length obviously, and depending on the language. Getters/Setters in C# take very few lines compared to Java.

    static boolean isOdd(int n){
boolean [] truthTable = new boolean [n+1];
boolean previousEven = false;
for (boolean i: truthTable){
previousEven = (previousEven) ? false : true;
}
return !previousEven;
}

My isOdd-class is 8 lines in total!
>>
thinking of making a very basic apple newton like device with Cortex M4F or M7F (with DSP and FPU), about 512kb / 1mb ram, touch LCD and wifi module for basic browsing, music listening and video playback (they are surprisingly capable of that), RSS reading etc. Will develop my own probably single-tasking OS for it, should be fun
>>
>>55002332

Is this code not written by you? You should just add a print statement printing the url since the thrown exception tells you nothing about what went wrong. As it is the exception is fairly worthless
>>
File: ALogicalConclusion.png (61 KB, 775x721) Image search: [Google]
ALogicalConclusion.png
61 KB, 775x721
Here, the interpreter would like to increment the line count number... only to realize it doesn't know how to add numbers. This causes it to raise an exception. Since this is IRB, it would like to catch the exception and just print out a nice error, but unfortunately it errors while catching the exception and just sort of panics and crashes.
>>
>>55006956
Terrifying. I feel like I'm staring into the abyss.
>>
File: 1386530408033.gif (2 MB, 189x189) Image search: [Google]
1386530408033.gif
2 MB, 189x189
>>55006913
>>
>>55006956
https://codegolf.stackexchange.com/questions/61115/make-your-language-unusable
>>
>>55006913
what why don't you do

if (n % 2 != 0)
return 'true';
>>
>>55006625
no
>>
>>55006751
Also, difference seems to come out to this, if anyone is curious.

For (compare two arrays):
.cfi_def_cfa_offset 56
subl $8, %esp
.cfi_def_cfa_offset 64
movzbl 16(%esp), %eax
cmpb %al, 24(%esp)
jne L5
movzbl 25(%esp), %eax
cmpb %al, 17(%esp)
jne L5
movzbl 26(%esp), %eax
cmpb %al, 18(%esp)
jne L5
movzbl 27(%esp), %eax
cmpb %al, 19(%esp)
jne L5
movzbl 28(%esp), %eax
cmpb %al, 20(%esp)
jne L5
movzbl 29(%esp), %eax
cmpb %al, 21(%esp)
jne L5
movzbl 30(%esp), %eax
cmpb %al, 22(%esp)
jne L5
movzbl 31(%esp), %eax
cmpb %al, 23(%esp)
jne L5
addl $56, %esp
.cfi_remember_state
.cfi_def_cfa_offset 8
xorl %eax, %eax
popl %ebx
.cfi_restore 3
.cfi_def_cfa_offset 4
ret


if:
.cfi_restore_state
cmpb $80, 25(%esp)
jne L5
cmpb $78, 26(%esp)
jne L5
cmpb $71, 27(%esp)
jne L5
cmpb $13, 28(%esp)
jne L5
cmpb $10, 29(%esp)
jne L5
cmpb $26, 30(%esp)
jne L5
xorl %eax, %eax
cmpb $10, 31(%esp)
jne L5
jmp L7
.p2align 4,,10
>>
>>55006976

Python can probably do something similar, but breaking everything at runtime is much prettier in Ruby. Much less __bullshit__
>>
>>55006913
return !(truthTable.Aggregate(false, (previous, i) => !previousEven))
>>
>>55007072
*!previous
>>
File: ruby.jpg (23 KB, 631x116) Image search: [Google]
ruby.jpg
23 KB, 631x116
>>55006956
>ruby
>>
>>55007001
Why? If module_b can see the functions defined in module_a, surely it should be able to see the global variables as well, right?
>>
>>55005434
Go.
Thread replies: 255
Thread images: 41

banner
banner
[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.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.