[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: 14
File: DPT.png (389 KB, 934x1000) Image search: [Google]
DPT.png
389 KB, 934x1000
Old thread: >>51814176

What are you working on /g/?
>>
Incase you're wondering why no one is here

>>51819095

Reminder to sage this thread as to not clog the catalog
>>
Kill yourself mate.
>>
>>51819684
no you literally kill yourself fucking fag troll
>>
stop spamming the board, you autistic piece of shit

>>51819095
>>
>>51819684
>>51819693
Guys, guys.
Let's just go to the thread with more posts.
>>
>>51819722
NO YOU FUCKING FAGGOT KILL YOURSELF

THIS IS THE LEGIT THREAD

AT THE VERY LEAST, THE OP IMAGE OF THAT THREAD SHOULD GET DELETED

AND IT WOULD IF /G/ HAD MORE THAN ONE JANITOR
>>
>>51819748
you could not be more of a closet homo
>>
>>51819722
AND ANYWAY, LITERALLY THE MAJORITY OF THE POSTS IN THAT THREADS ARE ABOUT THE (NON-)LEGITIMACY OF THE THREAD, NOT ABOUT PROGRMAMING

LITERALLY FUCKING KILL YOURSELF
>>
lets just all kill ourselves, i think it would be the best solution here
>>
>>51819789
nah it kinda sucks to be dead

i'm gonna live my life or at least make an impact before i leave

inb4fbi
>>
File: 1445468849306.jpg (296 KB, 900x900) Image search: [Google]
1445468849306.jpg
296 KB, 900x900
>>51819748
>>51819769
Guys, guys, listen.
You can't expect the moderators to take sides with posters about what image the thread should have, lest the moderators themselves be at odds with each other and the order fall into chaos.
Let's just go to the thread that will harbor the most discussion and not post only for our own selfish purposes.
I have attached a calming picture to ease your nerves.
>>
Literally kill yourself, OP.
>>
>>51819819
>You can't expect the moderators to take sides with posters about what image the thread should have
yes you can. 3d trap threads almost always get deleted, so why not 2d trap threads? at least they could remove the image. and reposting a thread before the bump limit by itself is grounds for a thread deletion.

>Let's just go to the thread that will harbor the most discussion
the trap thread is not the one that will harbor the most (relevant) discussion.

>not post only for our own selfish purposes
yes, let's now post trap threads before the bump limit for fuck's sake.

>I have attached a calming picture to ease your nerves.
jew confirmed
>>
>>51819872
>and reposting a thread before the bump limit by itself is grounds for a thread deletion.
lol
>>
>>51819872
>yes, let's now post trap threads before the bump limit for fuck's sake.
let's NOT post trap threads

fugg
>>
>>51819872
>Jew
You have a long, long way ahead of you.
>>
>>51820003
kill yourself
>>
>>51819872
>the trap thread is not the one that will harbor the most (relevant) discussion.
Because you're shitposting in it you fucking faggot
>>
>>51820142
it's not just me

i didn't even make this thread
>>
File: 1449756574386.jpg (3 MB, 3264x2448) Image search: [Google]
1449756574386.jpg
3 MB, 3264x2448
C fag pleb tards will never know the feel of being smart enough to understand OOP
>>
D is a shitty meme language
>>
>>51820276
OOP fags will never know the feel of making a screenshot.
>>
>>51820460
i guess i'll have to spell it out for you: it was the C fag that posted the photo
>>
File: måste accelerera fort.jpg (92 KB, 1632x918) Image search: [Google]
måste accelerera fort.jpg
92 KB, 1632x918
Is anyone here hosting scripts on GitHub that also load resources hosted on GitHub?

i.e. scripts that hotlink .js files or images from the GitHub repo, or just auto-update scripts that check the repo for updates


Their ToS doesn't mention anything on this
>>
File: thoughts.jpg (83 KB, 1176x747) Image search: [Google]
thoughts.jpg
83 KB, 1176x747
>>51820434

Having reviewed this project, I'm struggling to refer to any other platform as a meme.
>>
An example of creating an array of objects in python
class cls:
x = 0
def __init__(self):
print "started"
def add(self):
self.x = self.x+1
print self.x
arr = []
arr.append(cls())
arr.append(cls())
arr[0].add()
arr[0].add()
arr[0].add()
arr[1].add()
>>
>>51819395
Stop bumping this this spite thread.


We already have a thread.
>>51819095
>>
File: Cruzin' for a bruisin'.webm (395 KB, 854x480) Image search: [Google]
Cruzin' for a bruisin'.webm
395 KB, 854x480
>>51820812
this is the legitimate thread. report, ignore and sage all trap threads posted before the bump limit.
>>
learn C or C++?
>>
>>51820903
C++. people who learn C first never manage to write proper C++.
>>
>>51820903
Start with C so you learn the basics required for every sane programming language. Learn C++ next for muh std::vector.
>>
>>51820939
>Learn C++ next for muh std::vector.
see this is exactly what i mean >>51820917
>>
>>51820903
learn python so you can actually make something in a day
>>
>>51820962
yeah you'll make a crappy little toy at best
>>
What gui's are used for making games. As in if I wanted to make a game would I have to make my own gui or use windows extremely complicated gui for c++. I dont like the latter because it wont run on a mac but I dont want to design gui's for multiple OS.
>>
>>51820979
Qt?
>>
>>51820979
GUIs are just graphics.
If you're making a game you would make your own UI or it will look like complete shit
>>
>>51821004
I think the main issue is that I dont know how to render in c++. Youd think after taking several advanced algorithm course and programming languages classes I would have learned how to do this.
>>
File: 5Yv6PzW.png (21 KB, 883x470) Image search: [Google]
5Yv6PzW.png
21 KB, 883x470
How would I make this UI look less shit?

I can't think of any other way to lay it out or controls I could replace with something else to improve it.

Any ideas would be appreciated.
>>
>>51821044
Think of it like this. A video camera is your view of your game, 3D or 2D it doesn't matter, but the video camera is whatever your game currently is.

A UI is simply slapping a sticker on the lens of the camera. It can be an entirely black opaque sticker with tiny little squares cut out if you wanted it to be for some reason.

In real terms you want to draw your UI on top of whatever else you might be drawing at that moment.

If you don't know how to do it yourself, find a game engine that handles rendering for you.
>>
>>51821124
I get the concept. I just dont know where to start.
Every tutorial Ive come across uses windows.h.
>>
>>51821169
Xlib
>>
>>51821044
all you do to render something is make a series of ABI/API/library calls. like when you write HTML, you specify a background color and elements and whatnot. similar concept with rendering graphics
>>
>>51821063
It's simple, but it doesn't look like shit. I prefer a light background with dark accents.
>>
I have a huge number of key-value pairs that I need to access with high throughput (at least 10000 accesses per second). I need to find a way to store them in memory and access them.
Previously I've used redis. It was basically what I needed, but I don't think it's as fast and as efficient as it could be.

Any ideas on what I could use instead? Or maybe I should write my own mini-redis and try to use that?
>>
>>51821324
Why don't you make your own implementation using a binary search tree? AVL trees have good op/s.
>>
>>51821306
I don't like the layout and I don't feel like it flows in any way. Here have a gfycat of it running...
gfycat com/CostlyJitteryChrysalis

There must be something I can do to make it all come together a bit better.
>>
>>51821460
Split the page into two pages. It's a bit busy compared to the others.
>>
>>51821063
Might be able to help you if you explain what it's meant to do more. What is this? A desktop application?
>>
Why these thread battles?
>>
File: H8xVhZQ.png (19 KB, 883x470) Image search: [Google]
H8xVhZQ.png
19 KB, 883x470
>>51821485
It's all gotta be accessible together, it's going to all represent one big nested data object, so having all the stuff on one page is pretty much my only requirement.

I switched the sizes of the rightmost listboxes to keep everything in line a bit, definitely a step in the right direction. If I could present the button inbetween them a little better or come up with a new control method that is just as self explanatory I might be onto something.

>>51821550
It's a desktop application for generating an installation setup for Fallout 4 mods.
Takes a folder full of files and creates a couple XML documents and file/folder structure all from user input.
>>
>>51821580
hybrid /g/ /a/ vs /g/ autism.
>>
>>51821580
it's the trap poster, he keeps posting threads before the bump limit. if he at least abided the bump limit it'd kinda be fair game
>>
File: Dt55n2j.png (20 KB, 883x442) Image search: [Google]
Dt55n2j.png
20 KB, 883x442
>>51821581
This is definitely better.

All I've done here is posted my layout refinement process.

Hey, maybe it'll help someone who's also a complete novice like me improve their own UI layout/design.
>>
>>51821581
I would space things more consistently and more logically.

the gap between the controls on the left and the left edge of the window is bigger than the gap between the right controls and the right edge of the window. The gap between the Add Group controls and the Add Module controls is large compared to the gap between the Add Module controls and the large box to the right of it.
SelectAny and Select one should be aligned to the left of the window, imo.

"D:\" is just floating at the top. There's nothing to indicate what it's for. It should also be aligned to the left like the control below it.

You might also consider thinking about grid systems. It's basically the idea of aligning most of the graphic elements on your UI to a invisible grid, which tends to have the effect of making everything look more organised and aesthetic. Windows Phone and iOS make extremely heavy use of this.
http://webdesign.tutsplus.com/articles/all-about-grid-systems--webdesign-14471
>>
>>51821665
Also, is that super huge set description area really necessary? It doesn't look like a core feature to me.
>>
are clojure or scala any good for android apps?
>>
>>51821717
no
>>
>>51821717
no, but F# is amazing.
>>
File: ExampleForm.png (20 KB, 609x481) Image search: [Google]
ExampleForm.png
20 KB, 609x481
>>51821686
This is what the inputs will end up looking like when they get used by another program.

The description can get quite long and I might end up having to place controls for inputting code snippets for bold text and the like (assuming it supports it).

>>51821670
Yeah the spacing is a bit shit, I adjust one thing and it throws everything else off. Trying to fiddle with it now to get it all to line up nicely.

The D:\ floating at the top begins life as "Click Here To Select A Folder..." label.
>>
>>51821717
You'll destroy compile times when adding those libraries. Once you need multidex, expect compile times of 2+ min for a clean build.
>>
>>51821618
>it's the trap poster

I figured as much
>>
>>51820789
public boolean polygone() {
Point2D []T = new Point2D[segments.length*2];
int indice=0;
boolean B = true;
for(int j=0;j<(segments.length*2-1);j=j+2) {
T[j]=segments[indice].p1;
T[j+1]=segments[indice].p2;
indice++;
}
for(int j=0;j<(segments.length*2-1);j++) {
int k=0;
for(int z=0;z<(segments.length*2);z++) {
if (T[j].equals(T[z])){
k++;
}
}
if (k!=2) {
B=false;
break;
}
}
return B;
}

I am working on a method that determine if n segments form a polygon or not. is there a shorter way than this in java ? each segment has a starting and ending point.
>>
>>51821739
Can't you another page for the user to add the description and other metadata?
>>
>>51821800
public boolean polygone() {
for(int j = 0; j < (segments.length - 1); ++j) {
int k = 0;
for(int z = 0; z < segments.length; ++z) {
if(segment[j].p1.equals(segment[z].p1)) {
++k;
}
if(segment[j].p1.equals(segment[z].p2)) {
++k;
}
if(segment[j].p2.equals(segment[z].p1)) {
++k;
}
if(segment[j].p2.equals(segment[z].p2)) {
++k;
}
}
if(k != 2) {
return false;
}
}
return true;
}
>>
>>51821871
It's all databound, when you click a group the modules listbox changes over to the attached modules, and the description will change over to the one of the module that's currently selected.

That's why I was having the issue, all of the data is tied together in some way so it'd just make it a bit jarring to switch between pages.
>>
>>51821800
you could try sorting them so you only have to loop through them once instead of getting O(n^2) time complexity like you do now
>>
>>51820276
why case 0
>>
>>51822328
that is due to the intellectual capacity of Cfags
>>
>>51822345
gtfo javafag
>>
>>51822357
>he thinks I use Java of all languages
i'm not a masochist m8
>>
lack of ENTERPRISE itt is absolutely disgusting

post your .java's
>>
>>51821800
bump
>>
    Integer a = 1000, b = 1000;  
System.out.println(a == b);
Integer c = 100, d = 100;
System.out.println(c == d);


false
true

      J
J A V A
V V
A V A J
J
>>
>>51822644
lol
anyway, as we've said before, Integer != int. use .equals() or whatever
>>
>>51822793
>java dindu nuffin
found the java apologist
>>
>>51822815
niceme.me
>>
test
>>
>>51822961
[Code]
test2
[\Code]
>>
>>51822974
test3
>>
>>51822961
>>51822974
>>51822982
>>51822984
Fucking retard newfag get out reeeeeeeee
>>
>>51822982
Youre not me
test3
>>
>>51822644
>>51822815
Do people on /g/ actually take pride in not reading the language specification any more?

Jesus Christ, is this the same /g/ that a couple of years back shat on anyone who hadn't read the C standard cover to cover?
>>
traps
>>
>>51822997
bool faggot_detected()
{
bool faggot=true;
if (mad==true){
cout<<"reeeeeeee"<endl;
faggot=true;
}
return (faggot);
}
>>
>>51823006
>same /g/ that a couple of years back shat on anyone
same /g/ that can't average 2 ints
>>
>>51823059
>animuuuu
>>
>>51819748
>sage in all fields
>>
>>51823059
come back when you know how to program C :^)
>>
>>51823109
>muh average
m8...
>>
>>51823059
int faggot_detected() {
int faggot = 1;
if (faggot) {
puts("reeeeeeeeee");
faggot = 1;
}
return faggot;
}
>>
>>51823131
why do you set faggot equal to 1, then set it equal to 1 again. Is it because faggot is always true?
I meant to pass mad as the variable, and set it to true there. Not compare in the if statement. What happens when you edit code I guess.
>>51823109
C is a meme
>>
>>51823129
i think you replied the wrong post
>>
>>51823166
sure. linus torvalds is a big memer, along with anyone that programs operating systems or hardware.
>>
>>51823166
int faggot_detected(int mad)

then you have to write that here...
>>
>>51821063
Are you the guy that struggled with dictionary relationship in VB a week ago? Seems like you've come a long way since then. The application looks OK if it's for Windows 8-10. The only thing I'd change is to make the red color actually correspond to currect primary theme color.
>>
>>51823006
you fell for the b8
>>
>>51823199
Lets just pretend mad is a global variable shall we.
>>
>>51823188
So no one important I take it.
>>
>>51823217
also i can't program in C++ but wasn't this the syntax?
cout << "Sentence." << endl;
>>
>>51823006
>continuing to defend java

Seriously, where the fuck did the real DPT go?
>people shilling python
>people defending java
>nobody shilling haskell or fp
>no "first for X" etc

Are you all newfags or something?
Did I fall into a mirror universe?
>>
>>51823255
Yeah just know the if you dont have using namespace std then you have to put std::cout and std::endl;
>>
>>51823208
I am indeed that guy.
It's for Windows as a whole, just a WPF application with a shiny metro skin and controls (courtesy of Mahapps.Metro). It was either that or try to do my own styling, and I'd rather not.

At the moment it's largely non-functional, the UI is done and the back end code is done (because I ported the classes/methods over from my WinForms project) I'm just wondering how to bind the controls to data, especially seeing as the data is nested.
>>
why is averaging 2 integers in C such a big deal
>>
>>51823371
Because it's easy to move the goalposts.
>>
>>51823371
It's not.
>>
>>51823371
Because you have to account for overflows and rounding. You could just simply use Python and don't worry about this stuff though.
>>
>>51823434
Python is much much slower though, which is the main reason you would be choosing to use C in the first place. It's not trivial to average two ints in C because it's not trivial to average two ints in machine code, which C aims to be a very lightweight abstraction of.
>>
>>51820276
you can do everything you're doing in C. actually that code looks more similar to C than C++/Java

am i getting trolled
>>
>>51821063
Try no using WPF
>>
>>51823467
>actually that code looks more similar to C than C++/Java
It is C. That's his point.
>>
>>51823461
>because it's not trivial to average two ints in machine code, which C aims to be a very lightweight abstraction of.
It is trivial in machine code because you know the signed integer representation and have direct access to the carry/overflow bit.
In x86 it's just add and rcr (rotate through carry), two instructions.
The reason it's somewhat subtle in (portable/standard) C is because signed integer overflow is undefined and the actual integer representation is implementation defined.
>>
>>51823371
because faggots fall for the b8, and so the thread falls into irrelevance. same for hurr durr Integers in java and other retarded memes.
>>
>>51823496
Doesn't even compile/10
>>
>>51823461
>Python is much much slower though, which is the main reason you would be choosing to use C in the first place.
That's true however oftentimes you don't need the speed of C, and Python's "slowness" is good enough because it comensates with the huge standard library, a lot of third party libraries, and general ease of use which makes it trivial to solve a lot of tasks in (I'm not saying Python is suitable for every use case, but it's decent for a huge variety of them).
>>
Teacher told us to get the nth Fibonacci number as part of a take home final. How'd I do.
int fib(int num){
int x=0;
int y=1;
int z=0;
int counter=1;
while (num!=counter){
counter++;
z=y;
y=x+y;
x=z;
}
if (counter==0)
return (x);
else
return (y);
}
>>
>>51823526
>if (counter==0)
> return (x);
> else
> return (y);
Dunno what the point of this is.
If this is C, counter can never become 0, and the compiler might even just optimize this away to just return y
>>
>>51823473
What would you suggest?
>>
>>51823521
sure, but complaining about difficulty in averaging two ints in C is retarded. It's an obvious trade off for being so close to the metal.

Also F# is better than python in just about every way imaginable.
>>
Anyone know how I'd go about being able to get a number from a binary search tree by just giving it a position index. zero would return the left most node, one it's parent two the right child so on so forth. I've been trying to do this for days and have pretty much just given up at this point and have just instead used an array list and added all nodes in order to that then return the specified one, which can't be that efficient but it works.
>>
>>51823554
my b. copied old code. thats supposed to be num.
>>
>>51823555
WinForms
Either with default controls or custom drawing
>>
>>51823628
>WinForms
Literally why?

I ported the work I'd done in Winforms over to WPF because I couldn't stand it.
>>
>>51823577
Have a counter and use in order traversal.
Every recursive call increments the counter.
>>
>>51823662
Enjoy your XAML
>>
>>51823667

I tried that, but I must be fucking up somewhere as it always ends up returning a null. Checked most of it with print statements and it would even show me that it correctly identified the number it was suppose to return then that would be overwrote by a null later, but I couldn't avoid the null otherwise java moans about missing return statement.
>>
>>51823577
The index of a binary search tree isn't a number.
>>
File: pythonlogo.jpg (46 KB, 680x459) Image search: [Google]
pythonlogo.jpg
46 KB, 680x459
Hey guys, I'm currently building a keylogger in Python. I'm having an issue that's not supposed to be happening. Whenever you hit the space key, or enter key, it changes the text to something like this: 䜀潯ࡧ潭湲湩൧

import pyHook,pythoncom
import sys

print 'Logging all keystrokes...'

def OnKeyboardEvent(event):
if event.Key == 'Escape':
sys.exit('Stopping the process.')
file = open('C:\Users\Eugene\Desktop\keystrokes.txt', 'a')
file.write(chr(event.Ascii))
file.close()
return True

hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()


This is all I have so far and I literally can't figure out why it's doing this.
>>
>>51823691
I will, thank you.

Having to deal with a slightly clunky markup language in return for a nicer UI and a bit more control is more than a fine tradeoff.
>>
>>51823691
That didn't answer the question. I'm also curious. What's wrong with XAML? And how is not a code gen from the UI designer in WinForms not a million times worse?
>>
>>51823702
Because youre not using tail recursion. Set each recursive call to the variable you want to return.
Post code if you need further explanation. Essentially your problem though is that youre getting back the first call because thats how recursion works. It pops stack off. You need the value to remain of until the final pop.
>>
>>51823371
>hurr durr why would you ever want to average 2 integers
>>
>>51823526
void fib(int num) {
int x = 0;
int y = 1;
int z = 0;
int i;

for (i = 0; i < num; i++) {
z = x + y;
x = y;
y = z;
printf("%d\t", z);

}
}
[\code]

this should work
>>
>>51823730
If you have a spelling mistake inside your XAML file your program will crash / not compile and you will get a cryptic error message not telling you what the problem is

With WinForms the compiler will tell you what's wrong

Personally I just create my UI procedurally without the WinForms designer
>>
>>51823526
You've got it all wrong, mate.
fibs = histo phi where
phi [] = 0
phi [_] = 1
phi (x : y : _) = x + y
>>
>>51823706
if event.Ascii==13:
keys='<ENTER>'
elif event.Ascii==8:
keys='<BACK SPACE>'
elif event.Ascii==9:
keys='<TAB>'

I don't know anything about python or anything about the code I stole this from, but I assume you can work out what's going on here.
What is Google?
>>
>>51823839
>If you have a spelling mistake inside your XAML file your program will crash
in my experience, only with data binding shit. Which WinForms doesn't have.

Everything else will most certainly cause the application to fail to compile.

>Personally I just create my UI procedurally without the WinForms designer
Do why not just do the same in WPF?
>>
>>51823706
>
file.write(chr(event.Ascii))

Why not just:
file.write(event.Key)
>>
>>51823864
>>
I'm working on a OpenGL C++ GUI framework.
>>
>>51823839
>If you have a spelling mistake inside your XAML file your program will crash
As opposed to?
>Compiler won't tell you where the error is
It'll tell you what line it's in, that's more than enough, if you have half a brain you can make the giant leap between what caused the crash and what line the compiler pointed you to. Do you need spoonfeeding or something?
>>
>>51823902
I don't like using XAML and WPF also is much slower than using older GDI software rendering in many cases
>>
>>51823628
WPF can look like winforms if you want, hell it uses the same controls by default. It's vastly superior for custom styling.
>>
>>51823923
event.Key only gives you the uppercase
>>
>>51823925
It's just a histomorphism. What's the problem?
>>
>>51823960
>slower than using older GDI software rendering in many cases
Marginally. It's not something you're ever going to notice.
>>
>>51823883
I didn't think of that. Thanks, that makes a lot of sense.
>>
Using node webkit. I can sort of see the appeal, though javascript leaves a lot to be desired as a "desktop" language
>>
>>51823926
Fuck off Rajeesh
>>
>>51824002
It's ugly as fuck...
>>
>have an exam over c++ in 5 hours.
>too fucking cocky to study even though I know my professor is going to ask obscure projects.
>Ive barely been going to class and have no idea whats on the test
How fucked am I. Im in that same professor's algorithms course so he knows I can code in C++ so he doesnt bother me about not going to the intro class. But I remember that I never went to a python class and on the final was asked what it means to be an interpreted language and had no idea how what the answer was to anything that wasnt code.
>>
>>51824062
What's so ugly about it? It expresses the definition of the Fibonacci sequence quite elegantly.
>first element (nothing preceding it) is 0
>second element (one element preceding it) is 1
>all other elements are the sum of their preceding 2 elements
It's also far more efficient than the naive recursive definition.
>>
>>51823951
When I used it deleting a single character in the XAML file would result in some useless error message without the file/line
It was a while ago though

>>51824005
>Marginally
WPF literary is 1000+ times slower rendering text than OpenGL and about 5 times slower then the 20 year old GDI
>>
>>51824037
I like the idea of Electron and stuff so you can build interfaces easily with HTML/JS, I hate the idea that the backend must be written in JavaScript although you can at least use TypeScript or CoffeeScript which make it more bearable. There's also performance issues since it's not really native, although Discord seems to be quite optimized so I guess there's a way to build applications on top of Electron without sacrifacing much performance.
>>
>>51824093
What kino of obscure language is that?
>>
>>51824097
VS2015 points you directly to the line, throws out a competent enough error message, if you could write the code that caused the crash you can almost certainly work out what caused it with the information given.
>>
>>51824037
Are you at least writing ES6?
>>
>>51824081
you need to sort your life out m8
>>
>>51824113
It's Haskell, but you can do the same thing in any other language. It won't be nearly as concise, though.
>>
>>51824121
Well maybe they improved it
I still don't see why I'd wanna use XAML just for the UI rather than writing it in code like everything else
>>
>>51824146
>Its an intro level class my senior year. I cant take it seriously especially when Im taking much harder cs classes. Im only in it because I needed the credit and it was either that or compilers with a shitty temp professor who doesnt know anything.
>>
Why do so many languages have built in support for complex numbers? It is literally retarded, at best it should be a library feature.
>>
>>51824200
>not realizing how fast you can make calculations if you map functions into the complex plain.
Youre joking right.
>>
>>51824097
>and about 5 times slower then the 20 year old GDI
Which is still plenty fast such that it's never going to affect you application. WPF provides a wealth of features that are going to make a much more positive impact on your projects than 5x faster text rendering.
>>
>>51824081
>>51824184

is it an intro class on meme arrows?
you're not doing very well so far
>>
>>51824200
Here's your reply
>>
>>51824184
>intro class
>possibly failing it
Not the right attitude. Since you're worried, it's clear it should be a big deal to you. Lad, study your ass off right now, and next time don't be so lenient
>>
>>51824217
Literally no faster because processors don't have complex number instructions
>>
>>51824224
>meme arrows
Ive been here to long. back in my day these used to signify implications.
>>
>>51824159
You can do most of it in the code, all the properties are accessible, if anything the XAML just gives you another place to store generic properties to keep your code clutter-free.

Other than your argument about it being slower than GDI (which isn't all that relevant for common desktop applications) there's really no reason to use Winforms over WPF.
>>
>>51824244
Nice dubs,
>to long
Where is that? Some magical place in one of your Chinese Cartoons?
>>
>>51824244
they do
you're doing it wrong
>>
>>51824244
they do signify implications, and you still used it incorrectly
>>
>>51824127
God yes.
Getting it to work with nwjs was more work than it should have but it's work it.
>>51824100
I'm currently debating which of coffeescript, typescript and dart I should replace js with, I'm leaning towards typescript, then coffeescript, and not too interested in dart.
Electron was my first plan but I have an internship involving node webkit so might as well learn it (eek).
I'm not really a web guy so it's not my ideal experience
>>
I'm trying to write a simple hello world program in C, but it isn't working.
Here's my code:
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{
lua_State *L = luaL_newstate();
luaL_openlibs(L);
printf(lua_pushfstring(L, "Hello, world!"));
char c[1];
sprintf(c,"%d",'\n');
printf(&c);
}


It prints "Hello, world!10%" to stdout and I don't know why.
>>
>>51824159
xaml is just a direct mapping to .net objects in the form of xml. You can do everything in code, hell you can even figure out how just by looking at the markup
>>
>>51821800
that's the only possible method you faggot
>>
>>51824323
When you print the character c, it's not null-terminated. So you get garbage.

PS:
What the fuck are you doing?
>>
>>51824221
>>51824246
I think I'd rather have 5x better performance than store generic properties in an XAML file
>>
>>51824323
>i'm trying to write a simple hello world program in C
>#include <lua.h>
>#include <lualib.h>
>#include <lauxlib.h>
>>
>>51824353
So I should append a null character to c?
Okay I'll try it.
>>
>>51824334
I did everything in code later on
But WPF just provided nothing for me that I couldn't do faster and easier in WinForms
>>
>>51824323
wtf is this shit
>>
>>51824375
If you want to print a character, do it like this:
char c = '\n';
printf("%c", c);


I still would like to know what the fuck you are doing.
>>
>>51824323
You're getting "10" because you use %d for '\n' which is converted to the decimal value of \n which is 10 in ASCII. Replace %d with %c. Also it makes no sense, why don't you just:
printf("%s\n", lua_pushfstring(L, "Hello, world!"));
>>
>>51824323
  char c[1];
sprintf(c,"%d",'\n');
printf(&c);

retarded
printf("%c", "\n")

Or just do "Hello, world!\n" instead.
>>
>>51824382
Then you didnt need much in the way of custom controls or complex styling. That's what WPF excels at
>>
>>51824375
>>51824400

Ok I got it working:
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{
lua_State *L = luaL_newstate();
luaL_openlibs(L);
printf(lua_pushfstring(L, "Hello, world!"));
char c[2];
sprintf(c,"%c%c",0xA,0x0);
printf(c);
}


Now it prints "Hello, world!" and a newline.
I really like how compact and efficient C is, it's way better than Java.
>>
>>51824452
I know it's a joke, but I'm not laughing.
>>
>>51824452
i want to see your java code bud
>>
>>51824452
This is the shittest bait I've ever seen
>>
>>51824323
>Trying to write Hello World in C
Using Lua C API?
>>
>>51824234
Its far too late now. Ive only gone to class for exams. Maybe if I beg someone theyll tell me whats on the final.
>>
>>51824462
Made this yesterday:
public class JTestbuild
{
public static void main(String[] args)
{
int i = 0;
for(;;)
{
if(i==0){
System.out.print("H");
}
if(i==1){
System.out.print("e");
}
if(i==2){
System.out.print("l");
}
if(i==3){
System.out.print("l");
}
if(i==4){
System.out.print("o");
}
if(i==5){
System.out.print(",");
}
if(i==6){
System.out.print(" ");
}
if(i==7){
System.out.print("w");
}
if(i==8){
System.out.print("o");
}
if(i==9){
System.out.print("r");
}
if(i==10){
System.out.print("l");
}
if(i==11){
System.out.print("d");
}
if(i==12){
System.out.print("!");
}
if(i==13){
System.out.print("\n");
}
if(i==14){
break;
}
++i;
}
}
}
>>
>>51824480
>no unit test
i'm disappointed
>>
>>51824355
I can see that.

It's messy to have markup shit in actual code. I makes everything much neater to have everything static about the UI layout declared in something like XML. It also means the WYSIWYG editor can understand it and you can adjust that shit easily, which is impossible if you put everything in code.
>>
>>51824480
>int i = 0
>not for (int i = 0
>>
>>51824470
I tried writing it without the lua api the other day. This is what I came up with:
public class JTestbuild
{
public static void main(String[] args)
{
int i = 0;
for(;;)
{
if(i==0){
System.out.print("H");
}
if(i==1){
System.out.print("e");
}
if(i==2){
System.out.print("l");
}
if(i==3){
System.out.print("l");
}
if(i==4){
System.out.print("o");
}
if(i==5){
System.out.print(",");
}
if(i==6){
System.out.print(" ");
}
if(i==7){
System.out.print("w");
}
if(i==8){
System.out.print("o");
}
if(i==9){
System.out.print("r");
}
if(i==10){
System.out.print("l");
}
if(i==11){
System.out.print("d");
}
if(i==12){
System.out.print("!");
}
if(i==13){
System.out.print("\n");
}
if(i==14){
break;
}
++i;
}
}
}


It worked but there were a bunch of compiler warnings (just warnings, not errors) so I abandoned it.
>>
>>51824480
>for(;;)
What the hell does this do?
>>
>>51824518
It's a faggy way of writing
while
>>
>>51824508
Goddammit I posted the wrong code.
THIS is my C program:
const _start(){
asm(
"movl $len,%edx;\n"
"movl $msg,%ecx;\n"
"movl $1,%ebx;\n"
"movl $4,%eax;\n"
"int $0x80;\n"
"movl $1,%eax;\n"
"int $0x80;\n"
"msg: .ascii \"Hello, world!\\n\";\n"
"len = . - msg;\n"
);
}
>>
>>51824452
This is undefined behavior, you're going to need a goto statement somewhere but I'm not sure where
>>
>>51824518
loop forever
>>
>>51824518
C idiom for infinite loop

OPTIMIZED over while (1) because this wastes memory on storing (1)
>>
>>51824525
>int $0x80
>platform specific
>>
>>51824544
Yeah that's why I switched to Lua.
>>
>>51824524
>>51824529
I can see its a while loop, but like syntax wise I dont understand. Why does the compiler accept this.
>>
>>51824553
Because it's valid.
>>
>>51824553
Why not?
>>
>>51824552
This is a really shitty meme. What do you get out of this?
>>
>>51824553
A for loop is just syntactic sugar for a while loop.
The for statement itself is just a while loop statement with three statements inside it - typically these statements are a variable initialization, boolean statement, and increment statement. But this isn't always true.
This:
for(;1;)
is the same as
while(1)
and I'm fairly certain both are valid C++. Not sure about Java, but for(;;) is definitely valid in both.
>>
>>51824541
would that really not be optimised by the compiler?
>>
>>51824586
bullshit:
>A for loop is just syntactic sugar for a while loop
goto bullshit
>>
>>51824436
I have to disagree
Creating custom controls is extremely easy in WinForms
In WPF you can't even get the source of the ScrollBar control without obscure hacks

>>51824498
>which is impossible if you put everything in code
It's literary what I'm doing though
Only instead of an XML file I have a static class
>>
>>51824601
for(a; b; c) {
d;
}
// is equivalent to
a;
while(b) {
d;
c;
}
>>
>>51824601
u dumb m8?
for (int i = 0; i < 10; i++)

int i = 0;
while(i < 10) {
...
i++
}
>>
>>51824635
>>51824639

>is equivalent
>is syntactic sugar for

these are not the same thing
>>
>>51824601
It is.

/* These should be equivalent: */

for (size_t i = 0; i < 64; ++i) {
;
}

{
size_t i = 0;
while (i < 64) {
;
++i;
}
}
>>
>>51824651
>I am pedantic
>I am straight
These are not the same thing. Gay cunt.
>>
>>51824651
They are in this case.
>>
>>51824659
>>51824666
Retards. Then I guess a while loop is just syntactic sugar for a for loop.
>>
>>51824651
Do you know what syntactic sugar? Yes it's syntactic sugar according to the AST.
>>
>>51824601
Yeah I know a while loop is just syntactic sugar for a goto and goto is just syntactic sugar for if and if is just syntactic sugar for JMP, but nobody really cares.
>>
>>51824674
>In computer science, syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express. It makes the language "sweeter" for human use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer.
"Syntactic sugar for" doesn't mean "gets replaced with".
>>
>>51824674
for does more than a while, it can't be. you're really dumb m8. Stop posting.
>>
>>51824674
You haven't read the C standard.
>>
>>51824677
>>51824680
>>51824689
>>51824692
>>51824700


ok, where does the C standard say that a for loop is a specific kind of while loop, or is syntax for a while loop
>>
>>51824635
Those are both syntactic sugar for
a;
if(0){
x:
d;
c;
}
if(b) goto x;
>>
>>51824725
What's your point?
>>
What frameworks should I study to maximize job acquisition possibilities? I'm intermediate in C++, Java, and Python, but I would rather not deal with the usual shit they ask for in Java jobs and might consider Django for Python even if I don't fancy doing web programming
>>
>>51824720
It all gets compiled to CMP/JMP/JEQ anyway, so it's literally all syntactic sugar for those three commands.
>>
>>51824748
a and b are syntactic sugar for c
does not mean
a is syntactic sugar for b
>>
>>51824720
You have a basic misunderstanding of what the word "syntactic sugar" means. You should probably stop posting unless you're sure about embarrassing yourself further.
>>
>tfw make loading function from a json file in libgdx
>tfw no error
>tfw the class that holds the values that should be loaded don't change them
>tfw nothing happens
>tfw the code works
>tfw no idea why this happens
;u;
>>
>>51824651
>>is equivalent
>>is syntactic sugar for
>these are not the same thing
An equivalent expression with different (i.e more convenient) syntax is the definition of syntactic sugar.
>>
>>51824778
What the fuck are you on?

If a certain form of for loop and a while loop are equivalent, that doesn't imply as to whether or not one is syntactic sugar for another.

Tell me where the C standard explicitly states that's the case, or that a for loop is syntax for a while loop with certain extra statements, or fuck off
>>
how do I get this stupid cat to stop messing around with my keyboard lads? I'm trying to program
>>
>>51824821
So a while loop is syntactic sugar for a for loop?
>>
>>51824825
>If a certain form of for loop and a while loop are equivalent, that doesn't imply as to whether or not one is syntactic sugar for another.
The one that's more convenient to type is the syntactic sugar form of the other.
>>
>>51824829
Shitpaws lose again.
Welcome to the /dog petting thread/
>>
>>51824825
The C standard doesn't say array[i] "is syntactic sugar for" *(array + i), but it is. You have a very weak understanding of the concept, like the CS grad meme.
>>
>>51824869
>the one that's more convenient
Oh, so it's subjective. Brilliant.

No, it has to be made for that purpose.
So explain where the C standard says so.
>>
>>51824849
Could be, depends on what form and the context.
>>
Syntactic sugar sounds retarded, childish and autistic.
>>
>>51824896
>Oh, so it's subjective.
Yes, that is the point of syntactic sugar.
>it has to be made for that purpose.
No.

C could have just had if + goto but decided to add while, do-while and for because they are convenient forms for many common looping constructs.
>>
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff754762e in vfprintf () from /usr/lib/libc.so.6


why is this happening
>>
>>51824961
Because you touch yourself at night.
>>
>>51824961
well what does your call to printf look like?
>>
Is this defined behavior? What will this print?
#include <stdio.h>
#include <stdint.h>

int
main(void) {
int32_t a[] = { 0x1, 0x2, 0x3, 0x4 };
printf("%d\n", *((char *)a + 0x7));
return 0;
}
>>
>>51825035
It's well defined in so far that char * is allowed to alias anything, and successive increments of a char pointer set to some object will yield all the bytes that make up it.
But the actual value printed will depend on endianess.
>>
>>51825035
It'll probably print garbage, since it looks like it'll try to access something outside of a
>>
I have a Websocket API, which passes stringified JSON objects from server to client and vice versa. Would tokenizing the strings I use for fields and identifiers to integers to decrease network load be advantageous in terms of reducing load, or more complicated parsing procedures than native JSON parsing would hurt performance enough to outweigh any advantage? Assuming everything is gzipped, of course.
>>
>>51825035
It will print 2 on big endian systems and 0 on little endian
>>
>char wasn't called byte
>>
Ask your beloved programming literate anything.
Thread replies: 255
Thread images: 14

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.