[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: 43
File: cyberBully.jpg (214 KB, 1300x1081) Image search: [Google]
cyberBully.jpg
214 KB, 1300x1081
No cyber bully edition.

Previous thread got BTFO by a get, link: >>52224046

What are you working on today, /g/?
>>
hiterl
>>
>>52225087
>No cyber bully edition.
>>
hitker
>>
File: swift.jpg (515 KB, 2048x1536) Image search: [Google]
swift.jpg
515 KB, 2048x1536
> 2016 already
> he isn't making a split screen app for iPad® written on Swift 2

Why even live? Shit is comfy as fuck.
>>
shit thread so far
>>
>>52225087
SFML game programming in C++

gonna make a project for my qt3.14 3d asian programmer girlfriend
>>
>>52225242
post pic of game and qt gf

> 3d

nvm
>>
File: 1410881124972.jpg (24 KB, 226x235) Image search: [Google]
1410881124972.jpg
24 KB, 226x235
>>52225185
Damn, pretty cool to see the progress
keep it up anon-kun!
>>
>>52225185
so, are split screen apps different than regular apps? like a whole different app specifically programed to only run as a side app?
>>
>>52225242
>3d
wtf
>>
>>52225282
Thanks anon!

>>52225296
Nope, Apple® invented® a new xCode feature called UIStackView, you just need to design your app using this new feature then it will basically adapt to any screen size.
>>
File: 13963929212589.jpg (54 KB, 699x451) Image search: [Google]
13963929212589.jpg
54 KB, 699x451
>>52225279
>>52225297
>>
>>52225358
Based fucking Apple
>>
I'm in undergrad right now, and was thinking of going to grad school. An area I'm interested in is machine learning and ai stuff, but I'm open to anything. What programs should I look at?
>>
I don't fully understand what's going on in the getMd5 class, could someone explain to me what happens?

package md5generator;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Scanner;

public class MD5generator {

public static String getMd5(String passwordInput) throws NoSuchAlgorithmException {
MessageDigest md5Digest = MessageDigest.getInstance("MD5");
md5Digest.update(passwordInput.getBytes());
BigInteger hashInt = new BigInteger(1, md5Digest.digest());
return String.format("%1$032X", hashInt);
}

public static void main(String[] args) throws NoSuchAlgorithmException {
//Declare user input scanner
Scanner input = new Scanner(System.in);
String password = "StrongestPasswordInTheWorld";
while (!password.equals("")) {

//User enters password
System.out.println("Enter password: ");
password = input.nextLine();
//Program generates MD5 hash for input password
String hashedPassword = getMd5(password);
//Prints out user input password and hash
System.out.println("Password: " + password);
System.out.println("MD5 Hash: " + hashedPassword);

}
}
}
>>
>>52225570
>but I'm open to anything
I'm diamonds right now
>>
>>52225579
MessageDigest is initialized.
The object is updated with password.
The digest is obtained and converted to BigInteger.
The BigInteger is then converted to hex represantation.
>>
>>52225579
https://docs.oracle.com/javase/7/docs/api/java/security/MessageDigest.html
https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html
>>
base 2, base 10 and base 16 are the only non-meme number bases
>>
>>52225666
>base 10
literally the biggest meme

>m-m-muh metric
>>
>>52225579

If you're seriously storing a password using MD5... get off my Internet.
>>
>>52225666
Wrong. Base 12 is the superior base. 12 is divisible by 2,3,4 and 6. 10 is only divisible by 5
>>
File: mathsinjava.jpg (57 KB, 674x490) Image search: [Google]
mathsinjava.jpg
57 KB, 674x490
>>52225579
>>
>>52225697
is this real code?
>>
>>52225686
No, I'm making a cracker. It's a learning process, probably never gonna finish it. I gotta code to learn code.
>>
>>52225723
No, it's only a nightmare.
>>
>>52225679
kill yourself retard

>>52225689
kill yourself sperglord

base 10 is much easier to deal with than base 12
>>
>>52225723
This is genuine code, filename related.
>>
File: 1451028952220.jpg (47 KB, 480x388) Image search: [Google]
1451028952220.jpg
47 KB, 480x388
Working on a embedded game project for a class, using an Arduino UNO.

It's a pretty blatant ripoff of Mavrick Bird.
>>
>>52225185

Unless made to by a workplace, I will never develop applications for iOS. I do not like the idea of having to ask Apple permission to distribute an application to their users. I'd rather just distribute the binary directly.

I am willing to make applications for Android, despite how unpleasant the experience is, because I never have to interact with Google to get the application to the target market unless I want to. If Google thinks the application is trash, or it interferes with their bottom line (maybe it allows users to use Youtube Background Play without having a Youtube Red account), I can distribute the binary directly to my customers without their go ahead.

>>52225579
>>52225733

getMd5 is not a class; it is a function that takes as input a string, and returns the MD5 hash of that string.

>>52225689

Then you will be pleased to note that it is now the year 1200 in base 12.
>>
>>52225789
Thanks, lol, I can't even into correct lingo right now
>>
>>52225789
>Unless made to by a workplace, I will never develop applications for iOS. I do not like the idea of having to ask Apple permission to distribute an application to their users. I'd rather just distribute the binary directly.
>I am willing to make applications for Android, despite how unpleasant the experience is, because I never have to interact with Google to get the application to the target market unless I want to. If Google thinks the application is trash, or it interferes with their bottom line (maybe it allows users to use Youtube Background Play without having a Youtube Red account), I can distribute the binary directly to my customers without their go ahead.

TL;DR I'm poor
>>
>>52225789
>ask Apple permission to distribute an application

Cydia is an amazing community anon, you should try it sometime.

Go for App store only when you have something profitable.
>>
tamagochifag here.

what are some fun functuons i should try to implement today?
>>
>>52225787
Hey Hephraim Applefeld!
>>
>>52225787
>Mavrick Bird
>tfw traditional games have taught you bad habits like relying on walls during jumps
>>
>>52225818

To be honest, even if I were rich, I wouldn't use iOS. Despite all of the buzz we had last year about Android and the stagefright vulnerability, iOS actually managed to have more publicly disclosed vulnerabilities last year than not just Android, but Adobe Flash as well. If I use an OS like Cyanogenmod, then I can get security updates quickly without ever compromising my ability to use my mobile devices with the same level of freedom as I would my laptop.

>>52225822

I am well aware of the good community behind iOS jailbreaking. Nonethless, as a security-minded person, it is unsettling to have to think "the reason that I am able to do this on my phone is because there is a vulnerability on it that anyone could exploit, not just me; and if I patch this by using official security updates, I will lose this freedom."
>>
Daily reminder that if your language is not on this list, you should probably go ahead and kill yourself :

>java
>swift
>c
>php
>>
>>52225957
>java
>php

i literally died
>>
>>52226074
swift and c are just as bad you retarded memer
>>
>>52225957

Languages I use on a regular basis:

Ruby
C
C++

Languages I have used in at least one personal project and/or school assignment, but do not use normally:

Java
PHP
JavaScript (and CoffeeScript)
Ada
Racket
Python
C#
x86 Assembly

Languages I've fiddled with at least once:

A couple of Lisps/Schemes (I like TinyScheme)
Powershell
Rust
F# (for like a day or two. It's meh).
Objective-C

I've written a little bit of these here and there (not all of these are considered programming languages, but some are arguably turing complete):

Bash
GNU Make
HTML
CSS
SQL
LaTeX
XML

Honorable mention:

KPL (Kernel Programming Language). A language some professor made up to make teaching operating systems easier. It compiles to an architecture he made called Blitz. Basically, it's just a system's language with some debug functions. Had to use for an operating systems class.
>>
In JS, is there anything wrong with creating new objects within an object literal that's being used as a module?
Like,
var Foo = {
bar: new asdf(0),

xyz: new asdf(1)
}

Or should the creation of the objects be done outside of the module (while still being properties of it)? I normally just fuck around in global namespace because I never made a serious project, but I'm trying to go modular.
>>
>>52226246

If you want code to be used in other projects, do not use the global namespace for shit. If this is just for one project, feel free to pollute it, so long as you do not import methods that will conflict with your own.
>>
Guys i'm trying to make a mastermind algorithm (really simple i'm only doing this using random and intergers).
And I'm unsure how to apply the check for repetition in all the int's before printing.
Here's what I hate so far.
package javaapplication14;
import java.util.Random;
import java.util.Scanner;


public class JavaApplication14 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int mstrmind_random0,mstrmind_random1,mstrmind_random2,mstrmind_random3, input1,input2,input3;
int end;
Scanner keyboard = new Scanner(System.in);
Random random = new Random ();


do {
/** mstrmind_random0 = random.nextInt(10);
mstrmind_random1 = random.nextInt(10)*10;
mstrmind_random2 = random.nextInt(10)*100;
mstrmind_random3 = random.nextInt(10)*1000;
**/
mstrmind_random0 = (random.nextInt(10));
mstrmind_random1 = (random.nextInt(10));
mstrmind_random2 = (random.nextInt(10));
mstrmind_random3 = (random.nextInt(10));
System.out.print(mstrmind_random0+""+mstrmind_random1+""+mstrmind_random2+""+mstrmind_random3);
end = keyboard.nextInt();
} while (end > 0);




}

}

>>
>>52226332
>Here's what I hate so far
>>
>>52226332
I think you should put them in an array so you can iterate though them
that should help with checking
// pseudocode obviously
noduplicate = true
for i = 0 to 3 // iterate first term for comparison
for j = 0 to 3 // iterate second term for comparison
noduplicate = noduplicate && mstrmind_random[i] != mstrmind_random[j] // this will flip noduplicate to false as soon as it encounters a duplicate


it's a pretty inefficient way to check for duplicates because it's got tonnes of obvious redundant checks but you've only got 4 terms so who cares

then wrap your random generation in a while loop like this
bool noduplicate = false

while !noduplicate
// your code goes here
// above code goes here
>>
the only decent programming languages:
>Java
>C++
>C#
>D
>>
>>52226539
You forgot--
Oh wait you didn't forget D

I like you anon
>>
>>52226539
Can we get nim on this list?
>>
File: rollout.gif (128 KB, 210x240) Image search: [Google]
rollout.gif
128 KB, 210x240
>>52226539
>no love for x86 Assembly
>>
>>52226591
i haven't really looked into it tbqh but it does look good. not a fan of implicitly declared variables but maybe an IDE could highlight implicit declarations.
>>
>>52226652
>https://nim-by-example.github.io/variables/result/
oh it's actually only result that's implicit? i like
>>
>>52226421
>I don't even know how I wrote that.
>>52226495
I can't I seriusly have to do this with intergers at this point, and I have no idea how to use noduplicate
>>
why is the visibility not changing on hover? this seems like it should work to me.

<div id=steam>
<ul>
<li><a href="steamlink">steam</a></li>
<li>
<ul>
<li><a href="steamlink2">alt</a></li>
</ul>
</li>
</ul>
</div>


      #steam ul li + ul {
visibility: hidden;
}

#steam ul li:hover + ul {
visibility: visible;
}


the second link is appearing at all times but should only be visible when the first link is hovered. what did i fuck up?
>>
>>52226694
I mean an array of integers
int[] mstrmind_random = new int[4];
mstrmind_random[0] = random.nextInt(10);
mstrmind_random[1] = random.nextInt(10);
mstrmind_random[2] = random.nextInt(10);
mstrmind_random[3] = random.nextInt(10);


or

for (int i = 0; i < mstrmind_random.length; i++) {
mstrmind_random[i] = random.nextInt(10);
}


noduplicate is just a boolean I declared
you can write that in a different way

bool foundDuplicate = false;

for (int i = 0; i < mstrmind_random.length; i++) {
for (int j = 0; j < mstrmind_random.length; j++) {
if (mstrmind_random[i] == mstrmind_random[j]) {
foundDuplicate = true;
}
}
}
>>
>>52226739
I think /wdg/ would probably be better able to help with that
>>
>>52226792
yeah i've asked there but that place is a graveyard
>>
>>52226769
I see, but I can't really use arrays at this point.
But thanks, ill try to do it your way .
>>
>>52226804
oh

the problem is that mostly html+css development (that's what that is, right? I haven't written html or css for years) here usually gets sent straight to /wdg/, so we probably don't have anyone who could help
>>
>>52226827
alright i see i see. yeah its just some very basic html+css stuff but like i am so confused at to why something so basic is giving me this much trouble. i'll try there again. thanks, friend.
>>
>>52226814
Why can't you use arrays? Are you a student and the question doesn't involve them, or have you just never used them before?

If it's the latter, there's really only one solution to that, and they're pretty simple, and incredibly useful, when you get used to them

if you don't want to you could still write out each comparison if you really need to
if (mstrmind_random0 == mstrmind_random1 ||
mstrmind_random0 == mstrmind_random2 ||
mstrmind_random0 == mstrmind_random3 ||
mstrmind_random1 == mstrmind_random2 ||
mstrmind_random1 == mstrmind_random3 ||
mstrmind_random2 == mstrmind_random3) {

// run this code if there are duplicates
}
>>
>>52226539
why ?
>>
>>52225579
>>52225733
Hi, it's me again.

So I've come this far:
http://pastebin.com/2GUhrd5G

Now I want to get started on the graphical work. In school I was taught Swing, is this the best approach?

Also, how can I implement a path selection dialog as easy as possible? I don't really know what to look for, and all my googling is giving me the good old "JAVA_HOME Path problem" links. As the project is now, I have to manually type (or copy/paste) the path into the console, which is not ideal, lol. Any particular things I should read up on?

Any help and tips would be greatly appreciated!
>>
>>52226865
Both actually since neither does the teacher allow us to use functions that we haven't learned yet and I never used them.
Thanks.
>>
>>52226876
If you're writing an MD5 cracker shouldn't you be using a faster language?
>>
>>52226939
What makes Java a slow language?
What are the criteria for the "fastness" of a language?

I'm not being critical, I just want to learn as much as possible and maybe pick up a thing or two along the way.
>>
Is a programmer's code quality inversely proportional to the amount of terminal rice and scripts they've crammed into their .bashrc?
>>
>>52227012
no it's counter proportional, good devs don't care about the env, they just hack the code
>>
>>52227012
Nothing is ever that simple. But people who are interested in ricing are mostly people who want to "get into coding because it would be cool to know coding", and thus they only learn so much that they can show it off to people without really having too much insight. So a riced up build doesn't automatically scream "THIS PERSON CAN'T CODE" in my opinion, but I think it's likely that the person is one of the people I described earlier in this post.
>>
>>52225787
which school? are you enjoying the curriculum goy?
>>
>>52225789
why so formal m8? come 'ere, have a beer
>>
>>52226962
java compiles to bytecode which runs on a virtual machine. Oracle writes and compiles versions of the virtual machine to support other platforms
this was done so you only have to compile once and it will run on any system for which there exists a version of the virtual machine, but the added layer between the code you write and the instructions the computer executes tends to slow things down a bit
it used to be worse, but it's still getting better

other languages like C/C++ compile to architecture-specific code, which is generally faster, but you have to recompile for each different architecture you want to support

if you're just writing it to learn it'll probably be fine but be warned java can be anything from a bit slower than (well written) C/C++ code, to tonnes slower

as a general rule though, formulating a more efficient algorithm to do something, or eliminating redundant code, is going to be 100x more effective optimisation that switching to a 'faster' language
cracking MD5's, though, can't really be optimised, so switching to a faster language is kind of the only option for improving speed
>>
>>52227049
inverse_palm.jpeg
>>
>>52227078
>inverse_palm.jpeg

lol'd hard
>>
>>52227072
Thanks dude, informative and well-constructed 5-star post.

I'm using Java because that's what I learned in school. I've been checking out C/C++/C# a tiny bit, but it seems a little overwhelming (probably because I haven't done so much with it), it's probably easier than I think right now tho. I always try to keep my programs at a minimum amount of operations to get where I want, but I agree that when the workload is simply fucktons of repetitions, there really are close to no optimizations to do. Maybe when I'm done with the Java one, I'll try to recreate it in C/C++ to learn that language.
>>
>>52225818
It's almost like you didn't actually read what he typed.
>>
>>52227178
Move onto C#, it's basically just Java but better (Especially if you're developing for Windows)
>>
File: 588mlH7.webm (2 MB, 720x404) Image search: [Google]
588mlH7.webm
2 MB, 720x404
Ask your beloved programming literate anything

>>52226962
java, the programming language, is not slow or fast but the implementations of java are usually slower than the ones for c or c++ because java

- needs a runtime (garbage collection)
- has no explicit memory management
- has implicit bounds checking on arrays.
- has more level of indirection (because of GC and virtual)
- enforces exceptions (= more checking to do)
- has no unsigned types

and probably other reasons that i can't think off.

>>52227072
>java compiles to bytecode which runs on a virtual machine
Compiling java code aot or java bytecode aot is a thing. some compilers actually does that (gcj, excelsior)
>>
>>52227178
C++ gets a bit silly at times
the syntax can sometimes be absurdly difficult for humans to read (and, incidentally, for compilers to read. That's one of the reasons it takes so long to compile)

it's going to overwhelm you at first, so you either have to persevere to crack it, or just give up and use a similar language with nicer syntax - I'd suggest D but it's kind of niche so there isn't much support for it online. You'd probably have to make an account for the forums or something and ask and wait (use the old trick of registering a female username and you'll cut wait times in half)

I'd have to say C# is probably the best way to go. It's not too much faster than java honestly, but it'll help you bridge the gap to C/C++

oh yeah and another thing - learning java you've probably been using IDEs like eclipse or netbeans. A lot of people find these to be more trouble than they're worth, and that just writing files manually with an editor and compiling with the command line can be a lot simpler. Personally I recommend atom, it's pretty neat

>>52227221
Yeah I'd heard about compiling java like that but I have no idea how it performs so I don't really feel knowledgeable enough to talk about it
>>
File: slughorn.png (479 KB, 1280x547) Image search: [Google]
slughorn.png
479 KB, 1280x547
>>52227311
This is very dark stuff anon, very dark indeed
>>
>>52227340
>I saw the Half-Blood Prince just yesterday
Holy shit wtf

but kekcellent response

>>52227311
But to answer your question:
Yes, every hashing mechanism is suffering from this problem when you limit it to a string of x characters. At some point, two different files HAS to get a matching checksum. Take MD5 for example.

The MD5 checksum consists of 32 hexadecimal characters. This means that there are [Very many] combinations available. However, programs can be as long as they ever want. So when you've made [Very many] unique programs, the next program you make is guaranteed to have the same checksum as one of the previous programs (if it hasn't already happened).

It's possible, yes, but it will take an ENORMOUS amount of time.
>>
>>52227072
The VM isn't the only issue for performance.

Java also has a number of safety features (a program written in Java will never crash because of a mistake in Java code, only because of a mistake in native code or the language implementation), and those also have a performance cost even if the bytecode is being compiled to native code.
>>
is codeacademy viable?
i want to learn the basics and i don't know which language to take first that's not HTLM
>>
>>52225689
>10 is only divisible by 5
that's how you spot a troll
>>
>>52227414
The tasks are nice and you get to learn the language and how it can be used, however I think they make it too easy since you don't have to repeat what you learned earlier when you progress to a new subject, it's all pre-filled in except for the task in question. Therefore, it's easy to forget what you just learned as you progress.

But if you're able to remember stuff after doing it once or twice, it's perfectly fine.
>>
>>52227245
that's not how gets work
>>
>>52227414
If you want to stay a babby, yes. Take the python course and finish it in less than a week. Get on projecteuler after and do as many problems as you can with python to test and build your knowledge. When you're stuck, don't straight up look the answer up, look up bits and pieces like "efficient python sieve" or "properties of pandigital numbers"

I don't know if it will work for you, but that's how I got gud at Python.
>>
>>52227410
It's among the biggest though

I actually cannot believe I forgot to mention that java tends to eat memory like it's saving it for the winter
every object has a 1 byte overhead IIRC, and the handling of strings can only be described as 'fucking batshit insane'
since reading from memory is proportionately hugely slower than it used to be (meaning that in some cases it's actually tonnes more efficient to recompute a number rather than to store it in memory and get it back when you need to), this tends to impact performance a lot

also since automatic garbage collection is not something you generally want to place under a lot of stress (tends to be a lot slower than manual allocation / deletion), the performance drops due to larger memory usage are massively compounded
>>
>>52227294
> the syntax can sometimes be absurdly difficult for humans to read (and, incidentally, for compilers to read. That's one of the reasons it takes so long to compile)

Parsing isn't the issue; the time taken to parse a C++ program is a minuscule fraction of the overall time.

One of the factors which makes C++ slower is that name resolution is far more complex due to classes, namespaces, templates, and argument-dependent lookup. The existence of these features increases the time even if they aren't actually used.

Another factor is the use of templates and the extensive use of inline functions, which means that the code actually being compiled is significantly more complex than what's in the source file. While these are only a factor to the extent that they're used, the standard library uses both extensively.
>>
>>52227485
>the handling of strings can only be described as 'fucking batshit insane'

Are you talking about the row we had the other night over reference v. value equality?
>>
>>52227464
is there a better FREE site?
any books on programming?
>>
>>52227513
Oh, I'm talking about the free section.

https://www.codecademy.com/learn/learn-java
https://www.codecademy.com/learn/python
>>
>>52227491
Parsing is definitely one reason
I probably shouldn't have specifically said 'syntax'
I was referring to the fact that a compiler has to spend loads of time trying to resolve the meaning of anything that's put into it (arguably because of OO shit, the weird template system, and context-sensitive-grammar everywhere)

>>52227499
No I mean in the memory

prepare for total horror:
>every object has at least 8 bytes of housekeeping data, and arrays 12 bytes, and will be padded to a multiple of 16 bytes (in 32-bit versions of Hotspot);
>a Java String actually consists of more than one object
>a Java char takes up two bytes, even if you're using them to store boring old ASCII values that would fit into a single byte;
>a Java String contains some extra variables that you might not have considered.

I believe they're changing (or maybe have already changed, I don't know) the 3rd point there, which is good
basically the problem is the overhead, and the fact that String is bloated with other stuff which would be faster to compute on-the-fly on pretty much any modern hardware profile
>>
>>52227245
>>>52225666 (You)
>>>52226666 (You)
goddamn i get quads more often than i even realize
>>
>>52225087
Not as bad as the get that literally murdered /pol/ for the entirety of last night.

Last I checked, it was over 950 replies, plus like 17 threads about it.
>>
>tfw programming alone

Shit is the worst. I keep making silly mistakes that any other sane person could just be like "Oh, you did [retarded mistake] here."

I'm buying a rubber duck for now.

Anyone had any success with hiring prostitutes just to talk with? Kind of like an animated rubber duck with breasts.
>>
File: deep concern.webm (2 MB, 1280x720) Image search: [Google]
deep concern.webm
2 MB, 1280x720
>>52227946
>>
>>52227634
> I was referring to the fact that a compiler has to spend loads of time trying to resolve the meaning of anything that's put into it (arguably because of OO shit, the weird template system, and context-sensitive-grammar everywhere)
There isn't really much context-sensitive grammar (the actual grammar given in the standard isn't itself context-sensitive, but classifying certain tokens requires a lexical tie-in).

Bear in mind that the grammar only needs to specify enough detail that correct programs are parsed correctly. It does not need to distinguish between correct and incorrect programs, nor does it need to get involved in name resolution.

This is why e.g. the most vexing parse is resolved statically as a function declaration rather than an initialisation (taking into account whether the argument is a valid expression would make the grammar context-sensitive). You parse it one way, check that the result is valid (doesn't violate any constraints), if it isn't you report an error (i.e. you don't vary the passing according to what, if anything, an identifier refers to).

The other parts (i.e. name resolution) aren't parsing, they're compilation. Any performance hit isn't because the syntax is hard for a compiler, it's because the semantics are. But those semantics are a large part of what makes C++ powerful. You can do a lot at compile time to improve run-time performance (e.g. template expansion and function inlining).
>>
File: spiderdance.gif (1 MB, 231x161) Image search: [Google]
spiderdance.gif
1 MB, 231x161
>>52228097
I've got to confess I never did a real degree so my knowledge of the terms is a bit iffy at times
I did say syntax was the wrong word to use, and by extension parsing wasn't really what I meant
>>
>>52228194
Well, the tl;dr version is that compiling C++ programs is slow so that running them is fast.

The syntax is ugly because C++ adds a boatload of new features to C while trying to use essentially the same syntax. But changing the syntax wouldn't make compilation any faster.
>>
File: itcGiGu.png (38 KB, 749x556) Image search: [Google]
itcGiGu.png
38 KB, 749x556
Something isn't quite right here...
>>
File: safe in the light.jpg (256 KB, 1920x1080) Image search: [Google]
safe in the light.jpg
256 KB, 1920x1080
>>52228344
>>
>>52225087
Shouldn't have used a mac (tm) you stupid girls! You wouldn't have that problem with Microsoft (r) Windows (tm)!
>>
File: 1451403150671.jpg (44 KB, 500x269) Image search: [Google]
1451403150671.jpg
44 KB, 500x269
Could really use some help, what is the best way one would go about learning javascript having a bit of experience in programming. Looking for a book suggestion really.

I understand I could just read the online references but would they really explain all the gotchas associated with JavaScript? I've decided that Eloquent JavaScript would be a good book but I feel it might just be for beginners, could really use some advice
>>
Threadly reminder. OCaml is your salvation.
>>
>>52228340
It would, significantly so. C++ syntax is nowhere even close to LALR(1) understandable and requires extremely complex backtracking logic.
>>
>>52228563
The best way to learn javascript is to gouge out your eyes and eat them. With a rusty spoon if you can.
>>
>>52228564
>OCaml
That's a funny way to spell D
>>
>>52225787
rolling
>>
>>52228590
Call me when D programs are both fast to write and fast to run.
>>
>>52228602
ring ring
>>
>>52228563
javascript: the good parts
>>
Good and cheap books for learning Python?
>>
>>52228612
As expected, dfags have no idea what fast to write and fast to run mean.
>>
>>52228632
Ask a gay man with HIV to inject that knowledge through your anus.
>>
>>52228638
weren't you here for the race in the last thread?
>>
>>52228589
aye don't worry I've got a steel poker handy for my journey through the jungle of shit
>>
>>52228632
http://learnpythonthehardway.org/

Just pirate programming books.
>>
Writing an interface for a "smart"-managed switch that doesn't have SNMP support.
I'm using requests and BeautifulSoup, which makes it a bit easier, but the web interface is poorly written.
Weird tables, multiple elements using the same ID attribute, to much JavaScript.
I'm pretty sure SNMP is just disabled, I know it has support for it and is probably running.
>>
>>52228651
No, I was busy resting as fast as possible.
>>
I'm teaching myself Javascript. I'm starting off with code academy but this stuff is trivial (if statements and shit, probably functions and classes later) what's a good project idea I could do where I could learn a lotime of JS while doing it?
>>
>>52228706
Wait, you're writing a frontend based on scraped HTML rather than just interfacing with the firmware? baka
>>
Need a good regex for splitting English words, taking into account apostrophes and hyphens.

Here's what I've got so far:
[^\p{L}]*\p{Z}[^\p{L}]*
>>
>>52228706
>poorly written
Translation: I don't understand it.
>>
File: 1390196427175.jpg (518 KB, 1700x1000) Image search: [Google]
1390196427175.jpg
518 KB, 1700x1000
C++ newfriend here from a few days ago. Is Dev-C++ a good IDE for getting started?
>>
File: sad.png (3 KB, 280x94) Image search: [Google]
sad.png
3 KB, 280x94
>>52228615
bit old tho isn't it. This seems like a book I'd come back to after I've got some exp in js
>>
>>52228869
Consider Visual Studio if on Windows.
>>
>>52228819
>Wait, you're writing a frontend based on scraped HTML rather than just interfacing with the firmware? baka
It doesn't have anything other than a web interface.
No telnet, ssh, snmp, console port, etc.

>>52228859
Nah, just poorly written.
>>
>>52228869
sure start with Dev-C but get the Orwell version (or whatever its called) then move onto VisualStudio
>>
>>52228877
Alrighto, thanks. learncpp.com seems to also advise it.
>>
>>52225185
cool idea
>>
I'm implementing a faster matrix multiply into node through a c++ addon. Unfortunately I've never even written hello world in c++ and am having some trouble with memory leaks. Each time I call the function the memory use trends towards infinity? Anyone got any pointers (no pun)?

#include "stdafx.h"
#include <nvblas.h>
#include <nan.h>

void dmmult(double a[], double b[], int m, int n, int k, double c[]) {
//A is column-wise M x K matrix
//B is column-wise K x N matrix

const char transa[] = "N"; //Invert matrix A
const char transb[] = "N"; //Invert matrix B

const double alpha = 1; //Scaling factor
const double beta = 0;

dgemm(transa, transb, &m, &n, &k, &alpha, a, &m, b, &k, &beta, c, &m);
}

void dmmult_input(const Nan::FunctionCallbackInfo<v8::Value>& info) {
if (info.Length() < 5) {
Nan::ThrowTypeError("Wrong number of arguments");
}

int m = Nan::To<int>(info[2]).FromJust();
int n = Nan::To<int>(info[3]).FromJust();
int k = Nan::To<int>(info[4]).FromJust();

int i;
int len;

//Convert A to C array
v8::Local<v8::Object> aObj = info[0]->ToObject();
len = m * k;
double* a = new double[len];

for (int i = 0; i < len; i++)
{
double element = Nan::To<double>(aObj->Get(i)).FromJust();
a[i] = element;
}

//Convert B to C array
v8::Local<v8::Object> bObj = info[1]->ToObject();
len = k * n;
double* b = new double[len];

for (int i = 0; i < len; i++)
{
double element = Nan::To<double>(bObj->Get(i)).FromJust();
b[i] = element;
}

double c[] = { 0 };

dmmult(a, b, m, n, k, c);

len = m * n;
v8::Local<v8::Array> nodeArray = Nan::New<v8::Array>(len);

for (i = 0; i < len; i++) {
nodeArray->Set(i, Nan::New<v8::Number>(c[i]));
}

info.GetReturnValue().Set(nodeArray);
}

void Init(v8::Local<v8::Object> exports) {
exports->Set(Nan::New("dmmult").ToLocalChecked(),
Nan::New<v8::FunctionTemplate>(dmmult_input)->GetFunction());
}

NODE_MODULE(addon, Init)
>>
>>52229292
>FromJust();

JUST
>>
>>52229292
double* a = new double[len];
double* b = new double[len];


Because you are never freeing these.
 delete 
them when you are done.
>>
>>52229292
another anon will probably have more insight, but i'm pretty sure anything you create with the "new" keyword must be deleted to free the memory
>>
>>52229292
Because you're using new and delete instead of std::unique_ptr.
>>
>>52228830
splitting English words? Like into characters?
>>
>>52228830
okay, so you do know ^ makes the class invert, so your first statement matches zero or more items that aren't letters, then second matches a single space, then the last is like the first. where are you capturing letters?
>>
>>52228871
It's not and it's not.
>>
>>52229392
Splitting the entirety of this thread's content into a list of individual words.

I'm doing analytics for the NSA.

>>52229454
I'm capturing logical separations. I'm using the regex to split on matches for separations, such as whitespace, not capture the words themselves.
>>
>>52229478
well your regex will match every space. If all you need is to split by space \p{Z}+ is what you want. It matches at least one, but as many as possible, adjacent spaces.
>>
File: 1443871116076.jpg (47 KB, 960x720) Image search: [Google]
1443871116076.jpg
47 KB, 960x720
What is a good book to learn java? Currently using Big Java by Cay Horstman and I don't like it. Any other java books out there that people recommend?
>>
>>52229682
Suicide.
>>
test
>>
r8 my isnum function /g/
    public static boolean isNum(String s) {
char[] c = s.toCharArray();

for (char c1 : c) {
if (c1 == '0' || c1 == '1' || c1 == '2' || c1 == '3' || c1 == '4' || c1 == '5' || c1 == '6' || c1 == '7'
|| c1 == '8' || c1 == '9')
continue;
else
return false;
}

return true;
}
>>
>>52225185
That's a bitchin Windows 8 app you've got there.
>>
>>52229549
To add. English semantics is not something you can capture with regex. So your 'logical separations' will be limited in some aspect. Draw your lines.
>>
>>52225787
Rolling
>>
>>52229912
What do you goys think about software patents?
>>
>>52229856
switch my man.
>>
>>52229856
Java/10

    public static boolean isNum(String s) {
for (char c1 : cs.toCharArray()) {
if !(c1 == '0' || c1 == '1' || c1 == '2' || c1 == '3' || c1 == '4' || c1 == '5' || c1 == '6' || c1 == '7'
|| c1 == '8' || c1 == '9')
return false;
}
return true;
}
>>
>>52229856
if (c1 >= 48 && c1 <= 57)
>>
I've got a little modal window that opens, and I want to bind two different objects of the same type to two different sets of controls.

I am bad at databinding, how would I set two different containers for each object so I can bind the contents to separate instances of an object?
>>
>>52229956
Language?
Datatypes?
GUI framework?

Details, slut.
>>
File: 1408751367381.jpg (2 MB, 3504x2336) Image search: [Google]
1408751367381.jpg
2 MB, 3504x2336
>>52229930
http://www.gnu.org/philosophy/fighting-software-patents.en.html
http://www.gnu.org/philosophy/stallman-mec-india.en.html
>>
>>52229344
>int m = Nan::To<int>(info[2]).FromJust();
More like

RUST
>>
>>52229956
I hate to say this
>FactoryBean
>>
>>52229970
C# WPF.

I think I've figured out a way to do it, I just create a containing class for both objects, then just feed each object into the class, then set the context for each content container to be the two separate objects.

It's probably gonna be a bit of a pain in the ass but it should work.
>>
>>52230046
>>52229970
My only problem now is working out in my head how to set it up and pass the objects over, which isn't as easy as I first thought.
>>
>>52229363
>>52229363
>>52229373
>>52229383

Thanks comrades, adding
 delete 
fixed it.
>>
File: SS0VKZs.jpg (51 KB, 604x415) Image search: [Google]
SS0VKZs.jpg
51 KB, 604x415
Should I consider committing sudoku instead of learning Lisp or any other functional language if I believe this looks hard, senpaitachi?

1a. (MIT-Scheme) Using the function


(define (accumulate combiner null-value l)
(if (null? l)
null-value
(combiner (car l)
(accumulate combiner
null-value
(cdr l)))))

Implement sum-of-squares, which calculates the sum of squares of a list, for example

(sum-of-squares '(1 2 3 4 5))

should evaluate to 55.
>>
>>52229856
>j*va
int isnum(char *s)
{
int res = 1;
while (*s != '\0')
res &= isdigit(*s++);
return res;
}
>>
>>52230434
there is no point in learning any programming language besides
>Java
>C++
>C#
>D
>Nim
>>
>>52230434
You should off yourself anyway if you even consider lisp or anime after you turn 11 years old.
>>
>>52229954
>>52229946
>>52229856
public static boolean isNum(String s) {
for (int i = 0, n = s.length(); i < n; ++i) {
char c = s.charAt(i);
if (c < '0' || c > '9') return false;
}
return true;
}
>>
>>52230434

Keep trying. It takes a while to read code as a tree instead of as a sequence of instructions, but it will change the way you think about abstraction and complexity. It will give you familiar concepts even in `dayjob_language`.

First: http://www.htdp.org/
Next: http://www.eecs.northwestern.edu/~robby/courses/321-2015-fall/
Then: https://mitpress.mit.edu/sicp/full-text/book/book.html
Finally: OCaml, Haskell.
>>
>>52230500
there is no point in learning any programming language besides
>C
>>
>>52230500
What a horrible list.
>>
>>52230434
You should embrace languages like C++, D, and Python instead and stop wasting your time with useless stuff that has no practical use.
>>
>>52230560
thanks /g/!!
forgot completely about charAt()
>>
>>52229856
myString.chars().allMatch(Character::isDigit)


It's shit.
>>
>>52230775
>this much built-in bloated and obscure shit to solve tasks this simple
disgusting
>>
>>52225787
Rolling

On topic, working on a way to parse the event finder free throw data for individual players to produce an accurate version of TS% without having to do it manually.
>>
>>52230608
You should never just learn one thing. At least learn a scripting language and a compiled language.
Use the right tool for the job you are doing. But learning one language should prepare you for learning a new one pretty fast.
>>
>>52225756
>base 10 is much easier to deal with than base 12
Only because we're used to it.

Base 12 is better, you can divide 12 by 1, 2, 3, 4, 6, 12.

You can only divide 10 by 1, 2, 5, 10.
>>
>>52230861
We should have base 1 system then every number would be divisible by all the base numbers.

II + III = IIIII

II * III = IIIIII

Look how much easier it is to understand.
>>
>>52230915
This doesn't even warrant a reply
>>
>>52230861
dividing 10 by for example 4 is easy, it's 2.5

and 2.5 is easy to use

divide 12 by 5 and you get 2.4 which is not as easy to deal with and other numbers in base 12 will also be messy to divide by 5

the "solution" would be to use base 60 but that is also messy. we use base 60 all the time but it's a pain the ass to for example multiply 3½ hours by 1.5 and convert it to minutes, while if we had 10 minutes in an hour it would just be 3.5*1.5*10=52.5 minutes calculated in your head easy as pie
>>
>>52230820
>obscure

Any language worth using has primitives like this, they are basic building blocks.

Haskell:
all isDigit myString

C#:
myString.All(Char.IsDigit)

Python:
all([c.isdigit() for c in myString])

C++:
std::all_of(myString.begin(), myString.end(), isdigit)


etc.
>>
>>52230860
What's a scripting language? You mean interpreted?
>>
File: ooi.png (1 MB, 1920x1080) Image search: [Google]
ooi.png
1 MB, 1920x1080
>>52230915
Prime numbers are a meme, aren't they?
>>
>>52230948
A scripting language is one where you can execute the code files directly, instead of compiling them to executables first.
>>
>>52230860
Compiled languages are fine for scripting on homogeneous ecosystems.
>>
>>52230934
i love you anon
>>
>>52230967
So if I run a C interpreter?

Or if I run a PHP compiler?
>>
>>52230934
this is completely redundant when you can write it trivially using normal loops and conditions
>>
>>52230964
No, I don't think so, even in base 1 primes exist.

IIIIIII (7) is only divisible by I (1) and IIIIIII (7).
>>
File: 1374782163623.jpg (111 KB, 500x500) Image search: [Google]
1374782163623.jpg
111 KB, 500x500
>>52230860
>a scripting language and a compiled language.
240
>>
>>52231003
>loops and conditions
this is completely redundant when you can iterate and apply using language built-ins / standard library
>>
>>52230996
Yep, C can be considered a scripting language in a way if you use it as one. But since it's really not designed or used for that in real life, most would not really call it a scripting language.
>>
Anyone here who doesn't use syntax highlighting? I'm up for the challenge.
>>
>>52230967
doesn't make any sense.
>>
>>52231027
Don't even fucking think you can fool anyone, that is an I (eye) and I (eye) fuckin' know it. (eyet).
>>
>>52230967
or you could just use java
>>
>>52231038
linus torvalds
>>
>>52231032
you can program anything using loops and conditions

you can only do fizzbuzz-tier trivial code monkey tasks using built-in functions
>>
>>52231049
Yes it does.

>>52231052
I'm just explaining what scripting language is. You can cool your Java shilling for 5 seconds.
>>
>>52231003
>trivially
Irrelevant. Loops and conditions are naturally error prone and a huge source of bugs, not to mention more verbose.

Code is written to be read, and you can NOT tell me 5 lines of code is more readable than a simple 1 line expression.
>>
>>52231035
>But since it's really not designed or used for that in real life
You're full of shit

Languages aren't "designed" to be compiled or interpreted, anon.

Just look at the hundred different dialects of BASIC... The first ones were compiled, then they were interpreted, and most recently with Visual Basic (and VB.NET) they are again compiled (whereas VBScript is interpreted).
>>
>>52231050
I just think I's look neater at representing base 1 senpai.
>>
>>52231082
>Languages aren't "designed" to be compiled or interpreted, anon.
yes they are.

>The first ones were compiled, then they were interpreted, and most recently with Visual Basic
And?
>>
>>52231072
Check your privilege, you imperative scum.

Functions are first-class citizens too. Don't discriminate.
>>
File: 1430853197680.png (331 KB, 474x432) Image search: [Google]
1430853197680.png
331 KB, 474x432
>>52231074
>more verbose
>you can NOT tell me 5 lines of code is more readable than a simple 1 line expression
>f(xs x : xs: ds fa).iter.(filter.inrange(x -> xs f(pget)).apply(tk)) is more readable than "do this and do that. if this happened, then to that other thing"
kill yourself
>>
>>52230932
I think a better solution would be for kids to learn a range of base systems.
>>
>>52231097
>yes they are.
No, they really aren't.

>And?
Do you really think it was "designed" to be either?

Take Lisp for example, it was conceived as a theoretical language and then the first implementation was a Lisp machine (as in actual hardware built for running Lisp).
>>
What would a -1 base system look like, /dpt/?
>>
>>52231130
>No, they really aren't.
C was designed to be compiled. The whole point of the language it to be a high performance portable language. There is not much consideration in the language for making it good for scripting. It can be used for scripting of course, but it was not designed for that.

>Do you really think it was "designed" to be either?
BASIC? maybe not. Why?

>it was conceived as a theoretical language and then the first implementation was a Lisp machine (as in actual hardware built for running Lisp).
K. What's your point?
>>
>>52231100
Functions don't exist.
You're talking about code (natural numbers interpreted as machine instructions) not some made-up "functions."
>>
>>52231153
A MEME.
>>
>>52231114
>kill yourself

Nice argument.
>>
>>52231003
>this is completely redundant when you can write it trivially using normal loops and conditions
reinventing the wheel the post
>>
File: ij.jpg (104 KB, 1280x720) Image search: [Google]
ij.jpg
104 KB, 1280x720
/dpt/ can't write a function that converts any base system into another base system
>>
>>52231181
Code doesn't exist anon, lol.
>>
>>52231251
Do we need to support fractional bases? Arbitrary precision decimal bases? Irrational bases? Negative bases? Base 0?
>>
File: 1425429412322.gif (141 KB, 287x344) Image search: [Google]
1425429412322.gif
141 KB, 287x344
>>52231194
""""""""functional""""""""

data UpToTwo a = Zero | One a | Two a a
histo2 :: (UpToTwo a -> a) -> Int -> a
histo2 f = result . gen where
result (One x) = x
result (Two x _) = x
cons x Zero = One x
cons x (One y) = Two x y
cons x (Two y _) = Two x y
gen 0 = One $ f Zero
gen n = let
memo = gen (n-1)
in cons (f memo) memo

fib = histo2 phi where
phi Zero = 0
phi (One _) = 1
phi (Two x y) = x + y


imperative

int fib(int n) {
if(n == 0 || n == 1) {
return n;
}

int a = 0;
int b = 1;

for(int i = 1; i < n; ++i) {
int m = a + b;

a = b;
b = m;
}

return a + b;
}


>>52231222
never inventing anything the post
>>
>>52231251
let convertBaseSystem(oldBaseSystem, newBaseSystem) =
newBaseSystem

let oldBase = 10

let newBase = convertBaseSystem(oldBase, 12)
>>
>>52231269
Just natural number bases senpai.
>>
>>52225087
Fucking badgrl2
>>
>>52231273
>Functional programming is bad because I'm fucking horrible at it
Great argument anon.
>>
>>52231180
>The whole point of the language it to be a high performance portable language.
It was supposed to be portable period.

It was never intended to be fast, that's just the result of it in practice being a portable assembly.
>>
>>52231308
let's see your O(n) """"""""functional"""""""" fib
>>
>>52225579
>Instantiating an entire object just to read input
Classic Java
>>
>>52231291
>cheating
>>
>>52231273
>int fib(int n) {
> if(n == 0 || n == 1) {
> return n;
> }
This is completely redundant.

i is initially 1, it will by definition be less than 0 or 1.
>>
>>52230934
>C#
could also be
int.TryParse(myString, out myInt);

if you want to assign to an int in the same statement that can assign to a bool
>>
>>52231301
Including base 0 then? Yeah I cant do that.
>>
>>52231360
>0
>natural number
Pick one.
>>
>>52231273
The classic Pythonian is much more elegant.
def fib(n):
a, b = 0, 1
for i in range(0, n):
a, b = b, a + b
return a
>>
>>52231073
A scripting language is when you are using a programming language for extending a specific software/program. some examples are c# for unity3d, mircscript for mirc, javascript for internet browsers, C for linux, ... You can't say that X or Y is a scripting language but that X or Y has been used as a scripting language. Being interpreted or compiled is irrelevant.
>>
>>52231372
Some meme mathematicians count 0 as a natural number, they are, of course wrong to do so.
>>
>>52229856
No check for sign, no support for floating point or scientific notation.

0/10, would not lex with.
>>
>>52231342
sure but it still needs if(n == 0) return 0 because the guy that wrote the histo2 shit does the variation where fib(0) is 0
>>
>>52231308
See 20 threads ago where you got BTFO so much you stopped posting when the thread was less than 100 posts in.
>>
>>52231387
less punctuation != elegant

or else i should probably have gotten the pulitzer prize for my shitposts
>>
>>52231400
Like i said, a scripting language is one where you can execute the code directly without having to compile it to an executable. Just like the examples you listed, except for C.

>Being interpreted or compiled is irrelevant.
Never claimed it was, or even mentioned those things.
>>
>>52231432
>See 20 threads ago
uhh.. I guess that could have been me. But more than likely I just left my computer to do something else. I generally admit when i've been BTFO because I quite like being proven wrong.
>>
>>52231465
>2016
>literally too retarded to understand what he's even saying
>still says it
>>
>>52231494
>literally too retarded to understand what he's even saying
Good argument anon. I'm convinced now.
>>
>>52231319
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
>>
>>52231487
Your tears are delicious
>>
Cygwin or Mingw?
>>
>>52231507
>implying this is readable
>>
>>52231319
def fib(n, a = 0, b = 1):
return fib(n - 1, b, a + b) if n > 0 else a
>>
>>52231529
mingw

but i think you're supposed to have both? mingw for the compilers and cygwin for muh linux autism
>>
>>52231513
Yes anon, you totally got me. Good job :)
>>
>>52231538
See >>52231546
>>
>>52231554
Oh really? I just thought they both accomplished essentially the same thing
>>
>>52231546
m8...

def fibs(n):                                                                                                 
fibs = [0, 1, 1]
for f in range(2, n):
fibs.append(fibs[-1] + fibs[-2])
return fibs[n]
>>
>>52231546
that's basically a loop rewritten into a recursive function. we were talking about lambdas and junk like that
>>
>>52231583
That memory usage though

Try doing fibs(200)
>>
>>52231594
>that's basically a loop rewritten into a recursive function
Yes, that's the fucking point.

>we were talking about lambdas and junk like that
No, we were talking about a functional O(n) implementation of a fibonacci number generator.
>>
>>52231602
>>> fibs(200)
280571172992510140037611932413038677189525L


took less than 1 second

recursive will still use a lot of memory from the call stack
>>
>>52231538
zipWith is a common idiom in functional programming anon. The line is a concise description of the fibonacci sequence.
>>
>>52231619
>Yes, that's the fucking point.
it's pointless
>>
>>52231627
>recursive will still use a lot of memory from the call stack

Well, rewrite it in C and let GCC do TCO. Or alternatively, rewrite it in another language that supports TCO.
Thread replies: 255
Thread images: 43

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.