[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: 32
File: ji.png (485 KB, 934x1000) Image search: [Google]
ji.png
485 KB, 934x1000
What are you working on, /g/?

>Previous thread
>>52063885
>>
First for OSGTP is mentally diseased.
>>
>>52066446
while(1) {
printf("Please don't use an anime image next times!\n");
}
>>
File: ew.png (272 KB, 470x624) Image search: [Google]
ew.png
272 KB, 470x624
DAILY PROGRAMMING THREAD CHALLENGE:

MEME SWASTIKA

Get to work, /dpt/.
>>
>>52066446
Thanks for using an anime image
>>
>>52066446
Thank you for keeping up with tradition and using an anime image.
>>
>>52066493

If this is wrong, then I don't want to be right.
>>
File: 1450911355052.jpg (139 KB, 600x400) Image search: [Google]
1450911355052.jpg
139 KB, 600x400
>>52066541
"Since the dawn of history the Negro has owned the continent of Africa – rich beyond the dream of poet’s fancy, crunching acres of diamonds beneath his bare black feet and yet he never picked one up from the dust until a white man showed to him its glittering light.

His land swarmed with powerful and docile animals, yet he never dreamed a harness, cart, or sled.

A hunter by necessity, he never made an axe, spear, or arrowhead worth preserving beyond the moment of its use. He lived as an ox, content to graze for an hour.

In a land of stone and timber he never sawed a foot of lumber, carved a block, or built a house save of broken sticks and mud.

With league on league of ocean strand and miles of inland seas, for four thousand years he watched their surface ripple under the wind, heard the thunder of the surf on his beach, the howl of the storm over his head, gazed on the dim blue horizon calling him to worlds that lie beyond, and yet he never dreamed a sail.”

— Charles Darwin
>>
>>52066446
Thank you for not posting a trap thread.
>>
>>52066506
What would be the best way to do this?

E  EMEM
E M
M E
EMEMEME
E M
M E
MEME M
>>
File: fibonacci meme.png (4 KB, 220x139) Image search: [Google]
fibonacci meme.png
4 KB, 220x139
>/dpt/ still can't draw a golden meme

         MEMEMEMEMEME     
MEME MEM
EME EME
MEM M
ME EM
ME MEME EME
E EME MEM
M MEME
>>
File: rhodesia174.jpg (277 KB, 1768x1180) Image search: [Google]
rhodesia174.jpg
277 KB, 1768x1180
>>52066608

That doesn't change anything, for me. It only makes me wistful that the African dream is over.
>>
>>52066722
Enjoy jerking off to the worst human race.
Is that the KKK HQ?
>>
What's the point of learning languages like Rust if there's no job market for them?
>>
Reminder that OCaml is the best language, plebeians!
>>
>>52066608
diamonds are overrated
>>
>>52066740
>Enjoy jerking off to the worst human race.

It's great. I love it.
>>
>>52066750
so you can pretend with your pals on github that you're not a worthless mutilated freak
>>
>>52066789
I bet you do burger boy. Make your parents proud.
>>
File: pOaGsx9.png (150 KB, 1536x1298) Image search: [Google]
pOaGsx9.png
150 KB, 1536x1298
>>52066446
>>
moot should've been permabanning tripshitters from the day 1.
>>
>>52066870
2bh trips should be salted by the thread ID so that triphomos can't actually tripgay all over the place. There will still be tirpfaggotry but it would be subverted.
>>
File: erw.jpg (53 KB, 1280x720) Image search: [Google]
erw.jpg
53 KB, 1280x720
>>52066894
People are always wanting to restrict features. I hate this.

We don't have visible sage anymore, we don't have email field anymore, we don't have anything anymore.
>>
>>52066894
tripfags don't belong here. i'm yet to see a single decent tripfag and i've been here for a loooong time.

mind you, trips shouldn't be just turned off, instead people that attempt to use a trip should be instantly permabanned- as a way of sanitizing the board. you know, the way of /fur/
>>
>>52066930
>We don't have visible sage anymore, we don't have email field anymore, we don't have anything anymore.
well yes, i miss noko too and those are shit changes. visible sage is much needed as right now 4chan basically caters to various faggotries blooming like mold.
>>
>>52066930
There was no point in the email field as we can use the comment field to write the email. Getting rid of it freed up a non-negligible amount of resources every year.
>>
>>52066657
here's what i came up with

#!/usr/bin/octave -qf

if (size(argv())(1) < 1)
printf("Usage: swastika STRING\n");
return;
endif

function [ y ] = swastika ( x )
x = int8(x);
xx = [fliplr(x) x(2:end)];
len = length(xx);

vert = [zeros(len / 2, len); xx; zeros(len / 2, len)];
horiz = vert';

bottom = [zeros(len - 1, len); x, zeros(1, length(x) - 1)];
left = rot90(bottom);
top = rot90(left);
right = rot90(top);
sides = bottom + left + top + right;

y = char(max(32, max(sides, max(vert, horiz))));
endfunction

disp(swastika(argv(){1}));
>>
File: iu.png (320 KB, 940x720) Image search: [Google]
iu.png
320 KB, 940x720
>>52066947
I think we should all sport a trip. It would make /dpt/ more fun.
>>
>>52066992
Only because everything is logged for the sake of delivering the data to the NSA. If that weren't the case, it wouldn't matter, but the email field was useful since it could be used for various shenenigans.
>>
>>52067012
I agree
>>
This is meant to reverse the words on each line of a file but it doesn't quite work
#include<stdio.h>
int main(int argc, char * argv[])
{
FILE *file = fopen(argv[1],"r");
char line[1024];

while(fgets(line,1024,file))
{
int i = 0; int j = 0; int k = 0;
char words[100][100];

while(line[k])
{
if(line[k]!=' ')
{
words[i][j] = line[k];
j++;
}
else
{
i++;
j=0;
}
k++;
}

while(i>=0)
{
printf("%s ",words[i]);
i--;
}

printf("\n");
}

}
>>
Why doesn't someone try to "fork" C++ and remove/improve the legacy nonsense(different symbol for the pointer compound type and the dereferencing operator, prettier pointer to function syntax, etc.)?
>>
>>52067016
Is the comment field not good for those shenanigans?
>>
>>52067039
Boost is used to improve the existing code base.
>>
File: 15 - 1.png (303 KB, 405x692) Image search: [Google]
15 - 1.png
303 KB, 405x692
Friends it's the anon making a shit 4chan browser in terminal.

I'm going to make a little window that will stay on top and to the side of the terminal window to show images for each thread and reply.

I suppose I'm best to do this with pyqt4?
>>
>>52067029
decompose your shit

write a "getline" function
write a "strreverse" function

test incrementally
>>
>>52067039
Nobody cares enough to do exactly that. I'd personally look at something else like Lisp or Python. If you want something closer to C, I'd look at D, Java or Objective C.
>>
>>52067074
I just want a sane but close-to-C language without GC.
>>
>>52067049
Not even close. How do you pretend to sage and actually write sega in the email field?
>>
>>52067039
That's pretty much what D is about.
But anyway, shit paradigm, use OCaml instead.
>>
>>52066994
slight touch-up

arm = [zeros(len - 1, len); x, zeros(1, length(x) - 1)];
arms = arm + rot90(arm) + rot90(arm, 2) + rot90(arm, 3);

y = char(max(32, max(arms, max(vert, horiz))));
>>
>>52067101
Isn't D meant to be a C++ replacement?
>>
>>52067109
Show us some example outputs senpai.
>>
>>52067085
>pretend to sage
>writes sega so that people can see
You are the cancer that was killing 4chan.
>>
File: swas.png (44 KB, 317x612) Image search: [Google]
swas.png
44 KB, 317x612
>>52067118
pic in case the formatting is fucked

$ swastika "SURE THING BUDDY"
S YDDUB GNIHT ERUS
U D
R D
E U
B
T
H G
I N
N I
G H
T
B
U E
D R
D U
YDDUB GNIHT ERUSURE THING BUDDY
U D
R D
E U
B
T
H G
I N
N I
G H
T
B
U E
D R
D U
SURE THING BUDDY S
>>
>>52066947
Trips have a use, though. Not the way tripfags abuse them here, but still.
Tripcodes exist to be used as a temporary ID to be recognizable in a large discussion if/when it's relevant. When a discussion is done you throw your trip away.
Automatically permabanning all tripcodes would be retarded.

>>52066894
This to be honest family
>>
>>52067138
Now rotate it 45 degrees and make a circle around it.
>>
alright /g/ back on topic.
what's the best bits n bites?
it's obviously cheese bit cracker or toasted o.
>>
>>52067113
Yeah, it's literally meant to be C++ without the C compatibility.
>>
>>52067166
but then it would become a symbol of hate and oppression!
>>
>>52067227
Sounds like a great combo. Tell me more!
>>
>>52067124
The point is to play the
>he likes X
>SAGE GOES IN ALL FIELD
joke, you fucking inbred. Fucking redditards who've not even been there all summer trying to lecture 4chan users about how to use 4chan.
>>
>>52067236
Did you know that D comes after C in the latin alphabet? It's true!
>>
>>52067234
Oh no !
>>
File: ruff.jpg (65 KB, 500x368) Image search: [Google]
ruff.jpg
65 KB, 500x368
hello
>>
>>52066499
Instead of checking for a truth condition after every loop, use a conditionless loop. for(;;){...} will run without the exit condition.
>>
>>52066753
Said the hiring managers at Jane Street and LITERALLY NO ONE ELSE EVER
>>
I want to program something that operates on a set of files (i.e. a folder?).
It should delete/move some files based on their filename and possibly their content.
What do I need for this?
>>
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
>>
>>52067297
Literally any language ever.
>>
File: whosagoodboy.webm (3 MB, 720x405) Image search: [Google]
whosagoodboy.webm
3 MB, 720x405
you all pet your dogs today, /dog petting thread/?
>>
>>52067333
The only thing I pet is your mums pussy.
Dogs are disgusting.
>>
>>52067297
Use Python, it's probably the easiest language to do that kind of stuff
>>
>>52067353
shitpaw detected, get offline cat, your place is in a box full of your own shit.
>>
>>52067363
Enjoy picking up your dogs feces.
>>
>>52067305
Ya even Javascript, with Node.js, can do this lol
>>
>>52067387
enjoy your house smelling like shit and knowing that every surface in your house has trace amounts of shit and piss on it.
>>
>>52067305
>>52067360
What do I need?
I don't know how I could delete a file from within a program. All I know is how to read and write to one.
>>
>>52067418
Jokes on you, I don't have a pet.
>>
>>52067423
System calls.
>>
>>52067429
me neither :(
>>
>>52067440
H-hold me anon ;_;
>>
File: fedora14.jpg (42 KB, 500x500) Image search: [Google]
fedora14.jpg
42 KB, 500x500
>>52067302
>- Lua
>- Elixir
>- Haskell
>- Clojure
>- D
>>
>>52067466
No way, that's gay you fucking faggot.
>>
File: trains.webm (3 MB, 1280x720) Image search: [Google]
trains.webm
3 MB, 1280x720
Ask your beloved programming literate anything.

>>52065753
Kawa has a nice support for explicit typing.

for example,
(define (f x y) (+ x y))
compiles to

Method name:"f" public static Signature: (java.lang.Object,java.lang.Object)java.lang.Object

Attribute "Code", length:61, max_stack:3, max_locals:2, code_length:9

0: getstatic <Field gnu.kawa.functions.AddOp.$Pl gnu.kawa.functions.AddOp>
3: aload_0
4: aload_1
5: invokevirtual <Method gnu.mapping.Procedure.apply2 (java.lang.Object,java.lang.Object)java.lang.Object>
8: areturn

Attribute "LineNumberTable", length:6, count: 1

line: 6 at pc: 0

Attribute "LocalVariableTable", length:22, count: 2

slot#0: name: x, type: java.lang.Object (pc: 0 length: 8)
slot#1: name: y, type: java.lang.Object (pc: 0 length: 8)


while
(define (f x::int y::int) (+ x y))
compiles to
Method name:"f" public static Signature: (int,int)int

Attribute "Code", length:56, max_stack:2, max_locals:2, code_length:4

0: iload_0
1: iload_1
2: iadd
3: ireturn

Attribute "LineNumberTable", length:6, count: 1

line: 17 at pc: 0

Attribute "LocalVariableTable", length:22, count: 2

slot#0: name: x, type: int (pc: 0 length: 3)
slot#1: name: y, type: int (pc: 0 length: 3)
>>
>>52067302
>no Ruby
naw
>>
>>52066753
go away Dan
>>
>>52067502
Lua is widely used as the scripting language for games since it's really fast and easy to embed. You're right about the rest though.
>>
>>52067502
how can that guy be a real person
>>
File: maymay242.png (422 KB, 3000x3000) Image search: [Google]
maymay242.png
422 KB, 3000x3000
>>
>>52067531
yeah, I know but it's very niche and his post did mention using it as your "primary language".
>>
File: memeswastika.jpg (38 KB, 519x409) Image search: [Google]
memeswastika.jpg
38 KB, 519x409
>>52067138
python implementation lads
>>
File: SCN_0001.jpg (355 KB, 1275x1650) Image search: [Google]
SCN_0001.jpg
355 KB, 1275x1650
>>52067166
i have intuited an algorithm but i'm too lazy to translate it into code
>>
>>52067523
Well that's pretty fucking shit then, innit? It doesn't correctly infer that x and y are ints (or a generic Number class).
>>
Reminder not to write the word "reported" in any post, because janitors will ban you for it even if you don't actually submit a report.
>>
>>52067671
you just did

enjoy ur ban ;^)
>>
Fuck, having done F# I can't be bothered to do my C++ assignment.

>>52067671
or saged or ignored or christmas
>>
>>52067657
>It doesn't correctly infer that x and y are ints (or a generic Number class).
no shit sherlock, there nothing to infer since it's resolved in the dynamic environment, but the jvm's JIT compiler could fix that at run time.
>>
>>52067630
Looks like simple bresenham circle's algorithm to draw the circle using a diameter of length - (word's length - the 3 interlapping points + 4 to keep it around the swastika) or a diameter of word's length+1. The swastika bit should be easy.

I reckon rather than printing it line by line (which might be somewhat possible). It might be easier to just store it all in an array before printing it as you'd have to calculate for both shapes at the same time
>>
GDB actually works bretty gud with Go. Didn't expect that.
>>
>>52067081
I just use C.
>>
>>52067227
and with GC
top kek
>>
File: 67779.png (26 KB, 154x167) Image search: [Google]
67779.png
26 KB, 154x167
>>52067302
>java not on the list
>clojure, D, elixir
>implying you can get employed with haskell
>>
>>52067705
>what is function +
Meanwhile any decent language can perform the inference, thus kawa's type system is absolute dogshit.
>>
>>52067817
Modern C++ uses GC or reference counting. GC is much faster than reference counting, hence D is better in that regard. Moreover, the GC can be removed temporarily when it matters.
>>
File: kill_yourself.jpg (40 KB, 290x290) Image search: [Google]
kill_yourself.jpg
40 KB, 290x290
>>52067838
>Modern C++ uses GC
OHOHOHOHOHO
>>
>>52067838
>Reference counting
>Slow
Only if you use the C++ std::shared_ptr because it uses atomic operatons and memory barriers to be thread safe. A non-thread-safe reference counting will be faster than GC any day.
>>
>>52067855
>>>/tumblr/
>>
>>52067860
Top fucking kek.
>there are people who actually believe this
Even shitty GCs like boehmgc are significantly faster than reference counting.
>>
File: tasty.jpg (134 KB, 750x733) Image search: [Google]
tasty.jpg
134 KB, 750x733
>>52067826
you missed the point, if you ask to disassemble
(define (f x y) (+ x y ))
, the compiler could only give you a generic version because you haven't provided any arguments (= nothing to infer). compiler infers when a function evaluation is made, like in

(define (f x y) (+ x y))

(f 4 5) ; arguments type is know, can infer this


that's basic stuffs.
>>
>>52066499
will it halt?
>>
>>52067888
Just because you're inbred doesn't mean reality needs to become as retarded as you are.
let fn x y = x + y;;
-| val fn : int -> int -> int = <fun>
>>
>>52067882
>Giving up deterministic destruction for either multi-threading or arbitrary global blocks when the GC triggers.
Those who would give up essential Liberty, to purchase a little temporary Safety, deserve neither Liberty nor Safety
>>
>>52067923
I laff'd, but see polyml, multimlton, F#, hasklel, etc.
>>
>>52067967
Makes sense for those languages that were designed for GC, but not C++.
>>
>>52067923
I think that quote would work better with the words reversed.
>Those who would give up essential Saftey, to purchase a little temporary Liberty, deserve neither Liberty nor Safety
>>
>>52067888
Type inference should easily be able to infer a type for a generic/polymorphic function.

For example, in Haskell, the function
plus x y = x + y

is easily inferred to have the type
plus :: Num a => a -> a -> a
>>
>>52067967
None of a functional language's safety comes from its GC. With a sufficiently strong type system, a language can be safer (I'm talking compiles? => correct) than all of those languages without any need for garbage collection.
>>
>>52068083
Sure, if you don't mind losing cyclic data-structures.
>>
>>52067910
nice try but + is a typed operator in ocaml while in lisp + is just a procedure like any other ones.
>>
>>52068118
Your stupidity is mind-numbing.
>>
>>52067819
>implying language of choice is or should be your language of employment
Java is only a language of employment. Nobody informed about anything would choose to use it for personal projects
>>
>>52068097
With sized types, you can retain them, you just won't be able to recurse over them directly (which, of course, is how you keep safety).

>>52068118
Why can't it have a type?
>>
>>52067166
                                                                        

MEMEMEMEMEMEMEM
EMEME EMEME
EMEM MEME
MEM ER MEM
ME ITL EM
EME ILH EME
M EHE E M
ME IL LIHEI EM
ME HI IH LHI EM
E TL LT TLE E
M ERE R M
E REL LE EL E
ME TIH IT TI EM
ME LIE LH HL EM
M HEI IE M
EME IEH EME
ME IHL EM
MEM ELT MEM
EMEM R MEME
EMEME EMEME
MEMEMEMEMEMEMEM
>>
>>52068156
It's beautiful anon
Truly 10/10
>>
>>52068156
14/88 needs a border
>>
>>52068156
didn't get the corner H right

                                                                        

MEMEMEMEMEMEMEM
EMEME EMEME
EMEM MEME
MEM R MEM
ME TLE EM
EME LHI EME
M HEI H M
ME EI IEEIL EM
ME LH HL HIT EM
E IT TI LER E
M LRL M
E RE TL LT E
ME LTI HI IH EM
ME HLI IL LI EM
M EHE EH M
EME LIE EME
ME TIH EM
MEM REL MEM
EMEM MEME
EMEME EMEME
MEMEMEMEMEMEMEM



>>52068190
sure thing, hang on. what do you want the text to say? it can't have spaces yet
>>
>>52068156
god fucking damnit, I'm jealous

now put a flag around it
>>
File: 1440582393914.gif (1 MB, 472x357) Image search: [Google]
1440582393914.gif
1 MB, 472x357
>>52068156
c-can i get source?
>>
>>52068150
in scheme, you are free to redefine + and the default one accepts all kind of objects (integers, reals (float), ...). in ocaml, + is reserved to integers while +. is reserved to reals. No question that the compiler infers
let fn x y = x + y;;
because of the operator +, x and y must be integers in any case.
>>
>>52068208
wait now it says HITLR at the center damnit
>>
>>52068229
>free to redefine +
That's not a problem, you'd just have to redeclare its type at the same time.

>the default one accepts all kind of objects (integers, reals (float), ...)
That's what the Num type class in Haskell is for.
>>
>>52068147
So you are telling me you can't do personal projects for Android.
>>
So, is /dpt/ hyped for Perl6?
>>
>>52068266
Isn't it already dead? I know I tried it out at some point and found that there were some nice things, but seriously, how could you pile up that much non-sense? Is anyone ever gonna make a quality implementation for such a mess?
>>
>>52068264
Java is not required for Android development, you can write apps in C++ just fine.
>>
>>52068264
Many languages support java, including the vastly superior c#(which will run up to 10 times faster on dalvik devices and the same speed +/- for ART capable devices). That costs money though but almost every respectable language can be used on android devices.
In fact java is one of the worst options for android
>>
swastikas are done

what's next lads? how can we meme further?
>>
>>52068300
the language is too big for there to be a quality implementation :^)
i wouldn't actually think about using it for anything but shell script-y shit
>>
>>52068229
You can also redefine + in ocaml, that doesn't change that the type inference works perfectly fine.
let (+) x y = x +. y
let f x y = x + y;;
val ( + ) : float -> float -> float = <fun>
val f : float -> float -> float = <fun>

Stop backpedalling and admit you don't have a single clue and that kawa's inference is dogshit.
By the way, even typed racket can infer this kind of type.
>>
>>52068328
Right the word MEME out of swastikas, which are made of the word HITLER
>>
>>52068365
dear sweet jesus
>>
NIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGR
E N
G MEMEMEMEMEMEMEM I
G EMEME EMEME G
I EMEM MEME G
N MEM LER MEM E
R ME HIT EM R
E EME EIL EME N
G M HE EHE M I
G ME IL LI ILH EM G
I ME HI IH ITL EM G
N E TL LT ER E E
R M ERE M R
E E LE EL E N
G ME REL IT TI EM I
G ME TIH LH HL EM G
I M LIEEI IE M G
N EME H IEH EME E
R ME IHL EM R
E MEM ELT MEM N
G EMEM R MEME I
G EMEME EMEME G
I MEMEMEMEMEMEMEM G
N E
RGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGIN


there is some off by one error with the cropping but it werks

class Meme {
public static void main(final String[] args) {
final String textCircle = "MEME";
final String textSwastika = "HEILHITLER";
final String textBorder = "NIGGER";
final int windowSize = 72;
final int cropLeft = 1;
final int cropRight = 0;
final int cropTop = 6;
final int cropBottom = 5;

final int xSize = windowSize;
final int ySize = windowSize / 2;
final char[] strCircle = textCircle.toCharArray();
final char[] strSwastika = textSwastika.toCharArray();
final char[] strBorder = textBorder.toCharArray();
final char[][] arr = new char[ySize][xSize];

final double scale = 21.5;

double theta = 0.0;

int strIdx = 0;

for(int i = 0; i < ySize; ++i) {
for(int j = 0; j < xSize; ++j) {
arr[i][j] = ' ';
}
}
>>
>>52068450
        double foo = Math.PI / 4;
arr[ySize / 2][xSize / 2] = strSwastika[strSwastika.length - 1];

for(int i = -1; i <= 1; i += 2) {
theta = 0.0;

while(true) {
final int x = (int) (scale * Math.cos(theta));
final int y = (int) (scale * Math.sin(theta)) / 2 * i;

theta += 0.0001;

if(theta > Math.PI) {
break;
}

if(arr[ySize / 2 - y][xSize / 2 + x] != ' ') {
continue;
}

arr[ySize / 2 - y][xSize / 2 + x] = strCircle[strIdx++ % strCircle.length];
}

for(int j = 0; j < 2; ++j) {
double armLength0 = 0.0;
strIdx = strSwastika.length - 1;
while(strIdx != 0) {
final int x = (int) (armLength0 * Math.cos(foo));
final int y = (int) (armLength0 * Math.sin(foo)) / 2;
armLength0 += 0.0001;
if(arr[ySize / 2 - y][xSize / 2 + x] != ' ') {
continue;
}
arr[ySize / 2 - y][xSize / 2 + x] = strSwastika[--strIdx % strSwastika.length];
}
double armLength1 = 0.0;
strIdx = 1;
while(strIdx != strSwastika.length) {
final int x = (int) (armLength0 * Math.cos(foo) + armLength1 * Math.cos(foo - Math.PI / 2));
final int y = (int) (armLength0 * Math.sin(foo) + armLength1 * Math.sin(foo - Math.PI / 2)) / 2;
armLength1 += 0.0001;
if(arr[ySize / 2 - y][xSize / 2 + x] != ' ') {
continue;
}
arr[ySize / 2 - y][xSize / 2 + x] = strSwastika[strIdx++ % strSwastika.length];
}
strIdx = 1;
foo += Math.PI / 2;
}

}
>>
>>52068464
        strIdx = 0;
for(int x = cropLeft; x < xSize - cropRight; ++x) {
arr[cropTop][x] = strBorder[strIdx++ % strBorder.length];
}
for(int y = cropTop; y < ySize - cropBottom; ++y) {
arr[y][xSize - 1 - cropRight] = strBorder[strIdx++ % strBorder.length];
}
for(int x = xSize - 1 - cropRight; x >= cropLeft; --x) {
arr[ySize - 1 - cropBottom][x] = strBorder[strIdx++ % strBorder.length];
}
for(int y = ySize - 1 - cropBottom; y > cropTop; --y) {
arr[y][cropLeft] = strBorder[strIdx++ % strBorder.length];
}

int top = 0;
int bottom = 0;

for(final char[] line : arr) {
if(top++ < cropTop | bottom++ >= ySize - cropBottom) {
continue;
}

int left = 0;
int right = 0;

for(final char ch : line) {
if(left++ < cropLeft | right++ >= xSize - cropRight) {
continue;
}

System.out.print(ch);
}

System.out.println();
}
}

}
>>
>>52068350
works fine because you are still using a typed operator (+.), that's not a generic function.
>>
contemplating whether it'd hurt or help to show my coworkers an anon's nigger meme heilhitler swastika flag implementation
>>
>>52068479
1/10 if trolling, 1000/10 if retarded.
>>
>>52068479
>>52068249
>>
>>52068621
Is there a decent fast fixed point math library for sepples?
>>
>>52068504
it's you who are retarded. an equivalent of scheme's + in ocaml would be something like

type num = Int of int | Float of float

let add (x : num) (y : num) = x + y


you can't infer that.
>>
>>52068641
gmp
>>
int avg(int a, int b)
{
return b != 0 ? a / 2 + b / 2 + (a % b % 2) : a / 2;
}
>>
>>52068677
[retardation intensifies]
>>
>>52068703
Doesn't have fixed point. Only floating point and numerator/denominator rationals.
>>
>>52068677
http://withouttheloop.com/articles/2014-10-21-fsharp-adhoc-polymorphism/
http://stackoverflow.com/questions/15690053/impredicative-polymorphism-in-f
>>
Is there anything more comfy than settling in with your favourite language, with your favourite beverage, and solving problems using your ingenuity, a bit of math, and some hacks.

I admit, I'm code-monkey tier atm, but I'm perfectly happy just finding the best design principles and making sure my code is readable and maintainable.
>>
>>52068304
You know what JNI is right? If you use C++ you have to expose functions and write a lot of boilerplate. is not just writing C++ like if it were C++/CX.
>>
>>52068926
Skool m8

so much suffering
>>
>>52068321
Runs at about the same speed. Post benchmarks and prove it.
>>
>>52068215
he did it by hand, idiot.
>>
>>52068945
Im in school too. I found a job relating to my field, well into the end of first of year. Definitely saved me, because focusing on pure school work can get tiresome. Need something related, preferably where you can earn some money, to focus your mind on, instead of the same old thing everyday.
>>
>>52068951
>C# and java tun at the same speed
What are value types for $100 please alex.
That alone makes the JVM useless for computation.
>>
reminder that if you're using OCaml without https://github.com/ocamllabs/ocaml-modular-implicits you're not doing it right
>>
>>52068990
OCaml is a meme language?

Who uses it in production?
>>
>>52068988
I don't see your benchmarks. What are you, 12?
>>
>>52068951
http://xamarinandroid.blogspot.ie/2014/08/performance-comparison-between.html
>>
>>52069018
>Needing benchmarks to know that using the stack for small objects is orders of magnitude faster than the heap.
M E M E
E
M
E
>>
>>52069023
> Posts unknown nigger blog with numbers without reference.
What the fuck those numbers mean?
Are you a retard?
>>
>>52069038
What are you afraid of? Why don't you show the reality you are defending?
>>
>>52069038
>using unportable principles instead of benchmarks
>implying there is a stack
>implying there is a heap
>implying the stack is faster
>>
>>52069042
It literally posts the code before it shows the results you fucking retard.
>>52069053
You've already been proven wrong you retard. You were just to busy and retarded calling people retards to read the thing you called retarded. Retard
>>
>>52068926
I know that feel lad. I do support and software engineering (installations, upgrades) for my company since the development department is chock-filled. This holiday, there's been nothing more fun than solving adventofcode, codeeval, hacker.org challenges, etc in my favourite language with some nice bourbon on the rocks or some wine
>>
>>52069000
a ton of people use it for MirageOS which is the most popular unikernel for Xen right now (http://www.xenproject.org/developers/teams/mirage-os.html)
Jane Street uses it for finance shit, Facebook uses it for static analyzers and compilers, INRIA uses it for Coq, etc.
also, check'd
>>52069042
read the other blog posts
they rewrote android in C# (https://github.com/xamarin/XobotOS/) a few years back and then they found that it was a whole order of magnitude faster (https://blog.xamarin.com/android-in-c-sharp/). xamarin compiled apps still run faster (http://magenic.com/Blog/Post/4/Mobile-Development-Platform-Performance) on average and there's a ton more room for improvement when you remember that there's shit like value types, manual memory management, p/invoke, and so on to help you further improve performance
>>
>>52068939
Yes but you don't have to write in Java per se, that's the point.
>>
I'm trying to include my C header file in C++ code, but it's not working out.
I've added the
extern "C"
thing, I've tried compiling the C code with both gcc and g++ just to test that it actually works, but it still only throws a bunch of "undefined reference to" during compilation.

Any ideas on how to fix it?
>>
>>52069173
not sure if this is the way it works in c++, but did you do extern AND import?
>>
>>52069173
You need to add "-lLIBRARY" to your g++/gcc call. Replace LIBRARY with the name of the library.
>>
>>52069184
That's what I have, not sure what you mean by "import":
extern "C"
{
#include "csll.h"
}


>>52069192
It's not a library, it's a local file. Either way, I tried it and it couldn't find anything.
>>
>>52069173
Are the reference errors related to external library or the standard?
>>
>>52069224
Post the linker errors here then.
You are missing a library for sure.
>>
>>52069241
C++ code:
extern "C"
{
#include "csll.h"
}

int main()
{
SLList *newl = newlist(0);
return 0;
}


csll.h:
...
SLList *newlist(unsigned int data);
...


Output of
g++ -std=c++11 -fpermissive -o test csll.c test.c
:
/tmp/ccX9BdMH.o: In function `main':
test.cpp:(.text+0xe): undefined reference to `newlist'
collect2: error: ld returned 1 exit status
>>
>>52069132
javadroids: rekt
>>
>>52069311
>-fpermissive
NO. FUCK NO.
Take that out and fix the fucking error it is suppressing. In fact, replace it with -Wall -Wextra.
>>
>>52069328
Dude, not now. I'll take it out when I get through the dumb errors and have at least something that works.
Also, that thing that it's suppressing works fine in C.
>>
>>52069371
You are purposefully telling the compiler "fuck you, compile my shit code that you know is broken" then complaining that your code is broken.
>>
Is anyone willing to look at almost 200 lines of messy C atmega328p code
>>
>>52069311
Why are you passing C files to the C++ compiler.
You probably need extern "C" in your csll.c file too (or compile it with gcc to an object, then use g++ on your c++ files and C objects).
>>
>>52068859
the generic version is inferred when a call is made. the article says

// this version works!
let inline twice x = x + x

twice 2.0 |> Console.WriteLine
twice 2 |> Console.WriteLine

Each call to the inline function is replaced by inline code with its own
type inference, thus the compiler effectively converts the above to:

(fun (x:float) -> x + x)(2.0) |> Console.WriteLine
(fun (x:int) -> x + x)(2) |> Console.WriteLine


this is what i have said here >>52067888
>>
>>52069389
It's not broken, it alone compiles fine with g++. It's not the issue, chill out.

>>52069406
Because I wrote C code and now I want to use it in C++ code with minimal changes. Now that I'm thinking about it, kinda dumb to do that. But it's 2AM, what the hell do I know.
>>
>>52069429
thought you were talking about something else

(btw the different examples work in different ways)
>>
>>52069443
Compile your C file into a static C library, and put
#ifdef __cplusplus
extern "C" {
#endif
...
#ifdef __cpluspluc
} // extern "C"
#endif

in the header, or scrap all the extern "C" fun and make it compile as valid C++ WITHOUT FPERMISSIVE and do what you were doing.
>>
>>52069389
You blatantly have no idea what you're talking about
>>
This might be a retarded question, but why isn't the stack size much larger on 64bit systems?
>>
>>52069132
Of course Xamarin is going to defend Mono. And say it's 100 times better than Java for Android. Is their product.

Here you have unbiased benchmarks.
http://benchmarksgame.alioth.debian.org/u64q/csharp.html
>>
>>52069652
Not really needed.
Pointer size is doubled, which makes stack frames bigger, but it's incredibly rare the stack size is an issue unless you have unbounded recurstion.
>>
>>52069803
that's on a desktop. the JVM is a lot faster than Dalvik and ART. the reason Android is so laggy is because google thought it would be a good idea to make their own shitty runtime when better ones already existed
>>
>>52069311
> Output of
> g++ -std=c++11 -fpermissive -o test csll.c test.c

You're compiling both files as C due to the ".c" extension.

If a file contains C++ code, it needs to have a .cpp, .cxx, .cc or .c++ extension. Or you need to use "-x c++" (and then all files must be C++).
>>
>>52069905
I changed some names, that file had .cpp.
>>
>>52069825
yeah and they had literally one or two guys working on it... like what the fuck gjewgle
>>
is there a program that will get rid of my post-Christmas hangover?
>>
File: image.jpg (2 MB, 3264x2448) Image search: [Google]
image.jpg
2 MB, 3264x2448
This might be the wrong place to ask so let me know if it is.

On the left is a book I need for class next semester. On the right is one I got back in 2005 or so. Are there any other good textbooks or resources for C++ that I should take a look at which will help me? The only other languages I know are HTML and PHP for vBulletin boards I ran as a teenager. Thanks.
>>
>>52069990
Write C++ code, that will teach you the most.
>>
How would I go about making a shell script that sets to a default xrandr setting once the vga is plugged in?
>>
>>52069803
Android does not use the oracle JVM. It doesnt even use embeded java. It should, because both of those are insanely faster than dalvik, not sure about art. The oracle JVM, for all it's other faults, is actually miracle of optimization technology thanks to Hotspot
>>
>>52069803
>unbiased
Without looking at the code it seems like java was multithreaded while C# was not.
binary-trees

secs KB gz cpu cpu load
C# Mono
24.59 163,812 654 26.21 7% 0% 100% 1%
Java
5.75 354,364 583 8.17 41% 48% 37% 19%
>>
>>52070130
dalvik is already fast enough for mobile apps. when you need high performances, you go native.
>>
>>52069990

Get the 5th edition. A lot has changed since 2005.
>>
>>52070230
actually, the code is mostly the same with no explicit parallelization for both.
>>
>>52070237
>dalvik is already fast enough for mobile apps.
Except it isn't. Android has been having crippling performance issues for years and even in the last few versions they pop up more than the competing platforms. Much of it was due to their shitty VM
>>
>>52070230
>>52070271
implementations with explicit parallelization is even doing worst but java still faster.

Java    #5    6.20   524,828   926 20.90   87% 91% 82% 80% 
C# Mono #3 47.64 718,784 723 81.08 41% 46% 43% 38%
>>
>>52070230
You can look a the code, it's basically identical. I suspect mono just doesnt utilize multicore cpus as well. If it were .net it would likely be a closer result,
>>
So /dpt/, if you're doing something and you see that there's already libraries for doing it - do you use one of them or write it yourself? This is assuming you do know how to do it yourself and you won't gain anything knowledge-wise by writing it yourself
>>
>What are you working on, /g/?

Using codeeval to teach myself python3, if i don't have a task i lose interest immediately.

dont know if this is the best way but its my current method of learning:
>Read challenge
>Concoct general attack plan
>Begin coding
>Hit snag
>Read related python method pages
>Light googling for examples of what I want
>Deconstruct example
>Build my own implementation
>Test 6000 times for syntax errors and poor typing
>Submit code
>>
>>52070412
Write an IRC bot, they introduce you to a lot of different concepts and offer a lot of natural room for expansion if you have trouble thinking of things to do yourself.
>>
>>52070411
There are some tasks where learning a special library is slower than writing it yourself. If the library was to use, bug-free, and had a committed maintainer, I'd use it.
>>
>>52070246
This wouldn't be an issue if he chose a more sane language like C.
The latest edition was published 1989 and is still very relevant.
C99 and C11 can be gleaned from the wikipedia page.
>>
>>52070442
I was thinking of trying to write scripts for HexChat, it has a python library, but it would only be simple shit like a locally maintained ban list that refreshes on channel join.
>>
>>52070412
Please tell me it isn't your first language
>>
>>52070513
>>52070246

I'm interested in learning C as well but this is what I learn next semester. I'll shelve that edition then and look at getting a more recent one (this copy is from 2005). Any other decent resources?
>>
>>52070412
>begin coding
You mean programming
>>
>>52070513
C is also a borderline dead language.
>c
>sane
C is the epitome of bad design choices that people have slowly removed from public knowledge through propaghanda
>>
>>52070582
It's the same thing moron.
>>
>>52070581
Learn C now.
It's a tiny language in comparison.
The standard library and all of it's quirks are small enough to commit to memory.
How big is your C++ primer book?
>>
>>52070608
>C
>Dead

I came here to laugh at you.
>>
>>52070608
That's great senpai, what is your compiler or interpreter for your favorite language written in?
>>
>>52070557
Yes and no, Iv had experience with a bunch of stuff since i started dabbling in school, first language was C. This is the first time im taking learning seriously though.
>>52070582
Is there really a difference or is this just sperging
>>
>>52070582
Programming is by definition a form of coding.
>>
>>52070634
>machine automation has replaced humans in car manufacturing
>HAHA WHO BILLDS THE ROBOS?
>>
>>52070614

The primer is about 800 pages, the required text for class is 900. If C is easy to get into Ill try to learn as much as I can over the next 3 weeks.
>>
>>52070672
it's 200 pages
>>
File: codeeval.jpg (65 KB, 869x593) Image search: [Google]
codeeval.jpg
65 KB, 869x593
niggas wanna be me

but for real, just started this, it's fun as hell and challenging enough
>>
I want to get a certificate of mastery of VB.NET!!!!
>>
>>52070672
C fags love to be misleading. C is a small language. It is not an easy language. By the very nature of being small it's tedious and opens up huge areas of potential bugs.
That doesnt mean you shouldn't learn it. It just means keep in mind that when retards say c is easy, what they actually mean is the syntax is easy to memorize, not that using it to produce anything of value is easy. C is a necessary evil, and an excellent way to understand the computer.
>>
>>52070686
heh
>>
If you want to code in C, may as well go full autist and do assembly, it's much more fulfilling and you'll achieve just about as much if you're good enough imo (in my opinion) lad
>>
>>52070758
>i have never written assembler or C before
>>
>>52070767
weirdly enough, I have
>>
>>52070686
there's only 6000 people on codeeval
>>
>>52070784
please just let me have my 5 seconds of fame
>>
>>52070784
default view is ranking from the last 6 months
there's 6000 active users in the last 6 months.
>>
>>52070781
then you would know that C compiled using an optimizing compiler bears very little relation to assembler that you would write by hand
>>
>>52070819
that's still not a lot
>>
NIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERNIGGERN
R|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||I
E|||||||||||||||||||||||||||||||MEMEMEMEMEMEMEM|||||||||||||||||||||||||||||||G
G|||||||||||||||||||||||||||EMEME EMEME|||||||||||||||||||||||||||G
G||||||||||||||||||||||||EMEM ER MEME||||||||||||||||||||||||E
I||||||||||||||||||||||MEM TL MEM||||||||||||||||||||||R
N|||||||||||||||||||||ME HI EM|||||||||||||||||||||N
R|||||||||||||||||||EME IL EME|||||||||||||||||||I
E|||||||||||||||||||M HE EH M|||||||||||||||||||G
G||||||||||||||||||ME IL LI IL EM||||||||||||||||||G
G|||||||||||||||||ME HI IH HI EM|||||||||||||||||E
I|||||||||||||||||E TL LT TL E|||||||||||||||||R
N|||||||||||||||||M RE ERE ER M|||||||||||||||||N
R|||||||||||||||||E LT TL LT E|||||||||||||||||I
E|||||||||||||||||ME IH HI IH EM|||||||||||||||||G
G||||||||||||||||||ME LI IL LI EM||||||||||||||||||G
G|||||||||||||||||||M HE EH M|||||||||||||||||||E
I|||||||||||||||||||EME LI EME|||||||||||||||||||R
N|||||||||||||||||||||ME IH EM|||||||||||||||||||||N
R||||||||||||||||||||||MEM LT MEM||||||||||||||||||||||I
E||||||||||||||||||||||||EMEM RE MEME||||||||||||||||||||||||G
G|||||||||||||||||||||||||||EMEME EMEME|||||||||||||||||||||||||||G
G|||||||||||||||||||||||||||||||MEMEMEMEMEMEMEM|||||||||||||||||||||||||||||||E
I|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||R
NREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGINREGGIN


http://pastebin.com/Nc5fj4Y2
>>
>>52070832
That has literally nothing to do with why what he said was stupid
>>
>>52070832
Yes I thought it clear that I was talking about the learning opportunities of both
>>
>>52070855
>two of the arms says HILHITLER
well fuck... but i'm done, at least for today

nice meme idea anon
>>
>>52070840
This is the salty response of someone ranked 5000
>>
>>52070886
>muh code rankings
>implying serious programmers use that shit
>>
spent the past 8 hours trying to port the pecl dbase extension to php7, without knowing c before.

Anyone wants to try to help and compile it, and find out why it crashes when you try to call a function? I gave up while trying to install a debug php environment https://github.com/mote0230/dbase-pecl-php7
>>
>>52070911
>muh uncompetitive nature because I'm a pussy-whipped bitch
>>
>>52070911
No, serious programers don't even care about that shit. Your saltiness shows you care, which makes you a shit programmer
>>
>>52070922
>>52070935
>muh "competitive coding"
>thinks he's even slightly good at programming
>doesn't even have a maths degree
>>
File: cute anime pic 0636.png (289 KB, 514x424) Image search: [Google]
cute anime pic 0636.png
289 KB, 514x424
>>52070935
https://www.codeeval.com/open_challenges/1/
>fizzbuzz
>failure rate 49%

it's ok anon, some people are just born to copy paste other people's working code
>>
>>52070977
>doesn't even have a maths degree
true, but I was on tv and the guardian for my mathematical achievements when I was 11. I chose computer science instead
>>
>>52071003
>I chose computer science instead
SAD!
>>
>>52071021
I'm much happier with my programming/engineering job than I would be with maths tbhfwyl (to be honestly fair with you lad)
>>
>>52070988
>goes straight into damage control when called out
Of course your an animefag too.
>>
Anyone with VS willing to take a look at what I've got and tell me how bad I am?

I'm trying to improve but having 0 knowledge and no frame of reference means I'm really not sure how bad it really all is.

https://github.com/sirdoombox/Musick
>>
>>52070608
>C is a collection of bad choices
I agree to some extent, but we were talking about C++ which not only kept those bad choices but made several new bad choices
>>
>>52071064
>but made several new bad choices
not this newbie programmer meme
>>
I just reverse-engineered microsoft's paint image stretching algorithm, without looking at the source code for any similar programs.

Do you guys think a little blogpost about it would be interesting? It's not particularly hard, but I found the "intuitive" way to think about it to be misleading.
>>
>>52071088
Compare C++ with D fag
>>
>>52071117
sure
>>
>>52071124
>D
It really is meme hour
>>
>>52071064
It's begun to rectify it at least. C is basically dead developmentally and survives as a language by necessity. C is important but only neets think it's actually 'good'.
Thread replies: 255
Thread images: 32

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.