Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,411 members, 7,954,630 topics. Date: Saturday, 21 September 2024 at 03:16 AM |
Nairaland Forum / Harryobas's Profile / Harryobas's Posts
(1) (2) (3) (4) (5) (6) (7) (8) (of 8 pages)
Programming / Election Administrator Smart Contract For Substrate Based Blockchain/parachain by harryobas: 12:34pm On Dec 04, 2022 |
Howdy folks, In my quest to learn Rust and Blockchain technology, I decided to build a proof of concept smart contract for nigerian partisan election administration using ink!. A rust embedded domain specific language (eDSL) for writing webassembly (wasm) smart contracts which can be deployed to a substrate based blockchain/parachain. This is similar to solidity for writing EVM smart contracts for onward deployment to the etherum blockchain. The election administrator smart contract aims to streamline the entire election administration process by providing the following core functionalities: 1. voter registration 2. Registration of political parties together with their candidate for elections 3. casting and recording of votes 4. voter accreditation 4. vote count and collation of election results The election administration domain presents one of the numerous use cases where blockchain technology really shines not only in terms of security and integrity of election data but also in the enablement of transparency and flexibility of the election process as well as drastically reducing the overall cost of administering nationwide partisan elections. A word on Rust: I have been learning and using rust for quite a while now and i must say i have fallen helplessly in love with this amazing language that came out of mozilla. Rust has a steep learning curve which is to be expected being a systems programming language and especially for developers coming from dynamic languages like Ruby and Python. This however should not discourage you from giving Rust a try just keep at it and don't give up and you will reap the benefits later down the line. Here is a link to the code repo on Github As this is just a proof of concept, i'm open to feedbacks, ideas, constructive critic and of course pull requests Happy Coding! |
Programming / Re: Why I Am Stepping Into Rust by harryobas: 8:36am On Jul 24, 2020 |
Dujardin: I think you have a point. In my opinion, the core design goals of a software-intensive system should greatly influence the choice of programming language. For example if your design goal is performance and safety then Rust can be a good choice. If you require high scalability and concurrency then a language like Elixir should be considered. 1 Like |
Programming / Yew Framework: Build Multi-threaded And Performant Web Front-end In Rust by harryobas: 9:42am On May 22, 2020 |
I have been doing Rust now for over 8 months and I'm absolutely loving it. Rust advertises itself as a multi-paradigm programming language focused on performance and safety and provides memory safety without using garbage collection (wikipedia). With this statement one might be fooled into thinking that the use cases for Rust are pretty hardcore such as operating systems, compilers/interpreters and bare-metal embedded systems to name but a few. However, Rust is super flexible to the extent that it can be used for console applications, desktop applications, web applications, andriod libraries, ios libraries, Dapps (i.e smart contracts that run on the blockchain) etc. Rust on the Web with WebAssembly - As mentioned above, Rust extends far beyond its system programming domain and can be made to run on the web as well using WebAssembly (wasm) which is a technology that enables Rust to run alongside JavaScript on the web. WebAssenbly is a language agnostic bytecode that runs at near native speed. Other languages such as C++ and TypeScript can also be compiled down to wasm. Rust however provides first-class support and mature tooling for wasm. Yew Framework - Yew (https://yew.rs/docs/) is a complete frontend web application building framework that allows you to write web applications in Rust that can access Web APIs and compile them into wasm so that they can be run on the web. It is inspired by the Elm and ReactJS projects. It also encapsulates actor-based message passing concurrency via web workers on the web. Yew uses the stdweb crate (crates refer to libraries in rust) internally to access DOM APIs. Here are some of the features/goodies provided by the framework: 1. It features a component-based framework which makes it easy to create interactive UIs. Developers who have experience with frameworks like React and Elm should feel quite at home when using Yew. 2. It has great performance by minimizing DOM API calls and by helping developers easily offload processing to background web workers. 3. It supports JavaScript interoperability, allowing developers to leverage NPM packages and integrate with existing JavaScript applications. Happy Coding! 1 Like |
Programming / Re: Why I Am Stepping Into Rust by harryobas: 5:25pm On Apr 04, 2020 |
InfinityFabric: Dude Its like you misunderstand my post in certain areas so let me correct you as follows: 1. I did not say Rust has a better C inter-op than C++ just merely pointed it out as one of its features. 2. Language syntax is a matter of personal taste. For me C++ syntax looks uglier than Rust syntax. But hey that's just my opinion 3. Segmentation faults are impossible by default unless you for example use raw pointers in unsafe block 4. Rust provides the concept of traits that serve the same purpose as templates in C++. Traits in my opinion are cleaner and less verbose than C++ templates. 1 Like |
Programming / Re: Why I Am Stepping Into Rust by harryobas: 6:05pm On Apr 01, 2020 |
Charleys: E no suppose concern you. Na public forum be this (i.e talk your own i talk my own). So abeg talk the one wey concern you 3 Likes |
Programming / Why I Am Stepping Into Rust by harryobas: 5:40pm On Apr 01, 2020 |
In the last couple of months, I have been actively learning Rust which is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety (http://www.rust-lang.org/). Having been working with a dynamically typed language in the last couple years (Ruby) which obviously have performance limitations. In my quest for wanting to build high performance applications/systems, I decided to look into compiled and statically typed languages. Some of the options I considered were: 1. C++ - Statically typed systems programming language with high performance. This seem to fit the profile of what I was looking for but the deal breaker for me was its complex syntax rules and overall challenging use. 2. Go – A statically typed, compiled programming language that compiles very fast but has a much slower runtime speed compared to C++ due mainly to the fact that memory management is provisioned using garbage collection which in turn hurts runtime performace. 3. Swift – Too apple-centric for my liking. I have been learning Rust for over 6 months now and here are some of the features/goodies of this amazing language that came out of Mozilla: 1. Fast like C with excellent C inter-op 2. Segmentation faults are impossible 3. Null-pointer dereferences are impossible 4. Buffer overflows are impossible 5. First class build system / documentation generator / code formatting 6. Rich, expressive type system 7. But unlike C++, the types are sane (e.g. std::string) Happy Coding 2 Likes |
Programming / A Case For Coffeescript by harryobas: 10:22am On Nov 11, 2019 |
It’s hard to imagine a new web application today that doesn’t make heavy use of JavaScript, but if you’re used to something like Ruby and Python, it feels like a significant step down to deal with JavaScript, more of a chore than a joy. Enter CoffeeScript: a pre-compiler that removes all the unnecessary verbosity of JavaScript and simply makes it a pleasure to write and read. For me personally, working with and learning CoffeeScript has been an absolute joy. It has made me a better JavaScripter by giving a much deeper overall understanding of JavaScript. While it is not a replacement for JavaScript(you still need to know your JavaScript), it definitely enables accelerated JavaScript development. Go, go, coffee! CoffeeScript rocks, CoffeeScript is awesome. Happy Coding! |
Programming / Programming != Software Development by harryobas: 11:01am On Sep 02, 2019 |
Most times when I engage people (both IT and non-IT inclined) in discussions about software development and programming, most of them get it twisted. and when I tell then that programming is only a part(an important part) of the entire software development process then they are like how? So here is the how: 1. Computer science vs Software engineering - Having a degree in computer science does not make you a professional software developer although you may take some programming courses. But the goal of computer science is not about professional software development. Software engineering, on the other hand, focuses more on software development from a professional point of view so in addition to taking programming courses you also take courses focused on processes, methods, and tools for engineering high-quality software. 2. Software process framework - A foundation of the complete software engineering process. Software process framework includes five framework activities that are applicable to all software projects namely communication, planning, modeling, construction, and deployment with programming/coding falling under the construction activity. 1 Like |
Programming / Re: Learn Rust - Build Fast, Safe And Concurrent Programs Without Tears by harryobas: 3:03pm On Jul 15, 2019 |
nybol: With regards to performance, Rust is very much faster than Java as it compiles directly to machine code (no bytecode) Furthermore, the Rust compiler does not utilize resource hungry garbage collector (GC). |
Programming / Learn Rust - Build Fast, Safe And Concurrent Programs Without Tears by harryobas: 11:38am On Jul 15, 2019 |
Rust is a systems programing language that compiles directly to machine code (no bytecode or intermediate language). With execution speed comparable to C/C++. Rust is a relatively new language (first stable version released in 2015) that has gained a lot of traction very quickly. Its use cases are pretty hardcore: operating systems, device drivers and embedded systems that might not even have an operating system. However, it's actually a very pleasant language to write normal application code in as well. The big difference from C and C++ is that Rust is safe by default; all memory accesses are checked. It is not possible to corrupt memory by accident. The unifying principles behind Rust are: 1. strictly enforcing safe borrowing of data. 2. functions, methods and closures to operate on data. 3. tuples, structs and enums to aggregate data. 4. pattern matching to select and destructure data 5. traits to define behavior on data On a personal note, I think Rust is super cool and a very good alternative to C/C++ compared Languages like Go or Swift. Rust is awesome and Rust really rocks. Happy Coding! |
Programming / Don't Be A Framework-infected Programmer by harryobas: 12:32pm On Jul 12, 2019 |
Howdy folks, This is not meant to be a rant but I just thought it would be nice to point out this pitfall so that both inexperienced, as well as upcoming developers, can get a heads up. Time and time again I come across programmers who are "framework-infected". That is their knowledge of a particular language is centered around a framework such as Django, Ruby on Rails, React, Symfony, etc. While there is absolutely nothing wrong with having good knowledge of a specific framework, (after all, you would need this knowledge to land a job most times). But the danger for framework-infected programmers is that they attempt to learn a programming language through one of the popular frameworks for that language and I believe this to be a dangerous mistake. For example, I have come across programmers that know Jquery but don't really know JavaScript. Take Jquery away from them and they struggle to produce anything worthwhile in JavaScript. I think this trend of attempting to learn a programming language through a popular framework is motivated by the fact that people want to get productive very quickly and probably land a job in the shortest possible time. While this might pay off in the short term, it is however not sustainable. Framework-infected programmers are generally not very well grounded in the programming language of their adopted framework as their knowledge of the language is at best framework-centric. If you are an upcoming programmer, my advice is not to worry about any framework and focus on learning your language of choice properly(i.e both syntax and semantics) after which learning any framework based on your language of choice will be a breeze. After all, Django is still Python, Rails is still Ruby, Symfony is still PHP. Happy Coding! 3 Likes 2 Shares |
Programming / Ruby For Data Science by harryobas: 11:50am On Jul 08, 2019 |
Data Science is a new "sexy" buzzword without specific meaning but often used to substitute Statistics, Scientific Computing, Text and Data Mining and Visualization, Machine Learning, Data Processing, and Warehousing as well as Retrieval Algorithms of any kind. The general consensus when it comes to programming languages for data science is to utilize either Python, R or Julia. This, however, is not necessarily the case if you are a Rubyist. Here is a short list of some awesome data science tools for Rubyists: 1. Ruby vs. Python Ruby Python Daru Pandas NArray NumPy 2. Data Manipulation a. Kiba (https://github.com/thbar/kiba/) — lightweight Ruby ETL (Extract-Transform-Load) framework. b. jongleur (https://gitlab.com/RedFred7/Jongleur) — Workflow manager using DAG definitions to execute ETL tasks. 3. Distributed Computing a. ruby-spark (https://github.com/ondra-m/ruby-spark) — Ruby Interface to Apache Spark 1.x.x. b. JRuby-spark (https://github.com/chyh1990/jruby-spark) — JRuby based bindings for Apache Spark. 4. Data sets a. rdatasets (https://github.com/kojix2/rdatasets) — Data sets available in R via Rdatasets. b. red-datasets (https://github.com/red-data-tools/red-datasets) — Growing collection of publicly available data sets such as CIFAR-10, Iris, MNIST etc. 5. Statistics a. rb-gsl (https://github.com/blackwinter/rb-gsl) — Ruby interface to the GNU Scientific Library. b. simple_stats (https://github.com/brianhempel/simple_stats) — Enumerable patches for descriptive statistics. c. enumerable-statistics (https://github.com/mrkn/enumerable-statistics) — fast implementation of descriptive statistics for the Enumerable module. d. statsample (https://github.com/sciruby/statsample) — basic and advanced statistics for Ruby e. statsample-glm (https://github.com/sciruby/statsample-glm) — extension of statsample by Generalized Linear Models g. statsample-bivariate-extension (https://github.com/sciruby/statsample-bivariate-extension) — extension of statsample by Bivariate Correlations. h. distribution (https://github.com/sciruby/distribution) — probabilistic distributions and descriptive measures for them. i. statistics2 (https://github.com/abscondment/statistics2) — Normal, Chi-square, t- and F- probability distributions for Ruby. 6. Visualization a. matplotlib (https://github.com/mrkn/matplotlib.rb) — Ruby based wrapper around matplotlib. b. mathematical (https://github.com/gjtorikian/mathematical) — PNG and MathML renderings for your equations. c. daru-view (https://github.com/sciruby/daru-view) — daru-view is interactive plotting gem for web application (any Ruby web application framework like Rails/Sinatra/Nanoc/Hanami) & IRuby notebook. It is a plugin gem for daru. d. daru-plotly (https://github.com/genya0407/daru-plotly) — Plotly based visualization for Daru. 7. Interactive Computing a. iruby (https://github.com/sciruby/iruby) — Ruby kernel for Jupyter. b. iruby-rails (https://github.com/SciRuby/iruby-rails) — Integration library for IRuby and Rails. 8. Machine Learning https://github.com/arbox/machine-learning-with-ruby Happy Coding! |
Programming / Pair Programming - Learning In A Group Beats Studying On Your Own by harryobas: 8:33am On May 14, 2019 |
Pair programming, a common practice utilized mostly in agile software engineering work environments, is the practice of two programmers sharing one workstation/pc. At my current place of work, we learn in groups, which I like to think of as pair programming, which is two (or more) programmers learning from each other in one unified setting. With the rise of online education and the accessibility of development training videos and tutorials, getting started in programming is on the other side of a quick Google search. But learning the syntax of a programming language is only part of becoming a well-rounded developer. I strongly believe that the practice of pair programming can be hugely beneficial to any development team. it fosters collaboration within the team as developers learn from each other, share ideas, improve their overall coding skills and have fun. Any developers here who actually have the first-hand experience with pair programming? Would like to hear your thoughts and experiences. |
Programming / Time Complexity Guide For Developers - A Short Primer by harryobas: 2:04pm On Apr 16, 2019 |
As a developer, time complexity is one of the most interesting concepts you can learn from computer science, and you don’t need a degree to understand it! It’s interesting because it helps you see why a particular algorithm or program may be slow and what can you do to make it faster. Slow vs Fast Is sorting 1 million numbers in 150ms (milliseconds) slow or fast? I think that’s pretty fast, but this is not the question that time complexity is trying to answer. We want to know how an algorithm is going to perform as the “input size” grows. When we talk about “input size” we are talking about the arguments for the function or method. If a method takes one string as an argument then that’s the input, and the string’s length is the input size. Big O Notation With Big O notation we can classify algorithms according to their performance. Some examples of this notation are shown below: 1. O(1) - In this case, O(1) represents a “constant time” algorithm. That means that the algorithm will always take the same time to finish its work, regardless of how much work it has to do. 2. O(n) - In this case, O(n) represents "linear time". Where “n” represents the size of the input (string size, array size, etc). This means that the algorithm will finish its work in a 1:1 relation to input size, so doubling the input size will also double the time it takes to complete the work. Happy Coding |
Programming / Elixum - Permissionless And Open Source Blockchain Platform Written In Elixir by harryobas: 2:03pm On Mar 27, 2019 |
Elixium (https://github.com/ElixiumNetwork) is a decentralized, blockchain based DLT (distributed ledger technology) application network with an automated consensus mechanism that utilizes the proof of work (PoW) algorithm. Elixium is still in the early stages but looks very promising mainly due to its support for language agnostic smart contract development. Engineers will no longer be tied down to learning a new language like Solidity or migrating to a language like Javascript, they'll be able to use their existing toolset and create decentralized applications with any language that compiles to WebAssembly. They'll be able to use their C, C++, Python, Go, Ruby, and any other language they're already familiar with. Some of the other features provided by the Elixum DLT design include: 1. Smooth token emission similar to the CryptoNote token emission algorithm. 2. Memory-hardened PoW algorithm that discourages the usage of FPGA/ASICs. 3. TCP-layer zero knowledge peer authentication for secure communication. 4. Low target block solve time. A case for Elixir Elixir is a language built with Erlang, and Erlang powers the entire telecom industry. This is the language that supports the infrastructure of our mobile phone networks. It was built by Ericcson in 1986 for the purposes of being distributed, fault tolerant, and to have support for uninterruptable applications. Erlang was reported to have been used in production systems with a maximum downtime of 32 milliseconds per year. This is a great fit for blockchain, as it is a system that needs to be extremely fault tolerant and available. Furthermore, Erlang and by extension Elixir has native concurrency primitives based on the actor concurrency model baked into the language. Concurrency is at the core of the language - processes are cheap and you can run hundreds of thousands to even millions of processes easily. This allows for huge performance improvements and parallelization. Erlang has built in error containment and fault tolerance. It has a really cool feature called a Supervisor, which automatically restarts failed processes. Erlang also features hot code swapping functionality -- allowing the software to be updated without interrupting the program. This makes writing distributed applications easy. According to the Elixum DLT design documentation, because of Erlang's large support for concurrency, Elixium is able to mitigate pain points in blockchain by massively parallelizing things like transaction processing. Whenever a new transaction comes in, it's cheap and easy to spin up a separate process to validate and relay that transaction. Also, as a result of the fault tolerance built into Erlang, and by extension Elixir, Elixium is able to have self-healing nodes. If a node encounters an error during runtime, rather than crashing and waiting for the maintainer of the node to notice and restart the node, it is able to restart itself and not lose context of its current operations, which adds to the total uptime and security of the overall network. |
Programming / Re: The Difference: Framework Versus Library by harryobas: 3:28pm On Feb 13, 2019 |
Olumyco: I would define a framework as a reusable chunk of architecture and a library as a collection of related classes or functions(depending on adopted programming paradigm) that are reusable across applications. |
Programming / Re: Gain Confidence In Your Code Through Testing by harryobas: 10:35am On Feb 11, 2019 |
vezycash: From the Google definition of testing you have presented, you can see clearly that testing and debugging are completely different activities and debugging is not a subset of testing as you claim. Testing is focused on finding bugs and does not attempt to fix them. Debugging is focused on fixing bugs. But bugs have to be discovered before they can be fixed which is the goal testing(i.e to find bugs) |
Programming / Re: Gain Confidence In Your Code Through Testing by harryobas: 6:53am On Feb 11, 2019 |
vezycash: Dude you seem to miss the different objectives/goals of testing and debugging. They both have complimentary but different purpose. Testing is the process of finding bugs or errors in a software product. Debugging on the other hand, is the process of fixing bugs found during testing |
Programming / Gain Confidence In Your Code Through Testing by harryobas: 4:14pm On Feb 08, 2019 |
The longer you program, the greater the quantity and variety of bugs you have seen. With more experience as a programmer, you realize that in systems as complex as software applications, bugs are inevitable. For the inexperienced developer/programmer code is prima facie flawless. But experienced programmers know there are flaws, and only worry how many. The situation may seem dire, but we are not without hope. We have ways to mitigate, minimize, and even prevent bugs. Among these techniques are documentation, proper software design, and software testing. While all of these options are important, I think the most neglected among new programmers is software testing. To effectively test software in my experience and opinion, test cases will have to provisioned at 3 levels namely: 1. Software requirements level (i.e use cases or user stories) - Test cases at this level is focused on acceptance tests which test mainly functional requirements but depending on the application domain it is also possible have test cases for contextual requirements or ilities such as performance, availability and security to name but a few. 2. Software architecture level - Test cases at this level is focused on integration tests which test the interaction between a software's internal components. 3. Software component-level design - Test cases at this level is focused on unit tests which test a single component of your software this could either be a class or function depending on your adopted programming paradigm. All of these types of test cases are important, but component-level design test cases are of particular interest to programmers and developers are like as they are inherently developer-centric, focusing on unit tests which test a single components functionality independent of external dependencies. So why should you write unit tests as a developer? - You should write unit tests, because they will give you the confidence to build new features, fix bugs, and release new versions of your software. Write and execute thorough tests, and you can ship with confidence. |
Programming / Ruboto - The Andriod App Development Framework For Rubyists by harryobas: 8:42pm On Nov 25, 2018 |
Are you a Rubyist? Do you want to develop mobile apps for andriod but would rather use Ruby instead? Then check out Ruboto the Andriod app development framework for Rubyists. Its free, open source and available on github Ruboto (JRuby on Android) is a platform for developing full stand-alone apps for Android using the Ruby language and libraries. It includes support libraries and generators for creating projects, classes, tests, and more. The complete APIs of Android, Java, and Ruby are available to you using the Ruby language. Happy Coding |
Programming / Coffeescript: Javascript That’s Easy On The Eyes by harryobas: 11:06am On Sep 03, 2018 |
Howdy folks, Write a lot of JavaScript? Love clean code? Then you need to check out CoffeeScript (https://coffeescript.org/), a nifty little languages that compiles into JavaScript. Why would you want to learn some new language and spend time compiling? Because, in exchange, you get some of the best syntactic features from Ruby, Groovy and Python and your code becomes more readable, concise, DRY and easier to maintain. Happy Coding |
Programming / Don't Neglect The Importance of Domain Knowledge by harryobas: 12:29pm On Aug 09, 2018 |
As developers we all love to write code and we are always looking to improve our coding skills. However, in order to develop professional real world applications, i strongly believe that technical knowledge alone is not enough. Every application you develop or are planing to develop is either explicitly or implicitly targeted at a domain such as banking, retail, aviation etc. As developers we are obviously not domain experts and cannot for example claim to have the same level of banking knowledge as a banker/banking professional. But as software engineers/developers we need to have basic knowledge of the various entities/concepts of our application domain to enable us better understand application requirements which in turn enables us to produce good reliable software artifacts such as specs, architecture and code. All too often i come across developers who tend to focus solely on technical aspects(i.e languages and frameworks) neglecting domain knowledge and i believe this is an error. Now i am not saying technical knowledge is not important but as developers we should not neglect the importance of domain knowledge. KNOW YOUR DOMAIN |
Programming / Require English - A Ruby Tip For Rubyists by harryobas: 7:58am On Jul 27, 2018 |
Howdy Did you know that Ruby puts the currently-processing exception into a global variable: $!? There are lots of cryptically-named globals. Fortunately we can make them use more sensible names by requiring the English module. Here are a few of the variables that the English module brings into scope. $ERROR_INFO $! $ERROR_POSITION $@ $FIELD_SEPARATOR $; $OFS $, $PROCESS_ID $$ $CHILD_STATUS $? $MATCH $& Happy Coding
|
Programming / Why You Should Write Tests? by harryobas: 10:31am On Jul 26, 2018 |
Why Should You Write Tests? Here’s why: It builds a safety net against errors (especially useful for refactoring) If you don’t have a test suite then you don’t want to touch your code, because of the fear of something breaking… …having tests increases your confidence! It helps document your code Your tests describe what your application should be doing. It gives you a feedback loop When you are doing TDD you get a feedback loop that tells you what to focus on next, useful if you get distracted easily. It helps you make sure your code is producing the results you expect This one is important! If you are writing some complex logic, then you want to make sure it’s working with many different inputs & not just with one example you came up with. Tests can help you uncover corner cases & document them. It helps you land a developer job Most job applications will appreciate your testing skills, increasing your chances of landing the job. |
Programming / Working With Fractions In Ruby by harryobas: 9:28am On May 18, 2018 |
Developers typically represent numbers as either integers or floats. But occasionally, neither of these is a good choice. What if we want to represent a number as an exact fraction like 2/3 instead of an approximation like 0.667? In that case, our best choice is neither an integer, nor a float, but a "rational." Here's how rationals work in Ruby: You can create rational numbers in many ways 3/2r 1.5.to_r "3/2".to_r Rational(3, 2) Rational math produces rational results 2/3r + 1/3r => (1/1) 2/3r * 1/3r => (2/9) 2/3r / 1/3r => (2/1) Happy coding |
Programming / Naming Variables by harryobas: 12:17pm On Apr 16, 2018 |
Every time you are writing code you are naming things. When you read code that you or someone else has written, you are gaining most of your understanding about that code from the names of things in that code. Most of the time I can accurately predict a developer’s skill level by looking at how they have named methods, variables and classes in code they have written. A developer who lacks the ability to give good names to concepts and data in their code is like a mute translator. It doesn’t matter if you can understand something, if you can’t adequately explain it, the moment it leaves your head it is gone. The best way to improve this skill is to always put it into practice. I’ll often rename things in code I am just reading to get an understanding. As I start to understand what a method is doing, I’ll change the name to match that understanding. I’ll do this while I am reading the code, not even making any logic changes to it. The more you focus on giving good names to things, the better at it you will become. This is also the most visible thing about your code. It is hard to know if your code is correct or efficient by looking at it, but if I read it and can understand it, I am going to assume you know what you are doing. |
Programming / Functional Programming, Erlang And Elixir - A Brief Primer by harryobas: 9:47am On Feb 03, 2018 |
Functional Programming In contrast with object-oriented programming (OOP), functional programming (FP)—as the name implies—emphasizes functions over data. The basis for OOP is to define specialized data structures, classes, for the problem at hand and then tie functions to those structures in the form of methods. FP prefers more generic data structures and smarter functions that can operate on those structures. This along with the ability to treat functions as data and use them as input to other functions give a different kind of flexibility as compared to OOP. Either paradigm can be used to emulate the other, making them basically equivalent. Certain problems, however, might be easier to reason about and solve by using one or the other. “Traditional” OOP languages still rank high in various programming language popularity indices. This might change however, if the current trend towards functional programming continues. With Clojure and Scala on the JVM and F♯ on the .NET platform, interest in FP is definitely on the rise. Through the addition of lambdas—anonymous functions—to both Java and C++ FP concepts are creeping into OOP languages as well. Hybrid or multi-paradigm languages seem to be the next stage in the evolution of programming languages. Important FP Concepts All concepts mentioned below can be found in OOP as well, but they are generally more prominent in FP languages. a. Higher order functions - A function that take other functions as input. An example is map that takes a list and a function as input, applies the function to each item in the list, and returns a list of the results. This is equivalent to an imperative for-loop that steps through each item in a list and applies a transformation. b. Lambda - An anonymous function, often created on the spot as input to a higher order function. A convenient way to pass code around as data. c. Recursion - Often the only way to perform iteration, or looping, in a functional language. Many language implementations provide tail call optimization, or tail recursion, which enables an iterative process to be written recursively while still only requiring constant memory. This also allows endless loops to be written in a recursive fashion. Some languages, for example Scheme mandate tail call optimization for all implementations. d. Immutability - Once a value has been created, it cannot be changed by any means. The member data of OOP objects is often mutable, which means that querying the same object for its state at different times can give different answers. An immutable value on the other hand always guarantees the same answer. To “change” an immutable value, a copy must be made and the change performed as a transformation during the copy operation. Immutable data solves some of the problems related to concurrent programming, but it is not a silver bullet. Erlang The Erlang programming language has seen a relatively recent increase in popularity thanks to the likes of WhatsApp and Klarna. The language was developed at Ericsson in 1986 for use in telephone exchange systems. This specialized use case made certain properties highly desirable: concurrency, asynchronous message passing, fault tolerance, and live updating of running systems. Erlang was designed with these properties in mind, which led to a language capable of creating highly reliable systems. Erlang began its life as a proprietary language, but was released as open source in 1998. The same features that made it a good fit for telephone exchanges also turned out to be useful for other massively concurrent systems. The WhatsApp messaging system, written in Erlang, can handle over two million concurrent TCP connections. Language Features Erlang code is compiled to bytecode and runs on a virtual machine. The de facto standard implementation is called BEAM (Bogdan/Björn’s Erlang Abstract Machine). The sequential parts of Erlang are functional. All values and variables are immutable and recursion is the only loop construct. It is dynamically typed and garbage collected. Erlang has language level support for spawning concurrent processes (threads) within the virtual machine. These processes have no shared memory and can only communicate by sending and receiving asynchronous messages. This communication works the same way for communication between networked Erlang nodes running on different computers, making distribution completely transparent. Processes are extremely lightweight and running upwards of 30000 concurrent processes is not uncommon. Elixir Elixir is a dynamic, functional programming language created by José Valim. It targets the Erlang virtual machine (BEAM), which gives it the same properties of scalability, distribution and fault-tolerance that has made Erlang famous. The language is very young, the first commit. in the Git repository is dated January 9th 2011 and version 1.0 was released as recently as September 18th 2014. Thanks to a solid foundation in form of the Erlang ecosystem and the addition of tools for building, testing, package management, and documentation, Elixir already feels very polished and developer friendly. With Valim being a prolific Rubyist and one of the top contributors to Ruby on Rails it is not unexpected that Elixir’s syntax is heavily inspired by Ruby. Parenthesis on function calls can be omitted and blocks are delineated with do...end The general structure still stays close to Erlang, making it easy to move between the two languages. On top of that Elixir adds macros in the lisp sense, which allows for advanced metaprogramming, and protocols for polymorphism. Another smaller addition that nonetheless can make Elixir code look quite different from Erlang is the pipe operator |>. The expression foo |> bar means to evaluate foo and add the result from that as the first argument to the function call bar. This makes it easier to chain function calls in a way similar to object-oriented method chains. Concurrency Like Erlang, Elixir provides concurrency through processes and message passing. The default position of no shared state between processes removes a whole class of problems traditionally associated with concurrent computing. No shared state means no need for explicit locking through semaphores or other means. Unfortunately, problems such as deadlock and livelock still persists. Message passing also lends itself well to an asynchronous programming style. This does however mean that synchronous communication is harder, necessitating the creation of custom message protocols. References http://elixir-lang.org/ https://redmonk.com/sogrady/2015/01/14/language-rankings-1-15/ http://www.langpop.com/ http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html http://clojure.org/ http://www.scala-lang.org/ http://fsharp.org/ http://joeduffyblog.com/2010/07/11/thoughts-on-immutability-and-concurrency/ https://blog.whatsapp.com/196/1-million-is-so-2011 http://engineering.klarna.com/article/klarna-engineering-insights/ http://www.erlang.se/publications/bjarnelic.pdf https://pragprog.com/articles/erlang 1 Like |
Programming / Currently Learning Elixir And I'm Loving It by harryobas: 12:58am On Jan 11, 2018 |
What is Elixir? Elixir was first introduced in 2012. It is a general-purpose, functional language designed for building scalable and maintainable applications. Created by Jose Valim at Plataformatec. The language complies with the bytecode seen on the Erlang VM (also known as BEAM). Its syntax is similar to and often compared to Ruby. Scalability Elixir code runs inside lightweight, isolated processes, which allows for thousands of processes to run concurrently in the same machine. This, in turn, allows for vertical scaling and uses all of a machine’s CPU cores as efficiently as possible. These processes are also able to communicate with other processes running on different machines on the same network, providing a solid foundation for distribution and allowing for horizontal scaling. Fault tolerance Running into issues with running software is inevitable, but Elixir’s fault-tolerant system can make the process a little less painful. It provides ‘supervisors’ that you can program with descriptions of how to restart certain parts of a system when things fail. These parts will then revert to a ‘known, initial state’, which is guaranteed to work. Functional Programming Elixir allows you to write short, fast and maintainable code. Pattern matching allows developers to destructure data and access its contents. When mixed with guards, this allows you to match and assert conditions for code to execute. Who is adopting Elixir, and why? Social media giants such as Pinterest and Bleacher Report have switched over to Elixir, often with the Phoenix framework. Bleacher Report, for example, said that the switch from Ruby on Rails to Elixir has led it to reduce its number of required servers from 150 to just five, and handle eight times more traffic. Elixir is generally seen as a superior choice for high-traffic systems, which is becoming an increasingly pressing issue for developers given that the number of internet users has tripled over the last decade. While Rails apps can respond in tens of hundreds of milliseconds to web requests, Elixir apps can respond in microseconds. The evolving needs of companies means that it is in the best interests of developers to consider developing greater fluency in Elixir programming. Doing so could truly give you an edge over other candidates. source: https://www.siliconrepublic.com/advice/elixir-programming-language-career |
Programming / Functional Programming Is Fun With Elixir by harryobas: 1:37pm On Jan 02, 2018 |
I'm currently playing around with Elixir which is a pure functional programming language with a Ruby-like syntax. In fact, it was designed by Jose Valim a well renowned Rubyist and member of the core Rails team so if you are a Rubyist or comfortable with Ruby syntax then you will feel right at home with elixir. According to Wikipedia, Elixir is a functional, concurrent, general-purpose programming language that runs on the Erlang virtual machine (BEAM). Elixir builds on top of Erlang and shares the same abstractions for building distributed, fault-tolerant applications. Elixir also provides a productive tooling and an extensible design. The latter is supported by compile-time metaprogramming with macros and polymorphism via protocols. It is a really fun language that makes functional programming enjoyable. Elixir is rapidly gaining momentum as one of the fastest growing programming languages. Companies are now using it in production and it is surprisingly mature. |
Programming / Re: Ruby Vs Go by harryobas: 11:49am On Jan 02, 2018 |
Ruby is a pure object oriented language while go is procedural. In terms of performance go is a clear winner in fact it was developed by google as a replacement for c so it is a compiled language while Ruby is interpreted. In terms of productivity Ruby is much better in fact the core design goal of Ruby is programmer happiness rather than performance. But if you want to improve performance for Ruby you can go with JRuby which is Ruby on the JVM. 1 Like |
(1) (2) (3) (4) (5) (6) (7) (8) (of 8 pages)
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 128 |