[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: 318
Thread images: 22

File: 1482341897934.png (389KB, 934x1000px) Image search: [Google]
1482341897934.png
389KB, 934x1000px
What are you working on, /g/?

Old thread: >>58491695
>>
>>58496579
First for Pascal.
>>
Second for Rust is SJW cancer.
>>
Third for Python
>>
Fourth for Forth.
>>
5th for python3
>>
6th for regular expressions
>>
>>58496616
where did the sjws touch you?
>>
File: 2017-01-15-13:44:17.png (117KB, 1034x619px) Image search: [Google]
2017-01-15-13:44:17.png
117KB, 1034x619px
>>58496548

Which URL should I make the POST request on? Here's how the form looks like.
Sorry if this is a stupid question. I had no issues with this the last time and I'm pretty sure I'm doing everything exactly the way I did it before.
>>
is lisp the most redpilled language?
>>
>>58496660
formlocationurl.something
>>
>>58496649
>>>/r/ebbit
>>
~ $ python
Python 3.6.0 (default, Dec 24 2016, 08:03:08)
[GCC 6.2.1 20160830] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import braces
File "<stdin>", line 1
SyntaxError: not a chance
>>
>>58496689
nice argument
>>
>>58496660
click it yourself and go to the Net tab in your browser's inspector to see what request was made

this way you can see what exact url and parameters were used
>>
>>58496521

I can't figure it out, help.
>>
>>58496736
for(int i = 0; i < 1000; i++)
{
if(Math.Sqrt(i) % 1 == 0)
{
Console.WriteLine(i);
}
}


I hate spoonfeeding plebs but I really want you to stop posting.
>>
>>58496775
>>58496736
LINQ flavour if you really want to show off to your teacher/professor/mother

Enumerable.Range(0, 1000)
.Where(x => Math.Sqrt(x) % 1 == 0)
.ToList()
.ForEach(Console.WriteLine);
>>
>>58496775

Thanks ^-^
>>
i added a spinning icon to indicate the audio stream is being loaded

i'm thinking about integrating torrenting into this thing, so people can stream directly from torrents like popcorn time

would that send riaa assassin's after me?
>>
is linq like activerecord
>>
Would /g/ be interested in a prisoners dilemma competition?

We create a thread, anon's implement the solution, send the code to OP, OP runs it against each other and posts results in the thread.
The code would literally be a function that returns a boolean value so even if you don't know much programming, you could still participate.
>>
>>58496822
No.
>>
>>58496841
hows it different
>>
>>58496836
what exactly are you trying to do
>>
>>58496850
LINQ is just a convenient way of enumerating (and performing operations on) collections, where as ActiveRecord is a pattern which stores stuff in databases whilst you're working with in-memory objects to make persistence simpler (or some shit like that).
>>
>>58496888
i meant ActiveRecord the Rails ORM tho which has a similar chaining API, nvm
>>
>>58496821
Looks pretty good!
Kinda annoying that the loading icon is not centered in the square.
>>
>>58496821
search "macintosh plus"
rename it something else
>>
>>58496903
Yeah, I'm working on some css magic to fix it
>>
>>58496836
Sure, could be fun,i wrote some programs for that.
What language would it be in though?
Or would you use some cross-language interface
inb4 20000 tit-for-tats.
>>
>>58496895
That's what ActiveRecord does in Rails, it just stores stuff in DB's.

If you're going off the basis of the chaining, LINQ is more like SQL.
>>
>>58496878
A /g/ competition. People submit code, OP gathers the submittions and pits them against eachother, and than posts results which submission was the best.

The prisoners dilemma is as follows:
You and your friend have been accused of a crime. You get interrogated. You can either stay silent or betray your friend.
If you both betray eachother, you each get 2 years in prison.
If one of you betrays the other, and the other is silent, the betrayed gets 3 years, and the betrayer gets 0.
If you both stay silent, you each get 1 year.

You repeat this a thousand times against the same person, and see which submission racks up the least amount of years.

>>58496923
Most people don't even know what prisoners dilemma is so i don't expect everybody to just go for tit-for-tat.
Besides, if it gets a lot of interest, there's always more complicated problems.
As for the language, the easiest would be java. You provide an interface people have to implement with a single-class and no dependencies.
>>
>>58496954
So I get to run untrusted code on OP's computer? Count me in!

But there's a way to always win at that game that involves debugging your parent to check what the other program returned.
>>
>>58496993
Obviously there'd be rules like no network/disk io, no reflection, no dependencies.
And OP would get the actual source code to manually check.
>>
>>58496954
Also do we get info on the previous move? As in the peace war game? https://en.wikipedia.org/wiki/Peace_war_game
Or more broadly, what would be the input and the scope of the program that you ask the players to write?
>>
>>58497035
That's no fun.
There's not a whole lot of different solutions to the prisoner's dilemma if you don't allow people to play "creatively"
>>
>>58496850
>>58496895

LINQ is for interacting with data structures. ActiveRecord is for interacting with databases.
LINQ is a language feature. ActiveRecord is a library.
LINQ is the best tool for its job within the languages it is supported in. ActiveRecord is inferior to the Sequel gem.

Most of LINQ's features on Ruby would be equivalent to a subset of the methods available on the Array class.
>>
>>58497035
import random

def only_way_to_play():
return random.choice([True, False])
>>
File: 1481548521858.jpg (71KB, 720x602px) Image search: [Google]
1481548521858.jpg
71KB, 720x602px
A snake game I just finished in Java runs smoothly on windows 7 but on ubuntu it's very laggy and sometimes it just shows the top left corner of the window and nothing else. Wtf is going on?
>>
>>58496954

Simulating the prisoner's dilemma is pointless. The nature of the problem is that no matter what, betraying is always better for you regardless of the other person's choice.
>>
>>58496616
What's wrong with stealing what they built and use it for yourself?
>>
>>58497122
This is why we can't have nice things.jpg

There's literally nothing wrong with Rust
>>
>>58497049
Yes you can store all the previous moves. You get to play thousands of moves against the same player, so its about predicting what the player will do based on previous moves.

>>58497059
It's the most simple 'AI' competition possible. It's a start, and it still can be fun seeing where your submission ranks.

>>58497063
That would be a valid submission yeah. Though i'm not sure it would be rank high against other more clever solutions.
>>
>>58497132
>It's the most simple 'AI' competition possible. It's a start, and it still can be fun seeing where your submission ranks.
No, it can not possibly be fun. It's a waste of time for everyone involved and comparing that to an AI is an insult to machine learning.
>>
>>58497117
Not always no. If you betray all the time, you gain all those years because other smarter submissions would figure you out and betray you every time. And than when the smarter bots ran against more passive bots, they would gain less years overall than your bot.
>>
>>58497146
Which is why 'AI' was in quotation marks.
>>
>>58497168
"fun"
>>
>>58497117
Untrue in the described scenario (repeated trials)
>>
If you want prisoner's dilemma, just go play Zero escape virtue's last resort.
>>
>>58497206
It's about writing a bot that plays it for you, not playing it yourself.
>>
>>58497264
But a bit is boring. The thing about the prisoner's dilemma is the human judgment and decision taking. A bit will follow rules for it's decisions so it stops being a dilemma.
>>
>>58497410
s/bit/bot/g

Damn phone
>>
>>58497169
>>58497410
>>58497428
Fine. You want more 'fun'?

You can modify the game so instead of fixed 0 (if you betray and he stays silent), 1 (if you both stay silent), 3 (if you get betrayed) years, the years you get are random each time, so you have to keep that in account when making your decision.
>>
>>58497506
So there is no viable strategy since you can't predict the outcome
>>
>>58497506
So the only option is betray because I might get 0 years, otherwise if you pick a truly random integer I'll get a stupidly huge number of years in prison.
>>
>>58497512
No, each iteration you would know all possible outcomes. The only difference would be, it would be random every time.
So you know how many years you get if you get betrayed, you know how many years you get if you betray the opponent, and you know how many years you get if you both stay silent. Three variables that change every time, and you get all three as input.

>>58497522
Obviously there'd be bounds for the years. And who says the years have to be integers? It can be a float.
>>
There would also probably be anons who would compete to maximize their years instead of minimize them.
There's all kinds of stuff you can do.
>>
>>58497543
>Obviously there'd be bounds for the years.
That's still not an interesting game, now you're just introducing noise in the process but that doesn't change the usual strategy.

>And who says the years have to be integers? It can be a float.
That doesn't change anything. You can also measure it in milliseconds instead of years, but who the fuck cares?
>>
>>58497558
Then what would be an interesting game? Something that involves probabilities? Incomplete information? Impossibly deep state trees?
>>
>>58497567
Rules that are a teeny tiny bit more complex than the 60 years old begginer's introduction to game theory.
>>
>>58497599
You have to start somewhere anon.
>>
>>58497599
How about Ruby's sex collaboration game?
>>
>>58497611
>Stop trying to do interesting things!
>Why don't you go do some coloring books instead of reading that Feynmann guy?
If you don't challenge yourself, you'll never get further than "starting somewhere".
>>
>>58497567
>Then what would be an interesting game?
A game where you can get information about the competitor's program so you can outsmart them.
>>
File: screenie.png (558KB, 1440x900px) Image search: [Google]
screenie.png
558KB, 1440x900px
Can I hang with you guys?
>>
File: AZpCKCa.jpg (87KB, 600x744px) Image search: [Google]
AZpCKCa.jpg
87KB, 600x744px
>>58497924
>lazarus
yes my new friend
>>
>>58497924
Not unless that whole environment is written in LISP.
>>
>>58497924
Everything about this image looks disgusting
>>
>>58497943
Anthony Hopkins
>>
Is it permissible to interpret the ncurses window just as a field of rows and lines and just use it a an array of rows? At least temporarily? Like, if I wanted to draw a rectangle
draw_rectangle(corner_h, corner_v, height, width) {
for(i = corner_v; i < height; i++) {
for(j = corner_h; j < width; j++) {
if (i == (corner_v || corner_v+height - 1) || j == (corner_h || corner_h+width-1))
put_character('#', window_cursor[i][j]);
}
}
}

Sorry for the pseudocode, but I hope the idea is understood.
>>
I wanna make a programing language of some sort, I think it could be fun. Not a general purpose one, just a small DSL of some kind. But I can't think of anything I could use a DSL for, any ideas?
>>
>>58498005
write a virtual OS in Haskell
>>
>>58498005
Filesystem management.
>>
>>58497103
It's the "Write once, run everywhere" part of Java.
>>
>>58498031
Interesting. What would it look like? I guess it would have to be interactive, because you generally only wanna make a set of changes to a given file structure once. For example, the program "move every file from here to some other folder" only makes sense to execute once. So it would be more of a REPL than a compile and run kind of thing.
>>
>>58497924
>>58497970

Jesus how the hell do you work in that cluttered mess
>>
>>58498096
It would look like bash.
>>
Stop using dynamically typed languages

Just stop

You don't see builders trying to drill holes with hammers
>>
>>58497924
I just puked a little in a mouth, and then couldn't stop from throwing up entirely
>>
>>58498146
>muh tools
general purpose languages are NOT specialised tools
>>
Who here /golang/
>>
>>58498146
Actually, unless you say 'using dynamic languages to do X', that's not a great metaphor.
Unless you name a specific task, the last line is more like 'You don't see builders trying to use hammers'.
>>
>>58498181
See >>58498148
>>
>>58498181
Nobody, not even you
>>
Anyone know ClojureScript?

I need to make a piece of code to get the average age of everyone over 50 from a vector of ages. I know how to filter but how the fuck do I average the results?

This is what I have so far.

(defn gt50? [n] (> n 50))
(filter gt50? [55 20 75])


Returns
[55 75]
>>
>>58498214
golang is great for getting shit done, it doesn't have any of the abstract wankery that other languages do, and static typing allows it to have good performance, and concurrency is very easy in it, literally one function is all you need
>>
>>58498242
>ClojureScript

why
>>
>>58498243
race conditions and no generics
>>
>>58498197
You don't see builders using dildos
>>
>>58498250
you don't need generics

every language has race conditions, they're a fundamental problem of concurrency
>>
>>58498261
But what about the homosexuals? Dildos aren't just for women, Anon.
>>
>>58498280
Homosexuality is wrong
>>
>>58498248
Why not? I wanted to learn a Lisp and ClojureScript allows me to do webshit.
>>
>>58498275
rust solves race conditions in threads
>>
>>58498291
But what about the women? Dildos aren't just for homosexuals, Anon.
>>
>>58498181
It's the best language in its field. It's still shit though.
>>
>>58498294
Nope, it simply tries to paper over the problem, but it's impossible to solve it at the language level for all cases.
>>
>>58498316
>It's still shit though.
This.
>>
>>58498294
Rust solves data races, not race conditions. They're different things.
>>
>>58498243
I really want to like go, but I always find it a bit lacking. I don't know if just more libraries will be enough, or if it's missing something more fundamental.

>>58498303
>women
>builders
>>
>>58498243
Golang is a language targeted at the lowest common denominator, it's literally designed for idiots.

And one funny thing is that the go designers are very proud of their garbage collector which is optimized for very small pauses, that looks great on the marketing but the tradeoff is that the GC has to do more smaller pauses and ends up with much worse throughput than the competition.
>>
>>58498303
Dildos are wrong
>>
>>58498280
You don't see builders using dildos for their work, I mean
>>
>>58498325
Building isn't just for men, Anon.
>>
>>58498338
>>58498341
But what about sexual gratification for the involuntarily abstinent, Anons? It's not just for NEETs.
>>
>>58498291
Sexuality is wrong
>>
if you have a compiled language you KNOW where things go out of scope

garbage collection in compiled languages is stupid
>>
>>58498343
Yes it is
>>
>>58498365
But what about all those masculine lesbian builders, Anon?
>>
>>58498364
Not if they're heap allocated stupid nigger.
>>
>>58498357
Sure, but we're talking about the idea of builders using dildos as part of their job (building things), which doesn't happen
>>
>>58498361
No it isn't

>>58498371
Trannies aren't women

>>58498364
wrong
>>
>>58498375
you dense rorke, if there's no names that point to the object you can dealloc it
>>
>>58498371
They don't exist outside anime, anon
>>
>>58498384
You mean by doing a mark and sweep?
>>
>>58498384
Reference counting is garbage collection.
>>
>>58498377
But builders should be allowed to use dildos at work like everyone else, Anon.

>>58498380
But what about all those masculine lesbian builders, Anon?

>>58498389
I don't know about anime, but they definitely exist in real life.
>>
>>58498400
>>58498401
rust has Boxes, Vecs and Strings on the heap and still doesn't need GC hack.
>>
OK, so I learned Haskell
Where can I collect my full-time job?
>>
>>58498416
Are you in an adult anime, anon?
>>
>>58498422
In your mom's basement
>>
>>58498422
>i learned haskell
prove it
>>
>>58498426
I'm on 4chan right now, if that counts.
>>
>>58498422
>Haskell jobs
You got meme'd
>>
>>58498422
Oh great, you can help out with our transition to Java 8 (remember, our company coding guidelines state no lambdas), we also have some old Python 2 code that we'd like you to migrate to Python 3.
>>
File: 1482236145668.png (307KB, 500x500px) Image search: [Google]
1482236145668.png
307KB, 500x500px
"Blogosphere diversity is the optimal metric for making high-success-potential programming language decisions.”

Is this true?
>>
>>58498448
I don't even know what "blogosphere diversity" is, but I suspect the answer is no.

Where did you find such garbage, anon?
>>
>>58498420
You still need reference counting in Rust if you want to share heap allocated memory.
>>
>>58498448
No, it isn't true.
>>
>GC apologists get BTFO by Rust
>silence
hmm
>>58498460
still not GC, and basically exactly what I said in the beginning
>>
>>58498473
Reference counting is a form of garbage collection.
How's your string handling going? I heard you got some problems concatenating strings :^)
>>
>>58498473
Undecidable

>>58498487
No, it isn't.
>but wikip-
It can be used for GC, but by itself it isn't GC.
>>
>>58498453
>Where did you find such garbage, anon?
NodeJS blogs
>>
>>58498487
>concat!, format! macro
>String + &str expression
>>
File: 435436456457.jpg (13KB, 487x166px) Image search: [Google]
435436456457.jpg
13KB, 487x166px
Can anyone who knows about polygon partitioning explain why this works with the Hertel-Mehlhorn algorithm but not the Keil-Snoeyink algorithm?

Right is the result of HM. And this is the library I'm using:

https://github.com/ivanfratric/polypartition
>>
>>58498503
Don't read node blogs, anon.

In fact, pretend node doesn't exist. You'll be a better programmer for it.
>>
>>58498523
It's just morbid curiosity
>>
>>58498512
>B..but dude, we have this awesome macro to concatenate strings. We're systems programming dude.
Nice try Antifa, that doesn't work.
fn main() {
let s1 = String::from("foo");
let s2 = String::from("bar");
let s3 = concat!(s1, s2);
}
>>
>>58498564
Would you contract HIV out of morbid curiosity?
>>
>>58498572
I already have
>>
>>58498586
How are you finding it?
>>
>>58498568
https://doc.rust-lang.org/std/macro.concat.html

>Concatenates literals into a static string slice.
>literals

Do you even read?

Use format! to produce Strings.
>>
>>58497924
>>58497943
>>58497944
>>58497970
>>58498101
>>58498148
To be honest I wish I was using c/c++/python but:
* Pascal on windows is GOAT
* C/C++ static linking is shittier than Pascal's on unices
* C/C++/Python have no standard widget API
* Python doesn't come pre-installed on Windows
>>
>>58498590
Kinda shitty tbqh. Wouldn't recommend
>>
>>58498603
>C/C++/Python have no standard widget API
No, but there's Qt
>>
>>58498603
>I wish I was using python
No you don't.
>>
>>58498615
Statically linked Qt is hueg as far as I can tell
>>
>>58498626
It's a couple M depending on what you use.
LTO, inlining and dead code elimination will take most of it away.
>>
>>58498600
>Rust (((documentation)))
It's literally the worst out there.
Anyway, it still doesn't work bro
fn main() {
let s1 = String::from("foo");
let s2 = String::from("bar");
let s3 = format!(s1, s2);
}

Pro tip: sane languages use the '+' operator to concatenate strings. It's quite handy, you know?
>>
>>58498659
fn main() {
let s1 = String::new("foo");
let s2 = String::new("bar");
let s3 = s1 + &s2;
}
>>
>>58498690
woopsy String::new() doesn't take an arg xdDDDddD
>>
File: aa4.jpg (22KB, 456x628px) Image search: [Google]
aa4.jpg
22KB, 456x628px
Any C# devs with some spare time?

I'm trying to improve myself, I'm self taught so my skillset is relatively limited and I'm struggling to find decent tutorials/guides/blogposts on a couple topics.

I was hoping someone could teach me the basics of websocks and Win32 stuff, I've struggled trying to do it myself but I'm not making any progress.
>>
>>58498690
Sorry for the late response bro, I was riding my segway while laughing at Lenin jokes.
So how do we concatenate string slices bro? I tried the '+' operator like any languages does, but it didn't work.
fn main() {
let s1 = String::from("foo");
let s2 = String::from("bar");
let s3 = s1 + &s2;

let a1 = "foo";
let a2 = "bar";
let a3 = a1 + a2;
}
>>
>>58498659
format! works like python's format printf, the first argument is a format string literal and variable amounts of arguments to be interpolated, i.e.:
fn main() {
let s1 = String::from("foo");
let s2 = String::from("bar");
let s3 = format!("{} {}", s1, s2);
}
>>
>>58498746
you use Strings, or you use format!().
>>
>>58498730
Anyone who's worth anything learned by themselves.
Do yourself a favor and RTFM
>>
>>58498746
Either use
let a3 = a1.to_owned() + a2;
or use the format! macro.
>>
>>58498771
So far I've learned everything by myself, but I'm hitting my head against the wall with websocks specifically, everything on the subject is a massively overcomplicated implementation that doesn't actually show you the basics.

I'm trying to RTFM but I'm not getting anywhere, wouldn't ask if I didn't need it.
>>
>>58498746
>>58498774
in Haskell this is just

let s1 = "foo"
s2 = "bar"
s3 = s1 ++ s2
>>
>>58498749
>>58498768
>>58498774
You still don't get it. Why all that complicated shit just to concatenate a string?
Even C++ allows you to concatenate string like that. >>58498793 Haskell apparently does too.
>>
>>58498791
If you have a question in particular I'm sure people will be happy to answer, but if you expect someone to give private lessons on their own free time, don't expect them to do it >for free
>>
>>58496836
Don't we already know the optional solution for repeated prisoners dilemmas, though? Or are you trying to find something better than tit-for-tat?
>>
I'm in a college intro to java course and it's pretty much a waste of time as i finished our lab within the first 5 minutes

any things I can do in java to make sure I keep an A in this course and learn more about programming java on the side?
>>
>>58498802
lifetimes

also haskell is a high level language and LOL IO
>>
>>58498867
Does your language require IO in order to concatenate strings?
>>
>>58498885
??? where did this ever arise you fucking runt
>>
Maybe I should just define a struct
std::vector<std::pair<id_t_, std::vector<std::pair<std::vector<uint64_t, uint64_t> > > > >
>>
>>58498895
what? i don't understand

>>58498902
in Haskell this is just

Vector (Id_t_, Vector (Vector (Word64, Word64)))
>>
>>58498902
Whoops, forgot one of the pairs
std::vector<std::pair<id_t_, std::vector<std::pair<id_t_, std::vector<uint64_t, uint64_t> > > > >
>>
>>58498867
>lifetimes
They're just apologies for the borrow checker. I want a sane language, not something that requires me to write hacks just to please the borrow checker.
>>
>>58498913
>implying that isn't as complicated
C++ can look like that if you use
using namespace std;
(which is a terrible idea). I should just move over to a struct
>>
>>58498927
i've literally never had to fight the borrow checker, only once put <'a> in structs that have a reference and even then it's a bad idea
>>
>>58498953
>i've literally never had to fight the borrow checker
You just had to fight the borrow checker just to concatenate a string.
>>
>>58498920
>>58498941
type Idd a = Vector (Id, a)


Idd (Idd (Word64, Word64))
>>
>>58498977
factually incorrect
>>
>>58498997
So why do I have to fight the borrow checker to concatenate a string? Why can't the '+' op simply return a new string?
>>
>>58499020
literally did not have to interact with the borrow checker at all

>captcha: humane seguridad
>>
>>58499036
See
>>58498927
Lifetimes are part of the borrow checker.
>>
File: 1483895937163.png (156KB, 1000x1000px) Image search: [Google]
1483895937163.png
156KB, 1000x1000px
>>58496579
>tfw to intelligent to programm
>>
>>58499038
Meant to quote >>58498867
>>
>>58499038
but you didn't tho mate that's just a reference
don't think you actually understand what the borrow checker does
>>
>>58499056
>don't think you actually understand what the borrow checker does
It cripples your code in order to provide a false sense of safety.
>>
>>58498920
>std::vector<uint64_t, uint64_t>
That's still not right
>>
>>58499093
it tracks the *lifetime* of all references so that no code can dereference deallocated objects, eliminating double-free, dangling pointer and segmentation fault bugs.

it can do this without gc. stay mad
>>
>>58499093
>I care more about feelings than facts
I bet you're a frogposter, too
>>
>>58499136
>>58499143
Another Rust apologist has entered the ring!
>it tracks the *lifetime* of all references so that no code can dereference deallocated objects, eliminating double-free, dangling pointer and segmentation fault bugs.
And cripples the language by making it impossible to concatenate strings with the '+' operator.
They should've invested their time in a proper static analyzer for C++11 and up. That's where the future is, not at the Rust hugbox.
>>
File: 1484109954778.jpg (51KB, 800x634px) Image search: [Google]
1484109954778.jpg
51KB, 800x634px
>>58499143
where's the frogposter?
i'll fucking kill him
>>
>>58499129
Yeah, I just finished fixing that and came back to /g/ to see if anybody pointed it out yet
>>
>>58499167
>impossible to concatenate strings with the + operator
not true tho mate
>should've invested their time in a proper static analyzer for C++11
nope, none of the guarantees rust gives you can be implemented comprehensively outside of the compiler. otherwise it would already be a fucking solved problem
>>
Which one is the best method?
a)
int Mob::getStatsTotal() {
return hp + atk + def;
}
float Mob::getStatsAvg() {
return float(getStatsTotal())/3.0;
}

b)
int Mob::getStatsTotal() {
return hp + atk + def;
}
float Mob::getStatsAvg() {
return float(hp + atk + def)/3.0;
}


Should I call a public function in another public function in a class, or is that bad? Kinda feels wrong
>>
>>58499204
the first, of course
>>
>>58499204
First, the compiler should generate the same code
>>
>>58497621
More info on this?
>>
>>58499201
>not true tho mate
Show me code to concatenate two string slices and two heap allocated strings by only using the '+' operator. No cheating with macros.
>nope, none of the guarantees rust gives you can be implemented comprehensively outside of the compiler. otherwise it would already be a fucking solved problem
Poor code will always be a thing because it's hand crafted. Nothing can fix a human.
>>
File: 1480198444324.png (52KB, 1024x1024px) Image search: [Google]
1480198444324.png
52KB, 1024x1024px
>>58499169
Pourquoi détestes-tu les grenouilles?
>>
>>58499167
>And cripples the language by making it impossible to concatenate strings with the '+' operator.

Wrrrrooong!
FAKE NEWS, boys. Sad!

fn main(){
let mut x = "hello ".to_owned();
x += "world";

println!("{}", x);
}
>>
>>58499204
First. That way, if you add more stats later, you'll only need to change getStatsTotal and getStatsAvg will just werk.
>>
File: angif-move-the-goalposts-def.gif (27KB, 306x200px) Image search: [Google]
angif-move-the-goalposts-def.gif
27KB, 306x200px
>>58499256
>Show me code to concatenate two string slices and two heap allocated strings by only using the '+' operator.
>>
File: death to frogs.png (51KB, 933x267px) Image search: [Google]
death to frogs.png
51KB, 933x267px
>>58499261
you're gonna die
>>
>>58499256
>two string slices
it's called &str
fn main() {
let s1 = "foo";
let s2 = "bar";
let s3 = &(String::from(s1) + &s2);
assert_eq!("foobar", s3);
}

>two heap allocated strings
already shown you this dipshit
fn main() {
let s1 = String::from("foo");
let s2 = String::from("bar");
let s3 = s1 + &s2;
assert_eq!("foobar", s3);
}

>Poor code will always be a thing because it's hand crafted. Nothing can fix a human.
rust LITERALLY STOPS you from making loads of errors that will ALWAYS happen. don't come up with that "i never make mistakes i'm c++ rain man" bullshit. happens in every single c/c++ codebase, even important and massively peer-reviewed projects like chromium or v8.
>>
File: 1428658835576.png (29KB, 594x838px) Image search: [Google]
1428658835576.png
29KB, 594x838px
>>58499311
>>
>>58499326
You forgot to mention that Rust's strict typing enables a lot of optimizations and it makes RAII and exception safety way easier. FFS in C++ you have to use the "null object" idiom for move semantics to work. What the fuck were they thinking?
>>
File: frog legs.jpg (18KB, 250x250px) Image search: [Google]
frog legs.jpg
18KB, 250x250px
>>58499373
>>
File: 1471528564399.jpg (15KB, 405x371px) Image search: [Google]
1471528564399.jpg
15KB, 405x371px
>>58499399
>>
Why have you not whored yourself to the JVM yet? Between Java, Clojure, and the general platform agnosticism that comes from working with it, it seems like an amazing thing to get acquainted with.
>>
>>58499326
Both snippets require you to write more than just the '+' operator. Both of them contain hacks to please the stupid lifetime idiom.
>rust LITERALLY STOPS you from making loads of errors that will ALWAYS happen. don't come up with that "i never make mistakes i'm c++ rain man" bullshit. happens in every single c/c++ codebase, even important and massively peer-reviewed projects like chromium or v8.
>muh unsafe C/C++
There are infinite lines of safe C/C++ out there because they're not written by a Pajeet. Rust doesn't catch all errors so the claim of 'safe code' is false. Even worse, it cripples you code tremendously.
>>
no response rust-hating rorke? BTFO
>>
>>58499427
I can't hear you with all those GC pauses in your speech
>>
>>58499436
are you saying that chromium and v8 are written by pajeets? two of the most important projects for the web?
>it cripples your code tremendously
where is the proofs
>>
ANYONE WANT TALK ABOUT LUA?

>Should tables be split into sequence and associative data structures?
>Should integers be removed from the base language and put into a library? Or should they become less transparent?
>Are you working on anything in Lua currently?
>What are some of your favorite libraries?
>It's a shame MetaLua isn't up-kept, but Terralang looks cool.
>>
>>58499461
Call me when its arrays start at zero
>>
>>58499456
>are you saying that chromium and v8 are written by pajeets? two of the most important projects for the web?
Pajeets as in poor programmers retard.
>where is the proofs
string concatenation and https://www.reddit.com/r/rust/comments/33jv62/vecrcrefcellboxtrait_is_there_a_better_way/
>>
>>58499461
I like python
>>
>>58499487
Also: show me a non-trivial project rewritten in Rust for the sake of safety.
>>
>>58497128
Not enough fast libraries and arguably shitty docs are probably the only problems.
>>
>>58499487
are you saying that chromium and v8 are written by poor programmers? two of the most important projects for the web? answer the fucking question instead of deflecting, even for a rorke you are quite the hypocrite
>>
>>58499490
Yeah most of the people on the Lua mailing list are ex-pythonistas, but became disillusioned by the language's slow hulking mass.
>>
>>58499444
Well, learn more about how the garbage collector works, and meet it halfway. You can still optimise your code, even if your not working with the memory directly.
>>
>>58499499
librsvg
>>
>>58499508
Fair enough, but since the language is pretty young that's not entirely unexpected.
What's promising is seeing that the community is very active
>>
>>58499511
>two of the most important projects for the web
Non-sequitur. Windows is one of the most important system for computers, doesn't mean it's well-written. It's full of security problems.
>>
>>58499326
>rust LITERALLY STOPS you from making loads of errors that will ALWAYS happen. don't come up with that "i never make mistakes i'm c++ rain man" bullshit. happens in every single c/c++ codebase, even important and massively peer-reviewed projects like chromium or v8.
That's nonsense, anon. It is seriously not that hard to not mess up your pointers in C or C++. Rust avoiding the whole class of problems with static analysis (however limited) is a great thing; but to say that you will inevitably have bugs like this in C++ is bollocks.
>>
>>58499461
From my experience with lua (writing some scripts for MPV), it's a pretty shit language.
>>
>>58499540
not an argument
>>58499547
you CANNOT avoid it, don't even attempt to argue that it's probabilistically possible, in reality these mistakes are always made in all codebases
>>
>>58499518
How do I make an ArrayList of 10M integers in java?

Answer: Because Java generics are too broken of a mess to work with primitive types you'd naively have to use an ArrayList of Integer, but if you do that the GC will go batshit insane over it, spend 99.99% of the time running in circle, and your program will get terminated with an exception.
So you spend 5 hours writing your own implementation of a dynamic array like this is the 1970s over again.

Java™
>>
>>58499521
Is it already used in mainline Cairo etc. Nope.
>>58499511
I already explained myself. Try reading next time.
>>
File: 2017-01-15-171504_301x60_scrot.png (18KB, 301x60px) Image search: [Google]
2017-01-15-171504_301x60_scrot.png
18KB, 301x60px
>>58499590
touche mate you're the one who's got a comprehension deficiency
oxidised librsvg is already being put to use in Wikipedia, whose user base is pretty broad if i might say so myself
>>
Why did Google have to create go, a language designed for people who aren't good enough to use C++, Java, etc., if they only hire the best and brightest people?
>>
>>58499511
Are you saying that GCC and Linux are written by poor programmers because they make mistakes and use an inferior(tm) programming language?
>>
>>58499571
>you CANNOT avoid it
Maybe YOU can't. Other people can, and do.

>in reality these mistakes are always made in all codebases
I can assure you that they really, really aren't. They are often made in freshman code, yes. Real-life code with competent people behind it, not so much.
>>
How many simultaneous TCP connections can one Tor circuit handle?
>>
>>58499617
There's not enough best and brightest to go around, so they also hire average suckers to do the boring work.

Those people are given Golang and safety glasses
>>
>>58499629
Why don't we make teaching better in colleges then?

They should stop being glorified daycare centers. Teach people real CS, not just half of a scripting language and basic Java.
>>
>>58499621
>the mental gymnastics being performed to try and apologise for C/C++
>>58499622
wrong
https://www.cvedetails.com/vulnerability-list/vendor_id-1224/product_id-15031/opec-1/Google-Chrome.html
https://www.cvedetails.com/vulnerability-list/vendor_id-1224/product_id-17734/Google-V8.html
https://www.cvedetails.com/vulnerability-list/vendor_id-26/product_id-17153/hasexp-1/Microsoft-Windows-7.html
>>
>>58499611
Wew lad, you finally found Rust in production. Give yourself a pat on the back.
Meanwhile C++ is steamrolling you with projects like chromium, v8, llvm and so forth.
>>
>>58499511
>are you saying that chromium and v8 are written by poor programmers?
Insanely bloated, million line code projects for the simple task of rendering html+css and executing javascript?
Yes, that is made by very bad programmers.
>>
>>58499651
>C++ has been around for 30 years
>Rust has been around for 1 and a bit years
not an argument
>>58499657
do you even understand what you're saying?
>>
>>58499648
You can't force people to learn if they don't want to.
The best and brightest didn't wait for their teacher to start learning what they were interested in.

Now if you're asking "Why don't we make people not suck?", please remember there's a reason that eugenism is highly illegal.
>>
>>58499651
>hurr rust loses because all these projects made before it got to 1.0 aren't written in it
>>
>>58499675
We can't force them to learn, but we can certainly stop pretending trivial accomplishments or mere participation are feats worthy of recognition or an academic qualification.
>>
>>58499672
>not an argument
The only relevant backer of Rust is Mozilla. I don't see big cooperation like Red Hat, Apple, Tesla or Google listed on https://www.rust-lang.org/en-US/friends.html
I wonder why...
>>
>>58499701
Sure, but that wouldn't change the reality of the situation. It would just make you feel superior.
>>
>>58499580
Java does have it's bad points. BUT, there are other languages that compile to the JVM.
>>
>>58499525
Yes, with tokio out we might actually see some nice libraries now. Many current implementations have even Go running circles around them. And I want to strangle the RoR hipster that wrote most of the docs. We need terse descriptions with examples, not walls of theoretical masturbation on each page.

Also, the compiler is atrociously slow, not optimizing enough and not even multithreaded.
>>
File: me.jpg (93KB, 640x640px) Image search: [Google]
me.jpg
93KB, 640x640px
Dear /dpt/,

does anyone know how I can do the following without copy and pasting the whole class?

public class MyClass
{
Random r = new Random();
List<Item> item_list = new List<Item>();

public MyClass()
{
for (int i = 0; i < 100; i++)
{
Item item = new Item();
item.number = r.Next();
item_list.Add(item);
}
}

public Item GetItem(int idx)
{
return (item_list[idx]);
}
}

public class MyClassEx : MyClass
{
// this class needed to do exactly the same as MyClass - but use an ItemEx list and return ItemEx
}


public class Item
{
public int number;
}

public class ItemEx : Item
{
public int another_number_that_isnt_used_by_either_class;
}
>>
>>58499709
you missed Canonical, Dropbox, OVH, Line, Samsung, and yes Google is using Rust aswell.
>>
>>58499721
The language is C# btw
>>
>>58499726
Give me proof. What has Samsung running in Rust?
>>
>>58499735
Thanks, I thought it was Haskell until you clarified
>>
>>58499718
>Also, the compiler is atrociously slow, not optimizing enough and not even multithreaded.
As a C++ dev, I doubt the Rust compiler is going to get much faster.
Right now IIRC most of the compile times for rustc are in the LLVM optimization passes, so there's not a whole lot of low hanging fruits.

As for parallelizing the compiler, that doesn't sound super useful, since usually you'll want to start multiple instances of the compiler so all the cores are already busy.
Unless rustc can't currently compile files separately, but that sounds outrageously stupid.
>>
>>58499749
https://servo.org/
>Created by Mozilla Research, the Servo project is being built by a global community, from individual contributors to companies such as Mozilla and _Samsung_.
>>
>>58499709
>I wonder why...
Because Mozilla created it and it's still a young language, maybe?
>>
>>58499762
You don't need optimization turned on most of the time during development.
>>
>>58499624
I don't think the spec puts any limit on that.
>>
>>58499721
G E N E R I C S
>>
>>58499777
There's a bare minimum, if you don't let the compiler evaporate all the abstraction layers you'll end up with 10x slower than normal runtime.
>>
>>58499801
Not a problem for most projects, which are IO-bound rather than CPU-bound.
>>
>>58499785
When I tried using generics I couldn't access item.number
>>
>>58499814
Sure, but most projects are IO-bound by a factor of 1.5 to 3, not 10.
>>
>>58499819
Generics + typeclasses
>>
>>58499823
Yes, but how do you write it?
>>
>>58499762
The difference between Rust and C++ is that one instance compiles the final binary, which is your entire application, not a single C++ file. So AFAIK dependency type checking and translation to mir is parallelized, but then you have this giant static binary and the compiler chews it all over on a single thread.
>>58499822
And, if you want to run incremental benchmarks to optimise code, you are fucked much more than you would be with C++.
>>
>>58499894
>The difference between Rust and C++ is that one instance compiles the final binary, which is your entire application, not a single C++ file. So AFAIK dependency type checking and translation to mir is parallelized, but then you have this giant static binary and the compiler chews it all over on a single thread.
Yeah well, pretty much the same thing happens in C++.
Each translation unit is compiled separately, and then LTO kicks in and you need 5GB of memory and half an hour to link Chromium.
>>
>>58499863
If you're using a crippled language that doesn't support typeclasses, pass in a function that tells you how to get the number member from the element type.
>>
File: 1481133138439.png (340KB, 679x532px) Image search: [Google]
1481133138439.png
340KB, 679x532px
fiddling with tensorflow, pic related its me
>>
>>58499475
What's the problem with arrays starting at 1? It is more natural for man to count from one.
And Fortran has arrays starting at one, too.
>>
>>58499933
I'm sure C# support something like this
I just don't know how to write it
>>
>>58499961
I think C# calls them delegates.
>>
>>58499961
Probably you need to use interfaces + generics, you should google it.
>>
>>58500007
Interfaces are an impoverished version of typeclasses.
>>
>>58500007
I already google various things without much success
>>
childhood is loving haskell for its mathematical correctness. adulthood is realizing Rust makes more sense
>>
>>58500055
>loving haskell for its mathematical correctness
>mathematical correctness
tippity top kek
>>
>>58500055
Haskell is better than Rust. Prove me wrong.
>>
>>58500115
burden of proof is on the accuser
>>
>>58500115
Haskell is useless
>>
>>58500055
Haskell is pretty much worthless at this point. Rust is a lot better if you want to get stuff done (and will only get better), whereas for PLT research it's all about Agda, Idris, Coq, etc.
>>
>>58500153
Rust is pretty much worthless at this point. Go is a lot better if you want to get stuff done (and will only get better), whereas for PLT research it's all about Agda, Idris, Coq, etc.
>>
>>58500204
Go is pretty much worthless at this point. JavaScript is a lot better if you want to get stuff done (and will only get better), whereas for PLT research it's all about Agda, Idris, Coq, etc.
>>
>>58500216
i think this is the only one that i can safely say is untrue
>>
>>58500204
>no generics
>garbage collection
>>
>>58496636
beautiful post
>>
>>58500216
Go is pretty much worthless at this point. TypeScript is a lot better if you want to get stuff done (and will only get better), whereas for PLT research it's all about Agda, Idris, Coq, etc.
>>
File: Screenshot_2017-01-15_19-02-42.png (203KB, 1151x848px) Image search: [Google]
Screenshot_2017-01-15_19-02-42.png
203KB, 1151x848px
i decided to change the layout and colours completely

it's gonna be darker and more toned
>>
>>58500239
>no libraries
>Vec<Rc<RefCell<Box<Trait>>>>
>>
>>58500260
get a decent font nonce
>>
>>58500255
TypeScript is pretty much worthless at this point. Elm is a lot better if you want to get stuff done (and will only get better), whereas for PLT research it's all about Agda, Idris, Coq, etc.
>>
>>58497063
>using underscores in function names
stop
>>
My compiler throws out "No accessible 'Main' method with an appropriate signature was found in 'Module1'." When I compile the following code:

Imports Microsoft.VisualBasic.FileIO
Module Module1
Public com3 As IO.Ports.SerialPort = Nothing
Public incomingString As String = com3.ReadLine()

Sub Main(ByVal CSVPathLog As String, ByVal firstName As String, ByVal lastName As String, ByVal Tutor As Decimal, ByVal Status As String, ByVal Time As String)
Dim comString As String = ""
'Dim com3 As IO.Ports.SerialPort = Nothing
Try
com3 = My.Computer.Ports.OpenSerialPort("COM3")
com3.ReadTimeout = 10000
Do
'Dim incomingString As String = com3.ReadLine()
If incomingString Is Nothing Then
Console.WriteLine("No incoming strings")
Exit Do
Else
comString &= incomingString & vbCrLf
Console.Write(incomingString)
Console.WriteLine()

End If
Loop
Catch exception As TimeoutException
End Try
'End of Serial Logger

'Start of CSV Builder
Try
Dim inputLine As String = ""
Dim dataWriter As IO.StreamWriter = IO.File.AppendText(CSVPathLog)

If IO.File.Exists(CSVPathLog) Then
dataWriter.Write(firstName & ",")
dataWriter.Write(lastName & ",")
dataWriter.Write(Tutor & ",")
dataWriter.Write(Status & ",")
dataWriter.Write(Time & ",")
dataWriter.Write(Environment.NewLine)

End If
dataWriter.Close()
Catch exception As Exception
End Try

End Sub

End Module

Written in VB.Net
>>
>>58500294
Elm is pretty much worthless at this point. Translating Ruby into Python and embedding Python inside Rust and crosscompiling to WebAssembly is a lot better if you want to get stuff done (and will only get better), whereas for PLT research it's all about Agda, Idris, Coq, etc.
>>
>>58500267
>not even possible in Go because it has no generics and garbage collection
>>
>>58500260
why not integrate last.fm api and fetch music info to the left panel?
Like artist photo, album, release date, small wiki and lyrics
>>
I keep stumbling with youtube videos that say C++ isn't good for begginers and I don't know what the fuck I should learn anymore

Learning curve isn't a problem for me
>>
>>58500305
>snakecase/camelcase
runt
>>
>>58500287
suggestions?
>>
>>58500328
What are you hoping to get into? What do you want to program, end-game wise?

Most fags in this general will disagree with me, but for learning easy programming and the fundamentals, Visual Basic.Net is a good one, or C# - anything in the .Net family desu
>>
>>58500325
>not even possible in Rust because it has no libraries
>>
>>58500326
that's what i'm gonna do eventually, i'll also try to integrate scrobbling
>>
>>58500319
Translating Ruby into Python and embedding Python inside Rust and crosscompiling to WebAssembly is pretty much worthless at this point. Writing a dedicated browser in C is a lot better if you want to get stuff done (and will only get better), whereas for PLT research it's all about Agda, Idris, Coq, etc.
>>
>>58500346
Pretty sure you should just not specify it and use the default font which is optimised for system font rendering
>>
>>58500305
that's the pythonic convention
>>
File: Screenshot_2017-01-15_19-11-05.png (182KB, 852x855px) Image search: [Google]
Screenshot_2017-01-15_19-11-05.png
182KB, 852x855px
>>58500370
>>58500370
>>
>>58500328
unironically C
>>
>>58498730
>trying to improve myself
>learning C#
>>
>>58500369
Writing a dedicated browser in C at this point. Writing a dedicated browser in Scratch is a lot better if you want to get stuff done (and will only get better), whereas for PLT research it's all about Agda, Idris, Coq, etc.
>>58500396
>specified Arial instead
NOT what i meant
>>
i wonder what happens when a post replies to itself, regarding that guys program that changes 4chan threads to look like reddit with a chain of replies. would it recurse infinitely and break the program?

>>58500421
>>
>>58500350
I'd like to make simple games but as a hobby, I'd like to get a job as a programmer, or web backend, that's more important for me
>>
>>58500412
That's what happens when you don't specify a font
>>
>>58500436
what platform is this? try specifying Segoe UI
>>
>>58500412
Writing a dedicated browser in Scratch is pretty much worthless at this point. Designing an in-house virtual machine for your web site is a lot better if you want to get stuff done (and will only get better), whereas for PLT research it's all about Agda, Idris, Coq, etc.
>>
>>58500396
>not using the solarized color scheme
>>
>>58500398
Stop memeing around
>>
New thread:

>>58500500
>>58500500
>>58500500
>>
>>58500499
>hey guys what's 2+2? and don't say 4, that's ridiculous
>>
>>58500365
Awesome.
Looks like it'll become something I'd love to use.
Where are you hosting the project?
>>
>>58499246
The other day Ruby tried to pretend he had revolutionised game theory, but in reality he was just trying to find someone to have sex with :(
>>
>>58500055
Rust is the fox and Haskell is the grapes.
Thread posts: 318
Thread images: 22


[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.