[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: 346
Thread images: 43

File: prog.jpg (105KB, 473x496px) Image search: [Google]
prog.jpg
105KB, 473x496px
What are you working on, /g/?

Old thread: >>62405687
>>
>>62409688
Exactly, there's only one function in there, a function with C linkage. There is no wrapper, and there is no mangled function name.
>Check the ELF symbols. You will doubtless find the two functions you declared: one fucked mess of a name that points to the C++ function, and the clean C function name that was actually exported as the program's ABI.
You are incorrect, I showed that.
>>
What is the best lambda calculus and why is it the CoC?
>>
File: 1457024417693.jpg (35KB, 385x375px) Image search: [Google]
1457024417693.jpg
35KB, 385x375px
Have you ever thought of programming an AI just to have a friend?
>>
>>62409680
>Can you just write everything in a low level language like C, C++, or Rust?

Yes.

>Should you?

I dunno. It's your call. Weigh the cost-benefits.

>Is there even any point to Java, C#, and all that other crap that needs you to install various runtimes and such?

Yes. They are high performance virtual machines that programs run on top. It's easier to target the JVM by emitting Java byte code than to target x86 by emitting machine code.

>>62409732
So? It's well-known that C isn't a strict subset of C++.

>>62409744
>declares no C++ functions
>where are my C++ symbols in the ELF????
>>
File: cpp_function.png (61KB, 1163x551px) Image search: [Google]
cpp_function.png
61KB, 1163x551px
>Check the ELF symbols. You will doubtless find the two functions you declared: one fucked mess of a name that points to the C++ function, and the clean C function name that was actually exported as the program's ABI.
You're wrong.
>Because the function definition contains C++ code. The function declaration however is C.
Can Java function contain Haskell code in it? If not, how can C function contain C++ code in it?
>>
>>62409759
Because CoC is all you need.
>>
>>62409782
Meant to >>62409688
>>
>>62409760
even ai would hate me ;_;
>>
File: 4k.jpg (584KB, 3840x2160px) Image search: [Google]
4k.jpg
584KB, 3840x2160px
>>62409782
>T my_atoi
>all those fuckhuge type information-prefixed C++ stdlib symbols
>"you're wrong"

Try exporting those traits lmao
>>
>>62409775
foo is a C++ function, though.
$ echo 'extern "C" int foo() { class sepples{}; return 0; };' > main.cpp; g++ -c main.cpp
$ nm main.o
0000000000000000 T foo

That's not a C function, it's using C++ features. Still no wrapper.
>>
>>62409775
>So?
so you can't
>>
>>62409837
>moving the goalposts
>>
File: cpp_function.png (75KB, 525x843px) Image search: [Google]
cpp_function.png
75KB, 525x843px
>>62409837
These are imports, the only function being exported is my_atoi, and it contains C++ code directly, while you claimed
>You will doubtless find the two functions you declared: one fucked mess of a name that points to the C++ function, and the clean C function name that was actually exported as the program's ABI.
>>
>>62409864
>I got told HARD
>>
File: 2d-radiosity.jpg (30KB, 508x506px) Image search: [Google]
2d-radiosity.jpg
30KB, 508x506px
2D radiosity-based lighting.
>>
>>62409890
>AT&T syntax
tl;dr
>>
>>62409921
did you expect JS syntax?
>>
>>62409933
I expect Intel syntax
AT&T is far beneath me
>>
Trying to reverse engineer the steam API in order to automatically farm cards and sell them.
I got the farming part but I still have to figure how to interact with the market API. Reverse engineering really isn't as fun as I thought it was.
>>
>>62409921
>>62409947
It's not about the assembly, it's about the fact that my_itoa contains code compiled from C++ and even calls to functions from C++ standard library.
>>
>>62409842
>I scoped the class to the function

I don't even remember if that's possible. Do you even know what you're doing

>>62409864
I've been saying the exact same thing over and over. You simply don't understand what I'm talking about.

Try referring to
_ZNSt7__cxx1119basic_istringstreamIcSt11char_traitsIcESaIcEEC1ERKNS_12basic_stringIcS2_S3_EESt13_Ios_Openmode
through the ABI in a portable manner.

>>62409890
That's exactly what I said.

I told you that you'd find the C++ stuff, and the actual exported C symbol that calls your C++ stuff.

That's exactly what you found.

It implies C++ isn't even trying to have an ABI.
>>
>>62409980
>Try referring to...through the ABI in a portable manner.
You made a general statement about C++ functions, not specifically C++ template functions. An extern "C" function is still a C++ function, it just has a constrained signature.
>>
>>62409980
>arguing with sepples fags
When will you learn?
>>
>>62409980
I'm proving you wrong. The body of the function compiles as C++, but does not compile as C. It use C++-specific features. Therefore it is a C++ function and not a C function. There is only one symbol in the object file. That is the C++ function I have written. There is no wrapper, and there is no name-mangled function.
You are provably incorrect and all you have left is to try to change the subject by being astonished at basic C++ features.
>>
>create jar
>10kB
>n-nani?!
>oh wait, it lacks all libraries
>create fat jar
>20MB
>that's the power of java
>>
>>62410036
DELET!
>>
Fucking sepplesfags ruining yet another thread with their incoherent sperging.

>>62410036
Yeah but with jvm you can use any language that just compiles to java bytecode. It's also decently fast. You can just deploy the compiled bytecode and tell people to install java, they likely have it already installed. No need to bother with low level linking, distributing platform/compiler specific shared libraries and such.
>>
>>62409980
You're a dense one, aren't you? You said
> Check the ELF symbols. You will doubtless find the two functions you declared: one fucked mess of a name that points to the C++ function, and the clean C function name that was actually exported as the program's ABI.
I've shown, that there's only one function being exported, without mangling, containing C++ code directly in it. Mangled names are imports, not exports. The function doesn't call "C++ stuff", it contains its code directly.
>It implies C++ isn't even trying to have an ABI.
Is this supposed to be some kind of revelation? C++ never had standardized ABI, by design.
>>
>>62410036
>>n-nani
kys
>>
>>62410036
>create app.min.js
>10k
>oh wait, it lacks a browser
>100MB
>the power of webshit
>>
>>62410086
>You said
wasn't me tho
>>
File: 1500985569649.png (1MB, 1200x550px) Image search: [Google]
1500985569649.png
1MB, 1200x550px
>>62410088
>kys
>>
>>62410111
ky's you're a self
>>
>>62410082
>Yeah but with jvm you can use any language that just compiles to java bytecode. It's also decently fast. You can just deploy the compiled bytecode and tell people to install java, they likely have it already installed. No need to bother with low level linking, distributing platform/compiler specific shared libraries and such.
JARs are comfy indeed. They just work.
>>
>>62410082
Just statically link your programs if you don't want to bother with distributing shared libraries. That's what Rust and Go do by default.
>>
>>62410172
Are shared libraries really a good idea any more?
>>
>>62410193
I think they should just go but I'm sure you'll find autists here and elsewhere ready to defend the benefits of shared libraries.
>>
>>62410193
OS/driver libraries should be shared. Everything else should be static (and dynamically link to the aforementioned libraries).
>>
>>62410012
I'm an optimist.

>>62410008
>You made a general statement about C++ functions, not specifically C++ template functions

Who even said anything about templates? Let's not open that can of worms. Try referring to a simple non extern "C" function through the ABI.

>An extern "C" function is still a C++ function, it just has a constrained signature.

Yeah, you constrained your C++ function's signature to the point where it's literally a C function. You can't even do the thing name mangling was created for in the first place: function overloading.

It's totally a C++ function though! It totally has C++ ABI despite the "C linkage"! I mean, really...

Why don't we stop talking about functions then? Try calling an method (= member function) on a C++ object through Python. And don't make me a silly wrapper function to do it for you.

>>62410031
>scopes declarations to the function
>makes zero references to symbol
>calls zero (0) functions
>lol why aren't them in the object file?
>your wrong

>>62410086
>containing C++ code directly in it
>The function doesn't call "C++ stuff"
>it contains its code directly.

>return 0;

Yeah, nice code you got there.

I see you're one of those guys who can't even begin to imagine the assembly the compiler will generate. C++ tends to do that to people.

>C++ never had standardized ABI, by design.

Neither did C.
>>
>>62410240
>Try referring to a simple non extern "C" function through the ABI.
>moving the goalposts yet again
>>
>>62410240
>I said "try calling a C++ function".
I did. That's over.
Your condition was never that all C++ functions could be called outside of C++. Nobody ever said that was possible. But some C++ functions can be called outside of C++, that is proven.
What you're doing now is called backpedaling.
>>
>>62410255
I'm just giving you different examples so that you can understand.

Why? Because I asked you to interface with a C++ function, and you interfaced with a C function.

In other words: I asked you to link against a C++ symbol. You linked against a C symbol.

How hard can this be?
>>
>>62410303
Symbol =/= function
>>
File: 1495454995083.jpg (31KB, 456x320px) Image search: [Google]
1495454995083.jpg
31KB, 456x320px
>>62410296
>all C++ functions could be called outside of C++
>Nobody ever said that was possible

Welp.

>>62410314
>extern "C"
>C++ function

Just because it contains C++ code doesn't mean it's a C++ function.
>>
>>62410373
You have a strange idea of what constitutes a C++ function.
>>
>>62410296
>What you're doing now is called backpedaling.
His original point was that the C++ ABI is a joke (which it is). Nowhere have you proven him wrong.
>>
File: 1505189791662.png (70KB, 645x729px) Image search: [Google]
1505189791662.png
70KB, 645x729px
>Just because it contains C++ code doesn't mean it's a C++ function.
>>
>>62410381
I've never argued against that, the C++ ABI is a joke. But that was never the real point.
>>62408789
>Try calling a C++ function from Python.
There's a C++ function which can be called from Python! But it's not a C++ function despite being written in C++, because reasons.
>>
>>62410388
When you do extern "C", you're telling the compiler not to name the function name. This naturally rules out functions that require name-mangling. The content of the function is irrelevant. As far as the function signature is concerned, it might as well be a C one.
>>
>>62410425
>As far as the function signature is concerned, it might as well be a C one.
It's still a C++ function. How hard is this to understand?
>>
>>62410425
not to name-mangle*
>>
C FUNCTIONS ARE JUST ASSEMBLY SUBROUTINES BECAUSE THEY'RE COMPILED DURR HURR
>>
>>62410380
No I have an extremely clear idea of what a C++ function is. You're the one who's confused.

>>62410388
Even wikipedia knows the difference:

https://en.wikipedia.org/wiki/Nm_(Unix)

# nm test.o
# C
0000000a T global_function
00000025 T global_function2
00000004 C global_var
00000000 D global_var_init
00000004 b local_static_var.1255
00000008 d local_static_var_init.1256
0000003b T main
00000036 T non_mangled_function
00000000 t static_function
00000000 b static_var
00000004 d static_var_init

# nm test.o
# C++
0000000a T _Z15global_functioni
00000025 T _Z16global_function2v
00000004 b _ZL10static_var
00000000 t _ZL15static_functionv
00000004 d _ZL15static_var_init
00000008 b _ZZ15global_functioniE16local_static_var
00000008 d _ZZ15global_functioniE21local_static_var_init
U __gxx_personality_v0
00000000 B global_var
00000000 D global_var_init
0000003b T main
00000036 T non_mangled_function


>>62410420
>hey! mr. compiler! mr. C++ compiler!
>please come over here.
>I must speak with you for a sec
>you see, I wanna declare this here function
>but look now. I need you to pay attention
>even though I will be writing C++ code in it
>I need you to export it as if it was a C function
>that is why I'm writing this bit here extern "C"
>understand now mr. compiler?
>good!
>i will let you do your thing now!
>>
>>62410439
>It's still a C++ function.
Not in any sense that's relevant to the ABI discussion. When you say extern "C", you're effectively saying "use the C ABI for this".
>>
File: red.jpg (63KB, 1280x720px) Image search: [Google]
red.jpg
63KB, 1280x720px
>>62409722
>What are you working on, /g/?
Have you guys ever wondered why dpt is so inquisitive? Why does it ask all these questions, thread after thread, day after day? What is dpt:s endgame?
>>
>>62410489
>as if
Key phrase here. It remains a C++ function, only difference is that it has a C-friendly name.
You can call C++ functions from Python, anon. That's how you do it. It does not transform into a different language by adopting that language's linkage conventions.
>>
>>62410517
It gets boring at some point.
>>
>>62410517
>What is dpt:s endgame?
RMS for president.
>>
File: 1504909709662.png (98KB, 612x491px) Image search: [Google]
1504909709662.png
98KB, 612x491px
If I need to create a string of characters that takes less no more than 25 characters with what subscript value would I declare the string?
>>
>>62410586
>a string of characters that takes less no more than 25 characters
????

not possible
>>
>>62410586
Depends on whether the null terminator is one of those 25 characters.
>>
>>62410462
Please refrain from shitposting, okay? Thanks.

>>62410540
It's named like a C function, passes parameters like a C function, saves registers like a C function, gets exported as a symbol like a C function...

Are you really telling me it's a C++ function?
>>
Writing C++ for a point of sale business. Most of the code started in the 90s but since its C++ its pretty much still working fine. In house data solution is based on btrieve, fast as fuck but you have to be an autist to learn to use it.
>>
>>62410623
Yeah it's a C++ function, because everything inside it was written in C++.
Being able to use the calling conventions of a different language does not change the language it was written in. You said you can't write a C++ function which can be called from Python, but you can by using a common convention.
>>
>>62410540
>It remains a C++ function
Calling something a "C++ function" after it's been compiled down to assembly and uses the standard C naming scheme and calling convention is meaningless.
>>
>>62410694
Now you're getting it. Just because it's meaningless doesn't mean you can say it's not true.
>>
>>62410717
>Just because it's meaningless doesn't mean you can say it's not true.
But that's obviously not what that other sepples fag meant. You've turned it into a retarded argument about semantics, probably because you realized you're wrong.
>>
>>62410727
Calling it a C function is meaningless too. It's a subroutine with the C calling convention. But if it came from C++ code, it's a C++ function.
>>
>>62410693
Yeah so you used some language feature to make a C function from within C++. You can totally export C++ functions!

Call me when Python supports things such as the thiscall ABIs (note the s, for there are many). Actually don't call me. I seriously doubt they will ever be able to resolve the fucked names. Nobody is man enough to even try.

My point is that's what's necessary in order for C++ to actually play nice with anything but other C++ programs. Sure, you can restrict yourself to a C interface... And kiss C++ goodbye. Hope you didn't like object orientation or templates.
>>
>>62410782
No you're wrong, a Java method with JNI bindings is actually a C function.
>>
>>62410782
>Calling it a C function is meaningless too. It's a subroutine with the C calling convention.
Calling it a C function is meaningful, because if I tell you it's a C function, you know how to call it properly. If I tell you it's a C++ function, it tells you nothing.
>>
>>62410846
It's a C function in its interface, but it remains a C++ function in its implementation. Your problem was that you could not implement a function in C++ and then call it from Python.
>>
>premature optimization
Why did Knut get quoted on that and not his much more accurate and convincing quote just a paragraph earlier?
People tend to call things premature optimization when they're actually too stupid to try.
I'm not for reading and memorizing https://graphics.stanford.edu/~seander/bithacks.html and using it as soon as you get a chance of course. Those don't require anything of you to do. And where they can be done productively the compiler does it. But people yell at me about premature optimization when I'm packing my structs that will be allocated in 4mb chunks with a modicum of intellect.
I'm really sick of it. I believe this is why software sucks today.
>>
>>62410864
>it remains a C++ function in its implementation
Sorry to jump in but I'd contact the standard if you've written a compiler that can do this effectively. Lots of people who use the C ABI don't do it extensively enough to realize the issues (in making C++ code work with it) but if you have people would be VERY appreciative.
>>
>>62410864
>It's a C function in its interface,
Correct.

>but it remains a C++ function in its implementation
Incorrect. It gets compiled and ceases to be a "C++ function in its implementation". If you can identify it with any language at that point, it's C.

>Your problem was
Different poster. I think the other anon got tired of arguing with someone as dense as you appear to be.
>>
>>62410825
Not him. I'd just like to note that virtual machines are different. One can never interface with the virtualized code directly, only with the virtual machine.

In other words, from C one doesn't talk to Java but to the JVM. You ask it to call methods for you, using a notation that is eerily similar to fucked C++ symbols:

helloWorldClass = (*env)->FindClass(env, "example/jni/InvocationHelloWorld");
mainMethod = (*env)->GetStaticMethodID(env, helloWorldClass, "main", "([Ljava/lang/String;)V");
applicationArgs = (*env)->NewObjectArray(env, 1, (*env)->FindClass(env, "java/lang/String"), NULL);
applicationArg0 = (*env)->NewStringUTF(env, "From-C-program");
(*env)->SetObjectArrayElement(env, applicationArgs, 0, applicationArg0);


Unlike C++ though, this format is de-facto standardized.

>>62410864
>it remains a C++ function in its implementation

We're talking about interfaces. It's astounding that you think the implementation matters.
>>
>>62410982
The implementation matters because that's what you said was not possible in >>62408789. I read this as an assertion that you cannot write a function in C++ which can be called in Python.
If you meant something else then I don't think we have a problem.
>>
>>62410876
Cargo cult. Same reason people quote Dijkstra despite never having read or even understood the original paper.

>>62411026
Well obviously! You can call a C++ implementation from any language -- if you wrap it in a C package first!

Try doing this from Python (or any language):

cpp_object->member_function(arg1, arg2);


And don't make me a wrapper function to do it for you.
>>
File: ignore_sepples.jpg (77KB, 677x463px) Image search: [Google]
ignore_sepples.jpg
77KB, 677x463px
Daily reminder.
>>
>>62410925
>might throw exception
>might do anything what the fuck sepples implementations do now days, crash for no reason?
>>
How do emulators stay true to the speed of the original hardware?

For example, every little instruction on a Z80 takes so little time it would be unrealistic to "sleep" to fill out the remaining nanoseconds. At what point then do you slow down?
>>
Do I learn Python 2 or 3?
>>
>>62411145
3
>>
>>62411101
I'm not gonna try to prove something that can't be proven. You can't take any C++ function and make it as visible as a C function, and nobody ever said that.
In the end, the only solution is to drop to the lowest common denominator. It sucks, but it is a solution.

>>62411117
Are extern "C" functions not implicitly noexcept? If not then that's a serious oversight.
>>
>>62411120
>every little instruction on a Z80 takes so little time it would be unrealistic to "sleep" to fill out the remaining nanoseconds
You just count cycles for every instruction and only perform X cycles per timeslice.
>>
How long should it take someone very familiar with C and OOP principles to pick up C++?

I want to write a short project in C++ to put on my portfolio but I don't have a lot of time before I have to submit my resume. I would write the project in C otherwise but I'd like some solid C++ experience
>>
Why are the values of i and sum respectively 100 and 45 at the end of the program? I understand there's some assignment/initialization fuckery going on but I can't determine where it is
#include <iostream>

int main()
{
int i = 100, sum = 0;
for (int i = 0; i != 10; ++i)
sum += i;
std::cout << i << " " << sum << std::endl;
return 0;
}
>>
>>62411185
Depends how in depth you go. C++ is a very big, very complicated language. Everyone writes it differently too.
>>
>>62411120
You don't need to sleep for every instruction, only for input and drawing.
Also why would it be unrealistic to "sleep" it out? If you can't just sleep you can inline assembly do nop commands until it's long enough. Though with modern operating systems I think it's hard to synchronize because you can't know how much processing time is allocated to your program even if you knew how many commands your program uses.
>>
>>62411186
The i used inside the for loop is a different i. The original is left untouched. Sum is just 0+1+2+3+4+5+6+7+8+9=45
>>
>>62411186
You declared two i variables.
>>
>>62411216
>You don't need to sleep for every instruction, only for input and drawing.
You do have to cap the number of instructions per frame somehow.

>Also why would it be unrealistic to "sleep" it out?
Not enough resolution.

>If you can't just sleep you can inline assembly do nop commands until it's long enough
And what, tune it to the precise speed of your machine? That's retarded.
>>
Anyone know why this is raising an error on "ambiguous types?"

I tried implementing the top part of the code with the bottom function, but for some reason the pattern guards aren't working as I'm intending it to work:

--works fine
testZip :: [a] -> [b] -> [(a, b)]
testZip [] _ = []
testZip _ [] = []
testZip (l1_head : l1_tail) (l2_head : l2_tail) =

--raises error in picture attached
testZip2 :: [a] -> [b] -> [(a, b)]
testZip2 l1 l2
| [] _ = []
| _ [] = []
| otherwise = (head1, head2) : testZip2 tail1 tail2
where (head1 : tail1) = l1
(head2 : tail2) = l2
>>
>>62411224
>>62411240
So the for's i is local to for and to call the main's i I would have to use ::i?
>>
>>62411186
for (int i = 0; i != 10; ++i)

this block of code can be read as

int i=0;
while (i != 10){
// do stuff in the loop
++i
}
>>
>>62411256
>I would have to use ::i?
No, that would refer to some global namespace i (which doesn't exist). You can't refer to the original 'i' inside the for loop because the other 'i' shadows it.
>>
>>62411253
>>If you can't just sleep you can inline assembly do nop commands until it's long enough
>And what, tune it to the precise speed of your machine? That's retarded.
That's what we have done with microcontrollers but there it's easier. Having operating system and multiple threads kind of fucks that one up.
>>
>>62411256
Yes. It's said that the for's i shadows the main's i. Always use braces so that the new scope is clear:

#include <iostream>

int main()
{
int i = 100, sum = 0;
// main's i is visible here

for (int i = 0; i != 10; ++i) {
// for's i is visible here, shadowed main's i
sum += i;
}

// main's i is visible again
std::cout << i << " " << sum << std::endl;
return 0;
}
>>
>>62411145
>>62411155
What's the difference?
>>
>>62411279
>>62411312
Thanks.
>>
>>62411155
Thanks, any guides you recommend? currently reading 'Learn python the hard way'
>>
>>62411202
Thanks.

What do you think about just picking up the synyax and usage of standard libraries? I'd be writing a very C-style program but using STL or Boost instead of rolling my own data structures
>>
>>62411287
Like I said in another post, you just count cycles and stop once you've reached the cap for the frame.
>>
>>62411340
2 is the legacy version of python that is installed everywhere and used by everyone and will likely be around for a long time because faggots refuse to upgrade.

3 is generally a much better and cleaner language. Cleaned up much of the retarded stuff present in 2. Broke compatibility and generated a shit ton of drama because of it.

If you're not going to maintain old shit written in 2, the answer is always 3.

>>62411348
Yes.

https://www.python.org/doc/
https://wiki.python.org/moin/BeginnersGuide
>>
>>62411366
That's a good way to start, I suppose.
STL can be a little hazardous. maps, for example, have some bizarre specifications which mean all the implementations have terrible time complexity and perform poorly. And then there's weird shit like vector<bool> which just does not do what you expect it to. If you don't learn move semantics, you'll also take further performance hits on unnecessary copies.
But if you just want to ease yourself into C++ by adding features to C that you believe will make your life easier, and don't really have anything critical going on, that's a good way to learn.
>>
is oracle's particularly shit or are all db's ass cancer to work with?
>>
File: Charliesuit.jpg (39KB, 331x408px) Image search: [Google]
Charliesuit.jpg
39KB, 331x408px
What should I be reading if I want to code for Wallstreet?
>>
>>62411531
Oracle is shit.

Try SQLite for an objectively good database. If you need scale, PostgreSQL is the answer.
>>
>>62411551
The Daily Stormer
>>
>>62411577
Way ahead of you buddy, don't you think the kikes will be pulling any fastballs on me
>>
>>62411458
Thanks. Performance isn't a huge deal. I'll take a C approach, researching the STL library I want to use, and trying to use classes where I'd use a struct.

>>62411551
C++ covers most trading firms from what I can tell. Put a cryptocurrency related trading project on your resume (written in C++)
>>
>>62411666
*High frequency
>>
>>62411575
it's for a class so i can't. good to know though
>>
File: gooby pls.gif (1023KB, 390x219px) Image search: [Google]
gooby pls.gif
1023KB, 390x219px
>>62411762
>class involves use of oracle database

What the actual fuck
>>
>>62411792
yep, it's also all windows in the all the classrooms too. i got a free ride so idc but at least some of the teachers force kids to do assignments with unix. for one class it was a nu teacher with a faggy haircut who assigned us a program requiring windows dll's. i was kinda ticked that time, ngl
>>
>>62411985
I bet the money's good tho. For the school administration, that is.
>>
Improving implementation on a few of my python bots, making bits more modular so I can take commands from one bot and add them to another with minimal alterations.
>>
bash scripting on windows
>>
>>62409722
>Only Satori

What fucking level N337???
>>
Niche question but I can't think of where else to ask it:

I want to roleplay as Dennis Ritchie with my boyfriend roleplaying as Brian Kernighan while I'm developing a toy language. He's not a computer scientist, programmer, or anything of the sort. How the FUCK do I introduce the idea to him without making him go "lol wtf" and saying no?

please help me
>>
>>62412188
Post tits
>>
>>62412188
and I mean an extended sexual roleplay, just to be clear (trying to and succeeding in fucking me while I'm programming on the bed)

politely saging myself
>>
>>62412206
Unironically consider suicide
>>
File: 1459179996701.jpg (14KB, 238x192px) Image search: [Google]
1459179996701.jpg
14KB, 238x192px
I can't understand strtok in C

help
>>
>>62412188
>>62412206

https://twitter.com/dpttxt/status/908041830046072832
>>
>>62411666
Not that guy, but any suggestions for a cryptocurrency-related project?
>>
>>62412412
dumb frogposter
>>
>>62412412

Read the description of the function until you do understand it.

http://en.cppreference.com/w/cpp/string/byte/strtok
>>
>>62412559
i'd call myself experienced in C and that's a really weird function. can't blame him for not getting it. i read the man page and didn't get it at first. it's got a static variable in the function keeping track of things which is unusual in every stdlib function i've seen
>>
God.
I hate running across things.
https://www.youtube.com/watch?v=CRnnarKkm9Y
Someone at pycon has to explain what a hacker is (in the programming sense, the default sense) to a crowd of python programmers.
Truly these are the brainlets of our time.
>>
>>62412412
>strtok
>str to k
It converts a C string to a K string. What don't you understand?
>>
File: loot-crate.jpg (1MB, 1441x2560px) Image search: [Google]
loot-crate.jpg
1MB, 1441x2560px
loot crate just came in the mail
>>
>>62412669
why are you watching a pycon conference
>>
>>62412559
>>62412669

It's a really shitty stateful function that should be avoided at all costs. Use actual tokenizers and parsers rather than some halfassed shit you found in the standard library.
>>
>>62412441
try lurking hn "who's hiring" threads, there is always a bunch of cryptocurrency hipster companies postin, bizarrely high salaries tbqh. maybe their posts can indirectly give you an idea for a project
>>
>>62412441
https://github.com/butor/blackbird/blob/master/README.md
>>
File: Screenshot_20170913_222501.png (145KB, 968x1060px) Image search: [Google]
Screenshot_20170913_222501.png
145KB, 968x1060px
Hello /dpt/. I'm kind of new to programming but I made a Python program with curses interface that reads dbus and automatically detects the song you're listening (currently Spotify only) and fetches the lyrics online. I've managed to ignore all the Spotify "Remaster" and "Mono Version" shittery too. Now all I have to do to get lyrics is press Meta + F12 and F1 within the script to refresh it whenever the song changes. Easy.

Is parsing raw HTML from a lyrics site illegal? Can I share this script with anyone?
>>
if i could choose how to implement the strtok function, it would take (char* string, char* delimiter, int* offset) and increment the offset to the new index of the string after completing. without and NULL weirdness
>>
>>62412835
>t. too dumb for strtok
>>
>>62412846
And this is way way way more complicated than I'd make for my resume. I'd just build the trading logic without using any actual exchange APIs
>>
>>62412877
>t. retard who thinks some legacy junk he found on the standard library must be good
>>
>>62412835

I'll agree that it's pretty shitty, but it's not complicated if you just read the description of the fucking function.
>>
>>62412899
>t. idiot who thinks he's smarter than creators of standard libraries, which have been universally accepted
>>
>>62412899
>t. retard who doesn't understand the merits and intricate design of strtok
Go back to sepples.
>>
>>62412933
I said it was shitty, not that it was complicated.

>>62412934
>I worship the people who gave us gets
>I worship the people who gave us errno

>>62412935
LOL
>>
>>62412849
not illegal but the website will probably complain if your traffic is really noticeable. if you throttled and spaced out your requests you'll fly under the radar more
>>
>>62412968
>t. too dumb for gets and errno
Back. To. Sepples.
>>
File: donarudo-kun.jpg (62KB, 640x499px) Image search: [Google]
donarudo-kun.jpg
62KB, 640x499px
>>62412999
>too dumb for gets
>implying there is even one (1) way to use gets correctly
>>
File: 1496998730043.jpg (33KB, 493x386px) Image search: [Google]
1496998730043.jpg
33KB, 493x386px
>>62413043
>doesn't know how to use gets correctly
>openly admits it
>excepts to be taken seriously
>>
>>62412980

>traffic is really noticeable
Yeah... by "sharing" I was thinking uploading it somewhere and linking it if someone asks for it in a desktop thread or something.

>if you throttled and spaced out your requests you'll fly under the radar more
I only request the HTML code once on start and once every time F1 is pressed so I doubt anyone will notice.

Thanks for the response.
>>
File: 1503495028142.jpg (69KB, 680x680px) Image search: [Google]
1503495028142.jpg
69KB, 680x680px
>overflowing strings on purpose
>>
>>62413094
by noticeable i meant like, if you were scraping pages with milliseconds between requests
>>
File: patrician.gif (415KB, 480x238px) Image search: [Google]
patrician.gif
415KB, 480x238px
>>62413093
Enjoy your buffer overflows
>>
>>62413125
  char* chr;
gets(chr);
printf("%s", chr);


I just tested it with a really long string and nothing bad happened. Simple and buffer-overflow-free. You're welcome, brainlet.
>>
File: fuck.png (147KB, 800x800px) Image search: [Google]
fuck.png
147KB, 800x800px
>>62413158
>>
>>62413114
>overflow your own string buffers on purpose just to move on to the next function
>>
>>62413188
>gets proven wrong
>b-b-bait! i-it's bait!
Sure thing, Stroustrup.
>>
>>62413230
Look here, you fucking arsehole. Le sepples meme was all fun and games at first, but the moment you compared me to that Danish gnome you crossed the line.
>>
>>62413230
i think the implication was that your post was bait, not his
>>
>>62413299
>implying you understood my implications correctly
>>
>>62409782
1337 SKILLZ M8
>>
>frogposter starts shitflinging ITT yet again
>>
File: Capture.png (2KB, 204x25px) Image search: [Google]
Capture.png
2KB, 204x25px
>>62413158
>and nothing bad happened. Simple and buffer-overflow-free
>>
>>62413377
>running it on windows
>expecting anything good
There's nothing wrong with that code. It runs fine on Arch. Get a real OS.
>>
File: Capture.png (32KB, 808x208px) Image search: [Google]
Capture.png
32KB, 808x208px
>>62413393
>implying Windows
>implying running well on Arch means anything
>>
>>62413424
>implying it's my fault that you broke your system
Maybe you should stick to Windows, then.
>>
>The Day of the Programmer (in Russian: Дeнь пpoгpaммиcтa) is a russian professional day, that is celebrated on the 256th (hexadecimal 100th, or the 28th) day of each year (September 13 during common years and on September 12 in leap years). It is officially recognized in Russia.
>>
>>62413448
>implying my system is broken
>implying yours isn't for allowing such behavior
>>
>>62413464
>tfw the company had an outdoor event yesterday
>tfw stayed at the office and browsed 4chan instead
>>
>>62413469
>b-b-but it breaks on my machine!
>implying your screenshot isn't fake
That's not a measure of the code's validity. It runs fine.
>>
Is there a way in C++ to get a for loop to loop back early?
i.e.
for(loop 3 times) {
if(condition1) {
go back to for loop
}
}

Or is there a different sort of loop you could use for it?
>>
>>62413565
You mean break?
http://en.cppreference.com/w/cpp/language/break
>>
>>62413565
continue;
>>
I have a list of objects, all objects draw a circle on the screen, and each object in this list may or may not have an "effect" component which tells what color it is. Like:

object.effect->makeBlue();

The problem is that if "effect" is null, it breaks. So I always have to write a check to see if effect is null every time I want to (automatically) call the method, and I want to avoid that. What's the best way to move this check elsewhere so I won't have to write it every time I want to call makeBlue()?
>>
>>62413565
Would break not just stop the loop?
>>62413582
How would that be used?
>>
File: Capture.png (23KB, 1159x125px) Image search: [Google]
Capture.png
23KB, 1159x125px
>>62413543
>implying silently allowing overflows is "running fine"
>implying Arch isn't garbage
>implying you won't be looking back at this and cringing for ever defending gets
>>
>>62413565
can't you just use a normal for loop with an iterator int and just set the int to 0 to start over?
>>
>>62413605
Ah, I see what you mean now. He's right, you need continue. It just jumps to the next iteration.
http://en.cppreference.com/w/cpp/language/continue
>>
>>62413605
first meant to be for >>62413578
>>
>>62413583
instead of setting it to null if it doesn't have one
create a generic do-nothing function and assign that instead, then they can all be called safely and no checking is needed
>>
>>62413605
>How would that be used?
in your example replace
>go back to for loop
with
>continue;
>>
>>62413627
>>62413582
nvm I got it.
Thanks!
>>
File: 1489610198161.jpg (9KB, 250x250px) Image search: [Google]
1489610198161.jpg
9KB, 250x250px
>/a/ is making fun of us again
>>
File: 1496690244379.jpg (43KB, 390x470px) Image search: [Google]
1496690244379.jpg
43KB, 390x470px
>>62413607
Even your compiler knows you're too much of a brainlet to use gets correctly. Anyway, you haven't proven that there's anything wrong with my code.
>>
>>62413634
What do you mean, assigning a function instead of an object?
>>
>>62409722
https://youtu.be/uU0oa4lVaZI
>>
>>62413680
>implying you're not a brainlet for not understanding the dangers of gets and why it is, in fact, not running normally on your machine
>>
File: my-sides.jpg (6KB, 200x200px) Image search: [Google]
my-sides.jpg
6KB, 200x200px
>>62413728
>implying you're not a brainlet for taking any of this seriously
>implying you're not a brainlet for spering about buffer overflows when i'm passing it an uninitialized pointer
>>
>>62409722
Is there any set-based database thing that does not use SQL?
I would use ndbm but it does not support the intersection, union, and other set operations.
>>
>>62413763
>merely pretending
Seems like I've won
>>
>>62413763
>passing uninitialized pointers
As long as you don't forget to cast them.
>>
>>62409759
Untyped lambda calculus. You can even reduce or implement CoC in it.
>>
I HATE checking bounds
>>
>>62413786
>t. i will argue about code i didn't even read
>>
>>62413684
if effect can be null, then it should be possible to not even have an effect, rather than having a variable that's just null
make effect a component
then your object can have a map of components
in Effect, instead of MakeBlue, have a generic function called Update
then Update could just be the same as MakeBlue, or it could be anything else
then your call to what you used to call MakeBlue would happen in here
pseudocode:

for each component in object:
component.Update();


as you can see, no check is made anywhere here
>>
>>62413783
implement your own
>>
>>62413823
It's okay, everyone has their "C is the greatest" phase. Best to stop now before it gets to cringy to look back upon.
>>
>>62413855
*too, my bad
>>
>>62413668
Link?
>>
>>62413851
I have no idea how I could implement something like that efficiently or what algorithms I could use.
>>
>>62413855
>arguing about gets
>not even knowing that you're supposed to pass it a pointer that points to initialized memory
>thinking I'm a C programmer
>>
File: C.jpg (53KB, 430x575px) Image search: [Google]
C.jpg
53KB, 430x575px
>C
>>
>>62413895
>commence damage control
>>
>>62413915
You do that, kiddo. But what's the maymay arrow for?
>>
>>62413953
I'd hate to be this dumb
>>
Just installed Python. What should I write? I'm shit at programming btw
>>
File: tired-pepe.jpg (11KB, 251x242px) Image search: [Google]
tired-pepe.jpg
11KB, 251x242px
>>62413989
Back to lebbit with you.
>>
>>62414000
>What should I write
A javascript compiler.
>>
>>62414011
>posts frogs
>pretends to be not a redittor
>>
File: c17.png (40KB, 900x623px) Image search: [Google]
c17.png
40KB, 900x623px
>>62414033
How do?
>>
File: 1497573605480.jpg (60KB, 500x495px) Image search: [Google]
1497573605480.jpg
60KB, 500x495px
>>62414046
>misspells lebbit
>doesn't understand strtok
>doesn't understand gets
>>
File: 1502301401220.jpg (30KB, 316x202px) Image search: [Google]
1502301401220.jpg
30KB, 316x202px
>>62414046
fuck off
frog is 4chan
>>
>>62414063
Just read the Google V8 source code.
>>
File: 1505200820352.png (631KB, 1200x900px) Image search: [Google]
1505200820352.png
631KB, 1200x900px
Why webdev isn't a part of /dpt/?
>>
How does this line work?
vector< vector<int> > a(n,vector<int>(n));

I know that it's making a matrix of nxn, but I don't get the second part of the constructor, where it's meant to initialize the values.
So it's being initialized by the value of vector<int>(n)? I don't get it.
>>
>null as part of the language
>true and false as part of the language
????
>>
>>62414115
>words as part of the language
what were they thinking!?!?!
>>
>>62414132
Yeah, MS is retarded.
>>
>>62414115
>EOF is part of the language
>true and false as part of the language
???
>>
>>62414110
That's right. a is being filled by n copies of vector<int>(n).
>>
>>62409842
echo is a bash builtin though.
>>
>>62414093
>Why webdev isn't a part of /dpt/?
Because web development doesn't count as real programming. Get back to me when javascript and PHP have functions like strtok and gets.
>>
Need input on an idea for watching config files I had:

Many programs allow config files to be "watchable", i.e any change made triggers a change in a currently running program. Change a port number, and the server restarts it's transports to listen on that port number.

So I had the following thought, what if I had the original config file as usual, and then ANOTHER that represented the current "state" of the application config? To illustrate:

- On startup looks for config file (config.yml), reads from it
- Applies any "overrides" through command line parameters
- When done determining settings, the application
writes a new file named e.g "current_config.yml"
that can be watched and edited
- This "current" config file is completely overwritten every
time the application starts, and is ideally deleted on
graceful application shutdown


That way, we can keep the original file, and edit the "new" config file without overwriting a lot of the changes coming from the command line or other places.

Does this sound useful?
>>
>>62414393
sepples has strtok too, though.
http://www.cplusplus.com/reference/cstring/strtok/
>>
>>62414451
Okay, but sepples users are still not real programmers. Mastering strok is a necessary but insufficient condition.
>>
>>62414093
Ny pogodi
>>
>>62414393
>gets
Not even C has it now.
>>
>>62414501
That's just one of many issues with (((C11))).
>>
Why does strtok save the current token internally making the function not thread safe?
Instead they could have had it take 1 more size_t pointer as parameter which would hold the end of toke offset.
>>
#include <stdio.h>
// only chars for delim
const char *not_strtok(const char *s, char delim) {
while (s && *s != '\0' && *s != delim) ++s;
while (s && *s != '\0' && *s == delim) ++s;
return s;
}

void split(const char *s, char delim, char join) {
for (const char *p; s && *s != '\0'; s = p) {
p = not_strtok(s, delim);
for (const char *x = s; x != p && *x != delim; ++x) putchar(*x);
if (*s != delim && *p != '\0') putchar(join);
}
}

int main(void) {
split(" a series of words bla foo ", ' ', ';');
return 0;
}
>>
>>62414531
Because your suggestion is bad design.
>>
>>62414583
>omitting the curly braces of the whiles
Disgusting.
>>
>>62414583
Wait, what? Your function doesn't even actually do what strtok is supposed to do.
>>
>Therefore, when the math in a particular section in this chapter starts looking ugly, skim through the section until you locate the useful, nonugly formulas, rules, and so on, that do not have weird mathematical expressions in them. You don’t have to be a mathematical whiz to be able to design decent circuits.
circuit designers confirmed for shit tier job
>>
Anyone bootstrap a forth from assembly? Trying to build my own toolchain I figure forth would be easier to write a c compiler in than assembly.
>>
>>62414683
Is that a quote form a buzzfeed article?
>>
>>62414713
Practical electronics for inventors
>>
>>62414655
Yeah, I was trying to do something that does not keep internal state and can handle string literals. So, pretty much not_strtok.
>>
>>62409775
>Rust
>Low-level
>Not literally filled with bloat
>>
>>62414418
I think it's a bit confusing to edit a temporary file to make an application change its behavior, when I write something in a config file I would expect it to be present the next time I run the application
I do think changing options while running is useful tho, but if the application has any kind of user interface it should happen there. If not, maybe have a helper program that can send config overrides to a running process, so you could do something like $ myAppCtrl -set Port:1337 UseTCP:y
you could use tempfiles for that, but I think for a user it's a more sensible way to change the behaviour for the current run of the application. Of course you can still watch the config file for persistent changes.
>>
>>62414739
>i was trying to do something that does not keep internal state and can handle string literals
Okay, and it also doesn't actually return tokens, so it's not a good replacement for strtok.
>>
>>62414418
Good points. I was thinking of this to solve the use-case where the config file doesn't actually end up describing the application settings due to command line parameters and such.

I agree they should happen in a user interface.
>>
>>62414872
meant for >>62414833
>>
>>62414531
There is a C11 and a POSIX version of strtok which both are thread-safe. I think they do something similar (except with pointers).

>>62414584
Not really.
>>
>>62414872
>I agree they should happen in a user interface
yeah, but not every application has/needs one
In that case I would use a helper program or something similar that allows you to change options from the command line
>the config file doesn't actually end up describing the application settings due to command line parameters and such
I think an option to dump the current config might be helpful for that, so you can always know definitely how the application is configured. So if you had experimented a bit with changing options around at runtime and finally got it doing what you want, you could just do something like $ myApp --dumpconfig > myapp.conf
>>
actor Main
new create(env: Env) =>
env.out.print("Hello, world!")
>>
File: 1448214077279.png (17KB, 1154x860px) Image search: [Google]
1448214077279.png
17KB, 1154x860px
r8 my solution. does this count as recursive?

int GCD(int m, int n) {
if(n == 0)
return m;
int remainder = m%n;
m = n;
n = remainder;
return GCD(m,n);
}
>>
>>62415128
hey, dumping the current config doesn't sound so bad.
>>
>>62415191
yes?
>>
>>62415191
>does this count as recursive?
Yes, but that's just a stack-overflow-prone way to emulate a loop.
>>
>>62415214
Imo the most useful would be if the --dumpconfig printed what's basically a valid and usefully commented config file
>>
>>62415191
What if I call GCD(INT_MIN, -1)?
>>
>>62415245
ok thanks
>>62415252
how to improve?
>>
>>62415252
Also, you might as well just do this:
int GCD(int m, int n) {
if(n == 0)
return m;
return GCD(n,m%n);
}
>>
>>62415267
no clue, apparently INT_MIN is an undefined constant
>>
>>62415272
>how to improve?
Just use a normal loop to do exactly the same thing.
>>
>>62415279
that looks beautiful, thanks anon. i knew there was a better way but i couldnt figure it out
>>
What's the best wiki markup language?

Creole?
Markdown?
>>
Is this worth buying for £47?
>>
Started making a simple torrent client in C++ for practice. I don't have much programming experience beside some uni courses so this might be difficult. Just got the decoding of single-file bencoded .torrent files working.
>>
>>62414583
const char* not_strtok(char* out, int n, const char* s, char delim) {
for(; *s && *s == delim; ++s);
for(; *s && *s != delim && n > 1; *out = *s, ++out, ++s, --n);
for(; *s && *s != delim; ++s);

*out = 0;

return s;
}


That's more like it.
>>
>>62415443
No.
>>
File: knking.jpg (32KB, 407x500px) Image search: [Google]
knking.jpg
32KB, 407x500px
>>62415498
forgot image
>>
>>62415516
what a waste of money
give me a few minutes let me upload it for you
>>
>>62415634
>>62415516
>>62415443
https://my.mixtape.moe/kbltwo.tar.xz
>>
>>62415652
is this the scanned copy?
>>
I am working on a Gherkin parser which generates ABAPUnit test cases from feature descriptions and steps.
>>
The individual operations used in a counter program are often. Grouped into logical units called _____________.
A. procedures B. variables C. constants D. logistics
>>
>>62415736
That would be amazing.
>>
File: bait-but-also-true.png (17KB, 522x384px) Image search: [Google]
bait-but-also-true.png
17KB, 522x384px
Reminder
>>
>>62416067
>assembLER
hate this meme
>>
>>62415387
Most people are familiar with markdown so markdown
>>
>>62415449
That's been on my backlog for over a year now. Are you following any reference implementation?
>>
File: 1483889196911.png (786KB, 829x636px) Image search: [Google]
1483889196911.png
786KB, 829x636px
>>62416067
>developing in Haskell faster than developing in Python
>>
>>62416067
.GCC, G++, Assembler
. /\
.Guile, GHC CPython, etc
>>
>>62416310
blame yurop
>>
>>62416478
Assembler is a program, not a language
>>
>>62416598
GCC is a program, not a language.
>>
>>62412835
thats why you use strtok_r
>>
>>62416469
>I can write wrong code very quickly in Python!
>what is maintenance?
>>
>>62416400
http://www.kristenwidman.com/blog/33/how-to-write-a-bittorrent-client-part-1/
Just following this small guide I found on google and also the unofficial bittorrent specification. I'll study some implementation if I run into huge problems with this.
>>
>>62416838
>what is PEP 484 and PEP 526
>>
>>62416969
Gee, its almost like type systems are actually important or something.
>>
>>62416969
>optional typing
typelets, when will they learn?
>>
File: 20248132.jpg (122KB, 1920x1480px) Image search: [Google]
20248132.jpg
122KB, 1920x1480px
In C++,
1. How can one declare a derived member variable?
2. Initialize a static member variable with a certain value, preferably inside the class?
>>
>>62417051
Is there a semi-relevant typelet lang that hasnt had optional typing stuff yet?
>>
>>62417152
1.
struct AA {
int aa_;
};

struct BB : AA {
int aa_;

BB (int aa1, int aa2) {
aa_ = aa2;
AA::aa_ = aa1;
}

int fn1 (void) { return AA::aa_; }
int fn2 (void) { return aa_; }
};

2.
struct AA {
static int aa;
};
// in a .cc file, you can't to initialize in the header otherwise every TU the header is in will allocate space for the variable and you might get link errors i can't remember
int AA::aa = 5;
>>
>>62417152
>2
dont remember if its in c++ yet or still a proposal but you can use inline.
class foo {
static inline int x = 10;
}


modules cant come soon enough, all this fucking shit in c++ is horrible.
>>
>>62417212
JavaScript, but it's only relevant because of web browser shenanigans

Scheme?
>>
>>62416999
type systems are memes
>>
>>62417266
>JavaScript
typescript.
And yeah Lisp is probably the only one.
>>62417271
t. pythonista code crafter
>>
>>62417280
>typescript
Isn't that a separate language to JS?
>>
>>62417286
yeah ,its more of a superset, so its still very JS like.
>>
>>62417280
>And yeah Lisp is probably the only one.
Lisp is actually good though.

Funny how we've had so many non-Lisp dynamic languages in the last few decades and none of them has even managed to be as good as Lisp, let alone better.
>>
>>62417351
>Lisp is actually good though.
nah.
We already have performance languages that can be scripting langs as well. There goes Lisp's only job.
>>
>>62417280
Let's see I'd have to make more type errors than all the time you've spent writing types... gee somehow I don't think that could ever be true.
>>
>>62416937
bookmarked, thanks
>>
>>62417386
https://www.youtube.com/watch?v=3U3lV5VPmOU

Type systems aren't just about preventing type errors.
>>
>>62417386
a good type system is also an annotation is also your documentation.
Good type systems also severely reduce run-time errors.
>>
Rate my language. The aim is readability and maintainability. As a result, it's quite verbose with no type inference and very little coercion allowed.

declare Farter {
method fart(duration: Seconds, intensity: Percentage<Integer>): Result<Void>;
method getShartProbability(): Percentage<Integer>;
}

impl Farter {

ivar isFarting: Boolean = false;
ivar shartProb: Integer = 0;

constructor() {

}

method fart(duration: Seconds, intensity: Percentage<Integer>): Result<Void> {
// Do something
this.isFarting = true;
this.shartProb = Random.integer(fromInclusive=0, toInclusive=100);
return Result<Void>.success();
}

method getShartProbability(): Percentage<Integer>;
return Percentage<Integer>.fromIntegerSaturating(integer=this.shartProb);
}

}

struct FartAppArgs {
ivar duration: Integer;
ivar intensity: Integer;
}

func main(rawArgs: RawArguments): Result<Integer> {
lvar argsSpec<FartAppArgs> = new ArgumentSpecification<FartAppArgs>();
argsSpec.registerArg(longName="duration", shortName="d", targetMember=FartAppArgs.duration);
argsSpec.registerArg(longName="intensity", shortName="i", targetMember=FartAppArgs.intensity);

lconst parsedArgsResult: Result<FartAppArgs> = argsSpec.fromRaw(raw=rawArgs);

if (parsedArgsResult.getWasSuccessful()) {
lconst parsedArgs: FartAppArgs = parsedArgsResult.getValueAssumingSuccess();

lvar farter: Farter = new Farter();
lconst fartResult: Result<Void> = farter.fart(duration=parsedArgs.duration, intensity=parsedArgs.intensity);
if (!fartResult.getWasSuccessful()) {
Console.printf("Fart failed.\n");
return Result<Integer>.fromInteger(-2);
} else {
lconst shartRisk: Percentage<Integer> = farter.getShartProbability();
if (shartRisk.getIntegerSaturating() > 15) {
Console.printf("Warning: Significant shart risk.\n");
}
return Result<Integer>.fromInteger(0);
}
} else {
Console.printf("Invalid arguments.\n");
return Result<Integer>.fromInteger(-1);
}
}
>>
>>62414783
nostd Rust is pretty nice.
>>
>>62417500 (Me)
Formatting was ruined, try this: https://pastebin.com/typsDqYp
>>
>>62417500
java / 10
>>
>>62417538
Java has two major failings which I'm trying to avoid:
>Can't segregate interface from implementation
My declare{} and impl{} blocks can be in different files, and a changed impl{} does not require recompilation of anything that used the corresponding declare{}.
>Awful runtime
My goal is to require nothing other than a C runtime and the plan is to support direct calls to C ABIs and near-direct use of APIs too.

I do need to revisit how heap management will work, though. Maybe by requiring the use of explicit allocation pools instead of a magic "new".
>>
File: 1504477321486.png (10KB, 645x773px) Image search: [Google]
1504477321486.png
10KB, 645x773px
>>62417500
>maintainability
>no type inference
>>
>>62417402
>academic, haskell
nope

>>62417447
nah documentation is your documentation.
Other than type errors what other errors does it reduce?
>>
>>62417662
Compare:
lconst foo = someThing.findFooable();

What is `foo`? Is it a Foo, a Fooable, a Foo[], a Result<Foo>, a FooSearchResponse<Foo, FooSearchError>? I have no fucking clue! Better hope my IDE is good enough to figure it out.
Versus:
lconst foo: Result<Foo> = someThing.findFooable();

Now I know immediately what I'm dealing with, without needing massive IDE muscle to decide.

Making changes requires more keystrokes now, but that is not the deciding factor for maintainability.
>>
>>62411376
Does this really work?
Sounds like an amazing hassle to deal with multiple alus, fpu and the varying throughput for each instruction.
>>
>>62417743
I didn't realize I was dealing with a brainlet that relies on an IDE for everything.
>>
>>62417734
Documentation is just detailing how your functions work.
instead of a paragraph comment about why and what your args are. Everything is right there in the declaration
>>
>>62417500
These are the boring parts of language design. You've pretty much been completely swallowed in featureset by other languages.
Do something new.
>>
>>62417734
>Other than type errors what other errors does it reduce?
Nothing. But the stronger the type system, the more errors you can make type errors.
>>
>>62417757
You might have misread me. I don't want my language to require an IDE, or at least not any particular one, so I want a codebase written in it to be readable without helpers.

In my first example, you have to either remember, guess, look up, or have your IDE tell you what findFooable() returns. In my second example, you already know exactly what it returns because it's written write there in the source file.

Also, if the declaration of findFooable changes later, the error message will make more sense.
>>
it's kind of aesthetic how monolithic oracle is. cool name for a company too. less kitsch than 'google'
>>
>>62417808
In a language with type inference, a user could still use an annotation if they wish, and would reap the same benefits. But you are taking away that choice.
>>
>>62417500
><>
shit/10
>>
>>62417851
What syntax do you prefer for generics?
>>
>>62417500
>fart
>getShartProbability
HAHAHAHAHAHHAAHHAHAHAHAHAHAHAHA
>>
>>62417835
If a maintainability feature is optional, nobody uses it. I don't want codebases written in my language to end up looking like javascript.
>>
I'm bored, who has that list of 100 or so projects
>>
>>62417908
have you even read the dragon book all the way through?
>>
>>62417864
something using () [] {}, i think D uses a ! prefix.
foo!(int)()

just not <>; shit like this is terrible.
w<x||y> z;
>>
File: prog_challenges_v4.png (2MB, 3840x2160px) Image search: [Google]
prog_challenges_v4.png
2MB, 3840x2160px
>>62417931
>>
>start reading about java parallelism for a class project
>get met with this
https://docs.oracle.com/javase/tutorial/collections/streams/examples/ParallelismExamples.java

can't make it up
>>
>>62418038
puttering
>>
Anybody here familiar with GPU (NVIDIA CUDA to be precise) programming and python?
I'm planning on writing a small python module that uses CUDA codes underneath but I don't know where to start.
>>
>>62417937
>i think D uses a ! prefix
Yeah, ! is template instantiation.

array.each!writeln
>>
>>62417768
yeah right

>>62417790
It's like if firemen set fires so they could extinguish them because fighting real fires was too hard.
>>
>>62418126
You're an idiot.
>>
>>62418136
Remember what Dijkstra said about BASIC, and apply the same reasoning to Python.
>>
i hate java so much
>>
>>62417931
>>62417964
Please fuck off
>>
>>62418402
why was this anon triggered, /dpt/?
>>
>>62418136
>>62418383
lmao and the circle jerk is complete. Back to writing Haskell for your professors kids.
>>
How to put if statements inside if statements?
pls help
def ragequit():
print("Opinion discarded.")
print("R"+"E"*69+"!!!")
quit()
def start():
meme = input("Do you like memes?: ")
if meme == "y"or"yes"or"sure"or"yea"or"yeah":
pepe = input("You you like Pepe the frog?: ")
if pepe == "y"or"yes"or"sure"or"yea"or"yeah":
print("You're cool.")
elif pepe == "n"or"no"or"nah"or"na":
ragequit()
else:
print("What?")
elif meme == "n"or"no"or"nah"or"na":
ragequit()
while 1:
start()
>>
Not really that relevant but is vanilla octave garbage in your experience?
Should I be using it? or some other version?
Got a student license for matlab but fuck matlab.
>>
File: 1495230699862.jpg (606KB, 1395x858px) Image search: [Google]
1495230699862.jpg
606KB, 1395x858px
>>62418462
>>>/r9k/
>>
I'm tearing my fucking hair out lads.

I'm setting up a simple deploy script to run some git commands on a server when you push. All I want is to get the directory inputted, and run git status, but for some fucking reason it's not working

Deploy code is

curl -s http://website.com/deploy.sh | bash -s ../git/wowpro.git


Code for script is

#!/bin/bash

gitDir=${1:-../git/wowpro.git}

echo $gitDir > text.txt

ls $gitDir >> text.txt

git --git-dir=$gitDir --work-tree=. status >> text.txt 2>&1


And I'm getting back
../git/git/wowpro.git

fatal: Not a git repository: '../git/wowpro.git
'


It works when you input the directory straight into the git command but for some fucking reason not when using a variable.
>>
>>62418462
It's python3 btw
>>
>>62418455
I'm not in academia and I don't write Haskell. Try again.
>>
can a java conniseur please post the most minimal fork/join program to show me how it works? i can't tell what is what in the documentation examples. there's so much java boilerplate and idk what's from something it's important and unrelated to demonstrating fork/join, and what's relevant
>>
New thread: >>62418610
>>
>>62412732
Youtube recommends bullshit to me now because I was searching for python shit.
Yes I've been FORCED to use python.
>>
>>62410240
>I see you're one of those guys who can't even begin to imagine the assembly the compiler will generate. C++ tends to do that to people.
I check the assembly output of my C++ programs all the time.
It's not big, in fact it often ends up better than the equivalent C code would output, simply because creating efficient abstractions is easier in C++ than it is in C.
>>
Why are C programmers so retarded? You guys know nothing about programming, nor do you have any idea on what you're talking about, and you are always wrong about everything.
Thread posts: 346
Thread images: 43


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