[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: 325
Thread images: 20

File: whensomeonetalksd.png (243KB, 594x318px) Image search: [Google]
whensomeonetalksd.png
243KB, 594x318px
What are you working on, /g/?

Previous thread: >>61722378
>>
Bought 25 Raspberry Pis and I'm gonna make a concurrent FizzBuzz
>>
File: 41234234123.jpg (54KB, 610x448px) Image search: [Google]
41234234123.jpg
54KB, 610x448px
>What are you working on, /g/?
Improving my programming ability.
>>
File: 1406803019377.jpg (103KB, 1280x720px) Image search: [Google]
1406803019377.jpg
103KB, 1280x720px
FUCK YOU OP.
I fucking asked you to post an anime image this thread, and you didn't.
Make it again.
>>
I'm going to start a project where I don't expect a big number of contributors. My options for choosing the primary language are as follows.

1. Use a language in which I am not comfortable with, but it is massively popular and has tons of libraries but at the same time somewhat counter-productive.

2. Use a language that I am most comfortable with, but it is very unpopular and library count is very limited but I can stay comparatively more productive since I know it well.
>>
>>61726362
Sorry my man, just woke up
next time
>>
>>61726368
No, this time.
Delete the thread.

>>61726366
Always pick C.
>>
>>61726376
That's a weird way of spelling C++
>>
>>61726376
>Always pick C.
Discarded. Serious answerers only, please.
>>
>>61726366
>Use a language in which I am not comfortable with, but it is massively popular and has tons of libraries but at the same time somewhat counter-productive.
Sounds like the definition of Javascript
>>
>>61726388
I'm serious. If you want your open source program to be taken seriously, it has to be written in C.
>>
>>61726382
Depends on how capable your contributors are.
Good C++ > Good C > Bad C >>>> Bad C++
>>
>>61726382
C++ can be counter productive if it's a one man show
>>
>>61726344
nothing.

I need project ideas in C or Perl
>>
>>61726395
Welcome to C, where we take pride in writing 50 lines for the program that are just one liners in other languages
>>
>>61726407
machine learning DNN whatever thing that can detect whether a qt trap or a 3DPD is present in a picture
>>
>>61726344

>no anime image

d r o p p e d
r
o
p
p
e
d
>>
>>61726396
>Good C++
That's an oxymoron.
>>
>>61726407

idea guy here

make an image board
>>
>>61726458
https://gist.github.com/bkaradzic/2e39896bc7d8c34e042b
>>
>>61726484
>C with classes
No, that's not good C++.
>>
>>61726484
By definition all C++ code is terrible, so "good C++" can not exist.
>>
>>61726463
Not big into web development

>>61726432
that sounds like something I'd need a decent server to get working properly, even if I knew how to make it.

Am I just making excuses? who knows.
I'd like to do operating system related stuff. What's some entry level project I could do to get into kernel development?
>>
>>61726511
>All C++ code is terrible
>Thus all of the common C/C++ subset is terrible
>Thus the vast majority of C is terrible
>>
>>61726543
>>Thus the vast majority of C is terrible
C and C++ have different semantics, even for what would be syntactically the same code.
They should not be considered the same program, because they are demonstrably not.

Also, most C programs does not compile as C++, idiot.
>>
>>61726558
that's wrong. Many of them compile with warnings. C++ just forces you to be more careful with pointers usually, this is the main thing that wouldn't let it compile.
>>
>>61726362
Andrei's anime
>>
Can I write unit tests for C code in bash or Perl?
>>
>>61726611
No, he's a necrophile.
>>
>>61726620
Proofs?
>>
>>61726620
negrophile?
>>
>>61726629
He's been "working on" the same corpse for 15 years.
>>
>>61726616
>unit tests
I guess you technically can, but it would need to generate code that compiles and links with your own code, so it's going to be more complicated than to just use one of the existing C unit test frameworks that already exists.

But for integration testing, validation testing and system testing (as well as regression testing), it's preferable to use some form of scripting language.
>>
>>61726558
>C and C++ have different semantics, even for what would be syntactically the same code.
Rarely. Outside of void* usage, the C constructs which are not C++ constructs or behave differently as C++ are all edge cases.

Do you believe that the only code which is good C code is the code which does not compile as C++?
>>
File: proofs.png (67KB, 887x95px) Image search: [Google]
proofs.png
67KB, 887x95px
>>61726629
>>
>>61726642
D's not dead though
>>
>>61726666
AHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHHAHAHAHHAHAHAHHAHHAHHAHHAHHAH
>>
>>61726666
It's worse than dead, it's stillborn.
>>
What is the best programming language, and why is it Python?
>Highly readable
>Fantastic range of libraries
>Elegant integration of OOP features
>Smaller memory footprint than C++ and Java
Guess I answered my own question.
>>
File: 94829472134782342.jpg (14KB, 325x258px) Image search: [Google]
94829472134782342.jpg
14KB, 325x258px
>>61726674
>>Smaller memory footprint than C++ and Java
>>
>>61726674
>>Elegant integration of OOP features
dude self lmao
>>
>>61726670
>>61726671
Error: Argument not found
>>
>>61726674
>Elegant integration of OOP features
>self, self, self, self
>Smaller memory footprint than C++ and Java
>
I lol'd
>>
>>61726704
You can count the total number of D users using 2 bits.
If that's not dead, I don't know what is.
>>
>>61726719
Proofs?
>>
>>61726719
What language do you suggest?
>>
File: 981391283921312.jpg (13KB, 300x169px) Image search: [Google]
981391283921312.jpg
13KB, 300x169px
>>61726725
>>
>>61726719
argumentum ad populum
>>
File: 1478455372790.gif (2MB, 300x300px) Image search: [Google]
1478455372790.gif
2MB, 300x300px
>>61726727
>>
>>61726362
>I fucking asked
Don't ask.
Just post.
>>
>>61726652
This guy does it in Python https://www.youtube.com/watch?v=zW_HyDTPjO0 so I thought why not bash.
I'd like to change my C code as little as possible. Any bash or Perl tools to load a function given its name, whether from the compiled code or source, run it with given parameters and output its output? Something like cffi, I guess, as used in 4:30.
>>
>>61726735
We're not talking about it being good, we're talking about it being dead.
>>
>>61726739
not an argument
>>
>>61726674
>Highly readable
>source uses tabs
>you use spaces
>
I N D E N T A T I O N  E R R O R
>>
>>61726764
Languages are not alive
>>
>>61726725
Just google it.
>>
>>61726745
Thanks for the video, I wasn't aware that any non-C unit test frameworks existed.

This is going to make my life a lot easier.
>>
>>61726776
>>61726726
>>
>>61726776
Well shopped my friend
>>
What is the best programming language, and why is it Haskell?
>Dude monads lmao
Guess I answered my own question.
>>
>>61726620
>>61726642
>>61726670
>>61726719
>>61726776
Did you think it's going to be funny?
>>
>>61726811
I didn't edit that picture, aside from cropping my screenshot.
>>
>>61726778
I think this is possible with any group of languages that can call one another's functions.

Also there are unit test frameworks for bash so all I need to test C code in bash is basically to load C functions.
>>
say i have a multidimensional array A [i,p]
in c#, is it possible to access the A[p] and change the value of A[p] only?
>>
>>61726834
Suuuuure, all you did was "crop" it
>>
>>61726849
you do not understand what a multidimensional array is
>>
>>61726832
Do I think what's going to be funny?
>>
I'm struggling to understand interfaces and abstract classes in Java. I know those rules of them, but I just don't understand them in terms of the 'bigger picture' kind of thing. Like, when would I be using them? Why would you use them over inheritance, nested classes, or 'protected' classes/fields/methods? I don't know what to do with them and I can't seem to piece it together in my head.

Are there any good books or videos that explain this stuff for idiots? I just can't get my head around it.
>>
>>61726879
a n-dimensional array is basically just a floor(n/2)-dimensional array of floor(n/2)+1-dimensional arrays
>>
Anyone got an idea for a project that would be useful for me to do? I'm thinking about doing rust or javascript.
>>
>>61726953
create your own esoteric language and write an interpreter (+IDE) for it
>>
>>61726879
yes i don't
any good links so that i can understand multidimentional array and jagged array?
>>
>>61726953
>No mention of skill level and fields interested in
Write an x86-64 emulator.
>>
>>61726953
Get a non-trivial pull accepted into Linux.
>>
>>61726964
>>61726986
>>61727000
U S E F U L
>>
In a Lua program, I need to make a hundred buttons response to mouseovers.
This means binding a hundred events.
How can I do this iteratively?
All the buttons are in an array.

The difficulty lies in binding those events iteratively such they produce unique responses.

You can do:
buttons[i].MouseOver:connect(function)
But this will mean that there is no way to tell which button your mouse was over.

But you can't do
buttons[i].MouseOver:connect(function(buttons[i]))
Because you can't connect a function with arguments, only one without.
>>
>>61727008
All three are valid and mine is also trivial to do
>>
>>61727008
Why wouldn't an x86-64 emulator be useful?
Make it target ARM, and even have dynamic recompilation from x86 assembly to ARM assembly.

Really though, if you're not going to mention skill level, people are just going to throw out EXTREMELY difficult programs to write.
>>
>>61726927
Interfaces are easiest to understand when you look at Java's collection framework.
Say you want to use a List. List is an interface which specifies certain methods. You can add items to the end of a list or remove them, among other things.
List myList;
...
myList.add(new Object());
myList.remove(myList.size() - 1);

The important thing is that we don't care how the list is implemented, all that matters is that it has these methods. The two most common ways to implement a list are the ArrayList and a LinkedList. Both of these implement the List interface (which can be thought of as a limited form of inheritance), but they are unrelated otherwise. An ArrayList uses an array to store its list contents, while a LinkedList uses a sequence of nodes with pointers to each other.

But for our purposes, none of that matters. It's just a List, so let's use it like one.
List myList = new ArrayList();
myList.add(new Object());
myList.remove(myList.size() - 1);

If I wanted to write a method that finds the biggest number in a list, I shouldn't care what kind of list it is. All I should care about is that it has List methods.
public static findBiggest(List myList)
{

}


You can't make a List, since it's not a real class. It's just a contract saying what a class implementing it needs to be able to do.
List myList = new List(); // does not compile
>>
As much as I love Rust, it feels just as counter-productive. Conversion to and from &str and String, lifetimes, trait generics make it harder. I have high hopes for Rust but it still needs a lot of syntax sugar (like a way to distinguish a &str quotation and a String etc. Like """this""" should return a mutable String and "this" should return a &str, or, a more intuitive module system, a built-in readln!() etc comes to mind). Coming from D, Rust's Generics (in combination with with traits) do not seem all that helpful/comfortable to me. (though it might change over the time). Rust only reached v1.0 a while ago so I believe there be polishing to come.
>>
>>61727025
>Because you can't connect a function with arguments, only one without.
buttons[i].MouseOver:connect(function() fn(buttons[i]) end)
>>
>>61727025
>>61727072
Skid shit belongs to >>>/wdg/
>>
>>61727078
Lua has nothing to do with webdev.
>>
>>61727081
Lua is for skids, skids don't belong here
>>
>>61727084
>skids
You clearly don't know what the word means.
Also, if I had to apply it to a programming language, it would definitely be python.
import solution
solution.run()
>>
>>61727084
>skids don't belong here

Are_you_sure_about_that.mp4
>>
>>61727094
I know exactly what that means. Your trash scripting ```language``` is not programming. Take that pseudo programmer garbage out of here
>>
>>61727103
Yes, skids don't program. Scripting is not programming
>>
>>61727040
Ah, I see. Thank you. But why would I choose an interface over an abstract class, or vice versa?
>>
>>61727142
You can only extend one class, but you can implement as many interfaces as you like. Since you can only extend one class, you better make it count.
Abstract classes can contain variables and implementations of methods while interfaces only contain declarations of methods that must be implemented later*. A class (abstract or not) can do strictly more than an interface.
Some other languages (e.g. C++) don't have limitations such as this. You can inherit from multiple classes freely. Java is trying to force you to write code a certain way.

*default methods added in Java 8 allow you to define method implementations inside interfaces too. But no variables.
>>
File: 9780262691635.jpg (73KB, 409x475px) Image search: [Google]
9780262691635.jpg
73KB, 409x475px
Trying to stay awake on 24 hours no sleep, I'm not even programming I just watched Dragon Ball yesterday/today. I'm reading this though
>>
>>61726674
Python is an amazing language, but it's slow as fuck. There always seems to be a better alternative. For the smallest scripts you can use python, but you might use any of the million scripting languages at that level. For www you use php and javascript, for heavy calculations you use c. What do you actually use python for that wouldn't be better done with something else?
>>
Holy shit she's Qt
https://www.youtube.com/watch?v=QZD2nRqVoKg
>>
>>61727264
so this... is the power... of blogposting..... incredible...
>>
>>61727336
yeah man, haha like, dude, thumbs up.
>>
Do you guys procrastinate towards the end of writing a bit of code? When I've been working on a project for a couple of weeks and it's finally wrapped up I get cold feet and just don't write enough code I should be.
>>
>>61727264
>2017
>Still watching dragon ball
>>
>>61727393
>Do you guys procrastinate towards the end of writing a bit of code?
Of course. Everyone does it. It's easy to write in the start, since everything is clean and simple. Towards the end, everything is chaotic, shitty and buggy, so you just wish to already dump the project over for some poor cunt who has to maintain it.
>>
>>61727438
Too true.
>>
>>61726771
See that is one of the problems with python, they should have never allowed spaces to be used.
>>
>>61727438
>Towards the end, everything is chaotic, shitty and buggy
Only if you make it so.
>>
>>61727716
better that Python is up front about whitespace sensitivity, rather than some languages which pretends it's all curly braces until it isn't
>>
>>61727734
>rather than some languages which pretends it's all curly braces until it isn't
???

How is this an argument?
>>
File: question.jpg (37KB, 1024x576px) Image search: [Google]
question.jpg
37KB, 1024x576px
What tools are you guys using? I'm really enjoying using Sam, 9term and rc. Very comfy programming indeed.
>>
>>61727776
VS Code
>>
>>61727776
You're old
>>
I like how /wdg/ is dead/slow most of the time, webdevs are busy making dosh while we argue about rust
>>
>>61727853
Maybe because web dev is slow because nobody gives a shit about web dev?
>>
>>61727853
That's fine, you couldn't pay me enough to unironically webdev
>>
>>61727867
How much would it take for you to ironically webdev?
>>
https://lapinozz.github.io/learning/2017/07/17/compile-time-templated-a-star-pathfinding.html
>>
>>61727888
>C++14 TMP
But why? Constexpr exists.
>>
>>61727819
What's wrong with it? They're all pretty cool and are actually well thought out. The tools commonly used in Unix systems are so old and out dated; they weren't designed for graphical user interfaces. Plan 9 is actually nice because the programs were designed with graphical user interfaces in mind.
>>
>>61727882
$200,000/yr
>>
>>61727895
The more obscure the better, of course.
>>
>>61727734
What I meant is that they should have forbidden spaces and only have tabs as valid syntax.
>>
Is there any kind of standard or convention about how to name command line arguments? Like what kind of arguments should be capital letters or what certain letters should stand for? I suppose "-h" and "--help" are pretty much mandatory, but are there others?
>>
>>61727983
For block scoping sure. Alignment is best done with spaces.
>>
File: 1501442039957.png (31KB, 500x500px) Image search: [Google]
1501442039957.png
31KB, 500x500px
Kind of new to scripting/programming.

I'm trying to compare two lists, A and B, and return anything that's in A but not B.

List1 [1,2,3,4,5,6]
List2 [1,3,4,5]
return: 2,6
>>
>>61728083
Most languages have a function for that all ready.
>>
>>61728083
for x in list1:
if x not in List2:
yield x
>>
>>61728113
>yield
explain this shit plz
>>
File: 12837812381273.png (1MB, 1156x1156px) Image search: [Google]
12837812381273.png
1MB, 1156x1156px
>>61728119
it means you yield your boipucci to an elder programmer so that your own programming ability grows
It's a scientific fact!
>>
>>61728083
In Haskell, this is just
import Data.List

a \\ b
>>
>>61728139
that's female legs bud
>>
>>61728113
Thank you, I was trying to do it with 2 for statements.
>>
>>61728152
In set theory this is just A - B.
>>
>>61728083
In python it'd be return set(list1) - set(list2).

Also, what code tags do we have here? I'm a noob.
>>
>>61728158
that's the point bud
also you're a homosexual bud
>>
>>61728180
you make it sound like it's a bad thing bud
>>
>>61726927
if you don't understand a language feature and really can't think of a use for it, just don't use it. I know that's blasphemous, but you'll figure it out with experience and seeing other people's code. Don't waste time on it.
>>
>>61728214
In a relatively conservative language like Java, I don't think that's right. Interfaces are a pretty key thing to understand.
>>
>>61728250
>Interfaces are a pretty key thing to understand.
A beginner does not need to understand them. He'll learn to use them very quickly once he starts to have more than one class and inheritance between them.
>>
http://www.felixcloutier.com/x86/PUNPCKLBW:PUNPCKLWD:PUNPCKLDQ:PUNPCKLQDQ.html

For what purpose
>>
>>61728083
>>61728113
>>61728164
[x if x not in list2 for x in list1]
>>
>>61728412
set(list1) - set(list2)
>>
>>61726421
You forgot to add that in other languages (read: mostly C++) the standard library stuff is usually a subpar implementation with completely whacky memory usage patterns, or something that doesn't even fit your specific problem, but you're going to make it fit anyway because a book told you the most important thing to do was to save lines of code in your program.
That being said, there are libraries for C that you can use for quick programs, like the stb public domain libs, that do things some other languages' standard libraries would provide.
And really, the kind of verbose is certainly not C nor C++ - it's Java, despite it's vast standard library.
>>
Explain this
#include <iostream>

using namespace std;

void
print_array(auto& range)
{
for (auto& element : range) {
cout << element << endl;
}
cout << "First: " << *range.begin() << endl; // prints 1
cout << "Last: " << *range.end() << endl; // doesn't print 11
}

int
main()
{
auto arr = { 1, 4, 2, 0, 9, 11 };

print_array(arr);

return 0;
}
>>
>>61728666
end is past-the-last-item iterator
>>
>>61728666
That's one past the range, isn't it?
>>
>>61728666
what are the types of arr and range?
>>
>>61728730
std::initializer_list<int>
>>
>>61728730
std::initializer_list<int>&
>>
>>61728696
>>61728697
Oh okay
>>
>>61728742
>>61728753
horrifying
>>
Need help naming a class.

My program runs a 'process' loop X amount of times per second, which is used to update the state of the program.

I have made a class that can be inherited from, and used to run a method (called 'process') only every Y loops.

Eg:
Program runs 50 (X=50) loops a second
My sprite only needs to update 5 times a second, so I use my class to make it count to 10 (Y=10).

What should that class be names? The best I've come up with is ProcessLoopSubscribed

thanks /g/uys
>>
>>61728774
Stick factory at the end of your name and you're good to go.
>>
>>61728774
Pretty good bait.
>>
>>61728774
twiner :^)
>>
>>61728774
Retardator
>>
>>61728774
FurhrerLoop
OberstgeneralLoop
>>
>>61728780
>>61728782
>>61728788
>>61728801
>>61728805
sometimes I wonder why I come to /g/ for help
>>
>>61728818
kek as if /g/ was your personal tech support
>>
>>61728828
tech support implies its broken
it works perfectly fine
just wondering what you'd name it, in case I start sharing my code with someone
>>
So with
void
print_array(auto& range)
, the '&' implies that the argument is passed into the function by reference, right? In that case do I have to have to dereference it in the function body?
>>
>>61728844
nope you can just use it
>>
Can someone tl;dr me on C file i/o? An simple cat-like example is all I need (or a link to a good article that gives that)
>>
>>61728844
no, references do not have to be dereferenced, you're thinking about pointers
>>
>>61728844
Are you compiling with -fconcepts?
>>
>>61728857
https://www.tutorialspoint.com/cprogramming/c_file_io.htm
>>
>>61728869
No
>>
>>61728844
Nope, that's the point of references. You use them just like normal variables, except they never get copied when you pass them around.

Pointers work the same way except they're manual, so you have to call the function with &range (to pass the address of the range), and declare and use it with *range inside the function (to get the value stored at that address). References basically just automate that
>>
>>61728888
>>61728866
>>61728853
Thanks again
>>
>>61728879
You can't use auto as a placeholder for the type of an argument..
>>
>>61728904
What do you mean, it's working
>>
>>61728915
It's not valid C++.
>>
>>61728915
It's a compiler extension or something in pre-c++17 so it's not really standard but don't worry about it, it eventually will be.
>>
>>61728950
just like c99 vlas
>>
>>61728950
Oh. Seems to be working here with GCC 7.1.1, I'm using nothing but -Ofast argument
>>
>>61728969
That's because GCC likes to do stuff that isn't in the standard a lot.
>>
So insertion sort is just
1. find min element
2 prepend
3. index++ ; goto 1
right?
>>
>>61729021
>prepend
swap
>>
can anyone tell me what a good programming language to learn would be for a beginner besides python and javascript?
>>
>>61729231
D
>>
>>61729231
Ruby. C.
>>
>>61729276
>Ruby
He said good
>C
He said beginner
>>
>>61729312
Ruby is better than Python for beginners.

C is easy to understand.
>>
>>61729323
Who said anything about python?
C is easy to understand for intermediate programmers, hence universities teach C as the second language
>>
>>61729312
C. is actually a great choice for a beginner. It's a very logical language and pretty much nothing is abstracted away from you, so you'll always know exactly what your program does and why.
>>
>>61729367
yes, yes, very logical and easy
http://www.c-faq.com/index.html
>>
>>61729387
What do you find difficult?
>>
>>61729367
 printf("Hello??!"); 

yeah, right.
>>
>>61729416
nothing, just saying that there are a lot of edge cases that will confuse beginners
>>
>>61729416
He probably doesn't find anything difficult as he is not a beginner
>>
>>61729352
> Who said anything about python?
The original question.

>>61729352
If he's willing to tackle the clusterfuck that is Javascript, he can wrap his head around C with no problems.
>>
>>61729454
He said besides
>>
>>61729423
Should have gone with C++17 instead.
>>
>>61728969
Use
-std=c++14
(or c++11) to force standard compliance
>>
>>61729454
thats the thing, i utterly and completely failed to understand javascript properly to the point where now i just hate webdev in general.
>>
>>61729496
Doesn't work for me.
>>
>>61728481
I like how that stb writer has https://github.com/nothings/stb#why-not-c99-stdinth-declare-anywhere-etc
>>
>>61729533
What do you meant

Does it still compile your c++17 behaviour when you're compiling with the std=c++14 flag?
>>
>>61729537
> I still use MSVC 6 (1998) as my IDE because it has better human factors for me than later versions of MSVC.

Wtf.
>>
>>61729568
autism
>>
>>61729537
I've got to respect a man like that.
>>
How can I easily generate capitalised words of n (say, 5) random letters using the shell?

Right now I've got something along the lines of
head -c 256 /dev/urandom | tr -dc '[:alpha:]' | head -c 5
which obviously generates upper and lower letters. Is there a better way than do that but filter by '[:upper:]', do head -c 1, then filter by lower and do -c 4?
>>
When people say "backend" do they mean they like it in the rear?
>>
>>61729605
>that but
*than by. I'm not even phoneposting
>>
Is C# good languaage?
>>
File: converter.webm (696KB, 386x292px) Image search: [Google]
converter.webm
696KB, 386x292px
r8
>>
>>61729644
It's a better Java.
>>
>>61729644
Yeah, for most things. It's a very good general-purpose language. It depends on what you want to do. If you're interested in embedded dev, for example, C# isn't the first place you'd turn to.
>>
>>61729647
>numbers don't update from a live BTC ticker if you leave it typed in
2/10, not really useful
>>
>>61729691
What about for desktop apps and such?
>>
>>61729628
No, backend development is generally dealing with the data layers that are disjointed from the UI layers.

It doesn't have anything to do with anal sex.
>>
>>61729700
but it does. the btc price is gotten fresh from an API everytime you type and there's an async wait that updates the price of btc in the script
>>
>>61729716
C# with WPF really shines on Windows-based desktop applications. I wouldn't necessarily recommend it for Linux-based desktop applications at this point, but that may change with Xamarin 3.0.

Frankly, the only way to produce a "desktop" application that has a good consistent look-and-feel, with good animations and performance is to create a "totally-not-a-website" application, like Discord/Atom/VS Code/etc.
>>
>fixing other peoples code during the weekend as usual
>massive amounts of unused variables everywhere because they just copy-paste your code and modify it to suit another case
>msvc hasn't warned them about it as gcc does, but its not like they read compiler warnings anyway
man, working on school projects is a pain
>>
File: IMG_1159.png (788KB, 750x1334px) Image search: [Google]
IMG_1159.png
788KB, 750x1334px
>>61726344
Should I continue reading Modern Operating Systems? Or would it be wiser to work through a book on assembly first? Which supplements the other? Is it reasonable to try and learn? How many people have a deep understanding of their computer down to the specific details of their OS, or even to their hardware? Exactly what depth of knowledge does the average programmer have on on computer architecture?
>>
>>61729673
I like c# better as a language, but in my testing the JVM is far faster.
>>
>>61729605
head -c 256 /dev/urandom | tr -dc '[:upper:]' | head -c 5
>>
>>61729808
and man, all these potential buffer overflows, they use sprintf constantly but then allocate a buffer of something way too small, like 16 because "well the string is usually 16 long".
>>
>>61729828
Yep. By rights C# should be faster than Java though, what with structs and such. I guess that's just a testament to how good the JVM is.
>>
>>61729810
You could easily learn general OS concepts without knowing ASM. I know Tanenbaum's book you can read without really even knowing too much programming. On the other hand, something like Understanding the Linux Kernel, you should have a decent understanding of C and x86. Basically depends on the book you get and how general it is.
>>
>>61729928
>>
>>61728774
TemporalDecimator9000
>>
File: wake me up inside.gif (30KB, 529x256px) Image search: [Google]
wake me up inside.gif
30KB, 529x256px
>>61728774
>inheritance
Just use a decorator holy shit
>>
>>61726344
thanks for posting my husband
>>
is there a simple reason why webms with sound are not allowed outside of /wsg/ and /gif/?
>>
>>61730180
screamers
>>
>>61730180
Because 4chan is an imageboard, not video sharing service. On some boards it makes more sense because they focus on short videos.
Also not /dpt/ related, try /sqt/ next time when you have a stupid question.
>>
>>61730197
then why doesn't /tv/ allow webms with sound?
>>
>>61730217
because /tv/ is an awful board that doesn't deserve anything.
>>
>tron legacy boardroom projection recreated in HTML5

https://www.robscanlon.com/encom-boardroom/
>>
Why does GCC whine about this...
if (init_socket_api() != 0)
return 8;

... with:
warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]

?
>>
>>61730365
Show the whole function.
>>
>>61729833
That gives all uppercase, completely different from capitalised
>>
>>61730365
>>61730375
Nevermind, I noticed some idiot had used tabs instead of spaces on some lines. Removing them fixed it.
>>
>>61730365
Bescause they decide to fore opening brace.
>>
Repill me hard on nodejs. Do serious companies unsarcastically write their backends in js?
>>
>>61730515
>>>/wdg/
>>
From the textbook my professor wrote, which I had to pay $60 for:

"Java has so many failsafes that it's damn near impossible to break a Java program.

Although detractors consider it a disadvantage that Java forces its programmers to take these measures, the effort needed to do so is negligible if you have a fully-fledged IDE (or you've sufficiently customized Emacs/Vim, for you daddy-o's who were programming in the early 80s). It also means that even novice programmers can produce cutting edge programs, even if their methods are inelegant.

And compiled Java still has a smaller memory footprint than Python and C++ programs, some C programs, and even some assembly programs."

This reads like a /dpt/ shitpost. What utter cancer.
>>
>>61730660
Oh, the lenghts people will go to sell a book.
>>
>>61730660
>smaller memory footprint than Python and C++ programs, some C programs, and even some assembly programs
wat
>>
>>61730660
LMAO ahahahah

tell him to visit 4chan.org/g/dpt, he will fit right in
>>
>>61730515
Depends what you mean by "serious companies". Would a megacorporation with 5 million lines of corporate Java be more serious than an app company using nodejs and mongodb? Probably, but which one do you want to be?

The correct answer is of course neither, write your backend in pure C or lisp (and I'm only being half-ironic here)
>>
>>61730660
>compiled Java still has a smaller memory footprint than Python and C++ programs, some C programs, and even some assembly programs
Holy kek

Can you ask him to provide an example of a Java program having a smaller memory footpring than a well-written C++ or C program? "Some assembly programs" means you can weasel out by giving intentionally badly written assembly, but he didn't word it this way for C, which implies than it should have a smaller memory footprint than any C program
>>
Dear /g/. Why is it that there are people out there who write Java-code professionally, without using Lombok?

It's like using Spring, but not Spring Security. Or using Hibernate, but instead of using a comfy-tier properties-file, with JPA annotations on the persisted classes we go straight for XML.

Do people just like pain? Do they resent having the necessary information all in one place? Are they just insane?

Please help me understand Obi /g/ Kenobi. You're my only hope.
>>
>>61726829
Java has AbstractMonadBeanFactory though. Can Haskell deal with that?
>>
Are else if blocks in c just syntactic sugar for the compiler or is there some nuance?
>>
>>61730931
What do you mean? In the end everything in C is just syntactic sugar, in fact everything in assembly is just syntactic sugar for opcodes
>>
>>61731003

So it will be reduced down the the exact same assembly code?
>>
>>61730918
>AbstractSingletonProxyFactoryBean
I thought this was just a meme
>>
>>61731026
ifelse will boil down to conditional branches. It's all just branches.
>>
>>61726927
Just start with imagining an interface. Fuck abstract class. Just the interface.

An interface just says that anything that implements me will have THESE methods available.
For instance:
public interface 2DGeographical {
public 2DPoint getLocation();
}

Every class that implements that interface will have to have that method available. So let's say that you have some method that calculates how far apart two things are in 2D-space. It doesn't have to care about what types the things are. All it has to know is that it's a 2DType, and it will know that the methods it needs to call will be available.

import static java.lang.Math.*;

public final class Distance2D {
private Distance2D() {}

public static double pythagoreanDistance(2DGeographical first, 2DGeographical second) {
2DPoint left = first.getLocation();
2DPoint right = second.getLocation();
return sqrt(pow(left.getX() - right.getX(), 2) + pow(left.getY() - right.getY(), 2));
}


And now, you don't have to actually care if you throw in different monsters, bullets and monsters, etc. The distance will be calculated the same regardless. You get a sort of compile-time checked ducktyping. (But you have to define every type of duck, to avoid... Fowl play.)

And if you get that, you get interfaces. But don't worry, it takes some time for the concepts to truly sink in.
>>
>>61731072
>You get a sort of compile-time checked ducktyping. (But you have to define every type of duck
If you have to declare interfaces explicitly, it's not ducktyping.
>>
>>61731026
>exact same assembly code
There are no IF or ELSE instructions, but yeah, like the anon said it's branching.

I don't remember the nuances but if you use a ternary oprerator that avoids branches, making it slightly more optimised. But with modern compilers trivial if-else blocks will be reduced to that anyway whenever possible, so in that sense unless you turn off all optimisations you might not get a branch from your if-else.
>>
>>61730931
Not sure.
Without them you'd have a lot of code duplication (ignoring goto). Maybe the compiler could collapse your if() {} else{if() {} else{}} into an else if trivially in any situation.
You don't tend to call things like that syntax sugar though. Syntax sugar is things like c++ references vs pointers.

Anyway. I lack enough faith in the compiler smarts now that I'd say no, it doesn't work in every circumstance.
>>
Learning a buch of new stuff

LibGDX
TypeScript
Angular4

And making sense of this mess called web development.
>>
File: BOXXY.jpg (65KB, 322x301px) Image search: [Google]
BOXXY.jpg
65KB, 322x301px
I am working on an AI script inside of ruby for personal use and experimentation.
>>
>>61731180
>>>/g/wdg/
Fuck off back to /wdg/, a cancerous place where "code artisans" should stay.
>>
>>61731201
I'll experiment with your personal places, you gay boy.
>>
>>61731209
Make me you fuck
>>
I'm too lazy to google, so: what algorithm does crypt() from C's standard library use? I read somewhere that it's "MD5-based" which is really vague
>>
>>61731233
Give me your home address and I will.
>>
>>61727142
To add to what >>61727196 was saying:

Let's say that you're writing code that other people are supposed to be using.

So you and I are in charge of writing the code that talks to the database. So we decide that we're going to give people as little information as possible and so we set up out contract as such:
[/code]
public interface WaifuDAO {
public Collection<Waifu> singleWaifus();
}
[/code]

And later we give them a HikariWaifuDAO that uses HikariCP. But they want to move to Hibernate now.

Okay, fine.
Their old code looks like this, because they're not retarded:

public class Waifunator {
private final WaifuDAO waifuDao;
public Waifunator(WaifuDAO waifuDao) {
this.waifuDao = waifuDao;
}

// Imagine code going here that does stuff.

}
// and in some other class:
public class SingleWaifuBar {
Waifunator waifunator = new Waifunator(new HikariWaifuDAO(hikariCP));
// Imagining more code going here...
}


Now, since they were none retards, they now just have to change two things:
> Instead of setting up HikariCP, they have to set up Hibernate (which can use HIkariCP and thus the older config was not wasted. Yay.).
> Instead of instantiating HikariWaifuDAO, they instead have to make a HibernateWaifuDAO.
Here's all they'll need to change in the example code:

Waifunator waifunator = new Waifunator(new HibernateWaifuDAO(sessionFactory));


And all their singles night meetup with their 2D-waifus can go on as before.

And they don't know if we return sets, or lists or what have you. They just know that they get a collection of waifus. That's it. So if tomorrow we discover WaifuContainer2000, which is a better collection for waifus, then we can just swap on our end and they will notice zero change.

What this does in other words, is that it makes code more open to change. You can swap out parts without pain. The thing is, that while this is obvious after you have done it for a while, until then it kinda seems weird.
>>
>>61731231
>>
>>61731275
my waifu is not an object
>>
>>61727988
GNU has a list.
https://www.gnu.org/prep/standards/html_node/Option-Table.html#Option-Table

But common ones are -v/--verbose, -i/--interactive -v/--version (yes, that's two 'v's), -y --yes-to-all
>>
>>61731318
All women are objects
>>
>>61731336
tbf he didn't specify
>>
>>61729673
Depends on what you want to do desu.

Java with Lombok is often less verbose than C# for sufficiently cocky toy examples:

[quote]
@Value
@Builder
public Foo {
String this, is, a, shitty, example;
}
[/quote]
Good luck writing the equivalent in C#. (It will have an all-args constructor, a builder for it, getters for all the Strings, which will all be private and final, a toString, equals and hashcode implementation and probably something else I'm forgetting about.)

But in actual average day to day coding, Java 8 is about the same as C#. Both are good languages though, despite what haters are going to say.
>>
>>61730660
Well, Javac does provide rather decent assembly, but this is just retarded. Also, using daddy-o?
Jesus. I like Java, but there's no reason to lie about the language to sell it to people.
>>
I'm new to C. If I want to print a big string (e.g. usage/help info) in several different points, is it better practice to have a function that prints it out or #DEFINE the string as a constant? Or even store it as a const char * global variable?
>>
>>61731473
const char* global
>>
>>61726452
Alexandrescu is goat.
Too bad he works for Facebook.
>>
>>61731039
It was just a joke bro.
It does have some Monads here and there. Optional is probably the most obvious one. And it is it's own factory. (Optional.of("HELLO") returns an Optional<String> for example.)

But while singletons are cancer, and proxies are almost never used IME, the other buzzwords makes perfect sense. They just tell you what they're doing as a part of the engineering.

Please understand:
HAVING those names is much better than NOT having them. If you see something like a FooFactoryBuilder, then you know that:
> It's a fluent API thing for making FooFactory instances.
> FooFactory is just a thing that spits out Foos for you, likely wrapping some annoying bullshit you have to go through to make Foos.
> If you don't need Foos, you can safely ignore this thing.

As for why you'd need a factory builder, I'm not sure. It sounds weird. Maybe ask the architect what he was smoking. It is in other way, an attempt to inform you the reader, about the thought process (or lack thereof) that went into the design of the thing that you're looking at. And if you've ever had to fix something at fuck-you-o-clock, that extra information becomes really useful.
>>
>>61731514
>Too bad he works for Facebook
he doesn't
>>
>>61731517
Why would I want to use Optional when everything in Java is nullable?
>>
File: 1498763354325.png (88KB, 550x375px) Image search: [Google]
1498763354325.png
88KB, 550x375px
>>61731090
Dude, I just wanted to make a fowl-play joke. Why do you have to come down on a brother like that?
>>
>>61731513
thank
>>
Learning rust, I actually like it.
>>
File: ayla.jpg (30KB, 220x440px) Image search: [Google]
ayla.jpg
30KB, 220x440px
>>61731318
Then your waifu is a primitive. (Good taste anon.)
>>
>>61731577
thanks
>>
>>61731577
No you don't
>>
>>61731543
Because null is fucking cancer and needs to go and stay go. Coalescing nulls is solving the wrong problem. Use Optional.
>>
>>61731599

>python-style for
>secure
>easy string manipulation
>fast

Yes I do.
>>
>>61731613
It's too late now, Java chose nulls and Java will have nulls forever. I'd rather just stick to nulls than have nulls and optionals.
>>
>>61731637
Java will have null in shitty legacy systems from 1996 forever.

However, there's no reason modern APIs will ever return null.
And null is handy for internal within a boundary.
>>
>>61731707
>However, there's no reason modern APIs will ever return null.
Eh, it's useful for documentation within the function signature but we have javadoc for that. I don't see how code written with Optional is cleaner than code written without.
>>
>>61731707
Everyone in the world still regularly uses and handles nulls in virtually all of Java's existing code bases.

You can't just wave your magic NEET wand and prescribe your own design opinions to the world at large.
>>
>>61731742
It's not my NEETy fingers that are waving my magic cock around, it's Oracle's.

Optional is the wave of the future.

>>61731737
Actually no. We all work with less than genius-level intellects from time to time who don't. And then that one in a million chance happens and shit crashes because someone didn't check for fucking null. Optional makes the compiler yell at you until you do the right thing.
>>
>>61731798
>Optional makes the compiler yell at you until you do the right thing.
Kotlin's null handling is the answer, because it actually works with existing Java and it works cleanly. Optional is too little too late.
>>
>>61731824
Changing language doesn't fix the old language.
Kotlin is nice though.
>>
>>61731866
Expanding the language rarely fixes the old language. See: sepples.
>>
>>61731613
Aren't Javas Optional nullable themselves, Making them useless?
>>
>>61731903
Everything is nullable in Java.
>>
>>61731911
What a trash language
>>
>>61731929
apart from primitives anyway.
>>
Hi /g/
I'm writing a 4chan image downloader for shits and giggles, but I seem to be having some problems.
I'm trying to send an HTTP request to 4chan's API.
(To test I've used this thread)
The server keeps giving me HTTP 520 (Origin Error).
The internet seems to tell me this is a server-side error, but I can request it perfectly fine with my browser so...
Here's the code:
https://pastebin.com/WJjx3hf3

Do any of you know what I'm doing wrong or missing here?
>>
So I got a small programming task to do for an interview-type thing, and in the provided Readme they wrote:
5 Hint(s):                                                                                                                                         
1. Watch you for canaries
[more hints]

The challenge is in C. Is there a meme I'm not getting? The task itself is simple enough so I'd just ignore this, but there's about 20 candidates applying for the same position so if it means something and I can humour the guys there by acting on it it'll probably boost my chances.
Any ideas?
>>
>>61731903
>>61731911
lmfao

>go to create optional
>the value you try to create an optional with is optional
>get a nullrefex anyway
>>
>>61731983
Ignore the 5, I copypasted the pleb way from vim with relativenumbers on
>>
>>61731967
samefag here,
Java is throwing the following exception;
java.io.IOException: Server returned HTTP response code: 520 for URL: http://a.4cdn.org/g/thread/61726344.json
(I know it's an Origin error by using response.getMessage() after writing to the output stream)
>>
Adding -Wall -Wextra -pedantic flags to my build system causes compiler errors that don't happen when I don't include those flags. Why is that?
>>
>>61731983
The only time I've heard of the term canary wrt programming is a stack canary, a "canary in the mine" value which verifies that there haven't been buffer overflows into the stack.
>>
>>61732025
>making my compiler look for more things causes it to find more things
makes u think
>>
>>61732034
Ah, they were probably talking about buffer overflows then - the challenge involves some file IO and string manipulation, and was given to people who likely never used C, so it makes sense.
>>
>>61732048
They should only throw warnings though, no? Since I don't have -Werror enabled...
>>
>>61731967
Samefagging again,
A quick wireshark actually shows a 200 response, so this is a pure Java fuck-up...
>>
>>61732076
enable -Werror right this instant and fix your shitty code
>>
>>61732115
Figured it out, just remove the outputstream and it'll work just fine
>>
Anyone still have the source code to github/tux3/DelayCl0se ?
>>
>>61732161
Woulda been on from the start if I was around when development began. I'm trying to ease the team into it by enabling some warnings and seeing how they react while gcc screams.
>>
what languages aside from bash should a linux sysadmin know?
>>
So what compiler flags should you "normally" have enabled for a C project? I'm using std=c11 of course, and O2, but beyond that I have "-Wall -Wfatal-errors" which I copied from somewhere, and I have no idea whether that's good practice or I should have other things.
>>
>>61732230
AWK, sed, perl, python, C
>>
>>61732230
Not a sysadmin but I've found awk to be super useful when fucking around with larger files.
>>
>>61732223
flooding warnings will make them more likely to just ignore them. secretly distribute a compiler with -Werror hardcoded
>>
>>61732230
ini
>>
>>61732250
if you're not maintaining old systems is there any reason to learn perl in this day and age?
>>
>>61732314
Perl is better than shell scripts if you're a sysadmin in general.
>>
>>61732314
It's a good language. If you're the kind of fag that wants to use python instead go ahead I guess
>>
New thread

>>61732327
>>61732327
>>61732327
>>61732327
>>61732327
>>
>>61732322
>>61732331
perl 5 or 6?
>>
>>61731983
https://en.m.wikipedia.org/wiki/Buffer_overflow_protection
>>
>>61731517
the biggest problem with """monads"""" in Java is they failed to create a consistent interface for them.

>>61731543
Optional<Integer> a = null; 

this kills the optional
>>
File: glasögonprydd amfibie.png (12KB, 420x420px) Image search: [Google]
glasögonprydd amfibie.png
12KB, 420x420px
>make my entire application in python (QT for UI) and use py2exe/py2app


dare i?
>>
>>61732964
why the fuck do you ask?
>>
>>61732978
I don't know. No sound advice ever comes from /g/.
>>
>>61733100
fuck off with your pointless shit
>>
>>61732964
Oh yeah I used to run Carla which was such a program. And I ditched it after it repeatedly leaked over 5 GB RSS and triggered the OOM killer, probably thanks to the qualities of Python's amazing garbage collection.
I am tempted to say any sufficiently complex Python program ultimately collects itself, adequately, as long as you give it the sufficient run time.
>>
>>61726344
I'm after work

Want to do some code on the weekeend but all languages suck.

Recommend me a comfy langauge that won't require me to download a gingantic IDE but will have static typing.
>>
>>61732497
A monad is just a type with certain properties. But I get what you're getting at.
>>
>>61733618
OCaml
Thread posts: 325
Thread images: 20


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