[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: 20
File: daily programming thread2.webm (2 MB, 600x338) Image search: [Google]
daily programming thread2.webm
2 MB, 600x338
old thread: >>54454616

What are you working on, /g/?
>>
>>54463714
arent the EP's 5 mins? just put the entire thing in a webum
>>
>>54462328
this is the equivalent of taking /dpt/'s advice about learning python
>>
>>54463758
Wouldn't be SFW
>>
>>54463758
for some reason, webms are still limited to 2 minutes and 3MB despite the file limit being 4MB.

also the anime is too short, go read the manga, it's like 5 volumes.
>>
>>54463961
kys
>>
>>54463961
Why don't you learn a real language?
>>
>>54464036
Such as? Name it for me.
>>
>>54464036
I would also like to know.
>>
>>54464050
>>54464076
x86 Assembly
It's a real man's language
>>
>>54464091
x86 is dead gramps
ARM IS THE DESIGN OF THE FUTURE BABBY!!!!!!!!!!
>>
>>54464091
>x86
>not even x86-64
Obviously the real man's language is ARM.
CISC babies need not apply.
>>
File: hacker.png (255 KB, 600x561) Image search: [Google]
hacker.png
255 KB, 600x561
>>54464091
I also know x86 assembly. I've written programs using it that use the kernel instead of libc. But C has a lot of practical applications assembly has lost in the real world.
>>
>>54464109
is it impossible to scale up to quad/octo core 100W high-end desktop cpus or is it just that no one has bothered
>>
>>54464133
>C
>practical
In the real world the only thing people care about is ruby and node.js. Obviously if you cared about a real language, you would use Erlang and maybe Elixir.
>>
File: this_is_what_$20k_buys_you.png (12 KB, 483x315) Image search: [Google]
this_is_what_$20k_buys_you.png
12 KB, 483x315
Rate my commit comments, /dpt/.

Post yours.
>>
>>54464180
lel
>>
Please do not use an anime image next time, thank you.
>>
>>54464139
I don't understand what you're asking for. What does this have to do with ARM? ARM is useful for low power applications, which as far as servers go actually save costs on power per watt. So as far as that goes, some companies are willing to go with ARM for servers because it helps reduce operating costs while getting the same amount of computation done.
>>
>>54464210
Please do not complain about the opening poster's choice of image next time. Thank you.
>>
>>54464218
but can you make it so that they're good for desktop pc usage (higher performance than intel/amd)
>>
>>54464264
No. If you need a workstation, Intel is generally best. But getting a 1000W chip would be retarded. People who need high performance computation would get GPUs anyways.
>>
is there really anyone who unironically believes that Java/C# are better than C++/C?

Aren't arrays and stacks objects in Java?
>>
Do I need to become a trap to program? Please /g/, I need to know!
>>
>>54464331
Arrays are objects in java, but they are defined separately from other objects. I'm pretty sure stacks are just objects.
>>
>>54464331
Different tools, anon.

Stop comparing a wrench to a hammer.

Sure, you can probably drive a nail with the wrench, but it's easier to use the hammer.
>>
>>54464381
Yes, you're required to be a sissy butt-boy slut.
>>
>>54464404
What if I'm a boy who likes to dress as a girl who likes to dress as a boy?
>>
How would I go about deselecting in a listview if one clicks on the empty space below(in the listview)?
>>
File: 1457247881272.jpg (6 KB, 225x225) Image search: [Google]
1457247881272.jpg
6 KB, 225x225
>>54464180
>>
>>54463714
god damn I want to molest Hime

Also, why is Android such a piece of shit, can't even directly connect to an SQL server
>>
>>54464331
>is there really anyone who unironically believes that Java/C# are better than C++/C?
yes, for most tasks
>Aren't arrays and stacks objects in Java?
so?
>>
>>54464446

KOJIMAAAAAAAAAAAAAAA
>>
>>54464430
the levels of indirection are hurting my brain!
>>
Why are for loops in python so fucked?

>Learn a few compiled languages
>For loops are always easy to understand, (var=x;var=/</>y;x+z/-z/*z/++/--)
>Easy as cake to understand and implent, easy to see where everything is happening, very useful and robust
>Python dev decided he didn't want that 4noraisin
>For i in array makes i equal to the relevant index in the array, can't access what index it's on without fuckery
>For i in range(x) fixes this, but it starts to get a little wacky if you want to only loop for an unknown index of an array, resulting in the unweildy for i in range(len(array)) which is slow as fuck and consists of 2 function calls
>Can't change the increment of i, it's always going to be +1 so good fucking luck, lad
>No support for subsystems to do complex for statements

I mean come on, it's one of the easiest loops to compile into assembly
MOV CL,10
FOR:
<loop operations go here>
DEC CL
JNZ FOR


And I guarantee you that for i in range(len(array)) isn't run as cleanly and as neatly as that.

Fuck python.
>>
>>54464486
>Why are for loops in python so fucked?
>Why is python so fucked?
FTFY
>>
>>54464486
>Proof I'm a retard: The post
>>
>>54464458
>for most tasks
there are far better tools for tasks where you can't spare the time to write c++ than java and C#
>so
Why make stacks an object when they are a datastructure inherent to the CPU? You are over complicating them. Arrays are just memory managed stacks.

If you need to run methods on an array, why not copy an array and create an object's attribute out of it, then run whatever method you need to?
>>
>>54464486
>>54463765
>>
>>54464331
"Better" is vaguely defined. I use both C# and C++ heavily, and I find that each is better than the other in some ways, but I can't say that one is wholely better than the other.
>>
>>54464486
for i, val in enumerate(array): 
print i
print array[i]
print val
>>
>>54464542
>DURR JUST USE WHILE LOOPS INSTEAD OF FOR LOOPS
I'm sick of this meme.

Python for loops aren't even for loops. They are do loops in disguise.
>>
>>54464577
Learn the language and stop complaining like a bitch, webcuck.
>>
File: test.webm (2 MB, 427x240) Image search: [Google]
test.webm
2 MB, 427x240
>>54463791
easy way around that is to increase the framerate, and play it back slower
>>
>>54464574
this just further cements my position. who the fuck designed this language and thought that adding more keystrokes is a good move?

What was wrong with
for(i=0;i<sizeof(array);i++)
>>
>>54464390
I like your analogy, because you shouldn't drive a nail with a wrench, but you can and the results are ultimately the same.
Also, you can't tighten a bolt with a hammer, so the hammer uses change EVERY FUCKING BOLT to be a nail instead, because it jest werks.
>>
I love C++.

But as far as I see it, C# or Java are all in all a better bet. Not because they are faster than C++, but because when you add up their qualities, they end up being more productive, needing less training, and having more complete standard libraries than C++. And as for most of programs, their speed differences (in one way or another) will be negligible...
>>
>>54464637
shut the FUCK up
>>
>>54464637
Honestly I would stick to C# forever if it wasn't for Qt
>>
>>54464637
You just summed up why C# is my preferred language for getting shit done.

It's like a magic wand that's a little finicky at times, but it can literally do anything.
>>
>>54464620
it was made by one sub-105 IQ normie

people give it way too much credit, just because it's a language doesn't mean it's anywhere near as good as the proper languages
>>
>>54464662
python is better
>>
>>54464637
not to mention that you can use the time saved with productivity improvements to optimise your Java/C# code. It's not that uncommon to hear of C++ codebases being rewritten in C#/Java being orders of magnitude faster because there was much more time available for optimisation and many easy ways to optimise.
>>
>>54464637
no one cares, shut up
>>
>>54464637
>being more productive
Whew. Maybe if you are developing web apps in visual studio, but I bet I can get more done in vim with c++ in the same amount of time than any bay area hipster can with his net beans.
>>
>>54464670
kys

>>54464637
java or C# are better if you don't need the best performance

C++ is necessary for things like proper games
>>
if a trap gets fucked in the ass, have they lost their virginity?
>>
>>54464660
C# is sorely missing a good cross platform UI library. Java has a big advantage here. Even though Swing/JavaFX are shit, at least they work and are well supported.
>>
>>54464670
I don't care for the forced indentation and dynamic typing, personally.

I'm sure Python is fine, but I have no need to force myself to use it.
>>
>>54464620
error prone. just last week I wrote a nested loop like this
for (int i=0; i<sizeof(array); i++) 
{
for(i=0; i<sizeoff(array2); i++) {}
}

I've written loops thousands of times but I still make this mistake. probably because the habit is so ingrained I don't pay attention to the names anymore. call me a bad programer but I like writing
for i in array

more than
for (int i=0;i<sizeof(array);i++)

not least of which I now dont have an extranious "i" in scope
>>
>>54464693
see I don't have a problem with either of those.

But some of the syntax is special snowflake and it makes me not want to use it.
>>
>>54464686
Even android UI tools are better than fucking swing, jesus christ.
>>
>>54464705
but if you have two nested for loops in python and use the same increment variable you get the same error
>>
>>54464712
Yeah, android UI isn't really even that bad as UI frameworks go. All of them suck for one reason or another.
>>
>>54464730
word. I usually do something like
for person in house.people
for body_part in person.parts

so name collisions are still possible but less likely
>>
>>54464637
I agree for the most part, and personally find C# to be very near ideal as far as aesthetics and philosophy for a language of its sort. However, your use of the word "negligible" here may be a bit of a stretch. I'm all for the use of C# for a reasonable range of applications, but I also think it's important that the performance difference not be understated. I should also mention that while C#/C++ is apples to oranges, C#/Java is apples to apples, and it's much safer to say that C# is better on the whole. Not a huge difference, but enough that I would take C# over Java without hesitation any day, provided it's an option.
>>
>>54464670
You mean ruby.
>>
>>54464686
Massive improvements on that front soon, I would hope.

At the moment, you can use Xamarin to target all mobile and GTK# to target all desktops.

UWP is a write-once GUI that you target device families (tablet, mobile, desktop, console) and the GUI automagically modifies itself to better suit the platform. Windows systems and PS4 only for now, IIRC.

After the recent freeness of Xamarin, I'd imagine the next big thing would be the cross-platform desktop GUI.
>>
>>54464553
>there are far better tools for tasks where you can't spare the time to write c++ than java and C#
like? I'm sure there's a few, but none of them are that well established and have that many great libraries
>Why make stacks an object when they are a datastructure inherent to the CPU? You are over complicating them. Arrays are just memory managed stacks.
>If you need to run methods on an array, why not copy an array and create an object's attribute out of it, then run whatever method you need to?
Java arrays are pretty low level and the little OOP stuff they have actually very simplifies things. I can't really picture what you propose, but it seems way more complicated than what Java is doing now.
>>
>>54464738
At first I was annoyed as hell that I had to refresh my XML knowledge just to do the most basic shit in android.
Eventually though, it grows on you, especially the fact that the GUI stuff is fully segregated from the logic code, as it fucking should be.
You can make horrible hybrid classes that directly access the GUI, but you'll be limited eventually, so it forces people to use the segregated XML.

That said, the inconsistencies between camel case, pascal case and snake case never cease to trigger my autism.
>>
>>54464754
This is how I do it in C# as well.

It's actually readable like this.
>>
>>54464693
>I don't care for the forced indentation and dynamic typing, personally.
I don't care either, it doesn't bother me one bit.
>>
>>54464765
UWP on PS4?? The shit?

Perspex is something that would fit the bill perfectly if they ever finish it. https://github.com/Perspex/Perspex
>>
its not gay to be sucked off by a trap desu
>>
>>54464761
No, ruby is worse.
>>
>>54464828
>>>tumblr
>>
>>54464783
I fucking hate the way you have to inflate the xml layouts, and even worse, the way you are meant to access elements by id. It could hardly be more verbose. They couldn't just do it like WPF does it, because that would be too much work for them i guess. It's incredibly retarded sometimes.

That said, it's pretty fast, mature, fully featured and well supported. That's good enough for any UI framework.
>>
>>54464637
Hello vikram! How is the smell in the slums today? See any new children with 9 legs? Did you poo in vindaloo today
>>
I'm fucking around with playing cards today. I have this method in my Card class, that is supposed to compare two cards are return true if this < the other card. btw, to keep it simple, I have the face value and suit represented as integers.

   /**
* Compares this card against another card.
* @param that - the other card
* @return true if this < that, false otherwise
*/
public boolean less(Card that) {
if( this.suit == that.getSuit() ){
if( this.faceValue < that.getValue() ){
return true;
}
} else if( this.suit < that.getSuit() ){
if( this.faceValue <= that.getValue() ){
return true;
}
}
return false;
}


Is there a cleaner way to write this method?
>>
>>54464808
Are you stupid, or intentionally misunderstanding the concept of 'not caring for something'?
>>
>>54464886
>NullPointerException
m8...
>>
>>54464893
Are you new or just "pretending"?
>>
>>54464899
and where did you pull that from?
>>
>>54464812
>UWP on PS4?
I may have been wigged out on lack of sleep while watching //build/, I swear they mentioned it in a universal app demo.

Consider it false unless I find actual proof, I suppose. Certainly compatible with Xbone though.

What's neat is a developer can convert a full application to a UWP fairly easily.

They ran The Witcher 3 through the converter and ran it natively in a Store App with no performance hit.

That means dev once and deploy to Xbone, PC, WinPhone, etc, even if it's a Win32 application.
>>
>>54464930
from that.getSuit()
>>
>>54464886
Just implement Comparable
>>
>>54464945
Yes I believe you're right. That was my original plan, and then I realized that I could compare the cards' face values and suits because they are represented as integers.

I'll need to re-work some things. Thanks
>>
>>54464913
I've been around since Snacks, anon.

It appears that your post was either
>intentional twisting of words
>accidental retardation

I'm just legitimately curious which it was. I think I can assume you were 'trolling' now.

Good show, I was baffled for a while.

Feel free to screenshot this for teddit gold.
>>
>>54464886
is this Java? The idiomatic way to do so is to implement Comparable:
class Card implements Comparable<Card>

Then you get to plug into a lot of standard functions for free. For example, Collections.sort(cards) will sort a list of cards using your custom logic.
>>
>>54464940
still not getting how that would throw an np exception...
>>
>>54464899
I think it supposed to then. you can't really expect any non-exceptional flow after passing null to a comparing function
>>
>>54465087
The documentation should cover that.
>>
File: 15090961835_c4f26e4890_b.jpg (197 KB, 949x652) Image search: [Google]
15090961835_c4f26e4890_b.jpg
197 KB, 949x652
Hello, I'm thinking of learning a programming language for the first time. I have a decent understanding in how computers work, and am very good at Maths and logical thinking, but I have a pretty bad memory.

I just want to learn a language that can automate tasks, such as rearranging files into folders, ripping all pictures off a website etc.

I currently have Windows, Mac and Linux triple-booted, so operating system is not a boundary for me. Thanks!
>>
>>54465097
yeah
>>
>>54465101
python
python
python
>>
>we wanted the sombrero-american audience
http://taco.visualstudio.com/
>>
>>54465101
Bash
>>
>>54465101
Sounds like Python might be up your alley.
>>
>>54465101
Any of the multi-purpose high-level languages are fine for this.

C# or Python would be the easiest ones to learn and get shit done.

C# only if your daily driver is Windows.
>>
>>54465101
Use C.
>>
>>54465101
python is literally the most perfect language for this situation.
>>
>>54463714
This is still the most amazing thing I have seen, everytime you post it.
>>
>>54465101
Scheme
>>
>>54465087
woah woah woah

this isn't supposed to be a legit application. it's not like I'm throwing it up on github or anything.

of course there is the possibility of a np exception, right about that, but I just didn't feel like going all out like that
>>
File: 1452990796209.gif (842 KB, 724x720) Image search: [Google]
1452990796209.gif
842 KB, 724x720
What's a good way to learn haskell? I started reading haskell tutorial for C programmers but it kinda lost me. Want to try out a functional language to see what all the hype is about.
>>
>>54465101

Assembly.
>>
>>54465114
>>54465132
>>54465138
>>54465153

What are the limitations of Python?
>>
>>54465259
Slow
>>
>>54465199
I meant that throwing an exception after passing null as the argument is the proper behavior in this case. you could even use
Objects.requireNonNull(that, "The argument cannot be null");

as the first statement in the method to make the cause of the exception clear.
>>
>>54465211
like most languages, the best way to learn it is to write programs. can you fizzbuzz in Haskell yet?
>>
>>54465279
I basically don't know how to do anything, I really like K+R, because it taught me syntax while giving me small programs to try on my own, but I don't really understand functional or really know any of the syntax so I can't do anything yet
>>
>>54465259
>>54465272
And it looks like shit. C has the best looking syntax.
>>
>>54465311
Yeah significant whitespace is super gay
>>
>binary literals

Neat.
>>
>>54463961
Keep overflowing the stack, Hime!
>>
http://pastebin.com/kyjt3dH6

What exactly is wrong with my syntax here when trying to write out my member function? I'm getting all sorts of errors, the syntax for template classes when overloading operators is really confusing to me and VS isn't really helping me figure out what I should be doing.
>>
Learning to program with Racket language using the How to Design Programs book is a good idea? I plan to learn bash and python aswell but will dedicate less time to these 2.
>>
>>54463961
Keep overflowing the stack, Hime!
>>
File: 1.jpg (85 KB, 438x700) Image search: [Google]
1.jpg
85 KB, 438x700
>>54465427
>overloading operators
>ever
>>
>>54463961

Why's this book so famous?
>>
>>54465453
It's the gold standard in technical writing.
It's not designed for retards and it doesn't pad the book with 2000 pages of useless appendixes just to inflate the page count on store shelves.
>>
>>54465453
because one of the authors the creator of the C language
>>
File: mallocast.png (1 MB, 1280x720) Image search: [Google]
mallocast.png
1 MB, 1280x720
>>54465447
Are you retarded? You know why Java's ArrayList class is so shitty and hard to use? Because they never implemented (and really can't implement) operator overloading.

>>54465453
>The C Programming Language (sometimes referred to as K&R, after its authors' initials) is a well-known computer programming book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the language, as well as co-designed the Unix operating system with which development of the language was closely intertwined.

>>54463961
KEEP OVERFLOWING THE STACK, HIME!
>>
File: tuples.png (208 KB, 894x504) Image search: [Google]
tuples.png
208 KB, 894x504
YO DAWG I HERD YOU LIKE FUNCTIONS SO I PUT A FUNCTION IN YO FUNCTION SO YOU CAN
 'Program' has exited with an unhandled exception of type System.StackOverflowException
>>
>>54465211
Maybe you can try Learn You a Haskell.
>>
>>54465453
Because it comes with a dvd with your mother's amateur porn videos.
>>
File: 1452956028086.jpg (203 KB, 628x640) Image search: [Google]
1452956028086.jpg
203 KB, 628x640
>>54465515
Thank you, I will have a look
>>
>>54465447
What are you talking about.
What is the point of using OOP if you are not going to do it right?
>>
>>54465427
The ++ after the C seems to be quite a big oversight from you.
>>
>>54464673
Orb-tan, what's your favorite language?
>>
>>54465114
>>54465132
>>54465138
>>54465153
>>54465272

Okay, so it looks like Python might be for me. Where do you recommend I learn this. Get a book, or will any website do?
>>
>>54465565
Learn Python the Hard Way if you're new to programming.
>>
>>54465555
The quads compel me the answer.

F#
>>
>>54465305
I'll get you started on fizzbuzz then. In functional programing, a lot of control structures are replaced by lists operations, so instead of writing
for (int i=0; i<100; i++) {
fizz_the_number(i);
}

you write
map fizz_the_number [1..100]

that should be enough to let you banging, but if you have any questions feel free to ask.
>>
>>54464774
python

>java arrays are pretty low level
Objects are as far from low level as you can get.
>>
>>54465320
>projecting
why do you have to bring up your sexual orientation, anon?
>>
>>54465495
>(and really can't implement)
Of course they can, just like they did for String.
>>
>>54465542
operator overloading is not an OOP feature. what's more, it disqualifies a language from being purely object oriented, because all operations performed on objects must be done only through methods exposed at those objects.
>>54465495
enjoy your useless syntactic sugar that makes code unreadable in most cases and provides no good way to handle errors. also
>ArrayList
>hard to use
>>
>>54465603
you should give them something to search for like partial application and currying. or let them start by learning about functional composition instead of 'think of everything as a list'
>>
>>54465565
this
>>54465572
>>
Give me one good reason why I shouldn't use Rust instead of C++ for my next project
>hard mode: don't mention SJWs
>>
>>54465610
He didn't claim they were anon.
>>
>>54465667
It's a memelang.
>>
>>54465667
library support
usable debugging support
profiling support
>>
>>54465639
Those are great ideas that would help him but the best thing is to learn how to write programs. Haskell has a lot theory around it. You can read about neato functional topics all day, but I'd rather see people putting the language into practice.
>>
so there is no pair of numbers, perfectly representable as floats, where one is between 1 and 2 (not exactly 1 or 2), and the other is between 2 and 4 (not exactly 2 or 4), such that their product is 4?
>>
What's the most recent python library for handling post requests?

I'm trying to login to an smf forum with requests library and it simply does not won't to work. I think my login data is wrong but I can't find a decent tutorial for this. Everything is at least 5 years old.

Fuck me.
>>
>>54465740
nope you can only divide by powers of two with full accuracy because binary
>>
>>54465667
There's no reason to use either when you can use python.
>>
>>54463714
What anime is this?
>>
>>54465638
Meant to say "won't".

>>54465639
Not worth replying.
>>
>>54465610
Java arrays are not that different from C arrays, you just can't do pointer arithmetic, get runtime bounds checking and several useful methods, like length. they're objects probably because every reference variable that's always allocated on the heap is an object in Java
>Objects are as far from low level as you can get.
not really
>python
but you sacrifice a shitload of performance compared with compiled languages and that's usually not the case with Java
>>
What type of programs does C excel at? I'm trying to get practice with the language but I don't know what kind of programs I should be writing.
>>
>>54465447
this

>>54465495
kys
>>
>>54463714
contributing patches to the Linux kernel
>>
>>54463961
DELETE AND BAN
>>
>>54465812
himegoto

it's full of dicks
>>
>>54465829

Write a language interpreter.
>>
I guess I'm just bad at this or don't love it...

I can spend so much time being stuck on something without finding the answer and then I just start copy pasting everything from stack overflow until it works (which it never does). I can't control myself.
>>
java > c
>>
>>54465934
I like both Tbh
>>
>>54465934
this
>>
https://github.com/wrvc/etc/blob/master/loading-bar.c
rate my program
>>
>>54465986
>dat preprocessor
dropped
>>
>>54465934
>>54465968
k tard
>>
>>54465986
literally 0 comments / 10
>>
>>54466006
it's 2016
>>
>>54466013
comments are only needed if you're explaining some fancy algorithm or something
>>
>>54465138
>C# only if your daily driver is Windows
monoVM is fine tho
>>
>>54465986
extremely cancerous/10
>>
>>54465986
there's something especially retarded about defining a shorthand for something needlessly verbose
>>
>>54466033
>monoVM
not around here it's not
>>
>>54465986
>#define UI64 unsigned long long int

Nigga
>>
>>54466052
yes it's called C code
man and i do hate it!
>>
>>54466055
What about CoreCLR?
>>
>>54466031
>comments are only needed if you're explaining some fancy algorithm or something
this is a terrible mindset to develop. have fun trying to figure out what your code does after not looking at it for a year
>>
>>54466089
i literally just did, and it was easy as fuck, despite it being a top of the line proprietary signal processing system
>>
>>54466089
he's right though.

>have fun trying to figure out what your code does after not looking at it for a year
So long as i wrote it well, I have absolutely no problem with this and I do it frequently.
>>
>>54466031
hysterical
>>
>>54466118
>top of the line
anon...
>>
>>54466085
coreclr only supports enough to run asp.net mvc, not everything in the BCL.
>>
>>54465819
>not really
They are fundamentally not supported by any instruction set on any kind, the abstraction of objects is only possible with extremely complex planning, register and stack juggling and thousands and thousands of operands spread across hundreds of flags.
>>
>>54465868
C's type system is pretty shit for representing ASTs
>>54466130
mostly, but I do find sometimes there are some tricky bits that take me a few minutes to remember and I'd rather get it immediately
>>
>>54466278
>some tricky bits
These are the bits you comment. Otherwise you should strive to make code readable. Unnecessary comments bloat the codebase, can themselves be confusing and go out of date or become misleading very easily. I've seen this happen far too often in code bases.

Seeing stuff like
//update the name textbox
window.nameTextBox = person.name;

stuff drives me nuts. It's clearer to just read the code that to read the comment to understand what's happening. Unless you're doing something unusual this is generally the case.
>>
>>54466278

ASTs are amazingly simple to represent in C. Are you retarded?
>>
File: Lg4MH3P.gif (925 KB, 700x478) Image search: [Google]
Lg4MH3P.gif
925 KB, 700x478
gold:
https://www.reddit.com/r/programming/comments/4iguqx/what_should_you_learn_to_get_a_better_coding_job/d2yia6j
>>
>>54466355
i hate reddit threads, every reply chain has it's own "READ MORE" link and it makes it impossible to follow any conversation
>>
>>54466355
pretty sure that anti-oop tard is from /dpt/
>>
>>54466355
i don't get why they're hiding his posts. i mean, he's completely wrong but they can't just hide his posts..
>>
>>54466496
Because opinions are "harmful".
>>
>>54466496
because /r/programming/ is a "safe space"
>>
>>54466496
reddit is self-moderated, that guy's posts received too many downvotes.
>>
>>54466519
No, because he has too many downvotes.

That's why they're "hiding" his posts.
>>
>>54464180

> what is embedded
>>
>>54466260
http://www.drdobbs.com/embedded-systems/object-oriented-programming-in-assembly/184408319
bullshit, especially for java arrays from which you can't inherit etc. considering that object variables in java are just hidden self dereferencing pointers, an array of primitives in Java isn't much more complex than a pointer to a struct with an array and several function pointers
>>
C# :
- Xamarin
=> Android, iOS, Windows Phone, W10 and OSX apps
- Unity engine
- .NET apps
- .NET / Mono / CoreCLR web apps

tell me why you don't use it already
>>
>>54466718
because mono is shit and I dont want to program on phone apps
>>
>>54466718
Because F# is better
>>
>>54463714
job applications for an entry level rails position. kill me
>>
>>54466339
not nearly as simple as in Rust, for example
im not saying it's bad for interpreters, but out of all the things C can be used for that's not really one where it does much better than any other language
>>54466338
yeah I agree. the only comments I ever leave in other than those are comments for generating documentation
>>
>>54466740
>mono is shit
but it's not
>>
>>54466760
rails is dead bro
>>
>>54466718
>Android
i hardly trust java to compile to a respectable native code and sure as shit i'm not trusting a 3rd party integration layer.
enough layers already.
i don't write code for the rest of those so meh.
>>
>>54466816
mono is faster than java on android
>>
>>54466810
It is though, I mean for a community project it's not bad but still...
>>
>>54466856
sauce? i can't find shit
>>
>>54466911
Basically Xamarin cherry picked benchmarks as "proof"
>>
>>54463714
What's the fastest way to turn a website into an Android app? I'm using Xamarin. Someone on here suggested WebView yesterday. I have 6 hours.
>>
>>54466911
fuck, can't find it now. There's a blog article that compared a bunch of crossplatform frameworks and did benchmarks.

Mono was faster than Java on a bunch of shit. Though that might not still be that case.

>>54466945
Wasn't an article by Xamarin. You're thinking of when Xamarin ported Android to C# and found it ran faster than the original.
>>
>>54466972
WebView. Takes 2 minutes. Create app with a webview inside. Make it load your website. Done.
>>
File: 1456115263879.gif (937 KB, 255x163) Image search: [Google]
1456115263879.gif
937 KB, 255x163
>>54463714
Fuck everything. I'm just fapping to that.
>>
>>54467032
Just remember to kill yourself afterwards
>>
>>54466677
You just searched on Google "Assembly object oriented" and didn't even read what you just shared. I see you haven't done a lick of Assembly language in your life, either, you aren't even slightly read on it. The article that you posted specifically covers replicating what happens when you compile an object oriented program, the result is not even close to object oriented anything. That's like writing some 2,000 lines in C utilizing nothing but gotos, stacks and booleans and saying that it's object oriented because it returns the same result.

>an array of primitives in Java isn't much more complex than a pointer to a struct with an array and several function pointers
Functions, arrays and structs are all extremely complex to replicate in low-level systems.

Please for the love of god stop talking about something you know nothing about.
>>
>>54467008
Okay. I don't really know C# beyond the basics. I hope I can pull this off.

How do I get the website? Can I just use wget in powershell? I don't know if I have bash installed in this laptop.

How do I load the app onto the Android phone?
>>
>>54467088
you just do
this.myWebView.url = "http://muhsite.org"

>How do I load the app onto the Android phone?
Dude, you need to read this stuff up. Just follow the tutorials on the xamarin website for getting started.
>>
File: 2016-05-09-14.14.55_screenshot.png (706 KB, 2512x1940) Image search: [Google]
2016-05-09-14.14.55_screenshot.png
706 KB, 2512x1940
Fixing up some minor bugs in one of my websites.
>>
>>54467071
He thinks pointers are relevant to low-level systems, and bought the "C is low level" meme. Stop replying to him.
>>
Can i write android apps in C or does everything have to be java?
>>
>>54467148
You would have to deal with JNI and other shit to interface java with C
>>
working on a progam that given calculates all possible combinations of n squares that make up a number m.
f(3, 14) for example should output
1,2,3

so far so good, just code it like
void partitions(string prefix, int max, int depth) {
if (depth <= 0) {
double intPart;
if (modf(sqrt(max), &intPart) == 0.0) {
cout << prefix << (int)intPart << endl;
max = intPart;
}
return;
}
for (int i = 0; i*i <= max; ++i) {
partitions((prefix + std::to_string(i) + ", "), max - i*i, depth - 1);
}
}


The probelm ofcourse is catching dublicates. currently the code would output
1, 2, 3
1, 3, 2
2, 1, 3
2, 3, 1
3, 1, 2
3, 2, 1

that's very messy. Does anyone have ideas on how to prevent that?
The only thing I can think of is putting all n numbers into a vector, then comparing the current numbers with every n-tupel in the vector and only outputing the values if there was no match. I'm sure there's a more elegant solution though.
>>
>>54467262
naive way, like you're saying
sort numbers -> into pair/tuple -> into vector or set
>>
>>54467071
>The article that you posted specifically covers replicating what happens when you compile an object oriented program
which was the fucking point. you said objects in OO languages are as far from low level as you can get because their representations require juggling thousands and thousands of operands etc
>not even close to object oriented anything.
just like array objects in java
>Functions, arrays and structs are all extremely complex to replicate in low-level systems.
which again doesn't have anything to do with anything
>>
>>54463714
Fuck off this programming fag meme.
>>
>>54464886
There's a fast hack if you want.
Assuming your values are all ints and they're something sensible (1,2,3,4...) then you can set a value...just call it 'cardValue' which is the following:
//in the constructor
cardValue = that.getSuit() << 4 || that.getValue();
//later in the class
public boolean less(Card that)
{
return this.cardValue < that.cardValue;
}


What it does is it gives a unique value to each card, in ascending order of the value of the card. It's just binary arithmetic. Higher suits are larger numbers, and within suits the value of the card is simply compared.
>>
File: sad_frog.jpg (7 KB, 316x202) Image search: [Google]
sad_frog.jpg
7 KB, 316x202
I just blew an interview with google. I didnt expect to get the job but it still feels like shit that I couldn't handle their easy questions
>>
Is using geopt a good practice or should I rather parse arguments on my own?
>>
>>54467729
What kind of stuff did they ask you?

Personally, I wouldn't want to work at google.
They're in a world of their own when it comes to hiring and despite only wanting the best and brightest, they have most of them doing menial grunt computer janitor work because they can't all be project leads, after all.
>>
>>54465506
Are you just fuckin' around or does this actually cause a stack overflow? I don't see any recursion or the typical shit that causes those.

Also neat, multiple return types in java now. Still not using it.
>>
>>54467681
holy shit. that is ...magic. you just blew this junior SE student's mind.

thanks!
>>
>>54467774
The dumbest question I fucked up was "you are given a string and a list of characters, return true if any of the charcters in the list are in the string"

I started going at it considering the fasted route and then the guy then implied I didn't have to optimize it. I was like "okay" and brute-forced it and then he asked me if there was a better way to do it and I couldn't think of one

honestly that guy was kind of an ass looking back at it, but I should have just quicksorted the character list and then quick-searched each character in the string
>>
If I want to replace all occurrences of "dogs" except when dog is located between 2 asterisk i.e **dogs** is it possible to do in regex?
So regexReplace("dogs", "cats") on
>dogs eat dogs at **dogs** house
I should get
>cats eat cats at **dogs** house
>>
>>54465506
since when does java have vars and tuples?
>>
I'm using Python's requests module and i'm writing a script that basically monitors a website for certain changes.
But as someone who is using free dormitory internet (with limited bandwidth), i am concerned about a script like that eating up all of my bandwidth.
If i make one HTTP GET request, then the response is basically the whole HTML document of the website, right? How big is that normally, like let's say http://4chan/g ?
I'm guessing it's somewhere in the range of 100KB, so i probably wouldn't want to download that every 5 seconds (about 3GB within 1 day), but more like every 5 minutes (like 50MB within 1 day)?

I checked if the HTTP Response Header includes a "last-modified" tag, but for some reason it doesnt (not the /g/ example but the actual website im trying for). maybe because it's a dynamically created website.
>>
>>54467957
It doesn't
>>
>>54467882
its not Java and its not really multiple return types
local functions basically create an anonymous class -- similar to
var t = new { sum = 0, count = 42 };
t.sum == 0 && t.count == 42
>>
>>54467957
>>54467882
it's c#
>>
>>54467931
I would have replied with a simple naive nested loop function.

What else did they ask?
>>
>>54467681
>>54467898
I just realized the first line was totally wrong, but you should have got the sense of it at least. it should be
cardValue = this.getSuit() << 4 | this.getValue();
>>
>>54467947
>dogs(?=([^*]))
that'll match only dogs that isn't surrounded by 1 pair of asterisks which works for your use case, but might not work if you want *dogs* to be different from **dogs** (uses positive lookahead, so check to see if your regex implementation supports it)
>>
>>54467931
>brute-forced
>>54467996
>nested loop
jesus christ, how the fuck can you think of anything else than a lookup table? this is school-level stuff
>>
>>54468095
it's on the spot
if you were paying me to do this, I would give you a lookup table after thinking about it
>>
>>54468095
>lookup table

wouldn't I have to use a nested loop to iterate and compare through every table entry?
>>
>>54468125
on the spot? it takes you like half a second to think lookup table and about 6 lines of code to implement it!
>>
>>54468049
Thanks
I actually forgot something that might complicate it a bit, ** these dogs should also not match**
>>
>>54468146
no
>>
>>54467947
Asking how to do something "in regex" is sort of like asking how to do it "in a script". You need to specify the language for it to be useful.

If you don't know which regex dialect you use, just specify which language/library/tool it is. (Java uses PCRE, sed uses POSIX BRE, and people working with tools know this).
>>
>>54468170
What about:
** dogs ** dogs ** dogs **
>>
>>54467993
m$ java then. Close enough.

>>54467931
I don't know about working at google. Faggots look down upon you for going to work in business casual. Fuckers make t-shirts and shitty jeans mandatory.

Anyways decided to implement the google challenge in a silly way just for fun. Rate my code /dpt/
#include <stdio.h>
#include <memory.h>
#include <stdbool.h>

bool comparison[256];
bool blank[256];
bool contained_q(char * list, char * string) {
memcpy(&comparison,&blank,256*(sizeof(bool)));
for(int i = 0; list[i] != 0; i++)
comparison[list[i]]=true;
for(int i = 0; string[i] != 0; i++)
if(comparison[string[i]])
return true;
return false;
}

int main() {
for(int i = 0; i < 256; i++)
blank[i] = false;
printf("(%s,%s,%i)\n","aeiou","hello",contained_q("aeiou","hello"));
printf("(%s,%s,%i)\n","aeiou","why",contained_q("aeiou","why"));
}

Brotip: don't believe -Wall's lies.
>>
File: file.png (142 KB, 1000x500) Image search: [Google]
file.png
142 KB, 1000x500
I made myself a porn management app today.
>>
>>54468172
>>54468152
i'm thinking of how a lookup table would work, I'd literally have to create an array and pad it out with just the ascii values I'm looking for and 0's for everything else.
like *lookup = { 0, 0 , 0, .... 'W' } if i wanted to catch a W it would have to be the 87th item in the array

Am I doing it incorrectly?
>>
C baby here,I have a string like "500+600", what's the best way to break them to two integers and shove them in into an array of strings?

I'm having a lot more trouble with this than I expected. I'm looping through grabbing each char putting it into an array until I hit an operation symbol, then trying to send that array (the first number basically) into the string array, but I have no idea how apparently.

I've been googling a ton, and it seems this method is pretty shit, but I'm pretty ass at C and don't know how else my toddler brain can figure it out.
>>
>>54468217
Nested examples shouldn't match either I think
>>
>>54466718
I've been playing around with it, actually.

>>54466740
>mono is shit
So use the CoreCLR.
>>
>>54468238
how is this any different from a file explorer?
>>
>>54468240
if you're thinking of anything other than this, you're probably on the wrong track
int
chars_in_str(const char *c, const char *s)
{
char tab[256] = { 0 };
while (*c)
tab[(unsigned char) *c++] = 1;
while (*s)
if (tab[(unsigned char) *s++])
return 1;
return 0;
}
>>
File: dpt.webm (240 KB, 600x440) Image search: [Google]
dpt.webm
240 KB, 600x440
So I read a little bit about haskell and tried to make a shitty fizzbuzz, feel free to tell me I am retarded and why.

fizzbuzz = [if (x `mod` 15 == 0) then
"FizzBuzz"
else
if (x `mod` 5 == 0) then
"Buzz"
else
if (x `mod` 3 == 0) then
"Fizz"
else
show x | x <- [0..100]]


I basically have no idea what I am doing but this seems to work ok. Does haskell have no else if? I only searched a little but I didn't see it. Am I not meant to really use if else's? And I couldn't really find how I am meant to indent or where to break of the if/else etc.

Thanks goys
Thread replies: 255
Thread images: 20

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.