[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: 32
File: daily_progarmming_thread.jpg (105 KB, 457x614) Image search: [Google]
daily_progarmming_thread.jpg
105 KB, 457x614
Anime edition

old: >>54895080

What are you working on today /g/?
>>
Continue my journey with Elixir.
>>
putting stuff up my butt
>>
>>54906842
What is the best dialect of C to program in?
What dialect of C is the Linux kernel programmed in?
Why does dwm not use the stdint.h library?
Why do some projects not use the stdint.h library?
Isn't int16_t much better than just int because it is more specific?
>>
>>54906842
>Write for programmer first, for compiler second. Your co-worker will not be easily convinced, so I would prove empirically that better organized code is actually faster. I would pick one of his worst examples, rewrite them in a better way, and then make sure that your code is faster. Cherry-pick if you must. Then run it a few million times, profile and show him. That ought to teach him well.

I find it suspicious that advocates of object-oriented programming find it necessary to deceive critics to convince them of its superiority, or that this kind of behavior is acceptable at all in an academic and/or professional environment.
>>
>>54907033
>What dialect of C is the Linux kernel programmed in?
Mostly C90 see
https://stackoverflow.com/questions/20600497/which-c-version-is-used-in-the-linux-kernel
>>
>>54907033
>What is the best dialect of C to program in?
Plan9 C. Nice, small libraries with pleasingly simple names (dprintf -> print), automatic inclusion for linking, simple conventions, best toolchain, a no technical debt environment, etc. The only thing is that it didn't take off, sadly.

See http://doc.cat-v.org/plan_9/programming/c_programming_in_plan_9 et al.
>>
>>54906842
>What are you working on today /g/?
experimenting with rust
extern crate rand;
use rand::distributions::{IndependentSample, Range};

#[derive(Debug)]
enum Number<T> {
Prime(T),
MaybePrime(T),
Composite(T)
}

fn witness(a : u64, n : u64) -> bool {
let mut d = 1;
for i in (0..64).rev() {
d = (d*d) % n;
if ((n-1) & (1<<i)) != 0 {
d = (d*a) % n;
}
}
d != 1
}

fn miller_rabin(n : u64, s : u64) -> Number<u64> {
assert!(n > 3);
let mut rng = rand::thread_rng();
let between = Range::new(2, n-1);
for _ in 0..s {
if witness(between.ind_sample(&mut rng), n) {
return Number::Composite(n);
}
}
Number::MaybePrime(n)
}

fn isprime_primitive(n : u64) -> Number<u64> {
assert!(n > 0);
let mut i = 2;
while i*i <= n {
if n % i == 0 {
return Number::Composite(n)
}
i += 1;
}
Number::Prime(n)

}

fn isprime(n : u64) -> Number<u64> {
if n < 1000 {
isprime_primitive(n)
} else {
miller_rabin(n, 100)
}
}

fn main() {
let mut i = 2;
loop {
println!("{:?}", isprime(i));
i += 1;
}
}
>>
File: glenda_space_medium.jpg (13 KB, 239x276) Image search: [Google]
glenda_space_medium.jpg
13 KB, 239x276
>>54907326
>dprintf -> print
Not true sorry. It's still the nicest environment to do system programming in C tho. Also see http://plan9.bell-labs.com/sys/doc/comp.html
>>
Novice here, I decided to try and program the game Bang! in Java.
For those who don't know the game: it's a card game for 3-8 players, each has a role card (determines victory conditions), a character card (determines special power), and a bunch of playable cards. At the beginning of your turn you pick up 2 cards, then you can play blue cards for equipment, green cards for temporary equipment and orange cards for immediate actions. There are many different types of cards for each of these 3 categories.

Now here's my (main) problem: how should I go about implementing the "character cards" functionality?
There are like 80 different cards of this type and each has a different power that can influence a different aspect of the game. For example, one card could let you pick 3 cards at the beginning of your turn instead of the usual 2, another could let you shoot other players with cards other than the usual "Bang!" card, another still could let you regain 2 HP instead of 1 upon using a "Beer" card, etc.
I have this feeling I should use inheritance and make each character card its own class, but then how would I ensure that the program applied the special ability regardless of which aspect of play it modifies? Do I just have to have a check at any action? Or is there a more elegant way?
>>
V8 is a magical piece of software

https://ia601503.us.archive.org/32/items/vmss16/titzer.pdf
>>
File: smug_sakura.jpg (29 KB, 337x404) Image search: [Google]
smug_sakura.jpg
29 KB, 337x404
>>54908403
>mfw plebes tell me that Javascript is an "interpreted language"
>>
>>54907845
>each character card its own class
That'd be at least 81 classes. I've played the game, you could instead use scripts to load in the stats and abilities and have the abilities be flags that are not dissimilar from the equipment cards. Like "heal_amount = 2" "ignore_range = true" etc.
>>
>>54908478
>>54907845
>81classes with minor differences
>static language problems
>>
>>54907326
>best toolchain
>dat cross compiling ease

Muh dick
>>
So I have a nested loop in .net, and I want to refer to the indexes in the code running in the loop without having to type a long list of x = i, y= j, etc. Ideally I would want to have an array and use i(0) as the first index, i(1) as the next, etc, but it won't let me do that. I could use a dictionary and add all the index variables to it but it seems slow.
>>
Is it just me or has there been a sharp decrease in activity of these threads?
>>
>>54908533
>I want to refer to the indexes in the code running in the loop without having to type a long list of x = i, y= j, etc.

So.. just refer to them using i, j?

I don't see what the issue is here.
>>
>>54908533
How deep is your loop nested? Also why can't you use an array?
>>
>>54906842
She looks like wife material desu
>>
>>54908539
you can only fizzbuzz is so many languages
>>
>>54906842
ur mom
>>
>>54908566
>"For loop control variable already in use by an enclosing For loop"

>>54908564
Because it's a lot of nested loops and having to type out all of the indexes manaully inside makes it look messy as fuck.
>>
>>54908478
>use scripts to load in the stats
Like a scanner to read from a txt file that's organized in a sort of table?
>>
Any java dev here?
Which IDE do you use?
>>
>>54908937
Android Studio, because muh company policy.
>>
>54902122
>>54901762
Can't you just use
instance Monad (Categorised c)
?
>>
>>54909000
Why not use intelliJ ?
>>
>>54908937
Eclipse because my company makes me use it. I'd use Intellij if it was my decision.
>>
>>54909018
Android Studio is a reskinned IntelliJ. I also use vim if I just want to look up code in another project.
>>
>>54908472
>uses javashit unironically
>calls other plebs
A superoptimized flying turd is still a fucking turd.
>>
>>54907033

>What is the best dialect of C to program in?
C11

>What dialect of C is the Linux kernel programmed in?
GNU89, some GNU99.

>Why does dwm not use the stdint.h library?
Doesn't need exact width types. The C standard library also does not use stdint types for most things.

>Why do some projects not use the stdint.h library?
See above.

>Isn't int16_t much better than just int because it is more specific?
No. If you don't need an integer to be exactly a specific size, don't use fixed width types. They aren't even defined on all platforms (in particular, the ones that use 9-bit bytes). As a general rule of thumb, you should firstly always use the type of any function you are using that you haven't written. Most C functions use int to return status codes, and that's perfectly fine. The size_t and ssize_t types are often used with regards to strings/arrays, because the maximum sizes for these often vary based on the platform. I'd rather not use an int64_t to store my string length if I'm on a 32-bit platform, and I'd rather not be gimped by the restrictions of a 32-bit platform on a 64-bit platform, so when storing the lengths of these structures, and often when making indices to offset them, a size_t or ssize_t is preferred.
>>
>>54908657
>Because it's a lot of nested loops

Time to refactor.
>>
>>54909119
>in particular, the ones that use 9-bit bytes

1. Which platforms?
2. Does anyone care about them?
>>
>>54909141

1. Unisys/Univac machines. Some are still in use today. Also, some old IBM and DEC machines.
2. Not really, although I honestly think when writing C code, it is best to make the least amount of assumptions possible about the target platform. If you know something needs to be 32 bits, then by all means, use uint32_t or int32_t. Otherwise, int is fine... unless it NEEDS to be at least 32 bits, in which case int_least32_t is your best bet. And yes, I happen to have multiple devices in my room where int is 16 bits, rather than 32.
>>
So, i have this dictionary
 dic = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123465789 


i want to generate all password combinations with 6 letters for example: 5h7e54, DTE2ar, cujsas, 123asc, etc

how can i do this in C or python?

thanks
>>
>want to use a library
>I have to get it via all this git wizardry

Is there any point trying to muddle through on Windows or should I install Gentoo?
>>
>>54909284

Development on Linux is "fun" and "easy".
>>
>>54909284
You should have had Gentoo installed already, nobody gets into this thread without it
>>
>>54909250
>>54909250

bump
>>
>>54909250
In python you can use itertools

import itertools

dic = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ123465789"

passwords = itertools.combinations(dic, 6)
>>
>>54909250
Literally just generate 6 random integers, bring it into your dictionary's index range by modulo dividing it by the size and finally concatenate the rwsults.
>>
>>54909417
Fuck, I didn't read that thoroughly enough.
>>
>>54909388
this doesn't work

import itertools

dic = "abcdef"

passwords = itertools.combinations(dic, 6)

print list(passwords)


output
[('a', 'b', 'c', 'd', 'e', 'f')]
>>
>>54909446
well there is only one combination of 6 letters, using 6. try with more letters
>>
/fit/ is so fucking retarded they're even more dimwitted and underage than /g/
>>
>>54909481
no i was supposed to output all combinations with 6 letters:

aaaaaa
aaaaab
aaaaac
aaaaad
....
defcba
acbfed
...
>>
I wrote a script to list all packages on my Gentoo system in @selected with no other packages that depend on them.

For example firefox is in @selected because I specifically installed it, but there is nothing that depends on firefox.

However I fucked up my system and have garbage like "random-library-used-by-nothing" that is also in @selected because I specifically installed it, but it's not needed because there's nothing that depends on it.

#!/bin/bash

while read pkg ; do
equery d "$pkg" > temp
if [[ ! -s temp ]] ; then
echo "$pkg" >> nodeps
fi
done < pkgs # A list of all packages installed
>>
>>54909570
>#!/bin/bash

use #!/bin/env/bash
>>
>>54909532
ah i see, itertools.product does that

import itertools

dic = "abcdef"
passwords = itertools.product(dic, repeat=6)
for password in passwords:
print("".join(password))
>>
>>54908403
>We all love JavaScript
>ctrl+w
>>
>>54909585
>use #!/bin/env/bash

You mean
#!/usr/bin/env bash
, or
#!/bin/env bash
?
>>
>>54909609
kek
>>
>>54909630
i meant
#!/usr/bin/env bash
>>
File: dont curl|sh.png (19 KB, 618x175) Image search: [Google]
dont curl|sh.png
19 KB, 618x175
Just another day of programming discussions on #rust
>>
>>54909724
what's unsigned code?
>>
>>54906891
+1
>>
>>54909724
(c) kys
>>
>>54909731
code not signed with a digital signature
>>
>>54909724
please use 'humans' instead of guys
>>
>>54908937
Eclipse
best IDE
>>
File: 1463866805490.jpg (114 KB, 500x750) Image search: [Google]
1463866805490.jpg
114 KB, 500x750
im out of inspiration
gimme something to program
>>
File: cross.webm (3 MB, 480x270) Image search: [Google]
cross.webm
3 MB, 480x270
/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA).

>>54909895
A programming language implementations benchmark.

>>54909724
What irc client is that ?

>>54909388
There 56,800,235,584 combinations. kek.

Naive version

import math
import string

dic = string.ascii_letters + string.digits

# only 4,611,686,018,427,387,840 iterations Σ(°□°)⊃
for i in range(0b111111, (1 << 62)):

# state of art popcount (*  ̄∀ ̄)
if (bin(i).count("1") != 6):
continue

password = ""

# floating point log2 because i didn't read my hacker's delight today (*´・Д・)
for j in range(int(math.log(i,2)+1)):
if i & (1 << j):
password += dic[j]

print(password)
>>
>>54909895
Is this what turtle genitalia look like?
>>
combinations != permutations ffs
>>
>>54909895
sir please, this is a family friendly image board
>>
>>54909984
do you wear girl clothes when you program?
>>
>those boobs on the table

saved
>>
File: 1443500977688.png (835 KB, 1200x1080) Image search: [Google]
1443500977688.png
835 KB, 1200x1080
>>54910216
you don't ?
>>
What's the best course for C?
Paid or free, I don't mind, but free will be appreciated.
>>
>>54909984
mmm... sauce?
>>
>>54910268
Books.
>>
>>54910268
c primer plus
>>
>>54909984
They made a fucking anime out of this?
>>
>>54910268
https://www.quora.com/Which-are-the-best-books-to-learn-C

http://www.learn-c.org/
>>
Encapsulation: useful mechanism to increase robustness or shooting yourself and others in the leg?

Discuss
>>
>>54908682
by script I really just meant the files themselves. Organized using YAML or XML or something. A bit ambiguous meaning I used. But yes, reading organized data.
>>
File: laughing_anime_whores.gif (3 MB, 445x247) Image search: [Google]
laughing_anime_whores.gif
3 MB, 445x247
>he doesn't put an f after decimal values
>>
If people are making an engine, consider looking at this (possible) code from Kero Blaster

https://gist.github.com/Wunkolo/039f8c727edfa6cdddec#file-pxpack
>>
File: lau.webm (567 KB, 445x247) Image search: [Google]
lau.webm
567 KB, 445x247
>>54910396
>gif
>3.23 MB
>not webm
hey, this is the technology board here so we expect some use of the said technology.
>>
>>54910325
both
>>
File: AHAHAHAH FAGGOT.gif (49 KB, 200x200) Image search: [Google]
AHAHAHAH FAGGOT.gif
49 KB, 200x200
>>54910427
>he doesn't want his videos of laughing anime whores to autoloop
>>
>>54910427
>>54910396
it's funny how the webm has less quality in it
>>
File: sauce on my nipples.gif (2 MB, 377x364) Image search: [Google]
sauce on my nipples.gif
2 MB, 377x364
>>54910396
>the filename
>laughing anime whores
>anime whores
>whores
>>
>>54910453
A lot of anime reaction webms were converted from gifs by lazy people so they still retain the shittiness of the gif.
>>
>>54910476
actually most of webms are coming from gifs uploaded to imgur.
>>
>>54910325
Hiding complexity is actually best thing you can do to avoid fuckups. Stupid, unskilled and mediocre pogrammers (including yourself) don't have to tackle all shit that's behind the functionality, so chance that they screw something up decreases. Also saves time for everyone.
>>
>>54908937
Eclipse because we're using it at work, but I have preference for Intellij
>>
>>54910445
webms autoloop tho?
>>
>>54910599
Not for me, what browser do you use?
>>
>>54910568
unskilled coders will make bugs, with or without encapsulation
and there is nothing more pointless than making accesors and mutators if all that they do is returning or setting private variable
prove me wrong
>>
>>54910654
Chrome.
>>
>>54910677
>having a bunch of getters and setters

You're doing OOP wrong.

Not the guy you're responding to, but OOP's approach to complexity management is fine. It's modularization, i.e. correctly handling the complexity and preventing future maintainers from having to deal with that complexity unless necessary.
>>
>>54910721
>modularisation doesn't happen in any other paradigm
>>
>>54910735

That's right. OOP is the GOATest.
>>
>>54910677
>and there is nothing more pointless than making accesors and mutators
Say you have a class called Price, and it contains an i64, would you make that i64 publicly accessible?
>>
>>54910476
But yours has worst quality than the gif, that's what I meant, the gif has more details from a glance.
>>
>>54910721
>>having a bunch of getters and setters

>You're doing OOP wrong.
i do not write simple getters and setters most of the time
just make the fucking variables public, it's not a nuclear weapon ffs
>>
Does anyone here have an opinion on bioinformatics? It seems like just text parsing to me, but the algorithms can be pretty interesting; especially about how to make them more efficient. I was thinking about studying a bioinformatics class on coursera, not sure if that is a waste of time though.
>>
>>54910748
Why not?
>>
>>54910677
>and there is nothing more pointless than making accesors and mutators if all that they do is returning or setting private variable
yes, but if you end up deciding that you want to do more than just "returning or setting private variables" the interface stays the same.

The point of encapsulation is about making interfaces that abstract away the implementation so the end result is the same between versions. Likewise, you should always minimize mutability of your variables, your variables should be set by the client at construction, after that if you're using setters your implementation probably needs refactoring.

Accessors are open game though.
>>
>>54909984
>What irc client is that ?
It isn't a client, it's logs: https://botbot.me/mozilla/rust/
I used kiwiirc.com though if you're interested
>>
>>54910735
I didn't say that.
>>
>>54910764
C# gets this right. Want a mutable property?

{ get; set; }
>>
>>54910800
No, but you said that was "OOP's approach to managing complexity". That's practically every paradigm's attempt to managing complexity.
>>
File: no.jpg (186 KB, 816x488) Image search: [Google]
no.jpg
186 KB, 816x488
>>54910764
>just make the fucking variables public
you ruin the whole point of OOP, stupid!
>>
>>54910814
Literally retarded
>>
>>54910814
Yes, C# has almost reasonable approach (proving itself superior to Java once again).
Still prefer Python philosophy in that matter tho.
>>
>>54910782
Now say you've published that class as a library, people are depending on it, but you notice 64 bits isn't enough precision for some applications, so you decide to use gnu gmp instead.
What do you do now to avoid breaking existing code that depends on the internal representation of a price being stored in a 64 bit integer?
>>
>>54910835
>you ruin the whole point of OOP
i don't think the whole point of OOP is restricting access
>>
>>54910819
So? I'm not wrong.
>>
>>54910836
yes
public int MyNum { get; set; } = 0;
//...
obj.MyNum++;


is way more retarded than

private int myNum = 0;
public int getMyNum() { return myNum; }
public void setMyNum(int myNum) { this.myNum = myNum; }
//...
obj.setMyNum(obj.getMyNum()+1);
>>
>>54910864
If that's your standard for not being wrong then it's no wonder you like OOPs
>>
>>54910836
I think you mean beautiful.
>>
>>54910871

Don't even reply. He's probably the "lmao k sperg" guy.
>>
For those that know JavaScript, what's the best source to learn the language?

>Mozilla Developer Network JavaScript Guide
>Standard ECMA-262
ECMAScript® 2015 Language Specification
>>
>>54910850
>any year
>indicating privateness through public attributes with underscore prefixes
>not having real encapsulation
>>
File: 12yo simulator.png (15 KB, 801x270) Image search: [Google]
12yo simulator.png
15 KB, 801x270
>>54910871
They're both retarded, dumbass. Your response to someone saying "accessors are bad" is to show trivial accessors that shouldn't even fucking exist

>>54910883
>>
File: cute.jpg (680 KB, 1920x1080) Image search: [Google]
cute.jpg
680 KB, 1920x1080
>>54910862
The whole point of oop is complete abstraction of the data : Only the procedural abstraction is visible. For example, in Java, an interface can't have any variables, data is an implementation matter that should be irrelevant to the user. Please, learn your oop right.
>>
>>54910896
I mean can anyone fucking explain to me what the difference is between

x; and x { get; set; };
>>
>>54910909
this
>>
>>54910888
It's the perfect solution. You still mark shit as 'don't tamper unless absolutly necessary', but you don't barricade the doors and windows only to figure out ways of exiting the house few days later
>>
>>54910896
This looks like ES6 javascript but it's not. What is this?
>>
>>54910915
You can add logic to the { get; set; } version without changing the interface. The first version is a field rather than a property, and reflection treats them differently (generated IL may also be different, but that's just me speculating), so changing from field to property is a change in the interface.
>>
>>54910933
D

. also does UCFS so it pipes the thing before it into the first parameter of the call, i.e
5.someFunction(3) = someFunction(5, 3) (unless there's already a member for that)

! is template invocation
x => ... is a lambda
>>
>>54910930
>arguing with trips
>>
>>54910946
Yeah but if you're going to change it you should be using an interface in the first place
>>
>>54910963
>randomocracy instead of meritocracy
>>
>>54910885
bump
>>
>>54910971
You forgot your tripcode
>>
>>54910930
actually that sounds reasonable
>>
>>54910968
That doesn't make sense. Interfaces without multiple implementations are bullshit.
>>
>>54911004
No, it should be an implementation of an interface
>>
>>54911010
>>>>>>>>>/assuming you will never change anything that doesn't have an explicit interface/
>>
>>54911004
Leave him, maybe he is the interface for every class type of guy
>>
>>54911019
This is the fucking problem with OOP
Nothing is modular in the first place
>>
Is there a name for this or do others not really use anything like it?
bindFold :: (Monad m, Foldable t) => t (a -> m a) -> a -> m a
bindFold l n = foldl (>>=) (return n) l
>>
>>54911024
but every object has an implicit interface, anon, it's even its type.
>>
>>54910896

I like your D, famalam.
>>
File: 1464034129407.jpg (364 KB, 813x530) Image search: [Google]
1464034129407.jpg
364 KB, 813x530
I recently left my job as a trader, I'm looking move into a programming job. I also have just recently found Christ and want to do something not evil. Does anyone have suggestions of firms or niches I should look to? I don't really care about money.
>>
>>54911024
Always easy to spot the newbe: He's the one who thinks oop is only about classes. Ever heard of prototypes or message passing, whiteboi ?
>>
>>54911057
I think there's supposed to be a function that returns N random elements from a range but I can't for the life of me remember

>>54911080
>literally interface based languages
>haha proves him wrong
>>
>>54911080
>whiteboi

>>>/pol/
>>
>>54911024
But these people should be euthanized.
>>
you're not supposed to have getSomeVariable, you're supposed to have getSomeValue

the value might not even exist as a variable, the implementation could calculate it or something, and the implementation can have additional logic for all you know and it's fine as long as it fulfills the contract of the interface
>>
>>54911035
It is if you stop using fields. :^)
>>
>>54910885
https://developer.mozilla.org/en/docs/Web/Tutorials
Also http://bdcampbell.net/javascript/book/javascript_the_good_parts.pdf

JS is actually a good language, don't listen to spergs.
>>
>>54911120
Nobody on /pol/ says whiteboi

How do you live with being this bigoted and ignorant?
>>
>>54911165
Does Mozilla update it's documentation to match the latest changes?
>>
>>54911165
>>
>>54908533
Could you post your code, I'm having a really hard time trying to figure what the fuck you're actually talking about.
>>
>>54911187
Who the fuck reads a book that big?
>>
>>54911187
>herp da derp a definitive guide by one author is bigger than a positive summary by another author.

JavaScript is a crappy language but only a retard can't handle it.
>>
File: 1464823306282.png (5 KB, 270x175) Image search: [Google]
1464823306282.png
5 KB, 270x175
>>54911280
>JS shills are now forced to begin their posts with "JavaScript is a crappy language but"
>>
File: prime numbers python.png (108 KB, 1366x891) Image search: [Google]
prime numbers python.png
108 KB, 1366x891
I need help with this python code; i have three things that i want to fix from it.
I marked with red the details of the mistakes.
>>
>>54911280
>>54911296
1) HTML5/JS is a powerful platform that delivers applications to billions of people around the world, it runs on billions of devices.
2) Javascript is a descendant of Scheme and Self, so it is pretty cool language, especially if you forgive it its small defects. Solving the same problem in javascript seems to require 3-4x less code and 2-3x less dev time than solving it in C/C++/Java.
3) Fastest compilers/runtimes ever written for a dynamic languages were written for JS: V8, Chakra, Spidermonkey, Javascriptcore. JS is the fastest dynamic functional language in the world.

Programs written in JS tend to have 3-4x less code than equivalent C++ programs due to higher order functions and dynamism. Seriously, if you value your time you should use a dynamic functional language at least for prototypes.
>>
>>54910855
So do you ever make any variables public?
>>
>>54911175
lel, k tard
https://archive.4plebs.org/pol/search/text/whiteboi/
>>
>>54911296
JavaScript is far from perfect but I've had fun with it. The people that hate it are either bandwagoners or idiots that don't know how to take advantage of a dynamic type system.
>>
>>54911397
>literally people pretending to be black
>>
>>54911371
sorry, where is it red?
>>
>>54911382
No, usually not.
It's just as easy to generate accessors and they're much more flexible.
>>
unsigned int i =  1;
int j = -1;

if(j > i)
printf("nigger");


REEEEEEEEEEEEEEEEEEEEEEEEEEEE
programming languages are so fucking retarded sometimes, they can't even do simple math
>>
File: prime numbers python.png (111 KB, 1366x891) Image search: [Google]
prime numbers python.png
111 KB, 1366x891
>>54911371
oh i uploaded a wrong image without the errors marked, here's the good version of the pic
>>
>>54911296
*the JS shill is

>>54911431
i have literally never seen bait this bad
is this some kind of esoteric meta bait?
>>
File: 1459908542045.jpg (140 KB, 540x810) Image search: [Google]
1459908542045.jpg
140 KB, 540x810
i just started learning Haskell from LearnYouAHaskell

basically i want a comfy hipster startup programming job
am i heading in the right direction or should I be learning node.js, swift, and rubyonrails?
or should I be learning C and assembly?
Where's the money at?
>>
>>54909724
>use the best language that was ever created (rust)
>avoid the most disgusting (and dangerous!) community that was ever created (#rust etc.)
Fixed.
>>
>>54911423
still a common word on /pol/
>>
>>54911428
>>54911437
srry, there it is
>>
>>54911459
>common
No.
and they're all saying it ironically

>>54911456
The whole point of hipster languages is that you need to know all of them to get a job
>>
>>54911456
>startup
>comfy
You've got it all backwards anon, I'm sorry.
>>
>>54911474
well fuck
i just want a programming job, i'm good with math and logic, and I don't know how to go about it or what languages and stuff to learn how to use
>>
>>54911522
okay, maybe not startup, but fortune 500 software company silicon valley kind of thing
>>
>>54911373
DESU while JS isn't my favorite language, it's not the worst thing ever, particularly if it's the modern variant.

What I hate is HTML + CSS being a slow, clunky hack that isn't suited at all for most of what it's used for. Without optimization HTML + CSS is one of the most inefficient ways to construct a UI out there, optimizing it isn't a cakewalk, and even the most optimized HTML + CSS will be destroyed by any decent native UI toolkit (barring Windows, anyway. MFC, etc sucks ass).

If JSers could come up with a replacement for HTML + CSS that's specifically designed for creating applications (as opposed to presenting static documents) and use it instead of chromium wrapper crap, that'd be amazing, but they won't do that because web devs almost never care about efficiency. As long as it runs on their brand new quad core laptop with 16GB of RAM it's good, everyone else be damned.
>>
>>54911525
Are you retarded? Search for job openings and see reqs. Learn what you need and then apply to similar jobs.
>>
>>54911296
>i = "1"; i++
i++ = i + 1 = "1" + 1 = "11"

>NaN
NaN is still a numeric type, despite the fact it actually stands for Not-A-Number.

NaN just means the specific value cannot be represented within the limitations of the numeric type (although that could be said for all numbers that have to be rounded to fit, but NaN is a special case).

A specific NaN is not considered equal to another NaN because they may be different values. However, NaN is still a number type, just like 2718 or 3141

>==
double equals is for 'truthy' and 'falsy' comparisons and should very rarely if ever, be used.

>[5,1,20,10].sort()
no shit, the default sort for arrays in Javascript is an alphabetical search

tl;dr fuck off pajeet
>>
>>54911558
>If JSers could come up with a replacement for HTML + CSS that's specifically designed for creating applications
Look into React.
>>
File: 06-04-23-25-50.jpg (20 KB, 586x464) Image search: [Google]
06-04-23-25-50.jpg
20 KB, 586x464
Why is C# so comfy.
>>
>>54911569
>i++ = i + 1 = "1" + 1 = "11"
i + 1 isn't a modifiable lvalue
>>
>>54911588
F# is comfiest
>>
>>54911588
this

i wonder if it will gain some traction on other platform since .net core
>>
#include <stdio.h>

int main(void)
{
int i=0;
++(i++);
printf("%d\n", i);
return 0;
}


you should know what this prints
>>
>>54911558
>If JSers could come up with a replacement for HTML + CSS that's specifically designed for creating applications (as opposed to presenting static documents) and use it instead of chromium wrapper crap, that'd be amazing, but they won't do that because web devs almost never care about efficiency.

I thought about this, and that's why I have created my own V8-driven SDL2 application platform. It doesn't give you anything but canvas-like framebuffer though.

V8 is just a C++ program, you are free to create whatever you want with it.

There are also other projects, see react native and node.js GUI bindings.
>>
>>54911589
i++ increments the variable you stupid fuck
>>
>>54911617
everyone knows if it ever gains traction microsoft will destroy it, thus it never gains traction.
>>
>>54911585
I'm aware of React and its various flavors of native (mac, iOS, etc). I have no plans of using them personally because when I write JS it's going to be two lines on an otherwise static site.

It existing isn't enough, though. While React takeup seems to be high, everyone uses it to render to HTML browserside which defeats the purpose. The userbases of the various react native projects is tiny in comparison.
>>
I wrote a set of Node.JS scripts to wrangle my BIG DATA: several gigabytes of search engine queries.
>>
>>54911437
bumping on this
>>
>>54911634
Oh, and (i++) isn't a modifiable lvalue either
(++i) is
>>
File: javascriptpro.png (16 KB, 657x179) Image search: [Google]
javascriptpro.png
16 KB, 657x179
i know you guys are mad jelly right now desu senpai
>>
>>54911636
why would they destroy one thing they did right?
>>
>>54911654
>capitalized parameter name
>desu senpai
>no comma or exclamation mark
>>
>>54911675
tb.h f.am
>>
>>54911654
Try this http://pastebin.com/5nmdUBA8
>>
>>54911621
prints a compiler error.
>>
>>54911561
google wants software eng interns with c, java, python, and tcp/ip
sounds pretty good tbrqhwyfamalam
>>
>>54911689
>http://pastebin.com/5nmdUBA8
give me a year and i'll squat all over that pasta
>>
>>54911437
Your count function should be in your prime() function, it only goes up from the 2 it starts at because you don't increment count within your prime function. Does that make sense? Please ask a question if it doesn't, I tried to explain it clearly.
>>
>>54911431
No you can't do math, j is represented as 1111 1111 1111 1111 (if int is 16 bit) which is definitely greater than 0000 0000 0000 0001 (representation of i).

do your homework
>>
>>54911813
This is just an html file
>>
>>54911437
>>54911828
> it only goes up from the 2 it starts at
I meant it only increments the count once from 2 to 3 within your prime_2 function. Because you only go through the prime_2() function once, so count only goes up by one.
>>
>>54911859
Chrome gave me an unexpected syntax error after running it.
>>
>>54910952
neat

Javascript ES6 also uses lambdas in the same syntax.

I'd never heard of UFCS but it seems neat. Javascript programmers tend to do similar stuff in order to do functional programming or for some design patterns they use. Personally I would rather just have partial application, like Haskell does.
https://en.wikipedia.org/wiki/Uniform_Function_Call_Syntax

I don't really understand what the template invocation is doing but that aside D looks like a much nicer language to program in than I previously thought. Thanks for the info!
>>
>>54911047
Well, that's almost the same as
sequence
+
StateT a m ()
>>
>>54911437
Oh, crap, your stuff is more complicated than I thought at first. >>54911867 again. I think it has something to do with the recursive call you got going on with returning prime_2(n-1). I might have just confused you. I would restructure your recursive call, because without going through the debugging myself it's hard to picture what's going on in the stack in my head at least.
>>
>>54911185
Yes.

>>54911280
Javascript is a crappy language and it's very easy to write bad Javascript.
>>
>>54911987
>I can't stop myself from writing bad code

Fucking kill yourself.
>>
>>54911641
>everyone uses it to render to HTML browserside which defeats the purpose.
That is the purpose.
>>
>>54911899
Hmm, it should work. I saved this one http://pastebin.com/raw/5nmdUBA8 as test.html , opened it in chrome and it works. It is worth it.
>>
>>54912012
but who are you quoting?
>>
>>54911919
Templates in D can take any parameter, including functions
>>
>>54912061
"""it's very easy to write bad Javascript."""
>>
>>54912066
Oh, are functions in general not first class citizens in D? They are in Javascript, so it's fairly common to pass a lambda as a function argument like you did there.

>>54912091
A large number of people out there only scratch the surface of javascript and fall back on frameworks, coffeescript, and libraries like jquery to avoid having to actually learn the language.
>>
>>54912135
>A large number of people out there only scratch the surface of javascript and fall back on frameworks, coffeescript, and libraries like jquery to avoid having to actually learn the language.
These people should be purged in a great cleansing.
>>
>>54912135
They are but it's faster given templates are compile time
>>
>>54912182
I see, that does actually sound pretty cool.
>>
>>54911437
Does your code need to be recursive for homework or something? I feel like this version makes more sense to me and correctly gets 10 steps?

def prime(n):
for x in range(2,n):
if n%x==0:
return "not prime"
return "prime"

def prime_2(n):
count=0
hip = str(n)+ " -1 = " + str(int(n-1))
global x
while prime(n) == "not prime":
count+=1
print hip + " " + "not prime"
n=n-1
print count
print " "
return "number " + str(n) + " is prime found in " +str(count) + " steps"
print(prime_2(45687))
>>
>>54911437
Also, I think the biggest problem with your counting in the recursive function is you reset count to be 2 every time you call the recursive function.
>>
>>54912057
>http://pastebin.com/raw/5nmdUBA8

VM79:1 Uncaught SyntaxError: Unexpected token <(…)InjectedScript._evaluateOn @ VM73:145InjectedScript._evaluateAndWrap @ VM73:137InjectedScript.evaluate @ VM73:118
>>
>>54912276
>throwing strings around instead of booleans

absolutely haram
>>
>>54912476
Hi friend, thanks for your criticism, but I was just modifying another anons code to work better in the first way I thought of. I agree lol.
>>
>>54912476
First ammendment bitch
>>
>>54912276
It's not a homework, I'm trying to do somehting by myself.
And you missed the part where it needs to say " from the number " and the number
>>54912316
srry maybe i sent somehting that was njust trying to do, but i want to clarify that i've been into python for 2 weeks so im still a noob at it
>>
public void shit()
{
//...
}


vs

public void shit() {
//...
}
>>
>>54911437
>>54912476
imt the original poster from this, i did use the booleans but for the palindrome function
>>
>>54912624
neither, both of those are pretty equally ugly
>>
>>54912653
first one looks more comfy tho
>>
File: TOUCAN.jpg (97 KB, 770x1280) Image search: [Google]
TOUCAN.jpg
97 KB, 770x1280
>>54912672
>java
>comfy
>>
>>54912599
>And you missed the part where it needs to say " from the number " and the number
I was just trying to show a different way to do it, because I don't like recursion, in general, to solve a problem unless I see an easy recursive algorithm. Feel free to ask questions if you still need help?
>>
>>54912696
>implying curly braces are used only in java

time to learn at least one other language pajeet
>>
>>54912624
I prefer #1 for clarity personally.
>>
Okay, so I'm trying to learn Rust and the tutorial asked me to download the lib for generating random numbers. It has downloaded 200 MB so far and still not done.

WHAT
THE
FUCK
>>
>>54912714
>
public void ...

that basically narrows it down to Java, C#, D, etc. (in C++ it would be
public:
)
and since it's using a lower case letter for the method name it's almost surely not C# or D
>>
>>54911373
kys
>>
>>54912739
It's probably pulling in other library dependencies, so that might make sense.
>>
>>54907033

C89, C99 has trouble compiling on some stuff.
>>
>current year
>using C

Everyone, please stop prematurely optimizing.
>>
>>54912822
>current year
>not using a range of languages suited for different purposes
>>
>>54912739
>and the tutorial asked me to download the lib
cargo should do that for you
>>
>>54912822
>2016
>programming

You're on the wrong side of history
>>
>>54912845
>current year
>not having fizzbuzz as your're sole purpose
>>
>>54912895
yeah, today it's 'coding'
>>
void downloadImages(QString url, QString saveLocation){
QJsonObject data;
QNetworkAccessManager network;
QNetworkRequest request;
QUrl jsonURL = QUrl(url);
request.setUrl(jsonURL);
QNetworkReply *reply = network.get(request);

if(reply->error() != QNetworkReply::NoError){
qDebug()<<"nothing there";
return;
}
QString strData = (QString)reply->readAll();
QJsonDocument jsonTest = QJsonDocument::fromJson(strData.toUtf8());
}


So I am just trying make a Qt application that just downloads 4chan images from a thread. I'm confused on getting the JSON for the thread. The url that is being used is https://a.4cdn.org/g/thread/51971506.json. I printed it out to be safe. when I try to print out the size/length of of strData and jsonTest, I get 0.

If the Qt built in library is not good enough, what are some other libraries I should use instead?
>>
File: dfgdg.png (8 KB, 523x245) Image search: [Google]
dfgdg.png
8 KB, 523x245
>>54912706
hey thanks to you know i have 2 things solved, i analyzed some things even more... but now i have just one thing left to fix (the last NOT PRIME called should be just PRIME)
>>
>>54912891
Well yeah, cargo is pulling this repository with 30,000 commits.
>>
>>54910270

Boku no Boku
>>
guyz
guuuyz
I'm making an IA, it can already say "Good morning" or "Hello" or "Good evening" depending of the hour, will I make it guyz ?
>>
>>54912739
it's a shitlang made by webshits, what did you expect
>>
>>54912948
According to >>54912276's code, you're checking if n is prime, but printing prime(n-1). Also you are doing nothing if prime(n) returns "prime"
>>
>>54912992

Don't listen to this guy, it's Boku no Boku no Boku no Boku no Boku no Boku no Boku no Boku no Boku no Boku no Boku no
>>
>>54912706
>>54912948
i have this by now
def prime(n):
for x in range(2,n):
if n%x==0:
return "NOT PRIME"
return "PRIME"
def palindrome(n):
n_str = str(n)
if n_str == n_str[::-1]:
return True
else:
return False
def search_palindrome(n):
count = 0
print "Number entered: " + str(n)
while True:
count += 1
n_str = str(n)
n_rev = n_str[::-1]
r = int(n_rev)
n = n + r
print n_str + " + " + n_rev + " = " + str(n)
if palindrome(n):
break
print " "
return 'Palindrome "' + str(n) + '" found in ' + str(count) + " steps."
def prime_2(n, count):
hip = str(n) + " - 1 = " + str(int(n-1))
if prime(n) == "NOT PRIME":
print hip + " " + "NOT PRIME"
return prime_2(n-1, count + 1)
else:
# Recalculate the original value
original = n + count
count += 1
print " "
return "Number " + str(n) + " is prime found in " + str(count) + " steps, starting from the number " + str(original)
x = int(raw_input("Enter a number: "))
print prime(x)
print " "
print search_palindrome(x)
print " "
print "Number entered: " + str(x)
print " "
print prime_2(x, 0)
>>
>>54912946
I don't write much Qt but it looks like your code isn't asynchronous while
network.get()
is. reply is going to be null when your if statement runs, because the if statement runs immediately instead of waiting for a server response.

I don't know how you do asynchronous networking properly with C++/Qt, but with Objective-C/Cocoa we usually use completion blocks (known as closures in other languages).
>>
>>54912948
That's because you didn't have it print when it reaches a non-prime number.

You can add it outside the while loop that I had. The part where it prints is inside the loop, when it hits the prime number, it exits the loop. >while prime(n)
Hope that helps.
def prime(n):
for x in range(2,n):
if n%x==0:
return False #not prime
return True #prime

def prime_2(n):
oldn=n
count=0
hip = str(n)+ " -1 = " + str(int(n-1))
global x
while prime(n) == False and n>0:
count+=1
print hip + " " + "not prime"
n=n-1
print count
print hip + " " + "not prime"
print count
print " "
return "number " + str(oldn) + " is prime found in " +str(count) + " steps"
print(prime_2(45687))
>>
>>54912999
http://ai.neocities.org/
>>
>>54913045
>>54913087
My bad, I just copy pasted on the outside of that while loop it should be prime and not not prime, but that should be an obvious oversight.
>>
>>54906842
i like this image op
Thread replies: 255
Thread images: 32

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.