[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: 41

File: DPG.png (39KB, 180x193px) Image search: [Google]
DPG.png
39KB, 180x193px
What are you working on, /g/?

Old thread: >>59377805
>>
File: 1460210945075.webm (331KB, 1280x720px) Image search: [Google]
1460210945075.webm
331KB, 1280x720px
>>59383468
Thank you for using an anime monad!
>>
How can I tell if some language is a scripting language?
>>
File: 1483469700943.gif (499KB, 500x281px) Image search: [Google]
1483469700943.gif
499KB, 500x281px
>>59383531
It being dynamically typed already means it's both "scripting" and "shit".
>>
>>59383598
What if the language is object-oriented?
Can I call it a scripting language?
>>
>>59383531
If it doesn't have to be compiled?
>>
>>59384139
But that's what makes language interpreted though.
>>
>>59383531
It's it makes it easy to do useful things in very few lines of code.
>>
anyone here uses nuklear.h gui lib?
i need a C gui lib i can skin to be all sexy and material. will i be able to with nuklear.h?
>>
>>59384295
>sexy
>material
Please don't
>>
what are your opinions on how constexpr variables in file/namespace scope should be named? like do you think they should be in camelCase or in FUCK_YOU_CASE? i'm tempted to do FUCK_YOU_CASE because they're used in the same way as a #define constant would be, and it makes them easier to distinguish from run-time camelCase variables so you know it's a compile-time value when looking at code that uses it, and it's consistent with the naming convention of class-scope static final variables in java.
>>
>>59384294
> Forth, Haskell
> scripting
what are you on?
>>
>>59384476
this especially if it's not on android
>>
>>59385136
Rather than few lines of code I should have said little amount of work. Also not just some useful things but pretty much anything high level. If that's still true for haskell then yes I'd call it a scripting language. The clue is that a scripting language is not mutually exclusive with other types of languages. Some languages can be good at both scripting and more "serious" programming. Not sure if that applies to haskell etc though as I haven't used it.
>>
Awk or Perl?
>>
>>59385201
But haskell is compiled and forth is high level after 8-16 words depending on what you're working on (and it's compiled too).

it's almost as if you'd call x86 a scripting language when comparing it to arm due to the feature set
>>
>>59385372
Being interpreted is not a requirement for being a scripting language. And i don't get your instruction set analogy
>>
File: --1069.jpg (52KB, 500x522px) Image search: [Google]
--1069.jpg
52KB, 500x522px
How do we make a scripting language that doesn't suck?
>>
>>59385682
>what is lua
>>
File: S_Mostek-MK68000P-8B.jpg (34KB, 433x239px) Image search: [Google]
S_Mostek-MK68000P-8B.jpg
34KB, 433x239px
Are the Motorola 68k microprocessors still used in anything?
I'm taking a class next quarter on Computer HW & Organization, and one of the textbooks is on that chip. I thought that was kind of a goofy choice.
>>
File: --283.png (937KB, 776x795px) Image search: [Google]
--283.png
937KB, 776x795px
>>59385801
And how is Lua in bare environment?
Let's say, can I make a web server in Lua?
>>
Running legacy JBoss for uni project.
It's run on Java 8, although it shouldn't.
Should I be worried?
>>
>>59386242
*It works with
>>
>>59386187
As far as I know, m68k is widely used among microcontrollers.
>>
>>59386205
>And how is Lua in bare environment?
As long as you have C you can then add Lua as it has low requirements. That is one of its strengths
>Let's say, can I make a web server in Lua?
Possible, it exists, but it's niche
>>
>>59386507
Well, and how about a general-purpose scripting languages?
>>
>>59385637
Forth is a systems language meant to run without an OS... it is the OS in most cases

Haskell is a system for writing large and complex programs correctly
>>
>>59387423
Then they don't "make it easy to do useful things in very few lines of code." as was my first requirement
>>
>>59387335
Having to do that just to get declarations closer to statements that use them may well be the symptom of a function body that is getting too large. You can avoid that by splitting the function body into shorter functions.

I have the same problem in C++, because I don't want to get too many methods in my classes, but then I end up with gigantic methods with declarations all over the place. Eventually, while refactoring, I split the code inside public methods into shorter private methods. This way, it's even easier to define constant references at the start of the private methods to get more concise code afterwards.
>>
>>59386242
>>59386283
I remember Java keeping backward compatibility, so new Java should run old Java code.
>>
File: inputstream.png (44KB, 900x400px) Image search: [Google]
inputstream.png
44KB, 900x400px
I'm trying to write a simple file transfer program in Java using TCP Sockets.

I'm apparently not understanding how I/O streams work. Eclipse is telling me I need to cast a socket's getInputStream() as an InputStream in order to use it as such. Does getInputStream() not return an InputStream?
>>
File: beavis computer.gif (337KB, 492x376px) Image search: [Google]
beavis computer.gif
337KB, 492x376px
>>59388272
Aw fuck, ignore me. I'm retarded and imported the wrong InputStream LOL
>>
>>59387031
What do you mean? Lua is pretty general-purpose.
>>
>>59386242
should be ok. i can't think of anything that breaks backward compatibility off the top of my head
>>
>>59383598
>matlab/octave and mathematica are all shit
okay
>>
I'm trying to design syntax that appears algol-like but is actually homoiconic like Lisp.
How does this look?
fact : fn(int.t) -> int.t;
fact = fn(x) {
let {
aux : fn(int.t, int.t) -> int.t;
aux = fn(n, a) {
cond
[n == 1] { a }
[else] { aux(n - 1, a * n) }
}
};
aux(x, 1)
}
>>
Trying to make a CHIP 8 emulator and am learning how to do graphics using SDL.

I have a question... When I run the following code, pic related appears (a white rectangle shows up instead of the pattern I draw), what should I be doing instead?

int main(int argc, const char * argv[])
{
SDL_Window* gWindow = NULL; //Window we'll render to
SDL_Surface* gScreenSurface = NULL; //Surface contained by the window
if(SDL_Init(SDL_INIT_VIDEO) < 0)
{
printf("SDL cound not initialize! \n\t SDL Error: %s\n", SDL_GetError() );
}
else
{
//Create Window
gWindow = SDL_CreateWindow("SDL Tutorial",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_WINDOW_SHOWN);
if( gWindow == NULL)
{
printf("WINDOW Coulnd't initialize! SDL_Error %s\n", SDL_GetError());
}
else
{
//Get Window Surface
gScreenSurface = SDL_GetWindowSurface(gWindow);
SDL_FillRect(gScreenSurface, NULL, SDL_MapRGB( gScreenSurface->format, 0xFF, 0XFF, 0xFF)); //Fill screen white
SDL_UpdateWindowSurface(gWindow); //Update surface
}
}
std::cout << "Testing..." << std::endl; //wait 2 sec.
drawPattern(gScreenSurface);
SDL_Delay(5000);

}
void drawPattern(SDL_Surface* screen)
{
int count = 0;
for(int row = 0; row < SCREEN_HEIGHT; row++)
{
for(int col = 0; col < SCREEN_WIDTH; col++)
{
if(count%2)
setpixel(screen, col, row, 0, 0, 0); //Turn pixel black
}
}
}
void setpixel(SDL_Surface* screen, int x, int y, Uint8 r, Uint8 g, Uint8 b)
{
Uint32* pixmem32;
Uint32 color;

color = SDL_MapRGB(screen->format, r, g, b);
pixmem32 = (Uint32*) screen->pixels + x + y;
*pixmem32 = color;
}
>>
>>59390819
You're only calling SDL_UpdateWindowSurface once.
>>
>>59390873
Alright... I added
    SDL_UpdateWindowSurface(gWindow);

after the drawPattern() call, but it didn't seem to do anything... Is there a way i can update the SDL Window with a given SDL Surface?
>>
File: wieo.jpg (383KB, 2149x3035px) Image search: [Google]
wieo.jpg
383KB, 2149x3035px
>>59383468
So how do cookies work with libcurl?
I've performed my POST request and logged in, now how do I make subsequent requests so that the server knows I'm logged in?
>>
>>59390819
>what should I be doing instead?
using sfml
>>
does c have anything nice besides messing with pointers and function pointers?
>>
>>59391449
There appears to be some kind of C revival going on. Now all the python shits are trying to use it.
>>
>>59391449
"messing with pointers" grants you a lot of power.
If you want to learn to be a wizard in C though, master the preprocessor.
>>
>>59389073
for programming they're definitely shit. they're good for mathematical computation where you're mostly just dealing with numbers or lists of numbers so you don't care too much about the type
>>
>>59391449
C++ has everything C has and more
>>
>>59383636
Yes.

You can also call it worthless.
>>
https://www.youtube.com/watch?v=lC8X9qRuOvQ
>>
>>59392068
Sometimes less is more.

Fuck C++.
>>
>>59392068
Except coolness.
>>
>>59392068
>>59392105
C++ is fine but using most of its features can get quite bothersome rather fast.
>>
>>59392152
C++ really fucked by trying to be so much. If it had just been "C with classes," it might have been pretty nice.
>>
>>59392179
Ew fuck no.
>>
>>59392179
What I dislike is how it's doing so many things behind your back (did you just use an overloaded operator on a non-POD datatype? enjoy the 15 constructor calls) when it could do so with less overhead. This is much more unnerving than the excessive amount of features. But I don't fancy the way some people in /dpt/ dismiss anything C++ just because it's C++ either.
>>
>>59386187
No. M68k is the standard for teaching because its easy. Old tech otherwise.
>>
>>59392293
We had MIPS which feels even less used. M68k can be used for some calculators at least.
>>
File: encapsulationClassPrivacy-Notes.png (211KB, 3840x2160px) Image search: [Google]
encapsulationClassPrivacy-Notes.png
211KB, 3840x2160px
Hey /g/ I'm having trouble reproducing this code from my lecture class. The prof. wrote it in one file but I'm trying to separate it into multiple files but I'm getting a link error. I'd reckon this doesn't count as being homework related since it's more of trying to understand the lecture.

Thanks in advanced
>>
>>59392426
Don't include resource.cpp in main. Functions are declared in Header.h when compiling the main translation unit, symbols are then resolved at link time.
>>
What's all this about with scalaz and a code of conduct?

https://github.com/scalaz/faq/blob/master/conduct.md

https://groups.google.com/forum/#!topic/scalaz/fwEaMXlMtis
>>
Since C doesn't support switching based on a string, would creating an array of strings, comparing the input to each one, returning the index of the matched string, and using that for a switch statement be viable way of implementing it, if you just really didn't want to use an else if chain for some weird reason?
>>
>>59392517
You mean iterating through the array, returning the first index for which strcmp returned zero? Should work.You'd have to keep the indices and strings in sync, might be better to have a structure like

static const string_ids[] = {
{ STR_HELLO, "Hello" },
{ STR_HOWDOYOUDO, "How do you do" },
{ STR_GOODBYE, "Goodbye" },
};


and return the STR_ enum value associated with the matched string, that way it's less easy to let them get out of sync.
>>
I need to learn PHP for some upcoming jobs but I don't know where to start, I usually learn a language by doing projects that will test my understanding of the language but this is my first web language and I don't know where to start. Any suggestions?
>>
>>59392551
Welp I messed up the declaration (forgot the type) but you get the idea.
>>
>>59392517
The first option is slightly less efficient but better design.

void foo(const char *input, size_t n) {
switch(getbar(input, n)) {
case fizz: ...
}
}
>>
>>59392553
I think >>>/g/wdg/ knows better.
>>
>>59392553
A book or tutorial is always a good place to start
>>
He got an email from some guy with an mit.edu email
>>
File: overworldcuteflowers.webm (2MB, 1146x728px) Image search: [Google]
overworldcuteflowers.webm
2MB, 1146x728px
Beautiful flowers, aren't they?
>>
>>59392567
Forgot about them, thanks
>>
>>59383468
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
>>
>>59392553
Pluralsight/team tree house
>>
>>59392553
not that hard. look for a tutorial on it, like any other language. this time you make a web folder where you can also put html files and install wamp.
>>
>>59392577
Replace the square with a cute anime girl, or at least one would look like if they were a square.
>>
>>59392577
That's actually a rather smart and well-done way to render pixel flowers, I like it a lot.
>>
>>59392601
parse error<59392601:2>: "what" expected
Replace the square with a cute anime girl, or at least one would look like if they were a square.
^
>>
>>59392616
Thanks!
>>
>>59392620
Good job, you managed to pick up by error based on context.
Congratulations for proving that you recognise language.
Do you want a fucking medal?
>>
>>59392577

Neat.
>>
>>59392639
kindness error<59392639:4>: rudeness detected
Do you want a fucking medal?
^
>>
>>59392639
parse error<59392639:2>: "my" expected
Good job, you managed to pick up by error based on context.
^
parse error<59392639:3>: All euros should be euthanized
Congratulations for proving that you recognise language.
^
parse error<59392639:4>: Rude language, please revise
Do you want a fucking medal?
^
>>
File: 1489461328707.png (740KB, 1834x1200px) Image search: [Google]
1489461328707.png
740KB, 1834x1200px
>>59392068
this 2bh
>>
>>59392663
thanks pal
>>
>>59392692
Would you be inclined to go fuck yourself, were I to ask you to do so?
>>
>>59392714
only if you provide the lube, bb
>>
>>59392730
>lube
>Having a mutilated dick
>>
>>59392757
Oh, I thought you wanted to put it in my butt
>>
>>59392410

>MIPS which feels even less used
Back in the late 90s, early 00s, MIPS was king for game consoles. These days, it's mostly used for some routers and a couple of IoT devices.
>>
>>59391348
Please respond.
>>
File: parser.png (9KB, 934x57px) Image search: [Google]
parser.png
9KB, 934x57px
I've made a KISS hand-written LL(1) parser, don't know what I'll do with it yet.
>>
>>59392692

>All euros should be euthanized
Wut.
>>
>>59392929
s instead of z
>>
>>59392944
Why the hell would you think I was European for typing that, you stupid American?
>>
>>59393077
I'm not him.
>>
File: dany.png (435KB, 812x672px) Image search: [Google]
dany.png
435KB, 812x672px
If you prefer to program in C over more modern languages you are literally autistic.

free() yourself
>>
>>59393084
I prefer to program in C and OCaml.
>>
>>59393077
>i-i'm akshually british, not european

keep deluding yourself lmao
brits are absolutely european
>>
>>59393128
I'm not British, though.
I'm about as far away from the EU as you can get.
>>
>>59393143
Straya?

Kiwi?
>>
>>59393151
Obviously, you fucking reddit spacer.
>>
>>59393156
Yes but which one?
>>
>>59392919
>Please res
You actually do have examples in the libcurl doc and online. What is it exactly you don't get?
>>
>>59392928
Obviously you should make it to simplify expressions.
>>
>>59393166
Why do you care?
>>
Given a sequence of characters, encode from binary to a series of 0's.

A single 0 will indicate the following number of 0's is that many 1's
Two 0's will indicate the following numbers of 0's is that many 0's.

e.g. C is 1000011, so that's
0 0 00 0000 0 00

I put something together earlier today but I'm curious if somebody can come up with something more elegant or clever.
>>
>>59393212
Kiwis are aight

Aussies are rude
>>
>>59393224
That's basically exactly like having 0 and 1s though, since you get 0 and spaces.
>>
>>59393224

So you just end up using spaces as ones. retard
>>
>>59393210
You mean work like a CAS? That'd be neat.
>>
>>59393236
It's not a real world problem. It's a programming exercise.
>>
>>59393236
It's meant as a mental exercise, not a purposeful creation.

>>59393244
See above.
>>
>>59393234
you what cunt
>>
>>59393275
See? This is exactly what I mean. A Kiwi would have posted a much more pleasant reply.

You can really tell which former colony got the convicts.
>>
>>59393234
I am a New Zealander.

>>59393297
>A Kiwi would have posted a much more pleasant reply.
Don't generalise, you cum-guzzling fuck face.
>>
>>59393297
Nobody cares how much of a faggot you are, stop posting
>>
This thread is insufficiently programming related.
>>
>>59393224
Why designate whether or not you want 1s or 0s? Arent you always going to alternate, since "0 00 0 000" is the same as "0 00000", so you might as well always group all combinations of 0s into a group, in which case the next group has to be all 1s, and then the next group is all 0s etc.
But then since you have no "zero" specifier, you need to come up with an encoding to tell if the first group is 1 or 0
>>
>>59393328
Where have you been when all the anti-C shitposters and no-I/O trolls kept derailing /dpt/? It's doing rather well right now I'd say.
>>
>>59393335
Read it again.

>A single 0 will indicate the following number of 0's is that many 1's
>Two 0's will indicate the following numbers of 0's is that many 0's.

0 0 means "1"
0 00 means "11"
00 0000 means "0000"
0 0 00 0000 0 00 means "1000011"
>>
>>59393342
Yeah but those things were actually programming related. Unlike this retarded /int/ shitposting.
>>
>>59393312
rude

>>59393316
very rude
>>
>>59393372
Solve this then >>59393224


Also, accessing struct members in C/++:
Node->next
or
Node.next
>>
File: Felix.gif (982KB, 374x210px) Image search: [Google]
Felix.gif
982KB, 374x210px
Is there some way I can do the following?

//C++
B_Recurr.insert(std::pair<int, long>{0, 0}, std::pair<int,long>{1, 1}); //B_0 = 0, B_1 = 1;


Basically, I want to know if I can avoid using map[index] to add a value and "insert" a key-value pair.

Currently, my compiler throws the error:
/c++/v1/map:1108:59: Cannot increment value of type 'std::__1::pair<int, long>'
>>
>>59393343
Okay i got it flipped
What im saying is that
"1000011" could be represented by
0 0 00 0000 0 00, or
0 0 00 00 00 00 0 00 or
0 0 00 00 00 00 0 0 0 0 etc
But these last encodings are excessively verbose, since they break up strings of 0s into multiple parts for no reason
If we always group strings of zeros we notice a pattern
(0) 0 (00) 0000 (0) 00
E.g. for 1100110011
(0) 00 (00) 00 (0) 00 (00) 00 (0) 00
The parenthesized markers are always going to alternate, in an encoding that is not excessive. Since we know they always repeat, there is no point in even displaying them; they are useless information
>>
>>59393413
You're supposed to use an iterator in insert, i think. I think maps .find returns an iterator that you can insert into
>>
>>59390007
not terrible
>>
>>59393414
Fair assessment. Once you have the marker for the first grouping the rest can be assumed.
>>
>>59393449
Thanks
I'm learning from trying to design this language that its hard to remove the need for a GC without making the language either verbose or just shitty and completely unmanaged
>>
>>59393413
if you're using C++ 17


map.merge(othermap);
>>
File: 1483239533988.png (358KB, 389x507px) Image search: [Google]
1483239533988.png
358KB, 389x507px
>>59393414
okay but now pretend i'm you're boss and i wrote the specs that way
you cannot reason with me
i made us change our GUID length in our databases from 32 characters to 16 for one customer, invalidating tens of thousands of logs and defeating the entire purpose of using a GUID
>>
File: 1484948815353.jpg (9KB, 255x172px) Image search: [Google]
1484948815353.jpg
9KB, 255x172px
Are you self taught, or did you go to school? If you had a choice would you do it another way?
>>
>>59393494
Self then school.
If I had a choice I'd still go to school, but I'd fight tooth and nail to test out of as many classes as humanly possible.

I genuinely believe I could condense the last two years of university education into about a month with two textbooks and P3.
K&R to learn about data types and all that shit, then something for the last 2 days of the month to learn OOP principles.
>>
>>59393489
n-no
>>
File: 1485456058361.png (131KB, 500x500px) Image search: [Google]
1485456058361.png
131KB, 500x500px
>>59393554
do it
i'm youre boss
you have to do whatever i say
>>
>>59393224
It's not the most concise solution, but I'm quite a fan of using finite state machines.
#include <stdio.h>
#include <limits.h>
#include <stdbool.h>

int main(int argc, char *argv[])
{
enum {
START,
ZERO,
ONE,
} state = START;

unsigned char n = (argc > 1) ? argv[1][0] : 'C';

for (int i = 0; i < 8; ++i) {
bool bit = (n << i) & (1 << (CHAR_BIT - 1));
switch (state) {
case START:
if (bit) {
printf("0 ");
state = ONE;
}
break;
case ZERO:
putchar('0');
if (bit) {
printf(" 0 ");
state = ONE;
}
break;
case ONE:
putchar('0');
if (!bit) {
printf(" 00 ");
state = ZERO;
}
};
}

if (state != START)
putchar('0');

putchar('\n');
}

I've written it so leading zeros are ignored.
>>
>>59393586
>i < 8
Whoops.
That should be "i < CHAR_BIT".
>>
There are three options
>require lifetime specifiers on function everything, making shit verbose and hard to typecheck
>no lifetimes, but everything is heap allocated with refcounting
>no lifetimes, but everything is unsafe and dangling pointers are extremely easy to cause
They all suck goddamnit
>>
>>59393609
with sufficient polymorphism the former is probably good

>muh arrows
>>
>>59393623
I mean I think typechecking is gonna be possible but you'll have to lob around extra variables for every lifetime and shit gets ugly fast
fn is a static function w/o closure
lfn is a function with lifetime bound closure
arrays have lifetimes too

transform : fn{T,p,q} (array(p,T), lfn(q,T) -> T) -> unit;
transform = fn(A, f) {
for (i = 0 .. len(A)) {
nth(A,i) = f(nth(A,i));
}
};
>>
File: 1310381456254.png (91KB, 645x428px) Image search: [Google]
1310381456254.png
91KB, 645x428px
>>59393586
Pretty clean looking though. About the same length as what I came up with in C# too.
I felt sloppy iterating over it as an array for whatever reason.

static void Main(string[] args)
{
char[] MESSAGE = args[0].ToCharArray();

string bytes = "";
StringBuilder sb = new StringBuilder();

foreach (char c in MESSAGE)
{
sb.Append(Convert.ToString(c,2).PadLeft(7, '0'));
}

bytes = sb.ToString();
sb.Clear();

for (int i = 0; i < bytes.Length;)
{
if (bytes[i] == '1')
{
sb.Append(" 0 ");
} else if (bytes[i] == '0') {
sb.Append(" 00 ");
}
sb.Append("0");
i++;

while (i < bytes.Length && bytes[i] == bytes[i-1])
{
i++;
sb.Append("0");
}
}
Console.WriteLine(sb.ToString().Trim());
}
>>
>>59390007
Why bother? Lisp or Tcl or Rebol syntax until you've ironed out the semantics. Then a good syntax will come more naturally to you.
>>
File: progression.jpg (198KB, 442x3520px) Image search: [Google]
progression.jpg
198KB, 442x3520px
I'm currently having some trouble using the GNU Multiple Precision Library in the C++ STL Container map.
void getA(int termNum,map<int, mpz_t>& A_Recurrence, mpz_t A)
{
if(!A_Recurrence.count(termNum-1))
getA(termNum -1 , A_Recurrence, A);

else
{
mpz_t temp;
mpz_init(temp);
mpz_set(temp, (A_Recurrence[termNum]));

mpz_mul_si(temp, temp, 2); //temp *= 2;
mpz_add(A, temp, A_Recurrence[termNum-2]); // A = 2*A_R[t-1] + A_R[t-2]
mpz_set(A_Recurrence[termNum], A); //A_Recurrence[termNum] = A...
//Save the value for later use in calculating this for larger termNums
}
}

In my program, I have a map<int, mpz_t> that, given an integer, has an mpz_t as a value. When I attempt to access the mpz_t element at a given integer index, I get the following error:
/Applications/Xcode.app/.../c++/v1/memory:1673:20: Object expression of non-scalar type '__mpz_struct [1]' cannot be used in a pseudo-destructor expression

Looking more into the specifics, the line causing me trouble is
93:36: In instantiation of member function 'std::__1::map<int, __mpz_struct [1], std::__1::less<int>, std::__1::allocator<std::__1::pair<const int, __mpz_struct [1]> > >::operator[]' requested here

and in this case, line 93 is
 mpz_set(temp, A_Recurrence[termNum]; 


It appears I cannot directly access an mpz_t from a map... Are there any ways around this? My algorithm depends on accessing previous mpz_t's from the map.
>>
>Learnt C in school
>Learn Java and C++ because I fell for the jobs meme
>Learn other languages on my own free time. Simple stuff and nothing complex
>Get hired just 2 hours ago in a job that uses Python

Did I fell for the meme that is Java and C++?
>>
>>59393210
turn it into a language so we can shitpost about it
>>
i don't work, i am work
>>
>>59393516
is it worth it being a loan cuck though?
>>
>Rust requires that you put an exclamation mark after the function name for macros
The vomit just keeps coming out, I can't stop it.
This may be a complete deal breaker.
>>
>>59393224
'abc'
|> Enum.map(fn x ->
x
|> Integer.to_charlist(2)
|> Enum.chunk_by(& &1)
|> Enum.map(& case Enum.at(&1, 0) do ?0 -> "00 "; ?1 -> "0 " end <>
String.duplicate("0", length(&1)))
|> Enum.join(" ")
end)
|> IO.inspect
>>
you guys are all plebs at programming and couldn't even program a simple tic tac toe game
>>
>>59394246
you're right
>>
>>59393224
import Data.List (group)

f '0' = "00"
f '1' = "0"

g xs@(x:_) = unwords [f x, '0' <$ xs]

h = unwords . map g . group
>>
Has anyone ever messed with youtube's api?
I kind of want to make a vote bot (I already have) that cycles though API keys and votes for however many accounts you have.
Will the accounts get banned? I don't really want to register a few hundred accounts for nothing.
>>
>>59394312
Beat me to it
import Data.List
encode = unwords . map f . group
where
f (x:xs) = (s x) ++ ('0' <$ xs)
s '0' = "00 0"
s '1' = "0 0"
>>
>>59393224
>>59393586
C golfer coming through
#include <stdio.h>

int main(int argc, char** argv)
{
const char* intro[] = { " 00 ", " 0 ", "00 ", "0 " };
int r = 0, x = 46;
for (char* s = argv[1]; *s; s++, x = 48)
printf("%s0",
(*s == r)
? "" : (r = *s, intro[r - x]));
}
>>
>>59394482
>no return
>>
>>59394525
no compiler error :)
>>
>>59394536
undefined behaviour
>>
>>59394545
If the return type of the main function is a type compatible with int, a return from the initial call to the main function is equivalent to calling the exit function with the value returned by the main function as its argument; reaching the } that terminates the main function returns a value of 0. If the return type is not compatible with int, the termination status returned to the host environment is unspecified.
>>
>>59394566
you have won this battle
>>
>>59394240
Use Nim then
>>
LLVM 4.0 is out boys. How do I get compiler-rt to work if I build it at the same time as the rest of the tree?
>>
>>59392577
>diagonal movement is faster

nice flowers though.
>>
File: 1434675590369.jpg (5KB, 176x206px) Image search: [Google]
1434675590369.jpg
5KB, 176x206px
>>> lst = [1, 2, 3, 4, 5]
>>> for i in lst: print(lst); lst.append(1)

Works as expected, infinite loop.
>>> lst = [1, 2, 3, 4, 5]
>>> for i in lst[1:]: print(lst); lst.append(1)
...
[1, 2, 3, 4, 5]
[1, 2, 3, 4, 5, 1]
[1, 2, 3, 4, 5, 1, 1]
[1, 2, 3, 4, 5, 1, 1, 1]

Does not work, no loop beyond the initial slice.
>>
What should I do?

Should I shorten the amount of lines I am writing to optimize my code?
Or keep my code lines long to make it look like I am doing work to my boss?
>>
>>59394312
>>59394380
>not doing the harder, boring and fiddly part
You are not helping """our""" reputation, guys.

>>59393224
module Main where

import Data.Char (ord)
import Data.Bits.Bitwise (toListLE)
import Data.List (group, intercalate, replicate)

notation :: [Bool] -> String
notation list@(x:_) = (if x then "0 " else "00 ") ++ ('0' <$ list)

unary :: Char -> String
unary = intercalate " " .
fmap notation .
dropWhile (\x -> x == [False]) .
group .
reverse .
take 8 .
toListLE .
ord

main = do
line <- getLine
putStrLn $ intercalate " " $ fmap unary line
>>
>>59395023
In the first you are referencing an object's address and appending it to the same address as the object so it runs in an infinite loop.
For the 2nd you are referencing the object's content and then appending it to the same address of the first object thereby replacing the content of the object listed address called lst.
>>
Secure discord server clone in C
What are some features I should implement in your opinion?
>>
>>59395058
Before you start working on it, tell me, how do you store and manipulate strings?
>>
>>59395044
0/10
>>
>>59395058
>TLS
>build server with sanitizers on
>sqlite for data
>dedicated user gets exclusive r/w access to config files
>>
>>59395071
by writing em all in a .doc and using a string mixer until you get it right ofc
>>
>>59395093
lmao, great
>>
>>59393224
$ echo "1000011" | sed -r -e 's/0+/00 &/g' -e 's/1+/0 & /g' -e 's/1/0/g'
0 0 00 00000 00
>>
>>59395052
>thereby replacing the content of the object listed address called lst
I don't understand.
>>
>>59395137
Golfed down a little more.
$ echo "1000011" | sed -r 's/0+/00 &/g;s/1+/0 & /g;s/1/0/g'
0 0 00 00000 00
>>
>>59395145
lst doesn't contain [1,2,3,4,5]
lst is the address of the object that contains [1,2,3,4,5]
You have to tell python to specifically copy the contain of the object by referencing it like you do in your second statement with lst[1:].

Try this and see what happens when you only reference the address (variable name) and not its contents.
a = [1,2,3]
b = [3,2,1]
a = b
b[0] = 2
print(a)
print(b)
>>
class SelectSort
def initialize(num)
@num = num
sort(num)
end

def num
@num
end

def sort(num)
num.each_index do |x|
min_index = min(num, x)
num[x], num[min_index] = num[min_index], num[x]
end
return num
end

def min(subset, from)
min_value = subset[from..-1].min
min_index = subset[from..-1].index(min_value) + from
return min_index
end
private :min, :sort
end

I have been trying to learn to code, so I'm working on learning a sort function, so far I have learnt bubble sort and now I'm onto selection sort.

also trying to learn it in an OOP fashion(Ruby)
this is what im currently working on. Shellsort or mergesort next.
>>
>>59395172
$ echo "1000011" | sed -r 's/0+/00 & /g;s/1+/0 & /g;s/1/0/g;s/ $//'
0 0 00 0000 0 00


Heh, forgot a space. That last expression isn't really needed: it just gets rid of a possibly introduced single trailing space.
>>
>>59395191
Thank you, I suppose that makes sense.
>>
>>59395341
Think about the difference between:
a = b
# and
a = b[:]

So when you loop you can kind of look at it like:
for x in y = z

only that y is kind of implicit.
>>
https://www.microsoft.com/en-us/research/wp-content/uploads/2017/03/haskell-linear-submitted.pdf
>SPJ is trying to retrofit Rust's borrow checker in Haskell
Haskell is finished.
>>
File: 1486453556217.png (289KB, 540x438px) Image search: [Google]
1486453556217.png
289KB, 540x438px
[lazy evaluations]
* A lazy parameter is evaluated only if it was necessary.
* It will be evaluated every time it is called inside a function body
import std.stdio, std.string;

void my_fn(lazy string input = readln().strip()){
writeln("Hello, please enter your name:");
writeln("Welcome, ", input);
writeln("Another user! Please enter your name:");
writeln("Hello, ", input);

}


void main(){
my_fn();
}

ldc2 -O -release main.d ;and ./main 
Hello, please enter your name: #<-since the parameter was lazy function skipped the evaluation and executed the first statement
Stefan
Welcome, Stefan
Another user! Please enter your name: #Called again, since lazy evaluations are evaluated everytime you call for it
Brandon
Hello, Brandon
>>
So im completely new when it comes to coding.
The questions im asking is, what is the best language that will suit me?
Here is a little about me

I'm not creative
I think coding games is dumb
I want it to be generally easy to learn
And i want it to teach me a lot so i can understand other languages better. (Like knowing Spanish, it's not too hard to learn Portuguese because they are similar.

Also about how many years does it take to actually get good and start doing worth while things?
>>
>>59395689
You sound like the people who code in python so python. It takes years to be good but days to make fizz buzz
>>
>>59395689
What do you want to do with your programming knowledge?
>>
>>59395686
> It will be evaluated every time it is called inside a function body
It's like they've read something but didn't actually understood what it's about.
>>
>>59395697
Suggest Nim
>>
>>59395689
C#
>>
>>59395702
A lazy parameter is evaluated everytime it's called from within the function
>>
>>59395700
I'm not to sure.

I know what i want to do is help by making things easier than they are right now. Like how banking, buying tickets, doing all sorts of stuff that just makes stuff in life easier. Even if it's just a tiny little thing. I mean, i don't know what i would want to improve, i guess i could think.
>>
>>59395726
Absolutely Java but you will hate it
>>
File: server_issue02.png (80KB, 1143x550px) Image search: [Google]
server_issue02.png
80KB, 1143x550px
I'm hitting a snag while programming a simple file server in Java.

When I use the line servThread.sendFile(fileField.getText()); for the button which instantiates the server object (creates a server socket and accepts a connection from a client), it works fine.

But I want the actual file sending to be triggered by a second, separate button. When I put the line in that button's ActionListener section, I get an error when I press it.

I'm not entirely sure why that is. Can anyone offer any insight?
>>
>>59395720
Yes, and it shouldn't, it should cache the value, that's the point of laziness.
>>
>>59390007
that does look quite homoerotic.
>>
>>59395737
what the fuck
is this what people have to do in java to start a server lmao?
>>
File: 1376182921994.jpg (65KB, 445x488px) Image search: [Google]
1376182921994.jpg
65KB, 445x488px
>>59395686
>>59395720
Wow, that's really fucking stupid.
Since when has laziness been about re-evaluating shit you already have?
>>
File: server_issue02.png (88KB, 1143x550px) Image search: [Google]
server_issue02.png
88KB, 1143x550px
>>59395737
A slightly better picture to explain the issue.
>>
>>59395729
really? i hear so many meme's about it
>>
>>59395775
>Since when has laziness been about re-evaluating
I never said so, I just said it is re evaluated everytime you call it which is true
>>
>>59383531
fucking look it up online
jfc anon
>>
>>59395778
they are memes, not reality
>>
>>59395782
>it is re evaluated everytime you call it
That is not what laziness is. Laziness is about not evaluating something until you need it, so you can things like infinite lists or whatever the hell you want to do with it.
All you have there is some shitty syntactic sugar over a function call.
>>
>>59395799
>That is not what laziness is.
I explained what laziness is in my first post and then added another fact. All I have there goes to prove the correctness of the both statements I made.
>>
>>59395689
java & android
>>
>>59395812
>I explained what laziness is in my first post
You don't just get to redefine shit, you idiot.

[functional programming]
* When your program has a main function
#include <stdio.h>

int main()
{
puts("I'm using a functional programming language :^)");
}
>>
>>59395689
I'm the guy who suggest Java considering your aim. However to be honest no other language can bring you productivity like python. So start there

Or learn Nim
>>
>>59395828
>You don't just get to redefine shit, you idiot.
If by redefining you mean I made an incorrect statement you can point to me there. Other than that you can stop being an edgy meme star and stop posting
>>
>>59395828
>C isn't functional PL
That's where you're wrong, kiddo:
[x] Can define functions
[x] Can return functions from functions
[x] Can use functions as function arguments
[x] Can store functions in data structures
>>
>>59395851
>you can point to me there
>* It will be evaluated every time it is called inside a function body
This is not a requirement for lazy evaluation. It doesn't have anything to do with lazy evaluation, actually.

>>59395856
Functional programming is about a lot of things, but a big point of it is referential transparency. C does not guarantee that in any way; you can mutate state however you want, at any time you want.
>>
added while loops to my compiler
compile_function("gcd_iter", [["a", "1"], ["b", "1"]],
[["tmp", "1"]],
["begin",
["while", ["!=", "b", "0"],
["begin",
["=", "tmp", "b"],
["=", "b", ["%", "a", "b"]],
["=", "a", "tmp"]]],
"a"]
)

compile_function("gcd", [["b", "1"], ["a", "1"]],
[],
["if", ["==", "b", "0"],
"a",
["gcd", "b", ["%", "a", "b"]]])

you jelly interpreterlets?
>>
>>59395867
>You can't have FP without RT
So Haskell and Idris are the only FP out there?
>>
>>59395867
>* It will be evaluated every time it is called inside a function body
>This is not a requirement for lazy evaluation. It doesn't have anything to do with lazy evaluation, actually.
It does, eager evaluation is evaluated once while lazy evaluations are evaluated every time you ask for it. Is it too hard for you to understand that I am pointing a basic difference between lazy and eager evaluation?
>>
>>59395697
>but days to make fizz buzz
You don't even need to know how to program to write fizzbuzz. It's just logic, anyone can reason it out in crude pseudocode.
>t. wrote rudimentary bash scripts and fizzbuzz before even know what programming was
>>
>>59395875
>"begin"
>"while"
Why don't you use lexer and real AST?
>>
>>59395882
I don't see why you wouldn't want referential transparency if you're going to write a functional program.
At least to my understanding, FP is about the removal of mutable state, and RT/pure functions are a good way of doing that.
I suppose it's not a hard requirement, though.

>>59395889
>lazy evaluations are evaluated every time you ask for it
No, lazy evaluations are evaluated only when you need it. That's not the same thing.
>>
>>59395912
>lazy evaluations are evaluated only when you need it
When did I say otherwise? Do you have a low attention span?
>>
>>59395889
> It does, eager evaluation is evaluated once while lazy evaluations are evaluated every time you ask for it.
No, functions are evaluated every time you ask for it, lazy evaluations evaluate once and then return the cached result.
>>
>>59395917
You don't _need_ to evaluate it again the second time you use it: you already have it.
The result should be cached and used again later.
>>
>>59395903
because i don't know what those things are and started writing it in the most intuitive way

a begin expression is nice and makes writing the compiling tools easy

the language syntax can easily be preprocessed to include the "begins" and doesn't even have to look like the above, before it's compiled to assembly
>>
File: 1485764233138.png (372KB, 954x768px) Image search: [Google]
1485764233138.png
372KB, 954x768px
>>59395920
>lazy evaluations evaluate once and then return the cached result.
Doesn't look like it, in accordance with the given example
>You don't _need_ to evaluate it again
When did I say you (((need))) to? I said if you happen to call them multiple times, it will evaluate the same number of time see my example again, the second name is not Stephan it's Brandon
>>
>>59395926
I wasn't referred to the syntax but to the way to store program. Instead of storing keywords as strings and a program as a generic binary tree, it's better to use lexer to separate the input into lexemes and then use specialized data types for the syntax tree.
>>
why the fuck does this work
<head>
<script src="wine.js"></script>
</head>

<body>
<script>
const inputs = document.querySelector('#search');

console.log(inputs);
console.log('hello');
</script>
</body>


and this doesnt
<body>
<script src="wine.js"> // wine is a file with some functions i made
const inputs = document.querySelector('#search');

console.log(inputs);
console.log('hallo');
</script>
</body>


and why the fuck is there no documentation for this piece of shit langauge
>>
>>59395953
Well the problem is, the authors of D don't know what the lazy evaluation is, they failed to stole the idea properly. See https://en.wikipedia.org/wiki/Lazy_evaluation :
>In programming language theory, lazy evaluation, or call-by-need[1] is an evaluation strategy which delays the evaluation of an expression until its value is needed (non-strict evaluation) and which also avoids repeated evaluations (sharing).
>which also avoids repeated evaluations
>>
File: 1479017862316.jpg (1MB, 1305x1237px) Image search: [Google]
1479017862316.jpg
1MB, 1305x1237px
>>59395990
I don't see anything wrong with it, can you translate the program in your language and show it's output?
>>
>>59395961
i think isee what you mean
>specialized data types
forgot to mention all the expressions will "return" a 32 bit int

so if the programmer wants IO, provided i also make a library for that, they must use bitops to extract the bytes from a 32 bit int

it's slower, clunky, stupid, but i'm not aiming to replace C, but aim for correct functionality

basically i'll write a fileopen function in assembly and return the file pointer as a 32 bit int, and then it's up to the programmer to figure out what to do with the buffer - need to read more about the details here, but i think it's doable - you agree?
>>
>>59395953
>Doesn't look like it, in accordance with the given example
All your example proves that Andrei is fucking stupid and doesn't know what he's doing. No wonder the language is deader than dead.
Even the wikipedia article doesn't say anything about re-evaluation.
All you have is a shitty syntactic sugar over a function call.
Here you go, C has lazy evaluation too:
#include <stdio.h>
#include <ctype.h>

char *_input(void)
{
static char buffer[128];

fgets(buffer, sizeof buffer, stdin);

char *start = buffer;
while (isspace(*start))
++start;

char *end = start;
while (!isspace(*end))
++end;

*end = '\0';

return start;
}

int main()
{
// Setting up the "lazy" variable :^)
#define input _input()
puts("Hello, please enter your name:");
printf("Welcome, %s\n", input);
puts("Another user! Please enter your name:");
printf("Hello, %s\n", input);
}
>>
>>59395999
There is nothing wrong with the implementation, the problem is the way they use well-established terms like 'lazy evaluation' without understanding what it is.
>>
>>59396018
Can you keep that (((C))) away from me, it makes me cringe.

Show me some Haskell or OCaml please
>>
>>59396025
When talking about an imperative language, an example in a
>>
>>59396030
Pressed send too early:

When talking about an imperative language, an example in another imperative language is more appropriate.
I was trying to make an example which is the same, in a language that unquestionably doesn't have lazy evaluation.
>>
>>59396030
Try not to hack your (((C))) to pretend it has lazy evaluation. Please give me a true functional programming language's example as a reference
>>
>>59396045
I think you entirely missed the point of my example.
>>
>>59395777
remove ServerThread below the 'If runButton' comment
So its just: servThread = new ServerThread(...);
>>
File: crack.jpg (192KB, 1328x770px) Image search: [Google]
crack.jpg
192KB, 1328x770px
hey guys, looking for some help. Working on the first step of a password cracker with C's DES crack function.

So I have the hash I want to crack ("target_hash", which is just the letter g hashed with a salt of 50) and then I have my for loop iterating through chars A-z while function "cryph" hashes them. Then this hash I obtained is compared against the target one.

This is the part that doesn't work. The "if" line compares both hashes and should print out and terminate when there is a match, but it never does, even though I know the match occurs. Where am I fucking up?

#define _XOPEN_SOURCE      
#include <unistd.h>
#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>
//clang -ggdb3 -O0 -std=c11 -Wall -Werror -Wshadow crack.c -lcrypt -lcs50 -lm -o crack

int main(int argc, string argv[]){

if (argc != 2){
printf("Error\n");
return 1;
}
string target_hash = argv[1];
//try 1 letter
string myhash = "a";
for (char i = 'A'; i <= 'z'; i++){
char word[2] = {i, '\0'};
myhash = crypt(word, "50");
//printf("%c", word[0]);

if (myhash == target_hash){
printf("%c\n", word[0]);
return 0;
}
}

//50KxTNIBVzx7m
}
>>
>>59396093
m != M my dude
>>
>>59396105
sorry?
>>
>>59396105
nvm, got it
>>
File: 1381228285622.jpg (27KB, 260x384px) Image search: [Google]
1381228285622.jpg
27KB, 260x384px
>>59396093
>string argv
>string target_hash
>string myhash
Disgusting. NEVER typedef a pointer.

>if (myhash == target_hash){
You're comparing pointers here.
Your stupid typedef is hiding that.
>>
>>59396014
Yes? You still have to have some kind of buffer data type for the IO.
>>
>>59396105
fixed that, but it still won't work
it just runs through the if statement, never executing it
>>
>>59395778
java is used everywhere because companies don't give a shit about the tool they use. They just follow the trends. Now we're forced to use java.

In the end you will need java, but I recommend you to start with C. It will give you better knowledge on how stuff works in general. Switching to another programming language will be easy
>>
>>59396134
beginner here. I sorta understand what you're saying, but how would I fix it? Instead of string use char[]?
>>
>>59396152
So you are telling him to follow your trend and use C where it's got 0 value for?
>>
>>59396156
I can't really bothered explaining the relationship between pointers, arrays, and strings in C to you right now.
Anyway, just replace it with "if (strcmp(target_hash, myhash) == 0)" and it should work.
>>
>>59396141
yes i have pointers
>>
File: crack2.jpg (60KB, 642x516px) Image search: [Google]
crack2.jpg
60KB, 642x516px
>>59396170
>(strcmp(target_hash, myhash) == 0

that's not working either.

so strings in C are just pointers to char arrays, right? and with (myhash == target_hash) I'm comparing the pointers themselves, not their content? and your suggestion should get me to compare the content itself?

and the part in yellow in the pic is sort of the "pointer part", the memory where it's stored, and that makes the two pointers different?
>>
>>59396234
>so strings in C are just pointers to char arrays, right? and with (myhash == target_hash) I'm comparing the pointers themselves, not their content? and your suggestion should get me to compare the content itself?
That's precisely it.
Anyway, they're not comparing equal because 'm != M' for the last character.
You might want to look into why it's doing that.
>>
>>59395682
>Rust invented linear types
>>
>>59396274
No, but Rust is the first practical implementation. Read the paper, they use Rust as the reference.
>>
>>59396251
>because 'm != M' for the last character.

stupid mistake on my part, but I fixed it and it still won't work.

So in C, comparing pointers never works? what about comparing a pointer to an array or any other data type?
>>
>>59396306
>comparing pointers never works
not him, but i thhink it does
if two pointers point to the same thing they must have the same value right, they are the same address
>>
>>59396306
>comparing pointers never works
Comparing pointers works if that's actually what you're trying to compare. It only really makes sense if they both point to the same array, though.
It will never compare that data it points to without you explicitly doing it, though.
>>
>>59396299
Yes, and?
What's the problem?
>>

trait Printable
{
fn print(&self);
}

impl<T: std::fmt::Display> Printable for T
{
fn print(&self)
{
println!("{}", self);
}
}

fn main()
{
597.print();
3.14.print();
(8 * 4).print();
"lol".print();
}


Rust is pretty cool I guess.
>>
>>59396574
that shit looks complicated and bloated as fuck
>>
>>59396628
That looks better than C 2bh
>>
>>59396637
yes but if i want to write c i just need to hack some bullshit code and not worry about remembering and learning about traits, impl and lifetimes
>>
>>59396574
in Haskell this is just

print :: Show a => a -> IO ()
print = putStrLn . show
>>
>>59396664
yes but haskel is slower and shittier than rust
>>
>>59396679
>slower
there's no reason that particular code couldn't be optimised to the same level as rust, and it's largely IO bound anyway. perhaps the only problem is laziness

>shittier
not at all
>>
>>59396664
Well it's
fn print<T : std::fmt::Display + ?Sized>(v: &T) {
println!("{}", v);
}

in Rust, but that's not the point.
>>
File: offcenter.png (41KB, 480x560px) Image search: [Google]
offcenter.png
41KB, 480x560px
I'm using a GridBagLayout to create a simple Java GUI but some of my Swing components are off-center. I think it's due to the length of the JTextField on the right side. As I vary the length of it, the buttons far below it will also move.

Can anyone advise me on how I can prevent this from occurring? Making elements be absolutely-centered and not vary?

Pic related shows how the alignment of the buttons seems to change with the length of the JTextField above.

    public void run(){        
//Set layout and constraints
panel.setLayout(new GridBagLayout());
GridBagConstraints gc = new GridBagConstraints();

//Add Swing components to panel using GridBagLayout with the GridBagConstraints we've specified
gc.weightx = 0.5;
gc.weighty = 0.5;

gc.gridx = 0;
gc.gridy = 0;
gc.gridwidth = 1;
gc.anchor = GridBagConstraints.LINE_END;
panel.add(portLabel, gc);

gc.gridx = 1;
gc.gridy = 0;
gc.anchor = GridBagConstraints.LINE_START;
panel.add(portField, gc);

gc.gridx = 0;
gc.gridy = 1;
gc.anchor = GridBagConstraints.LINE_END;
panel.add(fileLabel, gc);

gc.gridx = 1;
gc.gridy = 1;
gc.anchor = GridBagConstraints.LINE_START;
panel.add(fileField, gc);

gc.gridx = 0;
gc.gridy = 2;
gc.gridwidth = 2;
gc.anchor = GridBagConstraints.CENTER;
panel.add(sendButton, gc);

gc.gridx = 0;
gc.gridy = 3;
gc.gridwidth = 1;
panel.add(runButton, gc);

gc.gridx = 1;
gc.gridy = 3;
panel.add(stopButton, gc);

gc.gridx = 0;
gc.gridy = 4;
gc.gridwidth = 2;
panel.add(statusLabel, gc);

//Add panel(s) to JFrame
frame.add(panel);
frame.setSize(480, 280);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
>>
>>59396736
Use QML
>>
>>59396735
that's exactly the point
>>
File: haskell_is_slow.png (30KB, 765x149px) Image search: [Google]
haskell_is_slow.png
30KB, 765x149px
>>59396717
>there's no reason
There is a reason, according to SPJ himself: https://www.microsoft.com/en-us/research/wp-content/uploads/2017/03/haskell-linear-submitted.pdf .
>>
>>59396717
>there's no reason that particular code couldn't be optimised to the same level as rust
Maybe in a magic pixie world where optimisation is not an NP-hard problem, but unfortunately that is not the world we live in.
>>
>>59396736
Use WPF
>>
>>59396772
She's programming in Java, anon.

It's a good choice for desktop applications, but doesn't make sense in this case.
>>
Why is naming things so hard?
>>
>>59396790
Did you just assume their gender?
>>
>>59396751
>>59396772
Afraid this isn't too helpful. I googled both of these and am not really seeing how either can be used to solve my problem simply.

Is there not simply a constraint or a value I can simply implement to prevent these cells from aligning themselves based on the content of other cells?
>>
>>59396762
>that particular code
???

and GHC does do sharing analysis, it just isn't guaranteed or always inferrable
>>
>>59396769
>NP-hard
Let me correct myself:
It's actually undecidable.
>>
>>59396769
>>59396821
>that particular code
>>
>>59396736
Sorry, I don't think there are many people who use Swing in their day to day programming stuff.

I would honestly suggest StackOverflow. Thousands of pajeets want those points and someone has to know Swing.
>>
>>59396864
What do people use for native gui these days? Not everyone is using js, right?
>>
>>59396574

Is this basically Java interfaces in Rust?

public interface Printable {
default public void print() {
System.out.println(this);
}
}

public class Foo implements Printable {
// no wait, that was it actually. I'm done now.
}
>>
>>59396902
autism is a beautiful thing anon. thanks for the laugh
>>
>>59396902
If you're targeting mainly Windows users, which is very likely, WPF is commonly used.

It depends on the language you're using, though. Obviously, if you only know Java, and have no intention of learning C#, WPF wouldn't be the solution. I've heard JavaFX is good for simple things, but last I checked, Swing/Qt were the way to go.
>>
>>59396902
Depends. It it's Linux or Unix it's probably gtk. Qt/QML is pretty popular too.
>>
>>59396902

Most of us Java programmers that aren't stuck in the US fixing Pajeet-code are making web interfaces these days.

JavaFX is the new hotness, but I haven't used it for anything yet, because again, mostly web backend.

Seriously, just ask StackOverflow. Or just live with your grid sizes being "wrong".
(don't they resize to fit all your stuff? I haven't read up on gridbag, I just know it's supposedly the best layoutmanager. But you might want to make sure that you allocate each grid the correct size.)
>>
>>59396963
>JavaFX is the new hotness
You are like 7 years behind the times
>>
>>59396963
>make a simple one-scene JavaFX GUI program
>120MB RAM usage

Kill me
>>
>>59396921
What? My bud has been shilling electron like there is no tomorrow. The whole "let's just put v8 into desktop app" idea seems bizarre. Last time I wrote gui apps was years ago and I used wpf for one and wxwidgets for another

>>59396943
>>59396945
>>59396963
Cool, thanks guys. Not the op tho, just curious
>>
>>59390819
Stop reading lazyfoo. You should return on an error, not make an else block. You'll be 20 levels of indentation in if you do that.
>>
>>59396963
>hello world in java
>100 megabytes
>>
>>59394624
I was putting that off but I'll guess I'll change that now
>>
>>59396299
Read the paper again, they list why Rust does it badly
>>
>>59396968
It only became standard with Java 8, so it's still the "new" thing.

>>59396977
Again, I haven't used it.

>>59396996
Come off it. It's not funny, and it's not true.
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}

Takes 534 bytes when compiled with javac on an NTSF filesystem.
>>
>>59383531
Scripting languages are optimized for scripts. That is small programs that does something. Not large programs.

So Java is the anti-scripting language, being designed for large scale programs.
Python is a scripting language being designed for smaller programs.

Scripting languages are great, so long as you script with them. If you send me a 2mb .sh file and it doesn't contain any binary blobs, my internal screaming will be loud and unending.

OTOH, if you write a java program to copy some files from folder a to folder b, you're an idiot.
>>
>C
>>
>>59397183
>What is floating point arithmetic?
>>
>>59385682
You can't. Because most scripting languages don't suck anon.

Bash is GREAT if you just want to wire some programs together in a simple fashion and maybe something a tad more advanced, but it sucks because people write more advanced stuff in it.

People push their scripting languages much farther than they're meant to go, and then complain that they suck.

Case in point: JavaScript.
Great for making the hamster gif dance when you mouse over it, but... really guys?
>>
>>59397183
>>> sum(.01 for _ in xrange(100000))
999.9999999992356


Hmmmmmmmmmm
>>
>>59386242
No. Backwards compatibility like that is one of Java's strengths.

JBoss will just run faster.
OTOH, JBoss? Why?
>>
>>59383468
>180x193
What the fuck is wrong with you? Do you not realize that you're saving and posting thumbnails? You probably have hundreds if not thousands of thumbnails saved that you ignorantly post you fucking moron. Fucking leave.
>>
>>59393489
Beat him over the head until he relents.
Since he's calling it GUID and not UUID, I assume MS shop, so say something about MS compliance with industry standards leveraging levers and so on.

And GUIDs are 128 bytes, aren't they?
>>
File: ayyy.png (50KB, 1152x130px) Image search: [Google]
ayyy.png
50KB, 1152x130px
>>59397183
wow, you must be some kind of a hacker daniele

would you mind carefully reading dis wikipedia page tho
https://en.wikipedia.org/wiki/Single-precision_floating-point_format
>>
Is there a faster way of plugging in common statements like "print" than auto-complete in pycharm?
>>
>>59383468
I'm a newfag on this board, trying to learn C#.

All I see here is windows 10 botnet, but I have windows 7 installed and all the books are for windows 8 and 10.

What gives? Are there no books for windows 7?

Should I just bite the bullet and learn something else?
>>
>>59397308
Did all the old editions of books disappear from reality or or are you just retarded?
>>
>>59397308
If you're trying to learn C# it shouldn't matter as long as you're on a recent version of Windows. Just install whatever version of VS the book is using.
>>
>>59397308
You can develop in C# on 7 just fine, as long as you're not trying to make UWP applications.
>>
>>59397183
I don't know what you're doing wrong, but it just werks for me.
>>
File: tiff.jpg (28KB, 600x350px) Image search: [Google]
tiff.jpg
28KB, 600x350px
>tfw you whip up some algorithm and it's slow as shit, taking over a second to run
>tfw you manage to reduce its runtime to like 3% or less of its original run time
>>
>>59397441
Usually ends up like that. With all optimizations, there's usually an 80/20 rule as to what's causing the slowdown (e.g. writing to console on every element rather than buffering).
>>
https://bugs.ruby-lang.org/issues/12004

>following the 4chan guy meh's epic resistance against SJW infection of his project...
>Matz absolutely rekts the same SJW in a most skillful display of polite Japanese form
>they even cite the opal trainwreck against her

Tell me again why the Ruby community is so hated.
>>
>>59397210
Your bashing of JS just proves you know jackshit about it.
>>
>>59397561
you're*
>>
>>59397183
>(You)
>>
>>59397321
I'm probably retarded but also a poorfag who can't really buy books so I just pirate them. Can't really find pirated ones of earlier versions somehow
>>
>>59397545
There are many potential reasons to hate a community regardless of this /pol/ bullshit. Like, you know, actual technical reasons.
>>
>>59397674
Really? Because when people shitpost about it, it's just "it's for faggots/macfags/SJW" and zed shaw's rails ghetto sometimes does come up
>>
File: 1483886935718.jpg (17KB, 236x350px) Image search: [Google]
1483886935718.jpg
17KB, 236x350px
writing my own bittorrent library for practice
the protocol isn't nearly as well designed as i expected it to be
>>
Is there an easy way in Git to apply the HEAD commit of a branch to another branch?

eg applying M7 to B4 in this:
Master: M1 -- M2 -- M3 -- M4 -- M5 -- M6 -- M7
Branch: B3 -- B4
>>
>>59397762
rebase it, will make it look like:
>Master: M1 -- M2 -- M3 -- M4 -- M5 -- M6 -- M7 -- B3 -- B4
>>
>>59397762
cherry-pick the HEAD of master while working on branch:
$ git checkout branch
$ git cherry-pick M7
>>
File: cringe.jpg (13KB, 200x200px) Image search: [Google]
cringe.jpg
13KB, 200x200px
>>59393095
>C-ancer
>OCamcer
>>
>>59397848
>>59397782
Thanks, the cherry-pick one did what I wanted
>>
New thread:

>>59397998
>>59397998
>>59397998
>>
>>59397969
Software is cancer.
Technology is cancer.
Life is genetically-engineered cancer.
Cancer is uncontrolled life.

Make your conclusions from these facts.
>>
>>59384139
That isn't a property of any given language.
>>
>>59397183
Retard
>>
>>59399144
>Bump
This thread is at bump limit.

Next thread:
>>59397998
>>
>>59399169
Bump.
>>
>>59385102
I prefer iNVERTEDcASE
Thread posts: 325
Thread images: 41


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