[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: 321
Thread images: 39

File: dpt-programming-cheatsheet.jpg (586KB, 4020x1449px) Image search: [Google]
dpt-programming-cheatsheet.jpg
586KB, 4020x1449px
Remember to wear striped socks and eat raw hot peppers to improve your programming abilities! What are you working on, /g/?

Old thread: >>62369794
>>
File: himegoto considered harmful.png (1MB, 1000x1400px) Image search: [Google]
himegoto considered harmful.png
1MB, 1000x1400px
void* based generics are strictly better than macro based generics
>>
>>62374078
I don't get the peppers meme
>>
>>62374109
Eat one and try programming. Then you'll understand.
>>
>tfw to smart to go to university
>>
File: file.png (474KB, 932x921px) Image search: [Google]
file.png
474KB, 932x921px
generating fractals

this one's a little spooky
>>
>>62374095
You mean void *based generics
>>
>>62374123
Why anon?

CS theory might seem useless at first but it's useful for becoming a great programmer
>>
Autodidacticism
>>
>>62374137
maybe she(he) means void *based, *generics
>>
>tfw a really good programmer you look up to says you're a good programmer
>>
Find the dangling reference.
>Protip:
You can't

#include <iostream>
#include <string>
#include <vector>
using namespace std;

struct StudentGrade {
public:
string name;
char grade;
};

class GradeMap {
private:
vector<StudentGrade> m_map;

public:
GradeMap() {}

char& operator[](string key) {
for (int i = 0; i < m_map.size(); ++i) {
if (m_map[i].name == key) {
return m_map[i].grade;
}
}
m_map.push_back(StudentGrade{key});
return (m_map.back()).grade;
}
};

int main() {
GradeMap grades;

char& gradeJoe = grades["Joe"];
gradeJoe = 'A'; // does a push_back

std::cout << "Joe has a grade of " << gradeJoe << '\n';

return 0;
}
>>
>>62374137
But pointer are a part of the type ?
>>
>>62374095
anything is better than macros
>>
>>62374185
C disagrees
>>
File: asdf.png (13KB, 758x708px) Image search: [Google]
asdf.png
13KB, 758x708px
here is a challenge.

code arbitrary circular movement on a (x,y) grid WITHOUT using trigonometric functions.
>>
>>62374198
? But the compiler will emit a warning if you try to call a fonction without the right amount of pointer.
>>
>>62374213
int *x, y; // x is a pointer, y is not

C hates types and it hates you for liking types.
>>
say, what is the difference between C, C++ and C#, and which one should learn to code in?
>>
>>62374212
do x and y correspond to polar coordinates
>>
>>62374226
I don't know how this is relevant to the conversation
>>
>>62374228
C for desktop software is terrible and people should stop doing it
C++ is okay, but its syntax is horrid
C# is Java done right, with Microsoft's dick in your ass (in a bad way)
>>
>>62374234
Yes
>>
>>62374234

no
>>
>>62374248
>C# is Java done right,
really sick of this meme
>>
>>62374212
>WITHOUT using trigonometric functions.
People use trig for this?
>>
>>62374255
just increase y
>>
>>62374212
>x^2+y^2=r^2
ez
>>
>>62374267
circular movement means going around, not in and out
>>
File: no trig allowed.png (24KB, 411x329px) Image search: [Google]
no trig allowed.png
24KB, 411x329px
>>62374267

>x^2+y^2=r^2

wrong
>>
>>62374212
>hey guys I have this logical problem for you but the catch is: you can't apply logic to solve it
>>
File: IMG-20170912-WA0006.jpg (3KB, 136x145px) Image search: [Google]
IMG-20170912-WA0006.jpg
3KB, 136x145px
>>62374078
>>
>>62374308

>hey guys I have this logical problem for you but the catch is: you have to come up with a different way to solve it,

perfectly valid thought exercise.
>>
>>62374286
the proof of that theorem involves trig but application of it does not involve trig

unless you think pythagoras' theorem is trig
>>
>>62374286
what the fuck are you even talking about? the definition of a circle with radius r and center p is "the set of points a distance r away from p." The distance formula is applied there, no trig needed.
>>
>>62374330
>>62374336
>lets use the definition.
do you also write X equals X as the answer in your calculus tests?
>>
>>62374377
cute
>>
Does anyone have experience with pandas dataframes in python?
I'm normally a C programmer and I'm feeling quite lost. There doesn't seem to be a function that resolves a window of values into a single or multiple values. i.e. func(df[1][0+100*n:100+100*n]) -> new df or new column in existing df that resolves to one value per row.
I'm not particularly CPU-time constrained yet,
but given what's ahead it will surely happen. And I'm feeling like I shouldn't do a O(n*100) algorithm in python. Doesn't seem like good practice.

So if anyone has any pointers that'd be great.
>>
>>62374535
>n*100
Well actually I don't even know the constant here.
Could be way worse.
>>
>>62374535
firstly, dont prematurely optimize
secondly big O notation drops the constant, so its just O(n)
thirdly O(n) is the fastest you can get for most algorithms
>>
>>62374535
>O(n*100)
that's sill O(n) you ape
>>
>>62374628
Calm down, no need to be so hostile to him.
>>
>>62374228
C will develop your understanding of how stuff works in memory
>>
File: Most misquoted man ever.png (43KB, 275x246px) Image search: [Google]
Most misquoted man ever.png
43KB, 275x246px
>>62374621
>dont prematurely optimize
Read the rest of the very page that you source that thinking from.
And if you haven't read the source (as you clearly haven't because this quote comes after pic-related) don't even bother quoting. What's the point? The point of quotes is to bring points across from previously established truths. But if you lie about the sources intent as you do here. You're just fooling others into believing the same falsehood.

Data science tools are designed to alleviate performance concerns using higher level languages. But you can't do that by having python iterate row by row, extracting values and doing whatever to them. You need something else.

>>62374628
>big o drops the constant
I'm perfectly aware I'm describing my problem succinctly.
Why would I tell you "I don't wish to iterate 100*n objects to yield a single output result directly in python, surely a data science tool have better methods for this?".
Rather than being perfectly clear like I've been.

If you're a god damned student who thinks having constants in bigO is somehow a sin you should immediately point out as if these constants are irrelevant to performance is pure lunacy.

>>62374645
I'm perfectly fine with hostility. He's being a dumbass.
>>
>>62374703
Damn. I lack some commas here. You're riling me up with this ridiculous bullshit.
Why do I even come here anymore? Especially at these hours. Nobody with a brain is here at this hour.
>>
>>62374136
neat
>>
>>62374737

hmm wow you're so smart anon you grace us with your presence
>>
Just went to my first programmer interview and I froze up when asked what happens with an example piece of code.

I think I'm an idiot that can't problem solve under stress.
>>
>>62374778
Well, I'm not gonna be here for long. Hope you can manage without me.
>>
>>62374783
>not researching or practising before an interview
>>
>>62374783
what was the example?
>>
>>62374822
Oh I did but the real experience is where the stress is.

>>62374825
Can't remember too well but it was a for loop with the variable being incremented while under a fixed int literal. The variable was also being decremented inside the body of the for loop as well if a certain mathematical expression evalued to true. I thought the loop would terminate after 15 iterations but in fact it didn't terminate at all and looped endlessly due to the decrement operation.

Sucks since it was piss easy and I found the trick questions like
134 == 0134
easier.
>>
>>62374825
Sum the primes under 2 million.
>>
>>62374918
>a fucking gotcha question
The current state of software.
>>
>>62374327
eat(ram) raw hot peppers?
>>
>>62374942
It's called green chillies
>>
>>62374095
Why?
>>
>>62374953
green is my chili
>>
>>62374955
heterogeneous representation
>>
File: tesdet.webm (576KB, 396x392px) Image search: [Google]
tesdet.webm
576KB, 396x392px
>>62374212

give it a go guys, its fun
>>
O(cn) = O(n) for a non-zero c.

Both are asymptotic upper bounds. In infinite asymptotics, the c is extraneous. There. No more arguing.
>>
Idiot here. I'm learning Java. Is there any disadvantage to printing things across multiple lines versus printing them all at once outside of clarity?
>>
>>62374982

only in addition you god damn retard. multiplication is another ball game.
>>
>>62374985
no.
>>
File: programming socks.png (338KB, 1140x813px) Image search: [Google]
programming socks.png
338KB, 1140x813px
>>62374078
What color is best for C?
>>
>>62375013
mmm... no.

https://en.wikipedia.org/wiki/Big_O_notation#Multiplication_by_a_constant
>>
>>62374377
>let's not use the definition
then it's not circular movement, retard.
>>
>>62375013
baka
>>
>>62375045
darker pink with black bands

C stands for Cutie
>>
>>62375013
bro...
>>
>out of college for a year
>got my job without being interviewed, because I knew my boss and he knew I wasn't too dumb
>he wants me to start interviewing possible interns in the next couple weeks
So, like, what do I ask them?

I'm thinking of starting off with super basic data structure and fizzbuzz-tier stuff, just to see if I should bother going on with the interview, but after that I'm not too sure.
My best guess is to give them a chunk of flawed, but working, code that does something basic, and give them an hour or so to "make it better".
I think that way I'll see how they actually program with an existing codebase, they can use Google or whatever documentation they like, and it lets me see if they're afraid to ask questions or not.

What do you guys think? Have any of you had any interviews that you liked?
>>
>>62375164
Give them a segfault one to debug and fix.
Your idea.
And then throw a really pajeet-tier (but working) code-base at them and ask them if it needs changed, and if so have them change it.
>>
>>62375164
>So, like, what do I ask them?
See
>>62375045
>>
File: dagothscurred.jpg (129KB, 800x600px) Image search: [Google]
dagothscurred.jpg
129KB, 800x600px
>>62374078
>Current laptop is old and shit
>Need new cheap one to at least run a decent text editor + command line compiling for some small to mid sized projects (webdev, python and java stuff mainly)

Any recs for something around 300 bucks? I'm a poor student so I don't have much of a budget.
>>
>>62375303
go check out /tpg/
>>
>>62375013
WOW... if you're a CS student, time to go to office hours.

>>62375081
BTFO
>>
>>62374078
Any recommended books on R? Shit makes me wanna cut my eyes out, but I have to learn it well enough to pass to finish my degree.

I have experience programming in C and Lisp, I just need to learn what the fuck the difference between an atomic vector and a table is and why the $ operator doesn't work on atomic vectors and why it works on tables. This language seems like ass so far. Why do people use this shit?
>>
>>62375045

Green and black, to match your terminal colors.
>>
I need to program a simple maze solver

11111111111111111111
00000111111111110000
11110111111111110111
11110000000000000111
11111111111111111111


But I don't really know where to start. I already loaded the file in a pointer to pointer data structure and have a pointer to run through the stream but I don't really know how to control the rules for the movement of the 0's.

Any tips? Don't really want it solved for me, just need an idea.
>>
having c++ issues need URGENT help sned backup on my location

even when I've cast the variable that's storing the result in as a double, fmod() keeps giving me a fucking integer. about to tear my hair out and im too autistic to figure out what exactly I need to google (i've already tried). thank
>>
Welcome to AyyLmoa Company. Before we start the interview we need to make sure you know your stuff.

1)
 int* (*itn)(int, int*, uint32_t, size_t); 
Explain this piece of code and how it might be used?
2)
How would you implement a tree with a fixed sized array? Could you show us on this whiteboard?
3) Implement a doubly linked list using a custom allocator so there's no cache misses.
4) what gets implicitly attached to a c++ class when you use virtual?
5) Can you implement a function on the whiteboard (show us your process) that can convert a number of any base to any other valid base.
6) What differences exist between a degenerate binary tree and a linked list if any?
7) What benefit does size_t have for loop counters over a short?
8) Why would you not use uint64_t?
9) You have to store a large list of objects, would you use a fixed array or a singly linked list?
10) Implement quicksort in x86 assembly (Show your work on the whiteboard)
11) When implementing concurrency do you prefer locks, STM, or CSP and why?
12) Are singletons acceptable in certain situations?
13) Does the wagegap exist and if so what should be done about it?
14) How many genders exist?
15) Using higher order functions or lambdas, implement a derivative/integral library. We will unit test it.
>>
>>62375642
I'd start by loading it to a 2D array, then programming a function to read a cell, then a function to read the neighboring cells.
>>
File: 1498261341789.jpg (6KB, 250x249px) Image search: [Google]
1498261341789.jpg
6KB, 250x249px
FUCK
I HAVE UNTIL SUNRISE TO LEARN C#
WHAT THE FUCK DO I DO?
HELP ME BEFORE I THROW MYSELF OFF A FUCKING BRIDGE
>>
>>62375652
Welcome to AyyLmoa Company. Before we start the interview we need to make sure you know your stuff.
We apologize for any typos.
1)
 int* (*itn)(int, int*, uint32_t, size_t); 

Explain this piece of code and how it might be used?
2)
How would you implement a tree with a fixed sized array? Could you show us on this whiteboard?
3) Implement a doubly linked list using a custom allocator so there's no cache misses.
4) what gets implicitly attached to a c++ class when you use virtual?
5) Can you implement a function on the whiteboard (show us your process) that can convert a number of any base to any other valid base.
6) What differences exist between a degenerate binary tree and a linked list if any?
7) What benefit does size_t have for loop counters over a short?
8) Why would you not use uint64_t?
9) You have to store a large list of objects, would you use a fixed array or a singly linked list?
10) Implement quicksort in x86 assembly (Show your work on the whiteboard)
11) When implementing concurrency do you prefer locks, STM, or CSP and why?
12) Are singletons acceptable in certain situations?
13) Does the wagegap exist and if so what should be done about it?
14) How many genders exist?
15) Using higher order functions or lambdas, implement a derivative/integral library. We will unit test it.
>>
>>62375681

Why do you have until sunrise? How long did you originally have to learn it?
>>
>>62375681
https://www.youtube.com/watch?v=lisiwUZJXqQ
>>
>>62375686
ha ha epic meem, bro
>>
>>62375686
>15) Using higher order functions or lambdas, implement a derivative/integral library. We will unit test it.

>working for free
t. company that will go down before the year finishes
>>
>>62375697
Perhaps he's in Antarctica
>>
>>62375681
https://learnxinyminutes.com/docs/csharp/
>>
File: 35.jpg (65KB, 225x581px) Image search: [Google]
35.jpg
65KB, 225x581px
>>62375715
>>62375697
>>62375711
>call teacher a faggot for trying to scam us into registering into his additional class for some bucks where he only teaches subhuman level graphical diagram flow
>Tells me if i dont like it can teach it myself or get expelled
>Call him a cuck and proceed to accept the challenge
>>
File: welgetthere.png (15KB, 913x853px) Image search: [Google]
welgetthere.png
15KB, 913x853px
>>62374212
it's actually pretty tricky
>>
Are graphics in C hard? Like in making graphic a sorting algorithm or some shit. By hard I mean should I just not bother and do it in another language hard.
>>
>>62375760
>circular
>>
>>62375788
Yeah its too hard. Do it in Nodejs
>>
>>62375794

that's the base we'll mess with until it starts looking circular.
>>
>>62375755

You dumb faggot.
>>
>>62374212

359 nested ifs with movement rules for every integer angle.
>>
>>62375788
Any significant modern graphics programming uses C-like shader languages. It's worth learning.

But if you're just trying to visualize things, don't use C. Use anything else. JS/Python/Ruby/etc.
>>
>>62375652
>1
That's a variable declaration of a function point.
>2
Just make the "pointers" offsets in the array.
>3
That's almost already done if you can do #2.
>4
Are you really using C++? Shame.
>5
Yes. Progressive remainders and quotients starting at least power of the base b greater than or equal to the number n.
>6
Different data formats. An example implementation of a binary tree has cells with 3 entries, and a linked list 2 entries.
>7
You can iterate over a 100,000 element array.
>8
Negative entries in an iterative loop can be meaningful, such as on the program stack
>9
It depends on what I'm doing with the large list. You want me to say linked list because it doesn't have to be contiguous, but I passed operating systems and know what virtual memory is, unlike you, retard.
>10
Ok.
>11
It depends on the concurrency problem
>12
No because you're using oop
>13
Yes. It's because women aren't career oriented. It should be encouraged because women shouldn't be encouraged to be something they aren't, career oriented. 2nd wave feminism was a blight upon women for the benefit of the corporation.
>14
2 genders. 2 scoops. 2 terms.
>15
I did that in SICP already.
>>62374212
I'll just use taylor series approximations. If that's not allowed, I'll use euclidean distance. When 0<t<r, x = t & y = sqrt(r^2 - x^2), when r<t<2r, x = r - (t - r), y = -sqrt(r^2 - x^2).
>>
>>62375964
stop doing his CS homework
>>
File: firm handshake.jpg (519KB, 1000x667px) Image search: [Google]
firm handshake.jpg
519KB, 1000x667px
>>62375964
Not bad. You passed the preliminary. For #13 I would have accepted "Wage gap doesn't exist". #4 was "vtable" but your healthy disdain of C++ gets gets you off the hook.

>You want me to say linked list
wrong. Linked lists should never be used.

Now for the real interview:
What's your facebook username and password?
>>
>>62376047
azurediamond
hunter2
>>
>>62374109
Green is my pepper.
>>
>>62376047
>Linked lists should never be used.

HASKELL IS CUTE! CUTE!
>>
Questions about C/C++ compilers. A number of things have been bothering me for quite a while.

-Declaring loop counter outside of a series of for loops, zeroing at the start of each loop
I see this quite frequently, and think it's error prone and incredibly ugly, but does it have any -positive- difference? I imagine a clever compiler could fold many sequential for loops into a smaller number, etc. And I tend to think of declaring the loop counter in the loop declaration itself as acting as a hint for the compiler making it easier to determine its actual purpose whereby it can just be thrown in a register and left there. I suppose x86 ISA initially had a register specifically for that, with dedicated instructions for incrementing. If the variable is repeatedly zeroed and used for different things, wouldn't it prevent that?

-Precomputing results
If a series of variables are declared and deterministic operations performed on them, all information known at compile time, which ultimately culminate to one end result that's used elsewhere (with other constants), will just those results be actually included in the binary? The runtime math isn't needed.

-General "cleverness"
I'm often guilty of this. I'll use shifts for multiplies and divides by powers of two, bitwise stuff for other numerical checks. It seems like the ideal compiler, and language, is one where you convey what you actually mean, and the compiler generates an optimal solution. Using a shift is obscuring and making ambiguous what is meant.

Feedback? Please, no horseshit about "micro-optimzations" either like we're on stackoverflow or something. Just hard facts.
>>
File: Weighted_A_star_with_eps_5.gif (6KB, 210x210px) Image search: [Google]
Weighted_A_star_with_eps_5.gif
6KB, 210x210px
>>62375642
A*. Although, if this is for class, you probably want just some simple recursion.
>>
Any PerlMonks around?
I'm trying to find an answer through searching but I can't figure out the right way to phrase this in a search-friendly way.

Basically I know how to start a new perl process from inside a parent one, and I know how to wait on that child, and I know how to ignore that child
What I DON'T know how to do is
>Start child
>Get PID
>Continue doing *other* things in the parent
>When the child is finished, read in results from return or STDOUT or whatever-the-fuck
I know how to do this in golang because it makes concurrent processing a cinch, I'd just spawn a new goroutine and pass it a channel I could periodically listen in on without blocking, but I haven't the faintest clue how to accomplish this in Perl.
>>
>>62376304
>-Declaring loop counter outside of a series of for loops, zeroing at the start of each loop
people do this outside of Ansi C?

>-Precomputing results
look up constexpr
>>
>>62375642
Fit the map into a data structure of some kind (usually a 2d array for simple ones), and use either a stack or queue to iteratively/recursively search through patterns checking each next possible move. If it's valid, put it onto your stack/queue. If it's invalid, pop the next "maze state" out of the stack/queue and try again. Repeat until solution is found.
>>
>>62376335
>look up constexpr
The context for that one is C. Constexpr is among the first things I miss.
>>
File: serveimage.jpg (21KB, 626x626px) Image search: [Google]
serveimage.jpg
21KB, 626x626px
Is there a function to call pi or a means to calculate it in a simple manner in Python?
>>
>>62376396
import math
math.pi
>>
I'm trying to learn scala. I knew some Java some years back, but currently a python expert and I figure it's the best way to significantly improve my health if I start integrating type signatures everywhere.

Just doing a bunch of coding exercises to force myself to learn, pretty neat language. I like that it's idiomatic to write elegant code.
>>
File: 1500860656412.gif (3MB, 460x373px) Image search: [Google]
1500860656412.gif
3MB, 460x373px
>>62376436
>currently a python expert
>>
>>62376304
>declare loop counter
Useless unless you're using an antique C.
>precomputation
Don't expect it to. Sometimes the compiler will do some precomputation with libc stuff. But it's tiny things.
>"cleverness"
Don't expect it to. I can see shifts for division by 2, but not much more.

In general, none of the optimizations you describe would ever occur unless you're doing -O3. This stuff should be determined on a case by case basis. Do you know how to read disassembled compiler output?

Also, I won't complain about microptimizations. I'll complain about you wasting your time with this shit instead of focusing on conditioning the data to minimize cache and branch misses, baka. A single cache miss is TWO HUNDRED cycles just GONE. And a single branch miss, 20.
>>
>>62376304
>Declaring loop counter outside of a series of for loops, zeroing at the start of each loop
Ancient trick before the compiler had scoped looping to prevent useless stray stack-declared variables.

>Precomputing results
Only useful if those results are ENORMOUS

>General "cleverness"
Compilers will generally do this in more places and far better than you can at this point. These things have been developed for 30-some years, all the obvious clever tricks have been optimized already.

It's fun to be an obtuse dick in these languages but it's ultimately almost always unnecessary, hardware and processing are so insanely cheap, even on embedded systems, that there's little point to doing them.
>>
>>62376406
I thought importing was way more complicated than that.

#This is firsty, it will display prompts and repeat answers
#
import math
print('What is your cocklength?')
myName = input()
print('How wide is that cock?')
myAge = input()
cl = float(myName)
cw = float(myAge)
pi = math.pi
cr = float((cw/2)*pi)
cv = float(cl*cr)
print('your cocks volume is:'+str(cv)+'in3')
if cv > 20:
print('Very nice, sir.')
elif cv == 20:
print('Youre doing well')
elif cv <20:
print('Start stretching that sucker.')
if cv <15:
print('And get a pump, shorty.')
#The End


Babby's first program! I guess now I just have to force it to draw a cock and compare it to the average or something.
>>
>>62376542
It's python.
Literally nothing is complicated.
That's the sole reason the language is so popular.
>>
I'm using the "Haskell Programming from First Principles" book to learn Haskell and while I'm enjoying it so far, I'm finding the data type -creation syntax a bit confusing.

For example, the book uses these types of data declarations:
data Identity a = 
Identity a

Which at least intuitively makes sense... Then you have things like:

  
data TisAnInteger = TisAn Integer --Example 1

data StringOrInt = -- Example 2
TisAnInt Int
| TisAString String

data Which a =
ThisOne a
|ThatOne a

instance Eq a => Eq(Which a) where
(==) (ThisOne x) (ThisOne y) = x == y
(==) (ThatOne x) (ThatOne y) = y == y
(==) _ _ = False

In Example 1, does this mean that TisAnInteger has one field, which is an integer? if so, what does "TisAn" do? Is that the name of the variable?

In Example2, I have the same question, but what does the pipe sign do? Isn't that supposed to be a "guard" using functions? Is this doing the equivalent of a "union" type in C? Thanks in advance!

I don't even know what the fuck the Eq(Which a) code is doing. How can the program know whether the data field a is "ThisOne" or "ThatOne"?
>>
>>62376577
>I'm finding the data type -creation syntax a bit confusing.
This feeling will only repeat itself throughout all of haskell, because it is not a language designed for humans.
It is a language designed for autists.
>>
>>62376577
It is like this

data TypeConstructorName typeargs =
Con1 Field1Type Field2Type Field3Type
| Con2 Field1Type Field2Type Field3Type


Think of it like BNF

You need different names for the different constructors in order to refer to them differently, e.g. when pattern matching or when creating a value of that type
(e.g. Con1 a b c d, which is different from Con2 a b c d)

Yes, the pipe in a data declaration is a lot like a C union, except it's a discriminated union (i.e. it has a tag).
You can think of that tag as being one of the constructor names
>>
are Promises in javascript basically multithreading?`

i dont get it
>>
>>62376548
Oh there's more reasons why python exists than just that. Scheme's way simpler (10 core syntactic forms: combinations, literals, define, lambda, let, cond, if, syntax-rules, define-syntax, let-syntax) than python, but you don't see scientists using Scheme.
>>
>>62376577
>>62376612
As for Eq (Which a)
As I say, it's a discriminated union, which means there's something like an enum in memory which says whether it's (TisAnInt _) or (TisAString _), pattern matching will evaluate it and figure out which it is.

If you look at the (==) _ _ case
That covers all other cases, including
(ThisOne x) == (ThatOne y)
(ThatOne x) == (ThisOne y)
-- notice these are different - This and That
>>
File: 1504726709001.jpg (52KB, 800x800px) Image search: [Google]
1504726709001.jpg
52KB, 800x800px
That feel when you don't want to use javascript but it will literally run at 80% of the performance of native code and be portable to any platform, ever.

So if you're writing any userland software in anything but JS, you're wasting your time.

What a soul crushing realization.
>>
>>62376655
*writes 100 MB hello world app*
>>
>>62376304
I wont bother with all of this but
>declaring loop counter outside
Doesn't matter.
Compilers hardly ever work on optimizing (ignoring gcc before it was given some proper competition in form of clang) code without having gone through some form of canonicalization and IR (intermediate representation).
>if the variable was repeatedly zeroed
If the zero-state isn't used it won't be in the final code. Compilers are very good at throwing away unnecessary steps like that.
>cleverness
It's basically pointless now. You have to consider if the bit-hack you're doing is avoiding some set of requirements the compiler must fulfill for the less hacky instruction. For instance when were talking powers of two and you have n*m. If you know m is always a power of two there's patterns you can use that'd make the compiler recognize this fact (thanks to right shifts being undefined behavior when shifting past the end of the bit length this error prone though). But it's generally a complete waste of time and if you cared to that detail you'd absolutely already be writing your code using intrinsics or just using asm.

This is a talk tailor made for this kind of question. You should watch it.
It explains LLVM (clang) as a compiler but it's applicable to both clang and gcc because they're similar. Different IR but principally the same.
https://youtu.be/FnGCDLhaxKU
>precomputing
The compiler does do a lot of work to do compile time work. But you can't guarantee it without C++ constexpr really. All constexpr does is make any code that couldn't be compile time inferred be an error instead. And of course it comes with annoying limitations as you expect from C++. Why bother actually making a solid feature? People have full understanding for them because they're naive. You should absolutely be allowed to do even IO in constexpr. They're nowhere close to that free though. Anyway, it's nice to get a compiler garauntee for your simple fib() function.
>>
>>62376665
Desktop memory is literally a non-issue, and mobile memory is a non-issue by virtue of aggressive memory management and swap implementations.

It's ogre, the hipsters have won.
>>
>>62376655
Why don't you just write in something that compiles to wasm? Also it's not wasting your time if javascript makes you want to kill yourself.

You're wasting the rest of your life writing in javascript if in 10 years they fish your partially decomposed corpse out of an icy river below a bridge.
>>
>>62376492
>I'll complain about you wasting your time with this shit instead of focusing on conditioning the data to minimize cache and branch misses
I already do that. Locality, minimizing allocations and copies, etc, is generally a primary focus. I went through a long period where I would be paralyzed for weeks at a time and wouldn't even attempt to write a single line of code until I understood the nature of what I was trying to do, in the contexts it could and should be done.

That faded a bit, but the consciousness and intuition developed remains.
>>
Any other languages with Clojure's cool, cool fraction type?
>>
>>62376548
>nothing is complicated in python
Complete lie. There's a lot of nasties in that language.
>>62376675
Anon if you want to write shit applications like every pajeet or Chinese does just go for it.
But don't defend it. It's a horrible practice that'll quickly die out now because lipo batteries are not growing quickly enough.
>>
>>62374212
don't even have to use multiplication:

https://en.wikipedia.org/wiki/Midpoint_circle_algorithm
>>
>>62376693
Haskell has rationals and Ratio
>>
>>62376638
Combinations, literals, lambas, define-syntax, etc are complex. That's simple for a PROGRAMMER.
A scientist wants to put shit in easy-to-learn-and-read syntax. I.E. standards SOV english.
Python captures this eloquently while allowing for syntax abuse to create incredibly terse and fast statements.
Then everybody wrote all their libraries for it.
So now the average scientist doesnt have to do anything, they just import <library that already has all this complex shit> and off they go.
>>
What's a good networking project to occupy ~2 weeks time? I'd like to write code and also gain some networking knowledge.
I work with C# at work so I think I'll do a windows form so it looks decent.
I just have no idea what to write. Packet sniffer? Port scanner? idk
>>
>>62376689
>I already do that. Locality, minimizing allocations and copies, etc, is generally a primary focus
Not the same thing as minimizing cache misses and branch misses. Watch this:
https://www.youtube.com/watch?v=Nsf2_Au6KxU

>>62376693
Scheme

>>62376698
ew
>>
>>62376695
>There's a lot of nasties in that language.
By the hand of the author. Properly, cleanly written python is readable by people with even the most modest understanding of programming.

Every language can turn to dogshit if the author writes obtusely.
>>
>>62376729
>any problems is the programmers fault
If that's the attitude then every language is the same.
>>
File: progress.mov.webm (2MB, 1280x720px) Image search: [Google]
progress.mov.webm
2MB, 1280x720px
Good mornin /g/!

>>62374078
>What are you working on, /g/?
I am still working on building my own OS on a raspberry pi. My internet didn't let my post my progress yesterday ;_;

I have the framebuffer now working with colored text. Also line drawing.

Next steps:
>printf like output formating
>emulate terminal like window which can be easily cleared
>input
>>
Still trying to write a garbage collector. First, I'm implementing a manual allocator. When you deallocate things in the same order you allocated them, it works fine. If you deallocate things in the opposite order (like with a stack-based destructor implementation), then it crashes.
>>
Java still doesn't have value types

why
>>
>>62376745
>any problems is the programmers fault
Where did I say that?

Even well written C can be very obtuse to read.
Properly, well written Python is almost never confusing to read unless you're making a very long complex call.
>>
>>62376805
There's no value in learning Java
>>
>>62376805
because java is for normies
>>
>>62376805
Legacy issues.

>>62376811
Majority market share in application development. If you don't know Java you don't have a job.
>>
File: 1502695544776.gif (172KB, 500x506px) Image search: [Google]
1502695544776.gif
172KB, 500x506px
>>62376817
>mfw I really don't have a job
>>
File: Awp7m5B.png (168KB, 320x351px) Image search: [Google]
Awp7m5B.png
168KB, 320x351px
>>62376824
You have to have language skills that are in demand.
C#, Java, and JavaScript are the three big ones.
God fucking help you if you have to work in Java all day though. Jeeesus christ.
>>
>>62376832
I could pick them up easily tbf, except the retarded enterprise shit.
>>
>>62376840
>except the retarded enterprise shit.
Take a wild guess as to what they want you to know
>>
>>62376396
from random import uniform
def pi(n=1e6):
l1 = [uniform(0,1) for _ in xrange(int(n))]
l2 = [uniform(0,1) for _ in xrange(int(n))]
return 4 * len(filter(None, map(lambda x: x[0]**2 + x[1]**2 < 1,zip(l1,l2))))/n
>>
>>62376728
>video
I like the presentation but some of that carries the wrong idea. It's of course very fuzzy in its presentation of everything intentionally as it's intended to be an overview.
21:00
But calling calls 'cheap' on modern CPUs is really only true for the class of functions that the compiler will have a preference to leave as calls. Where the compiler struggles to make the right decision (where you have to care if you used a call or not, many calls can very easily make trouble for the compiler) it can often be very expensive both in calling overhead and the fact that the compiler will lose out on other optimization opportunities.
But I'll say it's good on the whole of course. Just don't use it as your primary source of information. It's a good starting point but I'm very conflicted when there's information like the stuff above.
>>
>>62376809
>confusing to read
It's not just about reading.
Anon if you don't understand how your statement concludes what I pointed out you're not a person who should be advising others.
>>
So how come () is a postfix operator? It doesn't make sense. Usually for making a postfix operator you have to give a dummy argument like
Point operator++(int);
, right?
>>
>>62376868
Python is designed to be easy to write and easy to read
Literally that is its entire original purpose
If you're writing obtuse, massive one-liners that do complex functions, that's your fault. You are not adhering to the philosophy of python.

All bad code is not the authors fault.
All obtuse code is the authors fault.
If you can't understand that then you shouldn't be telling other people whether or not they're fit to advise others.
Learn to distinguish shittily written code from well written code, just like you would english, and maybe you'll get a fucking clue.
>>
>>62376887
#include <cassert>  // for assert()
class Matrix {
private:
double data[4][4];

public:
Matrix() {
// Set all elements of the matrix to 0.0
for (int row = 0; row < 4; ++row)
for (int col = 0; col < 4; ++col)
data[row][col] = 0.0;
}

double& operator()(int row, int col);
const double& operator()(int row, int col) const;
void operator()();
};

double& Matrix::operator()(int row, int col) {
assert(col >= 0 && col < 4);
assert(row >= 0 && row < 4);

return data[row][col];
}

const double& Matrix::operator()(int row, int col) const {
assert(col >= 0 && col < 4);
assert(row >= 0 && row < 4);

return data[row][col];
}

void Matrix::operator()() {
// reset all elements of the matrix to 0.0
for (int row = 0; row < 4; ++row)
for (int col = 0; col < 4; ++col)
data[row][col] = 0.0;
}

#include <iostream>
int main() {
Matrix matrix;
matrix(1, 2) = 4.5;
matrix(); // erase cMatrix
std::cout << matrix(1, 2);

return 0;
}
>>
>>62376887
There isn't a prefix () so there's no need for a dummy argument
>>
>>62376889
>designed
Yeah yeah anyone can set goals.
And you still don't get it. Just shut up.
>>
>>62376887
Why can't 4chan parse text correctly? How hard is it to make a smart [ code] filter?
>>
>>62374185
No, hence why
void *foo, bar;
declares a pointer and a variable.
>>
C/C++ doesn't have a pointer type
>>
>>62376304

>declaring loop counter outside of a series of for loops
C89 compatibility. Only reason to do it

>Precomputing results
Compiler can do this, might not if you don't use optimizations. As a programmer, use whatever is most readable, and trust the compiler to do its fucking job.

>General "cleverness"
Again, use what's readable, and trust that the compiler is smart. If a compiler sees x * 2, it optimizes that to x << 1. Don't do the compiler's work unless bitshifting is more explicit about what you want to do.
>>
>>62376960

C/C++ isn't a programming language.
>>
>>62376975
Correct. C/C++ are programming languages
>>
>>62376954
>void bar;
>>
>>62376975
Do you know what '/' means?
>>
>>62376911
>I disagree with you but I won't even try to refute what you're saying, so you're dumb!
I bet you're one of the dipshits who writes unreadable, write-only code in a language specifically designed to prevent that.
Because you're a bad fucking programmer.
>>
>>62376960
>C/C++
>plural
>"doesn't"

smfh anon
>>
>>62376984

If you were trying to refer to both languages individually, it would be more grammatically correct to say C/C++ don't have pointer types. Of course, this would be factually wrong.
>>
>>62376612
>>62376643
Holy shit that actually made sense.
I can't thank you enough.
>>
>>62377015
C 'or' C++ doesn't have pointer type
>>
>>62377032

That still sounds fucked. Try "Neither C nor C++ have a pointer type."

Which is again, incorrect.
>>
Never done database work. Trying to design a schema for a website. Feel like a fucking retard.
>>
>>62377214
Like I have a bunch of "leagues", how do I store the members? A table for each league where rows only store account ids belonging to the league?
>>
>>62377264
a table of users
a table of leauges
a table that has two columns - one has the id of a user and the other has id of one of the leagues the user belongs to

that'll be a $20,000 consulting fee, please
>>
>>62375907
you're hired
>>
>>62377328
So if a user is in a hundred leagues then they have a hundred rows in the account-league table?
>>
>>62374981
Here's my challenge: make your circles round
>>
>>62377387
y
>>
Will this:
typedef float DgAudioFrame[2]; // stereo
void dgAudioPush(size_t n, const DgAudioFrame *frames); // 22050 Hz

be optimized into
void dgAudioPush(size_t n, const float *frames); // 22050 Hz

?
>>
>>62377498
What do you mean? You're giving it a pointer. I don't see any performance issues with giving it a struct of 2 floats vs just floats as all the instructions you'd do on it would be just the same.
I don't remember what the undefined behavior of casting pointers/comparing pointer types/something were but I don't see that becoming relevant either.
>>
>>62377566
Oh, okay. Thanks.
>>
File: 1463305065952.jpg (359KB, 1024x1345px) Image search: [Google]
1463305065952.jpg
359KB, 1024x1345px
so im taking a java class in school and im having trouble doing assignments based off what we learn. My teacher will say write a program that does this using these things we learned and i just go blank. but when i look at a code from stuff ive learned i can understand how and why it works

anyone have any recomendations?
>>
>>62377696
>/pol/tard
>having trouble with basic shit
No surprise there.
>>
>>62377696
What did you learn? Take input and write output and do stuff like add multiply or divide?
>>
>>62376954
So does void * foo, doesn't prove anything. It's a void* you have, you don't have a *foo.
>>
>>62377696
You must write software.
>>
File: 1504853988629.jpg (129KB, 768x768px) Image search: [Google]
1504853988629.jpg
129KB, 768x768px
Deque is a doubly linked list that you can ONLY remove/insert from the front and back?
>>
>>62377729
we just got onto boolean statements and some formatting stuff.
>>
>>62377766
deque is a data structure in which you can efficiently add and remove to and from the beginning and the end
>>
>>62377766
>deque
Yeah. A double ended queue is like that. Actually for the double ended queue there's no representation requirement it's all about the api (pop/peak top/bottom).
But if you look at something like
http://www.cplusplus.com/reference/deque/deque/
You'll realize it allocates blocks. Not individual nodes. It's still a linked list (of blocks/buckets instead of nodes).
And if you look at the api it doesn't just allow access from the ends. You can even remove elements in the middle.

But the _double ended queue_ is what you described. I'm only mentioning the C++ version so you'll understand when people who are confused about terminology starts talking about removing things from the middle of a double ended queue that they're not actually talking about that. C++ deque is not just a double ended queue.
>>
>>62377786
Make a program that asks your age and judges you based on it.
If you don't know how to do input just make a variable that stores the age.
>>
>>62377865
you mean importing a scanner?
>>
Deques do not need to be implemented as a linked list. They can be efficiently implemented as circular vectors
>>
File: dunecat.jpg (30KB, 439x392px) Image search: [Google]
dunecat.jpg
30KB, 439x392px
Employed Haskell programmer here
>>
>>62377980
You should join us on the Haskell yacht
>>
>>62377980
no such thing
>>
File: 1421139501879.jpg (61KB, 420x599px) Image search: [Google]
1421139501879.jpg
61KB, 420x599px
>>62377999
>>
File: 1505085521117.gif (1MB, 636x481px) Image search: [Google]
1505085521117.gif
1MB, 636x481px
When you work with image, you must have it uncompressed in RAM and compress when you save, or you can work directly with PNG?
>>
>>62374329
Ironically enough, not using trigonometry is actually the most straightforward solution to that problem.
>>
>>62377902
Yeah.
Just do something.
>>
File: serveimage(7).jpg (80KB, 870x396px) Image search: [Google]
serveimage(7).jpg
80KB, 870x396px
For the love of God STOP using Python 2.
Phyton 3 is the future if the language, it's more consistent, more polished and more powerful.

If you keep using 2, you keep the community divided and hinder language evolution and adoption.
>>
>>62378033
You'll need to decompress it in order to work on it.
>>
>>62378033
Generally they need to be uncompressed in ram. eg png has to be "inflated", then the scanline filters reversed.
>>
For the love of God STOP using Python
>>
File: socks.jpg (45KB, 1001x1001px) Image search: [Google]
socks.jpg
45KB, 1001x1001px
Do you unironically wear these while programming?
>>
>>62378108
Why would it be ironic?
>>
>>62378125
In fact I wrote "UNironically", but alas, not everyone these days can read.
>>
>>62378147
Alas, not everyone these days can think.
Why would someone write unironically, without the connotation that there would usually be something ironic about it?
>>
>>62378094
But it's comfy.
>>
>>62378071
>>62378094
You are both of very correct and non-conflicting opinions.
I especially like the part where you say that using python hinders language evolution and adoption.
>>
>>62378188
lol got em
>>
Hey friends.So I finished my Chip-8 emulator,but every time I try to play, its black screen.Tried debugging it for 1 day, but to no avail.It reads the .rom file into memory, and fetches the OP code correctly.The problem is that everything seems to be perfectly coded, so I do not get what is wrong with it.If anyone would help, I would appreciate it.Thanks.

https://pastebin.com/kxYjn9AT
>>
>>62378277
Python 3.6 is actually very good, nice way of spergically interpreting comments in whatever way you please.
>>
File: lain1.png (191KB, 364x364px) Image search: [Google]
lain1.png
191KB, 364x364px
Unemployed Python programmer here
>>
>>62378659
Was that not what you were saying? My bad. I guess you're just wrong then.
>>
File: 1503969248197.png (180KB, 392x309px) Image search: [Google]
1503969248197.png
180KB, 392x309px
>>62378683
You should have used Lisp.
>>
>>62376693
Racket
>>
>>62377732
>bigO
>performance
It's about growth actually, not performance, which is why the constants never make sense.
>>
>>62378837
Meant for
>>62374703
>>
File: puke.gif (496KB, 400x226px) Image search: [Google]
puke.gif
496KB, 400x226px
>>62374078
>accidentally clicked on /dpt/
fuck off cancer trash you get nothing done
>>
So I have a 2d list in python, how can I check if there are any duplicates in it at 0 pos?
I mean [i][0]
>>
>>62378942
import multidimensional_list_has_duplicates

multidimensional_list_has_duplicates.has_duplicate_in_pos(mylist, 0)
>>
>>62379033
kek
>>
>>62378685
Not only you are a passive aggressive sperg, you also seem unable to elaborate.
>>
>>62378700
>lisp is a language
>>
>>62379054
>lisp is not a language
>>
>>62379075
>lisp is a language
>>
>>62378942
```
def check_dupes(list)
column_zero = [row[0] for row in list]
return len(column_zero) != len(set(column_zero))
```
>>
>>62379126
oops forgot 4chan uses tags for code not KaTeX

def check_dupes(list)
column_zero = [row[0] for row in list]
return len(column_zero) != len(set(column_zero))
>>
>>62379169
Ah that's clever
Thanks anon
>>
File: 90123109312.jpg (42KB, 400x400px) Image search: [Google]
90123109312.jpg
42KB, 400x400px
>>62374078
>>62374109
>>62374327

i think OP wants us to eat raw hot peppers so we make lewd facial expressions
>>
I got somewhat good at C++, bash, python, javascript.

What now?
I figured I should start working towards a decent resume.

But where to start?
I figured contribute to some open source stuff? But where? Github stuff is garbage, and besides would contributing to an obscure text editor really look good on a resume?

Currently working on a script based automation tool. Kidna like Auto-It for windows but for X11.

Got some basic functionality in. Simulate a keypress, move the mouse, click, find a pixel by color etc.

Grateful for any advice
>>
>>62379111
It's a family of languages.
>>
>>62379532
>lisp is a family of languages
>>
>>62376322
A* assumes you know both the start point and the exit point. This might not be the case. A simple BFS seems more suitable.
>>
>>62375642
Hug the left wall.
Brute force it.
>>
File: aaa.png (11KB, 429x284px) Image search: [Google]
aaa.png
11KB, 429x284px
is there any c/ python library that would allow me to use google handwriting recognition?
>>
>>62379805
Solve this maze:
#######
# #
# ### #
# #F S
# ### #
# #
#######
>>
File: IMG_20170908_190342.jpg (3MB, 2368x4208px) Image search: [Google]
IMG_20170908_190342.jpg
3MB, 2368x4208px
Apparently in golang strings are immutable. If I want to change a character at position i in a string how would I go about doing that? Thanks in advance
>>
I have an array [0,1,2,3,4,5,6,7,8]

each contains a 'weight' between 1-16

how can i iterate through each value 0-8 picking the lowest value every time?

using java for this
>>
>>62380004
if (we_have_not_found_the_finish && we_have_returned_to_the_discovered_point) {
direction = undiscovered();
turn_to(direction);
goto main;
}
>>
>>62380125
min = 0;
for ( int i = 0; i < sizeofaraay; i ++ )
{

x = array[i]
if( x >= min )
{
min = x
}
}
return x;
>>
>>62380155
>we_have_returned_to_the_discovered_point
>undiscovered();
Why don't you try actually describing an algorithm? Those on their own are meaningless.

It's just like my legendary new sorting algorithm, which sorts in O(n) time for any input:
while (!sorted) {
sort();
}
>>
>>62380190
Leave a snail trail.

3 are places you have been.
If 3 than returned to discovered point.
>>
File: 1504577214768.jpg (40KB, 405x650px) Image search: [Google]
1504577214768.jpg
40KB, 405x650px
Why did logic programming fail?
Isn't it cool to make the computer by itself to find the solution for your problem?
>>
>>62380183
if say [0], [1], [2] are 12, 14, 4

will this return 4, then 12, and then 14
or
4

i didn't word it well but i'm looking to do the former
>>
>>62380232
I wont return shit it will return 0.
I fucked it up.

Do you want to sort the array or just get the least lowest value?
>>
>>62380232
Sort the array.
>>
>>62380252
i want to get the position of the lowest value, and then the position of the next lowest value, etc.

thought that i might have to sort it to do this
>>
>>62380083
Maybe golang has something like StringBuilder in C#
>>
>>62380256
okay
>>
>>62380223
>Why did logic programming fail?
Because you have to be constantly mindful of the execution semantics of your supposedly declarative statements to have a computation that terminates at all (and does so in a reasonable time-frame).
>>
>>62379809
Already implemented in UWP, no tomfoolery required.
>>
>>62380259
Position or value? To very different things.

Just use 2 for loops and it will get you there.
>>
>>62380314
i want the position with the lowest value
then the position with the next lowest value
and so on

i basically want to iterate through 1-n in an order according to which position (1-n) has the lowest weight

not sure if this is doable or if i should rethink the entire thing
>>
Operator overloading: It doesn't make sense to me. Normally when you access a public function, you would write
 object.fn(arg) 


So how does operator overloading work? Is
 object++(1)
a prefix operator?
>>
File: o.webm (25KB, 800x624px) Image search: [Google]
o.webm
25KB, 800x624px
>>62374078
hanoi towers solver with graphics
>>
>>62380478
object++
or
++object

The extra argument is for the sake of overloading to distinguish between prefix and postfix, but it's not used (well, technically you could write object.operator++(1))
>>
>>62380520
>++object
It breaks the pattern of object.method(arg)
>>
>>62380478
myclass.add(5);

// With operator overloading:
myclass + 5
>>
>>62380515
>not coding proper disk movement animations
>>
>>62380554
Yes, bot how about prefix operators?
>>
File: 1467252095812.jpg (8KB, 206x226px) Image search: [Google]
1467252095812.jpg
8KB, 206x226px
>>62378659
>Python
>No interfaces
>No explicit casting
Kiss
>>
Help me understand the hate towards JS.

I have a bachelor's in CS, I've programmed in multiple languages, including C++, Java, R, Pascal, x86, MIPS and PHP and I just don't get it - what's wrong with JS? Whenever I wanna prototype something I default to JS. It seems to strike the right balance between ease of use and lack of limitations.
>>
>>62380520
So you were saying that I could use either operator++() or operator++(int) to use pre/post fix? That would make sense because the implementation is inside the class

But still, it still breaks the pattern of object.fn(). Can I normally use class::fn(object)? Even if that's true, I'd have to use class::++object

I'm confused
>>
>>62380594
>what's wrong with JS
The fact that it allows you to accidentally do things that make no sense without warning, and then to perform nonsensical operations on nonsensical results, and lets it snowball until somewhere far down the road it finally throws an exception because you're trying to perform an operation that is too ridiculous for JS to tolerate, at which point, good luck tracking down the source of the problem.
>>
>>62380570
I assume you're talking about C++?
In C++, there's no difference between whether they're prefix or postfix.
*x;
x.operator*();

x[n];
x.operator[](n);

The only difference is ++ and --, where a unary operator is itself overloaded with prefix and postfix variants. C++ uses a dummy int argument to distinguish between these, which isn't used but resolves the overload.
++x;
x.operator++();

x++;
x.operator++(0);
>>
>>62380621
welcome to dynamic languages
>>
I need some simple language to draw points and colored lines based on a simple textual representation. What can I use?
>>
>>62380611
There are two methods
YourClass::operator++() // prefix
YourClass::operator++(int) // postfix

If obj is of type YourClass, you can do the following, just like any other method.
obj.operator++();
obj.operator++(0);

However, the point of operator overloading is that you can also treat obj as if it were an integer and use operators on it
++obj; // desugars into obj.operator++();
obj++; // desugars into obj.operator++(0);
>>
>>62380621
You just need to learn some basic rules of the language. Pretty much universally true for all languages.

For example assignment operator "=" assigns a copy of data such as numbers, but will store a reference to arrays and objects.
>>
>>62376221
Haskell has some black magic-tier optimization that in most cases doesn't actually use lists at all.
>>
>>62380634
>implying sane dynamic languages don't just throw a runtime error when you do nonsense like []+1
>>
>>62380665
>sane dynamic languages
oxymoron

But yes, that's the closest thing to sane.
>>
>>62380638
literally anything that can fuck around with strings and ints, and output svg
>>
>>62380671
>>sane dynamic languages
>oxymoron
Poor lispless child
>>
>>62380685
lisp has nothing going for it except muh metaprogramming
>>
>>62380638
JS + HTML canvas :^)
>>
>>62380692
>lisp has nothing going for it except muh metaprogramming
And, you know, being leaps and bounds ahead on performance, with over half a century of optimising compilers

http://tapoueh.org/blog/2014/05/why-is-pgloader-so-much-faster/
>>
>>62380665
>throwing runtime error on something you can detect at compile-time
I'll never get this.
>>
>>62380638
BASICs of different flavours
>>
>>62380652
>You just need to learn some basic rules of the language
Try reading the actual post before you respond. I know the rules of the language (and probably better than you do), but knowing the rules doesn't help you when you make a mistake somewhere, like passing the wrong type of argument to a function, and instead of failing, the function produces nonsensical results that are then fed to another function later on, that also produces nonsensical results instead of failing and so on.
>>
>>62376718
>windows form
Use WPF instead. There's not much point in making a WinForms project unless you want to attempt to port to Mono+WinForms for a Linux deployment.
>>
>>62380714
I know right? Proper compilers for dynamic languages like SBCL can catch shit like that
>>
>>62380671
>muh opinions
No one cares. The point is that other dynamic languages will bail out relatively early when a type error occurs, while javascript will use bizarre implicit conversions and keep going.
>>
>>62380722
This.

Although, there are some examples often shown to illustrate that JS is bad that really are just someone failing to read the definition of a function.
>>
>>62380722
Do you test your code once every 1000 new lines or something?
>>
>>62380711
> compiled language is faster than CPython
(setf mind blown)
>>62380738
No, you can't, not in all cases, not without static typing.
>>
>>62380740
correct
>>
>>62380692
>lisp has nothing going for it except muh metaprogramming
And you have nothing going for this statement except "muh opinions".
>>
>>62380744
Not him, but having to test first for the correct type is annoying and slows down testing/fixing the actual logic.
>>
fuck opengl though
>>
>>62380749
>No, you can't, not in all cases, not without static typing.
No, only (You) can't
>>
I'm interested in learning common lisp. What are the pros and cons of the language? What would I be capable to do with it?
>>
>>62380761
Maybe it's just the nature of the projects I've been working in, but it was never a problem for me. Maybe it comes down to trying to use JS like a OO lang?
>>
>>62380788
learn a simpler and purer lisp first
>>
>>62380788
>I'm interested in learning common lisp
Congratulations and welcome!
>What are the pros and cons of the language?
Pros: It will turn your brain inside out and see programming in the abstract
Cons: You will have to turn your brain inside out in order to see programming in the abstract
>What would I be capable to do with it?
Anything at all, but easier
http://www.gigamonkeys.com/book/introduction-why-lisp.html
https://common-lisp.net/

>>62380812
Not mandatory, I survived fine going balls-deep with CL first, but then again I had already seen quite a bit of other languages
>>
>>62380714
>implying you can always detect it at compile-time
function add(a, b) {
return a + b;
}

var t = downloadSomeJSON(); // {x: 1, y: []}
var r = add(t.x, t.y); // Ooops.
>>
>>62380639
>++obj; // desugars into obj.operator++();
>obj++; // desugars into obj.operator++(0);
Is this a rule?
Can I not use obj,operator++(0) as a prefix op even if I implement it in that way in the class?
>>
>>62380878
That's a rule. The only reason the integer argument exists is to disambiguate prefix/postfix overloads of the ++ operator.
>>
>>62380895
Thanks anon.
>>
>>62380788
>What are the pros and cons of the language?
Pros: your ego will inflate despite the fact you won't be writing any code.
Cons: you'll waste your time learning idiosyncrasies of an obsolete language which aren't applicable anywhere outside the containment languages.
>>
>>62380788
>What would I be capable to do with it?
Anything really.
ECL compiles to C or C++ and you can inline C and C++ into it.
The developer maybe QT5 bindings for it and I thinks there's guide on how to compile it to android / ios.
If you want to do some low level math library to be used from other languages then you should go with C or fortran. Also embedded is still mostly C, you can program rasberry pi and maybe even arduino with ECL but generally Lisp is high level language.
>>
>>62380788
Pros: Lisp is made of cons
>>
>>62380788
>common lisp
>pros
Power and expressiveness, (relatively) good performance.

>cons
Almost nobody uses it (good luck finding work).
You have to deliver the entire runtime with the application (bloat).

>What would I be capable to do with it?
Anything you can do with any other high level language (and some low-level things through the C FFI with relative convenience).
Create your own domain-specific languages, create custom syntax, develop applications interactively (recompile functions and change variables on the fly without restarting the app), use an extremely powerful debug system.

Kind of a mixed bag.
>>
>>62381004
>You have to deliver the entire runtime with the application (bloat).
You can also just distribute source files or compiled .fasl files. If compiled they would only work with the implementation it was compiled from though.
>>
>>62380788
>What are the cons of the language?
cons n.v. 1. n. a compound data object having two components called the car and the cdr. 2. v. to create such an object. 3. v. Idiom. to create any object, or to allocate storage.
>>
>>62381022
>You can also just distribute source files or compiled .fasl files
That doesn't solve the problem. Only forces the client to download the runtime manually.
>>
New thread:

>>62381043
>>62381043
>>62381043
>>
>>62381042
>>62381022
>>62381004
http://www.cliki.net/Creating%20Executables

Y'all niggas need some googling
>>
>>62380638
You can use java with this http://introcs.cs.princeton.edu/java/stdlib/StdDraw.java
>>
>>62381082
No one said you can't create executables, but the generated executables are still going to contain a CL runtime system. One way or another you are going to deliver one.
>>
>>62375045
blue & white, classic, like C is
>>
File: dlogo.png (11KB, 125x95px) Image search: [Google]
dlogo.png
11KB, 125x95px
>>62378595
The problem is that you did not use D.
>>
>>62378595
>I finished
>it doesn't work

???
>>
File: 45668713037.jpg (76KB, 500x375px) Image search: [Google]
45668713037.jpg
76KB, 500x375px
>>62381686
>>
>>62377980
employed where tho
>>
>>62376755
Please explain to me
>>
>>62377404

Working on it chief
Thread posts: 321
Thread images: 39


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