[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: 26
File: hidamari_dpt_waifu2x_traps.png (2 MB, 1618x1308) Image search: [Google]
hidamari_dpt_waifu2x_traps.png
2 MB, 1618x1308
Old thread: >>52926461

What are you working on /g/?
>>
An aviation club management software in ASP.NET
>>
Cropping assets myself. Fucking designers...
>>
I'm challenging myself to write an efficient fizzbuzz. I'd be interested to see how fast other anons can make it.

Maybe this can be a challenge for the thread?
>>
Anything out there to learn how to use SDL with C, or is literally fucking everything out there using abortion++?
>>
>>52934963
90% of the overhead will just be the act of printing it, and the different solutions will be immeasurable microseconds apart.
You can't really benchmark super trivial programs.
>>
File: GT8VBty.png (15 KB, 124x758) Image search: [Google]
GT8VBty.png
15 KB, 124x758
>>52934914
Android app using Xamarin.

>tfw 16GB RAM
>>
>>52934990
>implying he can average 2 ints
ishyggy
>>
How do i get the decimal value of a float/double:
Ex.
2.5 would return 0.5
5.25 would return 0.25
-5.05 would return -0.05

Last one isn't mandatory.
>>
>>52935006
damn, you're beyond retarded
>>
>>52934990
Haven't worked through all this but it seems to be mostly C-like C++.
http://lazyfoo.net/tutorials/SDL/index.php#Hello%20SDL

>>52935000
Was thinking that, is there another problem that would make more sense to practice optimisation with?
>>
>>52935006
x.toString().split('.')[1].toInt()
:DDDDD
>>
>>52935006
Depending on your language, the easiest way to do it is to convert to string and split on the decimal point.
>>
>>52935006
Are you serious?

You could just send it to a string and grab everything after the "." and then parse it back into a double/float.
>>
>>52935028
>Was thinking that, is there another problem that would make more sense to practice optimisation with?
Most of Project Euler, ya dingus.

Those were made with optimization in mind.
>>
>>52935006
Why the fuck is everyone suggesting strings? Is this a joke I misses? just check if it's negative and modulo 1.
>>
>>52935006
Jesus son, you never go full retard.

Round down (specifically towards zero, however your language does that) to the nearest int, minus the int from the float, and there's your decimal part.
>>
>>52935057
Because it's easier to use the string method.

Exactly the same output, and done far more simply.
>>
>>52935006
float x = 3.14
float fractionalPortion = x - Math.Truncate(x);
>>
>>52935063
Is this subtle trolling? Taking modulo 1 is far faster than creating a fucking string and searching for a dot.
>>
>>52935001
>android
>xamarin
bloat on top of bloat
>>
>>52935058
this, faggots suggesting converting to string are even more retarded than the guy who asked the question.
>>
>>52935033
>>52935042
>>52935045
>>52935063
Good luck using strings when your shitty FP precision evaluates to 0.49999999999
>>
File: 1419276460727.jpg (61 KB, 500x539) Image search: [Google]
1419276460727.jpg
61 KB, 500x539
>TLOP still hasn't dropped
>>
>>52935057
because "memejs developers"
>>
File: 1391233690751.jpg (161 KB, 920x662) Image search: [Google]
1391233690751.jpg
161 KB, 920x662
Why do "scripting language" syntaxes universally suck cock? They try to simplify the language and end up making it unintuitive and clunky as fuck

batch sucks cock
bash sucks cock
AHK sucks cock
>>
>>52935006
depends on the language. some languages allow (f % 1.0f). or do something like this: >>52935058
>>
>>52935006
Here is the C solution, with the last case being handled correctly.
n - copysign(trunc(n), n)
>>
>>52935105
format it with "%.3f" first breh
>>
>>52935057
>>52935124
>>52935094
The only issue with using modulo is that the way it is implemented for negative numbers is language specific.

It's a perfectly elegant solution if negatives are handled correctly, but if you need an if statement then you may as well just do it manually with >>52935058
>>
>>52935057
I swear these guys must be trolling him ...
>>
>>52935054
It'd be nice if they timed the solutions for me. I know of a few other sites that do though.
>>
>>52935179
Write your own.
>>
Hello, /dpt/.
Just popping in to wish you all a good friday and to provide some sound advice.
When you're having a bad day, I want you all to remember: bitches ain't shit, but ho's n trix.
>>
>>52935204
But then how will I compare my times to other peoples? Having a standard timer is important.
>>
>>52935151
here's the better C solution: fmod(n, 1)
>>
I want to try the functional programming meme.
Is Haskell a good choice for my first functional language?
>>
>>52935212
I'd like to add to that: 2d is better than 3d.
>>
>>52935262
No, it isn't, you fucking manchild. Don't ever fucking reply to me again unless you're contributing to the thread.
>>
>>52935278
>contribut
>animu
>>
>>52935294
That was my point. Animu is not contribratu.
>>
>>52935306
>animu
>gee
>not contrabing
ishyggy
>>
>>52935028
>C-like C++
disgusting
>>
>>52935309
>>>/a/
>>
File: Screenshot_2016-02-12_23-52-50.png (313 KB, 640x502) Image search: [Google]
Screenshot_2016-02-12_23-52-50.png
313 KB, 640x502
>>52935028
>going through the second example
>get a bmp of stallman onto the screen for 2 seconds
>program segfaults
God it's good to be getting back into C
>>
>>52935357
>/a/
this is 4chink, m8, animu is everywhere, fgt
>>
>>52935392
>>>/highschool/
>>
>>52935330
Ad long as it's still in C it's fine for me, since there is a limit on how far you can go doing OOP in it, with cpp you end up with lazy smart pointers and Boost shit.
>>
>>52935408
m8, you don't know what you're talking about
>>
>>52935392
>>>/a/
>>
>>52935419
/g/ is just as good
>>
>>52935432
Describe to me in 8 words or less, without using memes or meme arrows, what anime has to do with programming.
Aaaand GO.
>>
>>52935451
Anime has little to do with programming, outside of some fringe subject matter within some shows.

However, pairing on-topic comments with an image that is anime-style art to help illustrate your mood, tone, or reaction is generally accepted on all boards of 4chan, as the site is rooting in and caters to those who enjoy that particular aesthetic.

You're right, anime basically has nothing to do with programming, and anyone just posting anime for the sake of posting it is a faggot. However, sperging out on these morons, rather than simply hiding the post and going about your business, does two negative things: it gives them attention, and makes the thread even more shitty.

tl;dr: everyone is a faggot, just ignore it if you don't like it or you're part of the problem too
>>
>>52935415
Shut the fuck up if you don't know what he is talking about, it was pretty clear he was taking about C and Cpp
>>
>>52935496
I don't believe I was sperging. I was humoring.
Also, nice, that's 100% 8 words or less.
Don't ever fucking blah blah etc im drunk at work and it's only 9am.
>>
>>52935512
>8 words

Anime not programming, fine in general on 4chan.
>>
>>52935451
4chan = animu. done.
>>
Whats a Good example of a dynamic array of structures in C? Without memory leaks?
>>
>>52935505
>was pretty clear he was throwing random words
ftfy
>>
>>52935451
None, /g/ is infested with weaboos.
>>
>>52935546
What's a good example of red cars? Without accidents?
>>
>>52935546
struct* stru = malloc(sizeof(struct) * num);
free(stru);
>>
>>52935561
>knowingly coming to a website dedicated to anime
>can't stand anime
are you mentally ill, anon?
>>
>>52935575
>bothering with free instead of letting the OS do the job
baka
>>
File: image_zpsxpgqwwqb.jpg (104 KB, 800x600) Image search: [Google]
image_zpsxpgqwwqb.jpg
104 KB, 800x600
>>52935568
>>
>>52935575
>sizeof(struct)
do you even?
>>
>8 words or less
if problem with images on imageboard fuck off

>working on
trying to figure if termux + python can compile apk's ON android phone.
>>
>>52935583
>only doing script-tier "programs" that do one simple task and then exit
>>
>>52934963
#include <stdio.h>
#include <unistd.h>
#include <inttypes.h>

#ifndef TARGET
#define TARGET 100
#endif

#ifndef BUFLEN
#define BUFLEN 100
#endif

static char buffer[TARGET * BUFLEN];


int main()
{
register uint_fast16_t i __attribute__ ((aligned(16)));
register uint_fast16_t j __attribute__ ((aligned(16)));
register char* pos = buffer;
register char* end = buffer + (TARGET - 1) * BUFLEN;

const char* format[] = {
"FizzBuzz\n",
"%"PRIu16"\n",
"%"PRIu16"\n",
"Fizz\n",
"%"PRIu16"\n",
"Buzz\n",
"Fizz\n",
"%"PRIu16"\n",
"%"PRIu16"\n",
"Fizz\n",
"Buzz\n",
"%"PRIu16"\n",
"Fizz\n",
"%"PRIu16"\n",
"%"PRIu16"\n",
};

for (i = j = 1; i < TARGET; ++i, ++j)
{
if (j == 15)
{
j = 0;
}

if (pos >= end)
{
write(0, buffer, pos - buffer);
pos = buffer;
}

pos += sprintf(pos, format[j], i);
}

write(0, buffer, pos - buffer);

return 0;
}

>>
>>52935540
Nice reading comprehension. This is what anime does to the brain.
>>52935532
This thread has a topic already.
>>52935561
Agree fully.
>>52935597
There were no images. Weebshits, ladies and gentlemen.
>>
Here's an easy puzzle to warm you up.

Santa is trying to deliver presents in a large apartment building, but he can't find the right floor - the directions he got are a little confusing. He starts on the ground floor (floor 0) and then follows the instructions one character at a time.

An opening parenthesis, (, means he should go up one floor, and a closing parenthesis, ), means he should go down one floor.

The apartment building is very tall, and the basement is very deep; he will never find the top or bottom floors.

For example:

(()) and ()() both result in floor 0.
((( and (()(()( both result in floor 3.
))((((( also results in floor 3.
()) and ))( both result in floor -1 (the first basement level).
))) and )())()) both result in floor -3.

To what floor do the instructions take Santa?

Instructions: http://adventofcode.com/day/1/input

How efficient can you make this, /dpt/?
>>
>>52935621
>register uint_fast16_t i __attribute__ ((aligned(16)));
>I don't know what the fuck I'm doing
>>
>>52935635
>How efficient can you make this
++
--
done
>>
>>52935647
It's meant as a joke, anon.

>benchmarking fizzbuzz non-ironically
>>
>>52935659
>I was only pretending to be a retard
sure thing, m8
>>
>>52935647
let's for once and for all dispel this fiction that anon doesn't know what he's doing. he knows exactly what he's doing. he's trying to make /dpt/ more like other subreddits. if i'm elected as the president of the united states, i'm going to focus on what /dpt/ makes the greatest subreddit in the world.
>>
>>52935635
int floor = 0;
foreach (char c in input) {
if (c == '(') {
floor ++;
} else {
floor--;
}
}
return floor;


>How efficient can you make this, /dpt/?
You have to check every char so O(n) at best.
>>
>>52935685
>O(n)
>efficient
ishyggy
>>
>>52935714
let's see you do better
>>
>>52935726
take your homework to stackoverflow, fgt
>>
>>52935726
Don't mind him, he's spent the entire duration of the thread posting 'ishyggy'; not even Christian could meme this hard.
>>
>>52935673
>believing that using register isn't a meme
>believing that using __attribute__((aligned)) on a fucking integer isn't a meme
Lurk more

It was the big joke of the /dpt/'s yesterday, where one of the threads derailed completely because anon had used "register uint_fast16_t". If you don't believe me, feel free to browse the archives.
>>
>>52935685
If we rely on input of only "(" & ")" we can check for only one of them and compare top the size of the string. Rather than comparing each character at most twice like you're doing
>>
>>52935740
>implying it it's homework and not an advent of code question with probably a bazillion solutions all over the internet
>implying >>52935685 isn't a perfectly fine solution
>implying this hard
>>
>>52935748
>believing
>believing
fuck off with your assumptions, shitsperg
>>
File: 1455161641782.jpg (111 KB, 1039x1191) Image search: [Google]
1455161641782.jpg
111 KB, 1039x1191
>>52935635
This is an american puzzle if I've ever seen one
>>
>>52935757
>perfectly fine solution
webcucks, everyone
>>
Anyone taking a look at the new Amazon game engine?

Also, any recommendations for game engines generally?
>>
>>52935754
he is already comparing each char at most once you dip

c != ')' instead of c == '(' might save like one instruction depending on the architecture
>>
>>52935006
x-int(x)
>>
>>52935762
>getting upset over a fizzbuzz
>>
>>52935781
Oh. oops. teehee
>>
>>52935769
so you expect me to believe there is a better solution even though you have nothing to show
>>
>>52935785
>seeples
>what is range
back to wdg
>>
>>52935754
>Rather than comparing each character at most twice like you're doing
Nah it's just the one if statement, the else doesn't add another comparison after it gets compiled. Besides you would have to call input.Length(), which in some languages would be calculated there and then, in others it's stored in the string object but it still has the overhead of a function call. And yeah my code also relies on correct input, that's why it can use else instead of else if.
>>
>>52935774
>Amazon's free game engine could legally run nuclear reactors during zombie attack
what the fuck are they on about

what are the key features, pros and cons of it?
>>
>>52935799
>prove me wrong
fuck off
>>
>>52935593
not that guy, but what's wrong there?
>>
>>52935811
ok kid
>>
>>52935806
>what the fuck are they on about
I think the point is that the language meets or exceeds arbitrary standards required by some committee for languages used in potential high-damage failure enviroments.
>>
>>52935781
But then he's going through an arithmetic operation for each character, instead of for only one of them. His code has a better worst case by 2 additions, but mine has a statistically lower expectation
>>
>>52935806
>"However, this restriction will not apply in the event of the occurrence (certified by the United States Centers for Disease Control or successor body) of a widespread viral infection transmitted via bites or contact with bodily fluids that causes human corpses to reanimate and seek to consume living human flesh, blood, brain or nerve tissue and is likely to result in the fall of organized civilization," the rules state.
fucking normies, putting corny ass jokes in the probably already long legalese terms of conditions, wasting everyone's time

who even thinks zombies are funny or cool?
>>
>>52935817
struct doesn't refer to anything

It makes just about the same amount of sense as doing

sizeof(if)
>>
>>52935408
Cpp is the farest end of OOP
There is a reason that every desing pattern is demobstrazed with cpp
Dumbass script kiddie
>>
>>52935837
what? write some pseudocode

you'll have to check every char no matter what, you can't just check one and infer the rest
>>
>>52935869
>can't just check one
csscuck confirmed
>>
>>52935774
>And while Amazon stresses that developers don't have to buy server time from them (it's not needed for single-player games, for example, or if companies have their own private servers), they're not allowed to use rival cloud services from companies like Google or Microsoft.
how could this possibly be okay in the european union

or is it for murriburgers only
>>
>>52935837
Until you account for floor -= input.Length(); anyway. Then you're at the point where it depends on the size of n, and I could make a multithreaded version and claim it's better for large n. Either solution is fine so long as the language you are using doesn't have to do another pass through the string for input.Length();
>>
>>52935859
>Cpp is the farest end of OOP
bwahahahaha
>>
>>52935900
if you have 9 characters

you check one and it's a '('

what are there remaining 8 characters?

not sure if trolling or straight up retarded
>>
>>52935917
>I could make a multithreaded version
do it
>>
>>52935935
>I'm a certified moron
>>
>>52935848
The best way is
Mystruct *my_struct = calloc(1, sizeof(*my_struct));
>>
>>52935848
No shit, it was an example.
>>
>>52935774
>Lumberyard can create games for Windows, Xbox One, and PS4, and the company says support for Mac, Linux, iOS, Android, and the Oculus Rift are all "coming soon." Its visuals technology is based on CryEngine, a set of popular and powerful development tools that the company licensed from Crytek, and includes all the usual bells and whistles — from particle effects and and real-time water dynamics, to "vegetation tools" for super-realistic plants (presumably).
>""""""""coming soon""""""""
>iOS*, Android* (*runs like ass)
so i'm guessing it's pretty much a repackaged cryengine 3 but with their web services built in. no thanks
>>
>>52935869
Floor = 0
for c in string
If c == "("
Floor ++
Floor += len(string) - Floor

My code only goes through an addition operation on the True condition. His goes through addition for every check. Unless the string were entirely "("s or very short my suggestion would have fewer additions
are you following our am I mistaken?
>>
>>52935935
>not sure if trolling or straight up retarded
Probably both, ignore him.
>>
>>52935961
kill yourself
>>
>>52935993
unless you're given the length of the string you'll have to do additions to count the length anyway
>>
>>52935965
just no
>>
>>52935993
Oops.
Should be:
Floor += floor - len(string)
>>
>>52935859
What, how am I script kiddie for using C, at least try too sound smart m8.
>>
>>52936012
but if you unroll the loop so you do the count for example 8 at a time instead of 1 at a time it will have fewer additions so it's a nice idea

but in practice you can get the additions practically for free because instruction pipelining
>>
>>52936000
>got told hard
>mad
>>
>>52935848
Nigger he obviously meant "struct" as in "your struct name".
>>
>>52936021
Why?
>>
>>52936036
>ur a doodoo head xD
>told hard
>>
>>52936040
>obviously
>pretending
>inb4
>ishyggy
fuck off
>>
>>52936022
No it should be floor -= len(string) - floor
take ((()
floor is 3 after the loop.
len(string) is 4.
So it ends up subtracting 4-3 = 1 from floor, bringing the total to 2.
>>
DAT FRAME RATE DOE

https://www.youtube.com/watch?v=2jHBsNncEPs
>>
>>52935977

Why not. It's free Cryengine, if you create an application with no networking features.

What would you recommend using, anyway?
>>
>>52936152
pygame
>>
>>52936152
it will almost certainly be shit for mobile games

>>52936160
kill yourself
>>
>Women write better code, study suggests
http://www.bbc.co.uk/news/technology-35559439
>The US researchers analysed nearly 1.4 million users of the open source program-sharing service Github.
>They found that pull requests - or suggested code changes - made on the service by women were more likely to be accepted than those by men.

HOW DOES MALE CODE EVEN COMPETE?
>>
>>52936195
>much meme
>somewhat animu
>so mad
>>
>>52936220
>program-sharing service
sounds like a legitimate study
>>
>>52936195
>cryengine
>mobile
Pick 1.
>>
>>52936220
>github
>women
you mean trannies
>>
>>52936220
>more likely to be accepted
>better code
>>
>>52936220
>more likely to be accepted than those by men.
No surprise there, everyone bends over backwards to accomodate women. More news at 11.
>>
>>52936220
>>They found that pull requests - or suggested code changes - made on the service by women were more likely to be accepted than those by men.
because they do trivial shit like fix typos or adjust wording. men are more ambitious and make larger changes so of course they will be more likely to get turned down
>>
>>52936242
>>52936248
>>52936257
>>52936258
>>52936263

>dpt is this desperate
>can't accept female superiority
>can't accept proof of anti female bias
>>
>>52936296
k tard
>>
>>52936296
Well like the study said, if you want to be accepted you need a vagina.
>>
>>52936296
>traps
end yourself, degenerate faggot
>>
>"For outsiders, we see evidence for gender bias: women's acceptance rates are 71.8% when they use gender neutral profiles, but drop to 62.5% when their gender is identifiable . There is a similar drop for men, but the effect is not as strong," the paper noted.
>>
>>52936314
this isn't a controlled study. it could well be that people who use gender neutral profiles are better at programming. and if there is a bias, so fucking what??? fuck off fag
>>
>>52936220
>>52936296
>>52936314

most successful shitpost 2016
>>
File: flamboyant_cuttlefish.webm (2 MB, 720x404) Image search: [Google]
flamboyant_cuttlefish.webm
2 MB, 720x404
It's time to ask your beloved programming literate anything.

>>52935451
http://kissmanga.com/Manga/SE

>>52935612
https://en.wikipedia.org/wiki/Unix_philosophy

>>52936160
pygame is sdl1.x
>>
>>52936337
>https://en.wikipedia.org/wiki/Unix_philosophy
kill yourself
>>
>>52936347
END YOURSELF, FEGIT!
>>
>>52936361
you think your web browser or your animu watching program never frees memory, k
>>
Alright dpt, is github still the best option to release free software? Or are there other better alternatives to github? I've been under a rock for the past year or so on the matter of code depositories.

I'm putting the finishing touches on my software by mostly prettying up my code and I want to release it as free and open source.
>>
File: sicpantibullyprotection.png (626 KB, 916x984) Image search: [Google]
sicpantibullyprotection.png
626 KB, 916x984
>>52936347
why
>>
>>52936390
most non-trivial applications don't just do one thing and then exit, so while running they need to free memory that they won't use again.
>>
>>52936414
>while running they need to free memory
get more ram, fgt; 16 GB is already standard
>>
>>52936443
kill yourself
>>
File: webcancer1.png (46 KB, 750x111) Image search: [Google]
webcancer1.png
46 KB, 750x111
seriously what the fuck is this shit? and it took probably 30 seconds (20 of which essentially froze the entire system) to even bring up the google chrome task manager
>>
Hey /dpt/, I took your guys advice and tried a couple of C books, but honestly found it hard to feel engaged with them, I got about 200 pages into C Programming A Modern Approach, and felt like I wasn't really getting much out of it, I guess just the way they explained things and how I am used to learning didn't mesh, and I read a small amount of The C Programming Language, but honestly, feel its for people with more experience than I have.
Well, I decided to try out C Primer Plus by Stephen Prata, I don't know why, but I just feel like I'm getting everything I ready with this book compared to the other two. And it gives me more motivation to keep going (I blasted through the first 4 chapters and didn't realise how much I had accomplished until I went to make breakfast)
Wish me luck on my adventure into programming! I found the introductory book for me and hopefully its smooth sailing from this point on!
>>
File: bear.jpg (23 KB, 380x326) Image search: [Google]
bear.jpg
23 KB, 380x326
>>52936520
Good luck anon.
>>
>>52935685
>not using AVX to process 32 chars at a time
stay pleb
>>
>>52935685
>floor += 2 * (c == '(') - 1;
do you even into no-branch programming brah?
>>
>>52936518
botnet
>>
>>52936584
>implying the compiler wouldn't avx this
>>
>>52936602
>2b - 1
thank you for this senpai
>>
>>52936657
>what is data dependency
retard
>>
>>52936520
Why are you starting with C?
>>
Someone give an idea for a decent project. I want something that will impress employers.
>>
So I've had this question for a while now.
I'm new to programming, and sometimes find myself wanting to use strings to refer to objects.

Say I have an ArrayList x.
Can I somehow use a string S with the text "x" in this manner:
S.add(whatever)?
>>
>>52936692

(char) (char) (char) (char) (char)
->
(is \()(is \()(is \()(is \()(is \()(is \()
->
sideways sum
>>
>>52936674
common trick to get -1/1 from 0/1
a similar trick can be used to return -1/0/1 from a cmp function usable by qsort
>>
>>52936708
No you can't but I don't know why you'd want to do something like that to begin with. You should want to know exactly which list you're adding an element to.
>>
>>52936708
Why not just use
x.Add(whatever);
?
>>
>>52936727
>myth of the sufficiently smart compiler
let me guess, you're a "managed language" fag; keep dreaming
>>
>>52936708
Map<String, ArrayList> strToList = ...;
ArrayList list = ...;
strToList.put("x", list);
...
strToList.get(S).add(whatever);
>>
>>52936702
I've been told a bunch that starting with C gives me a greater foundation for understanding what I am making the machine do with my code.
Since I want to move to C++, and Java afterwards, starting with their father language makes sense, but I guess starting with the higher level Java would give me a greater feeling of accomplishment by seeing my work come to life. Also giving me a good understanding of syntax, from what I've read in /dpt/ at least.
But, I won't lie, I'm hoping I can turn this into a career eventually, since I'm coming from a rather poor family. Something I can learn on my own time, with minimal investment is kind of necessary, and some of the widest used languages are C, C++, and Java, it just depends on how old the code would be that you might end up maintaining.
>>
>>52936737
>>52936746
I have a bunch of buttons.
I'd like to change the color of 3 buttons, and I'd like to use the int parameters of the method to refer to the buttons that need changing.
>>
Ok I've decided I'll write a language in C#, for some reason that came to mind and I think it can be fun.

What features should I include? Should it be prefix, infix or postfix? Anyone with any input?
>>
>>52936750
>being a moron
>>
You could have a list containing these buttons and then use the index to refer to which button you want. I still don't see the need for strings.
>>
>>52936385

Github is where a large portion of the open source community is right now, so if you release it there, you'll have the maximum likelihood of getting other people's hands on your code for contribution. It may not be a site you'll wish to support, however.
>>
>>52936789
>I've been told a bunch that starting with C gives me a greater foundation for understanding what I am making the machine do with my code.
This is correct, but as you've seen, it's a huge pain in the dick to *do* anything with C.

Do yourself a favor and jump right into Java or C#.

t. Someone who makes good money programming and never touched C
>>
>>52936799
>muh naive java implementation is jited to avx, honestly guise; no, I can't prove it, because no compiler CURRENTLY does this, but in theory...
go home, pajeet, this is over your head
>>
>>52936823
>C#

You mean C++
>>
>>52936791
Just do a case statement, or add your buttons to a list and use LINQ to select based on a property of the button.
>>
>>52936823
>never touched C
DESIGNATED
>>
>>52936826
>being a moron
>>
add boehmgc to your favorite C project and watch the memory leaks disappear :^)
>>
>>52936842
I love this meme
>>
>>52936837
I made no types there. Java and C# are two of the best learning languages, because you can start doing things very quickly.

>>52936842
Born and raised in US. Nice meme.
>>
>>52936750
It's not a myth. clang optimize that kind of loop into simd code.
>>
>>52936823
I'm probably not far enough into it to have found that its hard to do much with it.
I've been finding it hard to be engaged by books that have been suggested to me.
But, C Primer Plus 6th edition is something I just feel like I'm getting immediately.
>>
>>52936855
>got told
>muh damage control
>>
>>52936882
>I made no types there.
Oh the irony.

typos*
>>
File: rbr.png (13 KB, 332x352) Image search: [Google]
rbr.png
13 KB, 332x352
>I fell for the rails meme

I'm in too deep to pull out now
>>
>>52936889
show it; I guarantee it doesn't generate avx code
inb4 >I have no compiler handy, but I'm sure it can
>>
>>52936892
>being a moron
>>
>>52936902
fag
>>
>>52936909
>animuuuuuu
>>
>>52936841
>>52936787
Thanks for the help, I'll figure it out.
>>
>>52936905
http://llvm.org/docs/Vectorizers.html
>>
>>52936793
Are you going to compile it to machine code or for some VM?
Is it going to be some lisp like functional language?
Are you going to use the language for something?
Why C#?
>>
>>52936891
>C Primer Plus 6th edition
Looked this up, found this:

  long int estine;
long johns;
short int erns;
short ribs;
unsigned int s_count;
unsigned players;
unsigned long headcount;
unsigned short yesvotes;
long long ago;


Not saying bad or good, just thought this was humorous.
>>
>>52936902
Then just blow your load and hope for the best
>>
>>52936931
show the generated avx asm for that specific code snippet
protip: you can't because it can't
>>
>>52936960
This book is golden.

9/10, would give to my son.

  char broiled;        /* declare a char variable        */
broiled = 'T'; /* OK */
broiled = T; /* NO! Thinks T is a variable */
broiled = "T"; /* NO! Thinks "T" is a string */


http://ptgmedia.pearsoncmg.com/images/9780321928429/samplepages/0321928423.pdf
>>
>>52936960
typedef long long huge;
huge penis;
>>
File: 161017757_44042348.jpg (67 KB, 590x632) Image search: [Google]
161017757_44042348.jpg
67 KB, 590x632
>>52936826
you obviously have no clue on optimizing compilers.

foo.cpp
#include <string>

int rev (std::string input)
{
int floor = 0;
for (char c : input)
{
if (c == '(') {
floor ++;
} else {
floor--;
}
}
return floor;
}


compile with

clang++ -S -O3 -march=haswell -mllvm --x86-asm-syntax=intel -std=c++11 foo.cpp


look up foo.s, it's avx code.
>>
>>52936055
> floor + floor - len(string) != floor - (len(string) - floor)
> I can't into algebra
>>
>>52936905
https://goo.gl/B59idb

#REKT
>>
>>52936948
> Are you going to compile it to machine code or for some VM?

Probably some VM, it's nothing serious, just me wanting to write logic and tests.

>Is it going to be some lisp like functional language?

Functional, I'd like to write map and filter functions.

>Are you going to use the language for something?

Nope, writing it purely for entertainment.

>Why C#?

Because it's a comfortable language to write in.
>>
>>52937025
>hundreds of redundant instructions for what can be written in 10 instructions by hand
hahahahaha, that compiler sure is smart
>>
>>52937012
Niggers can you even associative property?
>>
File: tGKIDM8.jpg (115 KB, 650x650) Image search: [Google]
tGKIDM8.jpg
115 KB, 650x650
>>52937067
>show it; I guarantee it doesn't generate avx code
>>
>>52936055
>Floor += floor - len(string)
>No it should be floor -= len(string) - floor
WAT
>>
>>52937098
>memu
>>
>>52937071
Nigga the point of this is not associativity.
>>
>>52936160
>pygame

No fucking way.
>>
>>52937004
Keep in mind that the processor has its own optimizer that can improve the performance of simple loops consisting mainly of memory accesses dramatically. A non-SIMD version should in fact be essentially on-par performance-wise with a SIMD version on the same processor.
>>
>enroll in tech college
>scrape by for the first 6 months
>attend 3rd programming course
>everything goes right above my head
I'm just not cut out for this shit.
>>
>>52937159
>(a + b) + c != a + (b + c)
> Not associativity

Did I just completely miss the point or something?
>>
>>52937067
>10 instructions by hand
>10 instructions

avx256 has 32 registers. you need two instructions per register to fetch and store the data on each iteration.
if you only use 5 registers, it does already take 10 instructions.
please, get back to your daily fizzbuzz coding.
>>
>>52937190
Yep.
>>
>>52937027
If I had a language custom made for me here's few things I'd want

Cascade operator
foo.bar()..biz();

# would be same as
foo.bar();
foo.biz();


Safe navigation operator
For statically typed languages automatic type deduction
Clean C API
Clean module system
Anonymous functions, closures if possible
Type introspection and reflection
>>
>>52937233
Excluding the first two things maybe you want the D anon
>>
Should I learn haskell?
>>
>>52937202
>can't into parallel fizzbuzz
back to /wdg/
>>
>>52937190
Negation is central in this thing. In fact, if we focus on the increment:
> floor += floor - len(string)
> floor - len(string)
> same as -(len(string - floor)
> floor -= len(string) - floor
Therefore >>52936055 is retarded, QED as well
>>
>>52937233
So basically C#. You'd have to write your own cascade operator though.
>>
>>52937233
>Cascade operator
just "return this" you massive dolt
>>
>>52937202
>if you only use 5 registers
you only need 2 registers, pajeet
>>
>>52937324
this
>>
>>52937349
>avx
>>
scrublord question:

floating point operations result in rounding errors. in order to correct these errors, should I round up or down? is it language, or even case, dependent?
>>
>>52937233
something along the lines of this?
for (auto&& fn : { foo::bar, foo::biz })
foo.*fn();
>>
>>52937324
I bet you write i += 1 instead of i++
>>
>>52937385
you don't have to do anything in particular unless you specifically want integers or something. the default rounding mode is numerically stable.
>>
>>52937385
https://en.wikipedia.org/wiki/Kahan_summation_algorithm
>>
File: spongebob.jpg (10 KB, 300x186) Image search: [Google]
spongebob.jpg
10 KB, 300x186
PHP versions
5.4, 5.5, 5.6...

>mfw it goes straight to 7.0
>>
>>52937385
languages often have a built in "round" function - call that on the number in question and you'll correct the minor deviation by going to the closest integer
>>
>>52937463
>>>/g/wdg
>>
>>52937246
Definitely
>>
>>52937393
>>52937233

pic related
>>
>>52937406
i++ doesn't compile, you fag
>>
>>52937407
>I've been doing some 2d array shit in c++ and somehow x[9][3] and y[0][0] take up the same memory space. How the fuck is that even possible?
>They're defined as x[9][3] and y[9][4].
learn to index, you webshit
>>
>>52937407
lmao
>>
File: Honeycam 2016-02-13 02-08-22.webm (2 MB, 1280x720) Image search: [Google]
Honeycam 2016-02-13 02-08-22.webm
2 MB, 1280x720
Game Programming.

I'm not have any idea why character moves buggy.
Originally It moves smooth.
>>
>>52937899
Post code. This isn't >>>/vg/agdg so you'd best post some damn code with your problem.
>>
>>52937919
ah? I cannot post any of my development results at /dpt/?
>>
>>52937951
Feel free to post stuff, I think that anon was assuming you were asking for help.

If you want help fixing your code, obviously you need to post it.
>>
>>52937951
You can if you like, doubt anyone will care.

But all the game devs are in >>>/vg/agdg so you'd have more luck there.

If you need help with code you have to post it.
>>
>>52937976
>>52937968
thx anon. I didn't know about agdg thread.
>>
JS peasant coming through, try to not to get any of my filth on you as I ask this question:

I can't figure out why this for loop isn't working as intended. If it didn't work at all, then I'd be alright with it, instead it kind of half works. It's not even complex.

The loop takes an array (named "change") containing arrays, checks for the presence of 0 within each subarray, and if a subarray contains 0 at index 1, it removes that subarray from the change array.

var change = [      
["ONE HUNDRED", 0],
["TWENTY", 0],
["TEN", 5],
["FIVE", 0],
["ONE", 0],
["QUARTER", 0],
["DIME", 0],
["NICKEL", 0],
["PENNY", 0]
]
console.log(change); // logs code exactly as it appears above

for (i = 0; i < change.length; i++) {
console.log("#"+i+": "+change[i].indexOf(0)); // check for presence of 0, logs 1 for every entry except index 2 -- contains TEN (subarray has value of 5, at index 1, therefore 0 isn't present)
if (change[i].indexOf(0) > -1) {
change.splice(i, 1);
} // if present, remove from change array
}

console.log(change); // logs [[TWENTY,0],[TEN,5],[ONE,0],[DIME,0],[PENNY,0]]


>inb4 webdev a shit, >>>/wdg/, etc.
we all know this, but i have been exiled to a land of weak typing, coercion and false OO-design

also this is pretty weird shit
>>
File: android-kikaider-2879369.jpg (268 KB, 1200x987) Image search: [Google]
android-kikaider-2879369.jpg
268 KB, 1200x987
A better android app for reading manga, tracking chapters and series you're reading and anime you've watched / are watching. It's fun.
>>
File: cpp-opengl-flying-game.webm (2 MB, 1920x1080) Image search: [Google]
cpp-opengl-flying-game.webm
2 MB, 1920x1080
Working on my C++ OpenGL flying game.
>>
>>52938047
What're you using for displaying the file?
Thread replies: 255
Thread images: 26

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.