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

What are you working on, /g/?
>>
nimfriends
>>
>>52538609
posted early
u're a fgt
>>
>>52538609
>What are you working on, /g/?

My guns. I should be doing my course work, but my .22 has a sticky chamber. :(
>>
File: 1453181869033.jpg (253 KB, 1200x730) Image search: [Google]
1453181869033.jpg
253 KB, 1200x730
Anon, we've already seen your .webm, you don't have to make a thread early to make sure we see it again.

And isn't it time for you to go to bed now? You normally go to bed around this time.
>>
>>52538628
Why do you own guns?
>>
>>52538609
Might I request the source of that? For programming reference reasons, of course...
>>
>>52538654
Because he can
>>
>>52538659
I also need this because of reasons.
>>
File: 1451683583776.gif (2 MB, 400x600) Image search: [Google]
1451683583776.gif
2 MB, 400x600
>>52538609
CHIP-8 assembly is far too simple. Z80 here I come
>>
File: 1453181951499.jpg (238 KB, 1000x916) Image search: [Google]
1453181951499.jpg
238 KB, 1000x916
>>52538628
Nigger-lover with a gun?

Whose side will you be on when the race war begins, anon?
>>
>>52538654

Why don't you? I don't because I live with my mother, who hates them, but as soon as I move out, I'm getting myself a rifle. You though... what's your excuse?
>>
>>52538659
>>52538684
Secret Princess Himegoto
>>
File: 1453274345531.jpg (2 MB, 1993x2110) Image search: [Google]
1453274345531.jpg
2 MB, 1993x2110
>>52538689
>, anon
Sorry, habit. I mean tripfriend.
>>
>>52538696
>Secret Princess Himegoto
It's a trap... this is disappointing.
>>
>>52538691
What reason would I have to own a gun?
>>
File: lnq6kMC.png (2 KB, 346x54) Image search: [Google]
lnq6kMC.png
2 KB, 346x54
>>52538707
>>
File: 1453273932920.jpg (701 KB, 1339x1744) Image search: [Google]
1453273932920.jpg
701 KB, 1339x1744
>>52538712
Traps disgust me too, anon.
>>
>>52538712
what the hell is wrong with you?
>>
>>52538717
Niggers
>>
File: 1453180347711.jpg (1 MB, 971x1200) Image search: [Google]
1453180347711.jpg
1 MB, 971x1200
>>52538724
Why would you want to deprive yourself of info, anon?
>>
>>52538712

You didnt guess by the visible nipples?
>>
>>52538696
are you sure? google returns that on the thumbnail but it doesnt seem to actually be a match. Unless the tech related subs are fake.
>>
File: 1451683200606.png (906 KB, 600x775) Image search: [Google]
1451683200606.png
906 KB, 600x775
This is awesome, there's literally no programming related posts in this entire thread!
>>
>>52538781
>Unless the tech related subs are fake.
yes, they're fake
OP edited the subtitles
>>
>>52538781
>Unless the tech related subs are fake.

Lmfao

Just lmfao
>>
File: 1453181764838.jpg (202 KB, 858x1200) Image search: [Google]
1453181764838.jpg
202 KB, 858x1200
>>52538787
What are you working on, anon?

>>52538794
Because OP is autistic and he wants to force his trap fetish on everyone else.
>>
>>52538787

Such is what happens when the picture is more interesting than the text in any OP.
>>
>>52538793
>Dependent types are basically a weaker form of subtyping.
Where the hell are you getting this idea from?
>>
>>52538810
t. OP

Nobody likes your shitty webm.
>>
>>52538685

Z80's pretty interesting. It's based on the Intel 8080 instruction set, and it's mostly focused around the accumulator registers. The 8080, like the 8086 the followed it (and grew up into the architecture we all love) had 16-bit registers that could be interpreted as the high and low 8-bit values of it. So where the 8086 had registers AX, BX, CX, and DX that could each become AH, AL, BH, BL, CH, CL, DH, and DL, the 8080 and z80 CPUs have registers AF, BC, DE, and HL which can be broken into A, F, B, C, D, E, H, and L. Although F should probably not be used as a general purpose register, because it is the flags register...

By the way, do you plan on testing that z80 knowledge on real hardware at all? Because both the Gameboy and the TI-83 run a z80.

>>52538717

Home defense.
>>
File: 1451621287459.jpg (26 KB, 457x480) Image search: [Google]
1451621287459.jpg
26 KB, 457x480
>>52538781
>Unless the tech related subs are fake.
>>
File: trr.jpg (19 KB, 403x275) Image search: [Google]
trr.jpg
19 KB, 403x275
Why can't there be a no bloat, no botnet Windows?
>>
>>52538826
I've actually found a pdf file for Z80 which even shows how data moves around buses, registers, etc as well as how even simple functionality like adding happens without collision. I can agree that it's definitely very interesting.

>do you plan on testing that z80 knowledge on real hardware at all?
I don't even know where to start with physical engineering of any kind. Have you had any experiences with it, or have any quick tips?
>>
Alright, everyone stop shitposting.

What anime is everyone currently watching?
>>
>>52538819
Not OP here, I'm the one who transcoded it, so I like it.
>>
>>52538860
Hidamari Sketch.
>>
>>52538860
Higaurashi
>>
>>52538888
D-did I get quads?
>>
>>52538857

>physical engineering
I'm not suggesting you fab a CPU or hook up some circuit, I'm suggesting that you might, for example, get a gameboy flash cart and test a few programs on device, instead of just in an emulator. Or take a Ti-83/Ti-84 and dump some assembly program onto it.
>>
>>52538889
I did not. :(
>>
>>52538911
>>
>>52538911
Legend
>>
>>52538860

I recently finished One Punch Man. I don't have an anime I am currently watching.
>>
>>52538902
>get a gameboy flash cart and test a few programs on device
You know, that actually sounds doable and pretty tight since it's just assembling. I think the trouble is usually emulating real games on a PC rather than the other way round due to hardware quirks and timing exploitation. Would be fun playing on the gameboy again too
>>
File: Anon gets tricked tw(...).jpg (1 KB, 16x125) Image search: [Google]
Anon gets tricked tw(...).jpg
1 KB, 16x125
>>52538911
Spooky.


>>52538918
Watch Gintama from the beginning
>>
>>52538933
>>
>>52538911
Oh shit
>>
>>52538933
HE DID IT AGAIN
>>
I'm reading Red Storm, it's a Manwha
>>
>>52538928

You should do it man, make a gameboy game or some shit.

This may help if you don't want to do it entirely in asm:

http://sdcc.sourceforge.net/
>>
>>52538976
inspiring m8, alright since I'm learning z80 I'll go do it
>>
how do I become popular on github?
>>
File: po.png (232 KB, 550x663) Image search: [Google]
po.png
232 KB, 550x663
I hate it when /dpt/ is slow.
>>
>>52539224
Why do you want to be popular?
>>
>>52539224
get popular outside of github.
>>
File: 1316189299277.png (184 KB, 375x450) Image search: [Google]
1316189299277.png
184 KB, 375x450
>>52538911
You even checked yourself
>>
>>52539224
Master the art of writing codes of conduct
>>
What could one do if they solved the pattern of prime numbers?
>>
>>52539256
kekksimus maxximus
>>
>>52539269
find the next prime number
>>
>>52539234
to feel loved and important

>>52539236
but I'm a hikkineet I don't know how
>>
File: img2938579.jpg (17 KB, 259x346) Image search: [Google]
img2938579.jpg
17 KB, 259x346
still reading this shit
>>
>>52539303
>not wanting to feel hated and important
>>
>Haven't used depth first search much outside of theory classes
>Suddenly find myself using a depth first search to find all of the traces in a minimum edit distance graph

Welp, time to prove my BS is not a pile of BS.
>>
>>52539370
How often do you use breadth first?
>>
https://www.youtube.com/watch?v=kpk2tdsPh0A

Any other /v/irgins here? Someone needs to explain to this guy what an integer overflow wrap around is.

If you haven't seen this, skip to around 11 minutes and prepare for some mega autism
>>
>>52539511
Fuck off back to /v/ and take your cancer with you
>>
>>52539542
I'm a /g/entooman first and foremost, you fucking faggot, but the circlejerking on /v/ doesn't allow you have an actual conversation about the technical details of what this kid found
>>
>>52539511
I've seen that video before. It's not quite a clean wrap around though, because the model isn't displayed back in the original world. And if you travel say 10 up, to get the model to display again you need to travel exactly 10 down.
>>
>>52539555
Yeah I'm not quite sure of how the details work, but it seems like there's just some overflow and you get some strange results as a result

I highly doubt that Nintendo has created a massive grid that holds the same barebones world over and over again, so there has to be something wrong there
>>
>>52539569
I'm pretty sure you need to go watch the video again m8. It tests collision detection as an int, but stores position as a float. Float has a much larger range than int. So when Mario is in the PU, his real position is the float, so he is off somewhere really far away from the actual map, out in a void. But you can still walk run jump etc. as if you were on the real map, because the float get's converted to an int using a modulo for collision detection. His explanation is actually correct.
>>
>>52539611
Then why does it act like there isn't any obstacles if it's testing collision detection with the modulo? Wouldn't the modulo move it into an area WITH obstacles?
>>
>>52539654
Because of the way the game calculates speed and movement, explained earlier in the video (sorry, it's actually another video of his). When you move, the game checks the spot you will be next frame. If it is collision free, Mario moves there. Because he builds up so much speed, the spot is in the same place he is currently standing, but in a different PU. It doesn't check collisions all along the route, just in 4 places. Hence, quad PU's, QPU's. He always moves a distance of 4PU's, so the collision checker will always let him move.

Watch the video you idiot, instead of trying to call out his mistakes. If you understood it, you would see that it makes sense.
>>
>>52539727
sorry, English is not my primary language so perhaps some of the details were lost on me and as you said part of it was explained in another video

thx
>>
>>52539744
Yeah, it's a bit more complex than wrap arounds. It's related, but not the same. If it was a wrap around, when he reached the syncing speed, you would end up back in the same map, not off in the void.
>>
>>52539457
About as often as I do DFS. I don't tend to play in the graph theory arena. Haven't found much use for it until now, when I'm dealing with minimum edit distances.
>>
>>52539778
I haven't ever thought of a reason to use BFS
>>
>>52539796
I used it in a TRPG style game for deciding which cells around the player are traversable.
>>
>>52539812
That makes sense actually

I am retarded
>>
>>52538860
Recently rewatched Madoka and then finally got around to watching Madoka: Rebellion. Rebellion frankly ruined the series for me.
>>
>>52539316
>Updated for C11
>>
>>52538609
I want to learn to program where should I start?
>>
>>52539873
C
get a good book on it, with exercises, and write and compile all of them yourself
>>
File: reimu_content.jpg (138 KB, 575x575) Image search: [Google]
reimu_content.jpg
138 KB, 575x575
>>52539873
Well, what do you want to do with programming?
>>
>>52539873
I learned BASIC with a book called Kids and the Apple. The problem was that the book was for Applesoft BASIC and I had QBASIC, so there were lots of things that didn't really work correctly.
>>
>>52539873
https://www.python.org/
go there and download the python interpreter, there's an official tutorial there you can follow
see if programming is something for you

>>52539879
no
>>
>>52538860
I just started watching Welcome to the N.H.K. with my boyfriend
>>
File: we_get_it.png (28 KB, 740x212) Image search: [Google]
we_get_it.png
28 KB, 740x212
>>52539908
pic related
gays not welcome
>>
>>52539923
>unironically posting xkcd

le epic maymay xDDD
>>
>>52539879
Don't listen to this trash.
>>
>>52539923
Everybody is welcome in /dpt/
>>
>>52540004
provided you program in a language with static types
>>
>>52539853
for (ctr=0; ctr < 3; ctr++){
books[ctr] = (struct bookInfo*)malloc(sizeof (struct bookInfo));
printf("What is the name of the book #%d?\n", (ctr+1));
fflush(stdout);
gets(books[ctr]->title);
puts("Who is the author? ");
fflush(stdout);
gets(books[ctr]->author);
puts("How much did the book cost? ");
fflush(stdout);
scanf(" %f", &books[ctr]->price);
puts("How many pages in the book? ");
fflush(stdout);
scanf(" %d", &books[ctr]->pages);
getchar();
}

why is this allowed
>>
>>52540064
ignore the fflushes i had to add them for it to werk on my shell
>>
Is there a statically typed version of python?
>>
File: reimu_mad.png (240 KB, 550x700) Image search: [Google]
reimu_mad.png
240 KB, 550x700
>>52540064
oh god, what am I looking at
>>
>>52540082
NIM
I + I
MIN
>>
>>52540089
its the chapter that teaches u struct in this book:
>>52539316
>>
>>52540091
Does Nim work with existing python libraries?
>>
>>52538609
>Would you like to get sizeof()ed
Editor's note my ass. You can't sizeof() a dynamic structure. sizeof() is evaluated at compile time, it only works for complete types and statically allocated data structures.
>>
>>52540004
*Except blacks, trans, Muslims, gypsies, and Jews.
>>
>>52540162
http://nim-lang.org/docs/lib.html
ctrl + f "python"
>>
>>52540177
>implying he's not a class of his own
>>
I'm designing a singleton in C++14.
class singleton {
private:
singleton();
singleton(const singleton&)=delete;
void operator=(const singleton&)=delete;

static std::weak_ptr<singleton> ptr;
static std::mutex mget;
public:
static std::shared_ptr<singleton> get();
};

std::weak_ptr<singleton> singleton::ptr{};

std::shared_ptr<singleton> singleton::get()
{
std::lock_guard<std::mutex> lock(mget);
try{
std::shared_ptr<singleton> sptr(ptr);
return sptr;
}
catch (const std::bad_weak_ptr&)
{
auto u=std::make_shared<singleton>();
ptr=u;
return u;
}
}


I always heard that singletons are bad since they manage their own lifetime (which is typically until the running program ends). The idea here is to fix that and push the lifetime management to the returned shared_ptr-s of the get() method.
>>
>>52540199
>OOP is this desperate

USE GLOBALS FAGGOT
>>
>>52540193
>class

What fucking non-sense are you speaking?
>>
>>52540212
>USE GLOBALS
Yeah, no.
>>
File: UNTIL THE LIGHT BREAKS.jpg (165 KB, 1058x705) Image search: [Google]
UNTIL THE LIGHT BREAKS.jpg
165 KB, 1058x705
>>52540199
>"singleton pattern"
Pic related
>>
>>52540223
That's basically what a singleton is. You're saying "there will always be one and only one of this object".
>>
>>52540199
Why do you need a shared_ptr? If it's a singleton why not just use a unique_ptr and pass either a raw pointer from get or a const reference?
>>
>>52540199
Also, as an aside, I'd avoid shared_ptr unless you really, really, _really_ need it. shared_ptr really provides you quite a lot of rope with which to hang yourself.
>>
File: IjffUUQ.webm (603 KB, 358x640) Image search: [Google]
IjffUUQ.webm
603 KB, 358x640
Ask your favorite programming literate anything.
>>
>>52540199
use a unique_ptr and make the get function return a reference instead
or just use static functions really
>>
>>52540242
I'm just started learning C++14, so sorry if I'm wrong.

(I think) I need a weak_ptr inside the singleton so I can return that when it's needed. AFAIK weak_ptr and unique_ptr are not quite compatible, correct me if I'm wrong. Also I want to allow separate threads to keep multiple shared_ptr-s to the same singleton.
>>
>>52540004
Nobody is welcome in /dpt/, idealy.
>>
>>52540253
Besides runtime overhead?
>>
>>52540273
Writing a class in such a way that the same instance can be shared properly is hard and not really worth the complexity unless the object is especially expensive to construct/have sitting around.

So yeah, there's the runtime overhead, but that's not really the main issue.
>>
Hey guys i'm drunk learn coding
Suposedly case 2 should print out a sequence of 10 numbers, what Am I doing wrong?
     int num1, num2,send, sel;
Scanner keyboard = new Scanner(System.in);

num1=keyboard.nextInt();
sel=keyboard.nextInt();


switch (sel) {
case 1: {
send=cal1(num1);
System.out.println(num1);
}
case 2: {

num2=0;

do {
send=cal1(num1);
System.out.println(num1);
num1++;
} while(num2 > 10);
}
}



}


static int cal1(int n1)
{
int n2 = (int) Math.pow(n1, 3);
return(n2);
}
}
>>
>>52540294
>num2=0;
>while(num2 > 10);

what
>>
Ask your beloved programming illiterate anything
>>
>>52540260
I want the following to work as it's written in the comments.
int main()
{
{ //scope1
auto s1=singleton::get(); //singleton created

//end of scope, shared_ptr destroyed, ref-count went to 0, singleton destroyed
}

{ //scope2
auto s2=singleton::get(); //singleton created
{ //scope2.2
auto s2_2=singleton::get(); //returns a shared_ptr to same singleton

// s2_2 destroyed, ref count went to 1
}
//s2 destroyed, ref count went to 0, singleton destroyed
}
}


The idea is that the singleton manages a resource that is both expensive to create and expensive to keep in memory.

>>52540286
>not the main issue
what's the main issue? Complexity? What's wrong with my approach? I don't think client code would be too complex.
>>
>>52540294
while(num2 < 10);
there you go
>>
File: uuu.png (37 KB, 1360x728) Image search: [Google]
uuu.png
37 KB, 1360x728
Wtf, I can see the outline of 4chan posts burnt onto my screen.

Is anyone else seeing this? It seems to be the most clear when the background colour is grey.
>>
>>52540294
You're certainly never modifying num2 in that do; while.

Also, have some fucking dignity and use a proper for loop instead.
>>
>>52540304
is there a reason in particular you absolutely NEED the singleton to be destroyed when there are no more references to it?
if you say "performance" im gonna stab you
>>
>>52540310
Not programming related.
>>
>>52540304
That's more like a factory than a singleton.
>>
>>52540309
>>52540302
Thanks i'm incapable of resolving my own misshaps due to sheer inability of processing my own thoughts

>>52540311
Does Learning how to use java mean anything to you dude?
No offence i'm learning.
>>
>>52540304
That's hardly a singleton.
>>
>>52540304
With your approach: if it's something expensive to keep around I guess the reference counting approach should work fine.

If it actually is expensive to construct the approach isn't great because you can get into lots of situations where things grab the shared_ptr and give it up causing you to spend lots of time constructing/deleting the object.
>>
>>52540319
As I said it's just practice. One particular use case would be that the singleton is only need for limited time across multiple threads and you want to free up memory once it's not used.

Also it's just a method to give control to client code to manage this object's lifetime.
>>
>>52540324
/dpt/ is a chatroom, you can post anything you want here.
>>
>>52540364
>>
>>52540343
this

so long as you're part of the community you can do what you want
>>
>>52540336
The point is giving the control to client code, if it's really bad to construct multiple times than the client just needs to create a single shared ptr in main and it will never be destroyed.
>>
>>52540343
No it's not, fucktard.
>>
>>52540355
>>
>>52540355
fuck off commie
>>
>>52540360
>>
>>52538860
cheaper by the dozen
>>
>>52540319

Mate, this is C++, not Java. Performance is the name of the fucking game.

On that note, fuck adding a ton of abstract bullshit to make singletons. Just make only one of the thing, store it on the stack, pass it around by reference, and when it goes out of scope, it goes out of scope.
>>
>>52540331
Then it's not a singleton, sue me. It can still be useful (or not). What's your definition of a singleton though.
>>
>>52540372
>>
>>52540353
Right, but you're the one writing the class, so you should have a pretty good idea of its performance characteristics. Really you should make that decision for the client. If they want to change that they're free to just inherit and redefine.
>>
>>52540383
>>
>>52540369
A singleton only has one instance of it througout the lifetime of the program and is pretty much a shitty design pattern that javafags use to get global state.
>>
>>52540367
sure, but you really think a couple of bytes in extra memory is going to hit you performance wise unless you're on an embedded system?
what he's trying to do looks complex as shit with fuck all benefits compared to a regular singleton or factory pattern
>>
>>52540388
Except for "lazy" singletons when they have 0 or 1 instance. They still call them singletons.
>>
>>52538609
Learning Scheme still. It's incredible how easy Scheme has been so far and it's the first language I've ever seriously sat down and tried to learn.
>>
>>52540367
The performance really depends on the cost of construction vs cost of cost of having instances sitting around.

And really, if you can decide between reducing programming complexity and adding a small performance improvement that still operates in the same class of big O, you should be trying to reduce complexity 99 out of 100 times.
>>
>>52540399
Sure, but a lazy singleton still doesn't delete itself when it thinks it isn't being used anymore. It just delays construction until it is first needed.
>>
>>52540310
wow you've spent this much time on 4chins that the outline of the posts have been burnt onto your screen
>>
>>52540382
Well this is now up to library design. I still think there could be valid use cases for something like this. If the client only wants to use your singleton at the beginning of his program, then the traditional singleton is pretty shitty, since he can't free it. This design is more flexible with some runtime overhead though.
>>
>>52540355
a shiggy diddly
>>
>>52540428
Yeah, mine is not a traditional singleton, I want to improve it in this regard.
>>
>>52540362
>>52540379
>>52540385
kill yourself
>>
>>52540455
>>
>>52540477
I give up, I'll never be able to reply to my own post like that other anon.
>>
>>52540478
>:01
kek
>>
>>52540199
OK, I made it compile, turns out make_shared doesn't like private constructors (obviously).
class singleton {
private:
singleton()=default;
singleton(const singleton&)=delete;
void operator=(const singleton&)=delete;

static std::weak_ptr<singleton> ptr;
static std::mutex mget;
public:
static std::shared_ptr<singleton> get();
};

std::weak_ptr<singleton> singleton::ptr{};
std::mutex singleton::mget{};

std::shared_ptr<singleton> singleton::get()
{
std::lock_guard<std::mutex> lock(mget);
try{
std::shared_ptr<singleton> sptr(ptr);
return sptr;
}
catch (const std::bad_weak_ptr&)
{
std::shared_ptr<singleton> u(new singleton());
ptr=u;
return u;
}
}
>>
>learnt D pretty well
>feel like I should learn another memelang
>can't stop writing D
>can't stop wanting to write D
It's just too good
I feel no need to write anything else any more
someone give me a reason to learn something else
>>
>>52540537
D is a horrible meme.
>>
>>52540572
>a horrible meme.
that's a funny way to spell literally perfect
>>
>>52540583
>GC
>literally perfect
>>
How to convince this addon to copy a specific type of link when u hover above it automatically?

/*
var linkAddress = $('<span id="copylAddress" style="display: inline-block;" />');
$('body').append(linkAddress);
// This is a DOM element that has to be selectable but not visible to anybody
linkAddress.css({position: 'absolute', left:'-9999em'});

var previousCaretPosition = -1;

COPYL_DEBUG = false;

function write_to_console(text) {
if (COPYL_DEBUG)
console.log(text);
}

function selectElement(el) {
// Check if anything is currently selected, if so backup
if (window.getSelection().rangeCount > 0) {
previousCaretPosition = document.activeElement.selectionStart;
}
write_to_console("Previous cursor position: " + previousCaretPosition);
var range = document.createRange();

write_to_console("Selecting element " + el);
write_to_console("el[0] is " + el[0]);
range.selectNodeContents(el[0]);
write_to_console("Range: " + range);

write_to_console("Window selection range count before: " + window.getSelection().rangeCount);
if (window.getSelection().rangeCount > 0) {
window.getSelection().removeAllRanges();
}
write_to_console("Window selection range count now: " + window.getSelection().rangeCount);

write_to_console("Active Element: " + document.activeElement);
window.getSelection().addRange(range);
write_to_console("Window selection range count after: " + window.getSelection().rangeCount);
}
>>
>>52540635
>javascript:quote('52540635')

function clearLinkAddress() {
if (linkAddress.text()) {
linkAddress.text("");
linkAddress.blur();
write_to_console("Cleared linkAddress");

write_to_console("window.getSelection: " + window.getSelection());
window.getSelection().removeAllRanges();
}
if (previousCaretPosition != -1)
{
document.activeElement.selectionStart = previousCaretPosition;
write_to_console("Previous cursor position set: " + document.activeElement.selectionStart);
}

write_to_console("Current selection: " + window.getSelection().toString());
}

$(function() {
// The code attaches itself to all anchor elements
$("html").on("mouseenter", "a", function(){
// Everytime the user hovers (enters) a link
if(window.getSelection().toString()) {
write_to_console("Something is already selected. Don't do anything.");
} else {
write_to_console("Nothing is selected.");

linkAddress.text($(this).prop('href'));
write_to_console("linkAddress: " + linkAddress.text());
selectElement(linkAddress);
}

write_to_console("Current Selection: " + window.getSelection().toString());
}).on("mouseleave", "a", function(){
// Every time the user leaves a link
write_to_console("Leaving link.");
clearLinkAddress();
});

$(window).on("beforeunload", function() {
clearLinkAddress();
});

});
>>
>>52538609
So is web dev actually easier than other forms of programming or is it just /g/ being autistic again?
>>
File: crying-bear.gif (54 KB, 361x365) Image search: [Google]
crying-bear.gif
54 KB, 361x365
>>52538609
>mfw I made this release of himegoto and I'm seeing it posted here
>>
>tfw growing deranged and jaded over a shitty android app

Why is java such a piece of garbage?
Why android forces you to use java?
Why is everything so ass-backwards?
>>
File: YdGlAB0.jpg (248 KB, 950x1344) Image search: [Google]
YdGlAB0.jpg
248 KB, 950x1344
>>52538717
murica
>>
>>52538659
>>52538684
>>52538781
Yes, they're fake subs. Also, source is [&] Himegoto - 08 [720p][DD914D69].mkv, the scene in the OP starts around 02:05 (remember to switch subtitle tracks -- they default to actual subs).

Release available from nyaa, currently being seeded from a seedbox; the XDCC bot doesn't carry it anymore.
>>
>>52540583
What's good about D?
>>
>>52540686
>Why is java such a piece of garbage?
explicit static typing

>>52540686
>Why android forces you to use java?
http://clojure-android.info/
http://www.scala-lang.org/
>>
>>52540665
most of web dev is really easy. in silicon valley you can get a six figure job based on a few weeks worth of knowledge. any "web designer" can charge thousands of dollars to make a website for their client which is just some pre-fab wordpress shit. back-end web programming for a serious company can be a bit harder.
>>
>>52540720
>as fast as C++
>easier to write
>easier to read
>easier to write faster programs
>compiles instantly with LOC well into the thousands, even with dozens of separate files and a fuckload of templates
>>
>>52540773
>>as fast as C++
>>
>>52540769
>a few weeks worth of knowledge
like what? do you need to know some /gd/ shit, or is knowing how to use a premade CSS template with HTML enough?
>>
>>52540753
How hard are either of those?
>tfw 2 years of education totally wasted

Just kill me.
>>
>>52540753
explicit static typing is the only way to go there are no real advantages to having type inferrence or dynamic typing
>>
File: 9uy.jpg (68 KB, 1280x720) Image search: [Google]
9uy.jpg
68 KB, 1280x720
Every time I get a cold call I get paranoid thinking that it's the police checking to see if I'm in before they raid.

Anyone else know this feel?
>>
>>52540778
The only thing that's notably slower is GC
as long as you don't stress the GC the fuck out, it's as fast, and in my experience, usually faster, unless you spend 75% of your time making sure the C++ code you've written isn't slow as shit

D is quicker to write, quicker to optimise, quicker to compile and quicker to test
the only thing C++ has on it is that the very fastest possible C++ program conceivable would probably be faster than the very fastest possible D program (except in some specific cases), because, don't forget, C++ has been enormously popular for decades and the compilation process has had a lot of work done looking to optimise it

pretty sure bjarne said he wanted to add GC to it, so look forward to the advantage disappearing :^)
>>
>mfw a discussion about strong AI and some faggot brings up Asimov's three laws as if they have any meaning
Why is this allowed? Why do these people exist?
>>
>>52540800
you don't even know java properly if you have to ask yourself that. scala and clojure are garbage meme langs anyway and the high-level android API will be the same regardless of language.
>>
>>52540853
Only someone who is up to no good would be paranoid of such a thing.

What are you up to, anon?
>>
>>52540855
Pretty sure that GC will be an add on similar to smart pointers and the standard library wont use it excessively.
>>
>>52540837
They're only disadvantages, even advantages
people commonly claim are disadvantages in the end; fuck monkey patching.

Thankfully dynamic languages are dying and/or are adapting optional static typing.
>>
>>52540855
To bad D doesn't have any fucking libraries, what little it does have are abandoned, poorly maintained and habitually break backwards compatibility at every turn.
>>
File: goat.gif (954 KB, 400x225) Image search: [Google]
goat.gif
954 KB, 400x225
>>52541077
That just means that you've got something to do with your free time: start or contribute to open source libraries to do whatever you need
>>
Rust vs D?
>>
>>52541114
Isn't it glorious that now I'm expected to maintain software for companies in my free time? and people claim open source is about socialism? good goy.
>>
>>52540837
>there are no real advantages to having type inferrence
Clean, readable, maintainable, concise code isn't an advantage?
>>
>>52540853
my bf always answers the phone so no
>>
I'm reading C Programming, A modern Approach for my first programming book, but since I know small amounts of C++ I occasionally see things where I'm like "oh god why" when I realise how much easier C++ makes the implementation.
>>
File: lispbest.jpg (253 KB, 840x412) Image search: [Google]
lispbest.jpg
253 KB, 840x412
>>52541043
>Thankfully dynamic languages are dying

http://cacm.acm.org/blogs/blog-cacm/176450-python-is-now-the-most-popular-introductory-teaching-language-at-top-us-universities/fulltext

http://blog.codeeval.com/codeevalblog/2015

top 5 most used programming langages on github: javascript, java, python, php, ruby
>>
>>52541218
Example?
>>
Help, I'm trying to do an English-Morse translator in Java, I made 2 arrays, one all the English letters and the other the Morse equivalents.

Now, It's supposed to display the first word in one line, then when it detects a " ", the next word will be printed on the next line. I declared a newWord array and I need to print the elements in the same line until the " " is detected, the way my code is now, it just prints the entire array in one line with the brackets and commas included, is there a way to print multiple array elements in one line without the commas and brackets?

String word = readLine("Enter a word: ");

String[] newWord = new String[word.length()];

for(int k=0; k<word.length(); k++)
newWord[k] = " ";

for(int i=0; i<word.length(); i++) {
for(int j=0; j<=25; j++) {
if(i!=0) {
if(letters[j].equals(word.substring(i, i+1).toLowerCase())) {
newWord[i] = codes[j];
break;
}
}
}
}

println(Arrays.toString(newWord));
.
>>
>>52538775
As of 10 years ago it was still common to see nips in anime.
>>
>>52541227
>javascript
>python
Literally being massacred by Go.

Also

>github
>Literally half of all Python code on the entire website are Django forks with no commits
>Thinks ChakraCore is a Javascript project

Back to webdev general with you.
>>
>>52541235
While I understand that C gives more control with printf formatting, just using cout and not getting lost in my variables, and honestly, its my fault for it, but I don't really get why it needs to be there, the scanf & before the variable. And maybe its just cause this is an old book (first edition if a modern approach) I saw some stuff about pushback and popback(?) in C++, and when I read in C that every program I wanna make do that I need to make functions for it I was like "ehh, what, I do that how?" as the book showed me that it isn't (or wasn't, again, book from the 90's) which made me slightly sad. but I guess I am learning how the function actually works.
>>
>>52540853
better hide the cheeze pizza m8
>>
>>52541190
less code != better

you aren't even saving lines of code, just a few characters on a few lines
>>
>>52541309
>javascript
>python
>Literally being massacred by Go.
literally delusional
>>
>>52541309
where your evidences ?
>>
>>52541227
>sjwhub
>java which is the poster child of static typing is still one of the top languages on sjwhub
>>
>>52538609
>>52538609

C Plus Primer by Stephen Prata

C Programming: A Modern Approach by K.N. King

The C Programming Language (K&R) by Brian Kernighan and Dennis Ritchie

Opinions on these books as learning resources? I've just started on C Plus Primer.
>>
>>52541313
>but I don't really get why it needs to be there
Why what needs to be there? printf?
>the scanf & before the variable
Because C is pass by value. If you pass a variable to a function, it's not going to get changed. You need to pass the address of the variable so the function can change it.
Once you understand pointers, it makes perfect sense.

Also a lot of your pose doesn't make sense.
>>
>>52541386
>pose
post*
>>
File: git.png (406 KB, 1346x595) Image search: [Google]
git.png
406 KB, 1346x595
>>52541309
>>Literally half of all Python code on the entire website are Django forks with no commits
lel, k tard, actually go has more forks but less activity.
>>
>>52541386

" and honestly, its my fault for it, but I don't really get why it needs to be there, the scanf & before the variable" the reason I ended with a comma before that was because I meant for that to be the thing I was referring to.
what I meant to say made me sad, I was thinking faster than I was typing.
was that pushback and popback don't appear to be standard, as they seemed to be when I read about doing stack work in C++
>>
>>52541413
>was that pushback and popback don't appear to be standard, as they seemed to be when I read about doing stack work in C++
C or the C standard library doesn't deal with data structures. You have to/get to design and implement them yourself.
>>
>>52541413
Adding to this, while I understand pointers (on a basic level) because of the little of C++ I read a couple years back when I was originally toying with the idea of learning how to program, I just figure that telling the program "take input" and just giving it the variable name seems logical enough to me without having to give it the address since the variable already has a type and is at that address anyway... I dunno, maybe its just me.
>>
>>52541349
>just a few characters on a few lines

I don't think you understand what few means, unless the extent of your programming is fizzbuzz.
>>
File: 1384641981374.jpg (110 KB, 512x512) Image search: [Google]
1384641981374.jpg
110 KB, 512x512
>>52541249
I can't find anything relevant on google guys, can this be done or should I not be using arrays?
>>
>>52541439
Again, C is pass by value. scanf is just a function. A function doesn't know about and has no direct access to the variables of the function that called it.
>>
>>52541354
>Meanwhile half of the StrongLoop development team literally just packed up their shit, sold the company to IBM, effectively halted development on Express and publicly denounced Nodejs for Go
>Same with Koa and TJ

Tots healthy scene tho
>>
>>52541468
I guess that makes it make a bit more sense, but then, why does C++ do it so effortlessly with cin? I apologize if this seems like an idiot question, but I will be moving to C++ after I feel confident with C
>>
>>52541443
maybe a bit of an exaggeration but it's literally not that many characters to write int, float, SomeType instead of var, let, auto. and the percentage of lines variable declarations vs. the meat of the code is small. with type inference you aren't improving the code whatsoever.
>>
>>52541504
>do it so effortlessly with cin?
Invisible references. C++ will sometimes pass a reference to a function, and it will sometimes pass the value, based on how the function is defined.
I think it's completely retarded and a total clusterfuck, but C++fags seem to like information hidden from them for some reason.

>but I will be moving to C++ after I feel confident with C
There is really no point in doing that. C and C++ are completely different languages. Knowing C isn't going to make you better at C++ specifically.
>>
>>52541511
>instead of var, let, auto
You realize not all languages that have type inference use keywords for variables, right?
>>
>>52541551
:= or = is even more disgusting
>>
>>52541511
>with type inference you aren't improving the code whatsoever

Being able to write short lambda expressions isn't improving the code?
>>
>>52541537
Well I'm planning on learning at least C, C++, and Java / C# and hoping that I could do a few small projects that would look good on a resume and look for work.
While I enjoy programming as a hobby (at least I have so far when I have free time) working as a cook currently, I can't say living paycheck to paycheck WITH 2 roommates is appealing at all... I'd make way more as a codemonkey if thats all I could accomplish with myself.
>>
>>52541572
no you fucking fedora tipping neckbeard
>>
>>52541585
rude
>>
>>52541585
>damage control
>>
>>52541309
go is a systems language
it's not even comparable to what you'd use javascript or python for
do you have any idea what you're talking about
>>
>>52541732
>go is a systems language
Not a very good one, it has a garbage collector.
>>
>>52541732
>go is a systems language
>garbage collected
>>
>>52541745
They obviously hasn't actually checked on Go since 2008~, back then It was planned to replace C++ at Google but later it evolved to focus on network services and effectively it became Google's BASIC.
>>
can someone post the programming challenge picture please and thank u
>>
>>52541785
>effectively it became Google's BASIC.
(cont.)

Replacing Sawzall.
>>
>>52541249
What do "letters" and "codes" look like? And show the output you're getting.
>>
>>52541537
>completely different languages
>Knowing C isn't going to make you better at C++ specifically

For one; they're pretty fucking similar (nigh-on identical) in syntax; so learning C teaches you the basis and root of both languages. What differs is their application; and knowing C will give you a deeper understanding of general memory management - which is useful in all aspects of programming, especially C++ since it based directly on C, rather than just influenced by it.

I think learning C before C++ is a good idea.
>>
>>52541843
>(nigh-on identical) in syntax
Programming C in C++ is not the same as programming C++. Idiomatic C++14 is a completely different beast from C.
>>
File: morse java.png (1 KB, 345x53) Image search: [Google]
morse java.png
1 KB, 345x53
>>52541818
letters = ['a', 'b', 'c' .... , 'z']
codes = [ '.-', etc, etc ,'--..']
>>
File: morse java.png (2 KB, 703x59) Image search: [Google]
morse java.png
2 KB, 703x59
>>52541896
should have used two words for the example
>>
>>52541843
>(nigh-on identical) in syntax
Right, static_cast<std::int64_t>(a) is TOTALLY like C.
>>
>>52541537
>I think it's completely retarded and a total clusterfuck, but C++fags seem to like information hidden from them for some reason.
It is all about readability.
Operator overloads is a great example of how you can make your data structures more readable.
Say you want to do matrix multiplication. wouldn't it make sense that you made two functions (matrix*matrix, matrix*scalar, scalar * matrix)?
That is not hidden information. That is just more useful to the person using the library.
>>
>>52541896
>>52541915
There's usually a method called "join" that will combine the elements using a given separator.
>>
>>52541956
>>52541943

All in all, I'm saying that learning C from scratch is an easier task than learning C++ from scratch.

Going from C to C++ is a much easier transition than going from nothing to C++.
>>
>>52541957
That gets rid of the brackets but what about the commas? Maybe I shouldn't be using arrays?
>>
>>52542015
There should be a way to change the separator used. Just use an empty string. But yeah, I would just build the string directly.
string new_word = "";
for (i = 0; i < word.length(); i++) {
new_word += get_code(word[i]);
}
>>
>>52542049
I tried that but that only works when the user inputs one word, it should be able to output:
word-encrypted
2ndword-encrypted
3rdword-encrypted etc.

Anyway, thanks, I'll try the join method
>>
>>52541956
Matrix multiplication is a terrible example for operator overloading. Does '*' mean cross product or dot product? Who the fuck knows?
There are other inherent problems with operator overloading, especially when it comes to error values.
If you do
(a * b) + c
and a * b fails, what happens? What should + c return? How will the programmer know which operation failed?
You could then say: "Well, just limit it to one operation at a time like
if ((tmp = a + b) == error)
whatever();
tmp = tmp * c;

At that point, you could have just used a normal function and have it look every bit as good (and hide less information).
The you can bring up exceptions, but everybody knows that exceptions in C++ are a shit-show and everyone tries to pretend that they're not there.
>>
>>52542049
>>52542072
Wait, now that I think about it would work as a nested loop, thanks again
>>
>>52542072
>I tried that but that only works when the user inputs one word
I don't see how your code will fix that. You could just replace spaces with newlines.
>>
>>52542110
My code gets the entire sentence, then I would replace the spaces with newlines, as you said, I just didn't know how to do that
>>
>>52541978
Ctards never learn how to write proper C++. if you want to learn C++ you should start with java or C++.
>>
>>52542170
>Ctards never learn how to write proper C++.
Probably because they learn how disgusting C++ is.
>>
File: Golang.png (78 KB, 1224x440) Image search: [Google]
Golang.png
78 KB, 1224x440
Does Go have a future?
>>
>>52542180
as a niche programming language, yes.
>>
>>52542180
it will exist but not as one of the top languages
>>
>>52542180
Does it have any advantages to other similar languages?
>>
>>52542190
What even is Go's niche?
>>
>>52542206
no
Thread replies: 255
Thread images: 38

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.