[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 321
Thread images: 28

File: jvjs7.jpg (175KB, 700x350px) Image search: [Google]
jvjs7.jpg
175KB, 700x350px
What kind of trouble are you up to?

Old thread: >>62271195
>>
>trouble
How to stop procrastinating
>>
>>62278156
Isn't Java deprecated in education now? I read a headline but cba to read it.
>>
trying to make a babies first botnet
>>
I'm reading a HTML tutorial on w3schools.
>>
File: 1496425578606.png (87KB, 698x658px) Image search: [Google]
1496425578606.png
87KB, 698x658px
>>62278261
>>
File: bullshit.png (13KB, 770x312px) Image search: [Google]
bullshit.png
13KB, 770x312px
trying to figure out this stupid shit for uni but the -1 on the range(len fucking ruins it
>>
>>62278184
remember - you can make your code cute by using lambdas.

In python the expression (and thus scope) isn't evaluated until it is called so you can do things like
Niggr = lambda x: i*x if x > 3 else i*3

for i, j in enumerate(something()):
print(niggr(j))


CUTE
>>
>>62278269
What's so funny?
>>
If I'm developing a multi-user networked application with support for thousands of simultaneous users and I use MySQL (MariaDB to be exact), should I write a database server into a separate application, or directly connect to the database from all the servers that serve users?
>>
>>62278290
python lambda syntax is disgusting.
even java does it better
>>
>>62278348
you're a nigger
>>
>>62278291
First
>>>/wdg/
Second, use Mozilla's reference and tutorial on HTML.

>>62278284
Anon, remember your fundamentals.
>>
>>62278358
>>62278290
jesus christ and I just realized the point you were making with i's scoping. that's gross, even javascript doesn't allow that
>>
>>62278332
I'm a fan of writing a database access API for the app
this way you precisely control what the clients can do (no arbitrary sql queries), because you only create a handful of API calls for what they actually need
you also get to verify the fuck out of each parameter that is sent in
>>
>>62278348
Java's lambda syntax isn't that bad though.
>>
>>62278156
Working with Java
public class Solution {
public List<List<String>> groupAnagrams(String[] strs) {
if (strs == null || strs.length == 0) return new ArrayList<List<String>>();
Map<String, List<String>> map = new HashMap<String, List<String>>();
for (String s : strs) {
char[] ca = s.toCharArray();
Arrays.sort(ca);
String keyStr = String.valueOf(ca);
if (!map.containsKey(keyStr)) map.put(keyStr, new ArrayList<String>());
map.get(keyStr).add(s);
}
return new ArrayList<List<String>>(map.values());
}
}


Working with Javascript
function groupAnagrams(strs) {
let map = {};
for(let s of strs) {
let key = s.split('').sort().join('');
(map[key] = map[key] || []).push(s);
}
return Object.values(map).map(a => a.sort());
}
>>
>>62278388
I was thinking of just making an API instead. So you would not make a separate application for the database, then? Just do all queries from main program, but through the API.
>>
>>62278364
>First
>Second
Third, you write like an asshole.
>>
>>62278400
I would make a separate application
the client application doesn't have to know anything about the database really, it doesn't even have to know a database exists
it just has to know where to send requests and how to parse the responses
>>
>>62278415
I see. I might do try that, then.
>>
File: 1504658421132.jpg (93KB, 1280x720px) Image search: [Google]
1504658421132.jpg
93KB, 1280x720px
>>62278404
>Third, you write like an asshole.
How old are you?
>>
>>62278375
No, javascript allows that, look up variable hoisting
>>
>>62278425
Old enough to be your father kid, stop watching chinese cartoons. They make you stupid.
>>
File: asdeg.png (6KB, 223x515px) Image search: [Google]
asdeg.png
6KB, 223x515px
>>62278364
This is what I have to choose from, if I write it

 diagonal = []
last_column = len(matrix) - 1
for row in range(len(matrix)):
diagonal.append(matrix[row][last_column- row])


it works perfectly but I can't take the fucking -1 out of the "range(len(matrix)" part so it cuts the last number
>>
>>62278392
Actually, a little bit better is this one
function groupAnagrams(strs) {
let map = {};
for(let s of strs.sort()) {
let key = s.split('').sort().join('');
(map[key] = map[key] || []).push(s);
}
return Object.values(map);
}
>>
I'm actually employable now that I'll be finishing up college, and am curious how prevalent is C# in the current job market? I've been using C++ for years and am very comfortable with it, but I seems like Microsoft is giving more attention than ever to C# and it seems like there's more and more frameworks popping up that use it.
>>
>>62278451
>>62278451
Although admittedly it has slightly worse time complexity when all your strings are one anagram.
>>
>>62278392
working with python
from collections import default dict
def groupAnagrams(strs):
handler = lambda: ''.join(sorted(s.split('')))
keys = defaultdict(list)
for s in sorted(strs):
keys[handler()].append(s)


We win again
>>
>>62278461
I knew it because I'm actually your lost and forgotten twin. It's good to see you after all these years brother.
>>
>>62278471
Yeah you can't beat Java's verbosity. And you can still get reasonable static assertions with TypeScript.

Although you probably want to return
keys.values()
>>
>>62278466
Er, meant to say different anagrams.
>>
>>62278460
>I'm actually employable now that I'll be finishing up college

Oh ho ho, maybe not as much as you think.
>>
>>62278571

More than others I guess? I have a GitHub with plenty of contributions and a sizable open source program made for editing Halo 2 .map files. I mean, I've never been through the process, but I hope they don't look at me like every other shit that just plopped out of college (spoiler: they will)
>>
File: 1478141418312.jpg (118KB, 500x500px) Image search: [Google]
1478141418312.jpg
118KB, 500x500px
>>62278449
This should tell you that one of your other answers is wrong then.
Think, anon, think. I believe in you!
>>
>>62278600
Link your github, fag.
>>
>>62278608
I have less than 30 minutes left to turn it in and I've been stuck on it for the past 2 hours.
I don't want to give up but this is fucking ridiculous, I found a way that works but because some dickhole that wrote this shit thinks it has to be more complicated than it is, my answer is wrong
>>
>>62278392
ArrayList<List<String>> groupAnagrams(String[] strs) { 
Map<String, List<String> map = new HashMap<>();
for (String s : strs) {
String sorted = Stream.of(s.split("")).sorted().collect(Collectors.joining());
map.computeIfAbsent(sorted, k -> new ArrayList<>()).add(s);
}
return new ArrayList<List<String>(map.values());
}
>>
>>62278684
Take a sceenshot of each combobox then like you did here >>62278449
I or some other fag will give you an answer.
>>
>>62278176
>tfw 4 month streak of no code written
>>
>>62278156
Could you please delete your image? It's late at night and I'm tucked in bed all snug but it's so spooky when I saw it uhm well now I have to get up and change my sheets and pajamas...
Please take the image down now, please and thank you...
>>
>>62278702
All the boxes have the same choices
>>
>>62278460
>I'm actually employable now that I'll be finishing up college
Wait, does this mean you have no chance without a degree?
>>
>>62278704
No.
>>
File: 1495115718107.png (61KB, 1201x774px) Image search: [Google]
1495115718107.png
61KB, 1201x774px
https://www.reddit.com/r/dailyprogrammer/comments/6y19v2/20170904_challenge_330_easy_surround_the_circles/

import std.stdio,
std.algorithm,
std.string,
std.conv,
std.array;


void main()
{
float[] x_max, x_min, y_max, y_min;

char delim = ',';
string input;
while ((input = readln().strip()) !is null){
//C++ cucks can suck my fucking cock
float[] vals = input.split(delim).map!(to!float).array();
x_max ~= vals[0] + vals[2];
x_min ~= vals[0] - vals[2];
y_max ~= vals[1] + vals[2];
y_min ~= vals[1] - vals[2];
}

float max_x = x_max.maxElement();
float min_x = x_min.minElement();
float max_y = y_max.maxElement();
float min_y = y_min.minElement();

writefln("(%s, %s), (%s, %s), (%s, %s), (%s, %s)", max_x, max_y, min_x, max_y, min_x, min_y, min_x, max_y);

}
>>
>>62278641

I'd rather not, identifiable information there. Though I could clear it up for a bit I guess.

>>62278719

No, it doesn't. But I live in a pretty major city where business converge on my school pretty much daily looking for talent. It's just a good place to network and build a resume with research.
>>
>>62278733
Please, anon, it's really spooky...
>>
File: 1469758534469.jpg (30KB, 600x518px) Image search: [Google]
1469758534469.jpg
30KB, 600x518px
>>62278752
>https://www.reddit.com
>>
>>62278348
>java lambdas
still waiting for Java 8 to hit

>>62278471
>We win again
I threw up a little

def groupAnagrams(strs)
strs.group_by { |s| s.chars.sort.join }
end
>>
File: 1474080067610.jpg (436KB, 907x1350px) Image search: [Google]
1474080067610.jpg
436KB, 907x1350px
>>62278697
Well that's better anon. Still bigger and uglier than JS/Python though. I'll forgive that you omitted the class/imports to make Java look less verbose.

But... can you beat this functional programming?!

import qualified Data.Map as Map
import Data.List

groupAnagrams strs = map sort $ Map.elems dict
where dict = Map.fromListWith (++) [(sort s, [s]) | s <- strs]
>>
>>62278806
Fuck ton better than /g/'s shitty programming "exercises"
>>
>>62278820
What is it that you guys are trying to achieve?
>>
>>62278813
Java 8 hasn't hit yet?
>>
>>62278813
You're just cheating because your runtime happens to have a group_by function. Which, might I add, python does as well. That's completely irrelevant to the language itself.

It's the same logic as the people amazed by twitter Mathematica programs that just call lots of pre-implemented code.
>>
>>62278752
>
        //C++ cucks can suck my fucking cock

Why did you bring that up?
>>
>>62278716
Sorry, I had to take shit.
Choose
[0,1,2,3,4]
for the second combobox.
Step it up, anon.
>>
>>62278845
Because he loves using GC
>>
>>62278860
dude GC lmao
Meanwhile no splitter in C++ library, maybe C++26 will fix this
>>
>>62278822
Why are you posting here if reddit is so good? Go back.
>>
File: ....jpg (18KB, 200x256px) Image search: [Google]
....jpg
18KB, 200x256px
>>62278752
I've returned to my mortal body to say thanks to this gentleman for using the superior systems language.
>>
>>62278887
THANK YOU, BASED ANDREI
>>
>>62278866
>Meanwhile no splitter in C++ library
fuckkkk, how will we deal?
idk, maybe google somebody that wrote one or make your own
>>
>>62278847
Thanks but too late, time ran out
>>
>>62278813
I've been programming in Java 8 for over a year now.
>>
>>62278903
nosplitter.webm
>>
File: t3_5qz1rc.png (108KB, 400x381px) Image search: [Google]
t3_5qz1rc.png
108KB, 400x381px
>>62278156
>mfw databases TA pronounces SQL as s-q-l and not sequel
>>
>>62278434
Does not.

var nigger = function(x){ return x>3 ? i*x : i*3 };

[1,2,3,4,5].forEach(function(i){
[10,20,30].forEach(function(j){
console.log(i,j,nigger(j));
});
});


This won't work. You can prepend it with var i, or let i, or whatever else, the i inside the function won't refer to the i the loop iterator.
>>
>>62278697
What does this do?
>>
desu, it is kind of strange that when I use C++ I essentially always have to include a header-only text manipulation file I wrote a while back

like, why doesn't <string> have split, or ToLower, or TrimWhitespace
you know, absolutely basic shit that you use all the time in every program that handles text
>>
>>62278945
Rust doesn't have this problem.


It just has other problems.
>>
>>62278909
Fuck. I need to stop eating taco bell, especially at night.
Anyway, I think you might've overthought that problem, anon. But even then, you should've brute-forced it.

>>62278926
dumb frogposter
>>
>>62278940
Looks like it's detecting anagrams in input.

["red","oops","der"]

will produce

{
"edr": ["red", "der"],
"oops": ["oops"]
}
>>
>>62278843
>core library is cheating
sure, let's go and implement sprintf every time we use it
def groupAnagrams(strs)
res = Hash.new{[]}
strs.each { |s| res[s.chars.sort.join] <<= s }
return res
end
>>
>>62278953
You have to do some of the most autistic gymnastics imaginable just to get buffer input in rust.unwrap().ok()
>>
>>62278840
I've had a shit day and was just trying to have fun I guess. Wasn't a point to it, sorry if it shitted up your day instead.

>>62278938
Sadly no, you didn't write equivalent code. Python has different scoping rules than JS but in this case the functional scoping does the same thing.

Your mistake was you added additional functions, which creates additional scopes. I don't blame you though, var scoping in JS is a clusterfuck and is poorly understood even by professional developers. Thank god they introduced let.

var nigger = function(x){ return x>3 ? i*x : i*3 };
for(var i in [1,2,3,4,5]) {
for(var j in [10,20,30]) {
console.log(i,j,nigger(j));
}
}
>>
>>62278940
same thing the function I replied to it does. Takes a list of strings and groups all the strings that are anagrams into lists, and returns all such lists.

["abc", "cba", "def", "bac"] => [["abc, "cba", "bac"], ["def"]]
>>
>>62278820
No, nothing can beat Haskell.
>>
File: 729.gif (134KB, 340x340px) Image search: [Google]
729.gif
134KB, 340x340px
Employed Haskell programmer here
>>
>>62278981
>>62279019
Except you didn't even do the same thing.
>returns a dictionary
>not sorted lists of anagrams
>>
>>62279055
wanna know how I know you're a dynamic dummy? you didnt even read the type signature
>>
>>62279017
No, no, no, anon, you're the dumbo here, your code is not equivalent.

In python, code right before the loop and code in loop are not in the same scope. In python you can't add print(i) right before the loop, and in my code you also can't add console.log(i) right before loops, so my code is equivalent to python; yours isn't - in yours outside and inside of loop are the same scope.

> I don't blame you though
Eat a bag of dicks. If you honestly didn't know you were in the wrong while you were typing your reply, there's no hope for you.
>>
File: Hash.png (19KB, 890x102px) Image search: [Google]
Hash.png
19KB, 890x102px
>>62279063
Tell me what the type signature is, then.
>>
>>62278156
I'm trying to wrap my head around SSA so I can use LLVM instead of my slow stack machine VM & bytecode. Then there's the matter of my type system, which operates directly on the syntax tree in the slowest way imaginable...
>>
>>62279055
>>62279063
now i don't know who to trust
this must be why people voted trump
return res.values
>>
>>62278820
That's so cute, Haskell; Here's how real men do it:

sub groupAnagrams(@){
push @{ ($dict{ join '',sort split // } ||= []) },$_ foreach @_; values %dict;
}
>>
File: sigil_cycle.png (16KB, 482x295px) Image search: [Google]
sigil_cycle.png
16KB, 482x295px
>>62279166
consult your mental health professional
>>
>>62279187
>m-muh punctuation
>>
File: 1504643678801.jpg (198KB, 1920x1080px) Image search: [Google]
1504643678801.jpg
198KB, 1920x1080px
Why can't we all be friends?
>>
>>62279098
>In python, code right before the loop and code in loop are not in the same scope.
You're fundamentally wrong about this. Python doesn't have block scope. I thought you already understood that, and that was the whole point of showing >>62278290.

Don't believe me? https://stackoverflow.com/q/3611760

>In python you can't add print(i) right before the loop, and in my code you also can't add console.log(i) right before loops
Wrong about the second one. Due to variable hoisting, i will be declared but set to undefined - it won't error. This is one of the scoping differences. You can literally try it:
console.log(i); for(var i;false;);
The code I wrote exposes the similarities between python and JS because once the variable is set, when the function is called later, hoisting behavior doesn't matter anymore.

>in yours outside and inside of loop are the same scope.
In both, outside and inside the loop are the same scope. That's how it works in both languages.
>>
File: 1406803019377.jpg (103KB, 1280x720px) Image search: [Google]
1406803019377.jpg
103KB, 1280x720px
>>62279203
Because my opinions > your opinions, and we'll never get along until you accept that.
>>
>>62279208
Putting print(i) before loops in that code snippet causes an error in python, and I did test it. Putting console.log(i) into my code also causes an error. In your code, it doesn't.
>>
File: 1464922259133.jpg (56KB, 601x600px) Image search: [Google]
1464922259133.jpg
56KB, 601x600px
can anyone help me out with a little java problem im having. i just started learning java and im trying to compile this program but i keep getting "class, interface, or enum expected"

heres what i wrote

public class MathTest
{
public static void main(String[] args)
{
int value = 3;
value = value - 2* value;
value++;
System.out.println(value);



}
}
>>
>>62279203
Being friends requires state and Haskell people just can't allow such a dangerous thing.
>>
File: 1497590831706.jpg (40KB, 1408x396px) Image search: [Google]
1497590831706.jpg
40KB, 1408x396px
>>62279219
>>
>>62279166
Fuck. You almost can't beat code golfing in perl.

>>62279224
I don't disagree with that, it was one of my points
>>
>>62279228
is this the entirety of your file? this compiles and runs
>>
>>62279245
Your point was that my code is not equivalent to python and that yours is. That's wrong, and is demonstrated by printing i before the loop - my and python snippets cause an error, behaving similarly, your code works, behaving differently from original python snippet.
>>
>>62279253
yes it is. im attempting to compile it and i keep getting the same error.
>>
>>62279272
>markdown


lol
>>
>>62279272
>>62279230
you forgot to read the CoC, friend. Reading the CoC should be the first thing any rust programmer does! Its located in the sticky!
>>
>>62279285
What line causes the error? Are you sure you're compiling the right file?
>>
>>62279166
>impure
>>
>>62278392
In rust:
fn group_anagrams(strs: Vec<String>) -> Vec<Vec<String>> {
use std::collections::*;

let mut map = HashMap::new();
for s in strs.iter() {
let key: String = {
let mut key: Vec<char> = s.chars().collect();
key.sort();
key.into_iter().collect()
};

let list = map.entry(key).or_insert(Vec::new());
(*list).push(s.to_string());
}

map.values()
.map(|x| {
let mut c = x.clone();
c.sort();
c
})
.collect()
}
>>
>>62279272
How do you fuck up twice?
>>
>>62279285
well, you either have something before it or after it because I can compile it just fine
https://repl.it/Kjoz/0
>>
>>62279299
idk what i did wrong. i just retyped everything in i posted here and it worked fine now im wondering if i declared the class wrong or something.
>>
>>62279305
Probably not the best way, but meh
>>
>>62279273
That's not the case, however - here's why:

This behavior in which i is read before the loop begins NEVER OCCURS in either snippet we wrote, which is why variable hoisting has no effect on the result of this program. The fact that variable hoisting has no effect on the result of this program, meaning python and JS's scoping is doing the exact same thing, is my central thesis.

Why is i not being read before the loop begins? Because it's read inside a function call which is only called inside the loop.
>>
>>62279305
Hideous.
>>
>>62279307
> Third times the charm
>>
>>62279320
To add to that, a version of the previous snippet that would behave "like" our programs is:

function logi() { console.log(i); }
for(var i=0; i<10; i++) logi();


Which I'm saying never demonstrates any scoping differences between JS or python.
>>
>>62279321
Yeah, well I'm rusty [spoiler]pun intended[/spoiler] so you're welcome to try pruning it.
>>
>>62279320
In python, i is not accessible before the loop. The mechanism that makes it available inside the lambda function is something completely different from the mechanism that makes i available in JS - in JS, i is accessible before the loop. It's not in any way similar to behavior demonstrated in python.
>>
>>62279349
>[spoiler]
You dumb motherfucker.
>>
>>62279353
Jesus dude, chill
>>
>>62279359
Post a loli and I'll look the other way.
>>
>>62279352
I understand that they're different - my point is that the difference is irrelevant here. All of the functional scope reasoning applies reusably between python and JS save for a few exceptions like variable hoisting.

Variable hoisting was *not* a feature of the program I showed you. There is no point at which a variable is evaluated to undefined due to variable hoisting. If variable hoisting was not a feature of JS, that JS program would still not error. Therefore, I gave you a demonstration of the same scoping features. I don't understand why this is difficult.
>>
File: here_you_go.jpg (27KB, 320x320px) Image search: [Google]
here_you_go.jpg
27KB, 320x320px
>>62279371
> Good enough
>>
>>62279418
I figured it on my own that python really does have shitty scoping, almost no different from JS.

niggr = lambda x: i*x if x > 3 else i*3

def test():
for i, j in enumerate([[1,2],[2,3],[3,4]]):
print(niggr(j))

test()


If we forcibly put lambda and the loop in different scopes, it does stop working.
What a mess. And, yes, you're right, it turns out lambda and loop iterator were in the same scope in python, even though the fact that loop iterator was unavailable when placed between those two seemed to suggest otherwise. I apologize for offering a bag of dicks to you.
>>
File: umaru happy ending - no sound.webm (511KB, 1280x720px) Image search: [Google]
umaru happy ending - no sound.webm
511KB, 1280x720px
>>62279420
webm

>>62279305
rust is not a pretty language
>>
If you know C++, does that mean you also know C?
>>
File: homo.png (148KB, 267x252px) Image search: [Google]
homo.png
148KB, 267x252px
>>62279420
I said I wanted a loli, not a disgusting rat.
>>
>>62279491
If you have to ask, then no. You would possibly know C to an extent that would allow you to write something, but not to read someone else's code or solve problems.
>>
>>62279491
Nobody knows C++.
>>
>>62279452
Hey man, apology accepted. I figured we would make it here eventually. I've been wrong on /g/ before too and had to come clean once I figured it out. It sucks but it's a learning experience. No worries.

>>62279495
lmao
>>
I am reading this https://github.com/firebase/quickstart-android
im still new to android app but where is the entry? in java its main(String[] args) but i dont see it anywhere??
>>
>>62279514
You were mistaken about what I got wrong though - it was python and not JS.
>>
>>62279519
Android apps don't have main(). Activities are entry points.
>>
>>62279166
Hey, I don't really know how to use perl but is that really working? I tried a guesswork approach to get something useful out of that function and it seems to group it into one array.
print Dumper(groupAnagrams(["cba","foo","oof","abc","bar"]))
$VAR1 = [
[
'cba',
'foo',
'oof',
'abc',
'bar'
]
];


>>62279521
Oh, no wonder. So I was poking at the wrong thing and we were just kind of butting heads at each other. Oops.
>>
>>62279491
I guess. There are analogues for most things. C sees more grouping into translation units because that's the granularity of encapsulation, so a C++ programmer would have to get used to that. More use of opaque data types. I actually am liking the transition, except for void *. I prefer templates to nothing.
>>
>>62279491
No.
>>
>>62279541
It accepts an array and not a reference to array.

use Data::Dumper;

sub groupAnagrams(@){
push @{ ($dict{ join '',sort split // } ||= []) },$_ foreach @_; values %dict;
}

print Dumper [groupAnagrams("cba","foo","oof","abc","bar")];
>>
>>62279565
And that produces
B:\>perl anagrams.pl
$VAR1 = [
[
'foo',
'oof'
],
[
'cba',
'abc'
],
[
'bar'
]
];

B:\>
>>
>>62279565
>It accepts an array and not a reference to array.
The fact that you need to explain this is exactly why dynamic typing is bad
>>
>>62279471
Yea, well I was trying to make it mostly the same syntax behavior as the JS version, it probably could be cut down 50%.
>>
>>62279574
It's explicitly specified in function prototype actually. Too bad for you.
>>
>>62279541
>>62279573
Oh, I see. I'm still a little lost on perl syntax at the moment, but I can see why it produces short code. How much longer would this be if you sorted the groups like the other programs?
>>
>>62279600
What should they be ordered by?
>>
>>62279534
which Activity? is it specified in the Gradle build somewhere?
>>
>>62279614
The way the original leetcode problem does it is the groups' elements are lexicographically sorted but appear in any order in the outer array.
>>
>>62279625
In the AndroidManifest.xml file as far as I know.

>>62279628
Putting map{[sort @$_]} before values should do the trick.

sub groupAnagrams(@){
push @{ ($dict{ join '',sort split // } ||= []) },$_ foreach @_; map{[sort @$_]} values %dict;
}
>>
In C how do I apply options returned by argv on all the argv that aren't an option?

Said argv can only be wrote after the options.

One way I figured is to make the program run two "for" conditions that will check first for all the regular string argv then apply on them all the options that are found on the second for cycle.

But it seems retarded...
>>
>>62279656
Wow, I truly can't follow perl syntax right now. But I get beat in code golf every time by perl so I should learn it.

Anyway, the best golf I can do of the Haskell program is
import qualified Data.Map as M
import Data.List
groupAnagrams z=map sort$M.elems$M.fromListWith(++)[(sort s,[s])|s<-z]


Don't think I can fix the imports...
>>
>>62279680
Slightly better using applicative:
groupAnagrams z=sort<$>M.elems$M.fromListWith(++)[(sort s,[s])|s<-z]
>>
>>62279680
perl is known for being write only
>>
>>62279707
Er, with a fix for precedence issues it turns out to be the same length:
groupAnagrams z=sort<$>(M.elems$M.fromListWith(++)[(sort s,[s])|s<-z])


>>62279722
I'd be willing to believe that in some cases, but it still has great terseness characteristics.
>>
>>62279722
I read perl just fine.
>>
>>62279665
>In C how do I apply options returned by argv on all the argv that aren't an option?
what
>>
>>62279680
>Wow, I truly can't follow perl syntax right now.

s --hello world-- print


Can you guess what this Perl program does and how it does that?
>>
How can I rewrite this Tower of Hanoi code to use (if) instead of (cond)?

(define (hanoi n origin target)
(cond ((= n 1)(display "Move a block from tower ")
(display origin)
(display " to tower ")
(display target)
(display ".\n"))
((> n 1)(hanoi (- n 1) origin (- 6 origin target))
(hanoi 1 origin target)
(hanoi (- n 1) (- 6 origin target) target))))
>>
>>62279769
Forget it I just fixed it.
>>
>>62279787
No clue at all. Apparently s is used for substitution in perl, but I can't find any examples without // in them, and this works with an arbitrary amount of words in between the "decrements", if that's what they are...
>>
>>62278156
What's with this image?
>>
>>62279795
is this a joke?
>>
>>62280024
it's /g/'s shittiest new meme. You see it in wdg a lot.
>>
>>62278945
i have a guess. solving a problem idiomatically with the kinds of string functions you find in many other standard libraries is generally convenient, but also potentially results in potentially unneeded copies, allocations, iterations, etc. compared to a solution tailored to your use case that operates in-loop/in-place/combines work where possible. and in the case of something like "split", libraries generally return a container of strings, but the STL avoids returning containers altogether, because that would make assumptions about how the user wants to store their data and whether or not they wanted to operate on data in- or out-of-place, and could get in the way if your use case could be better implemented using some other data structure (potentially your own), which is why (in general) it uses iterators for generalized iteration and takes function objects for user-defined operations on data. and while there isn't a "toLower" for strings, there is std::tolower for a single char, and strings implement iterators, so you can use the simplified "foreach" style for loop syntax and <algorithm> functions like for_each, transform, find(_if), copy(_if), replace(_if), etc with them, like this:

for (auto& c : s) c = std::tolower(c);
std::for_each(s.begin(), s.end(), [](auto& c) { c = std::tolower(c); });
std::transform(s1.begin(), s1.end(), s2.begin(), [](auto c) { return std::tolower(c); });


with the stuff in <algorithm>, <string>, and a small handful of other STL functions as building blocks, the stuff you'd want from other standard libraries' string implementations can be implemented very trivially (unless you want unicode support; then you're fucked, haha). but since the details of an ideal implementation still vary enough depending on use case, they leave it up to you
>>
Why use classes when you can just create a struct and write a bunch of functions to manipulate data in it?
>>
>>62280080
Why use a struct with a bunch of functions when you can just write a class?
>>
>>62280080
Because scoping.
Also virtual functions and inheritance if you care for that crap.
>>
Thoughts?

private static volatile Pattern separatorPattern;
private static volatile Pattern linePattern;
private static final String LINE_SEPARATOR_PATTERN =
"\r\n|[\n\r\u2028\u2029\u0085]";
private static final String LINE_PATTERN = ".*("+LINE_SEPARATOR_PATTERN+")|.+$";

private static Pattern separatorPattern() {
Pattern sp = separatorPattern;
if (sp == null)
separatorPattern = sp = Pattern.compile(LINE_SEPARATOR_PATTERN);
return sp;
}

private static Pattern linePattern() {
Pattern lp = linePattern;
if (lp == null)
linePattern = lp = Pattern.compile(LINE_PATTERN);
return lp;
}
>>
>>62279883
You can use almost any delimiter you like after s

s/a/b/;
s!a!b!;
s*a*b*;
s sasbs;
>>
>>62279722
I don't think perl is a well thought out language in a number of areas but I think the "write only" thing is kinda unfair. Every language is unreadable until you learn how to read it, lisp is just as incomprehensible to someone who's only worked in C family languages. People who work with perl on a daily basis usually don't have any issues reading perl in general. Yes there are crazy oneliners that are hard for even experienced perl programmers but the possibility for same kind of syntax wankery exists in almost every language, normal day-to-day perl has as much of an internal sense of style and readability as anything else.
>>
>>62280080
Classes are a convenient way to create a struct and write a bunch of functions to manipulate data in it.
>>
Here's how I would group content together that is related logically or functionally but not related together at all in the layout with MobX, assuming that the modal is somewhat global, meaning that it should be openable from anywhere on the site:


// MuhNavbar
function MuhNavbar({ uiStore: UiStore }) {
return (
<button onClick={uiStore.toggleMuhModal}>Click me</button>
)
}

// UiStore
class UiStore {
@observable isMuhModalVisible;

@action
toggleMuhModal() {
this.isMuhModalVisible = !this.isMuhModalVisible;
}
}

// MuhModal
function MuhModal({ className: string }) {
return (
<div className={`muh-modal ${className}`}>
qwsedrfvgbjnmk
</div>
)
}

// App (root component)
@observer
class App extends React.Component<{ rootStore: RootStore }> {
render() {
const uiStore = this.props.rootStore.uiStore;
return (
<div>
<MuhNavbar uiStore={uiStore} />
{/* show/hide modal using inline styles or css class or prop or whatever */}
<MuhModal className={uiStore.isMuhModalVisible ? "" : "hidden"}/>
</div>
)
}
}
>>
>>62280124
>class
dropped
>>
>>62280056
No, this is real Scheme code.
>>
>>62280080
data hiding, inheritance, static analysis, and programmer sanity all come to mind
>>
Why do we need constructors anyway?
>>
>>62280159
I meant the question. Do you not understand how either if or cond work?
>>
>>62280178
What sort of constructors?
>>
>>62280186
I know but it looks like you don't.
>>
>>62280172
>inheritance not destroying programmers sanity
dumb oop poster
>>
>>62280231
>I'm retarded
We knew.
>>
>>62280231
>inheritance destroying programmers sanity
found the brainlet
>>
>>62280192
Any sort. I don't see why you can't just use memberwise initialization and static functions.
>>
>>62278156
Why should I use python virtualenvs? They seem to make shit harder.
>>
Why is the Scanner class in Java like 2300 lines?
>>
>>62280246
Do you realize that someone might want to not expose members to the user of his class?
>>
>>62278156
Left pic should be typescript.
>>
>>62280266
Do you think it ought to be longer? Shorter? Why?
>>
>>62280267
Its impossible to directly initialize any object containing a private member.
>>
>>62280298
I don't see why you're replying with this to me.
>>
>>62280246
Constructors are shorter, way more convenient and gather all the control flow related to building your object in them.
>>
>>62280231
>not being smart enough to use inheritance properly
I think it's funny that "code pattern" shills championed inheritance for a decade until they figured out it's abusable and make it absolutely taboo like every other powerful programming construct.
>>
>>62280272
Shorter.
Because it's just a thing that reads your key inputs?
>>
>>62280306

If your object contains a non-public data member, you can't initialize like a fully public struct.
class Foo
{
private:
int x, y, z;
};
Foo foo = {1, 2, 3}; // can't access private members

So why do you need to have constructors instead of static functions like this?
Foo Foo::make(int x, int y, int z)
{
return {x, y, z};
}

Speaking theoretically.
>>
>>62280342
It reads structured data from a stream. Look at docs, there are tons of functions scanner has to implement.
>>
>>62280357
You can't use new with your make static function.
>>
>>62280357
Constructor is implemented as a static function. It's just used with a slightly different syntax, to make it clear to the person who's reading the code what this particular static function is supposed to do.
>>
>>62280372
Only because that's how sepples was designed to begin with. I'm asking why it would be necessary if you were making a new language.
Why shouldn't new take an arbitrary function and heap-allocate the result?
>>
>>62280414
How would you refer to the heap memory for the object within the function? Would it get passed in as an argument? That's basically just Python's syntax. Or if there's a keyword for it, then it's just "this"
>>
>>62278156
rewriting x265 because it doesn't support 75% of h265 features
>>
>>62280526
Let me see if I understand.
You have something like this.
Obj Obj::make(int, int, int);
Obj *obj = new Obj::make(x, y, z);

You're asking how the return value of Obj::make will be placed into the region of heap memory allocated by new rather than onto the stack (or a register or whatever your calling conventions specify)
>>
I need help anon, i'm coding a program in java that count the occurrence word by word in a .text file, it's working but the array words can't cumulate the words of the file instead any next line the previous words of the array are overwritten what can i do?

while(s.hasNextLine()){
line = s.nextLine();
words = line.split(" ");
}
>>
Stop calling it JavaScript
It's ECMAscript
>>
>>62280605
My browsers says it's Javascript.
>>
>>62280628
Windows also says GB means 2^30 B when in reality 2^30 B = 1 GiB
>>
>>62280605
no because it doesn't deserve that much respect from me
>>
>>62280639
Windows is also right in that regard. RAM manufacturers don't say GiB do they?
>>
>>62280639
>in reality
You mean according to that one bunch of people no one cares about. 1 gigabyte is 2^30 bytes.
>>
Why do you guys hate /wdg/ so much?
>>
>>62280671
uncreative people
>>
File: disgusted_in_japanese.png (298KB, 624x468px) Image search: [Google]
disgusted_in_japanese.png
298KB, 624x468px
>>62278926

>mfw someone pronounces SQL as "sequel".
>>
File: binary prefixes orgs.png (289KB, 1280x905px) Image search: [Google]
binary prefixes orgs.png
289KB, 1280x905px
>>62280669
>You mean according to that one bunch of people no one cares about.
Like NASA or the IEC.
>>
File: 1502344586073.jpg (37KB, 278x278px) Image search: [Google]
1502344586073.jpg
37KB, 278x278px
Is it faster to write in C++ than C?
>>
>>62280671
Worse than C++ coderz.
>>
List of programs that use proper SI prefixes,
either base-10 or base-2.
1 kB = 10^3 B
1 KiB = 2^10 B
1 KB = Kelvin Byte


>Parted, GParted
KiB, MiB, GiB

>macOS Finder
kB, MB, GB (base 10)

>pcmanfm
KiB, MiB, GiB

>Nautilus
kB, MB, GB (base 10)
>>
>>62280722
lol no. Sepples is, write slow and debug forever.
>>
Can some one explain why my loop wont work?(I know this is retarded have mercy I am still coming down)

I just wanted to add an elif so I could mess around with some stuff, but it will never match my input with my variable.

Does input() return a string or a variable?

 Alarm = input("When do you want to wake up: ")
print(Alarm)

while True:
if Alarm != now:
print('ZZZ til:' + Alarm)
# print('Current time is' + now + time.strftime('%S'))
print(now)
time.sleep(3)
now = time.strftime("%H%M")
continue
elif Alarm == "5":
saytheese.saythis(now)
print('test!!!!')

else:
vidopener.getnews()
saytheese.saythis("The time is " + now)
# use vidopener or just post whole code here?
break


Please help I am almost desperate enough for tits.
>>
>>62280719
You just clearly demonstrated that in reality there is no agreement on which units should be used.
>>
>>62280755
The vast majority of industry standards organizations recommend SI binary prefixes.
>>
>>62280737
It looks like "now" isn't set before the "if".
>Does input() return a string or a variable?
https://searx.me/?q=python%20Does%20input%28%29%20return%20a%20string%20or%20a%20variable%3F&categories=general
>>
>>62280763
And yet, historical prefixes still continue to be used. Doesn't that make you think? Doesn't that stimulate your neurons really, really hard?
>>
>>62280763
>tfw fell in 8.589 GB RAM meme
>>
>>62278348
It's mostly because GvR hates functional in all it's forms.

It's why, aside from just syntax, lambdas are gimped, even to the point of allowing only a single statement.
>>
>>62280598
>You're asking how the return value of Obj::make will be placed into the region of heap memory allocated by new rather than onto the stack
Pretty much. In a constructor you might write:

Obj::Obj(int x, int y, int z)  {
this->x = x + 4;
this->y = y;
}


that is the memory for a newly constructed object has been allocated at the point the constructor starts executing. That's what the `this` pointer points to. You can't wait for the constructor to complete before allocating that memory because it may rely on it.
>>
>>62280920
You make a good point. I suppose I hadn't considered the hidden this parameter of constructor functions.
>>
>>62280671
It feels good to think you're better than someone else.
>>
>>62280737
Anon you might want to check out:
https://docs.python.org/2/library/sched.html

use the standard library to handle time events
as an example:
import sched, time

def print_hello():
print("Hello anon")


s = sched.scheduler(time.time, time.sleep)

alarm = input("how many seconds:")
print (alarm)
s.enter(int(alarm),1,print_hello,())
s.run()
>>
>>62278813
>>62278981

Great job!

I always get those replies when I paste Ruby here:
>meh, you're cheating!
>meh, it's not the same because your langauge isn't anal retentive about types like Haskell

There are people that get indeed mad when you use anything above assembly. Just ignore them and let them use the worng tools for the job. They can't deal with that power level.
>>
>>62280734
But you have strings in C++.
Isn't that alone fact make development faster because you can write this
str3 = str1 + str2;

instead of this?
str3 = (char*)malloc(strlen(str1)+strlen(str2)+1);
strcpy(str3, str1);
strcat(str3, str2);
>>
>>62280604
make words an ArrayList<String> and replace `words = line.split(" ");` with `words.addAll(line.split(" "));`

Also you should have been able to figure this out with google.
>>
>>62281003
>not just using library or implementing your own strings for C
dumb sepples poster
>>
>>62281003
Use sprintf
>>
>>62281003
Templates make compilation slow. Especially in large projects, it's not uncommon to have build times over an hour. It took half a day for me to build all of ITK from source on a 2015 top of the line MBP.
>>
>>62281034
>implement your own *
Sepples already did that, so now I can br productive instead of writing boilerplate.
And I still can if I want/have to.
>>
>>62281045
>sprintf
>not snprintf
>>
>>62281056
hue hue hue br br br
>>
>>62281045
>>62281188
Yet you have to allocate the memory.
>>
>>62281260
have the buffer in stack you dumbo
>>
>>62281277
...I have to implement stackas well?
>>
>>62280722
C++, but probably only when given the generous assumptions that you know what you're doing and that you're using modern language features where applicable. i have a linear algebra library with a small fraction of the LOC that an equivalent C implementation would require, with no macros, minimized use of explicit template syntax (thanks to generic lambdas and class template argument deduction), and it's at least as fast as a C implementation - realistically faster because of extremely aggressive constant folding and inlining aided by constexpr, which can eliminate series of matrix multiplications in normal use cases, allow for guaranteed computation of valid complex sets of multilevel transformations at compile time, etc. definitely faster to write than a C implementation even if only because it eliminates redundancy

>>62280734
>write slow
if a C implementation is faster to write, it's almost certainly because it is simply less functional. there are things C++ can do which C can only emulate with either redundant code, or serious abuse of macros (which is essentially the same thing)
>debug forever
i'll take an ugly templated type error over a segfault any day. some information is better than no information, and compile-time errors are better than runtime errors

>>62281050
templates don't make compilation slow in and of themselves, the "virtual code" (aka "functionality") they add does. if you wrote actually equivalent C code (as in a shitload of specialized struct/function variations), you'd see the same effect. you just don't see this in practice because it would be intractable. and a void pointer approach is not equivalent. templates migrate data and computations to the type system and compile time, respectively, which a void pointer approach does not do. C is seen as having faster compilation times because C projects are almost universally much smaller-scale and overall less robust/functional/scalable
>>
>>62281331
>but probably only when given the generous assumptions that you know what you're doing and that you're using modern language features
K ur dum
>>
>>62281003
>
str3 = (char*)malloc(strlen(str1)+strlen(str2)+1);
strcpy(str3, str1);
strcat(str3, str2);

jesus
>>
>>62281449
Explain, please?
>>
>>62281475
what?
>>
>>62281449
This is why C is not for general use
>>
>>62281479
>Jesus
>>
>>62281449
This is what happens when you don't have a string type. You only get a char*, which can be any of
>a zero terminated sequence of chars
>an array of chars
>a single char
>an old school generic pointer
>any of the above and also NULL
Cfags will defend this.
>>
>>62281502
It's just an expression to suggest exclamation.
>>
>>62281506
Don't pretend C++ is any better
>>
>>62281522
sepples fags think std::string and std::string_view fixes all of these problems
>>
>>62278291
W3schools isn't associated with the w3 consortium

W3schools tutorials are outdated, show bad webdev practice(s) or in some cases are just straight up wrong.

Mozilla has tutorials that actually meet proper standards. Use their stuff instead
>>
>>62281449
>>62281003
Please don't cast malloc it's bad form.
>>
https://alexpolt.github.io/type-loophole.html
>>
>>62281522
You're right, you can't build on a broken foundation.
>>
>>62281557
I do as I please.
>>
>>62281557
Why?
>>
>>62281522
>Don't pretend C++ is any better
>nullptr
>std::string
lel
>>
>>62281600
nullptr is better than NULL, but that doesn't solve the problem that pointer types are inherently nullable.
>>
File: 1501587574571.png (56KB, 1200x1200px) Image search: [Google]
1501587574571.png
56KB, 1200x1200px
>Create a nice language that has all the ergonomics like lazy ranges, iterators, UFCS, macros, modules, generics and everything, all without GC overhead
>Damn, at this rate we'll erase C++ from the history in a decade, let's make it harder for us
>Obliterate user friendliness with the autistic pointless ritual of the so called safety
>unwrap().unwrap().ok().unwrap()
>Bufread, BufReader, Read, io xddddddd
>>
got an interview today with [meme san fran startup] /dpt/, wish me luck

10am to 3pm and no lunch. not even a lunch break. the fuck?
>>
File: Snapchat-286424151.jpg (220KB, 720x1280px) Image search: [Google]
Snapchat-286424151.jpg
220KB, 720x1280px
Who else uses turbo c++ as their ide here? I feel like I'm completely retarde for using this but so far it's the mosy perfect, unbloated IDE i have ever used and it support Ansi C just fine. Also coding with old white kb and crt is comfy as fr*k
>>
>>62281658
oh my, you're even using the best mouse
>>
>>62281646
You're doing it wrong. Use the ? operator.
>>
>>62281658
>Snapchat
KYS you LARPing faggot
>>
>>62281663
lucky me I had it since I'm like 6, heard of the /g/ meme afterwards.
>>
>>62281675
Convert this to rust, in the least possible lines
vector<int> v;
int n;
while (cin >> n) {
v += n;
}
>>
>>62281678
:(
>>
File: 1502357646102.jpg (177KB, 709x821px) Image search: [Google]
1502357646102.jpg
177KB, 709x821px
Will rusties ever learn?
>>
>>62281718
You are not funny
>>
>>62281380
am i wrong? if you don't know what you're doing you're probably gonna spend a lot of time mutating vague google queries for stackoverflow questions, and if you're not aware of some of the newer language features you're gonna end up doing unnecessary work when it comes to things which have been streamlined or made redundant

>>62281003
>>62281056
i'm on your side here in terms of C vs. C++ in general, but honestly strings really aren't a great example of something C++ holds over C. the STL in general is... pretty lean in terms of standard libraries (*too* lean to some, though generally i find its design reasoning to be fairly legitimate). but std::string is kind of on another level. in fact it's probably safe to say it stands apart as the most lacking thing in the STL. it really doesn't add much to cstrings. it's got essentially no unicode support whatsoever, little in the way of utility functions, and realistically a lot of C++ string code ends up just using some combination of C stdlib string functions, at least when the project doesn't cook up its own string type, which basically any project above a certain scale and/or which needs remotely robust string functionality does. the real selling point for C++ is the language-level features, and secondarily some parts of the STL... other than std::string
>>
Hi guys I'm starting to learn C and I need an IDE, I run Linux
>>
>>62281786
No you don't. If you're starting to learn you can use a text editor.
>>
>>62281786
Lewnicks is ur IDE lol!!
Language?
I use CodeLite for C++, VS Chode (or Atom) for everything else..using terminal changes everything.
>>
>>62281786
So if you are starting to learn please start with a simple text editor like VS Code, Sublime Text or Atom. At the end of the day you need to learn to use a compiler and CMake anyway
>>
>>62281786

No, you learn to use MAKE.
>>
>>62281805
What if I want to compile my code ?
>download a compiler
Can't I directly download an IDE then ?
>>
>>62281786
This >>62281828
For IDE there is Clion, Qtcreator, Netbeans and Eclipse
>>
>>62281822
>language
I am literally high. I stand by what I said.
>>
>>62281841
>What if I want to compile my code ?
cc main.c && ./a.out
>download a compiler
#apt install clang
>>
>>62281841
You probably already have gcc installed. Just call gcc or clang directly until you can't, then learn make. It's important that you understand the compile and link model, an IDE will just be confusing obscuring magic otherwise.
>>
Well thanks for the advice guys I'll install Atom and get going
>>
>>62281891
install required tool for integrated terminal, clang-completion, clang-lint and clang-format
>>
>>62281720
Yes I am.
>>
>>62278184
Yes, a lot of universities are moving a way from it, as it requires a lot of knowledge to fully understand a "hello, world" program. For example, you need to know what a class is, what packages are, what the static keyword does, etc...

Alternatively, the university will hand wave them away leaving students confused...
>>
Languages like C/C++ actively force you to use and IDE
>>
>>62281539
as a sepples fag, i'm pretty sure most sepples fags aren't even aware of std::string_view. i applaud you for doing your homework before talking shit. i've come across some excellent use cases for it, but i won't deny that it and especially std::string remain largely incomplete

>>62281615
you know what does solve that problem? writing a non-nullable pointer type, which you can definitely do. nullptr is of the type std::nullptr_t (actually it's sort of the other way around; std::nullptr_t is an alias of "decltype(nullptr)"), which is quite intentionally a unique type, so you can handle for the case in the type system with template specialization/overload resolution
>>
>>62281968
Well maybe not a whole IDE. But something that at least allows you to follow a definition and declaration of symbols.
>>
>>62281968
Well you guys are confusing me, I'll start with a simple text editor and see for myself then, if it's too much hassle compiling everything myself I'll download code::blocks
>>
>>62282010
Once you start having multiple source files and have to maintain stupid header files you will need an IDE. C/C++ is so outdated that they need IDEs to help the developers.

Clang is working on a language server and god knows if it is actually possible to have a working LS for C++
>>
>>62282027
How do I debug ?
>>
>>62282042
lldb a.out
>>
>>62281759
Your premise is retarded
How can c++ ever be slower than c if you can just write c in c++ and use new features only when it's faster to do so?
>>
>>62282027
>C/C++
>/
Ok kid.
>>
>>62282053
restrict pointers
>>
>>62281720
But he's right.
>>
I'm so happy clang is a thing. Freetards have held back the C++ community for so god damn long with their restrictive licensing and poor compiler model (constant propagation during parsing as an example).

I'm starting to think people like RMS are actually just vain. Between the GNU/ debacle and the restrictions on GCC its difficult to see malign reasons.
>>
>>62281968
>like C
No not really. I won't deny they're helpful but C certainly doesn't have enough depth of issues to require one.
>>
>>62282195
RMS was concerned about closed tools being able to leverage individual portions of gcc.
>>
>>62279305
>taking a vec of strings
how about an iterator of borrowed strings?
>using stable sort
unstable sort is faster
>not just using the vector of chars as key
>inserting a copy of the string into the map instead of a reference
>cloning the vectors
3/10
at least you made an effort. here is how a pro does it:
fn group_anagrams<'a, I>(strs: I) -> Vec<Vec<&'a str>> where I: IntoIterator<Item=&'a str> {
let mut map = HashMap::new();

for s in strs {
let mut key: Vec<_> = s.chars().collect();
key.sort_unstable();
map.entry(key).or_insert_with(|| Vec::new()).push(s);
}

map.into_iter().map(|(_, mut v)| { v.sort_unstable(); v }).collect()
}
>>
>>62281948
>Yes, a lot of universities are moving a way from it, as it requires a lot of knowledge to fully understand a "hello, world" program.
They would usually teach Java as a second language after an imperative language like C. I would go so far as to say any place that doesn't is pretty fucking worthless.

Python is like NeoPascal. It technically supports every paradigm they want to teach in an undergrad CS course, so less wasted time teaching new languages. Never mind it supports some of them poorly.
>>
>>62282221
Yes. That's the problem. I'll intent. He wishes to divide efforts and duplicate work.
If it's for the stated supposed moral goal how do you justify the piece of shit that is the gcc code base?
It's hurting developers more than proprietary software because people think there's an open source alternatives but anyone with good intent towards helping fellow developers would think of GCC as the natural starting point and immediately be crushed by the unworkable nature of it.

Even a seemingly simple task like parsing C++ (which is not simple, but someone might think a parser is a simple thing) is just a nightmare. If you're trying to force people into your copyleft ideals you should make it easy to work with.
What seems to have happened (imo) is that the vanity took over the moral intentions and preventing others from significant contribution took priority. It's not like other open source projects at all. It's a theme with GNU.

How else would clang, a very young project relatively, be so so much better than the big primary platform for C++ for many years in that regard?
It doesn't make sense to me how you'd end up there with good intent. I suppose the road to hell is paved with good intentions but they're hurting more than just proprietary software with their designs.
>>
>>62281699
literally one function: https://doc.rust-lang.org/std/io/trait.Read.html#method.read_to_end
>>
Can JAI save us?
>>
>>62282402
no. the other three letter meme language is better
>>
File: faggot.png (840KB, 1058x690px) Image search: [Google]
faggot.png
840KB, 1058x690px
>>62282373
>>
>>62282373
Mr. Klabnick I just want to say your presentation on OOP philosophy was shit and you should be ashamed of yourself.
>>
>>62282420
>no argument

>>62282432
it is klabnik. no ck. just k. also kys
>>
>>62282407
APL?
>>
>>62282289
Are you the real klabnik?
>>
>>62282442
yes my child
>>
>>62282455
Prove it.
>>
>>62282472
stop responding to a namefag.
>>
>>62282455
Don't you have better things to do, like bullying some girl for writing coreutils in js?
>>
>>62282297
>Python is like NeoPascal
I thought it's like NeoBasic
>>
>>62282373
wtf are you the real deal?
You do realize you've thrown &mut self into null, right?
>>
>>62282505
yes i am the real deal.
>you've thrown &mut self into null
what? rust has no null
>>
>>62282373
That doesn't read line by line, it collects the entire String at once

Also, stop pretending to be steve
>>
>>62282540
literally one function: https://doc.rust-lang.org/std/io/trait.BufRead.html#method.lines
>>
>>62281615
>>62281987
oh and i guess maybe i should mention, in case it wasn't clear, that the benefit of this is that you can write a non-nullable pointer type which never actually tests the contained pointer (or pointer being copy/move constructed/assigned from depending on the semantics of your implementation) for null/zero at runtime (in other words, a zero-overhead implementation is possible)

>>62282053
the context of the discussion was regarding which of C and C++ is faster to *write* in. as for your question, though:
strict aliasing rules and the lack of a restrict pointer designation in C++ is one potential way. and while C++ does offer some abstractions which are truly zero-overhead in practice, there are other cases where whether or not a feature is faster depends on tricky factors. for example, templates (especially those which perform constexpr computations on template parameters) can migrate some data/computations to the type system/compile time in a way that can not be emulated in C except (theoretically) by extreme (and realistically intractable) abuse of macros, resulting in leaner assembly for instantiations of such functions than any realistic C analogue. however, if enough function template instantiations fail to inline, the increase in binary size can result in poorer cache locality, potentially even to the point that the binary is outperformed by an analogous C binary which uses boilerplated/macro'd function variations or a void pointer-based approach. so you could see legitimately lighter function assembly for the function instantiations in your C++ binary (one could say they are "locally" faster), but still see overall worse performance. this is avoidable, but my point is that it's definitely not always as simple as it seems
>>
God I feel stupid...
I spent almost 3 days reading through my code trying to figure out why it didn't work and it came down to a syntax error.
What compiler warning can I add, so it will catch this the next time I fuck up?
void should_warn_func(int var)
{
var = 3;
}
void what_func_should_be(int &var)
{
var = 3;
}
>>
>>62282579
this wouldn't have happened with rust
>>
New thread:

>>62282576
>>62282576
>>62282576
>>
>>62282556
I know you aren't the real steve but is there any chance to have the text_io crate included in the standard rust?
>>
>>62282600
write an rfc
>>
>>62282608
I'll think about it actually, firstly I will improve on the text_io to include some common function macros

Then again, I don't think people will accept my RFC. They would have done it ages ago.
>>
>>62282591
I am not switching language.
Does anyone know what this is called so I can find it in the documentation?
>>
>>62282652
It's called being a dumdum
>>
>>62282558
>the context of the discussion was regarding which of C and C++ is faster to *write* in.
yes
your premise is retarded
How can c++ ever be slower than c if you can just write c in c++ and use new features only when it's faster to do so?
>>
>>62283419
Because, like >>62282558 said, C++ is missing certain C features like restrict pointers. Others like VLAs are also not ISO C++ but commonly offered as compiler extensions
Thread posts: 321
Thread images: 28


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.