[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: 316
Thread images: 23

File: roberta (1).jpg (77KB, 545x765px) Image search: [Google]
roberta (1).jpg
77KB, 545x765px
old thread >>55711471

what are you working on that isn't script shit, /dpt/
>>
first for python is a meme language and no one should use it for anything more than a script that can be written in a day
>>
>>55715586
first for you've probably never had a real programming job
>>
>>55715537
Are girls with guns going to become a new theme for /dpt/? Because I for one approve of this.
>>
>>55715609
nuns with guns
>>
>>55715609
Only probably these two times

I used to love making the trap poster butthurt by beating him to the punch but I have things to do
>>
>>55715537
> roberta (1).jpg
Can't you find something related to programming to post, scriptfag?
>>
>>55715676
Hey it's trap poster everyone
>>
>>55715687
>everyone
Everyone hates you for what you did.
>>
>>55715711
(you)
>>
Need some help debugging my trie implementation /dpt/.

My Trie class looks roughly as follows:
class Trie {
private:
std::array<std::unique_ptr<Trie>, 27> children_;
public:
/* ... */
};


Each Trie object has an array of pointers to the children of its roots. There are 27 elements in the array, one for each possible (uppercase) letter of the alphabet plus one for the null character. If the root of the Trie does not have, say, the letter 'C' as a child, then third element of the array will be a nullptr.

Here is how I insert strings into the Trie:
void Trie::insert(const char *string) {
Trie *p_trie = this;
for (unsigned int i = 0; i < std::strlen(string); ++i) {
std::size_t child_index = static_cast<std::size_t>(string[i] - 'A');
if (not p_trie->children_[child_index]) {
p_trie->children_[child_index] = std::make_unique<Trie>();
}
p_trie = p_trie->children_[child_index].get();
}

// Add null character.
p_trie->children_[children_.size() - 1] = std::make_unique<Trie>();
}


and here is how I check that a string is inside the trie:
bool Trie::has_string(const char *string) const {
const Trie *p_trie = this;
for (unsigned int i = 0; i < std::strlen(string); ++i) {
std::size_t child_index = static_cast<std::size_t>(string[i] - 'A');
if (not p_trie->children_[child_index]) {
return false;
}
p_trie = p_trie->children_[child_index].get();
}

// Check null character.
return children_[children_.size() - 1] != nullptr;
}


Unfortunately this doesn't work: as the pic shows, inserting some strings to a trie and checking that they are there returns false instead of true. If I change the last line of has_string to
return true;
, it works, so there must be some issue with setting the last character to nullptr.
>>
Is there a certain algorithm by making procedural paths to run on with branches without the paths blocking eachother?

I want to know how you make the procedural aspect of a game like Temple Run
>>
>>55715773
can my opponent reply
>>
whatever happened to julia
>>
>>55715537
Thank you for not using a trap image again. You're a based OP.

>>55715676
Fuck off trapfag
>>
>>55715880
People realised that you can get Python to run as fast as Julia, which obviated its purpose.
>>
>>55715880
last time I checked it was in the development stage and not even the core syntax was finalized
>>
>>55715893
>samefagging this hard
How about all you animefags fuck off?
>>
>>55715905
>People realised that you can get Python to run as fast as Julia
[Citation Needed]
>>
Thank you for not using a programming image.
>>
File: MOV02260.webm (3MB, 640x480px) Image search: [Google]
MOV02260.webm
3MB, 640x480px
i suck nigger cock in my freetime
>>
>>55715991
wat dis?
>>
>>55715991
>you will never make your own Christmas tree lights that have this kind of custom movement.
;_;
>>
>>55715780
Questions:
Why use size_t for indices?

>const Trie *p_trie = this;
>p_trie = p_trie->children_[child_index].get();
Why are you changing the value of a const pointer? Is this some weird C++ thing?

Also I think the problem is
for (unsigned int i = 0; i < std::strlen(string); ++i)
. If you want to process the null character as well, shouldn't it be
i <= std::strlen(string)
?
>>
>>55716018
an atmega8a, some leds and a piezo buzzer
>>
>>55715991
Does it make noise too? The black thing on the right of the IC looks like a buzzer. Also what's that LED bar called.
>>
>>55716060
>Why use size_t for indices?
Easier to check if it's off bounds.

>>const Trie *p_trie = this;
>>p_trie = p_trie->children_[child_index].get();
>Why are you changing the value of a const pointer? Is this some weird C++ thing?
He isn't changing the const pointer itself, only the pointed to object.
>>
>>55715780
Sounds like you know where your issue is. Fire up your nearest debugger and have at it.

Tries are wasteful as shit for strings. I hope this is a school assignment.

>>55715940
numpy + pypy. Reduce parsing overhead and checks of the language itself + fast arrays and vectorized array and matrix operations.

>>55716060
>Why use size_t for indices?
It's considered 'correct' to index arrays with a type that can contain all possible array indices. size_t namely.

>Why are you changing the value of a const pointer?
The pointer isn't const, the value is.

>If you want to process the null character as well, shouldn't it be
i <= std::strlen(string)
?
This is probably the issue.
>>
>>55716060
I'm not who you're replying to, and I don't use C++, but this shit applies to C as well:
>Why use size_t for indices?
size_t is the type that makes the most sense. It can index into any arbitrary array.
>Why are you changing the value of a const pointer?
It's not a const pointer. It is a pointer to const.
>>
>>55716060
>Why use size_t for indices?
I have warnings set on max. If I don't typecast
string[i] - 'A'
to an unsigned type, the compiler complains about a sign conversion.

>Why are you changing the value of a const pointer? Is this some weird C++ thing?
const int *p
is a pointer to a constant int, not a constant pointer. I can change the value of p, but not the integer it points to.

I'm intentionally not processing the null character in the for loop, because then
string[i]
would equal 0, and hence
string[i] - 'A'
would be a negative index. Instead I'm just setting the last element of the last array of children and treating that as the location of my null character.
>>
>>55716097
>Tries are wasteful as shit for strings. I hope this is a school assignment.
Is there another data structure that allows me to (efficiently) check for membership of both a string *and* any prefix of that string? The prefix thing is important and the reason why I'm not using a hash table.
>>
>>55716085
>Does it make noise too?
yes
>Also what's that LED bar called.
not sure. got it from uni
>>
>>55716097
>numpy + pypy. Reduce parsing overhead and checks of the language itself + fast arrays and vectorized array and matrix operations.

You can also use Cython and get near C-like performance practically for free.
>>
>>55716150
>near C-like performance
Just because something gets compiled, it doesn't mean that it's going to perform anywhere close to C.
>>
>>55716109
>size_t is the type that makes the most sense. It can index into any arbitrary array.
uints can't?
>>
size_t is big enough to hold the size of the biggest possible object in the language. Thus it is used for sizes and indexes.
Other types may not be able to hold a big enough size.
>>
>>55716166
Right.
The largest possible array is an array of SIZE_MAX chars (obviously you won't get this in practice), and size_t can index into it. unsigned int has no guarantees about anything.
>>
>>55715843
You're a faggot
>>
>>55716162
Look at Cython versus C benchmarks. Performance is nearly identical for large enough data sets.
>>
>>55716097
>vectorized array and matrix operations
that's not what julia is for desu

try to implement something in python and not just call a function, it's gonna be 100 times slower

and even the python functions that are written in C are slow as shit compared to competition, which is probably because the best programmers don't spend their time developing python libs
>>
File: 241235507890.jpg (63KB, 633x758px) Image search: [Google]
241235507890.jpg
63KB, 633x758px
>>55715537
>What are you working on?

Nothing because the only two ideas that I had fucked me over when I got cucked by two totally seperate and unfixable issues.

So now I'm working on sweet fuck all because I am a creative black hole.

Why did I bother learning to program in the first place /dpt/?
>>
>>55716188
Largely depending on the programmer and how shit they are
>>
>>55716188
>Look at Cython versus C benchmarks.
they're cheating, you need hours to figure out where to add types to optimize that mess which is so different from Python that you gotta wonder why would someone do it like that and not just call C from Python
>>
You are all a bunch of normies holy shit
>>
>>55715598
You don't know what you're talking about.

Shitty languages like Python are banned in my team because they're breeding grounds for bugs. I personally got a co-worker reprimanded because I spotted him checking in Python code.

Did you go to a code bootcamp where all they taught you was Python, Ruby and JS? Sorry kid, you got played.
>>
File: retarded.gif (2MB, 500x375px) Image search: [Google]
retarded.gif
2MB, 500x375px
>>55716255
>they're cheating,
>>
>>55716255
>you need hours
You need minutes. Adding type information isn't rocket surgery.
>>
>>55716274
This man speaks the truth only superior languages like Java are worth learning and it's step brothers like C, C#, and C++ everything else is obsolete
>>
>>55716290
>Adding type information isn't rocket surge
python sciptfags are not allowed to say "isn't rocket surgery"

learn a real language, it isn't rocket surgery
>>
>>55716097
>numpy + pypy
So C, really.

Big fucking whoop. Any language can call C code and then claim to be fast.
>>
>>55716274
>Shitty languages like Python are banned in my team because they're breeding grounds for bugs. I personally got a co-worker reprimanded because I spotted him checking in Python code.
This doesn't make sense, since when could you just start writing code in a new language on an already existing project?

Also, you're obviously a retard working with retards. The company I work for make analysis software for IPTV providers, and I've implemented a real-time MPEG DASH analyser in Python. Shit is cash.
>>
>>55716291
kek, Java is shit too. C/C++ for performance-critical code, Haskell for everything else. We tried Scala but it's too much of a mess.

A few years ago we had a Java/Spring evangelist, we're still picking through and trying to get rid of the rot he wrote.
>>
>>55716303
>So C, really.
No, Python. Calling C functions does not make it C. Why is this difficult to understand?
>>
I'm not a fan of Python myself, but it has its uses. I wouldn't recommend it for anything that is bigger than 300 lines, requires a lot of performance or has to be very stable (Python doesn't have a static type system). Most of the time you're better off with a language that's better suited for the job when you need one of those points
>>
>>55716356
>non-ironically pretending that Haskell is actually used
>non-ironically calling it C/C++
>calling it Java/Spring evangelist without actually knowing what Spring is
Found the NEET who is pretending to have a job.
>>
>>55716308
He was writing some sort of check script, intended to be used separately from the main code, on its outputs.

If your company uses Python, then you are the retards, anon.
>>
>>55716358
> Calling C functions does not make it C.
the rest of the language is slow as fuck

and I mean two orders of magnitude slower, completely useless
>>
>>55716356
Java is great for enterprise business applications. It is not Java's fault that you had a very bad programmer who couldn't handle Java and it's complexity. If used properly Java will harness you great programming power
>>
>>55716303
Python, like all other languages such as Java and PHP, has its standard library implemented in C.

If you call standard library functions and built in functions, you're not "calling C", you're still working in Python.
>>
>>55716358
>write a Python script that does nothing but run C code
Python is so fast guise!!!
>>
>>55716356
Java should die, I agree with that (even though it probably wont because of all the legacy code). I'm a big fan of Rust. C++ performance, type system like Haskell, able to write high level or low level, zero cost abstractions and much more.
>>
>>55716410
See >>55716398

If you use a standard library function or object, you are running C code. The interpreter is written in C.

You have a strange arbitrary definition.
>>
>>55716392
Please Pajeet, go shit in the street.
>>
>>55716422
>>55716425

No Java is a good programming language your statements of it's bad for no reason proves you are bad programmers
>>
>>55716422
>type system like Haskell
Hahahahahahaha no. It's a big step up from C++ but it's nowhere near Haskell that regard.
>>
>>55716388
>works in an environment with language fanboys
>thinks anyone developing in C or in C++ would lump those two together and call it C/C++
>thinks Haskell is easier to maintain and find fresh meat for than Scala or Java
>>
>>55716389
What's your point? For ~80% of your code base, performance isn't too important, so even two orders of magnitude isn't a big deal. (And that's assuming the code is CPU bound, which is rarely the case anyways).

For the actual performance bottlenecks, you can just call Cython or Numpy or Numba or whatever and you will probably get your desired performance without sacrificing development time or code readability. If not, then you should consider another language.
>>
>>55716392
>>55716435
Please fuck off Pajeet. Java is shit and you know it. It should only be used to maintain existing programs, not to write new ones.
>>
>>55716443
What exactly isn't like Haskell? It has algebraic data types, traits (same as typeclasses in Haskell), etc.
>>
>>55716435
It's an absolutely terrible language and it fails to give you even the most basic code reuse. Whenever you use a language like Java, or C#, you're basically saying that you like rewriting the same code over and over again. Unless there's a business reason you need to use that language then there is no sane reason to use it.
>>
>>55716450
>For ~80% of your code base, performance isn't too important

this conversation started with comparing julia (a math language) to python performance

performance is everything and julia is readable
>>
File: 1434942762321.jpg (122KB, 640x640px) Image search: [Google]
1434942762321.jpg
122KB, 640x640px
>by the time I can figure out what the hell somebody elses' code is supposed to do I could have just coded it myself
>>
Look how elegant and well structured real Java programming is


package com.tutorialspoint;

public class HelloWorld {
private String message;

public void setMessage(String message){
this.message = message;
}

public void getMessage(){
System.out.println("Your Message : " + message);
}
}

package com.tutorialspoint;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainApp {
public static void main(String[] args) {
ApplicationContext context =
new ClassPathXmlApplicationContext("Beans.xml");

HelloWorld obj = (HelloWorld) context.getBean("helloWorld");

obj.getMessage();
}
}

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<bean id="helloWorld" class="com.tutorialspoint.HelloWorld">
<property name="message" value="Hello World!"/>
</bean>

</beans>



So well structured separating the class with what you want to do in the code. Having a main class to actually execute the code and having xml to assign unique numbers to control how objects are created. This is perfect for when you have medium to large applications to organize and maintain your code. Object Oriented Java Programming is the best programming style out there
>>
>>55715537
A torrent magnet link indexer built with Elixir and Phoenix framework.

Anyone can host it and start a search engine for torrents.
>>
>>55715843
i guess u use python2
>>
>>55716510
in C++ it's twice the time to read others' code
>>
>>55716483
All you have to do is make one change in a class if you decide you want to modify it and your whole code will work. You also can reuse multiple classes you wrote for different applications. OOP is clearly more superior for it's maintainability and allows for multiple people to work on it with ease.
>>
>>55716481
Last I checked, no HKTs, for one. So that means no generic Functor, Monad, Bifunctor, ..., to say nothing of things like MonadError.
>>
>>55716547
What the fuck am I reading
>>
>>55716514
Hows the jump from C to Java?

I wanna make fart apps soon
>>
>>55716514
Java and C# are great small languages

the two combined are smaller than C++ with STL
>>
>>55716583
They are so similar you will barely notice the differences

>>55716587
How are they small languages?
>>
>>55716583
it's comfy, it's great to know c before you learn java
>>
>>55716605
>How are they small languages?
they're just small, less complex, take less time to learn
>>
>>55716547
Riddle me this: how can I implement Applicative in Java, in such a way that I can get ap6 for free for a new type constructor if I give implementations of pure and ap for it? Because I don't want to have to ever implement ap6 more than once.
>>
>>55716143
>*and* prefix
I'd bet that a hash set of the string and all it's prefixes would consume less space. i.e.
t
te
tes
test
would be added to the set. Unless your aim is to enter and prefix and list possible full words.

>>55716199
Yes python is slow because it spend a lot of time parsing, and even more time doing redundant type checks. Most of those type checks happen in the C runtime and can't be JIT'd out. Julia is better in that regard. Really doubt the difference is 100x. And don't say Julia isn't about array and matrix processing, it has a fucking BLAS builtin and describes itself as a numerical computation language. It was built to compete with MATLAB, J, Python+numpy, etc. Hell the first versions were just modified Python+numpy with some additional libs.
>>
>>55716649
If you used a better language then you wouldn't have all those type checks in the runtime
>>
>>55716632
you can import it every time automatically using Netbeans configuring the settings to do so
>>
>>55716665
Holy kek
>>
>>55716450
>For ~80% of your code base, performance isn't too important
Webdev detected.

I'm over here, doing [spoiler]gamedev[/spoiler], and performance is something to worry about.
>>
>>55716661
Oh I mainly use C and Lua. But shitting on python for being slow really flags the 14 year olds.
>>
I'm looking for inspiration. Does anyone think a prgram that takes 4chan boards to search and keywords as an input, then searches for those keywords in the OPs of threads in the inputted boards, then downloads all the images of that thread is the keywords match, sound remotely interesting? If not can I get some more ideas?
>>
>>55716692
post your game nodev
>>
>>55716696
I shit on it because it's slow and you get no benefit for that slowness. It has no redeeming features. I'm not opposed to languages that are slow but give you something worthwhile in return.
>>
is Hacker news actually smart or are just they a bunch of cucks?

I went on there a few days ago and the latter seems true.
>>
>>55716649
>I'd bet that a hash set of the string and all it's prefixes would consume less space. i.e.

I'd be surprised if that was true, but I can try it.
>>
>>55716762
Fast development time. Obviously that won't matter to you if your time isn't worth anything.
>>
>>55716762
(You) are fucking retarded holy shit
>>
>>55716821
I can develop just as fast in better languages, if not faster due to better code reuse being available.
>>
just read about references/pointers

man I wish java had this, that and managing your own memory would be kinda cool

c++ is awesome

anyone (dis)agree ?
>>
>>55716848
C++ is also 30 years old and obsolete. You should use Rust, it's a modern systems-oriented programming language that emphasizes safety and zero-cost abstractions.
>>
>>55716858
>obsolete
kek
>>
>>55716858
I'll have a look at it, thanks for mentioning
>>
>>55716649
>And don't say Julia isn't about array and matrix processing
math is much more than matrix operations

of course it's gonna be backed up by BLAS like everything else, but it's much more than that
>>
>>55716858
There are zero Rust jobs it will be a waste of his time.
>>
>>55716858
>C++ is also 30 years old and obsolete.
No other language can do what C++ can do, Rust included. Any non-trivial program in Rust requires fighting the ownership system or using unsafe.
>>
File: 2088xdu.jpg (88KB, 1600x1600px) Image search: [Google]
2088xdu.jpg
88KB, 1600x1600px
>>55716858
>obsolete

HAHAHAHAHAHA
>>
>>55716818
Well think about the overhead of a trie. 27 slots each 8 bytes wide for each character, and I really doubt the longer words will have a use more than 1 or 2 slots deeper in the tree. That's a lot of wasted space. The hash set would have known overhead too O(n^2) ( divided by 2 but I don't want to upset the CS aspies) so you can reason about memory consumption. Tries have better asymptotic space efficiency, but you can decide which one's better if you know your input set.

>>55716858
C++ is nice because if you just treat it like C with classes and few other nice features (const correctness, constexpr, coroutines, etc.) you get a better version of C.
>>
>>55716881
No other language can do what Java does
>>
>>55716881
C can, just with more verbosity.
>>
>>55716841
that's because you're more familiar with those languages, development time in python is objectively pretty much the lowest you can get, all things being equal
>>
>>55716821
>Fast development time

congrats, now rewrite it in a real language because it's too slow.
>>
>>55716848
>man I wish java had this
no, you don't

be a happy java programmer and forget about c++
>>
>>55716916
>objectively
You best have some sources, anon
>>
>>55716858
c++ is definitely not obsolete, and although rust surely is a nicer language it's adoption rate is still low
>>
>>55716873
this, unfortunately
>>
>>55716848
Java has references, friends. In fact, variables can't be objects at all, only references.
>>
>>55716915
Can you implement RAII in C? Template metaprogramming? Do you have smart pointers in C? Actually half-decent random number generation?
>>
>>55716954
All the jobs are Java Java Java Linux sql then web dev Javascript php etc more importantly JAVA!
>>
>>55716908
Kek
>>
>>55716978
It's true name another language that has taken OOP to the extreme limits and made every single god damn thing an object . PRO TIP you can't
>>
>>55716900
I'm putting an entire dictionary (~100,000 words) into my trie. Most English words have a fair bit of overlap, so my intuition says that a trie will have better memory layout. I'll benchmark to be sure.

I always have the option of trying bitwise tries if I'm worried about memory.
>>
>>55716971
> Java Java Java
there are still plenty of other jobs though

there are even a bunch of well paying Perl jobs lol
>>
>>55716917
It usually isn't too slow for me. The only time I've run something that was too slow because of the language, and not because the algorithm I was using was shit, was probably back when I did use python and I kept running into a recursion limit. That was probably my only major gripe about the language.
>>
>>55716965
You can do them all by hand.
>>
What's a decent size for a token used for logging in?
>>
>>55716971
My friend has a Scala job, his boss gets mad if he uses Java
>>
>>55716848
java has references and why would you actually want to manually manage memory if you don't have to for performance?
>>
How do I into custom allocators?

I keep hearing that using the standard allocator means I'm a cuck and that my programs will run slowly. But how do I even start writing my own allocator? Any good resources out there?
>>
>>55716917
This.
>>
>>55717027
If you've admitted that performance isn't a concern, then why use Java when you could use Haskell or Scala or F#? They're all better than Java.
>>
>>55717015
You can't implement RAII in C.
>>
>>55717029
Unless you're seeing performance problems and you're sure they're being caused by the allocator, you don't need a custom one.
>>
>>55717039
Compatibility more Enterprises run on Java and it's Enterprises business applications than any other programming language get rekt noob
>>
>>55716930
use your brain, or name a non domain specific language with shorter development time than python
>>
>>55716873
>>55716954
https://www.quora.com/Will-Rust-be-as-popular-as-C++
Either Rust is going to get really popular, or other languages will adopt Rust's innovations.
>>
>>55717055
Scala runs on the JVM and can call Java code. There's no reason to use Java.
>>
>>55717056
html
>>
>>55717056
Haskell
Lisp
>>
>>55717039
harder to manage with large development teams, not as many developers available, not as many libraries etc, performance might still be a concern just not so much that you'd want to use c++, java is still quite fast compared to most other languages
>>
>>55717049
I would like to learn it for it's own sake. It seems like a useful skill to have in case it comes up.
>>
>>55717029
mmap memory (or VirtualAlloc if you're a wincuck), dole it out in whatever manner fits your use case best.

If you are using an allocator to allocate objects of a static size, then in your memory pool keep a metadata area that uses bits to represent if each slot in the pool is in use or not. Use that to dole out the closest slot.

If you are optimizing for spatial locality make an allocator that works by taking another pointer as an argument and returning a large enough space for the request as close as possible to the input pointer.

If you are dealing with really large pieces of unchanging or rarely changing memory just directly mmap exactly the space you need and avoid the housekeeping overhead.

Etc. etc. etc. Just analyze your requirements and write accordingly. Just have a thorough knowledge of mmap and data structures. That's really all you need.
>>
>>55717093
>Programming skills
>Useful

LaughingSystems.Exe
>>
>>55717090
Scala runs on the JVM so its performance is similar to Java. It takes a week at most to get someone writing Java-esque code in Scala, which will increase productivity. You can also use all your favorite Java libs in Scala.

I don't even like Scala. I just see no reason why you would use Java.
>>
>>55717029
>>55717093
It's just data-oriented design. You analyze how you allocate, access, and free your memory, and you write an allocator that organizes it around the results of that analysis.
>>
>>55717018
Fucking CIA nigger shit browser is dropping my 4096 chars cookie.
>>
>>55717079
Scala compile times are prohibitive, or so I've been told.
>>
>>55717029
>>55717143
Alternatively, you find a library with a bunch of custom allocators already made, and you do the reverse and tailor your code to match what the allocators are designed for.
>>
>>55717080
>not domain specific
>>55717086
for specific problems this is arguable but not for general purpose programming, designing and implementing a functional program takes more time than just typing it out procedurally in near pseudocode python, these languages also don't have all the high level libraries/frameworks that python does

I also found this in the meantime for somewhat of a source
http://www.connellybarnes.com/documents/language_productivity.pdf
>>
>>55717067
>there isn't even a decent GUI framework for Rust

I like it when glorified webshits state their opinions about a systems language
>>
>>55716762
>It has no redeeming features.

For you.
>>
>>55717216
burger king
>>
I can't believe you no programmer shit on Java daily when it is actually a pretty good language
>>
>>55716858
Go ahead and write a bootloader in rust for me.
Then I might consider it.
>>
File: bmw.jpg (39KB, 615x345px) Image search: [Google]
bmw.jpg
39KB, 615x345px
I'm at a bit of a pickle.

I have to make a LRU cache in C++, as direct 1 set map, 2 way set, 4 way set, etc (powers of 2 <=16). It basically reads in an initial file that tells it "this is a 1/2/4 way set with XByte Line Size, and Total Cache Size XByte", then it reads in another file with a list of addresses such as
Read: Size reference: Hex Address
R:4:58
R:4:40
R:4:04

My question is, How do I make a dynamic LRU on read that can be iterated through yet still contain a set size 1~16(base 2)? I was thinking some container of a container (like a list of unordered map or something) but ultimately unsure if this would even work.
>>
>>55716388
>If your company uses Python

like Google?
>>
Of course, we already knew that the python objector was going to be a functional weenie.
>>
>>55717232
thanks for explaining yourself I can definitely see your point
>>
>>55717245
so that's why their server farms are so humongous

shareholders should sue them for negligent wasting of money
>>
>>55717159
Depends how you use it. If you're just using it as a better Java, then compile times aren't >>55717159
that much worse than javac. If you're using it as a worse Haskell/Idris, then compile times are very long indeed.

(Why are you doing so many compiles?)
>>
>>55717308
>GOOGLE BTFO
>>
>>55717245
Google is indeed retarded. They came up with go.
>>
File: 3be.jpg (24KB, 600x463px) Image search: [Google]
3be.jpg
24KB, 600x463px
>>55717341
Go is actually one of the better langs out there you fuck
>>
>>55717202
You can write similar, imperative-style code in Haskell with do notation.
>>
>>55717357
Sure, if you like writing the same code repeatedly.
>>
>>55717244
Why the hell not just an array? This is a bit of a brag question though, I don't know why I'm responding.
>>
>>55717247
I'm a Haskell/Idris weenie. Don't lump me in with the ML/Erlang/LISP/F#/OCaml crowd. Those people disgust me.
>>
> Python

why can't you inline functions in python ?

function calls are slow as fuck

classes are even slower

large amount of code becomes after a while because the stupid indents are the only thing separating it

this wasn't designed by a programmer, I tell you
>>
>>55717357
>Generics are too hard for retards to understand
>I doesn't matter if those who aren't liter bottom-of-the-barrel retarded would have their productivity increased two-fold or more
>I don't understand generics or how to implement them -Rob "JUST" Pike
>>
>>55717436
But muh nump(t)y

Calling C from other languages is impossible
>>
>>55717369
oh yes i'm sure writing non-idiomatic haskell is the pinnacle of productivity
>>
>>55717451
HOW DARE YOU CRITICIZE THE MASTER IF HE SAYS WE DON'T NEED GENERICS THEN WE DON'T NEED THEM IF HE SAYS THUMBS ARE UNNECESSARY I WILL GLADLY LOP MINE OFF
>>
>>55717457
what
>>
>>55717486
Java doesn't even need them they are useless all programming languages should follow Java'
>>
>>55717457
>Calling C from other languages
why not call a real programmer to code in a real language ?

unless you're doing web dev or your programs are small or your programs look like a bunch of chained function calls, you shouldn't be using python
>>
File: GTK_vs_Qt.png (60KB, 500x286px) Image search: [Google]
GTK_vs_Qt.png
60KB, 500x286px
What GUI framework does /dpt/ recommend? It has to be cross-platform and be supported by major programming and scripting languages (or at least by C++ and Python).

I have a hard time deciding between GTK and QT.
Also, what GUI framework is currently the most prelevant in the software industry?
>>
>>55717503
>>55717503
In fact, let's do away with return values, you don't need them. You can write the return value somewhere and the caller can then retrieve it. Because returning a value is confusing
>>
>>55717436

>Python is slow
>he didn't fall for 64GB RAM meme
>>
File: rob.pike.jpg (19KB, 500x335px) Image search: [Google]
rob.pike.jpg
19KB, 500x335px
>>55717451
JUST
>>
>>55717531
ncurses
>>
>>55717451
it's not about not knowing how to use generics, it's about people (and especially devs fresh out of school) overusing them
also, pretty sure the lord has stated that it's a technical problem, not a social problem, that generics don't go well with simple type inference and structurally typed interfaces
>>
File: 1462054233183.gif (2MB, 500x500px) Image search: [Google]
1462054233183.gif
2MB, 500x500px
>>55717528
tthhiiss
>>
>>55717531
Qt
>>
>>55717555
I thought Google only took intelligent programmers? Guess I was wrong.
>>
>>55716961
How can you do this in Java?
void swap(int &a, int &b)
{
a ^= b ^= a ^= b;
}
>>
>>55717555
>simple type inference
Yeah, another issue. Shit is so useless I don't ever use it.
>structurally typed interfaces
Don't see how this and generics are mutually exclusive, or even make generics difficult. Interfaces already erase types and use reflection, so it's going to catch bad uses. Of course, there might be more runtime errors but this what you get with type erasure anyway.
What a pile of bad design.
>>
>>55717528
>unless you're doing web dev or your programs are small or your programs look like a bunch of chained function calls
those are actually the majority of programs though nowadays
>>
>>55717620
intelligent programmers are very likely to overengineer
just have a look at the haskell/scala/idris/coq crowd
the guys that make lots of that stuff are incredibly intelligent, but willing to sacrifice a lot of other useful things for type safety or statelessness.
>>
>>55717645
>Interfaces already erase types
Type erasure is a good thing, it gives parametricity, which makes code easier to reason about

>and use reflection
OH GOD WHY
>>
File: CER4aN5.jpg (158KB, 1440x1415px) Image search: [Google]
CER4aN5.jpg
158KB, 1440x1415px
Is visual studio still bloated as heck?

I'm thinking of switching to it from Code::Blocks because mingw has some problems (no std::to_string) for example and some libs don't have builds for it yet and I cba to build them myself.
>>
>>55717660
>other useful things
Like what?
>>
>>55717634
>implying that is faster using modern hardware
>>
>>55717667
https://golang.org/pkg/reflect/
I've had to use it several times before. Goodbye performance and safety.
>>
>>55717531
has anyone seen a GTK app that looked nice?
>>
RATE

check if string is palindrome
int isStrPalindrome(char *str)
{
int i,j;
for (i = 0, j = strlen(str) - 1; i < j; i++, j--)
if (str[i] != str[j])
return 0;
return 1;
}


check if number is palindrome
int isNumPalindrome(int x)
{
if (x < 0)
return 0;
int var = 1;
while(x/var >= 10)
var *= 10;
while(x != 0) {
int l = x / var;
int r = x % 10;
if (l != r)
return 0;
x = (x % var)/10;
var /= 100;
}
return 1;
}
>>
>>55717691
Xor swap is a meme. But you can't swap generically in Java. I think that's his point.
>>
>>55717696
Y'know, I wish language design would be left to people who know what they're doing

Sure, there would be fewer babby languages for the bootcampers, but that's not a bad thing
>>
>>55717667
interfaces don't use reflection, just ignore that retard.
http://research.swtch.com/interfaces
>>
>>55717725
12/11, top code, you should put it on your resume
>>
>>55717684
>Like what?

Good standard libraries.
>>
>>55717728
>go
>research
No
>>
>>55717728
interfaces and reflection is how you deal with generic routines. Or you can repeat yourself a lot.

Write a procedure to perform a union on two maps, preferring the first argument if keys collide.
>>
>>55717684
readability, implementation simplicity, for some of the langs i've named even the ability to do i/o (or making it incredibly difficult to use i/o), explicitness
>>
>>55717747
Third party libs more than make up for that.
>>
>>55717649
maybe, I just hate it that people think that they can use their python knowledge alone to develop something new and meaningful

to do that you need to learn an additional "real" language which even Python's own libraries use
>>
>>55717749
it's amazing that people are willing to ignore amazing people like russ cox that have written pretty damn good papers just because they've contributed to go

>>55717754
oh look he's moving the goalposts
>Interfaces already erase types and use reflection
interfaces DO NOT use reflection
that's what i replied to, not something else
the fact that you may have to use reflection to deal with the lack of generics has NOTHING to do with the implementation of interfaces
>>
>>55717755
Readability is subjective.

Implementation simplicity is only an issue if you're writing a compiler for the language. Are you writing such a compiler?

The IO type is not 'incredibly difficult'.

Please define 'explicitness'.
>>
>>55717812
I think it's a sad waste of somebody's talents and abilities to use them working on such a myopic language.
>>
>>55717713
GIMP
>>
File: Screenshot - 230716 - 17:25:30.png (35KB, 686x462px) Image search: [Google]
Screenshot - 230716 - 17:25:30.png
35KB, 686x462px
>>55717713
System load indicator
>>
>>55717725
Now recursively.
>>
>>55717911
Disgusting
>>
>>55717713
Every GTK application when used with a nice looking theme
>>
>>55717929
Lol
>>
>>55717831
>Readability is subjective.
sure, like almost everything else in software engineering we talk about
in addition to that subjectiveness there's also the fact that there's simply more people that can read C-like code (partially because of what they learned first as well, but that doesn't really matter because that's not gonna change for at least the next 20 years).

>Are you writing such a compiler?
no, i'm not, but the users of a simple implementation also benefit from that simple implementation: it's easier to improve its efficiency, add new abstractions and complexities (which is notably easier than removing existant complexity), easier to find bugs for many different platforms, ...

>The IO type is not 'incredibly difficult'.
i explicitly stated "some langs on that list". haskell is not as extreme as other langs on that list.

>Please define 'explicitness'
exceptions vs handling errors at every level
using type inference for everything vs explicitly annotating functions in haskell
something is explicit when a lot of the information i need when reading local code is already present and i don't have to jump around 20 levels of the callstack
http://www.johndcook.com/blog/2012/01/09/holographic-source-code/
>>
>>55717848
that's funny because all the original devs are incredibly talented people with a huge track record of amazingly useful stuff
iirc the original designers were ken thompson, rob pike and russ cox, all of which have contributed a bunch of widely used stuff to society

that being said, they have other priorities than the stateless/category theory circlejerk
>>
>>55717544
Guy looks like such a faggot.
>>
how hard is it to call a java class from Jython?
>>
What is the hardest/most complex subfield /industry for a programmers to work in?
>>
>>55717971
>>55718013
either way folks, i gotta go, maybe i'll read your replies some other time.
>>
>>55718262
Video game engine programming.

No, really.
>>
>>55716514
Not sure if trolling.

All that xml boilerplate for what? simple I/O? I'd rather do it with a tiny DDBB. The classical SQL query with a monstrosity. At least with SQL you learn a pretty usefull functional language.
>>
File: a28.jpg (32KB, 480x454px) Image search: [Google]
a28.jpg
32KB, 480x454px
>>55718302
uh thats what i wanna do when i get my masters inshallah

any tips? Im all in to learn the math/physics for it
>>
>>55718262
templatized OOP C++ is probably the hardest
>>
>>55718371
learn C++
learn DirectX/OpenGL
learn matrices/quaternions
learn how to manage memory well
above all, be a good programmer
>>
>>55718083
also why can't I import shit that's in /usr/share/java/ ?
>>
>>55717777

Allegedly. For that, you need large communities.
>>
>>55718371
Dont do it professionally, it is hell. By all means do it as a hobby, but the vidya industry is hell. Get a comfy 9-5 that lets you enjoy your life the rest of the time.
>>
>>55718426
The Java community is one of the largest and has yet to write anything like lens. Java is inherently too limited.
>>
File: rob-pike-before-after-google.jpg (56KB, 508x400px) Image search: [Google]
rob-pike-before-after-google.jpg
56KB, 508x400px
>>55717544
>>
>>55718746
From autistic nerd to lead singer of a british rock band. An inspiration to us all.
>>
>>55718646
>comfy 9-5 that lets you enjoy your life the rest of the time
There's no such thing. Technology evolves and you need to keep up to stay employable as an expert especially when you're older and it's getting harder.
>>
>>55717531
Qt is pretty popular. The only thing I don't really like about it is the license for non-free software.
>>
>>55718820
That's fair. I try to experiment with new tech during my lunch hour, and on the train to and from work. Only stuff that interests me, though.
>>
File: 5f1.jpg (191KB, 1280x892px) Image search: [Google]
5f1.jpg
191KB, 1280x892px
What coding music does /dpt/ listen to?
>>
>>55715620
shes a maid yo
>>
>>55718959
White noise.
>>
>>55718959
Touhou, classical, russian
>>
IP ranges are documented, right?

How can I look up the range a specific IP address is in?
>>
>>55718959
https://www.youtube.com/watch?v=u5FyRZbqfeM
>>
File: 1441417058260.jpg (401KB, 802x609px) Image search: [Google]
1441417058260.jpg
401KB, 802x609px
>>55718746

If there was any doubt that Google was evil, Pike proves it.
>>
>>55718959
https://www.youtube.com/watch?v=0JQ0xnJyb0A
>>
>>55718997
>dithering
nnnnnggghh I'm so moist right now
>>
>>55718959
>>>/mu/ faggot
No derailing the thread
>>
>>55718989
xddd
>>
I wanna code something with somebody. I'm bored. Anything.
>>
Want to learn a language but I don't have Internet in my current housing. I can go to a Starbucks or something and download sme pdfs. Anyone know any good books?
>>
Time to make my own female personal assistant to keep track of tasks: http://responsivevoice.org/
>>
>>55719019
what the fuck is this shit
>>
>>55717660
>intelligent programmers are very likely to overengineer
>just have a look at the haskell/scala/idris/coq crowd
Those are language wankers, not programmers or computer scientists (even though they might have CS degree, it's being scientific that makes you a scientist).

What programs did these people make besides the compilers for their own languages? What innovative algorithms or data structures did they come up with that weren't slower and more convoluted ways of doing things people already knew how to do?
>>
>>55719287
>calling yourself a scientist like that's a good thing
/sci/ is this way: >>>/sci/
alternatively try: >>>/r/eddit
>>
>>55719287
You are a fucking retard.
>>
>>55718959
The avalanches
>>
its funny how when anyone posts real production c++ code this thread dies every time

guess youre all a bunch of script kiddies lol

more interested in the bants than the facts
>>
>>55719184
https://docs.google.com/file/d/0B9Z7mcoZscczMzNjMjZjOTItMTRjNC00MGE4LTliMGYtOTNkZmYyNTFjOGJj/edit
>>
>>55719428
Implying C++ is impressive.
>>
>>55719196
this is great, now i can listen to my Juicy by biggie smalls in korean lady voice
>>
>>55719428
>production code must inherently be shitty
Only in C++ land, where everybody is a masochist
>>
>>55719019
damn that was neat
>>
>>55719502
why would you think its impressive? or are you paralyzed by expressive power?

script kiddies cant deal with a low level languages

>whats a symbol
>whats a calling convetion

stop calling yourselves programmers
>>
>>55719022

Thanks. I did it meself.
>>
>>55719573
C++ coder at h(er|is) best. You're cute anon.
>>
>>55719196
Why does it have to be java script?
>>
>>55719591
baka
>>
>>55719573
I know what calling conventions are, that's why I never want to have to think about them.

I get that you think you're an Uber h4x3r for using the lowest-level language you can tolerate, but you're kidding yourself because you're not writing asm. You're the script kiddie, kiddo.
>>
>>55719623
heard of the -S flag? guy i have to read the emitted machine code because the standards board and compiler writers are literally sadistic greybeards

but thats any lang
>>
>>55719658
>wtf im writing lol

sorry
>>
>>55719658
Yes, I have. It's a sad day when I have to use it.
>>
How do I make codeblocks use makefiles (make or cmake) instead of its own project files for building?
>>
>>55719722
you literally want to go out of your way to do more work for yourself?
the fuck is wrong with you
>>
>>55719732
No, I want it to save the project as a makefile so I can compile it without the IDE.
>>
>>55719747
why
>>
>>55719722
>>55719732
>>55719747
god IDEs are trash


((unless you stick to a single ecosystem))
>>
>>55719747
Just use emacs anon.
>>
>>55719783
>Post a Reply
(cont.) how is CLion btw? im on mac os and getting real tired of makefile janitoring et cetera
>>
>>55717244
Why are you making a cache in C++ and not an HDL like SystemVerilog? I've made a simple proc 5-stage proc w/ branch pred. and with an l1/l2 cache, I cannot image why you would do it in C++.

Anyway, I can prob. answer your question if you give me a few more details. LRU is a replacement policy when you need to evict a (dirty) cache line, are you saying you want to read in some cache parameters and set up an LRU based on those? Are you looking for pseudo LRU or a true LRU?
>>
>>55719167
Alright lets code a Java business application together and make money
>>
File: 1469270773518.png (35KB, 1366x768px) Image search: [Google]
1469270773518.png
35KB, 1366x768px
>>55715537
This image is from previous dpt thread. I have autism + ADD, therefore have a hard time concentrating. How do I set up these bracket alignments in vim?
>>
>>55719926
>4 spaces indentation
How to spot noobs.
>>
>>55719428
>real production c++
that's just normal C++ with lots of &s and consts, mutables, etc

basically, you double the size of your code with that shit and extra code for "readability" and that's your "production c++"
>>
>>55715537
Python beginner here. I'm stuck.

#!/usr/bin/python

print """
Script to automaticaly SSH into machine and taking action(s) afterwards."""

print """
Please enter data."""

IP = raw_input("""
IP: """)
user = raw_input(""" Username: """)
password = raw_input(""" Password: """)

import os

print """
Pinging %s to check if up and reachable.
""" % (IP)

response = os.system("ping -c 10 " + IP)

if response == 0:
print """
%s is up and reachable!""" % (IP)
else:
print """
%s is down or unreachable!""" % (IP)

print """
Connecting to %s as %s.
""" % (IP, user)
#
# import pxssh
# s = pxssh.pxssh()
# if not s.login (IP, user, password):
# print "SSH session failed on login."
# print str(s)
# else:
# print """
# SSH session login successful."""
#
action = raw_input("""
What action to take next (help for options): """)

if action == "help":
print """
'help' for options
'email' to send IP of machine per email
'status' to get status of machine"""

#
# s.sendline ('python ~/scripts/sending_ip.py')
#
# print """
# E-Mail has been send."""
#
# s.logout()
#
# print """
# SSH session logout successful.
#
# """
>>
>>55717670
Update your mingw version, Compiler != IDE.
>>
>>55719817
uh whats the domain here? some hardware description crap?
legimite curious
>>
File: 4smart.png (103KB, 1327x453px) Image search: [Google]
4smart.png
103KB, 1327x453px
Just wrote a program where you input a list of keywords and a list of boards on 4chan; the program then checks if any of your keywords are in any thread in any of the boards you listed, if it is, it will download every image from the thread. Can anyone tell me if it works for them too? It's in python

All you have to do is change the keywords and boards lists (if you want) and then just run the program.

http://pastebin.com/aLM06eFG
>>
>>55718302
Really? I write OpenGL/C++ for a living and I'll be damned if this is as hard as it gets. Matrices and quaternions are babby tier, anyone can find some dusty linear algebra book from a library.
>>
I'm looking for something as lightweight as sublime with similar features but I want it to be open source
>>
>>55720208
>CS
>Ability for actual math
pick one
>>
File: 1433093281385.jpg (53KB, 1280x720px) Image search: [Google]
1433093281385.jpg
53KB, 1280x720px
>mfw pointers
>>
reminder:

https://youtu.be/55P-UHdZ7WI
>>
Can I use .h as header files for .cpp files? Or should I use .hpp?
>>
>>55720329
Yes you can.
>>
>>55718959
https://www.youtube.com/watch?v=xF0-LGoXtaw
>>
>>55720345
What's the difference and which is preferred?
>>
>>55720156
>feet

Truly awful fetish.
>>
>>55720361
No idea. Personally I use .h for C and .hpp for C++.
>>
>>55720346
oh my gof

>the c++ cult
>>
>>55720361
No difference, and it's just your preference, .hxx and .hh are an option too.
>>
>>55720156

So much random ass trailing white space to clean up...
>>
>>55720407
>>55720392
I guess .hpp makes most sense for .cpp files
>>
>>55720093
I don't know what you mean by domain. Do you mean HDL? It stands for Hardware Description Language. When you are designing/testing/researching hardware, it's imperative you make sure it works as you intend, both timing-wise and logically. You use it to 'program' physical constructs, like FSMs for control, ALUs, ect, without having to go and fabricate the device.
>>
>>55720361
>>55720392

yeah its completely arbitary
#include is just dumb text inclusion
.hpp is good but it doesnt matter

(i call offline files .inc such as those generated by tools as gnu gperf and ~proprietary~ tools)
>>
>>55720451
thank you

youre a nice person and i appreciate your helpfulness
>>
>>55720455
sorry this post is some esl euro jank shit
>>
>>55720329
I always use .h
>>
>>55720374
Kill yourself niggerlover.
>>
Is it worth switching to vim and are there any good frontends or should I just use it from terminal?
>>
>>55720508
vim is very powerful
id recommend learning it
theres a plug-in for your ide
modal editing is cool and good
>>
>>55720508
im also interested in this question. dont know if its worth using vim on linux
>>
NEW THREAD!

>>55720551
>>
>>55720538
No, emacs is superior.
>>
>>55720558
thank you hime
>>
>>55720558
> new thread at 306 replies
> animefag

you summerfags are annoying
>>
>>55720532
i have to express this point

being able to navigate through a file more succintly keeps you from developing a good few wrist ailments

t. carpal tunnel syndrome programmer
(good min 800mg ibuprofen per day)
>>
>>55720585
>esl jank again
>better i stop posting for tonite

sweet dreams happy cees
https://youtu.be/lTa8WoOVRbw
>>
>>55720027
Why are using three double quotes? That's for multi-line comments (or docstrings)
>>
>>55716422
I'm assuming you've never developed anything near enterprise level. Java isn't the end all but it's powerful and very good at what it does.
Thread posts: 316
Thread images: 23


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