[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: 336
Thread images: 25

File: dpt_rust.png (146KB, 1000x1071px) Image search: [Google]
dpt_rust.png
146KB, 1000x1071px
What are you working on, /g/?
Old thread: >>58325678
Functional Programming Thread: >>58332039
>>
>>58335192
First for D.
>>
File: 1480664674937.png (328KB, 451x451px) Image search: [Google]
1480664674937.png
328KB, 451x451px
>Java
>C++
>Python
>>
>>58335206
>D
RIP
>>
>>58335192
Find the mistake in the text below? Why can't you? Why is it perfect?


Just use C and D. If you really want you can use C++ instead of/alongside D.

If you want something on a VM with support/libraries all over the place then use Java. Second winner in this category is C#.
You can write the performance critical parts in C.

Plus choose one scripting language with good C interop. Anything you like.

If you want something with FP then choose between OCaml, F# or StandardML.

Lisp/Scheme is good for the learning experience, embedding and when you know what you're doing. If you want a Scheme(-like) language then use Racket.

Anything else is domain specific bullshit.
>>
>>58335218
C++ is hard only if you are a retard
>>
>>58335192
Qt or wxWidgets? I heard Qt has gigantic binaries with static linking and requires you to put qml files everywhere.
>>
>>58335251
Qt ofc.
>I heard Qt has gigantic binaries
All the dlls make maybe 20-30Mb total, who cares.
>>
>>58335269
Also, I saw something about it faking the native theme. Does that mean if you have a custom theme on XP or Linux that it'll look messed up or does it try to look like the enduser's theme?
>>
What are some other procedural languages that support something like goroutines?
>>
Is pic related true
>>
>>58335251
>qml
it's optional, you don't have to use qml, you can use .ui forms which are transpiled to cpp/hpp and linked or just create the widgets from within your code
>>
File: 1483342988862.png (379KB, 689x752px) Image search: [Google]
1483342988862.png
379KB, 689x752px
>>58335192
alright /g/ I feel retarded. I'm trying to make this damn thing rotate but it just stands still.

//A simple spinning graphic of the tsukuru icon
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <iostream>

using namespace sf;
using namespace std;

int main()
{
RenderWindow window(VideoMode(100, 100), "SFML works!", Style::None);
Texture tsukuru;

if (!tsukuru.loadFromFile("icon.png"))
{
//error here
}

Sprite icon;
icon.setTexture(tsukuru);
icon.setOrigin(Vector2f(50, 50));
icon.setPosition(50,50);

Clock clock;
Time elapsed;
Time elapsed2;

float scale = 1;
bool flip = false;

while (window.isOpen())
{
elapsed = clock.getElapsedTime();
if(scale <= 1 && scale >= -1)
{
flip = !flip;
}
else
{
if (flip == true)
{
scale = scale + 0.014;
}
else if (flip == false)
{
scale = scale - 0.014;
}

}
icon.setScale(scale, 1);
elapsed2 = clock.getElapsedTime();
cout << elapsed2.asMilliseconds() << "@" << endl;
while((elapsed2.asMilliseconds() - elapsed.asMilliseconds()) <= 1)
{
while((elapsed2.asMilliseconds() - elapsed.asMilliseconds()) <= 1)
{
elapsed2 = clock.getElapsedTime();
cout << elapsed2.asMilliseconds() << endl;
}
clock.restart();

window.clear();
window.draw(icon);
window.display();
}
}
>>
>>58335299
>IOS
>Language
What?
>>
Is chapel the best language?
>manual memory management
>first-class concepts for concurrent and parallel computation
>type inference
>backed by DARPA
>lambdas
>oop
>>
>>58335393
>oop
And it's complete garbage.
>>
>>58335334
Your compiler might bitch about shit if you don't have the C++14 flag enabled, you can just rip that chrono stuff out if you want. Had to do it to get my computer to not melt.
idk wtf ur trying to do anon but here
#include <SFML/Graphics.hpp>

#include <thread>
#include <chrono>

using namespace std::chrono;
using namespace std::chrono_literals;
using namespace sf;
using namespace std;

const nanoseconds MAX_FRAME_TIME = 16666667ns;

int main()
{
RenderWindow window(VideoMode(100, 100), "SFML works!", Style::None);
Texture tsukuru;

if (!tsukuru.loadFromFile("icon.png"))
{
//error here
}

Sprite icon;
icon.setTexture(tsukuru);
icon.setOrigin(Vector2f(50, 50));
icon.setPosition(50, 50);

float rotation = 0;

while (window.isOpen())
{
high_resolution_clock::time_point start_time = high_resolution_clock::now();

rotation++;
icon.setRotation(rotation);

window.clear();
window.draw(icon);
window.display();

nanoseconds frame_time = high_resolution_clock::now() - start_time;
if (frame_time < MAX_FRAME_TIME)
std::this_thread::sleep_for(MAX_FRAME_TIME - frame_time);

}
}
>>
>>58335401
I'll read about <chrono> i guess. I have no idea how it works or what it's members are. I'm pretty used that the time isn't the problem though.

The
  cout << elapsed2.asMilliseconds() << endl;
is spitting out the correct numbers on cue, but nothing is moving. So the scaling isn't working or the sprite isn't Idk desu. being drawn properly.
>>
Is this an example of good or shit c++??

https://raw.githubusercontent.com/Palm-Studios/sh3redux/master/include/SH3/arc/file.hpp

https://raw.githubusercontent.com/Palm-Studios/sh3redux/master/source/SH3/arc/file.cpp

https://raw.githubusercontent.com/Palm-Studios/sh3redux/master/source/SH3/arc/types.cpp
>>
>>58335334
I don't see any code that does any rotating.
>>
>>58335485
Looks not too bad, but could be improved.
>>
>>58335485
Looks good to me, the author knows how to use the STL and the modern C++ and the code itself is pretty clear.
>>
>>58335514
icon.setScale(scale, 1);
sets the scale in the x dimension. It's 3d rotation of a 2d disc along the x axis.
>>
>>58335457
Your greedy regexes are probably fucking you up by consuming your slashes, along with those trailing slashes that you may or may not want. Use non-greedy regex (.*?) or at least don't have it match your slashes ([^/]+)
>>
>>58335545
>>58335334
then this is your problem:
>float scale = 1;
>if(scale <= 1 && scale >= -1)
the if statement is true, so all you do is flip the bool and never touching scale,
>>
>>58335515
>>58335521
Thanks lads, I'm working with this dude and as a C programmer, wasn't too sure if this was good modern C++ or a clusterfuck. I usually just use cpp as C with classes haha.

As a side, could you possibly explain the benefit of a unique_ptr as opposed to a raw pointer and delete in the destructor.
>>
>>58335581
Ah thank you. I'm retarded.
>>
>>58335588
In that scenario it just serves the role of a separator of concerns.
>>
>>58335588
> could you possibly explain the benefit of a unique_ptr as opposed to a raw pointer and delete in the destructor.
It's impossible to get a dangling pointer, to forget to delete, or to double delete it. And all this compiles to a no-op and entirely free at run-time.
>>
>>58335631
>>58335622
Thanks again guys, I seriously need to brush up on modern C++ practices.
>>
>>58335575
Oh sorry, I moved the question to >>58335626 but I will see what I can do with that. I'm not 100% on regex.
>>
File: 1472007964659.png (230KB, 640x360px) Image search: [Google]
1472007964659.png
230KB, 640x360px
>>58335218
>C
>Rust
>Haskell
>>
>>58335581
Haha thank you. I got it working now, but it's fast as all hell, but thank you for your help. I'm gonna go to sleep now, haha.
>>
File: women's butts.png (7KB, 203x196px) Image search: [Google]
women's butts.png
7KB, 203x196px
>>58335299
Somewhat, but not really.
>>
>>58335674
>but it's fast as all hell
the chrono thing will fix that, you can use the one built into SFML too but that one is super unreliable
>>
>>58335702
I already slowed it down. I changed the increment on the change of scale from 0.014 to 0.002.

You said that the SFML time methods are unreliable. Can you elaborate on that? I don't know much about them. I haven't had to use them very much.
>>
File: (((2017))).png (34KB, 584x213px) Image search: [Google]
(((2017))).png
34KB, 584x213px
>>
>>58335735
>the Unix kernel
>the
>>
>>58335588
Even if you only write C++ as C with classes, why not use the features of C++ such as have a destructor?
unique_ptr and shared_ptr are just classes which contains a pointer and a reference counter.
When the counter is changed, it will automatically delete.
It is like using .at() operator to access elements as you can see if the access is valid.
>>
>>58335729
>I already slowed it down. I changed the increment on the change of scale from 0.014 to 0.002.
Well if you're not using sleep or something to slow it down it'll be diff speeds depending on the computer.
>You said that the SFML time methods are unreliable. Can you elaborate on that?
Yeah, you can do window.setFramerate or something like that but I've found that even on the newest versions of SFML that the timer will randomly work at half or twice the fps that you've specified. When I used to use the SFML limiter in my program it would regularly work at half speed for no discernible reason.
The chrono thing isn't perfect either but it's quick and ez. I think SDL actually has a good, consistent FPS limiter though.
>>
>>58335741
Wow, you'd think one of the people working on unix since 1981 knew his shit!
>>
>>58335763
>unix
There is no "Unix" anymore.
>>
>>58335757
>Well if you're not using sleep or something to slow it down it'll be diff speeds depending on the computer.
That's fine. It's only for this one computer anyway.

>Yeah, you can do window.setFramerate or something like that but I've found that even on the newest versions of SFML that the timer will randomly work at half or twice the fps that you've specified. When I used to use the SFML limiter in my program it would regularly work at half speed for no discernible reason.
>The chrono thing isn't perfect either but it's quick and ez. I think SDL actually has a good, consistent FPS limiter though.
Ah good to know. Thank you for that info. I'll look into SDL.
>>
>>58335747
> unique_ptr and shared_ptr are just classes which contains a pointer and a reference counter.
unique_ptr has no counter, it's just a pointer with destructor and move semantic.
>>
>>58335735
>This is the person who designs Go
Well, it explains everything.
>>
>>58335788
>That's fine. It's only for this one computer anyway.
Eh, it's still sketchy. It'll prob be a diff speed between release and debug builds, maybe even between one build to another if you change a bunch of code.
>Ah good to know. Thank you for that info. I'll look into SDL.
You can also use just SDL for its timer and nothing else if you want.
>>
>>58335747
unique_ptr does not have a counter though, it has a free'er/dtor and move semantics.
>>
template <std::size_t I, typename... Ts>
struct type_pack_element_aux {
private:
template <std::size_t, typename T>
struct indexed_type {
using type = T;
};

template <std::size_t... Is>
static auto make_set( std::index_sequence<Is...> ) {
struct set : indexed_type<Is, Ts>... {};
return set{};
}

template <typename T>
static std::enable_if<true, T> impl( indexed_type<I, T> );

static std::enable_if<false, void> impl( ... );
public:
using type = decltype(impl(make_set(std::make_index_sequence<sizeof...( Ts )>{})));
};


Can anyone elaborate how does the inheritance mechanism in make_set works like, and later how does exactly SFINAE kick in?
>>
>>58335825
Jesus fucking chirst.
How do people defend that lagnauge?
>>
>>58335807
The people designing Go also designed B (and with that indirectly a large part of C), Unix, Plan 9 and UTF-8!
>>
>>58335830
That's not something you'd write in your daily code, though.
>>
>>58335830
No other language have an equally powerful metaprogramming capability.

Even Hasklelfags are envious of this.
>>
>>58335839
But what about Lisp?
>>
>>58335847
Lisp is a children's language
>>
File: 1468625228290.jpg (29KB, 300x260px) Image search: [Google]
1468625228290.jpg
29KB, 300x260px
>>58335192
>rust
>>
>>58335893
Thanks for your very constructive contribution, anon.
>>
>>58335836
It's time for this meme to stop. Yes, Ken Thompson played some role in designing Go, but he's like 80 or something and the main designer is Rob Pike, who lives in his echo-chamber for 40 years now while producing nothing of value. Also everything in this list is an obsolete shit except for UTF-8.
>>
>>58335825
Nevermind, I figured it out, that's pretty neat.
>>
>>58335940
C is pretty useful for what it was designed for and Plan 9 certainly brought a bunch of good ideas to the table that are being utilized now, so as a research OS it definetly succeeded.
Not even gonna start on how Unix influenced computing.
According to several sources Go was designed by Robert Griesmer, Rob Pike and Ken Thompson equally, i.e. all of them came up with ideas and would only implement them once all of them agreed on them.
This means that Ken Thompson agreed to all ideas provided by Rob "Echo-Chamber" Pike and thus contributed to every single core concept of the language.
If you've got any source showing the opposite, feel free to let me know :^^^^)
>>
>>58335940
This

I mean, for fuck's sake, Rob Pike thought it was a good idea to
>include directly from github by using an url
but he forgot to add a versioning system for this, so not only is it a massive security risk it's also pants on head retarded and requires you to clone the repo yourself and then point the compiler at the actual local location

>implement generic containers
but by relying excessively on type casting, because there is no generic type specification, you essentially just throw type safety out the window and end up with a system that's similar to early day Java where every collection passes type Object around and you cast here and there

>retain C style pointer/reference semantics
but throw pointer arithmetic out the window so now you're stuck with a broken system that forces you to explicitly handle references instead of the system just doing this for you as part of type inference

>throw exceptions out the window
but still recommend that you implement exceptions using Go semantics, because guess what, exceptions are a good thing after all

Go is the perfect example of why the so-called "UNIX philosophy" is outdated and should be considered fucking harmful.
>>
>>58336004
>Plan 9
>brought good ideas
No, Plan 9 reiterated old ideas that should have died with the death of UNIX.

See >>58336012

Go is a terrible language, and there's a reason why people only implement """microservices""" in it and abandon it for larger projects.
>>
>>58336004
>According to several sources Go was designed by Robert Griesmer, Rob Pike and Ken Thompson equally, i.e. all of them came up with ideas and would only implement them once all of them agreed on them.

It shows since these old fugs would rather ignore decades of PL research.
>>
>>58336012
Yes, go get was a bad idea.
Yes, lack of generics is annoying for most areas that Go is useful in, although they'd slow down compilation by a bunch.
Having references isn't such a bad thing performance wise (considering Go is designed to be a low level backend web language), because gc can allocate a lot more things on the stack (gc also has escape analysis, so *a lot* more is being allocated on the stack than in other languages that do not have explicit references).
In general, this boosts cache coherency quite a bunch.
I don't understand you argument about exceptions. Are you talking about error values being passed up the stack or panic?
>>
>>58336063
I know that this argument is pretty popular, but the last few decades of PL research mostly focus on two implications:
Less state => better code
More abstraction capabilities and expressiveness => better code
I am not so sure about these two implications (and I know the Go devs aren't either), and I think it's weird that these two implications being true is taken for granted in PL research.
I've encountered problems where duplicating a bit of code or using a bit of state resulted in more understandable code, and I'm sure you have as well.
Imo, abstracting solely for the purpose of reducing syntax duplication is often a bad idea, while abstracting for the purpose of reducing the duplication of some intuitive concept is often a good idea.
>>
>>58336121
>I don't understand you argument about exceptions. Are you talking about error values being passed up the stack or panic?
The defer, panic and recover semantics, which can be used to implement exceptions. I misspoke, however, because I was under the impression that the best practice is to implement an exception-like control, but it seems that it is actually the contrary.
>>
>[UnPaid]
>looking a programmer who loves marching cubes/dual contouring,voxels,minecraft,Empyrion,7 days to die,autocraft,gearblocks etc.
>required to collaborate with me in building voxel planets inside Unity

Sure thing, buddy.
>>
>>58336166
Yeah, error values are best practice and panics are rarely used.
You normally use error values for user errors or errors that cannot yet be identified as user errors and would be expensive to double-check in the caller.
You use panics for errors that have been identified as programming errors and errors that haven't been identified yet while being easy to double-check in the caller.
The idea is that exception semantics and monadic control flow are very useful when an error should bubble up a bunch of stack frames and crash the program unless otherwise caught. This is true for programming errors, but not for user errors.
For user errors or still unidentified errors the default behavior shouldn't be to crash the program.
Also, unless your language is dynamically typed and completly follows the error handling philosophy of Erlang (this especially means having supervisors) then panics/exceptions will be difficult to use in a concurrent environment, which is what most Go programs are about.
>>
>>58336220
Okay, I'll retract my last complaint. My issue with lack of generics is my most vocal though. I cannot believe that anyone in modern times would design a new language from scratch and not implement some sort of generic programming.
>>
>>58336344
Tensorflow
>>
How do you come up with project ideas?
>>
>>58336220
The Go's way of solving this results in "if err!=nil" in every other line while still allowing you to just ignore the error and proceed to use the value. It's like the old C way, only errno is now integrated with function call.

The proper way to handle errors without exceptions is to use Sum Types (aka ADT): you use type system to force a programmer to check for an error before he can use the value. But, again, Go's type system isn't expressive enough to allow this.
>>
>>58336362
Having a job helps.

When you're playing with live, living data with a purpose, it really helps you get more ideas for personal projects that are tangentially related.
>>
>>58336384
This. When the job you're at actually lets you play around with making their data do something, you start getting ideas. Just don't let non-technical superiors come up with ideas. Ever. Ever ever.
>>
>>58336379
Using sum types for errors isn't too different from error values, they're merely more type safe.
You can *always* ignore the error, even with sum types, as long as you've got no totality.
Ignoring errors in Go with functions that return multiple values is explicit, not implicit, just like it'd be with sum types.
Only disadvantage here is that errors of functions which only have an error as return value can be implicitly ignored, but that's relatively rare (most prevalent case being resource closing).
>>
>>58335870
>i-it doesn't count
>>
>>58336503
>no generic programming
You're damned right it doesn't count.
>>
this thread has too few anime girls to be considered a true /dpt/

pls fix
>>
File: migken.gif (209KB, 640x426px) Image search: [Google]
migken.gif
209KB, 640x426px
>>58336606
>>
>>58336509
>complaining about the lack of generics in a language with dynamic typing
/g/ in a nutshell
>>
File: 1483623719550.png (514KB, 810x698px) Image search: [Google]
1483623719550.png
514KB, 810x698px
>>58336606
>>
>>58336653
>generic programming = generics
>not even knowing what metaprogramming is

I'd say your post is /g/ in a nutshell.
>>
>>58336677
Kek
>>
>>58336455
>Using sum types for errors isn't too different from error values, they're merely more type safe
No?
>You can *always* ignore the error, even with sum types, as long as you've got no totality.
You can try to "ignore" an error in Rust, by using .unwrap() on Result<>, but it will panic if the result is an error at the runtime, so it's actually not ignoring at all. In other words, there is no way to write something like this in safe Rust:
value, _ := maybe_error(); //ignore error but use the value
lets_use(value);

or
value, err := maybe_error();
another_value, err = maybe_error(); //overwrite the previous error without checking it

>Ignoring errors in Go with functions that return multiple values is explicit, not implicit, just like it'd be with sum types.
I don't think "value, _ := func()" is "explicit" about anything.
>Only disadvantage here is that errors of functions which only have an error as return value can be implicitly ignored, but that's relatively rare (most prevalent case being resource closing).
Don't forget about uncomposability of Go's approach. When using exceptions you can just write your code in sequential manner, having all your error-processing code in one place. With ADT you can compose error-producing code with monads in Haskell or try! macro/? operator in Rust. In Go you have to explicitly check the error every time there is a possibility for one with "if err!=nil", repeating the same error handling code, and this makes the code unnecessary verbose and hard to read.
>>
Text editor poll continues
http://www.strawpoll.me/12023125
>>
File: stallman gnu drake.jpg (186KB, 690x460px) Image search: [Google]
stallman gnu drake.jpg
186KB, 690x460px
>>58335669
>Fortran
>APL
>Lisp
>>
>>58336677
/g/neric
>>
>>58336677
Why would you need generic programming facilities if you have a dynamic typing system ?
Btw, Racket and Clojure have optional static type systems which I'm pretty sure allow generic programming.
I don't know much shit about Lisp, but it's famous for its macros allowing metaprogramming, so I don't understand what bother you about it.
>>
Where can I learn how to write makefiles?
>>
>>58336847
Racket/Scheme and Clojure are not pure Lisps, they add additional functionality. These are decent languages, but optional statically strong typing should be mandatory static strong typing with type inference IMO.

You're right in that generic programming doesn't make a lot of sense without static typing, but it should go without saying that dynamic typing is the source of all evil in this world, even Hitler.
>>
>>58336903
>Where can I learn how to write makefiles?

http://wiki.osdev.org/Makefile

http://www.gnu.org/software/make/manual/make.html
>>
>>58336384
I don't have a job, but I want to improve and have things to show. I really don't make anything right now because I can't think of anything to do
>>
File: imagem018.jpg (123KB, 1280x720px) Image search: [Google]
imagem018.jpg
123KB, 1280x720px
lads I had 19,7 in 20 in the test, I'm almost there.

I did beat the cute girl, she was at 19,5.

#pwned
>>
>>58336978
you should do some lifting
>>
File: 1461529211603.jpg (246KB, 643x960px) Image search: [Google]
1461529211603.jpg
246KB, 643x960px
>>58336978
get outta here pajeet
>>
>>58336929
What do you consider a pure Lisp ?
>>
>>58336727
Of course you can. Just match and leave the case for the error empty. Yes, this isn't idiomatic, but ignoring errors in Go isn't idiomatic either.
I consider anything explicit that requires to to do *anything* to say "I am not using this error". Whether you do that via having an empty match case or via _ doesn't matter much. The important thing is that you need to explicitly write anything to ignore the error. The issue with implicitly ignoring an error is that you might forget handling the error, but as long as anything requires you to explicitly handling it, the risk of forgetting to handle the error is greatly reduced.
Yes, this is still an issue with single return value functions in Go.
>>
>>58337060
Guile
>>
>>58337060
Javascript.
>>
File: mens butts.png (32KB, 675x517px) Image search: [Google]
mens butts.png
32KB, 675x517px
>Java
>>
>>58337237
Convenient proxy, not so convenient name.
>>
>>58335299
I was being interviewed for a bank job once.
The guy didn't care about what languages i knew, he only cared how well i knew SQL.
If you learn SQL+Java inside out you can get any pajeet tier job you want.
>>
>tfw static typing will never be complete because of rice's theorem so we'll never be able to write a perfect termination checker
feels bad man
>>
C++ compilers for Apple?
>>
>>58337318
clang
>>
>>58337311
>falling for the turing complete meme
>>
>>58337328
Is that the only option?
>>
>>58337097
> Of course you can. Just match and leave the case for the error empty.
Yeah, I think I overstated my point, you can ignore the fact of an error happening in Rust. What I tried to say is that you can't ignore an error and then continue using returned value as if nothing happened as in my examples above. The only way to get the returned value is to match the Result value, thus checking no error happened. I.e.
match result {
Ok(v) => {
//can use v in this context
},
Err(e) => {
//can't use v in this context
}
}

> The important thing is that you need to explicitly write anything to ignore the error.
This get me thinking, in the code
value, err := maybe_error();
value2, err = maybe_error();
if err!=nil {}

the first err is ignored, yet it isn't explicit at all from the code itself.
>Yes, this is still an issue with single return value functions in Go.
Yea, but the problem with composability is more general. In Rust you can write something like
fn read_username_from_file() -> Result<String, io::Error> {
let mut f = File::open("username.txt")?;
let mut s = String::new();
f.read_to_string(&mut s)?;
Ok(s)
}

to get all the error forwarding you need without any explicit code, because ? operator allows you to compose Result<>'s. While in go analogous code will require at least two explicit "if err!=nil" branches with error forwarding in them. And after you have a possible error in rust you can use helper methods like .and_then or .or_else on it to compose values from different sources.
>>
>>58337340
I guess gcc works, too.
>>
random roll
>>
>>58337340
You can install gcc too, but why would you?

Or any other C compiler.
>>
>>58337346
Well, that's all right then. Maybe Apple isn't so useless as i thought.
>>
>>58337339
sadly every non turing complete language will also not be able to solve many problems that do not require turing completeness :(
>>
I need to learn pyqt, is this book good? Does /g/ have a different recommendation?
>>
File: serveimage.jpg (32KB, 387x499px) Image search: [Google]
serveimage.jpg
32KB, 387x499px
>>58337406
this one, that is. ISBN 0134393333
>>
>>58337406
Yeah. Just download source for pyqt, there's lots of examples there.
>>
>>58337343
>The only way to get the returned value is to match the Result value, thus checking no error happened.
This is correct, the issue in Go would be that at some later point you'd get a panic for using nil somewhere.
In Rust, if we ignore the error however and it does occur, we'd likely get some kind of incorrect behavior as well (caller expects something to happen that doesn't happen).
On the example code you provided, it's true that it isn't immediately obvious and that isn't good, although this essentially stems from := looking very similar to = (which is another issue in itself, I don't like that semantical choice either). However, what's even worse, we can abuse the rules for := to create something even less obvious:
value, err := maybe_error();
value2, err := maybe_error();
if err != nil {}

There's an advantage to := behaving this way, but this example is a clear disadvantage.
The Rust code you provided suffers from a slight disadvantage: While less code, it isn't immediately obvious which functions return errors and which don't. You're losing that kind of information with this kind of control flow, and it can be quite annoying for maintainers when the function isn't as small as your example and doesn't just use functions everyone knows from the standard library.
So the "verbosity" of "if err != nil" isn't completly useless, and I can see it being benefitial for maintainers.
>>
>>58335206
https://youtu.be/AxnotgLql0k
I don't know C++ and/or D enough to make sense of this.
16 minutes in.
That infinite for loop. This code should fail if our element isn't in the array.
Is he relying on exceptions or something? If that were the case wouldn't he have to catch it explicitly?
He does the same thing multiple times throughout the talk.

D looks pretty sweet though.
>>
>>58337564
With an IDE this isn't the case.
The information is in the type
>>
>>58337633
Yup, if we assume that the maintainer is using an IDE (or at least a plugin that provides this) then it isn't as much of an issue anymore and I'd say that it's better that way in any case.
>>
>>58337630
If there's anything I noticed during cppcon talks, example codes during talks often lack safety belts when the talk does not focus on it because you need less code to fit it on the slide, then there's always some smartass in the audience that will try and keep pointing them out.
>>
>>58337694
I think type information should be considered to be as important as colour highlighting
>>
Get to crack on with work, integrating money-grabbing-betting-providers with our stack so we can make them more money.

kms
>>
>>58337630
>>58337734
actually he addresses that one at 29:30~ or something about it
>>
>>58337737
What a coincidence, Rob Pike doesn't like syntax highlighting either.
>>
>>58337564
> In Rust, if we ignore the error however and it does occur, we'd likely get some kind of incorrect behavior as well (caller expects something to happen that doesn't happen).
Btw Rust's Result type has #[must_use] applied to it, so if you just ignore it you get a "unused result which must be used, #[warn(unused_must_use)] on by default" warning. This kinda solves the problem.
> we can abuse the rules for := to create something even less obvious
Interesting. I've tried some simple code before I posted it and it didn't allow me to redefine a variable with :=, so I assumed it will be the same with err.
> it isn't immediately obvious which functions return errors and which don't
If the "?" operator isn't visible enough you can use try! macro, but I think it's good as it is. Also this is exactly the point - to reduce verbosity of simple error forwarding, I don't think there is a benefit from "if err != nil" doing the same all over the code.
>>
Hi, I was asleep for 10 years, so I lost what's new in C++11.

I was a C developer in the past and want to jump into C++. I bought "C++ Primer" but the book keeps saying things I already know, still, I fell that I can't write a proper C++ program. Is there a faster resource or cheatsheet? I don't want to eat 1000 pages of things I know, maybe missing that single page that says what is important.
>>
>>58338026
lambdas
>>
>>58337630
>that vacancy stuff at ~40 mins
that's genius... mind blown
>>
>>58338026
https://en.wikipedia.org/wiki/C%2B%2B11
>>
>>58338087
Yes, but most of those changes are from a C++ standpoint. I don't actually know C++, only C.
>>
/g/ cool kids club checklist

[x] hate OOP
[x] hate IDEs
[x] use only Haskell
[x] never produce actually useful software (this is important)
[x] wear knee socks
[x] tiling window manager
[x] dark-like-my-soul customized colors
[x] hate popular Linux distributions (because too intelligent for them)
>>
>>58337564
Still, even with all these annoyances, I still think Go brought some cool stuff to the table, especially for imperative languages, so here's some shit I like that isn't as popular in other (mostly imperative) languages:
- Structurally typed interfaces, I wish we could have more structural typing everywhere, and not just with verbose C++ templates or OCaml
- The garbage collector focusing low latency over throughput, considering the GC is now at <1ms for 20GB+ heaps
- Fast compilation
- Having no inheritance and replacing it with type embedding (I consider this a better solution than C#'s "make every method non-overridable by default")
- Green threads and CSP, especially because the syntactic sugar for channels is nice (<-chan, ->chan & chan types, ch <- foo & foo <- ch for sending & receiving) and intuitive (I wish other languages with CSP implementations had similar syntactic sugar)
- Having no type hierarchies and prioritizing error values over exceptions (even though it'd be better with sum types and generics)
- Treating every method as nothing but syntactic sugar for a function and being able to use every method like a function
- Having only package-private and public as visibilities (I dislike the choice of capital letters for public though)
- Constant arithmetic having arbitrary size and precision
- ++ and -- being statements, requiring braces for all blocks, no semicolons, initialization in if, break by default in switch-case, no braces for for/if, and a bunch of other shit
- gofmt
Also, lastly, Go repopularized the concept that sometimes duplication is better for readability than abstraction.
>>
>>58335282
Linux doesn't have a standard native theme
GTK is GTK
Qt is Qt
FLTK is FLTK
and so on
>>
>>58338149
0/8.

I write C# in Visual Studio on Windows. I regularly produce and maintain software that companies are using right now, and I don't wear knee socks.

Feels great.
>>
>>58338149
[x] hate OOP
[x] hate IDEs
[x] use only Haskell
[x] never produce actually useful software (this is important)
[ ] wear knee socks
[ ] tiling window manager
[x] dark-like-my-soul customized colors
[x] hate popular Linux distributions (because too intelligent for them)
>>
>>58335247
was checking ocaml and seems a copy of haskell
why to learn ocaml when I can learn the original haskell?
>>
>>58338149
>[x] wear knee socks
There's only one faggot forcing the trap shit on /g/.
>>
>>58338149
[] hate OOP
I literally cannot wrap my head around it
[] hate IDEs
[] use only Haskell
[x] never produce actually useful software (this is important)
[] wear knee socks
[] tiling window manager
[] dark-like-my-soul customized colors
[] hate popular Linux distributions (because too intelligent for them)

1/8
>>
>>58337861
>This kinda solves the problem.
I think it's better to replace warnings with errors in most cases.
In every big project, warnings and laziness regarding warnings piles up very quickly, most developers simply don't care much about warnings, especially if they weren't the ones that wrote the code.
>Interesting. I've tried some simple code before I posted it and it didn't allow me to redefine a variable with :=, so I assumed it will be the same with err.
If one of the variables in the list is new, it'll assign to the ones that already exist and declare + initialize the ones that don't exist yet.
>If the "?" operator isn't visible enough you can use try! macro
I missed the "?" operator, that solves the issue entirely. I wasn't looking for it, so I assumed it doesn't exist, but this is a pretty good solution to the problem, even without an IDE.
>>
>>58338149
[ ] hate OOP //OOP is overused, but I don't *hate* it. I prefer functional shit.
[ ] hate IDEs
[ ] use only Haskell
[ ] never produce actually useful software (this is important)
[ ] wear knee socks
[ ] tiling window manager
[ ] dark-like-my-soul customized colors
[x] hate popular Linux distributions (because too intelligent for them) //I hate all desktop linux distros
>>
Please stop shilling Jew languages like Go and Rust.
>>
>>58338160
Also, while writing this post I found an argument regarding sum types and Go:
https://golang.org/doc/faq#variant_types
They don't seem to work well with structurally typed interfaces.
Now I wonder how OCaml handles this, because it'd be really cool to have both structural typing and sum types.
>>
>>58337842

Syntax highlighting, oh so childish
>>
>>58335769
>There is no "Unix" anymore.
Mac OS X is a certified Unix.
>>
>>58338160
> - The garbage collector focusing low latency over throughput, considering the GC is now at <1ms for 20GB+ heaps
> - Fast compilation
> - Green threads and CSP, especially because the syntactic sugar for channels is nice (<-chan, ->chan & chan types, ch <- foo & foo <- ch for sending & receiving) and intuitive (I wish other languages with CSP implementations had similar syntactic sugar)
> - Treating every method as nothing but syntactic sugar for a function and being able to use every method like a function
> - Constant arithmetic having arbitrary size and precision
> - gofmt
These are the good parts.
> - ++ and -- being statements, requiring braces for all blocks, no semicolons, initialization in if, break by default in switch-case, no braces for for/if, and a bunch of other shit
This is good too, but it's more like fixing C syntax.
> - Having no inheritance and replacing it with type embedding (I consider this a better solution than C#'s "make every method non-overridable by default")
> - Having only package-private and public as visibilities (I dislike the choice of capital letters for public though)
Debatable.
> - Having no type hierarchies and prioritizing error values over exceptions (even though it'd be better with sum types and generics)
Questionable, see the discussion in the thread.
> - Structurally typed interfaces, I wish we could have more structural typing everywhere, and not just with verbose C++ templates or OCaml
I never understood this, this is just like duck typing but there is no reason to use it in a statically typed compiled language, you can just define proper named interfaces/type classes/traits and implement (or not implement) them explicitly, instead of relying on name matching.
>>
>>58338026

https://en.opensuse.org/images/b/b9/C---for-C-programmers.pdf
>>
>>58338335
only because they paid for the certificate, not because it's fully conforming
>>
>>58338351
It is fully conforming.
>>
>>58338351
https://en.wikipedia.org/wiki/Single_UNIX_Specification#Compliance
>>
>>58338337
>this is just like duck typing
Yes, structural typing is just statically typed duck typing.
>you can just define proper named interfaces/type classes/traits and implement (or not implement) them explicitly, instead of relying on name matching.
That's exactly the point. You don't have to define the interface, but you still get the benefit of the type safety. Why define an interface when the compiler can do it for you?
>>
is the newboston tutorials for C++ worth it?
>>
>>58338337
The advantage of structural typing is that users of your library or whatever can simply define their own interfaces for their specific use case.
With nominal typing you define a bunch of interfaces that you think will be useful for your users. Now if your user wants to use a method combination that isn't provided by one of your interfaces, he needs to reimplement the type in some way (e.g. inherit from it and implement the interface, compose the new type from the old type and forward all methods, etc.) or resort to function types for every single method, which don't provide the same comfort as interfaces for objects. With structural typing, your user can just define his own interface and is good to go.
It's a lot nicer than duck typing in dynamically typed languages, because it can actually get checked by the compiler. Only disadvantage in regards to dynamically typed duck typing would be that you have to define an interface, while in a dynamically typed language the interface sort of defines itself through the way you use the value (I thought about this for a bit and to achieve the same in a statically typed language you'd need to get rid of type inference, because it'd otherwise be ambigious).
>>
>>58338440
You still define the interface, you just don't implement it in the original type. See >>58338464 for why the compiler can normally not define the interface for you.
>>
wow OOP is fucking shit
why would one use something like polymorphism?
>>
>>58338455
>is C++ worth it?
no
>>
>>58338550
Subtype-, ad-hoc- or parametric polymorphism?
>>
Does anybody have this?
Tkinter GUI Application Development Projects [Video]
https://www.packtpub.com/application-development/tkinter-gui-application-development-projects-video
>>
>>58338573
subtype polymorphism via inheritance
>>
>>58338440
Because I want to group types not only by accidents of methods names, but by intentional categories I define. For example, I can have a Bow and a Shape interfaces, both having a "draw" method, and I don't want compiler to allow users of my library to use them interchangeably. Even though Go doesn't have generics, I still may wish to define a function what accepts only Shapes I or my users designated as such and not everything you have "draw" defined on.
>>58338464
>The advantage of structural typing is that users of your library or whatever can simply define their own interfaces for their specific use case
Yes, this s a problem with the traditional OOP, but you can do it easily with type classes in Haskell and traits in Rust: you can define your own traits and implement them for outside types without proxy, forwarding or vtables, or you can implement outside traits for your own types without any "inheritance" taking place. And this approach allows you to implement some advanced stuff like Associated Types/Type families, where each type implementing an interface can define types that depends on the type in the context of the interface. For example, Iterator trait has Item type in it to designate the type of values it iterates over, so you can accept only iterators over i32 by bounding the input type to "Iterator<Item=i32>", or you can declare a variable of this type by "let v: I::Item;". You can't have such things with structural type bounding.
>>
>try to set up a just werking c programming environment on windows
wew
please kill me
>>
>>58338837
>being computer illiterate
>>
>>58338837
i tried that, ended up using an IDE(Clion).


It's pretty decent
>>
>>58338550
I just think better in OOP.
>>
>>58338959
>>tfw not intelligent enough for FP
>>
Are web development programmers brain dead?
https://www.npmjs.com/package/isarray
>1 million downloads every day

Does anyone want to guess how many lines of code this simple package is?
var toString = {}.toString;

module.exports = Array.isArray || function (arr) {
return toString.call(arr) == '[object Array]';
};

Literally. This is a function that has 1 million downloads in a single day, that's only one line of code.
>>
>>58338978

Web Devs arent even human
>>
>>58338026
>I was asleep for 10 years
I know that feel. Wish you all the luck in the world, bro.
>>
>>58338959
I think better in FP, and have programmed since the days of Sinclair BASIC.

You need to let go.
>>
>>58338697
Do default methods cause the fragile base class problem?
>>
>>58337042
>>58337033
thats not me nubs im the shoulder and arm
>>
>>58339237
>taking photos of other men
are you gay
>>
>>58339178
Not in the traditional OOP sense, since default methods are defined on a trait and have no access to the internal state of a concrete type implementing the trait, only to the other trait methods.
>>
>>58339267
only on weekends
>>
>>58338550
>polymorphism
Code reuse.

class employee
{
private:
float pay_rate;
string name;
public:
employee(string);
void pay();
void set_pay(float);
};

class manager : employee
{
private:
std::vector<employee> employees;
public:
void hire_employee(string);
void fire_employee(string);
};
>>
> C++

is cmake a meme?

is using it for simple projects overkill?
>>
>>58339367

Who needs classes when you've got structs and interfaces
>>
>>58338194
OCaml is multiparadigm.
>>
>>58339306
Well, the fragile base class problem isn't just related to state, it's just about generally causing incorrectness by changing the implementation of the base class, essentially breaking encapsulation.
Trait contains foo, bar and foobar.
Default method foo calls bar. We implement foobar, calling foo, because we know the implementation of foo calls bar, not foobar. We change the implementation of foo to call foobar. Now we've got a recursion caused by simply changing the implementation of the default method.
This is the exact reason why inheritance is bad, so it confuses me that the issue is present with traits.
>>
>>58336978
19 and 7? In 20? You got 20 divided by 26?
>>
File: 38726475937823.jpg (37KB, 584x326px) Image search: [Google]
38726475937823.jpg
37KB, 584x326px
I need a way to take a concave polygon and turn it into a series of convex polygons. Can anyone help me out?
>>
>>58339510
do you have it as an ordered list? (i.e. each vertex in the list is next to the vertices that it's connected to)
>>
>>58339528
Yes.
>>
>>58338047
I'm really surprised that it took that long for that to be a thing. It's something I do regularly for practically any situation where I pickup modify and place data.
Though that's for convenience generally, not to avoid tests.
>>
I need ideas for my toy assembler. :)

https://github.com/jtzeng/herontitan
>>
>>58339403
Classes assist heavily with RAII programming. Thus you don't need a garbage collector for a hello world program.
>>
>>58339535
break it into triangles

one way is to check if (i, i + 1, i + 2) is a valid component triangle (i.e. its edges don't intersect the polygon), and keep doing that until you have all the triangles
>>
>>58337805
Nah that just explains why he's using what's essentially a goto.
I'm surprised that nobody explained this to me. I'm still confused about it.
I suppose the only option left is to a D compiler and debugger and figure this out.
>>
>>58338837
Install Windows SDK + build tools (or the DDK), launch a command line window with vcvars, compile/link with cl.exe, done.
Alternatively install mingw, launch mingwvars and use gcc.
What's the problem?
>>
File: mens' asses.png (15KB, 565x337px) Image search: [Google]
mens' asses.png
15KB, 565x337px
>>58335192
A language that doesn't use punctuation. Rather, common terms for that punctuation are used.
>>
>>58339559
>raii
Disgusting.
If you're not doing proper MMM you can fuck right off with any opinion you have on GC vs non-GC anon. You're the portion of programmers doing non-GC that'd likely benefit from it.
>>58339367
>code reuse
No that's not a proper reason. The reason for polymorphism is to assist oop or for control flow reuse. I.e. You don't have to re-write every switch case in your program when you add a new type.
>>
>>58339535
Well, triangles are always convex, so you can satisfy your requirements by always choosing triangles.

I think the big problem to solve is making sure that you only add lines that don't cross over other lines. If you can write a function that tells you whether a line crosses over any of a list of other lines, then I think the hard work is done. After that, just write a function that adds lines by connecting any two previously-unconnected vertices, but only if the new line doesn't cross over an existing line. Once you exhaust all the possibilities, then you should have the shape decomposed into all triangles.
>>
>>58338455
Thenewboston is a mediocre resource. Teaches poor habits, such as terrible variable names. e.g. Bucky Tuna etc
>>
>>58339380

>is cmake a meme?
No. It is semi-popular, but that popularity is not undeserved.

>is using it for simple projects overkill?
Also no, especially if that project grows in size, and build requirements become quirky. I thought at first that CMake was going to have quite a bit of intellectual overhead, but it's actually pretty simple, yet powerful.
>>
>>58339587
static string MyMethod Frown Smile
Sneer
string tree Equals Quote Quote Wink
int spaces Equals 30 Wink
int balls Equals 1 Wink
for Frown int i Equals 0 Wink i Mouth Equals 30 Wink i Plus Plus Smile
Sneer
for Frown int a Equals 0 Wink a Mouth spaces Wink a Plus Plus Smile
Sneer
tree Plus Equals Quote Quote Wink
Smirk
spaces Dash Dash Wink
for Frown int b Equals 0 Wink b Mouth balls Wink b Plus Plus Smile
Sneer
tree Plus Equals Quote Star Quote Wink
Smirk
balls Plus Equals 2 Wink
tree Plus Equals Environment Dot NewLine Wink
Smirk
return tree Wink
Smirk
>>
>>58339587
Why?
>>
>>58339645
What do you mean?
>>
>>58338837
>just werking
IMO the easiest way to go about it is to just install [insert visual studio version here] and start empty projects.
Point msbuild to your .sln and compiler or run from within visual studio.

Mingw gcc is also an option but it's worse when you need to be more serious than compiling hello world.
>>
>>58339653
What is the point?
>>
I'm making a list datatype in C, I'm having some trouble with my struct.
I'm trying to store an integer value in the struct by having a void pointer point to it but I get "Assignment makes pointer from integer without a cast" warning.
typedef struct
{
void *data;
struct list *link;
} list;
list *temp = malloc(sizeof(list));
temp->data = 2;//Warning
I know I could just have an int instead of a void pointer in the list struct, but I can't do that because of my assignment rules.
>>
>>58339380
>overkill
No its not. It's very simple. But it really annoys me that C/C++ are so cruddy they need external build tools generally.
>>
>>58339661
data is a pointer
2 is an int
>>
>>58339658
It's a language that allows you to program without punctuation, so you only need letters for your keyboard.

It might save 3rd-world countries money in the public sector for hardware costs.
>>
>>58339675
just use the C preprocessor
>>
>>58339661
>temp->data
Data is a pointer. Currently it points to uninitialized memory (nothing sensible, depending on your environment it could be null). It hasn't gotten any memory allocated for it.
Do temp.data =malloc(sizeof(int)); so it has some memory.
>>
>>58339668
The void pointer is so your list can store ANY data, not just an integer, but the other consequence of this is that you need to think about allocating/deallocating memory for this pointer separately from the list nodes.

list *temp = malloc(sizeof(list));
temp->data = malloc(sizeof(int));
*temp->data = 2;
/* ... when done ... */
free(temp->data);
free(temp);
>>
>>58339661
*(temp->data) = malloc(sizeof(int));
*((int*)temp->data) = 2;
>>
>>58339474
Well, yes, this can be a problem, but it isn't specific to traits, you can have the same cycles with standalone functions.
>>
>>58339661
If you want to be able to store both ints and pointers in the same object you're gonna need some way to disambiguate them since an address is just a number.
You could add another field to your struct and use that as a type tag, or if you wanna be sneaky steal a bit from the pointer and use that as a flag - the lowest few bits (4 at least) will always be cleared on any pointer returned from malloc because of alignment.
>>
>>58339717
>>58339722
>->
Guys this is derferencing two pointers. First the list and then data. Please stop. You're only gonna confuse him.
>>
>>58339757
Nothing confusing about this at all, he has a pointer which points to a pointer, there's no way around dereferencing two pointers aside from a hack like storing the int value in the pointer variable, and aside from the non-portability, it won't follow his assignment.
>>
>>58339733
That's a different kind of issue.
In the case of standalone functions, you directly reference whatever code you're calling, but with default implementations, the trait isn't actually referring to that other code.
Say you've got a library foo and that library has a thousand users. With standalone functions, only those users that foo is referring to would be affected, while with default implementations, any user could potentially be affected.
That's why it's called the "fragile" base class problem, because any superclass *may* break if you change the implementation of one overridable method. With default implementation the issue is exactly the same. With standalone functions, you know exactly which users might break: The one you referred to before and the one you are now referring to.
Also, regarding your comment on state earlier: Rust allows side effects, so there's still a bunch of issues.
HOWEVER, it's less of an issue than the traditional OOP problem, because default implementations in Rust are probably normally frozen and they aren't used commonly for anything but the complement.
>>
doing architecture and design

identified a race condition but don't know how to avoid it
i think i'll just sweep it under the rug
>>
>>58339891
>architecture
>race conditions
You already failed.
>>
>>58339656

VS is a pain when you need to compile any open source library at all and get it to work fine. MinGW just works, and there is no reason it should not just work for larger projects, as it functions identically to how GCC does on Linux.
>>
File: ?.png (7KB, 120x120px) Image search: [Google]
?.png
7KB, 120x120px
guy A is discussing with guy B a subject C.

what's the name of the fallacy where guy A starts attacking on guy B on a complete different matter, rather than refuting the current argument?
>>
>>58339890
> In the case of standalone functions, you directly reference whatever code you're calling, but with default implementations, the trait isn't actually referring to that other code.
You're right, except maybe for the libraries relying on callbacks.
> Also, regarding your comment on state earlier: Rust allows side effects, so there's still a bunch of issues.
I meant that since there is no actual base class with an internal state in this case, the only way for the default methods to change the state of an object is via the non-default methods and thus the type itself can control the changes in its state. As I understand this is one of the problems with FBC in traditional OOP.
> HOWEVER, it's less of an issue than the traditional OOP problem, because default implementations in Rust are probably normally frozen and they aren't used commonly for anything but the complement.
I guess so. Also you can just reimplement the default methods for your type if you don't want to rely on them not changing in the future.
>>
>>58340010
straw man
>>
>>58340010
Red herring.
>>
>>58339980
and design
real life isn't like in your textbooks where all the steps are clearly defined and separated

anyway i found out how to limit the effects, now instead of critical failure i have an easily recoverable failure
>>
>>58340010
Strawman? Depends on the specifics a little.
>>
>>58340051
>write software
>race conditions plague your code
>"b..but it's recoverable.
That's not how real life works.
>>
>>58339891
A lock?
>>
I'm not confident that this is the right thread, but I'm big on making software to automate work-related tasks, games, or pretty much anything else, but I typically do this using techniques like pixel color checking. If I need to interact with data, I usually have to have the bot copy the data to the clipboard and process it from there. It's a little clumsy, but I think it's unavoidable when it comes to automating compiled software.

I want to make a few programs which will automate online tasks, and I figure that since the page source is available to me, I should be able to manage these tasks in a more elegant way. I have zero experience with programming webpages or having them interact with software, so I don't have any idea of how to do this.

I want to have the software read the HTML/CSS of the page, work out what's there, assess what it needs to do, then submit forms (ideally) without actually having to click on buttons, scroll up/down, fill out text boxes, etc.

Essentially, I don't want to make another bot which just takes over the mouse+keyboard and does things "the human way but faster" - I want to be interacting with the page source.

How feasible is this? Should I just try to do it in Greasemonkey, or is there a better way? Are there any good tutorials/books on this?
>>
>>58340093
yeah it would be great if i could lock the resource and then unlock in the future
>>
>>58340010
Goal shifting?
>>
>>58340010
If it's an extension of the subject with additional requirements, it's moving the goalpost.

Need more context.
>>
>>58340051
True, but that's also no excuse for shitty architecture. If you designed your code properly you certainly shouldn't be discovering surprise race conditions.
>>
>>58340111
Mutex?

google this you fucking idiot
>>
>>58340107
There are many variables that need to be determined before a good answer to this is given.

First and foremost, are you absolutely certain that the website does not have APIs? Is this some sort of game bot or ad spam?

There are absolutely ways to automate submission of web forms without controlling the mouse/keyboard, as long as they're not generating fucktons of dynamic content for the page.

Any modern language with plenty of libraries would be fine for this.
>>
>>58340038
With callbacks it's pretty obvious that they're being called, though.
State can be affected as well, assuming there are accessors defined by the trait, for instance.
Access to state may be indirect, but there may be resulting incorrectness related to state.
>Also you can just reimplement the default methods for your type if you don't want to rely on them not changing in the future.
Yeah, that's a similar solution like not overriding anything in traditional OOP languages.
By the way, this issue is obviously present in Haskell as well, but in an even more limited scope due to the lack of side effects. Infinite recursions (the most trivial to detect and probably common issue caused by the fragile base class problem) are still possible, though.
>>
>>58340124
>>58340116
>>58340066
>>58340047
>>58340040
yeah it might be a strawman or goal shifting

the example is: "John and Bill are discussing soccer players salaries, when Julian, a really fat person, contributes something to the discussion and John calls Julian a fat lard ass, instead of discussing with him his viewpoints"
>>
>>58339661
In code where I'm working with a void* and I know the type it should store I generally make a variable for a pointer with the correct type.

int *data = malloc(sizeof *data);
temp->data = data;
*data = 2;
>>
>>58340107
There are ready made tools and frameworks for that, Selenium is a popular one.

But if you wanna do it from scratch you just need to write a simple http client which makes the appropriate requests.
>>
>>58340143
i have a thread and it would be great if i could use something like
thread_lock(&something)

do_stuff()

thread_unlock(&something)
>>
>>58340234
I told you to fucking google it
>>
>>58340211
Well, that's just Ad Hominem then.

The fact that John and Bill are discussing something doesn't factor in here.

Also, not programming.
>>
>>58340234
You're literally retarded.
>>
>>58340234
HMM I WONDER IF THERE'S A WAY TO ACCOMPLISH THIS BEHAVIOR
>>
How can i change an array of strings in a C function?

It is important that the array is being passed to the function as a double pointer ("**").

void str_to_strarray(char* string, char** arr) {
arr[0] = "awdawda";
}

int main(void) {

char arr[4][10];

printf(arr[0]);

return EXIT_SUCCESS;
}
>>
>>58340266
>>58340253
>>58340250
wouldn't be great if something like that could be done?

many applications would benefit from this
>>
>>58340284
my code does not work btw. It prints gibberish
>>
>>58340286
Annoying Anonymous can't even keep his data safe from other threads. Sad! Can't even Google the answer.. Many such cases!
>>
>>58340302
You're never calling str_to_strarray()
>>
File: 437594387953453.png (138KB, 1188x1548px) Image search: [Google]
437594387953453.png
138KB, 1188x1548px
>>58339569
>>58339622
Thank you, this was a big help. My pseudo-solution is pic related. However, the part of checking if a triangle is within the polygon is difficult for me. Checking if the line intersect will be easy.

My other problem is that some of these polygons could be hundreds of vertices and it would be very beneficial if I could get the minimum number of convex polygons out of it.
>>
>>58339489
u a clever nigga, how bout i bust a nut in your mum pretty boi
>>
>>58340328
I am a retard. Thanks
>>
>>58340286
It can't be done, it's an unsolved problem in computer science.
>>
>>58340356
This. It's NP hard.
>>
>>58340329
http://mathoverflow.net/questions/60212/partitioning-a-polygon-into-convex-parts
https://en.wikipedia.org/wiki/Polygon_triangulation
>>
>>58340234

https://msdn.microsoft.com/en-us/library/windows/desktop/ms686345.aspx
>>
>>58340356
>>58340360
i thought so too.

well, i have to find a workaround then
>>
Squirt In My Gape 5
any good?
>>
>>58340163
>are you absolutely certain that the website does not have APIs?
I'm reasonably confident that everything I'll be doing is on static webpages. I guess it makes sense that this would be an issue, but I hadn't really considered it. Goes to show how green I am.
>Is this some sort of game bot or ad spam?
One of the programs I'd like to make in my spare time is to automate a simple browser game which is, as far as I can tell, just HTML. More of an exercise in programming than anything useful. The work-related stuff I'm planning on making immediately isn't ad spam, but I guess it's mechanically similar - fill out the same form lots of times with minor permutations. I might complicate it more depending upon how intuitively this comes to me.

>>58340232
>Selenium
This looks promising. It looks like they even have a tool to help me work out the structure of the forms I'd need to submit. I'll give this a go, thanks.
>But if you wanna do it from scratch you just need to write a simple http client which makes the appropriate requests.
I have no idea how to do this, but it seems like it might be worthwhile to learn. Do you have any good resources on this?
>>
>>58340010
Not everything is a fallacy. He's just changing the subject.
>>
>>58340505
if i can't name the fallacy he used how can i prove he is arguing wrong
>>
>>58340395
A great way to avoid race conditions is to copy the data, do all the work that doesn't modify the data. Check that the data set is the same as the copied version and then if it is you proceed.

It gets you there most of the time but not all the time.
>>
>>58340536
It's a tough one. An unsolved problem in rhetoric.
>>
Why they all say java is bad? What are its cons?
>>
>>58340592
you are trolling right?
>>
>>58340592
What are its pros?
>>
>>58340621
Tons of support, jobs, frameworks, libraries, and compatibility.
>>
import hashlib, ssl, sys
print(hashlib.sha256(ssl.PEM_cert_to_DER_cert(ssl.get_server_certificate((sys.argv[1], int(sys.argv[2]))))).hexdigest().upper())
>>
What can i use to detect collision between 2 textures in a game in java(libgdx)? I tried to make recangles with the same coordinates and dimensions of the textures and use if(rect.overlaps(rect2)) but it only works the between 2 rectangles or 2 circles(2 shapes of the same kind), and it seems the wrong way. Is there a better way?
>>
File: 01.png (49KB, 800x660px) Image search: [Google]
01.png
49KB, 800x660px
Reverse engineering a custom compression format so I can spoil people on what cute anime girls die first.
>>
>>58340655
print(
__import__('hashlib').sha256(__import__('ssl').
PEM_cert_to_DER_cert(__import__('ssl').
get_server_certificate((__import__('sys').argv[1],
int(__import__('sys').argv[2]))))).hexdigest().upper()
)
>>
>>58340356
>>58340360
>>58340395
>>58340553
just use a fucking mutex don't let these retards troll you

>>58340592
they are mad jelly fedora tippers who are too stupid to understand java. java is the #1 programming language. it doesn't have that many real disadvantages. java and C++ are by far the best programming languages imo. they're the best choices for almost all serious applications.
>>
>>58340648
quality over quantity
a mountain of shit is just a slightly bigger pile of shit
>>
>>58339638
>>58339667
It's kind of simple to use, but the mess it automatically generates is pretty impressive and not at all human readable.
>>
>>58340607
No, just don't know much about programming

>>58340621
I can make android apps.
>>
>>58340592
Try converting a List<Integer> to int[].
>>
>>58340702
>using __import__()
was gonna do this but i think it's less efficient and also longer
>>
>>58340750
I don't even know the differences between an array and a list
>>
>>58340724
you can make android apps with javascript

wahts your point?
>>
>>58340708
I can't imagine what a turgid existence yours must be if you separate every single thing mentally into "great" or "shit".

I don't like Java. I don't care for it at all, but if my primary motivations were to expose myself to as many jobs as possible, I'd pursue it.
>>
File: 1474332185675.png (176KB, 437x556px) Image search: [Google]
1474332185675.png
176KB, 437x556px
>>58335192
>send a couple of mails last friday to apply for a C# position
>they haven't respond
Welp, guess the programming gods don't want me to stop being a neet.
>>
>>58340769
No worries my friend! We've set up a special place for you
>>>/g/wdg
>>
>>58340778
don't worry

they don't see sharp the mails they receive
>>
>>58338149
[] hate OOP
[] hate IDEs
[] use only Haskell
[x] never produce actually useful software (this is important)
[] wear knee socks
[] tiling window manager
[] dark-like-my-soul customized colors
[] hate popular Linux distributions (because too intelligent for them)

Well at least i got the important one.
>>
>>58340778
>apply to one job
>if they don't hire me I have to be a NEET

What the fuck is wrong with you?

Apply to 30 jobs, and if you don't even get an interview, you need to SERIOUSLY evaluate your value proposition as portrayed by your email/resume.
>>
>>58340777
Exactly, the only reason to use Java is because it's popular.
And the reason it's popular was because of a huge campaign, which has obviously paid off, and not because of any actual benefits to using Java.

http://www.cs.utexas.edu/users/EWD/OtherDocs/To%20the%20Budget%20Council%20concerning%20Haskell.pdf
>>
>>58340675
https://en.m.wikipedia.org/wiki/Gilbert–Johnson–Keerthi_distance_algorithm
Probably the simplest.

But if all you have is circles and rectangles you could just do AABB by setting a basis that axis aligns the rectangle sides and then do a point comparison between the circle center and box.min-radius and box.max-radius.

But that's an odd kind of lazy where if you're not already comfortable with collision checking gjk is easier to implement.
>>
>>58338149
[x] hate OOP
[x] hate IDEs
[ ] use only Haskell
[ ] never produce actually useful software (this is important)
[ ] wear knee socks
[x] tiling window manager
[x] dark-like-my-soul customized colors
[x] hate popular Linux distributions (because too intelligent for them)
>>
File: dijkstra.png (44KB, 643x220px) Image search: [Google]
dijkstra.png
44KB, 643x220px
>>58340814
specifically what this paragraph says about Java
>>
>>58340814
there are many reasons besides popularity to prefer java over haskell. haskell FUCKING SUCKS you fucking moron
>>
>>58340814
Being popular adds tangible benefits to any programming language, dumbfuck.
>>
>>58340792
hehe
>>58340801
Yeah, I definetely need to apply at more companies, the thing I don't know is how much they take to respond emails, or if they're stacking all of the appliers and then choosing the best option (which might take a while).
>>
>>58340771
Games also?
And i don't have a point, just want to know why java is "bad"
>>
>>58340839
Look, I get that you've never heard of Dijkstra, and I'm not arguing for Haskell in this, I'm arguing against Java, which is an utterly shit language.

>>58340842
Being popular is THE ONLY BENEFIT.
Why is it popular? Paid advertising campaign.

IN EVERY OTHER REGARD, JAVA IS ONE OF THE WORST PROGRAMMING LANGUAGES EVER CREATED
>>
Holy fuck.

http://codegolf.stackexchange.com/questions/1956/generate-the-longest-error-message-in-c/10470#10470
>>
>>58340861
>everything is references
>everything is classes
>everything is verbose
>everything is methods

It's like someone took all the worst ideas and put them into one language
>>
Imagine if operating systems were sort of sane and provided ways of restricting your application to a specific API where everything is just easy to do and you don't have to worry about stupid shit some moron thought was a good idea 10 years ago.

I just wanted a frame buffer, a circular sound buffer, a way to get some memory and a way to read the keyboard state.

And that's somehow more than 4 pages of code.
It should be less than 10 lines.
>>
>>58340783
kek
>>
>>58340868
>putting one academic on a pedestal
it's literally one guy's opinion, and it's from 2001, java has evolved a lot since then, it even has functional features which were inspired by haskell

>>58340861
java is not bad, it's infinitely better than javascript especially for games
>>
>>58340868
>Being popular is THE ONLY BENEFIT.
Popularity provides tangible benefits.

For one, more people that may have had the same issue you're dealing with, so more easily searchable blogs/forum posts/StackOverflow posts.

As stated before, more support, frameworks, libraries, and compatibility.

I'm not saying Java is a good language, but popularity is a benefit that begets other extremely important qualities in the name of Getting Shit Doneâ„¢.
>>
>>58340905
>it's literally one guy's opinion, and it's from 2001, java has evolved a lot since then, it even has functional features which were inspired by haskell
It added generics and lambdas
Do you know what those two features mean?
You can ignore EVERY OTHER PART OF THE LANGUAGE.
You SHOULD ignore EVERY OTHER PART OF THE LANGUAGE.
>>
>>58340814
>>58340868
>2001

AHAHAHAHAHAHAHAHA FAGGOT
>>
>>58340930
Dijkstra died in 2002 you fucking muppet

>>58340924
To some degree, but Java is not a "getting shit done" language
>>
>>58340702
I will just let this here:
import Text.CSV

-- Parses a CSV file
main :: IO ()
main = do
let fileName = "input.csv"
input <- readFile fileName
let csv = parseCSV fileName input
either handleError doWork csv

handleError csv = putStrLn "not a CSV"
doWork csv = (print.findOldest.tail) (filter (\x -> length x == 2) csv)

-- Finds oldest person.
findOldest :: [Record] -> Record
findOldest [] = []
findOldest items = foldl1 (\a x -> if age x > age a then x else a) items

age [a,b] = toInt b

toInt :: String -> Int
toInt = read


import pandas as pd 
table = pd.read_csv("input.csv")
print(table[table.age==max(table.age)])
>>
>java
It's not bad to any degree most programmers here would be noticing.
>b-but it's verbose
It's standard library is. It's function headers are.

But for actual programming it's not.
>>
>>58340957
>Java is not a "getting shit done" language
yes it is, especially for large teams
>>
>>58340819
Easy
>>
>>58340961
Wow, it looks as if you haven't made any changes whatsoever to this after the previous 2 times that you posted it and were corrected with working, shorter equivalents!
>>
>>58340957
>Dijkstra died in 2002 you fucking muppet
Not a fucking argument. His 2001 opinion was not based on the state of the language in 2017.
>>
>>58340778
>>58340801
HR guy here.
We never answer immediately to applicants. We let just think that they are worthless and don't deserve the job, so we can hire them later at half price.
>>
>>58341003
Further proof that HR is the scourge of capitalism.
>>
File: meme hell.jpg (78KB, 500x500px) Image search: [Google]
meme hell.jpg
78KB, 500x500px
>make C program in pure suckess.org aryan coding style master race
>compiles flawlessly, zero warning
>add -Os in the Makefile CFLAGS
>GCC now gives me -Wunused-result on fgets
How can GNU get away with this?
>>
Need some help guys.
Got this java program to take a string, reverse it then compare to see if it's a palindrome, but it doesn't Work. Returning false everytime, any help?
import javax.swing.JOptionPane;

public class Palindrome{
public static void main(String args[]){
String palindrome= JOptionPane.showInputDialog(null, "Input palindrome");
String reverseP = new StringBuffer(palindrome).reverse().toString();

if(palindrome.equals(reverseP){
System.out.println("Palindrome detected!");
}
else{
System.out.println("No palindrome found");
}
}
}

>>
File: 89127581564728.png (8KB, 942x90px) Image search: [Google]
89127581564728.png
8KB, 942x90px
Is Javafag here?
>>
I think I just yesterday started "using Linux seriously" and already I've decided the whole NumLock KeyPad function was to be set to mouse pointers and common mouse pointer actions like maximize, close, minimize, move up ( for windows ), move back, fillHeight, fillLength, setAside. No zoom, becuase mouse wheel.

It makes everything so much easier about dealing with windows. I even set time restrictions on my typing so that I'd take it easy and not type so callously. I'm already feeling calmer. I may move on to vim next.
>>
>>58340900
Again, i'm completly ignorant, but it seems good to create methods you can re-use everytime you want
>>
>>58340996
you didn't managed to make it work correctly. If I find the pic of the thread I will post them, they are pretty funny.
>>
File: AHAHAHA.gif (491KB, 500x220px) Image search: [Google]
AHAHAHA.gif
491KB, 500x220px
>>58341028
>new StringBuffer(palindrome).reverse().toString()
>java
>>
>>58341033
not javafag but das is true

except oop has nothing to do with the actual spec for enums and this is all just a side effect anyway. Haters.
>>
>>58341035
I have no clue what you're trying to say.
>>
>>58341028

well what inputs are you using?

call .toLowerCase on both strings
>>
>>58341048
Worked on my end perfectly fine.

Here's an alternative
https://www.fpcomplete.com/blog/2016/09/data-haskell
>>
>>58341028

you are missing a bracket in the if statement
>>
>>58341056
Ah yeah fuck me man I'm so sorry I'm trying to use the language my uni teaching me

>>58341069
Am testing it with strings like "madam" and "yay" but i'll add .toLowerCase

>>58341087
Yes
thank you so much
>>
>>58341048
>>58341083
oh, and I forgot

>table[table.age == max(table.age)]
>>
>>58341056
>less verbose than C
>100x faster than python
problem?
>>
>>58341083
doesn't functional imply referential transparency? why would work on some data and not on another?
>>
>>58341056
Well it serves to serve consts. It could just be a keyword evaluation tool. Summin call a standard lib?
>>
>>58341109
Use C# instead
>>
>>58341121
I don't know why it didn't work on your end
>>
>>58341109
This is Daily Programming Thread, not Daily Coding Thread.
>>>/out/
>>
>>58341133
>C#
pleb taste
>>
>>58341144
One of the absolute best langugaes out their freindo
>>
>>58341133
>C#
great taste
>>
>>58341150
so is java
>>
New thread:
>>58341182
>>58341182
>>58341182
>>
>>58341198
lamda value: value[1]
or
\v.v[1]

a function, that given some argument v, returns v[1]

presumably your sorted function then uses this key function to extract the value to sort by
>>
>>58341056
all you need to do is

[]i ME[]iNTALLY []i//
__Mmni jiji()|}:/""''

multiply the whole design from the c interface by x^3 ( of course you call it something else ) and you set the new interface on a scale proportional to that increase except it only applies as growing and so is either already "further out" or is "really fat".
>>
>
[]i ME[]iNTALLY []i//
__Mmni jiji()|}:/""''


God damn, Haskell looks disgusting.
>>
>>58340837
>trusting skeletals
L M A O
>>
>>58341198
I don't know this language but I've got to guess that
lambda value: value[1]

is a lambda function... this is an expression that evaluates to a function, the function here has one parameter: value, and just returns value[1].
>>
>>58341028
Is equals a compare function or is it one of those 'same object' comparisons oop is so fond of?
Thread posts: 336
Thread images: 25


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