[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: 322
Thread images: 15

File: dpt.png (39KB, 180x193px) Image search: [Google]
dpt.png
39KB, 180x193px
What are you working on, /g/?
>>
>>51601187
I fucked up

Previous thread: >>51595491
>>
>>51601187
SeconD
>>
>>51601187
>Image for ants
>Forgot old thread link
You really fucked up.
>>
Fourth for Egison best language!
>>
File: dd.jpg (199KB, 1280x965px) Image search: [Google]
dd.jpg
199KB, 1280x965px
5th for D!
>>
File: neon paradise.png (4MB, 1543x965px) Image search: [Google]
neon paradise.png
4MB, 1543x965px
Reposting from old thread

I'm working on an image editor for glitch art.

We just released a new version, and I would be eternally grateful if you guys would check it out.
Feedback is greatly appreciated, especially regarding usability.
Something you didn't like, something that stood out, unexpected results, etc.

Link:
>glitchy.codemouse.dk

Pic is an image I made with the program.
>>
Friendly reminder that writing a program takes 50x longer than it would in any other language because there are no libraries to be found.
You have to write EVERYTHING yourself.
>>
this has bothered me for quite a while. in fact, I've never been sure how it is supposed to be done: if you have a long task, how do you decide how to separate it in smaller functions, and what arguments to pass? the less, the better? just do it and see if you need to separate it later?

I need to download a file, but restrict it depending on file size and MIME type. and I can check both restrictions while dowloading, by checking the headers (which I suppose should not be trusted... but that's another topic), and when the download is finished, by checking the size and mime-type of the file that has been downloaded.
the thing is, I don't know if I should put all of this in one function, or two or more functions. if I put it in one, I kinda lose control over what is done to the file, plus I will probably have to separate it in two parts to not reuse code, and if I put it in >1, I have to reuse objects from one function to the other, and pass many more arguments...

anyway, this was just an example. what are factors to decide how to write a function/method?
>>
>>51601246
Thankfully there is a language with a girl in her logo.
>>
>>51601260
wat
>>
How do you guys take on big projects?
I recently started working a fairly large project (writing a network stack from scratch).
To stay focused, I created a TODO file with at the moment somewhere around 100 small goals.
Previously I had the problem that I lost interest after a few weeks, but I really want to build and finish this.
>>
>>51601291
SCRUM board.
>>
>>51601291
>a few weeks to write a network stack
you were never meant to be a programmer
>>
>>51601256
>No source code
Sorry, I'm not downloading your malware.

>>51601270
>what are factors to decide how to write a function/method?
Intuition. Good taste.
Making something a function that could easily be done as an if statement is overkill, but if there is any real computation involved or it's conceptually different to what you're doing, make it a different function.
Also, I try to make as many functions as I can to be pure (with maybe the exception of passing a pointer in to a buffer).
>>
>>51601218
if you are getting neetbux, you probably don't need too much money anyway, and your government probably won't bother suing you for $100/mo in taxes
anyway, if you really were interested in working, you'd be trying to find info... not asking 4chan
>>
>>51601291
>writing a network stack from scratch
Have fun reading dozens of very large RFCs. TCP gets very complicated when optimisations are thrown in.
>>
Threadly reminder that the act of writing computer instructions is not coding. The proper term is programming
>>
>>51601364
The government would throw you in jail because defrauding the government is a felony. Moreover, your neetbux during that period would be revoked and you would be liable for additional fees.
>>
>>51601327
If it takes you longer than a day to write your own web server then you're incompetent.
>>
Thinking about writing my own relational database software in C. Good idea/bad idea?
>>
>>51601327
what do you mean? it should take less, or more time?
>>
>>51601463
it shouldn't take you 2 weeks is what i'm saying
>>
>>51601363
>Sorry, I'm not downloading your malware.

Dang sarnet, I almost had you!
You are getting too clever for me
>>
>>51601445
>more than an hour
FTFY
Literally
>open socket
>spawn thread
>serve something
>>
>>51601445
That's just the application layer. What about all of this shit below it?
>>
>>51601424
Isn't coding a proper subset of programming since coding refers to typing as opposed to using something like Scratch or a dataflow language?
>>
>>51601494
Are you asking how long it takes to implement an operating system in order to implement an http server?
>>
>>51601187
Working on some simulations in ns-3 and an Android app.
>>
>>51601445
>network stack
retard
>>
>>51601505
Coding literally is not a word.
>>
Why doesn't Racket have a function to read a char WITHOUT the user pressing enter?
>>
>>51601388
please, explain
>>51601327
>>51601479
>>51601445
>>51601488
>>51601494
did these guys read every single RFC out there...?
>>
>>51601187
Daily reminder that Julia is more elegant and faster than haskell or any lisp.

maxSum(lists) = map(x -> max(x...), lists ) |> sum
>>
>>51601535
Why do you need to reinvent a very carefully engineered wheel?
>>
>>51601538
>Jewlia
>>
AJAX?
>>
File: 4CNvf6m.png (39KB, 771x659px) Image search: [Google]
4CNvf6m.png
39KB, 771x659px
>>51601541
Kill yourself

>>51601535
They are fucking retards
>>
>>51601326
Seems interesting, I've used kanban in some projects before.

>>51601327
What do you even mean?
I'm going to build everything from the standards, implementing routing, something like netfilter (firewall, NAT, mangle), a socket API, routing algorithms, etc.

>>51601507
The only thing I'm going to use from the OS is the raw socket interface that gives the raw, unprocessed standard 802.1 Ethernet packets.
No networking will happen in the kernel, everything should happen in userspace.

>>51601388
That's part of the plan. Currently reading the IEEE 802.1 and 802.2 standards for Ethernet, LLC, bridges, etc.
I don't really care how much time it will take, I just want to understand everything.
Reading, implementing and then writing about it.
>>
>>51601548
Aren't you a clever one?
>>
>>51601575
>I'm going to build everything from the standards, implementing routing, something like netfilter (firewall, NAT, mangle), a socket API, routing algorithms, etc.

Why?
>>
>>51601582
Friendly reminder that reinventing the wheel is a good thing, contrary to the baseless FUD most code monkeys insist on perpetuating.

Doing it yourself allows you to learn about the chosen problem domain and thus become a better programmer. It adds to the amount of possible solutions to a given problem and thus is always valuable. You are also very likely to end up with a better library or application than existing ones, since you aren't constrained by backwards compatibility and, due to today's free and open source software world, you can learn from the past mistakes of others. You are also free to choose the implementation specifics, such as the language of implementation.

>b-but reinventing the wheel is bad

Are you against innovation, evolution and choice? Reinventing the wheel is crucial when the wheel is actually part of your core business. This is a known fact in all engineering professions. Perhaps the term "reinvent the wheel" is the source of the problem. Let us say "reengineer the wheel" instead.

Don't take it from me. Here are some sources that will enlighten you:

http://www.obxerve.com/en/article/reinventing-the-wheel-can-be-good/

http://www.codinghorror.com/blog/2009/02/dont-reinvent-the-wheel-unless-you-plan-on-learning-more-about-wheels.html

http://lea.verou.me/2012/04/in-defense-of-reinventing-wheels/

http://www.joelonsoftware.com/articles/fog0000000007.html

https://en.wikipedia.org/wiki/First-mover_advantage#First-mover_disadvantages

http://timkastelle.org/blog/2012/01/please-reinvent-the-wheel/
>>
File: 1443717897495.jpg (18KB, 279x246px) Image search: [Google]
1443717897495.jpg
18KB, 279x246px
>>51601538
maxSum = sum . fmap max
>>
>>51601570
>They are fucking retards
and I agree. these fucking retards talk fast... I wonder if they have ever made anything, at all

>>51601541
did you even read the posts?
>a network stack from scratch
>your own web server
surely you can program things from scratch in a few hours just fine, anon :^)
>>
>>51601363
>Intuition. Good taste.
>Making something a function that could easily be done as an if statement is overkill, but if there is any real computation involved or it's conceptually different to what you're doing, make it a different function.
>Also, I try to make as many functions as I can to be pure (with maybe the exception of passing a pointer in to a buffer).
thanks.
in this example I gave, what bothers me is that I'd either have to pass a *FILE, or I would have to open the same file twice. the first solution seems to be potentially prone to horrible bugs, the second seems stupid... and that's how I get stuck when trying to solve little problems. I don't know if there is something wrong with me, or if this is really important at all

>>51601270
anyone else?
>>
>>51601691
>the first solution seems to be potentially prone to horrible bugs
Not really. It's also idiomatic, you should have your functions doing as little resource management as possible.
>>
>>51601520
No language does.
>>
>>51601538
Daily reminder that Julia is beyond broken.
http://danluu.com/julialang/
>>
>>51601582
Because I can.
But mostly as a research platform, because scripting eg an ECMP routing or custom queueing algorithm in Python is easier than having to write a kernel module. So it is mostly for prototyping, before porting it to a lower level language
And it's also for understanding how *everything* in the network stack works.
>>
>>51601620
>this is what cmen believe
>>
File: 1394607712758.jpg (7KB, 225x225px)
1394607712758.jpg
7KB, 225x225px
>>51601797
>Update: this post was edited a bit to remove a sentence about how friendly the Julia community is since that no longer seemed appropriate in light of recent private and semi-private communications from one of the co-creators of Julia.
>>
Should I put the parser generated by a parser generator into my repo or make a script to generate it when building the program?
>>
>>51601849
Always makes me laugh.
>>
>>51601881
You should include the input to the parser generator instead; the generated parser should be treated as an object file (more or less). It's the same as if you have template files or build-time constant.
>>
File: for_free2.jpg (64KB, 748x752px) Image search: [Google]
for_free2.jpg
64KB, 748x752px
>>51601256

I did some glitch art with my editor.
>>
>>51601881
Generate it.
>>
>>51601520
> Why doesn't Racket have a function to read a char WITHOUT the user pressing enter?
Read a char from where? And what is this "user" of which you speak?

Standard input might be a file, pipe, socket, or device. A device might be a terminal or some other device.

The language itself wasn't designed specifically for interacting with a user via a terminal so it isn't going to automatically start messing with standard input to facilitate that case.

On Unix, the terminal driver doesn't pass terminal input onto the process until either Enter/Return or Ctrl-D is pressed unless the terminal is in raw mode (and most shells will automatically put it into canonical (non-raw) mode before executing any program because that's what programs expect).

The main reason for this is so that you can use backspace (or Ctrl-W or Ctrl-U) to edit the input before submitting it (which can't be done if the driver is passing each character to the program as it's entered).

Programs which want "raw" terminal input either use the termios functions (tcsetattr etc) to configure the terminal driver, or use curses to deal with that (and a lot of other stuff besides).
>>
>>51601797
None of that stuff applied even when the post was written, that guy is just some butthurt blogger.
>>
>>51601988
>d-d-d-damage control!
All that stuff still applies to this day.
>>
>>51601246
Is D a meme? I'm quite new here, I don't know D and I can't understand if all those people who mention it are serious or just joking...
>>
How childish do you have to be to deliberately pretend like your language doesn't have shortcomings?

I've got an idea: post your favourite language and something(s) you dislike about it.
>Haskell
>Monads can't be defined by join instead of >>=
>an instance of Applicative isn't automatically derived for every Monad, likewise for Alternative/MonadPlus
>uses :: instead of : for type annotation
>>
>>51602095
D is a meme language
the only people that defend it are NEETs that have never built any real world applications
>>
>>51602095
D is probably pretty good but it's a little bit obscure. There's not too many major projects in D, whether enterprise or free software.

If you need something like D but want to be taken seriously, you pretty much have to use C++ and suck it up.
>>
I have just implemented another system call for my kernel, and have just discovered that it and about 2 other system calls are not correct in all circumstances. Why? Alignment Exceptions!

When you have
1.) An architecture that doesn't like grabbing words from unaligned addresses
and
2.) A language that determines string length from a word in front of the string, rather than null termination

Trying to grab filename substrings the C way is... needless to say, bad. Fuck me, I'm going to have to redesign some code to COPY INTO A BUFFER
>>
>>51602095

It's a meme, but not all memes are bad. Some of them are very enjoyable.
>>
>>51602095
It's a 10/10 would fuck again language
>>51602125
C
Shitty strings
Very little libraries
>>
>>51602125
>C
The entire preprocessor is complete shit, and macros are so bad that they are unusable.
>>
>>51602095
it's a meme, and it's mostly the same small group of people shilling it
>>
>>51602179
>very little libraries
once you go the C route, you might as well reinvent everything yourself.
>>
>>51602158
>A language that determines string length from a word in front of the string, rather than null termination

You say that like it's not leagues better than null termination.
>>
>>51602125
java
can't turn off bounds checking
no free optimizing AOT compiler for windows and linux
that's about it
>>
>>51602283
>that's about it
>>
AJAX?
>>
>>51602283
>java
do you hate yourself?
>>
>>51602301
FEYENOORD
>>
>>51602283
>that's about it

m9...
>>
>>51602257

The problem is that this means that strings must be on word aligned addresses.
>>
>>51602335

That's true, but still.
>>
>>51602293
>>51602302
>>51602334
nice meme
>>
>>51602371
t. Alberto Barbosa
>>
>>51602158
do it the Go way?
http://blog.golang.org/slices
http://blog.golang.org/strings
>>
>>51602371
Enjoy not being able to pass primitives by reference
>>
>>51602371
java is absolute shit
>>
>>51602393
big whoop wanna fight about it

for barely useful things like that i have C++ anyway
>>
>>51602402
epic
>>
>>51602417
>i-it's not that big of a deal anyway
>so what if my language can't do basic shit other languages can
>>
>>51602125
>F#
>a lot of checks that could be done in the compiler end up deferred to runtime (I assume this is due to the extensive .NET / C# interop needs?)
>calling function syntax unpredictable (should I tuple this, or is it F# native?)
>constructing algebraic datatypes composed of records has pretty redundant syntax
>
>>
Oh god templating linked list functionality in c++ is an absolute nightmare
>>
>>51602435
name 3 good reason to use java
>>
Why does C have so few libraries?
>>
daily reminder that functional programming is best used in imperative languages
>>
>>51602454
Not really
>>
>>51602466
I just wish more imperative languages would realize the benefit of a type system that also quantifies effects.

Which is why I'm working on my language. Functional and referentially transparent, but runs like C in pretty much every other way.
>>
>>51602454
I assume you mean a stack based link list that stores types and not objects.

Otherwise, you're a failure
>>
>>51602462
Are you kidding? C has fuckloads of libraries.
>>
>>51602125
>OCaml
>still no real typeclass support
>ugly parametric polymorphism syntax: must be
('a, 'b) x
instead of
'a 'b x

>type constructors aren't curried
>type constructors can't even be curried with GADTs
>>
>>51602490
I hope one day it'll be the second best, just below D
>>
>>51602500
Yeah? Name 5.
>>
>>51602530
stdio
stdlib
time
math
string

slacker
>>
>>51602516
I'm going to beat D.
>>
>>51602462
C is supposed to be a small language. You could add more, but then it would eventually be C++.
>>
>>51602556
Whose?
>>
>>51602353

I dunno man, I just guess I find null termination easier to work with. Besides, you can always implement your own string system easily within a null terminated one.
>>
>>51602125
>guile
Shit memory management (lol boehmgc) which leaks ridiculously fast, unbounded, in any memory-intensive set of operations.

>racket
Almost every error is a runtime error unless you use typing. Typing is very performance costly when going to/from typed code, has to be guided so hard you practically type every expression manually (sometime with hacks like if(type is x) do-with-x(the-thing) else if(type is y) do-with-y(the-thing) else error("never happens")), can't type only some expressions in a typed file (all or nothing), yet typing can improve performance 50fold in some cases (tensors).

>chicken
No 64-bit or more datatypes.
Green threads.
>>
>>51602556
You can't beat Andrei's D, it's bigger and more powerful than you could possibly imagine
>>
>>51602456
statically typed
clean and consistent syntax that leads to highly readable and easily maintainable code
immaculate support for OOP and adequate support for other paradigms
>>
>>51602581
import javax.hook.bait;
>>
>>51602575
>I dunno man, I just guess I find null termination easier to work with.

That's because you're an unrepentant Ctard. Long before C was even a twinkle in Ritchie's benis, languages had come and gone that tested the null-terminated string and switched to length-prefix.
>>
>>51602549
tch yeah, real clever
*puts C into the rubbish receptacle*
where it belongs, heh
>>
small poll
http://bfdss.net23.net/site8/poll.html
>>
>>51602601
if you don't think
>statically typed
at the minimum is a good thing i don't know what to tell you m8
>>
kinda new to programming. is pen and paper required at any point?
>>
>>51602549
Kill yourself

>>51602530
GMP
glib
OpenCL
OpenGL
libfreetype
zlib
etc...
>>
>>51602635
Most languages are statically-typed. Why should I use Java over the many other languages with static typing, decent syntax, and multiparadigm support?
>>
>>51602637
not really except for in certain school classes maybe. but you'll probably want to sketch on algorithms and maybe designs either on the computer or on pen and paper
>>
>>51602637
I find it nice for planning shit out
>>51602581
Lots of languages have that
>>
>>51602530
just
ls /usr/lib
, most of what you'll find there will be c libraries
>>
>>51602635
>java
>clean syntax
>consistent syntax
>highly readable code
>easily maintainable code
>even remotely acceptable OOP support
>any support for non-OO paradigms whatsoever
It's bait, anon-kun.
>>
>>51602530

libcurl (networking)
libopenssl (crypto)
klib (data structures)
libsdl (multimedia)
libgtk+ (GUI)

Want more? Be more specific on what you want that library to do.
>>
>>51602530
Too many to name. Every library that isn't complete shit has a C interface.
>>
>>51602654
i don't care if you prefer some other language, it's a matter of taste i guess. but java is good for android for instance. >>51602283 is my legit opinion about java
>>
>>51602686
ok sanchez
>>
>lowercase Java shill
It's always the same guy, isn't it?
>>
File: 1448826868552.gif (3MB, 260x209px) Image search: [Google]
1448826868552.gif
3MB, 260x209px
Reminder that if you can't swap two ints in one line of code you're not even in the level of a street shitting code monkey
>>
>>51602495

I am, I've been trying to implement double linked ordered list functionality but there's way too much error in my code

Would it be possible to make a placeholder iterator? Like instead of the Node? Right now I'm trying create an insert function that inserts an item into the list based on a comparison functor (a<b) and uses iterator traversal. But obviously I can't access the direct value of the node through the iterator using the -> operator.

// Inserts an item based on the standard functors, and returns an iterator position
template <class Item, class Order>
typename DLinkedOrderedList<Item, Order>::Iterator DLinkedOrderedList<Item, Order>::insert(Item item) {
DLinkedOrderedList<Item, Order>::Iterator k; // Creating an iterator k for the linked list
Node *temp; // Placeholder node

for (k = this.begin(); k != this.end(); ++k) { // Forward iterator traversal
if (IsLess::compare(item, k->value)) { // Compares the input item with the value (item) at the iterator
temp = k; // Temp holds the contents of the node
k->value = item; // Item is assigned the be held in position k
k->next = temp; // Next value holds the previous value
m_size++; // Increments the size of the list
return k; // Returns the iterator k that the item was inserted at
break; // Breaks the "if" loop
}
else
return Iterator(NULL); // An iterator must be returned
}
}
>>
>>51602735
>anti-java memers
there is nothing wrong with java it's literally one of the best general purpose programming languages in existence
>>
>>51602671
>>51602678
alright, I was hoping I could get all comfy on the sofa, but I guess I'll move to a table
>>
>>51602125
Go
>if err != nil {
...
>}
even then, you can save a line by using
> if something, err := blah(); err != nil {
that's it.
>>
>>51602743
a, b = b, a
>>
>>51601187

trying to make an opencv web interface using angularJS, except i have no clue what im doing and i'm learning as i go.

Once I figure out how to inject html contents into a page (currently selecting 1 image processing option from the drop down just opens an entire new window) I'll have covered all the small problems.

The big one is how the hell am I supposed to let a user control an already running executable? This one I am truly stumped on and I haven't trudged through enough crap about web dev to know how to fix this.

example of what i'm talking about

http://docs.opencv.org/2.4/_images/Adding_Trackbars_Tutorial_Result_1.jpg

I want the user to be able to see updates to the final image as they change the values on the track bar.
>>
>>51602775
>Python
Only real languages allowed, kiddo.
>>
>>51602743
>mutable variables
>>
>>51602692
Having a C interface doesn't make something a "C Library"!
>>
>>51602790
that's Go
>>
>>51602653
>can't count
>uses non-standard 3rd party libraries
why live
>>
>>51602791
>assignment == mutation
Typical of an ignorant FP autist who will never accomplish anything worthwhile.

>>51602814
Even worse.
>>
It has eh editor now!
>>
>>51602743
void swap(ref int a, ref int b)
{
int temp;
a = (tmp = b, b = a, tmp);
}
>>
>>51602821
If it's not doing any mutation, then what's the point? Just swap any occurences of "a" and "b" afterwards
>>
>>51602821
>Even worse.
>>>/a/
>>
>>51602749
store the elements in a tuple and create an iterator over it

std::get<n+1>(tuple)
std::get<n>(tuple)
std::get<n-1>(tuple)
>>
>>51602825
>one line of code
No temp variables allowed either. Also what is that meme lang, D?

>>51602844
>>>/trash/
>>
>>51602812
You should define what a C library even is. Is something a "python library" if it's usable in python but not written in it?
>>
>>51602859
>>>>/trash/
yeah, sorry, I should have told you to go there instead.

reminder: Go >> your shit language, you should learn Go before it's too late
>>
>>51602743
a ^= b; b ^= a; a ^= b;
>>
>>51602859
All the swapping was done on one line like you said and you didn't say no temp variables. I put it in a function just out of habit, I easily could have just stuck it in main.
>>
>>51602905
Lemme fix that.
a ^= b ^= a ^= b;
>>
>>51602790
It's Lua
>>
>>51602904
>Go >> your shit language
What kind of meme language uses bit shifts to denote inequality?
>>
>>51602913
nice one. this can be done in based java of course.
>>
I read up on haskell syntax, typeclasses and shit, but i CANT think in the functional way. what do i do?
>>
>>51602859
auto ref invokeSwapped(alias FN, X, Y)(auto ref X x, auto ref Y y) 
if (is(typeof(FN(y,x))))
{
return FN(y,x);
}


auto take = (int a, int b) => a - b;
invokeSwapped!take(5, 4);


-1
>>
>>51602940
Have you perchance read The D Programming Language?
>>
>>51602938
Just start using it. It'll come to you.
>>
>>51602933
uhm, have you ever heard of this thing called math (or "maths")? it's the "much greater than" sign
>>
>>51602963
>buying proprietary softbacks
>>
>>51602743
(set! a (set! b a))
>>
>>51602981
>being british
>>
>>51602981
>not writing softbacks on some obscure language and shilling them on /g/
>>
>>51602997
>being a literal tripfag
>>
>>51602822
what the hell am i looking at?
>>
>>51602814
>>51602821
whats wrong with go?
>>
>>51602997
>Being a burgerclap
>>
>>51602905
>>51602913
>bit manipulation
M E M E
E M E M
M E M E
E M E M

>>51602976
In math, = is the equals sign too. Do you also write
if (a = b)
?
>>
>>51602997
>being an anarcho-capitalist-statist-christian-libertarian
>being an attention whore
>>
>>51602991
>L*sp
Again, >>>/trash/
>>
>>51603046
*jewish
>>
>>51603042
>In math, = is the equals sign too. Do you also write if (a = b)?
are you retarded or just pretending?
>>
>>51602015
The whole thing boils down to some bumfuck saying his doesn't like the API design. That's not "broken as fuck" sorry to disappoint your undirected rage.

If you have anything concrete feel free
>>
>>51603042
>imperative assignment in math
>imperative comparison in math
haskell safe space when
>>
>>51603042
>doesn't know XOR
>calls himself a programmer
>>
>>51603081
Did you even read the article? Do you even know what an API is?
>>
Man, pattern matching in a where block is fucking me up. Why is '=' weird in Haskell?
>>
>>51603108
>cannot be implemented in a feedforward neural net
literally euphoric
>>
>>51603081
1/10 if trolling, -10/10 if retarded.
>>
>>51603124
Post your code.
>>
>>51603028
>>51603010

These things are infinitely better than living on a rock where it always rains and everyone is inbred.

>>51603046

God bless, ya'll.
>>
>>51603158
>fresh air
>anti-racemixing
>bad things
>>
>>51603051
>implying your shitty language can compete with lisp
nice one fag, why don't you show your own code?
>>
The best thing about Java is that every program is basically open source since it can be decompiled so easily.
>>
>>51603148
From lyah :

 
initials::String->String->String

initialsfirstnamelastname=[f]++"."++[l]++"."
where(f:_)=firstname
(l:_)=lastname
>>
>>51603127
>AI
nice meme

>>51603265
Do you have something against spaces?
>>
>>51603278
whitespace and comments slow down compilation
>>
>>51603127
>he doesn't know about NTM models
>he doesn't know that virtually any nonlinear net can model xor
>>
>>51603265
Christ, use spaces please.

The problem is that Haskell has significant indentation. So you need to write it like:
where (f : _) = firstname
(l : _) = lastname

or
where
(f : _) = firstname
(l : _) = lastname

or something like that.

Also, your code looks broken to fuck anyways.
>>
>>51603293
Am I being rused?

Also, [f]++"."++[l]++"." is equivalent to [f, '.', l, '.']
>>
File: Screenshot_2015-11-30-03-33-53.png (200KB, 720x1280px) Image search: [Google]
Screenshot_2015-11-30-03-33-53.png
200KB, 720x1280px
>>51603302
>>51603278
>>
Anyone have a recommendation for good books on Computational Geometry?
>>
>>51603351
Such a shit book
>>
>>51603351
I feel like this is why people say not to use LYAH. It's a pretty convoluted example where use of the "head" function and list syntax like >>51603306 pointed out are much better.

My point about significant indentation still stands, see how it's written in the book?
>>
>>51603110
Not seeing anything concrete out of you, just a bunch of whiny bitch tears.
>>
>>51603355
heh yeah
*unzips cargo shorts*
compute this
>>
>>51603144
> Nuh uh
> Because it is
> Actually say something of substance? How do I do that?
>>
>>51603265
Don't be a nigger.
 
initials :: String -> String -> String
initials firstname lastname = [head firstname, '.', head lastname, '.']
>>
File: GOTEEM.png (6KB, 700x34px)
GOTEEM.png
6KB, 700x34px
>>51603042
>In math, = is the equals sign too. Do you also write
if (a = b)
?
>>
/** Small Straight: four of the five dice have consecutive values( e.g. 2,3,4,5 */
public static boolean isSmallStraight( int [] rolls ){

int consecutive = 0;
int counter = rolls[0];
for( int i=0; i<rolls.length; i++ ){
if( rolls[i] == counter )
consecutive++;
else
counter--;
counter++;
}
return consecutive == 4;
}


Can anyone top this?
>>
>>51602971
This desu. There was one book I wanted to read which contained OCaml code. I was rubbish at the start but I got it by the end.
>>
File: smug clockmed.png (109KB, 269x228px)
smug clockmed.png
109KB, 269x228px
>>51603265
>initialsfirstnamelastname
>>
>>51603435
-10//10 it is then.
>>
>>51603532
Nothing to say it is then.

Whats the matter? Too much of a bitch to say something for fear you might show your ignorance? It certainly seems so.

Or you could just respond with some internet meme insult like a child.
>>
>>51603503
I, uh...
>>
Java
>>
Java
>>
>>51602125
C#
can only use => to define read-only properties.
Should be able to do
public type PropertyName => member.ReadWritePropertyOfSameType;

and have the derived property be read/write.
>>
can you generate files on server using html
>>
>>51603503
It's shit.
/* Get number of consecutive rolls. */
size_t
getnconsec(const int *rolls, size_t nrolls) {
int nconsec = 0;
for (size_t i = 0; i < nrolls - 1; ++i)
if (rolls[i] + 1 == rolls[i + 1])
++nconsec;
return nconsec;
}

bool
is_smallstraight(const int *rolls, size_t nrolls) {
return getnconsec(rolls, nrolls) == 4;
}
>>
First for go
>>
>>51603784
>rolls[i] + 1 == rolls[i + 1]
++*rolls == *++rolls
>>
>>51603847
>const int *
>>
>>51603847
Undefined behaviour, you fuckwit.
>>
>>51603847
Those don't do the same thing
>>
Can I create a loop in a new function?
>>
>>51603908
Yes, unless you're using a language that doesn't have loops.
>>
>>51603503
I'm not even sure if your code is correct to begin with...
>>
>>51603908
Why don't you fucking try it out??
Nobody's gonna stop you, and it won't hurt that much if it doesn't work.
>>
>>51603759
use Java
>>
>>51603943
In some languages, it's very impractical to "just try out" something. For instance, opendylan (by contrast with mindy) requires a project and lib file accompany any source file that is to be compiled and they must all have the correct information so the project can be compiled.
>>
>>51603940
>>51603784
I fixed it
/** Small Straight: four of the five dice have consecutive values( e.g. 2,3,4,5 */
public static boolean isSmallStraight( int [] rolls ){

int consecutive = 0;
int counter = rolls[0];
for( int i=0; i<rolls.length; i++ ){
if( rolls[i] == counter )
consecutive++;
else
counter = rolls[i];
counter++;
}
return consecutive == 4;
}
>>
The D programming language has a function called
makeTrans
>>
>>51604022
It's still just searching for a sequence of identical values, isn't it?
>>
>>51604165
:^)
>>
>>51604022
Still horrible. It's not idiomatic at all (at least I hope that's not a Java idiom).
>>
>>51603784
I don't think this works with duplicate values say {1,2,3,3,4}
>>
tfw I was doing while loops and copy/pasting previous work, and as I was working with a different program, I found out that I could have just done a do loop.
>>
>>51603984
If you're using such a heavyweight language, you wouldn't be asking trivial questions like that.
Still, that sounds like a pain in the ass for any scale of development.
>>
>>51604215
Visually there appears to be 3 consecutives in that list. Without changing the logic, my function returns 3 on that list. Unless you're saying getnconsec({1, 2, 3, 4, 5}) should evaluate to 5 I don't know what you mean.
>>
>>51604210
k bud its not that bad alright
>>
>C++ doesn't have ranges
>C++ doesn't have uniform function call syntax

Why live?
>>
>>51601270
It really depends on your own diction of the topic.

If you deal in high level arguments, words such as do and go come to mind, then you can write one huge function of write several sub functions to act as breakpoints in your code. If you deal in low level arguments, you can literally divvy up tasks in a procedural manner ( or go the almighty haskell route of functorial ) and encapsulate the events via a class system or use structs to designate the appropriate structure to be worked on so that you can do it all at any time you see fit but also manage to keep the data from eventually colliding.

Best tip, from me to you, is to figure out what parts you might want to change and put that in a separate function. If there is some work in a few line passes that you cannot omit, create a lambda function and do the work there and then return to the normal sequence of the function.

This code is ultimately for you. Only you can dictate the pace, really.
>>
>>51604316

Learn from that
>>
>>51604464
Are you trying to sound complicated?
>>
>>51604394
If you're using such a heavyweight language you're in the only position where you should ask these questions actually.
And yes, it's a pain in the ass for small projects, but for medium or large ones, you'd be providing a library and project file with your source anyway so it doesn't change much.
>>
>>51604455
C++11 has ranges I think. What's a uniform function call syntax?
>>
>>51604567
I think ranges were proposed for C++14 but set back to C++17
>>
>>51601538
>>51601625
max_sum = max(sum(i) for i in lists)
>>
>>51604567
C++11 has range-based for loop, but not ranges (which are in a sense a generalization of iterators).
>>
Whats everyones favorite pl t ciclejerk. I currently know python, c++, racket, and a bit of java.
I found racket to be stupid at first but looking back functional languages are pretty cool. Should I learn Haskell. Im going to be start working on some things and was wondering if I should just stick to c++ or if Haskell was the superior language that everyone circlejerks.
>>
>>51604626
I think there is, with Iota<x>, as in
for(unsigned i : iota<10>) {
...
}
>>
>>51604629
OCaml is the industry-approved version of haskell. It's also less gay with indentation and has support for mutability and OOP.
You should go back to racket first, though, since you seem to finally be open to accept scheme's greatness.
>>
Dong work for a book to learn c++. Made this program after the chapter on vectors while/for loops and create your own functions.
#include "std_lib_facilities.h"

int main() {

vector<string> words;
vector<string> disliked = {"broccoli", "beans", "spinich"};

for(string temp; cin>>temp;)
words.push_back(temp);
cout << "Number of words: " << words.size() << "\n";

sort(words);
vector<string> print_list;

for (int i=0; i<words.size(); ++i) {
if (i==0 || words[i-1]!=words[i]) {
for (int j=0; j<disliked.size(); ++j) {
if(words[i]==disliked[j]) {
print_list.push_back("BLEEP");
break;
}
if (j==(disliked.size()-1)) {
print_list.push_back(words[i]);
}
}
}
}

for (int k=0; k<print_list.size(); ++k){
cout << print_list[k] << "\n";
}

return 0;
}


It works but I want to break it up into functions because I have a hard time fucking with it while keeping it all straight.

Occurred to me I do not know what a function looks like when I want it to return a vector. Anyone know how to do that? I know you can send one a vector with just the name like sort().
>>
>>51604567
C++11 doesn't have ranges, it has a range-based loop.

Uniform function call syntax:
x.fn(a, b, c) (where x has no member fn)
->
fn(x, a, b, c)
>>
>>51604675
Huh, never knew that we had that. Perhaps it is _a_range_ but it is hard to express more of them in current C++?
>>
>>51604692
How's multicore in OCaml these days?
>>
>>51604728
inb4 use templates to make a monad to do this for you
>>
>>51604748
Not him, but according to what I've heard it still doesn't exist. I don't personally use it though so I am not the biggest expert.
>>
>>51604728
>I can't read: the post
>>
>>51604728
uniform function call syntax is not always beneficial.
C++ gains features for not having that. The grass isn't always greener, and just because you have an opinion doesn't mean it's correct.

As for ranges, I can implement a fully generic lazy range in ~50 LOC. Unless you're talking about something else and you just don't want to tell us what it is?

I disagree with lots of things about C++ but ranges and uniform function calls are the very least of its issues.
>>
>>51604817
>uniform function call syntax is not always beneficial.
>C++ gains features for not having that.
Er...what?
>>
>>51604748
4.03 supports multicore, and there's a compiler hack that enables it anyway.
Coincidentally, I was impressed to learn how many languages didn't have any multicore support.
>>
>>51604841
virtual functions.
Less possibility for ambiguity in C++'s already confusing overloading semantics.
>>
I honestly never pay attention to C++ code and have never really had an interest in learning. I mostly write C and Python but I'm interested in looking at C++ a little.

What's the K&R of C++?
>>
>>51604841
The ability not to have _____the___self_object___of___selfness___.param
everywhere in function bodies.
>>
>>51604800
I don't understand what you mean.

>>51604817
Ranges + UFCS + algorithms are a really good combination, but I could understand not wanting them.

TBQHF I think UFCS should be a standard library monad.
>>
>>51604875

One of the Stroustrup books. Programming: Principles and Practice Using C++ second edition is kinda a learner book.

The C++ Programming Language 4th edition is more a manual for people that are completely comfortable with programming already.
>>
>>51604860
Yeah I think I remember Erlang only fairly recently (in the grand scheme of things) getting proper multicore support.
>>
>>51604912
I recently wrote a programming language that depends on methods rather than UFCS, because type overloading is impossible due to type inference.
4.equal(5) // -> false
4.equal(4) // -> true


However, I added syntax that mimics UFCS in some respects
let f = .equal :: int; // f : fn(int, int) -> bool
f(4, 5) // -> false
f(4, 4) // -> true

It even works with type inference (sometimes)
fn foo (f : fn(int, int) -> bool) {
f(4, 5)
}
...
foo(.equal) // -> false
>>
>>51604817
template <typename T>
struct UFCS
{
UFCS(T&& y) : x(y) {}
template <typename FN>
decltype(auto) operator>>(FN&& lm) { return UFCS<decltype(lm(x))>(lm(x)); }
T x;
};

(for non void, MSVC only)
doesn't bind with other args (1 param only)
identity monad

    std::cout << (UFCS<int>(5) >> [](int x) { return x * x; } >> [](int x) { return x + x; }).x << '\n';


lambdas in C++ are hideous
>>
>>51605038
Really? I thought it was still using greenthreads right now.
>>
>>51605123
(this'd be a lot nicer as 5.square.duble.writeln)
>>
Is there an online chess engine I can pass arguments like php and will return his moves. I'm making a chess client but I don't want to download a chess engine. My last choice is to use the chess telnet thing but then I need to interface telnet to my program which is harder.
>>
File: output.webm (339KB, 1200x800px) Image search: [Google]
output.webm
339KB, 1200x800px
Can your editor do this?
>>
>>51605497
At least my editor doesn't rape people with toothbrushes
>>
Anyone know how to make a loop in c++ that continues until you receive a specific character?

while(cin!="|") is not working. | is the character btw. Do I need to use >> somehow?
>>
>>51605497
disgusting and retarded
>>
>>51605581

Should I just use a boolean and let the special character flip it therefore breaking the loop?
>>
>>51605581
cin.get() reads a character from cin
>>
>>51605129
Oh shit you might be right
>>
>>51605497
>using a mouse in your text editor
>>
>>51605668
>reaching for escape to navigate 3 lines
>>
>>51605497
elijah, you know very well that that shit is useless and retarded
>>
>>51605676
At least for the escape key you don't have to leave the keyboard.
>>
>>51605832
Not when I'm utilizing TrackPoint(tm) on my Thinkpad(tm) x201
>>
Work is depressing.

• No coding conventions or standards
• 80% of coworkers are so incompetent that if they stopped helping and actually did nothing, our productivity would improve because I spend more time fixing their broken shit than the time it would have taken to just do it myself.
• Of the 20% who actually can code something that at least works, they're big into design patterns and everything that would have been a 4 line method is now composed of a dozen interfaces, two dozen implementation classes, a couple factories, several strategy patterns, etc.
• Most management doesn't listen. A couple of them are total bros, but most of the others suck. I literally had a meeting with one manager about all the data changes that would occur with a new project. When testing started, the testing team ran to me all freaked out about how the results had changed compared to the legacy system. "Did you honestly expect them to be the same?" - "Yeah. Manager X said that everything would be identical".
• Same manager from previous story. I was analyzing some software their team had written.

The only reason I stay now is that I have job security. I would have to pull a Jared Fogel and join ISIS before they would think about firing me. It's still depressing though.
>>
>>51605939
sux
>>
>>51605939
Same where I work, We are constantly shifting technologies because the head engineer falls for every buzzword on the planet.

We are constantly doing work on our 10 year old back end to make it 'webscale'

more than half of the developers write code that looks like something out of a CS freshmans "code/" folder.

The departments aren't synchronized so QA is using some cloud platform for the bugs/edits but the project managers are still developing specs in microsoft fucking word
>>
>>51605939
Honestly it sounds like you're working too hard and your coworkers have already figured out how to do the least amount of work possible because they all know you're just gonna pick up the slack anyway.

Stop trying so hard and find greener pastures in the meantime.
>>
First for windows 10
>>
>>51605939
Looks like 4chan cut off part of my post (but strangely included the last line)? Maybe something about greentext following bullets? Anyway. Another story from the same manager who doesn't listen. I was analyzing some software their team had written...

>Are we ready to start testing and deployment?
>No. It's so broken and so much data is wrong or missing that you cannot proceed forward until these issues are fixed.
>Can we postpone them and do a bug fix release later?
>No. All future tasks depend on this portion working and producing correct data or at least a significantly large subset of correct data. It is nowhere even close.
>Right. But can we just put that on hold and deploy it anyway?
>No. It will corrupt the whole database with bad data and all existing records will be marked as unidentified and be deleted if you try to use this.
>Okay, team. You heard him. We'll proceed forward as expected. Make a note of this issue so we can patch it later.
>>
I'm putting my extremely ambitious, resource intensive project on hold for now, to actually learn shit about programming.

So far the Codecademy course on Python has been super easy. I'm taking notes as I go along.
>>
>>51605939
>Of the 20% who actually can code something that at least works, they're big into design patterns and everything that would have been a 4 line method is now composed of a dozen interfaces, two dozen implementation classes, a couple factories, several strategy patterns, etc.
That's what you get for hiring compsci grads.
B-B-BUH MUH DEGREE!
M-M-MUH THEORY!
>>
I'm finishing up uni and I'm good at maths, but an absolute garbage programmer. Any way I look at my code, it should work, but there's always something I've never heard of that fucks up in the background, like there's something OS or hardware or implementation-dependent I didn't expect or there's some peculiarity in the language or the compiler keeps throwing cryptic messages and I have no idea what could ever bother it. It's probably stupid to try and group all my failings into one category of background bullshit, but I don't even know where to start.

Aside from just picking up experience, how could I tackle this? I'm thinking maybe reading an in-depth comparison of multiple languages might cover most of what I need. Or perhaps it'd be enough to just pick a relatively tricky one and study up on it, hoping the general ideas carry over?
Any reading material you could recommend?
>>
>>51606042
So did it fuck up their database?
>>
>>51606109
git gud (by programming more)
>>
>>51606109
Program more.
That's it.

What you're describing are novice frustrations. You look at the code, you think "Yeah that should do it", and then get blocked and mad when it doesn't because you missed X component of feature Y.
Just keep at it, eventually it'll click.
Or it won't, not everybody is cut out for it.
>>
>>51606109
It's like my friend studying chess. He reads tactics books but never actually plays and is terrible. Play more games, and you will improve.
>>
>>51606042
>Are we ready to start testing and deployment?
>No. It's so broken and so much data is wrong or missing that you cannot proceed forward until these issues are fixed.
>Okay so testing go ahead and report your bugs, then we'll release friday, okay?

Every fucking week at my job.
>>
You boys wanna get depressed about the state of software development?
Here's a piece written about the modern programming mindset by someone with the modern programming mindset
https://blog.enki.com/coding-is-boring-unless-4e496720d664
>>
I have programmed for years and this is the most useful thing I have ever programmed:
#!/bin/sh

dpt() {
~/bin/dpt.py
}

dpt_with_notify() {
notify-send 'Searching for Daily Programming Thread'
dpt
if [ ! $? ]; then
notify-send 'Daily Programming Thread not found.'
fi
}

if [ $1 = "-a" ]; then
dpt_with_notify
else
dpt
fi

#!/usr/bin/python2

import basc_py4chan as chan
import webbrowser
import re

def get_matching_threads(board_name, pattern):
board = chan.Board(board_name)
threads = board.get_all_threads()

match_threads = []
for thread in threads:
sub = thread.topic.subject
com = thread.topic.comment
if sub and re.search(pattern, sub, re.IGNORECASE) or \
com and re.search(pattern, com, re.IGNORECASE):
match_threads.append(thread)
return match_threads

def open_threads(threads):
for thread in threads:
webbrowser.open_new_tab(thread.url)

def main():
import argparse

default_board = 'g'
default_pattern = "Daily Programming Thread|DPT"
parser = argparse.ArgumentParser(description=\
'''Open threads matching a pattern in-browser.
Defaults to /g/ and this pattern: "{}".'''.format(default_pattern))
parser.add_argument('pattern', nargs="?", default=default_pattern,
metavar='pattern', help="The pattern to search the OPs for.")
parser.add_argument('-b', '--board', dest='board_name',
default=default_board, metavar='board',
help="The board to search for the patterns on.")
args = parser.parse_args()

board_name, pattern = args.board_name, args.pattern

print board_name, " ", pattern
match_threads = get_matching_threads(board_name, pattern)
open_threads(match_threads)
exit(len(match_threads))

if __name__ == '__main__':
main()

I should honestly quit programming. I never make anything interesting.
>>
>>51606113
Thankfully someone stepped in and stopped them from trying to proceed. They worked for a few more months and then handed it back to me. Their schedule for me absolutely insane though. Each component was scheduled for 1 day of analysis, data integrity checks, and sign off. It takes a week or two to do one component. So we instantly fell behind schedule. The schedule got pushed back, but when they pushed it back, they just moved all the dates forward, but didn't bother to adjust the whole "1 day per module" part of it. So the higher-ups started getting nervous as fuck about why the schedule kept being missed despite the schedule being adjusted 5 or 6 times.

It's going more smoothly now. I've approved most of their components and things are much better than they were earlier this year when the project was in complete disaster mode. I think I might even get a raise out of this when my yearly review comes up.
>>
>>51606244
Wanna cuddle and program together? :3
>>
That one guy that asked me why ++i was more efficient over i++, i++ creates a copy of i that is increased then returned. ++i increments i directly and returns it.
>>
>>51606294
only matters when using iterators in C++
>>
>>51606310
Yes, but why not just use one thing if it's better even if only applicable in iterators
>>
>>51601187
Chatbot debugging.

It's a convoluted mess of a codebase seeing as my programming skills have grown with the project and it's overdue for refactoring, and I now have a glorious headache.
>>
>>51606436
Just rewrite it from scratch
>>
File: stangor-fig09_007.jpg (170KB, 1648x691px) Image search: [Google]
stangor-fig09_007.jpg
170KB, 1648x691px
>>51605939
>lolnormies
friendly reminder that the vast majority of the population is stupid as hell and you're one of those people
>>
>>51606063
>my extremely ambitious, resource intensive project
>Codecademy course on Python
shiggly diddly
>>
>>51606294
from a purely performance point of view it doesn't matter in most cases for compiler-optimized languages, but from a style point of view you should kill yourself if you use i++ outside of situations where you actually use the initial value like
arr[i++] = 1;
>>
NEW THREAD

>>51606575
>>
>>51606586
Kill yourself
>>
>>51606586
The bump limit is 310 you degenerate fuck.
>>
>>51606310
>only matters when using iterators in C++

It matters when using any non-intrinsic type.

Also, it's my understanding that it matters way less as of C++11 or C++14.

Also, on an unrelated note, it's my understanding that this hasn't been n^2 for a long time:
for (int i = 0; i < strlen(s); i++)
{
// do whatever to s[i]
}


(this was a classic interview question. Old-timey C/C++ would call strlen on ever iteration. Modern compilers understand that if the body doesn't modify s, that strlen's result can be cached.)
>>
>>51606446
It would be the sixth time I've rewritten it, and it has become exceedingly efficient at what it does.

But seriously (though it has been rewritten a half-dozen times), the current problem is just many bits and pieces of poorly designed modules sitting on top of a reasonably polished core more than anything.

If ever I rewrite the entire system again, it'll be because I've discovered a vastly superior approach to what I'm trying to do. Which is somewhat unlikely in the near future.
>>
>>51606645
>Modern compilers understand that if the body doesn't modify s, that strlen's result can be cached
How can the compiler make this guarantee? You're better off making sure that it's efficient rather than hoping the compiler optimizes it.
>>
>>51606779
>How can the compiler make this guarantee?

How couldn't it?
>>
>>51606779
this

especially non-GCC compilers can emit surprisingly bad code
>>
>>51606902

Pfft.

If you're not pointing out flawed assembly, you're not saying anything important.

>blanket dig at non-GCC compilers
>generic FUD
>>
>>51606853
Any pointer dereferences in your code could potentially point inside 's', and any external function calls may be modifying it if its declared globally
>>
>>51606956

Oh my God, you mean side effects might actually be *lessened*?!

/sarcasm

Obviously, *OBVIOUSLY* what the optimizer can do depends upon what's inside the loop body. No fucking duh.
>>
>>51606995
I just gave examples showing that its really easy for that optimization to be impossible (or unlikely)
>>
Trying to figure this out in Perl (Industry Standardâ„¢ for work):

Option 1 (pseudo-code):
create empty Array
foreach File in directory:
open File
push contents of File to array
close File

foreach element in Array:
print element


Option 2 (pseudo-code):
foreach File in directory:
open File
print contents of File
close File


WHY THE FUCKING FUCK IS OPTION 1 FASTER. Any number of files, any size of files... it's always faster. FUUUUUUUUUUCK
>>
>>51607079
Because I/O is the most expensive operation here so when you print with each file it's slow as fuck.
>>
>>51607122
It has to do that in either case. Is the bottleneck in Case 2 where switching between manipulating file-storage and printing and back causes a slow-down?
>>
>>51607079

Honestly, the performance should be dependent on the OS here, for how it handles I/O. If each of those file reads is using the same buffer for storing data as it gets pulled off the disk, then it might be efficient to regularly access that buffer while all of the disk I/O is being performed, so it can be kept in cache. Then, when terminal I/O must be done, a different buffer is used, and loaded into cache. In option 2, one is constantly switching between I/O buffers.
>>
>>51606995
C code:
int hash (char* s) {
int i, k = 0;
for (i = 0; i < strlen(s); i++)
k = (k + s[i] * 11) % 107;
return k;
}


GCC output: (gcc -O2 hash.c)
004011a0 <_hash>:
push %edi
push %esi
mov $0x4c8f8d29,%edi
push %ebx
sub $0x10,%esp
mov 0x20(%esp),%ebx
mov %ebx,(%esp)
call 401200 <_strlen>
xor %edx,%edx
lea (%ebx,%eax,1),%esi
jmp 4011e3 <_hash+0x43>
xchg %ax,%ax
movsbl (%ebx),%eax
add $0x1,%ebx
lea (%eax,%eax,4),%ecx
lea (%eax,%ecx,2),%ecx
add %edx,%ecx
mov %ecx,%eax
imul %edi
mov %ecx,%eax
sar $0x1f,%eax
jne 4011c0 <_hash+0x20>
add $0x10,%esp
mov %edx,%eax
pop %ebx
pop %esi
pop %edi
ret


Clang output (clang -O2 hash.c)
004011a0 <_hash>:
push %ebp
mov %esp,%ebp
push %ebx
push %edi
push %esi
sub $0x8,%esp
mov 0x8(%ebp),%edi
mov (%edi),%al
xor %esi,%esi
test %al,%al
je 4011f8 <_hash+0x58>
mov %edi,(%esp)
mov $0x1,%ebx
xor %esi,%esi
mov %al,-0xd(%ebp)
call 401230 <_strlen>
mov %eax,%ecx
mov -0xd(%ebp),%al
jmp 4011d4 <_hash+0x34>
nopl (%eax)
mov (%edi,%ebx,1),%al
inc %ebx
movsbl %al,%eax
imul $0xb,%eax,%eax
add %eax,%esi
mov %esi,%eax
mov $0x4c8f8d29,%edx
imul %edx
mov %edx,%eax
jb 4011d0 <_hash+0x30>
mov %esi,%eax
add $0x8,%esp
pop %esi
pop %edi
pop %ebx
pop %ebp
ret


Tell me some more about strlen() being optimized out
>>
In Python,

I want to open a process.
While I have a line on Python stdin,
I want to write one line to the process, and receive one line of stdout from the process.

I want to do this infinitely without spawning a process for each line. I can't get all the input at once, and I need the output as soon as the input line goes in.

How do I do this?
>>
>>51607259
God, why does objdump default to AT&T syntax?
>>
>>51607259
Make it const. It probably can't make the assumption that 's' won't change, in case the program is multithreaded.
>>
>>51607329
Because that's what GCC outputs and what the GNU assembler takes.
>>
>>51602743
int a = 1; int b = 2; int :) = 3; :) = a; a = b; b = :);
>>
>>51607079
why wouldn't option 1 be faster?
>>
>>51607079
similar issue: http://stackoverflow.com/questions/8547778/why-is-one-loop-so-much-slower-than-two-loops

printing is pig slow so the array takes almost no overhead in time by comparison. in option 1 you're focusing on one thing at a time and you're pretty much buffering all the content so you can print it all at once. in data-oriented design you want to do things like this, focus on one thing at a time instead of a mix of several different things
http://www.gameprogrammingpatterns.com/data-locality.html
Thread posts: 322
Thread images: 15


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