[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 / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y ] [Search | Home]
4Archive logo
/dpt/ - Daily Programming Thread
If images are not shown try to refresh the page. If you like this website, please disable any AdBlock software!

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

Thread replies: 327
Thread images: 21
old thread: >>52509824

What are you working on, /g/?
>>
>>52514324
A waifu
>>
>>52514324
reading through the copy of K&R C I got for christmas. I'm fairly new to programming and looking to learn C before I become to attached to any of the higher-level/Object-Oriented languages I've used (Java, Python, Objective-C).

Is C truly the master race? Will I come to regret this?
>>
File: losing snake.gif (45 KB, 647x552) Image search: [iqdb] [SauceNao] [Google]
losing snake.gif
45 KB, 647x552
>>52514324
Just the usual
>>
>>52514324
>Made before the bump limit
Delete this degenerate shit, faggot.
>>
Thank god for Curry and Howard, they're making my discrete math class so easy. For example, the value of implication was immediately intuitive to me:
0 => 0 = 1
0 => 1 = 1
1 => 0 = 0
1 => 1 = 1

a : 0 => 0
a = id

b : 0 => 1
b = absurd

c : 1 => 0
-- cannot prove c!

d : 1 => 1
d = id


>>52514304
>it's not the programmer's responsibility to write correct and fast programs

>>52514334
>he doesn't know about programming with proofs

>>52514354
static typing + no manually written testing needed > everything
>>
Just wrote this:
    mov $0xe,%edx
mov $0x400095,%ecx
mov $0x1,%ebx
mov $0x4,%eax
int $0x80
mov $0x1,%eax
int $0x80
rex.W
gs insb (%dx),%es:(%rdi)
insb (%dx),%es:(%rdi)
outsl %ds:(%rsi),(%dx)
sub $0x20,%al
ja 40010
jb 40010
and %ecx,%fs:(%rdx)


Am I a hacker now?
>>
>>52514428
Even better, actually, I can prove the contradiction of c:
~c : (1 => 0) => 0
~c f = f tt
>>
>>52514428
>no manually written testing needed
lel, you are a 10x programmer, right ? most of the errors (i would say 99%) that i had when programming with dynamic languages where logic errors and not type errors.
>>
>>52514324
Animefags need to go to reddit.
>>
>>52514503
There are more than just logic errors and "type errors", such as doing something that will cause a segfault. Expressive type systems can statically verify that a correctly-typed program will never segfault (of their own folly).
Also, logic errors that can lead to a segfault will be caught.
>>
>>52514538
>such as doing something that will cause a segfault
Which is the result of a logic error or a type error.
>>
>>52514503
This. The few times I had type errors was not reading the standard library careful enough. There's really no situation where normal coding is going to be bogged down by dynamic typing. You have to go out of your way to cast a type to another type without knowing, or to pass a type to a function that doesn't use it, so it's useful in self-contained tiny functions where you're using dynamic typing to shorten code.
>>
>>52514560
Nice job not reading my post.
>>
>>52514446
>int $0x80
>32-bit
Yuck
>>
>>52514565
>my little 20 line toy programs never had issues with dynamic typing xd
>>
>>52514568
I did. It was bullshit. Whether or not this will be caught has nothing to do with the type system used.
>>
>>52514446
>AT&T
What's it supposed to do anyway
>>
File: opcodes.jpg (140 KB, 669x723) Image search: [iqdb] [SauceNao] [Google]
opcodes.jpg
140 KB, 669x723
>>52514591
Funny that you say that. Before writing chip-8 in C, I've had no problems implementing virtual machines in python, small or large as they are
>>
>>52514324
This is such a cute girl!

Today I realised the importance and superiority of state machines while working on my programming language implementation.
>>
>>52514604
Plug it into as and see for yourself! It should be compatible with all versions of Linux running actual versions of GNU Binutils.
>>
>how you want your type system senpai
>just fuck my performance up and force me to fully compile and run my program to find a bug that I can then hunt down with a debugger

>>52514600
It literally does. You can have a type system that's expressive enough that you can know that a program that compiles will never segfault, even in the presence of logic errors (which are purely an error on the programmer's part to make what they want to make).
>>
>>52514428
>problem of static typing is not the syntax, it's the handcuffing of the programmer forcing him to think about types when its unneeded most of the time. also, it's shit for a dynamic language to be statically typed.
I don't get it, dynamic or not you will have to think about types.

>he doesn't know about programming with proofs
Is there any non-shitty* language that does this?

*aka not agda
>>
>>52514685
Not yet, unfortunately, but I'm working on one.
>>
>>52514560
And both of them can be avoided.
>>
>>52514654
No. Dynamically typed languages don't create segfaults by type abuse. Those are caught when they happen as they are still strongly typed. The only way segfaults happen in those is when you call unsafe libraries. And even then your beautiful statically typed program has no chance of not segfaulting,
>>
>>52514694
f-fuuzetsu?
>>
>>52514591
Hurry up with your rebuttal familio. I've got snake node shifting to implement
>>
I only learned a bit of MIPS for a class.
How do I git gud with real assembly?
>>
>>52514616
>40 line toy program
>half of it is an array
not laffin
>>
Is there any way to combine ja and jb instructions into a single line? Right now I have
ja 40010
jb 40010

'jne 40010' breaks things, so I'm assuming I need an unsigned version of jne. Does such a thing exist?
>>
>>52514729
>40 lines
pretending to be retarded I see
>>
>>52514697
integer faculty(integer n)
return n + 1;

I don't see how static typing helped me prevent this logic error here. You might want to elaborate on that.
>>
>>52514714
I didn't imply that. I'm just saying that a type system alone (without tests) can be enough to prevent segfaults and other nasty bugs.

>>52514716
Who?
>>
>tfw just deleted 1500 lines of depreciated code from the repo

A-atleast I learned something r-right?
>>
>>52514744
>without tests
Worthless in any professional real-world scenario.
>>
>>52514767
What?
>>
>>52514742
We are talking about logic errors leading to segfaults.
>>
>>52514642
I have my Windows up so I can take notes for class
>>
>>52514757
>depreciated
>>
Is it true that Python doesn't have TCO and has problems running two threads concurrently?
>>
>>52514757
getting rid of code is sometimes more important than adding new one
>>
>>52514794
implementation defined
>>
>>52514790
That's probably why he had to remove them

You never know how much the whole code might be worth in the future
>>
>>52514773
You will have to elaborate on that as well.
What kind of logic error that can't possibly happen in a statically typed system can lead to a segfault in a dynamically typed one?
>>
>>52514794
oh boy, someone is confusing concurrency and parallelism again
>>
>>52514794
>problems running two threads concurrently
Last time I checked, python's solution to multithreading issues was to run them one at a time.
>>
>>52514790
I misspelled it on my git commit too.

Fuck.

Anway to change a commit message? I haven't pushed yet.
>>
>>52514827
Not really, it's pretty clear what I mean.
>>
Currently a student intern working on an angular.js app making dece money at a reputable place.

I want to get smart and make big bucks. What do I learn and git gud at? Data science? Machine learning? Security? Point me in the right direction, family.
>>
>>52514818
Your argument against static typing is that you need tests anyways to prevent bugs, so why even have types in the first place.

My counterargument is that a type system can prevent bugs without the need for tests. Errors that purely reside in "business logic" are not errors to the computer, so it makes no sense for the computer to check them. However, they will not be able to lead to an error that the computer does care about, again because of the type system.
>>
Any of you have some spare idea for a degree work?

some of seniors' work:
card game in java
-somebusiness analytics software
-walleyball support software with analytics
-menu ordering software in c#

desu these are rubbish
>>
File: 1429279282773.webm (2 MB, 600x338) Image search: [iqdb] [SauceNao] [Google]
1429279282773.webm
2 MB, 600x338
>>52514324
>>
File: 1451683583776.gif (2 MB, 400x600) Image search: [iqdb] [SauceNao] [Google]
1451683583776.gif
2 MB, 400x600
>>52514915
GameBoy/GameGear virtual machine
>>
>>52514878
Security is a pretty big field nowadays
>>
>>52514915
>degree work
>card game in java
no that's not okay
>>
>>52514879
>My counterargument is that a type system can prevent bugs without the need for tests.
Really!
>Errors that purely reside in "business logic" are not errors to the computer, so it makes no sense for the computer to check them.
Good job, you have convinced me: You are a fucking retard.
>>
>>52514915
Write some freetard programs that people will actually use. There's plenty of libraries to contribute to.
>>
>>52514938
I'm ashamed as well
>>
>>52514949
Everything decent is already written though.
>>
>>52515002
Where are my virtual waifus then?
>>
trying to learn java to make some android apps, I hate java but I love the whole java ecosystem and tooling it provides.

It's really hard coming from a language as nice as c++
>>
>>52514926
>the kernel is trying to pack the struct
incorrect
>>
>>52514938
I did a card game in my babies first intro to c# class as a final project. So yeah that is not acceptable for a senior project.
>>
>>52514915
Cluster analysis and visualization.
>>
>>52515040
How else are they going to encourage retards to get CS degrees?
>>
>>52515032
Well, the things that don't require dozens of years of research, anyway.
>>
>>52514939
Actually, I'm going to change my stance. A lot of business logic errors can be squashed using types -- for example, having a type for sorted lists that simply does not permit you to express an unsorted list. Then, a sorting algorithm would have to output a sorted list.

You wouldn't ever need to write a unit test to ensure that the algorithm outputs a sorted list.
>>
>>52514949
such as?


there are plenty more, mainly business analytics/support softwares

>>52514938
>>52515040
maybe cardstone#2 idk
>>
>>52515002
Do you Python?

There's a shitton to write.
>>
>>52515193
Such as?
>>
http://phoronix.com/scan.php?page=news_item&px=AMD-HSA-GCC-Merged
https://gcc.gnu.org/gcc-6/changes.html
https://gcc.gnu.org/onlinedocs/jit/index.html
Why aren't you using GCC yet?
>>
>>52515249
But I am
>>
>>52515249
I am though
>>
>>52515002
thats is my exact problem, I just dont wanna shit out some stupid ripoff
>>
>>52515086
>>52515217

Take something like scipy.

The integrate package is shit. You could easily grab a paper from the 90s and write a better ODE/PDE simulation functions. It's easy and used by a lot of academics nowadays.

Actually I think there's still not even a basic PDE simulator. You could write that and do a PR, unless you somehow fuck up that's contributing to a major and relevant open source project. It will look better on your CV that your stupid GUIshit addons and card games anyway.
>>
>>52515249
>https://gcc.gnu.org/gcc-6/changes.html
what is this, what does it do? i literally just started taking a programming class in college
>>
>>52515249
>-Wmisleading-indentation
Kek.
>>
>>52515249
>https://gcc.gnu.org/gcc-6/changes.html
>those C changes
are we in heaven lads?
>>
>>52515249
>GCC 6 release April
Didn't 5 just come out last summer?
>>
>>52515321
That seems pretty neat actually, if it doesn't slow down compilation a lot.
>>
>>52515416
Why would that in particular slow down compilation?
>>
>>52515249
Hopefully, soon enough braces won't be mandatory, we can scope with indents, as it should be

>that last link
absolute madman, slow down GCC
>>
>>52515457
>soon enough braces won't be mandatory
They aren't:
if (test)
dothis();


>we can scope with indents
But this is stupid.
>>
>>52515441
I figured it would have to do extra work in tracking indentation rather than just ignoring it. Though maybe they already keep tabs or spaces on it.
>>
>>52515495
>They aren't:
For scoping multiple lines they are

>But this is stupid.
I didn't say it should be mandatory, just that the alternative wouldn't be mandatory. That way, I don't have to throw braces everywhere unless I wanted to
>>
>>52515539
>For scoping multiple lines they are
huh? no
dothis(1,
2);
>>
>>52515556
multiple statements, you know what I mean
>>
File: le absolute aryan.jpg (23 KB, 640x504) Image search: [iqdb] [SauceNao] [Google]
le absolute aryan.jpg
23 KB, 640x504
>>52515416
Look at the example they showed. Absolute madmen.
>>
http://svr-pes20-cppmem.cl.cam.ac.uk/cppmem/
>>
File: 16606658.jpg (612 KB, 1600x1200) Image search: [iqdb] [SauceNao] [Google]
16606658.jpg
612 KB, 1600x1200
>Taking some introductory programming class workshop thing teaching VB.NET to familiarize myself with how programming languages work
>Did about twenty exercises in LPTHW, felt confident in my abilities but too lazy to open the PDF again and finish the rest
>Assigned to write up a simple program, either an extremely basic roguelike game, Minesweeper or a scientific calculator in Visual Studio
>Decide to write a simple 8x8 Minesweeper game
>Given two months to complete it
>No idea what the fuck I am even doing
>Struggle and feel stressed as I overheard others in the class discuss how complete his or her project is

>Fail it completely
>Couldn't even write code for the basic shit like setting the variables or strings or outputting a system message
>Drop the workshop thing completely and stopped attempting to learn how to program for over two years

I want to try learning VB.NET. I enjoy coding. It's fun, but I get so demotivated when there are people obviously more enthusiastic than me..
>>
>>52514714
>Dynamically typed languages don't create segfaults by type abuse.
ehh... C? Assembly?
>>
>>52515721
>VB.NET
Almost trolled me 6/10
>>
org 100h    ;this is a .com executable

mov si,00h
mov cx,100h

hexdump: ;takes DS:SI as a pointer and
cld ;dumps up to CX bytes of memory to screen as hex
;does not change segment
hxs: ;uses si,cx,ax,bx,dx
xor ax,ax
lodsb
mov dx,ax
shr ax,4
add ax,48
cmp ax,57
jna something
add ax,39
something:
and dx,15
mov ah,0eh
int 10h
mov ax,dx
add ax,48
cmp ax,57
jna something2
add ax,39
something2:
mov ah,0eh
int 10h
loop hxs
ret

Compare with:
org 100h    ;this is a .com executable    

mov si,00h
mov cx,100h

hexdump: ;takes DS:SI as a pointer and
cld ;dumps up to CX bytes of memory to screen as hex
lea bx,hxtab;does not change segment
hxs: ;uses si,cx,ax,bx,dx
xor ax,ax
lodsb
mov dx,ax
shr ax,4
xlatb
and dx,15
mov ah,0eh
int 10h
mov ax,dx
xlatb
mov ah,0eh
int 10h
loop hxs
ret

hxtab:
DB 48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102


Which one should I prefer in a real application? The first one, just because it doesn't take up space in the data segment, right?
>>
>>52515734
those aren't dynamically typed
>>
>>52515734
>Dynamically typed
>C
what?
>>
>>52515757
Unless you write for space-constrained chip choose the one that reads better.
>>
>>52515776
You can pass everything around as pointers in C to code dynamically. Just like every otherwise statically typed languages. Dynamic typing is simply the absence of static type checking at compile time. Every language I know of gives you ways to bypass it.
>>
I've finished my first bash script it's a password hasher, how'd I do? ( https://github.com/ZippyWeb/PassHasher)

#!/bin/bash

#! I got the idea for this script off /g/, so far I've added Salting ROT and character limits

echo "Usage: Pick up to five words, you can use one if you want (your "salt sentance") and two numbers, this will be your passphrase your passphrase will stay the same but the passwords generated will change for each website.
"
#! you should edit the ROT alphabets and salt order for added security

read -p "Salt sentence: " salt1 salt2 salt3 salt4 salt5
read -p "Website: " password
read -p "Character Limit: " charlim

md5_PASS01=$(echo -n $salt1)$(echo -n $password | md5sum)
md5_PASS02=$(echo -n $salt2)$(echo -n $md5_PASS01 | md5sum)
md5_PASS03=$(echo -n $salt3)$(echo -n $md5_PASS02 | md5sum)
md5_PASS04=$(echo -n $salt4)$(echo -n $md5_PASS03 | md5sum)
md5_PASS05=$(echo -n $salt5)$(echo -n $md5_PASS04 | md5sum)
sha_PASS01=$(echo -n $md5_PASS05 | sha512sum | tr [a-z] [A-Z])
echo "$sha_PASS01" | fold -w $charlim

read -p "ROT value: " rotvalabc

abc="AyB£CfDahkiuEFGnHdfeerIJ&[email protected]:XYZAyB£CfDahkiuEFGnHdfeerIJ&[email protected]:XYZ"
rot=$sha_PASS01
rotted=$(echo $rot | tr "${abc:0:26}" "${abc:${rotvalabc}:26}")
echo ${rotted} | fold -w $charlim

read -p "ROT value for numbers: " rotvalnum
num="[email protected]!89)[email protected]!89)[email protected]!89)0"
rot=${rotted}
numrot=$(echo $rot | tr "${num:0:10}" "${num:${rotvalnum}:10}")
echo ${numrot} | fold -w $charlim


exit
>>
>>52515721
Why didn't you ask for help here? C-Can we help?
>>
Is it possible to have a datatype that can store either a string or a struct like how a byte can store a character or an integer?
>>
>>52515905
A union
>>
>>52515905
https://en.wikipedia.org/wiki/Union_type
>>
>>52515811
>You can pass everything around as pointers in C to code dynamically.
No. You still have to cast them to their target type or you'll get compiler errors. Because C is statically typed.
Learn the fucking difference between static/dynamic and weak/strong types.
>>
>>52515811
>Dynamic typing is simply the absence of static type checking at compile time.
No, that would be typeless. A dynamic type system needs to do type checking.
>>
>>52515969
>You still have to cast them to their target type or you'll get compiler errors.
Yes, but casts happen at runtime not compile time. Casting happens implicitly in dynamic languages at runtime.

>Learn the fucking difference between static/dynamic and weak/strong types.
I do anon.
>>
>>52515942
>>52515948
Thanks. The anon who asked 6 threads ago now has his answer.
>>
>>52515905
A tagged union
>>
>>52516031
>Yes, but casts happen at runtime not compile time.
No. there is no cast.
>Casting happens implicitly in dynamic languages at runtime.
No, there is no cast.
>>
>>52515969
>No. You still have to cast them to their target type or you'll get compiler errors. Because C is statically typed.
No, you don't if you use void *
>>
>>52516065
That still doesn't make the language dynamically typed. The type is void*
>>
>>52516057
>No. there is no cast.
Yes there is. If you write
10 + obj

, obj will be cast to a number or a string (in many languages). If it is not either those it will fail at runtime with a type error. This depends on how loose or strong the type system is of course.

It's effectively the same as
10 + (Integer)obj

in Java. You will get a runtime error if the type cast fails.
>>
>>52516083
It shows that you do not need casts, I am not debating if C is dynamic typing or not.

>>52516104
Learn what a cast is. Only the second is a cast.
>>
Hi.
I'm just starting C++.
What compiler is good?
>>
>>52516083
Then dynamic languages are all static too, because the type of everything is Id/Any, like in Object-C or TypeScript.
>>
>>52516065
You can't do any arithmetic or really much of anything with a void*. You can only pass it around, something will cast it when it needs to use it.
>>
>>52516109
>Learn what a cast is. Only the second is a cast.
The first is a cast too, it's just done implicitly.
>>
>>52516124
see last part of >>52515969
>>
>>52516123
g++
>>
>>52516144
But I know those things. Please explain why you think I am wrong.
>>
>>52516138
There is no implicit casting (in C at least).

>>52516126
>something will cast it when it needs to use it
You do not need to cast void *
void *a = malloc (sizeof (int));
int *b = a; /* no casting! */

char *a = malloc (sizeof (int));
int *b = (int *)a; /* casting! */
>>
>>52516175
>>
>>52516188
might be a good time to take a hint
>>
Void pointers do not a dynamic type make.
>>
>>52516175
I am not a bait you little shit.
>>
>>52516182
You need to cast in order to use them for anything though. Of course you don't need to cast them when you're just passing them around.
>>
>>52516216
What are you talking about? Did you even read my example?
>>
>>52516206
What's the hint? That some dynamic typing advocate thinks I'm wrong, but can't explain why? That's nothing new.
>>
>>52516213
Then fuck off and learn how to use a search engine.
>>
>>52516233
yes, try multiplying the two ints together using the untyped pointers. You need to cast them to int pointers.
>>
>>52514428
a => b <=> ~a v ab
>>
>>52516250
>the two ints
>two separate examples
wow anon-kun, you really are retarded.
>>
>>52516260
I understand that, but it doesn't actually add any "meaning" to the value of implication.
>>
>>52516282
personally I think that is the whole "meaning" of implication.
>>
File: nani.png (304 KB, 722x768) Image search: [iqdb] [SauceNao] [Google]
nani.png
304 KB, 722x768
Why is a cocktail sort preferable to a bubble sort?
>>
>>52516272
I know they are different. But you're saying you never need to use casting. You don't always need to use casting, but to do anything with the data your pointer is pointing to besides passing it around and assigning it to variables, you need to cast it.
>>
>>52516271
? I don't understand your post.
>>
>>52516242
You don't make any sense.

>>52516250
>using the untyped pointers
Nice goalpost moving, how about this instead?
int
mul (void *a, void *b)
{
int *c = a, *d = b;
return *c * *d;
}

See? No casting.
>>
>>52516271
W-why did you qoute everyone's post but mine?

Oh god, there are only 3 of us in /dpt/ isn't there?
>>
>>52516271
(You)
>>
>>52516294
It's an equivalent definition.
>>
>>52516303
>only 3 of us in /dpt/ isn't there?
Apparently 40 different IPs have posted. I'd say that at any time there are only about 2 dozen very active posters (contribute more than 1 or 2 posts).
>>
>>52515721
>Minesweeper

Lets spec it.

* Generate a width by height grid of tiles.
* Randomly populate it with a number of mines.
* User needs to be able to place a flag on a tile.
* User needs to be able to click on a tile.
* If a user clicks on a tile which has a mine then it's game over.
* If a user clicks on a blank tile then a paint fill occurs on the grid of tiles.
* The paint fill cascades on tiles which have no adjacent mines.
* The paint fill halts on tiles which have adjacent mines.
* Tiles that halt a paint fill have the number of adjacent mines displayed on them.
* The user wins when all tiles are either flagged or paint filled.

Have I missed anything?
>>
>>52516302
>int *c = a, *d = b;
This is casting to int though.

But I get you, it's not really explicit like it would be in Java or some shit.
>>
>>52516322
duh, so?
>>
>>52516335
>* The user wins when all tiles are either flagged or paint filled.
I'd simplify it to "all non-mine fields were uncovered/filled". I'm pretty sure you are not *required* to actually flag mines, it's just a tool for helping the player.
>>
>>52516335
Perhaps a timer?
>>
>>52516342
No, see the example I posted above. This is NOT casting, it would be casting if you did
int *c = (int *)a;
>>
>>52516357
It doesn't add any meaning, though, no more than expressing it with a truth table would.
>>
>>52516335
>forgetting the main character - the smiley face
>>
>>52516282
no sun => no light if you don't have other light sources
no sun => light since you can get light without a sun
sun =/> no light since there WILL be light if there's a sun
sun => light for the above reason
>>
>>52516387
neither does anything else if you want to define meaning that way.
>>
Find a flaw.
void swap(int *a, int *b)
{
register int tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
>>
>>52516406
>register
>>
>>52516406
No one cares about your shitty "register" bait.
>>
>>52516406
Type conflict?
>>
>>52516406
>register
There is seriously no reason to use that ever
>Not inline
>>
>>52516405
Maybe not meaning, but mathematical justification beyond the logic of examples like >>52516397.
>>
Anyone got any (significant) project ideas? Just finished a side project and itching for another.
>>
>>52516406
It allocates memory.
>>
>>52516436
that's just a shitty wannabe logic sentence example.
>>
>>52516440
>(significant)
By that do you mean non-trivial or useful?
>>
>>52516452
Okay.
>>
>>52516380
I think we're splitting hairs here. I don't really care that much. Casting refers to changing how a bit pattern is interpreted by the language.
int *c = a

is basically telling the compiler that the value of a can be treated as an int pointer. Yes, it doesn't have the (int *)a thing, but it still changes the interpretation. Maybe that's not what casting tends to mean in the context of C. Whatever.
>>
>>52516464
preferably both, but useful > non-trivial.
>>
>>52516440
>significant
How significant is 'significant'?
I can think of some projects that would probably take 2 years or so.
>>
>>52516469
pitch em!
>>
File: 1452351559589.gif (131 KB, 600x338) Image search: [iqdb] [SauceNao] [Google]
1452351559589.gif
131 KB, 600x338
Do you ever think about the horrible painful death that awaits you, /dpt/?
>>
cocktailsort.c:46:3: warning: ISO C90 forbids mixed declarations and code [-Wpedantic]
unsigned k; /* <-- */
^


why is ansi C so shit?
>>
>>52516483
Wayland Compsitor

>>52516504
Why the fuck are you using ANSI C in 2016?
>>
>>52516436
This post hints me that you have no fucking idea what you're talking about. How do you want to prove a definition?
>>
>>52516504
The last ANSI C supports that.

But honestly, it's shitty thing to do.

>>52516526
What are you talking about? The last update happened in 2012.
>>
>>52516500
I am now. Thanks, anon.
>>
>>52516500
every day anon. Nothing a breathing mask and a tank of industrial grade helium can't get me out of though.
>>
>>52516538
I don't know, this all just started with me saying that it helped me to understand it in terms of the Curry-Howard principle.
>>
>>52516500
You are now breathing manually.
>>
>>52516526
>Wayland Compsitor

no

next idea please
>>
>>52516545
>The last update happened in 2012
It was 2011, not 2012. That's why it's colloquially called C11. Also, that is an ISO standard, not an ANSI standard.
'ANSI C' typically refers to C89.
>>
>>52516332
>only about 2 dozen very active posters
At least 5 of those are traps.
Dozen weeabs minimum set exclude traps.

There aren't enough normal people per faggots ITT.
>>
>>52516568
>no
It's a non trivial idea that would actually be useful. It involves low level graphics, input and operating system interfaces, as well as very high level things like GUIs and user-experience.
You're probably just a winbabby.
>>
>>52516571
>It was 2011, not 2012
TC1 was published in 2012.

>Also, that is an ISO standard, not an ANSI standard.
It is an official ANSI standard.
>>
>>52514926
i like it

saved for future cuteposting
>>
>>52516612
no, i don't like fucking with open source projects. always too much politics and high barrier to entry, esp. wayland.
>>
>>52516468
From just my personal life:
Improve installation of YouCompleteMe. It's pretty involved and the first couple of times, following the docs to a tee, I got errors installing it.
Improve installation of email servers. iRedMail didn't work, couldn't get it to work so I gave up. Installing and configuring dovecot and postfix manually is a fucking nightmare. Most of the online howtos don't work for me (Debian 8).
I would love the languages I write in to be faster. The LuaJIT is currently out of a main developer. Before he left Mike Pall described a 4-color incremental GC that would improve performance measurably and put it on par with Java's GC for performance. That would be cool.
If you are well versed in state-of-the-art cryptography there are a few projects out there for decentralized encrypted messaging/file transfer/VoIP/computation/etc. like BitMessage or Urbit, that need more hands on deck for development.
>>
>>52516679
>open source
>high barrier to entry
countless open source projects are javascript libraries these days. you could literally edit shit on your phone and then make a pull request.
>>
>>52516679
Isn't wayland just a protocol? How are you fucking with Open Source projects?
>>
>>52516712
>You could literally edit shit on your phone and then make a pull request.
yeah, because you can't do that for literally any language.
>>
Math.floor(Math.random() * 10) + 1;


What an absolutely disgusting way to have to generate a random number. Why can't the native function in JavaScript just be Math.random(1, 10)?
>>
Where did the old namefigs go? Where is Marisa? Where is Fuuzetsu? Where is Jonson? Where is Nand? Where is the python troll?
>>
>>52516679
>no, i don't like fucking with open source projects
So you're not a winfag, but don't like open source. You have a shitload of open source software on your computer, you better remove it.
>too much politics
It's literally your own project though. I never said anything about contributing to something else.
>high barrier to entry
They typically don't. It's just sometimes the code is complex as fuck and can take awhile to understand, but that has nothing to do with it being open source.
>esp. wayland
What the fuck do you know about Wayland?
>>
>>52516759
sure you can but enjoy compiling and testing most languages on a phone.
>>
>>52516771
Hopefully dead.
>>
>>52516771
Namefags are fucking shit. I'm glad there aren't any of them here anymore.
Fore some reason, I hate namefags more than tripfags. Maybe it's just because namefags are typically retarded 12 year olds.
>>
>>52516771
no one cares about tripfags. hopefully everyone ignored them enough that they moved on.
>>
>>52516771
They went to IRC.

You'll see them spam it in this thread without their trip every now and then.
>>
>>52516813
What about that delightful AWOO namefig that scrambles the amount of unicode flare on her name with every post so you can't filter her?
>>
>>52516712
>you could literally edit shit on your phone and then make a pull request.
I'm not even sure how that's possible... I hate having to type more than two sentences on any phone screen.
>>
>>52516824
What channel?
I remember back in the day it was /g/sicp and /g/lisp?
>>
>>52516833
>can't filter
only if you're braindead.
>>
>>52516769
function random(a, b) {
return Math.floor(Math.random()*abs(b-a)) + 1 + a;
}
>>
>>52516838
The name of the thread.
>>
>>52516769
>absolutely disgusting
>why can't random in this one language be different than random in 90% of the languages?
how is babby formed?
>>
>>52516878
>*abs(b-a)) + 1 + a;
What's that do, senpai?

Why not?
return Math.floor(Math.random() * b) + a
>>
What does math.floor do?
>>
>>52516928
For retards who do
random(1, -2)
I guess it really should be.
function random(a, b) {
return Math.floor(Math.random()*abs(b-a)) + Math.min(a);
}

And this is me bullshitting. I don't know JS.
>>
>>52516951
What is air?
>>
What's a good haskell library to learn?
Ncurses's not working...
>>
>>52516957
fuggg
Math.min(a, b)*
>>
>>52516967
None of them really...
>>
>>52516957
Why would people need to use imaginary numbers?
>>
>>52516995
why is the meme responder in the every thread?
>>
>>52517003
>negative number
>imaginary number
nigger you just went full retard
>>
>>52516957
I see.
>>
>>52517019
>imaginary number
Why? Imaginary numbers are numbers that aren't real, right? Negative numbers aren't real.
>>
>>52516406
void swap(int *a, int *b) {
*a ^= *b;
*b ^= *a;
*a ^= *b
}
>>
any haskell fags lurkng?
how advanced r u?
>>
>>52517010
When you are deeply involved in memery, like yourself, you will come across many others on the same path as you. To others we memers are invisible, seemingly retarded.
>>
>>52517037
yeah when a company's earnings are -100k it sure is an imaginary number. fuck off, troll.
>>
>>52517037
Holdupholdupholdup, what? Are you fucking serious?
>>
>>52516805
>enjoy compiling and testing most languages on a phone.
same goes for JavaScript.
>>
>>52517075
>when a company's earnings are -100k it sure is an imaginary number

Can they smell or feel their -100k? Yeah, didn't think so.
>>
>>52517066
but memery makes u a meme
>>
>>52515249
>The default mode has been changed to -std=gnu++14.
YES
>>
>>52517043
XOR swap is retarded, gets in the way of optimisations, and fails if a and b alias.
>>
>>52517116
>>52517037
https://en.wikipedia.org/wiki/Negative_number
btfo
>>
>>52517058
Just ask the question.
>>
>>52517058
I'm about as advanced as your hormone treatment
>>
>>52517043
doesn't work if a == b
>>
>>52517110
you can run node.js on android no problem.
>>
>>52517132
>using C++
>ever

>>52517140
>gets in the way of optimisations
Only if you use a retarded compiler.
>>
>>52517154
I bet that's super fun to set up.
>>
>>52517153
>>52517140
a = a + b;
b = a - b;
a = a - b;
>>
>>52517141
"represents" "represents" "represents"
>>
>>52517183
>Only if you use a retarded compiler.
It's much easier to optimise out a temporary variable than having to go through that shit.
>>
>>52517121
Exactly kohai.
>>
>>52517200
k tard
>>
>>52517198
Enjoy your undefined behaviour in case of overflow.
>>
>>52517225
Says the anon that thinks he can smell or feel debt as if it's a real thing.
>>
>>52517265
>he can't smell debt 3 miles away
>>
>>52517198
There is nothing wrong with a temp variable. Most compilers would just do 2 loads and 2 stores. Or on x86, xchg.
>>
File: snake done.gif (60 KB, 907x552) Image search: [iqdb] [SauceNao] [Google]
snake done.gif
60 KB, 907x552
Well guess I'm pretty much finished, except for a win screen that you won't see anyway cause you'd have to eat 2047 fruits to get there. Time to move onto bigger things, CHIP-8 assembly is far too simple
>>
<?php
define('DB_HOST', '4chan.org');
define('DB_NAME', 'meme_database');
define('DB_USERNAME', 'hiroshima');
define('DB_PASSWORD', 'tentacleporn');

$db = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USERNAME, DB_PASSWORD);

$var = rand(1, 10);
$roll = (string)$var;

$sql = $db->prepare("SELECT id, title, views, source FROM webm WHERE id` = :id");
$sql->execute(array(':id' => $roll));
while($row = $sql->fetch(PDO::FETCH_ASSOC)) {
print $row["title"] . "\n";
}
?>


Can you tell me what I've done wrong? I am a retard
>>
>>52517308
On AVR as well.
LDI ZH, 0
LDI ZL, 16
XCH Z, r17

However that takes 4 cycles. But saves a register.
>>
>>52517381
You used PHP.
>>
>>52517358
The snake freezes for a sec when it eats the fruit, doesn't look very smooth.

2/10
>>
>>52517142
What theories to learn for better understanding of Haskell?
>>
>>52517396
What should I use?
>>
>>52517358
source?
>>
>>52517381
>PHP
>MySQL
>redundant variable
>2015

S M H F A M
>>
>>52517428
Haskell.

>>52517419
Web programming.
>>
>>52517435
What do you mean?
>>
>>52517419
Lambda calculus and graph reduction for sure.
>>
>>52517443
Source code? Can you post it?
>>
>>52517465
For the virtual machine, the snake game or the assembler?
>>
>>52517436
I am copy pasting here. I don't know any programming languages. Just trying to get this shit to work ;_;
>>
>>52517476
Everything you have.
>>
>>52517444
Any nice libraries other than yesod to learn?
>>
got some questions guys. im planning on writing a chat room software. i plan on the server having multiple rooms that each hold users. The architecture might be a bit over my head, anyone know any helpful resources to read up on?
>>
>>52517518
Studying "pointless" and how algebraic types can be defined as fixpoints of functors is interesting.
>>
>>52517510
it'll all be on github.com/vinheim3 but I won't post the snake code yet until I put on the win screen
>>
>>52514915

Do you go to pepperoni u?
>>
>>52514324
in java, can i use an if statement with a return inside of it if i want to end main prematurely or will it not allow me to do that since main is a void function?
>>
>>52517545
Thanks :3
>>
fuck yes finished chip8
>>
>>52517585
>casting from void *
>int for indexes
>C++
>>
hello gayboys
>>
>>52517265
>negative numbers are imaginary
>get btfo
>i-i'll just shift the goalposts
>>
>you can't open this file because of internet security configuration
wtf?

how do I disable this stupid IE meme?
>>
>>52517606
look at how much I give a shit. I finished it and I'm happy about that.
>>
>>52517558
Yes, just
return;
. You can do that for any void function.
>>
>>52517642
>being happy from writing shitty code
>>
Best Linked List implementation for dumb Java class.
1. Single generic List class with all methods defined
2. Two classes, one for the head another for the nodes. Head defines all the methods.
The example in the assignment uses two classes. I only need to support insert at the front and delete.
>>
>>52517694
I wouldn't get too smug over a linked list, mate.
>>
>>52517694
Java has no pointers, you can't do that.
>>
>>52517719
I'm not smug, it's a question. Which one is more 'idiomatic'.
>>
>>52517672
>>
>>52517738
Oh, I didn't even realise you were asking a question. I thought you were bragging about how much better you are than your classmates.
Anyway, either approach is valid. The first approach can make it slightly easier to append lists together, the second allows you to store the tail pointer so you get fast tail insertions etc.
>>
File: shit.png (49 KB, 981x1455) Image search: [iqdb] [SauceNao] [Google]
shit.png
49 KB, 981x1455
Why the fuck is this happening?
>>
>>52517694
Both
Have a head that stores the size and the first/last node but make sure it's optional to use and allow nodes to live by themselves.
>>
>>52515038
Incorrect. Blue, status decreased.
>>
>>52517787
>implicit declaration of function 'recCalc'
Put the function above main, not below it.
>Segmentation Fault
Probably a stack overflow. You're making too many recursive calls.
>>
>>52517787
>cygwin
lol

>100 million elements
>can't TCO it
>>
>>52517815
Ahh, seems appropriate.
>>
>>52517787
>>52517835

Or just declare the prototype:

int recCalc(int);
>>
>>52517870
There is almost no reason to prototype shit (excluding header files and mutual recursion).
Just reorder the functions.
>>
>>52517568
Alright, everything's up

>>52517585
Congrats senpai
>>
>>52514324
Does OpenGL have a way to scale images without affecting the aspect ratio, or do I need to implement bicubic interpolation by hand?
Using C and GLFW by the way.
>>
>>52517880
Prototypes always seemed cleaner to me.
>>
>>52517900
All you're doing is duplicating information for literally zero benefit. Some people (especially newer people) try to strive for top-to-bottom reading of source files, but everyone else realise that is pointless and just stick main() at the bottom of the file. Just look at pretty much 99% of C projects.
>>
>>52517893
>Does OpenGL have a way to scale images without affecting the aspect ratio
uh... yes. You just tell it to render the texture at the size you want. Need to make sure the ratio is correct yourself.
>>
>>52517381
You're missing a backtick, or have one too many. `id` or just id, choose the latter.
>>
File: snake no delay.gif (18 KB, 640x345) Image search: [iqdb] [SauceNao] [Google]
snake no delay.gif
18 KB, 640x345
>>52517410
There you go senpai, drawing squares produces a noticeable delay, and you draw more upon eating a fruit, so I reduce the delay after that happens
>>
File: 35412355_p0.jpg (1 MB, 1729x879) Image search: [iqdb] [SauceNao] [Google]
35412355_p0.jpg
1 MB, 1729x879
>>52517937
Oh I'm sorry I forgot to mention that it needs to scale along with the window in an image-viewer like fashion.
I was thinking I could use GLFWs window size callback in concert with glviewport but I'm not sure how I would actually implement this given that the callback function only receives the dimensions in "screen coordinates" (whatever they are) instead of pixels.
And then there's the fact that the callback sometimes does not catch a window resize operation so I would have to permute the arguments to glviewport based on -value- and not -change-.
>>
Rewriting ocaml in ocaml.
>>
>>52517959
That's better.

I hope the snake goes faster the more it eats like in classic snake too or you'll only get a 5/10.
>>
>>52518101
Is the ocaml compiler really not written in ocaml?
>>
>Someone asks a simply question on Stack Overflow
>They get a 200 page essay
>>
>>52518147
Sometimes simple question have complex answers Rajeed.
>>
>>52518101
>Omemel isn't already self-hosting
>>
>>52515034
Use kotlin if you don't like Java
>>
>>52518147
SO is a rep whoring site full of autists, they feel the need to dump everything they know about a topic to get them points.
>>
>>52518147
>Someone asks a question relating to JavaScript
>You can use X in JQuery!
>>
>>52518201
Stack Exchange sites are basically just wikis hidden behind the guise of a Q&A site. So thorough answers even to simple questions should always be rewarded (as long as they aren't full of useless info).
>>
NEW THREAD!

>>52518289
>>52518289
>>
>>52518296
Dumbass
>>
>>52518296
Fuck off, didn't even hit bump limit.
>>
>>52514389
What language is this?
>>
>>52518330
That's what you thin.
>>
File: shit2.0.png (62 KB, 993x1501) Image search: [iqdb] [SauceNao] [Google]
shit2.0.png
62 KB, 993x1501
>>52517855
fuck you (what's TCO?)

>>52517835
>>52517880
reordered functions, reduced elements to 100.
still doing nothing.
>>
Javascript peasant coming through with his scrublord question:

I'm doing some API work; taking JSON data and then appending that to the page. JSON calls are made by iterating through an array of usernames, and then storing data related to each username in a number of variables. These variables are then used to insert data into an html string I append to the page.

However, I find that if I declare those variables globally, the html appended to the page is all wrong. If I declare them within the forEach callback function, it all works fine. What gives? I don't understand why this happens.
>>
/thread
>>
>>52518345
Bump limit is 310 faggot, you may now create a new thread.
>>
Can I use list comprehensions to output multiple elements to a list on each iteration?

[ if even x then [1,2] else [1] | x<-[1..] ]


This is giving me a list of lists of integers. Currently fixing it with post-processing.
>>
>>52518354
scope. When you pass in the callback, say callback.bind(this). That way, you'll have access to variables in your main script's scope.
>>
>>52518347
>what's TCO?
Tail-call optimisation.
An optimisation which converts a recursive function into an iterative one. It only works on certain types of recursion.

Also, I don't even understand why your function is recursive in the first place.
>>
>>52518458
Because it has to be.. it's not a for fun thing
>>
>>52518354
>However, I find that if I declare those variables globally, the html appended to the page is all wrong.
I'd have to see the code, but the JSON calls are happening asynchronously, and the callbacks are all using the same global variables. So you are getting concurrency issues.

Putting the variables inside a callback will mean there are separate variables for each name in the array. Or so I'm imagining.
>>
>>52517787
Dude, you are blowing your stack. Not to mention I'm pretty sure whatever the hell you are doing, you are doing incorrectly.
>>
>>52518135
It actually is. That's a major point of confusion for ocaml noobs: the standard library that ships with ocaml is meant to be only just enough to build the ocaml compiler, it's not usable for actual production.
>>
>>52518347
Probably because you've commented out your print?
>>
>>52518541
It's supposed to recursively find the first 100 million rational numbers. This is how you find all their numerators, the denominators are the next element in the array, it's called a hyperbinary sequence.

>>52518588
That's just a dumb answer,
>>
>>52518621
You aren't bounding n...
And honestly I'm not familiar with what you are doing, but are you certain the loop is correct? Recursion is usually supposed to replace iteration.
>>
>>52514324
i wrote a windows form application in c# for class today.
>im drunk
>>
>>52515038
I know, I'm not the one who made it though, I just transcoded it from mkv.
>>
>>52519843
there's a trollsub that discusses programming?
link
>>
File: 1444039983454.png (55 KB, 648x268) Image search: [iqdb] [SauceNao] [Google]
1444039983454.png
55 KB, 648x268
>>52519858
"&" subs, there's 3 tracks, "no fun" is the default, there's another called "fun" which has this stuff, and in the earlier episodes there's a "weeb" track which is basically just romaji.
You can find it on Nyaa.

Also, only the part I uploaded (E8) has anything programming related.
Thread replies: 327
Thread images: 21
Thread DB ID: 447703



[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 / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | Home]

[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 / qst / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vip /vp / vr / w / wg / wsg / wsr / x / y] [Search | 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.
This is a 4chan archive - all of the shown content originated from that site. This means that 4Archive shows their content, archived. If you need information for a Poster - contact them.
If a post contains personal/copyrighted/illegal content, then use the post's [Report] link! If a post is not removed within 24h contact me at [email protected] with the post's information.